# Path: hurray/server/escape.py
# _UTF8_TYPES = (bytes, type(None))
# _TO_UNICODE_TYPES = (unicode_type, type(None))
# def utf8(value):
# def to_unicode(value):
# 
# Path: hurray/server/log.py
# def define_logging_options(options=None):
#     """Add logging-related flags to ``options``.
# 
#     These options are present automatically on the default options instance;
#     this method is only necessary if you have created your own `.OptionParser`.
# 
#     .. versionadded:: 4.2
#         This function existed in prior versions but was broken and undocumented until 4.2.
#     """
#     if options is None:
#         # late import to prevent cycle
#         import hurray.options
#         options = hurray.options.options
#     options.define("logging", default="info",
#                    help=("Set the Python log level. If 'none', hurray won't touch the "
#                          "logging configuration."),
#                    metavar="debug|info|warning|error|none")
#     options.define("log_to_stderr", type=bool, default=None,
#                    help=("Send log output to stderr (colorized if possible). "
#                          "By default use stderr if --log_file_prefix is not set and "
#                          "no other logging is configured."))
#     options.define("log_file_prefix", type=str, default=None, metavar="PATH",
#                    help=("Path prefix for log files. "
#                          "Note that if you are running multiple hurray processes, "
#                          "log_file_prefix must be different for each of them (e.g. "
#                          "include the port number)"))
#     options.define("log_file_max_size", type=int, default=100 * 1000 * 1000,
#                    help="max size of log files before rollover")
#     options.define("log_file_num_backups", type=int, default=10,
#                    help="number of log files to keep")
# 
#     options.define("log_rotate_when", type=str, default='midnight',
#                    help=("specify the type of TimedRotatingFileHandler interval "
#                          "other options:('S', 'M', 'H', 'D', 'W0'-'W6')"))
#     options.define("log_rotate_interval", type=int, default=1,
#                    help="The interval value of timed rotating")
# 
#     options.define("log_rotate_mode", type=str, default='size',
#                    help="The mode of rotating files(time or size)")
# 
#     options.add_parse_callback(lambda: enable_pretty_logging(options))
# 
# Path: hurray/server/stack_context.py
# class StackContextInconsistentError(Exception):
# class _State(threading.local):
# class StackContext(object):
# class ExceptionStackContext(object):
# class NullContext(object):
#     def __init__(self):
#     def __init__(self, context_factory):
#     def _deactivate(self):
#     def enter(self):
#     def exit(self, type, value, traceback):
#     def __enter__(self):
#     def __exit__(self, type, value, traceback):
#     def __init__(self, exception_handler):
#     def _deactivate(self):
#     def exit(self, type, value, traceback):
#     def __enter__(self):
#     def __exit__(self, type, value, traceback):
#     def __enter__(self):
#     def __exit__(self, type, value, traceback):
# def _remove_deactivated(contexts):
# def wrap(fn):
#         def null_wrapper(*args, **kwargs):
#     def wrapped(*args, **kwargs):
# def _handle_exception(tail, exc):
# def run_with_stack_context(context, func):
# 
# Path: hurray/server/util.py
# PY3 = sys.version_info >= (3,)
#     def cast(typ, x):
# def import_object(name):
# def raise_exc_info(exc_info):
# def exec_in(code, glob, loc=None):
# def errno_from_exception(e):
#     def __new__(cls, *args, **kwargs):
#     def configurable_base(cls):
#     def configurable_default(cls):
#     def initialize(self):
#     def configure(cls, impl, **kwargs):
#     def configured_class(cls):
#     def _save_configuration(cls):
#     def _restore_configuration(cls, saved):
#     def __init__(self, func, name):
#     def _getargnames(self, func):
#     def get_old_value(self, args, kwargs, default=None):
#     def replace(self, new_value, args, kwargs):
# def timedelta_to_seconds(td):
# class Configurable(object):
# class ArgReplacer(object):


import datetime
import numbers
import re
import sys
import os
import textwrap
from hurray.server.escape import _unicode, native_str
from hurray.server.log import define_logging_options
from hurray.server import stack_context
from hurray.server.util import basestring_type, exec_in
        setattr(self._options, name, self._originals.pop(name))


