當前位置: 首頁>>代碼示例>>Python>>正文


Python DataFileElement.content_type方法代碼示例

本文整理匯總了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
開發者ID:msarahan,項目名稱:SMQTK,代碼行數:11,代碼來源:compute_many_descriptors.py

示例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
開發者ID:dhandeo,項目名稱:SMQTK,代碼行數:15,代碼來源:compute_many_descriptors.py

示例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)
開發者ID:Kitware,項目名稱:SMQTK,代碼行數:44,代碼來源:iqr_search.py

示例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)
開發者ID:Kitware,項目名稱:SMQTK,代碼行數:6,代碼來源:test_DataFileElement.py

示例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')
開發者ID:Kitware,項目名稱:SMQTK,代碼行數:5,代碼來源:test_DataFileElement.py

示例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")
開發者ID:msarahan,項目名稱:SMQTK,代碼行數:5,代碼來源:test_DataFileElement.py


注:本文中的smqtk.representation.data_element.file_element.DataFileElement.content_type方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。