etiquette/etiquette/constants.py

212 lines
4.4 KiB
Python
Raw Normal View History

import converter
2017-01-30 01:47:59 +00:00
import logging
2016-11-06 04:24:43 +00:00
import string
import traceback
try:
ffmpeg = converter.Converter(
ffmpeg_path='D:\\software\\ffmpeg\\bin\\ffmpeg.exe',
ffprobe_path='D:\\software\\ffmpeg\\bin\\ffprobe.exe',
)
except converter.ffmpeg.FFMpegError:
traceback.print_exc()
ffmpeg = None
2016-11-06 04:24:43 +00:00
FILENAME_BADCHARS = '\\/:*?<>|"'
ALLOWED_ORDERBY_COLUMNS = [
'extension',
'width',
'height',
'ratio',
'area',
'duration',
'bytes',
'created',
'tagged_at',
'random',
]
SQL_LASTID_COLUMNS = [
'table',
'last_id',
]
SQL_ALBUM_DIRECTORY_COLUMNS = [
'albumid',
'directory',
]
SQL_ALBUM_COLUMNS = [
'id',
'title',
'description',
]
SQL_BOOKMARK_COLUMNS = [
'id',
'title',
'url',
'author_id',
]
SQL_PHOTO_COLUMNS = [
'id',
'filepath',
'override_filename',
'extension',
'width',
'height',
'ratio',
'area',
'duration',
'bytes',
'created',
'thumbnail',
'tagged_at',
2016-12-20 22:54:23 +00:00
'author_id',
]
SQL_TAG_COLUMNS = [
'id',
'name',
2017-05-13 00:31:17 +00:00
'description',
]
SQL_SYN_COLUMNS = [
'name',
'master',
]
SQL_ALBUMGROUP_COLUMNS = [
'parentid',
'memberid',
]
SQL_ALBUMPHOTO_COLUMNS = [
'albumid',
'photoid',
]
SQL_PHOTOTAG_COLUMNS = [
'photoid',
'tagid',
]
SQL_TAGGROUP_COLUMNS = [
'parentid',
'memberid',
]
SQL_USER_COLUMNS = [
'id',
'username',
'password',
'created',
]
_sql_dictify = lambda columns: {key:index for (index, key) in enumerate(columns)}
SQL_ALBUM = _sql_dictify(SQL_ALBUM_COLUMNS)
SQL_ALBUM_DIRECTORY = _sql_dictify(SQL_ALBUM_DIRECTORY_COLUMNS)
SQL_ALBUMGROUP = _sql_dictify(SQL_ALBUMGROUP_COLUMNS)
SQL_BOOKMARK = _sql_dictify(SQL_BOOKMARK_COLUMNS)
SQL_ALBUMPHOTO = _sql_dictify(SQL_ALBUMPHOTO_COLUMNS)
SQL_LASTID = _sql_dictify(SQL_LASTID_COLUMNS)
SQL_PHOTO = _sql_dictify(SQL_PHOTO_COLUMNS)
SQL_PHOTOTAG = _sql_dictify(SQL_PHOTOTAG_COLUMNS)
SQL_SYN = _sql_dictify(SQL_SYN_COLUMNS)
SQL_TAG = _sql_dictify(SQL_TAG_COLUMNS)
SQL_TAGGROUP = _sql_dictify(SQL_TAGGROUP_COLUMNS)
SQL_USER = _sql_dictify(SQL_USER_COLUMNS)
2016-11-06 04:24:43 +00:00
# Errors and warnings
WARNING_MINMAX_INVALID = 'Field "{field}": "{value}" is not a valid request. Ignored.'
WARNING_ORDERBY_INVALID = 'Invalid orderby request "{request}". Ignored.'
2016-11-06 04:24:43 +00:00
WARNING_ORDERBY_BADCOL = '"{column}" is not a sorting option. Ignored.'
WARNING_ORDERBY_BADDIRECTION = '''
You can\'t order "{column}" by "{direction}". Defaulting to descending.
'''
2016-11-06 04:24:43 +00:00
# Operational info
TRUTHYSTRING_TRUE = {s.lower() for s in ('1', 'true', 't', 'yes', 'y', 'on')}
TRUTHYSTRING_NONE = {s.lower() for s in ('null', 'none')}
ADDITIONAL_MIMETYPES = {
'7z': 'archive',
'gz': 'archive',
'rar': 'archive',
'aac': 'audio/aac',
'ac3': 'audio/ac3',
'dts': 'audio/dts',
'm4a': 'audio/mp4',
2017-10-04 23:54:28 +00:00
'opus': 'audio/ogg',
'mkv': 'video/x-matroska',
'ass': 'text/plain',
'srt': 'text/plain',
}
2016-11-06 04:24:43 +00:00
DEFAULT_DATADIR = '.\\_etiquette'
DEFAULT_DBNAME = 'phototagger.db'
DEFAULT_CONFIGNAME = 'config.json'
DEFAULT_THUMBDIR = 'site_thumbnails'
DEFAULT_CONFIGURATION = {
2017-01-30 01:47:59 +00:00
'log_level': logging.DEBUG,
'cache_size': {
'album': 1000,
'photo': 100000,
'tag': 1000,
'user': 200,
},
'enable_feature': {
'album': {
'edit': True,
'new': True,
},
'bookmark': {
'edit': True,
'new': True,
},
'photo': {
'add_remove_tag': True,
'new': True,
'edit': True,
'generate_thumbnail': True,
'reload_metadata': True,
},
'tag': {
'edit': True,
'new': True,
},
'user': {
'login': True,
'new': True,
},
},
'tag': {
'min_length': 1,
'max_length': 32,
'valid_chars': string.ascii_lowercase + string.digits + '_()',
},
'user': {
'min_length': 2,
'min_password_length': 6,
'max_length': 24,
'valid_chars': string.ascii_letters + string.digits + '~!@#$%^*()[]{}:;,.<>/\\-_+=',
},
2016-11-06 04:24:43 +00:00
'digest_exclude_files': [
'phototagger.db',
'desktop.ini',
'thumbs.db',
],
'digest_exclude_dirs': [
'_site_thumbnails',
],
'id_length': 12,
'thumbnail_width': 400,
'thumbnail_height': 400,
'motd_strings': [
'Good morning, Paul. What will your first sequence of the day be?',
],
2016-11-06 04:24:43 +00:00
}