#!/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)

[((52, 92), 'os.environ.get', 'os.environ.get', (['"""BEPASTY_SITENAME"""', 'None'], {}), "('BEPASTY_SITENAME', None)\n", (66, 92), False, 'import os\n'), ((212, 254), 'os.environ.get', 'os.environ.get', (['"""BEPASTY_SECRET_KEY"""', 'None'], {}), "('BEPASTY_SECRET_KEY', None)\n", (226, 254), False, 'import os\n'), ((381, 426), 'os.environ.get', 'os.environ.get', (['"""BEPASTY_APP_BASE_PATH"""', 'None'], {}), "('BEPASTY_APP_BASE_PATH', None)\n", (395, 426), False, 'import os\n'), ((459, 526), 'os.environ.get', 'os.environ.get', (['"""BEPASTY_STORAGE_FILESYSTEM_DIRECTORY"""', '"""/app/data"""'], {}), "('BEPASTY_STORAGE_FILESYSTEM_DIRECTORY', '/app/data')\n", (473, 526), False, 'import os\n'), ((557, 617), 'os.environ.get', 'os.environ.get', (['"""BEPASTY_DEFAULT_PERMISSIONS"""', '"""create,read"""'], {}), "('BEPASTY_DEFAULT_PERMISSIONS', 'create,read')\n", (571, 617), False, 'import os\n'), ((651, 695), 'os.environ.get', 'os.environ.get', (['"""BEPASTY_ADMIN_SECRET"""', 'None'], {}), "('BEPASTY_ADMIN_SECRET', None)\n", (665, 695), False, 'import os\n'), ((186, 197), 'sys.exit', 'sys.exit', (['(1)'], {}), '(1)\n', (194, 197), False, 'import sys\n'), ((352, 363), 'sys.exit', 'sys.exit', (['(1)'], {}), '(1)\n', (360, 363), False, 'import sys\n'), ((838, 897), 'os.environ.get', 'os.environ.get', (['"""BEPASTY_MAX_ALLOWED_FILE_SIZE"""', '(5000000000)'], {}), "('BEPASTY_MAX_ALLOWED_FILE_SIZE', 5000000000)\n", (852, 897), False, 'import os\n'), ((1090, 1138), 'os.environ.get', 'os.environ.get', (['"""BEPASTY_MAX_BODY_SIZE"""', '(1040384)'], {}), "('BEPASTY_MAX_BODY_SIZE', 1040384)\n", (1104, 1138), False, 'import os\n'), ((1052, 1063), 'sys.exit', 'sys.exit', (['(1)'], {}), '(1)\n', (1060, 1063), False, 'import sys\n'), ((1269, 1280), 'sys.exit', 'sys.exit', (['(1)'], {}), '(1)\n', (1277, 1280), False, 'import sys\n')]