Choose object type from content type.
500940
def choose_type(cls, content_type):
        """"""
        return cls.type_cls.SUBDIR if content_type in cls.subdir_types \
            else cls.type_cls.FILE
846842
def smart_content_type(self):
        """"""
        content_type = self.content_type
        if content_type in (None, '', 'application/octet-stream'):
            content_type, _ = mimetypes.guess_type(self.name)

        return content_type
1112660
def default(self, obj):
        """"""
        if isinstance(obj, BioCDocument):
            return encode_document(obj)
        if isinstance(obj, BioCCollection):
            return encode_collection(obj)
        raise TypeError(f'Object of type {obj.__class__.__name__} is not BioC XML serializable')
731952
def get_page_objects_by_ext_type(context, object_type):
    
    try:
        objects = context['page']['ext_content'][object_type]
    except KeyError:
        raise template.TemplateSyntaxError('wrong content type: {0:>s}'.format(object_type))
    return objects
1179466
def set_content_type (self):
        """"""
        if self.url:
            self.content_type = mimeutil.guess_mimetype(self.url, read=self.get_content)
        else:
            self.content_type = u""
817607
def get_content_object_url(self):
        """"""
        if (self.content_object and
            hasattr(self.content_object, 'get_absolute_url')):
            return self.content_object.get_absolute_url()

        return None
221149
def from_string(cls, id, format, raw_content, compressed=False,
                    encoded=False):
        """"""
        content = cls(id, format, compressed, encoded)
        content._raw_content = raw_content
        return content
808390
def content_type(self, value=None):
		
		content_type = self.normalize_name('Content-Type')
		if value is not None:
			self.replace_headers(content_type, value)
		if content_type in self.__headers.keys():
			return self.__headers[content_type][0]
708479
def ParseObjs(self, objs, type_names):
    """"""
    for obj in objs:
      for type_name in self._RDFTypes(type_names):
        if isinstance(obj, self._GetClass(type_name)):
          yield obj
1187398
def get_or_create_generic(self, content_object=None, **kwargs):
        
        if content_object:
            kwargs['content_type'] = ContentType.objects.get_for_model(
                content_object
            )
            kwargs['object_id'] = content_object.id

        return self.get_or_create(**kwargs)
732115
def content_type(self) -> ContentType:
        """"""
        return self._ctype if self._ctype else self.parent.content_type()
124741
def get_for_content_type(self, ct):
        """"""
        try:
            return json.loads(self.state)[ct.app_label][ct.model]
        except KeyError:
            return None
1277502
def get_content_type(obj, field_name=False):
    
    content_type = ContentType.objects.get_for_model(obj)
    if field_name:
        return getattr(content_type, field_name, '')
    return content_type
301485
def filter_generic(self, content_object=None, **kwargs):
        
        if content_object:
            kwargs['content_type'] = ContentType.objects.get_for_model(
                content_object
            )
            kwargs['object_id'] = content_object.id

        return self.filter(**kwargs)
1180653
def fromstring(text, schema=None):
    """"""
    if schema:
        parser = objectify.makeparser(schema = schema.schema)
        return objectify.fromstring(text, parser=parser)
    else:
        return objectify.fromstring(text)
755972
def content_type(self, request=None, response=None):
        """"""
        if callable(self.outputs.content_type):
            return self.outputs.content_type(request=request, response=response)
        else:
            return self.outputs.content_type
712227
def select_header_content_type(self, content_types):
        
        if not content_types:
            return 'application/json'

        content_types = [x.lower() for x in content_types]

        if 'application/json' in content_types or '*/*' in content_types:
            return 'application/json'
        else:
            return content_types[0]