Files
hudozka/utils/Sync/settings.py
T

159 lines
3.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import os
import yaml
__author__ = 'Roman Timashev'
name = 'HudozkaSync'
config = yaml.load(open('config.yaml', 'r'))
def absolute(path, ensure=True):
a = os.path.expanduser(path)
if ensure:
os.makedirs(a, exist_ok=True)
return a
def abs_fn(root):
return lambda path: os.path.join(root, path)
def env(param, default=None):
if param in os.environ:
return os.environ[param]
return default
database_uri = config['database_uri'] # env('MONGO_URI')
skip_unchanged = config['skip_unchanged']
person_uri = {
'Н.В.Андреева': 'nv-andreeva',
'И.Н.Втюрина': 'in-vturina',
'О.Д.Гоголева': 'od-gogoleva',
'В.А.Саржин': 'va-sarzhin',
'Р.К.Тимашев': 'rk-timashev',
'А.С.Тимашева': 'as-timasheva',
}
upload_enabled = config['upload_enabled']
upload_url_image = 'https://static.shlisselburg.org/upload/art/images/{}'
upload_auth = (
config['upload_auth']['login'],
config['upload_auth']['password'],
)
image_processing_enabled = config['image_processing']
album_html_img_class = 'hudozka-product'
image_ext = '.jpg'
image_sizes = [
('original', None, None),
('big', 1500, 667),
('big@2', 3000, 1334),
('medium', 400, 300),
('medium@2', 800, 600),
('small', 250, 175),
('small@2', 500, 350),
('little', 100, 100),
('little@2', 200, 200),
]
awards_image_sizes = [
('medium', 640, 480),
('small', 300, 200),
('preview', 50, 50),
]
event_image_sizes = [
('big', 1200, 800)
]
teacher_image_url_base = 'https://static.shlisselburg.org/art/images/teacher-{id}-{size}{ext}'
teacher_image_output = '/Users/tmshv/Desktop/Hudozka Static/images'
teacher_image_sizes = [
('big', 1200, 800),
('medium', 640, 480),
('preview', 50, 50),
]
album_image_sizes = [
('big', 1200, 800),
('medium', 640, 480),
('small', 250, 175)
]
date_formats = [
'%Y',
'%m.%Y',
'%d.%m.%Y',
'%d.%m.%Y %H:%M',
'%d.%m.%Y %H:%M:%S'
]
date_formats_direct = [
'%Y',
'%m.%Y',
'%d.%m.%Y',
]
date_formats_reverse = [
'%Y',
'%Y.%m',
'%Y.%m.%d'
]
origin = config['origin']
collection_images = 'images'
collection_documents = 'documents'
collection_awards = 'awards'
collection_schedules = 'schedules'
collection_articles = 'articles'
collection_collective = 'collective'
collection_albums = 'albums'
collection_pages = 'pages'
provider_name = config['provider']['name'] # env('SYNC_PROVIDER', 'fs')
provider_root = config['provider']['root'] # env('SYNC_PROVIDER', 'fs')
# _providers_roots = {
# 'fs': abs_fn(env('SYNC_LOCAL_PATH')),
# 'yd': abs_fn('/'),
# }
# f = _providers_roots[provider_name]
f = abs_fn(provider_root)
dir_documents = f('Documents')
dir_awards = f('Awards')
dir_schedules = f('Schedules')
dir_articles = f('Articles')
dir_collective = f('Collective')
dir_gallery = f('Gallery')
dir_pages = f('Pages')
url_page_base_preview = 'https://static.shlisselburg.org/art/images/page-{page}-{id}-{size}{ext}'
document_url_template = 'https://static.shlisselburg.org/art/uploads/{file}'
document_url_upload_template = 'https://static.shlisselburg.org/upload/art/uploads/{file}'
document_url_preview_template = 'https://static.shlisselburg.org/art/images/{id}-{size}{ext}'
image_url_upload = 'https://static.shlisselburg.org/upload/art/images/'
image_url_base = 'https://static.shlisselburg.org/art/images/'
image_name_format = '{type}-{id}-{img}-{size}{ext}'
yandex_disk_access_token = config['yandex_disk_access_token'] # env('YANDEX_DISK_ACCESS_TOKEN')
# update_enabled = env('SYNC_ENV', 'production') == 'production'
# delete_enabled = env('SYNC_ENV', 'production') == 'production'
update_enabled = config['update_enabled']
delete_enabled = config['delete_enabled']