Move default DB filename etc. to constants
This commit is contained in:
parent
241d1466eb
commit
24b6970617
2 changed files with 6 additions and 5 deletions
|
@ -142,6 +142,9 @@ ADDITIONAL_MIMETYPES = {
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFAULT_DATADIR = '.\\_etiquette'
|
DEFAULT_DATADIR = '.\\_etiquette'
|
||||||
|
DEFAULT_DBNAME = 'phototagger.db'
|
||||||
|
DEFAULT_CONFIGNAME = 'config.json'
|
||||||
|
DEFAULT_THUMBDIR = 'site_thumbnails'
|
||||||
|
|
||||||
DEFAULT_CONFIGURATION = {
|
DEFAULT_CONFIGURATION = {
|
||||||
'log_level': logging.DEBUG,
|
'log_level': logging.DEBUG,
|
||||||
|
@ -185,5 +188,4 @@ DEFAULT_CONFIGURATION = {
|
||||||
'motd_strings': [
|
'motd_strings': [
|
||||||
'Good morning, Paul. What will your first sequence of the day be?',
|
'Good morning, Paul. What will your first sequence of the day be?',
|
||||||
],
|
],
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1146,7 +1146,7 @@ class PhotoDB(PDBAlbumMixin, PDBBookmarkMixin, PDBPhotoMixin, PDBTagMixin, PDBUs
|
||||||
os.makedirs(self.data_directory.absolute_path, exist_ok=True)
|
os.makedirs(self.data_directory.absolute_path, exist_ok=True)
|
||||||
|
|
||||||
# DATABASE
|
# DATABASE
|
||||||
self.database_file = self.data_directory.with_child('phototagger.db')
|
self.database_file = self.data_directory.with_child(constants.DEFAULT_DBNAME)
|
||||||
existing_database = self.database_file.exists
|
existing_database = self.database_file.exists
|
||||||
self.sql = sqlite3.connect(self.database_file.absolute_path)
|
self.sql = sqlite3.connect(self.database_file.absolute_path)
|
||||||
self.cur = self.sql.cursor()
|
self.cur = self.sql.cursor()
|
||||||
|
@ -1166,7 +1166,7 @@ class PhotoDB(PDBAlbumMixin, PDBBookmarkMixin, PDBPhotoMixin, PDBTagMixin, PDBUs
|
||||||
|
|
||||||
# CONFIG
|
# CONFIG
|
||||||
self.config = copy.deepcopy(constants.DEFAULT_CONFIGURATION)
|
self.config = copy.deepcopy(constants.DEFAULT_CONFIGURATION)
|
||||||
self.config_filepath = self.data_directory.with_child('config.json')
|
self.config_filepath = self.data_directory.with_child(constants.DEFAULT_CONFIGNAME)
|
||||||
user_config_exists = self.config_filepath.is_file
|
user_config_exists = self.config_filepath.is_file
|
||||||
if user_config_exists:
|
if user_config_exists:
|
||||||
with open(self.config_filepath.absolute_path, 'r') as handle:
|
with open(self.config_filepath.absolute_path, 'r') as handle:
|
||||||
|
@ -1180,9 +1180,8 @@ class PhotoDB(PDBAlbumMixin, PDBBookmarkMixin, PDBPhotoMixin, PDBTagMixin, PDBUs
|
||||||
with open(self.config_filepath.absolute_path, 'w') as handle:
|
with open(self.config_filepath.absolute_path, 'w') as handle:
|
||||||
handle.write(json.dumps(self.config, indent=4, sort_keys=True))
|
handle.write(json.dumps(self.config, indent=4, sort_keys=True))
|
||||||
|
|
||||||
|
|
||||||
# THUMBNAIL DIRECTORY
|
# THUMBNAIL DIRECTORY
|
||||||
self.thumbnail_directory = self.data_directory.with_child('site_thumbnails')
|
self.thumbnail_directory = self.data_directory.with_child(constants.DEFAULT_THUMBDIR)
|
||||||
os.makedirs(self.thumbnail_directory.absolute_path, exist_ok=True)
|
os.makedirs(self.thumbnail_directory.absolute_path, exist_ok=True)
|
||||||
|
|
||||||
# OTHER
|
# OTHER
|
||||||
|
|
Loading…
Reference in a new issue