#!/usr/bin/python

import os
import sys

SITENAME = os.environ.get("BEPASTY_SITENAME", None)
if SITENAME is None:
    print("\n\nEnvironment variable BEPASTY_SITENAME must be set.")
    sys.exit(1)

SECRET_KEY = os.environ.get("BEPASTY_SECRET_KEY", None)
if SECRET_KEY is None:
    print("\n\nEnvironment variable BEPASTY_SECRET_KEY must be set.")
    sys.exit(1)

APP_BASE_PATH = os.environ.get("BEPASTY_APP_BASE_PATH", None)

STORAGE_FILESYSTEM_DIRECTORY = os.environ.get(
    "BEPASTY_STORAGE_FILESYSTEM_DIRECTORY", "/app/data",
)

DEFAULT_PERMISSIONS = os.environ.get("BEPASTY_DEFAULT_PERMISSIONS", "create,read")

PERMISSIONS = {}
admin_secret = os.environ.get("BEPASTY_ADMIN_SECRET", None)
if admin_secret is not None:
    PERMISSIONS.update({admin_secret: "admin,list,create,modify,read,delete"})

try:
    max_allowed_file_size = os.environ.get("BEPASTY_MAX_ALLOWED_FILE_SIZE", 5000000000)
    MAX_ALLOWED_FILE_SIZE = int(max_allowed_file_size)
except ValueError as err:
    print("\n\nInvalid BEPASTY_MAX_ALLOWED_FILE_SIZE: %s", str(err))
    sys.exit(1)

try:
    max_body_size = os.environ.get("BEPASTY_MAX_BODY_SIZE", 1040384)
    MAX_BODY_SIZE = int(max_body_size)
except ValueError as err:
    print("\n\nInvalid BEPASTY_MAX_BODY_SIZE: %s", str(err))
    sys.exit(1)

[((6, 11, 6, 51), 'os.environ.get', 'os.environ.get', ({(6, 26, 6, 44): '"""BEPASTY_SITENAME"""', (6, 46, 6, 50): 'None'}, {}), "('BEPASTY_SITENAME', None)", False, 'import os\n'), ((11, 13, 11, 55), 'os.environ.get', 'os.environ.get', ({(11, 28, 11, 48): '"""BEPASTY_SECRET_KEY"""', (11, 50, 11, 54): 'None'}, {}), "('BEPASTY_SECRET_KEY', None)", False, 'import os\n'), ((16, 16, 16, 61), 'os.environ.get', 'os.environ.get', ({(16, 31, 16, 54): '"""BEPASTY_APP_BASE_PATH"""', (16, 56, 16, 60): 'None'}, {}), "('BEPASTY_APP_BASE_PATH', None)", False, 'import os\n'), ((18, 31, 20, 1), 'os.environ.get', 'os.environ.get', ({(19, 4, 19, 42): '"""BEPASTY_STORAGE_FILESYSTEM_DIRECTORY"""', (19, 44, 19, 55): '"""/app/data"""'}, {}), "('BEPASTY_STORAGE_FILESYSTEM_DIRECTORY', '/app/data')", False, 'import os\n'), ((22, 22, 22, 82), 'os.environ.get', 'os.environ.get', ({(22, 37, 22, 66): '"""BEPASTY_DEFAULT_PERMISSIONS"""', (22, 68, 22, 81): '"""create,read"""'}, {}), "('BEPASTY_DEFAULT_PERMISSIONS', 'create,read')", False, 'import os\n'), ((25, 15, 25, 59), 'os.environ.get', 'os.environ.get', ({(25, 30, 25, 52): '"""BEPASTY_ADMIN_SECRET"""', (25, 54, 25, 58): 'None'}, {}), "('BEPASTY_ADMIN_SECRET', None)", False, 'import os\n'), ((9, 4, 9, 15), 'sys.exit', 'sys.exit', ({(9, 13, 9, 14): '(1)'}, {}), '(1)', False, 'import sys\n'), ((14, 4, 14, 15), 'sys.exit', 'sys.exit', ({(14, 13, 14, 14): '(1)'}, {}), '(1)', False, 'import sys\n'), ((30, 28, 30, 87), 'os.environ.get', 'os.environ.get', ({(30, 43, 30, 74): '"""BEPASTY_MAX_ALLOWED_FILE_SIZE"""', (30, 76, 30, 86): '5000000000'}, {}), "('BEPASTY_MAX_ALLOWED_FILE_SIZE', 5000000000)", False, 'import os\n'), ((37, 20, 37, 68), 'os.environ.get', 'os.environ.get', ({(37, 35, 37, 58): '"""BEPASTY_MAX_BODY_SIZE"""', (37, 60, 37, 67): '1040384'}, {}), "('BEPASTY_MAX_BODY_SIZE', 1040384)", False, 'import os\n'), ((34, 4, 34, 15), 'sys.exit', 'sys.exit', ({(34, 13, 34, 14): '(1)'}, {}), '(1)', False, 'import sys\n'), ((41, 4, 41, 15), 'sys.exit', 'sys.exit', ({(41, 13, 41, 14): '(1)'}, {}), '(1)', False, 'import sys\n')]