本文整理汇总了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.'
示例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.'
示例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')