当前位置: 首页>>代码示例>>Python>>正文


Python LibraryLocator.from_string方法代码示例

本文整理汇总了Python中opaque_keys.edx.locator.LibraryLocator.from_string方法的典型用法代码示例。如果您正苦于以下问题:Python LibraryLocator.from_string方法的具体用法?Python LibraryLocator.from_string怎么用?Python LibraryLocator.from_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在opaque_keys.edx.locator.LibraryLocator的用法示例。


在下文中一共展示了LibraryLocator.from_string方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_from_json_studio_editor_style

# 需要导入模块: from opaque_keys.edx.locator import LibraryLocator [as 别名]
# 或者: from opaque_keys.edx.locator.LibraryLocator import from_string [as 别名]
 def test_from_json_studio_editor_style(self):
     """
     Test that LibraryList can parse raw libraries list as passed by studio editor
     """
     lib_list = LibraryList()
     lib1_key, lib1_version = u'library-v1:Org1+Lib1', '5436ffec56c02c13806a4c1b'
     lib2_key, lib2_version = u'library-v1:Org2+Lib2', '112dbaf312c0daa019ce9992'
     raw = [lib1_key + ',' + lib1_version, lib2_key + ',' + lib2_version]
     parsed = lib_list.from_json(raw)
     self.assertEqual(len(parsed), 2)
     self.assertEquals(parsed[0].library_id, LibraryLocator.from_string(lib1_key))
     self.assertEquals(parsed[0].version, ObjectId(lib1_version))
     self.assertEquals(parsed[1].library_id, LibraryLocator.from_string(lib2_key))
     self.assertEquals(parsed[1].version, ObjectId(lib2_version))
开发者ID:feedbackfruits,项目名称:edx-platform,代码行数:16,代码来源:test_library_content.py

示例2: _get_library

# 需要导入模块: from opaque_keys.edx.locator import LibraryLocator [as 别名]
# 或者: from opaque_keys.edx.locator.LibraryLocator import from_string [as 别名]
    def _get_library(self, library_key):
        """
        Given a library key like "library-v1:ProblemX+PR0B", return the
        'library' XBlock with meta-information about the library.

        Returns None on error.
        """
        if not isinstance(library_key, LibraryLocator):
            library_key = LibraryLocator.from_string(library_key)
        assert library_key.version_guid is None

        try:
            return self.store.get_library(library_key, remove_version=False, remove_branch=False)
        except ItemNotFoundError:
            return None
开发者ID:akbargumbira,项目名称:Labster.EdX,代码行数:17,代码来源:library_tools.py

示例3: __new__

# 需要导入模块: from opaque_keys.edx.locator import LibraryLocator [as 别名]
# 或者: from opaque_keys.edx.locator.LibraryLocator import from_string [as 别名]
 def __new__(cls, library_id, version=None):
     # pylint: disable=super-on-old-class
     if not isinstance(library_id, LibraryLocator):
         library_id = LibraryLocator.from_string(library_id)
     if library_id.version_guid:
         assert (version is None) or (version == library_id.version_guid)
         if not version:
             version = library_id.version_guid
         library_id = library_id.for_version(None)
     if version and not isinstance(version, ObjectId):
         try:
             version = ObjectId(version)
         except InvalidId:
             raise ValueError(version)
     return super(LibraryVersionReference, cls).__new__(cls, library_id, version)
开发者ID:akbargumbira,项目名称:Labster.EdX,代码行数:17,代码来源:library_content_module.py

示例4: source_library_key

# 需要导入模块: from opaque_keys.edx.locator import LibraryLocator [as 别名]
# 或者: from opaque_keys.edx.locator.LibraryLocator import from_string [as 别名]
 def source_library_key(self):
     """
     Convenience method to get the library ID as a LibraryLocator and not just a string
     """
     return LibraryLocator.from_string(self.source_library_id)
开发者ID:Colin-Fredericks,项目名称:edx-platform,代码行数:7,代码来源:library_content_module.py

示例5: test_lib_key_with_trailing_whitespace

# 需要导入模块: from opaque_keys.edx.locator import LibraryLocator [as 别名]
# 或者: from opaque_keys.edx.locator.LibraryLocator import from_string [as 别名]
 def test_lib_key_with_trailing_whitespace(self, lib_id_fmt, whitespace):
     with self.assertRaises(InvalidKeyError):
         LibraryLocator.from_string(lib_id_fmt.format(whitespace))
开发者ID:edx,项目名称:opaque-keys,代码行数:5,代码来源:test_library_locators.py

示例6: test_lib_key_from_invalid_string

# 需要导入模块: from opaque_keys.edx.locator import LibraryLocator [as 别名]
# 或者: from opaque_keys.edx.locator.LibraryLocator import from_string [as 别名]
 def test_lib_key_from_invalid_string(self, lib_id_str):
     with self.assertRaises(InvalidKeyError):
         LibraryLocator.from_string(lib_id_str)
开发者ID:edx,项目名称:opaque-keys,代码行数:5,代码来源:test_library_locators.py


注:本文中的opaque_keys.edx.locator.LibraryLocator.from_string方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。