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


Python AppLocation.get_files方法代碼示例

本文整理匯總了Python中openlp.core.utils.AppLocation.get_files方法的典型用法代碼示例。如果您正苦於以下問題:Python AppLocation.get_files方法的具體用法?Python AppLocation.get_files怎麽用?Python AppLocation.get_files使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在openlp.core.utils.AppLocation的用法示例。


在下文中一共展示了AppLocation.get_files方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_files_no_section_no_extension_test

# 需要導入模塊: from openlp.core.utils import AppLocation [as 別名]
# 或者: from openlp.core.utils.AppLocation import get_files [as 別名]
    def get_files_no_section_no_extension_test(self):
        """
        Test the AppLocation.get_files() method with no parameters passed.
        """
        with patch('openlp.core.utils.AppLocation.get_data_path') as mocked_get_data_path, \
                patch('openlp.core.utils.applocation.os.listdir') as mocked_listdir:
            # GIVEN: Our mocked modules/methods.
            mocked_get_data_path.return_value = 'test/dir'
            mocked_listdir.return_value = copy.deepcopy(FILE_LIST)

            # When: Get the list of files.
            result = AppLocation.get_files()

            # Then: check if the file lists are identical.
            assert result == FILE_LIST,  'The file lists should be identical.'
開發者ID:marmyshev,項目名稱:bug_1117098,代碼行數:17,代碼來源:test_applocation.py

示例2: get_files_test

# 需要導入模塊: from openlp.core.utils import AppLocation [as 別名]
# 或者: from openlp.core.utils.AppLocation import get_files [as 別名]
    def get_files_test(self):
        """
        Test the AppLocation.get_files() method with all parameters passed.
        """
        with patch('openlp.core.utils.AppLocation.get_data_path') as mocked_get_data_path, \
                patch('openlp.core.utils.applocation.os.listdir') as mocked_listdir:
            # GIVEN: Our mocked modules/methods.
            mocked_get_data_path.return_value = 'test/dir'
            mocked_listdir.return_value = copy.deepcopy(FILE_LIST)

            # When: Get the list of files.
            result = AppLocation.get_files('section', '.mp3')

            # Then: Check if the section parameter was used correctly.
            mocked_listdir.assert_called_with('test/dir/section')

            # Then: check if the file lists are identical.
            assert result == ['file5.mp3', 'file6.mp3'],  'The file lists should be identical.'
開發者ID:marmyshev,項目名稱:bug_1117098,代碼行數:20,代碼來源:test_applocation.py

示例3: reload_bibles

# 需要導入模塊: from openlp.core.utils import AppLocation [as 別名]
# 或者: from openlp.core.utils.AppLocation import get_files [as 別名]
 def reload_bibles(self):
     """
     Reloads the Bibles from the available Bible databases on disk. If a web
     Bible is encountered, an instance of HTTPBible is loaded instead of the
     BibleDB class.
     """
     log.debug('Reload bibles')
     files = AppLocation.get_files(self.settings_section, self.suffix)
     if 'alternative_book_names.sqlite' in files:
         files.remove('alternative_book_names.sqlite')
     log.debug('Bible Files %s', files)
     self.db_cache = {}
     self.old_bible_databases = []
     for filename in files:
         bible = BibleDB(self.parent, path=self.path, file=filename)
         name = bible.get_name()
         # Remove corrupted files.
         if name is None:
             bible.session.close()
             delete_file(os.path.join(self.path, filename))
             continue
         # Find old database versions.
         if bible.is_old_database():
             self.old_bible_databases.append([filename, name])
             bible.session.close()
             continue
         log.debug('Bible Name: "%s"', name)
         self.db_cache[name] = bible
         # Look to see if lazy load bible exists and get create getter.
         source = self.db_cache[name].get_object(BibleMeta, 'download_source')
         if source:
             download_name = self.db_cache[name].get_object(BibleMeta, 'download_name').value
             meta_proxy = self.db_cache[name].get_object(BibleMeta, 'proxy_server')
             web_bible = HTTPBible(self.parent, path=self.path, file=filename, download_source=source.value,
                 download_name=download_name)
             if meta_proxy:
                 web_bible.proxy_server = meta_proxy.value
             self.db_cache[name] = web_bible
     log.debug('Bibles reloaded')
開發者ID:marmyshev,項目名稱:bug_1117098,代碼行數:41,代碼來源:manager.py


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