本文整理汇总了Python中smqtk.representation.data_element.file_element.DataFileElement.content_type方法的典型用法代码示例。如果您正苦于以下问题:Python DataFileElement.content_type方法的具体用法?Python DataFileElement.content_type怎么用?Python DataFileElement.content_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类smqtk.representation.data_element.file_element.DataFileElement
的用法示例。
在下文中一共展示了DataFileElement.content_type方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: iter_valid_elements
# 需要导入模块: from smqtk.representation.data_element.file_element import DataFileElement [as 别名]
# 或者: from smqtk.representation.data_element.file_element.DataFileElement import content_type [as 别名]
def iter_valid_elements():
for fp in file_paths:
dfe = DataFileElement(fp)
ct = dfe.content_type()
if ct in generator.valid_content_types():
valid_file_paths[fp] = ct
yield dfe
else:
invalid_file_paths[fp] = ct
示例2: is_valid_element
# 需要导入模块: from smqtk.representation.data_element.file_element import DataFileElement [as 别名]
# 或者: from smqtk.representation.data_element.file_element.DataFileElement import content_type [as 别名]
def is_valid_element(fp):
dfe = DataFileElement(fp)
ct = dfe.content_type()
if ct in generator.valid_content_types():
if not check_image or test_image_load(dfe):
return dfe
else:
return None
else:
log.debug("Skipping file (invalid content) type for "
"descriptor generator (fp='%s', ct=%s)",
fp, ct)
return None
示例3: iqr_ingest_file
# 需要导入模块: from smqtk.representation.data_element.file_element import DataFileElement [as 别名]
# 或者: from smqtk.representation.data_element.file_element.DataFileElement import content_type [as 别名]
def iqr_ingest_file():
"""
Ingest the file with the given UID, getting the path from the
uploader.
:return: string of data/descriptor element's UUID
:rtype: str
"""
# TODO: Add status dict with a "GET" method branch for getting that
# status information.
fid = flask.request.form['fid']
sid = self.get_current_iqr_session()
self._log.debug("[%s::%s] Getting temporary filepath from "
"uploader module", sid, fid)
upload_filepath = self.mod_upload.get_path_for_id(fid)
self.mod_upload.clear_completed(fid)
self._log.debug("[%s::%s] Moving uploaded file",
sid, fid)
sess_upload = osp.join(self._iqr_work_dirs[sid],
osp.basename(upload_filepath))
os.rename(upload_filepath, sess_upload)
# Record uploaded data as user example data for this session.
upload_data = DataFileElement(sess_upload)
uuid = upload_data.uuid()
self._iqr_example_data[sid][uuid] = upload_data
# Extend session ingest -- modifying
self._log.debug("[%s::%s] Adding new data to session "
"external positives", sid, fid)
data_b64 = base64.b64encode(upload_data.get_bytes())
data_ct = upload_data.content_type()
r = self._iqr_service.post('add_external_pos', sid=sid,
base64=data_b64, content_type=data_ct)
r.raise_for_status()
return str(uuid)
示例4: test_content_type_explicit_type
# 需要导入模块: from smqtk.representation.data_element.file_element import DataFileElement [as 别名]
# 或者: from smqtk.representation.data_element.file_element.DataFileElement import content_type [as 别名]
def test_content_type_explicit_type(self):
ex_type = 'image/png'
d = DataFileElement('foo.txt', explicit_mimetype=ex_type)
self.assertEqual(d.content_type(), ex_type)
示例5: test_content_type
# 需要导入模块: from smqtk.representation.data_element.file_element import DataFileElement [as 别名]
# 或者: from smqtk.representation.data_element.file_element.DataFileElement import content_type [as 别名]
def test_content_type(self):
d = DataFileElement('foo.txt')
self.assertEqual(d.content_type(), 'text/plain')
示例6: test_content_type
# 需要导入模块: from smqtk.representation.data_element.file_element import DataFileElement [as 别名]
# 或者: from smqtk.representation.data_element.file_element.DataFileElement import content_type [as 别名]
def test_content_type(self):
d = DataFileElement("foo.txt")
ntools.assert_equal(d.content_type(), "text/plain")