class _Option(object):
    UNSET = object()

    def __init__(self, name, default=None, type=basestring_type, help=None,
                 metavar=None, multiple=False, file_name=None, group_name=None,
                 callback=None):
        if default is None and multiple:
            default = []
        self.name = name
        self.type = type
        self.help = help
        self.metavar = metavar
        self.multiple = multiple
        self.file_name = file_name
        self.group_name = group_name
        self.callback = callback
        self.default = default
        self._value = _Option.UNSET

    def value(self):
        return self.default if self._value is _Option.UNSET else self._value

    def parse(self, value):
        _parse = {
            datetime.datetime: self._parse_datetime,
            datetime.timedelta: self._parse_timedelta,
            bool: self._parse_bool,

# Path: hurray/server/escape.py
# _UTF8_TYPES = (bytes, type(None))
# _TO_UNICODE_TYPES = (unicode_type, type(None))
# def utf8(value):
# def to_unicode(value):
# 
# Path: hurray/server/log.py
# def define_logging_options(options=None):
#     """Add logging-related flags to ``options``.
# 
#     These options are present automatically on the default options instance;
#     this method is only necessary if you have created your own `.OptionParser`.
# 
#     .. versionadded:: 4.2
#         This function existed in prior versions but was broken and undocumented until 4.2.
#     """
#     if options is None:
#         # late import to prevent cycle
#         import hurray.options
#         options = hurray.options.options
#     options.define("logging", default="info",
#                    help=("Set the Python log level. If 'none', hurray won't touch the "
#                          "logging configuration."),
#                    metavar="debug|info|warning|error|none")
#     options.define("log_to_stderr", type=bool, default=None,
#                    help=("Send log output to stderr (colorized if possible). "
#                          "By default use stderr if --log_file_prefix is not set and "
#                          "no other logging is configured."))
#     options.define("log_file_prefix", type=str, default=None, metavar="PATH",
#                    help=("Path prefix for log files. "
#                          "Note that if you are running multiple hurray processes, "
#                          "log_file_prefix must be different for each of them (e.g. "
#                          "include the port number)"))
#     options.define("log_file_max_size", type=int, default=100 * 1000 * 1000,
#                    help="max size of log files before rollover")
#     options.define("log_file_num_backups", type=int, default=10,
#                    help="number of log files to keep")
# 
#     options.define("log_rotate_when", type=str, default='midnight',
#                    help=("specify the type of TimedRotatingFileHandler interval "
#                          "other options:('S', 'M', 'H', 'D', 'W0'-'W6')"))
#     options.define("log_rotate_interval", type=int, default=1,
#                    help="The interval value of timed rotating")
# 
#     options.define("log_rotate_mode", type=str, default='size',
#                    help="The mode of rotating files(time or size)")
# 
#     options.add_parse_callback(lambda: enable_pretty_logging(options))
# 
# Path: hurray/server/stack_context.py
# class StackContextInconsistentError(Exception):
# class _State(threading.local):
# class StackContext(object):
# class ExceptionStackContext(object):
# class NullContext(object):
#     def __init__(self):
#     def __init__(self, context_factory):
#     def _deactivate(self):
#     def enter(self):
#     def exit(self, type, value, traceback):
#     def __enter__(self):
#     def __exit__(self, type, value, traceback):
#     def __init__(self, exception_handler):
#     def _deactivate(self):
#     def exit(self, type, value, traceback):
#     def __enter__(self):
#     def __exit__(self, type, value, traceback):
#     def __enter__(self):
#     def __exit__(self, type, value, traceback):
# def _remove_deactivated(contexts):
# def wrap(fn):
#         def null_wrapper(*args, **kwargs):
#     def wrapped(*args, **kwargs):
# def _handle_exception(tail, exc):
# def run_with_stack_context(context, func):
# 
# Path: hurray/server/util.py
# PY3 = sys.version_info >= (3,)
#     def cast(typ, x):
# def import_object(name):
# def raise_exc_info(exc_info):
# def exec_in(code, glob, loc=None):
# def errno_from_exception(e):
#     def __new__(cls, *args, **kwargs):
#     def configurable_base(cls):
#     def configurable_default(cls):
#     def initialize(self):
#     def configure(cls, impl, **kwargs):
#     def configured_class(cls):
#     def _save_configuration(cls):
#     def _restore_configuration(cls, saved):
#     def __init__(self, func, name):
#     def _getargnames(self, func):
#     def get_old_value(self, args, kwargs, default=None):
#     def replace(self, new_value, args, kwargs):
# def timedelta_to_seconds(td):
# class Configurable(object):
# class ArgReplacer(object):


# Path: hurray/server/options.py
import datetime
import numbers
import re
import sys
import os
import textwrap
from hurray.server.escape import _unicode, native_str
from hurray.server.log import define_logging_options
from hurray.server import stack_context
from hurray.server.util import basestring_type, exec_in

        setattr(self._options, name, self._originals.pop(name))


class _Option(object):
    UNSET = object()

    def __init__(self, name, default=None, type=basestring_type, help=None,
                 metavar=None, multiple=False, file_name=None, group_name=None,
                 callback=None):
        if default is None and multiple:
            default = []
        self.name = name
        self.type = type
        self.help = help
        self.metavar = metavar
        self.multiple = multiple
        self.file_name = file_name
        self.group_name = group_name
        self.callback = callback
        self.default = default
        self._value = _Option.UNSET

    def value(self):
        return self.default if self._value is _Option.UNSET else self._value

    def parse(self, value):
        _parse = {
            datetime.datetime: self._parse_datetime,
            datetime.timedelta: self._parse_timedelta,
            bool: self._parse_bool,

            basestring_type: self._parse_string,