# Path: rophako/settings.py
# class ConfigHandler(object):
#     def load_settings(self):
#     def print_settings(self):
#     def load_plugins(self):
#     def __getattr__(self, section):
# 
# Path: rophako/utils.py
# def sanitize_name(name):
#     """Sanitize a name that may be used in the filesystem.
# 
#     Only allows numbers, letters, and some symbols."""
#     return re.sub(r'[^A-Za-z0-9 .\-_]+', '', name)
# 
# def remote_addr():
#     """Retrieve the end user's remote IP address. If the site is configured
#     to honor X-Forwarded-For and this header is present, it's returned."""
#     if Config.security.use_forwarded_for:
#         return request.access_route[0]
#     return request.remote_addr
# 
# Path: rophako/log.py
# class LogHandler(logging.Handler):
#     def emit(self, record):


import os
import time
import requests
import hashlib
import random
import rophako.jsondb as JsonDB
from flask import g
from PIL import Image
from rophako.settings import Config
from rophako.utils import sanitize_name, remote_addr
from rophako.log import logger
    if album == "" and new_album:
        album = new_album

    # Sanitize the name.
    album = sanitize_name(album)
    if album == "":
        logger.warning("Album name didn't pass sanitization! Fall back to default album name.")
        album = Config.photo.default_album

    # Make up a unique public key for this set of photos.
    key = random_hash()
    while photo_exists(key):
        key = random_hash()
    logger.debug("Photo set public key: {}".format(key))

    # Get the album index to manipulate ordering.
    index = get_index()

    # Update the photo data.
    if not album in index["albums"]:
        index["albums"][album] = {}
    if not "settings" in index:
        index["settings"] = dict()
    if not album in index["settings"]:
        index["settings"][album] = {
            "format": "classic",
            "description": new_desc,
        }

    index["albums"][album][key] = dict(

# Path: rophako/settings.py
# class ConfigHandler(object):
#     def load_settings(self):
#     def print_settings(self):
#     def load_plugins(self):
#     def __getattr__(self, section):
# 
# Path: rophako/utils.py
# def sanitize_name(name):
#     """Sanitize a name that may be used in the filesystem.
# 
#     Only allows numbers, letters, and some symbols."""
#     return re.sub(r'[^A-Za-z0-9 .\-_]+', '', name)
# 
# def remote_addr():
#     """Retrieve the end user's remote IP address. If the site is configured
#     to honor X-Forwarded-For and this header is present, it's returned."""
#     if Config.security.use_forwarded_for:
#         return request.access_route[0]
#     return request.remote_addr
# 
# Path: rophako/log.py
# class LogHandler(logging.Handler):
#     def emit(self, record):


# Path: rophako/model/photo.py
import os
import time
import requests
import hashlib
import random
import rophako.jsondb as JsonDB
from flask import g
from PIL import Image
from rophako.settings import Config
from rophako.utils import sanitize_name, remote_addr
from rophako.log import logger

    if album == "" and new_album:
        album = new_album

    # Sanitize the name.
    album = sanitize_name(album)
    if album == "":
        logger.warning("Album name didn't pass sanitization! Fall back to default album name.")
        album = Config.photo.default_album

    # Make up a unique public key for this set of photos.
    key = random_hash()
    while photo_exists(key):
        key = random_hash()
    logger.debug("Photo set public key: {}".format(key))

    # Get the album index to manipulate ordering.
    index = get_index()

    # Update the photo data.
    if not album in index["albums"]:
        index["albums"][album] = {}
    if not "settings" in index:
        index["settings"] = dict()
    if not album in index["settings"]:
        index["settings"][album] = {
            "format": "classic",
            "description": new_desc,
        }

    index["albums"][album][key] = dict(

        ip=remote_addr(),