# Path: src/formencode/api.py
# def get_localedir():
# def set_stdtranslation(domain="FormEncode", languages=None,
#                        localedir=get_localedir()):
# def deprecation_warning(old, new=None, stacklevel=3):
# def deprecated(old=None, new=None):
#     def outer(func):
#         def inner(*args, **kwargs):
# def is_empty(value):
# def is_validator(obj):
#     def __init__(self, msg,
#                  value, state, error_list=None, error_dict=None):
#     def __str__(self):
#         def __unicode__(self):
#     def unpack_errors(self, encode_variables=False, dict_char='.',
#                       list_char='-'):
#     def __classinit__(cls, new_attrs):
#     def __init__(self, *args, **kw):
#     def to_python(self, value, state=None):
#     def from_python(self, value, state=None):
#         def _message_vars_decode(self, message_vars):
#     def message(self, msgName, state, **kw):
#     def all_messages(self):
#     def subvalidators(self):
#     def _initialize_docstring(cls):
#     def __repr__(self):
#     def __classinit__(cls, new_attrs):
#     def to_python(self, value, state=None):
#     def from_python(self, value, state=None):
#     def is_empty(self, value):
#     def empty_value(self, value):
#     def assert_string(self, value, state):
#     def base64encode(self, value):
#     def _validate_noop(self, value, state=None):
# class NoDefault(object):
# class Invalid(Exception):
# class Validator(declarative.Declarative):
# class _Identity(Validator):
# class FancyValidator(Validator):


import cgi
import locale
import re
import warnings
import six
    import dns.resolver
    import dns.exception
            import datetime as datetime_module
                import socket
            import socket
            import random
from encodings import idna
from six.moves import map
from six.moves import range
from .api import (FancyValidator, Identity, Invalid, NoDefault, Validator,
    deprecation_warning, is_empty)
            from mx import DateTime as mxDateTime_module
            from six.moves.urllib import parse as urlparse
            from six.moves import http_client
            from six.moves.urllib import parse as urlparse
    from formencode.national import USStateProvince
    from formencode.national import USPhoneNumber
    from formencode.national import InternationalPhoneNumber
    from formencode.national import USPostalCode
            from hashlib import sha1
            from hashlib import sha1
def PhoneNumber(*kw, **kwargs):
    deprecation_warning("please use formencode.national.USPhoneNumber")
    return USPhoneNumber(*kw, **kwargs)


def IPhoneNumberValidator(*kw, **kwargs):
    deprecation_warning(
        "please use formencode.national.InternationalPhoneNumber")
    return InternationalPhoneNumber(*kw, **kwargs)


class FieldStorageUploadConverter(FancyValidator):
    """
    Handles cgi.FieldStorage instances that are file uploads.

    This doesn't do any conversion, but it can detect empty upload
    fields (which appear like normal fields, but have no filename when
    no upload was given).
    """
    def _convert_to_python(self, value, state=None):
        if isinstance(value, cgi.FieldStorage):
            if getattr(value, 'filename', None):
                return value
            raise Invalid('invalid', value, state)
        else:
            return value

    def is_empty(self, value):
        if isinstance(value, cgi.FieldStorage):
            return not bool(getattr(value, 'filename', None))

# Path: src/formencode/api.py
# def get_localedir():
# def set_stdtranslation(domain="FormEncode", languages=None,
#                        localedir=get_localedir()):
# def deprecation_warning(old, new=None, stacklevel=3):
# def deprecated(old=None, new=None):
#     def outer(func):
#         def inner(*args, **kwargs):
# def is_empty(value):
# def is_validator(obj):
#     def __init__(self, msg,
#                  value, state, error_list=None, error_dict=None):
#     def __str__(self):
#         def __unicode__(self):
#     def unpack_errors(self, encode_variables=False, dict_char='.',
#                       list_char='-'):
#     def __classinit__(cls, new_attrs):
#     def __init__(self, *args, **kw):
#     def to_python(self, value, state=None):
#     def from_python(self, value, state=None):
#         def _message_vars_decode(self, message_vars):
#     def message(self, msgName, state, **kw):
#     def all_messages(self):
#     def subvalidators(self):
#     def _initialize_docstring(cls):
#     def __repr__(self):
#     def __classinit__(cls, new_attrs):
#     def to_python(self, value, state=None):
#     def from_python(self, value, state=None):
#     def is_empty(self, value):
#     def empty_value(self, value):
#     def assert_string(self, value, state):
#     def base64encode(self, value):
#     def _validate_noop(self, value, state=None):
# class NoDefault(object):
# class Invalid(Exception):
# class Validator(declarative.Declarative):
# class _Identity(Validator):
# class FancyValidator(Validator):


# Path: src/formencode/validators.py
import cgi
import locale
import re
import warnings
import six
    import dns.resolver
    import dns.exception
            import datetime as datetime_module
                import socket
            import socket
            import random
from encodings import idna
from six.moves import map
from six.moves import range
from .api import (FancyValidator, Identity, Invalid, NoDefault, Validator,
    deprecation_warning, is_empty)
            from mx import DateTime as mxDateTime_module
            from six.moves.urllib import parse as urlparse
            from six.moves import http_client
            from six.moves.urllib import parse as urlparse
    from formencode.national import USStateProvince
    from formencode.national import USPhoneNumber
    from formencode.national import InternationalPhoneNumber
    from formencode.national import USPostalCode
            from hashlib import sha1
            from hashlib import sha1

def PhoneNumber(*kw, **kwargs):
    deprecation_warning("please use formencode.national.USPhoneNumber")
    return USPhoneNumber(*kw, **kwargs)


def IPhoneNumberValidator(*kw, **kwargs):
    deprecation_warning(
        "please use formencode.national.InternationalPhoneNumber")
    return InternationalPhoneNumber(*kw, **kwargs)


class FieldStorageUploadConverter(FancyValidator):
    """
    Handles cgi.FieldStorage instances that are file uploads.

    This doesn't do any conversion, but it can detect empty upload
    fields (which appear like normal fields, but have no filename when
    no upload was given).
    """
    def _convert_to_python(self, value, state=None):
        if isinstance(value, cgi.FieldStorage):
            if getattr(value, 'filename', None):
                return value
            raise Invalid('invalid', value, state)
        else:
            return value

    def is_empty(self, value):
        if isinstance(value, cgi.FieldStorage):
            return not bool(getattr(value, 'filename', None))

        return FancyValidator.is_empty(self, value)