forked from openlp/openlp
File list refactor
This commit is contained in:
parent
c626653092
commit
5a8cd52acf
@ -1,3 +1,4 @@
|
|||||||
|
import os.path
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||||
|
|
||||||
@ -153,16 +154,16 @@ class SettingsManager(object):
|
|||||||
return list
|
return list
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_files(section=None, suffix=None):
|
def get_files(section=None, extension=None):
|
||||||
"""
|
"""
|
||||||
Get a list of files from the data files path.
|
Get a list of files from the data files path.
|
||||||
|
|
||||||
``section``
|
``section``
|
||||||
Defaults to *None*. The section of code getting the files - used
|
Defaults to *None*. The section of code getting the files - used
|
||||||
to load from section directory.
|
to load from a section's data subdirectory.
|
||||||
|
|
||||||
``suffix``
|
``extension``
|
||||||
Defaults to *None*. The extension to search for.
|
Defaults to *None*. The extension to search for.
|
||||||
"""
|
"""
|
||||||
path = AppLocation.get_data_path()
|
path = AppLocation.get_data_path()
|
||||||
if section:
|
if section:
|
||||||
@ -171,17 +172,9 @@ class SettingsManager(object):
|
|||||||
files = os.listdir(path)
|
files = os.listdir(path)
|
||||||
except:
|
except:
|
||||||
return []
|
return []
|
||||||
if suffix:
|
if extension:
|
||||||
return_files = []
|
return [file for file in files
|
||||||
for file in files:
|
if extension == os.path.splitext(file)[1]]
|
||||||
if file.find(u'.') != -1:
|
|
||||||
filename = file.split(u'.')
|
|
||||||
filesuffix = filename[1].lower()
|
|
||||||
filesuffix = filesuffix.lower()
|
|
||||||
# only load files with the correct suffix
|
|
||||||
if suffix.find(filesuffix) > -1 :
|
|
||||||
return_files.append(file)
|
|
||||||
return return_files
|
|
||||||
else:
|
else:
|
||||||
# no filtering required
|
# no filtering required
|
||||||
return files
|
return files
|
||||||
|
@ -114,7 +114,7 @@ class BibleManager(object):
|
|||||||
self.path = AppLocation.get_section_data_path(u'bibles')
|
self.path = AppLocation.get_section_data_path(u'bibles')
|
||||||
self.proxy_name = unicode(
|
self.proxy_name = unicode(
|
||||||
QtCore.QSettings().value(u'bibles/proxy name', u'').toString())
|
QtCore.QSettings().value(u'bibles/proxy name', u'').toString())
|
||||||
self.suffix = u'sqlite'
|
self.suffix = u'.sqlite'
|
||||||
self.import_wizard = None
|
self.import_wizard = None
|
||||||
self.reload_bibles()
|
self.reload_bibles()
|
||||||
self.media = None
|
self.media = None
|
||||||
|
Loading…
Reference in New Issue
Block a user