<s> """<STR_LIT>""" <EOL> import os <EOL> import logging <EOL> import re <EOL> import string <EOL> import wsgiref . util <EOL> if os . environ . get ( '<STR_LIT>' ) == '<STR_LIT>' : <EOL> from google . appengine . api import pagespeedinfo <EOL> from google . appengine . api import validation <EOL> from google . appengine . api import yaml_builder <EOL> from google . appengine . api import yaml_listener <EOL> from google . appengine . api import yaml_object <EOL> else : <EOL> from google . appengine . api import pagespeedinfo <EOL> from google . appengine . api import validation <EOL> from google . appengine . api import yaml_builder <EOL> from google . appengine . api import yaml_listener <EOL> from google . appengine . api import yaml_object <EOL> from google . appengine . api import appinfo_errors <EOL> from google . appengine . api import backendinfo <EOL> _URL_REGEX = r'<STR_LIT>' <EOL> _FILES_REGEX = r'<STR_LIT>' <EOL> _URL_ROOT_REGEX = r'<STR_LIT>' <EOL> _DELTA_REGEX = r'<STR_LIT>' <EOL> _EXPIRATION_REGEX = r'<STR_LIT>' % ( _DELTA_REGEX , _DELTA_REGEX ) <EOL> _START_PATH = '<STR_LIT>' <EOL> _ALLOWED_SERVICES = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> _SERVICE_RE_STRING = '<STR_LIT:(>' + '<STR_LIT:|>' . join ( _ALLOWED_SERVICES ) + '<STR_LIT:)>' <EOL> _PAGE_NAME_REGEX = r'<STR_LIT>' <EOL> _EXPIRATION_CONVERSIONS = { <EOL> '<STR_LIT:d>' : <NUM_LIT> * <NUM_LIT> * <NUM_LIT> , <EOL> '<STR_LIT:h>' : <NUM_LIT> * <NUM_LIT> , <EOL> '<STR_LIT:m>' : <NUM_LIT> , <EOL> '<STR_LIT:s>' : <NUM_LIT:1> , <EOL> } <EOL> APP_ID_MAX_LEN = <NUM_LIT:100> <EOL> SERVER_ID_MAX_LEN = <NUM_LIT> <EOL> SERVER_VERSION_ID_MAX_LEN = <NUM_LIT> <EOL> MAX_URL_MAPS = <NUM_LIT:100> <EOL> PARTITION_SEPARATOR = '<STR_LIT>' <EOL> DOMAIN_SEPARATOR = '<STR_LIT::>' <EOL> VERSION_SEPARATOR = '<STR_LIT:.>' <EOL> SERVER_SEPARATOR = '<STR_LIT::>' <EOL> DEFAULT_SERVER = '<STR_LIT:default>' <EOL> PARTITION_RE_STRING = ( r'<STR_LIT>' % <EOL> ( APP_ID_MAX_LEN , PARTITION_SEPARATOR ) ) <EOL> DOMAIN_RE_STRING = ( r'<STR_LIT>' % <EOL> ( APP_ID_MAX_LEN , DOMAIN_SEPARATOR ) ) <EOL> DISPLAY_APP_ID_RE_STRING = r'<STR_LIT>' % ( APP_ID_MAX_LEN - <NUM_LIT:1> ) <EOL> APPLICATION_RE_STRING = ( r'<STR_LIT>' % <EOL> ( PARTITION_RE_STRING , <EOL> DOMAIN_RE_STRING , <EOL> DISPLAY_APP_ID_RE_STRING ) ) <EOL> SERVER_ID_RE_STRING = r'<STR_LIT>' % ( SERVER_ID_MAX_LEN - <NUM_LIT:1> ) <EOL> SERVER_VERSION_ID_RE_STRING = ( r'<STR_LIT>' % <EOL> ( SERVER_VERSION_ID_MAX_LEN - <NUM_LIT:1> ) ) <EOL> _IDLE_INSTANCES_REGEX = r'<STR_LIT>' <EOL> _INSTANCES_REGEX = r'<STR_LIT>' <EOL> _INSTANCE_CLASS_REGEX = r'<STR_LIT>' <EOL> _PENDING_LATENCY_REGEX = r'<STR_LIT>' <EOL> _IDLE_TIMEOUT_REGEX = r'<STR_LIT>' <EOL> ALTERNATE_HOSTNAME_SEPARATOR = '<STR_LIT>' <EOL> BUILTIN_NAME_PREFIX = '<STR_LIT>' <EOL> RUNTIME_RE_STRING = r'<STR_LIT>' <EOL> API_VERSION_RE_STRING = r'<STR_LIT>' <EOL> SOURCE_LANGUAGE_RE_STRING = r'<STR_LIT>' <EOL> HANDLER_STATIC_FILES = '<STR_LIT>' <EOL> HANDLER_STATIC_DIR = '<STR_LIT>' <EOL> HANDLER_SCRIPT = '<STR_LIT>' <EOL> HANDLER_API_ENDPOINT = '<STR_LIT>' <EOL> LOGIN_OPTIONAL = '<STR_LIT>' <EOL> LOGIN_REQUIRED = '<STR_LIT>' <EOL> LOGIN_ADMIN = '<STR_LIT>' <EOL> AUTH_FAIL_ACTION_REDIRECT = '<STR_LIT>' <EOL> AUTH_FAIL_ACTION_UNAUTHORIZED = '<STR_LIT>' <EOL> SECURE_HTTP = '<STR_LIT>' <EOL> SECURE_HTTPS = '<STR_LIT>' <EOL> SECURE_HTTP_OR_HTTPS = '<STR_LIT>' <EOL> SECURE_DEFAULT = '<STR_LIT:default>' <EOL> REQUIRE_MATCHING_FILE = '<STR_LIT>' <EOL> DEFAULT_SKIP_FILES = ( r'<STR_LIT>' <EOL> r'<STR_LIT>' <EOL> r'<STR_LIT>' <EOL> r'<STR_LIT>' <EOL> r'<STR_LIT>' <EOL> r'<STR_LIT>' <EOL> r'<STR_LIT>' ) <EOL> DEFAULT_NOBUILD_FILES = ( r'<STR_LIT>' ) <EOL> LOGIN = '<STR_LIT>' <EOL> AUTH_FAIL_ACTION = '<STR_LIT>' <EOL> SECURE = '<STR_LIT>' <EOL> URL = '<STR_LIT:url>' <EOL> POSITION = '<STR_LIT>' <EOL> POSITION_HEAD = '<STR_LIT>' <EOL> POSITION_TAIL = '<STR_LIT>' <EOL> STATIC_FILES = '<STR_LIT>' <EOL> UPLOAD = '<STR_LIT>' <EOL> STATIC_DIR = '<STR_LIT>' <EOL> MIME_TYPE = '<STR_LIT>' <EOL> SCRIPT = '<STR_LIT>' <EOL> EXPIRATION = '<STR_LIT>' <EOL> API_ENDPOINT = '<STR_LIT>' <EOL> HTTP_HEADERS = '<STR_LIT>' <EOL> APPLICATION_READABLE = '<STR_LIT>' <EOL> APPLICATION = '<STR_LIT>' <EOL> SERVER = '<STR_LIT>' <EOL> AUTOMATIC_SCALING = '<STR_LIT>' <EOL> MANUAL_SCALING = '<STR_LIT>' <EOL> BASIC_SCALING = '<STR_LIT>' <EOL> VM = '<STR_LIT>' <EOL> VM_SETTINGS = '<STR_LIT>' <EOL> VERSION = '<STR_LIT:version>' <EOL> MAJOR_VERSION = '<STR_LIT>' <EOL> MINOR_VERSION = '<STR_LIT>' <EOL> RUNTIME = '<STR_LIT>' <EOL> API_VERSION = '<STR_LIT>' <EOL> SOURCE_LANGUAGE = '<STR_LIT>' <EOL> BUILTINS = '<STR_LIT>' <EOL> INCLUDES = '<STR_LIT>' <EOL> HANDLERS = '<STR_LIT>' <EOL> LIBRARIES = '<STR_LIT>' <EOL> DEFAULT_EXPIRATION = '<STR_LIT>' <EOL> SKIP_FILES = '<STR_LIT>' <EOL> NOBUILD_FILES = '<STR_LIT>' <EOL> SERVICES = '<STR_LIT>' <EOL> DERIVED_FILE_TYPE = '<STR_LIT>' <EOL> JAVA_PRECOMPILED = '<STR_LIT>' <EOL> PYTHON_PRECOMPILED = '<STR_LIT>' <EOL> ADMIN_CONSOLE = '<STR_LIT>' <EOL> ERROR_HANDLERS = '<STR_LIT>' <EOL> BACKENDS = '<STR_LIT>' <EOL> THREADSAFE = '<STR_LIT>' <EOL> API_CONFIG = '<STR_LIT>' <EOL> CODE_LOCK = '<STR_LIT>' <EOL> ENV_VARIABLES = '<STR_LIT>' <EOL> PAGESPEED = '<STR_LIT>' <EOL> INSTANCE_CLASS = '<STR_LIT>' <EOL> MINIMUM_PENDING_LATENCY = '<STR_LIT>' <EOL> MAXIMUM_PENDING_LATENCY = '<STR_LIT>' <EOL> MINIMUM_IDLE_INSTANCES = '<STR_LIT>' <EOL> MAXIMUM_IDLE_INSTANCES = '<STR_LIT>' <EOL> INSTANCES = '<STR_LIT>' <EOL> MAX_INSTANCES = '<STR_LIT>' <EOL> IDLE_TIMEOUT = '<STR_LIT>' <EOL> PAGES = '<STR_LIT>' <EOL> NAME = '<STR_LIT:name>' <EOL> ERROR_CODE = '<STR_LIT>' <EOL> FILE = '<STR_LIT:file>' <EOL> _ERROR_CODE_REGEX = r'<STR_LIT>' <EOL> ON = '<STR_LIT>' <EOL> ON_ALIASES = [ '<STR_LIT:yes>' , '<STR_LIT:y>' , '<STR_LIT:True>' , '<STR_LIT:t>' , '<STR_LIT:1>' , '<STR_LIT:true>' ] <EOL> OFF = '<STR_LIT>' <EOL> OFF_ALIASES = [ '<STR_LIT>' , '<STR_LIT:n>' , '<STR_LIT:False>' , '<STR_LIT:f>' , '<STR_LIT:0>' , '<STR_LIT:false>' ] <EOL> class _VersionedLibrary ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , <EOL> name , <EOL> url , <EOL> description , <EOL> supported_versions , <EOL> default_version = None , <EOL> deprecated_versions = None , <EOL> experimental_versions = None ) : <EOL> """<STR_LIT>""" <EOL> self . name = name <EOL> self . url = url <EOL> self . description = description <EOL> self . supported_versions = supported_versions <EOL> self . default_version = default_version <EOL> self . deprecated_versions = deprecated_versions or [ ] <EOL> self . experimental_versions = experimental_versions or [ ] <EOL> @ property <EOL> def non_deprecated_versions ( self ) : <EOL> return [ version for version in self . supported_versions <EOL> if version not in self . deprecated_versions ] <EOL> _SUPPORTED_LIBRARIES = [ <EOL> _VersionedLibrary ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> experimental_versions = [ '<STR_LIT>' ] , <EOL> ) , <EOL> _VersionedLibrary ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' ] ) , <EOL> _VersionedLibrary ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' ] ) , <EOL> _VersionedLibrary ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' ] ) , <EOL> _VersionedLibrary ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' ] , <EOL> experimental_versions = [ '<STR_LIT>' ] , <EOL> ) , <EOL> _VersionedLibrary ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' ] , <EOL> experimental_versions = [ '<STR_LIT>' ] <EOL> ) , <EOL> _VersionedLibrary ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' ] ) , <EOL> _VersionedLibrary ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' ] ) , <EOL> _VersionedLibrary ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' ] ) , <EOL> _VersionedLibrary ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> ) , <EOL> _VersionedLibrary ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' ] ) , <EOL> _VersionedLibrary ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' ] , <EOL> experimental_versions = [ '<STR_LIT>' ] ) , <EOL> _VersionedLibrary ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> default_version = '<STR_LIT>' , <EOL> deprecated_versions = [ '<STR_LIT>' ] <EOL> ) , <EOL> _VersionedLibrary ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> default_version = '<STR_LIT>' , <EOL> ) , <EOL> _VersionedLibrary ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' ] , <EOL> default_version = '<STR_LIT>' <EOL> ) , <EOL> ] <EOL> _NAME_TO_SUPPORTED_LIBRARY = dict ( ( library . name , library ) <EOL> for library in _SUPPORTED_LIBRARIES ) <EOL> REQUIRED_LIBRARIES = { <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) : [ ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) : [ ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) : [ ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) : [ ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) : [ ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> } <EOL> _USE_VERSION_FORMAT = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> _HTTP_SEPARATOR_CHARS = frozenset ( '<STR_LIT>' ) <EOL> _HTTP_TOKEN_CHARS = frozenset ( string . printable [ : - <NUM_LIT:5> ] ) - _HTTP_SEPARATOR_CHARS <EOL> _HTTP_TOKEN_RE = re . compile ( '<STR_LIT>' % re . escape ( '<STR_LIT>' . join ( _HTTP_TOKEN_CHARS ) ) ) <EOL> _HTTP_REQUEST_HEADERS = frozenset ( [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:host>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] ) <EOL> _MAX_COOKIE_LENGTH = <NUM_LIT> <EOL> _MAX_URL_LENGTH = <NUM_LIT> <EOL> class HandlerBase ( validation . Validated ) : <EOL> """<STR_LIT>""" <EOL> ATTRIBUTES = { <EOL> URL : validation . Optional ( _URL_REGEX ) , <EOL> LOGIN : validation . Options ( LOGIN_OPTIONAL , <EOL> LOGIN_REQUIRED , <EOL> LOGIN_ADMIN , <EOL> default = LOGIN_OPTIONAL ) , <EOL> AUTH_FAIL_ACTION : validation . Options ( AUTH_FAIL_ACTION_REDIRECT , <EOL> AUTH_FAIL_ACTION_UNAUTHORIZED , <EOL> default = AUTH_FAIL_ACTION_REDIRECT ) , <EOL> SECURE : validation . Options ( SECURE_HTTP , <EOL> SECURE_HTTPS , <EOL> SECURE_HTTP_OR_HTTPS , <EOL> SECURE_DEFAULT , <EOL> default = SECURE_DEFAULT ) , <EOL> HANDLER_SCRIPT : validation . Optional ( _FILES_REGEX ) <EOL> } <EOL> class HttpHeadersDict ( validation . ValidatedDict ) : <EOL> """<STR_LIT>""" <EOL> DISALLOWED_HEADERS = frozenset ( [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:date>' , <EOL> '<STR_LIT>' <EOL> ] ) <EOL> MAX_HEADER_LENGTH = <NUM_LIT> <EOL> MAX_HEADER_VALUE_LENGTHS = { <EOL> '<STR_LIT>' : _MAX_COOKIE_LENGTH , <EOL> '<STR_LIT>' : _MAX_COOKIE_LENGTH , <EOL> '<STR_LIT:location>' : _MAX_URL_LENGTH } <EOL> MAX_LEN = <NUM_LIT> <EOL> class KeyValidator ( validation . Validator ) : <EOL> """<STR_LIT>""" <EOL> def Validate ( self , name , unused_key = None ) : <EOL> """<STR_LIT>""" <EOL> original_name = name <EOL> if isinstance ( name , unicode ) : <EOL> try : <EOL> name = name . encode ( '<STR_LIT:ascii>' ) <EOL> except UnicodeEncodeError : <EOL> raise appinfo_errors . InvalidHttpHeaderName ( <EOL> '<STR_LIT>' ) <EOL> name = name . lower ( ) <EOL> if not _HTTP_TOKEN_RE . match ( name ) : <EOL> raise appinfo_errors . InvalidHttpHeaderName ( <EOL> '<STR_LIT>' ) <EOL> if name in _HTTP_REQUEST_HEADERS : <EOL> raise appinfo_errors . InvalidHttpHeaderName ( <EOL> '<STR_LIT>' <EOL> % original_name ) <EOL> if name . startswith ( '<STR_LIT>' ) : <EOL> raise appinfo_errors . InvalidHttpHeaderName ( <EOL> '<STR_LIT>' ) <EOL> if wsgiref . util . is_hop_by_hop ( name ) : <EOL> raise appinfo_errors . InvalidHttpHeaderName ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> if name in HttpHeadersDict . DISALLOWED_HEADERS : <EOL> raise appinfo_errors . InvalidHttpHeaderName ( <EOL> '<STR_LIT>' % name ) <EOL> return original_name <EOL> class ValueValidator ( validation . Validator ) : <EOL> """<STR_LIT>""" <EOL> def Validate ( self , value , key = None ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( value , unicode ) : <EOL> try : <EOL> value = value . encode ( '<STR_LIT:ascii>' ) <EOL> except UnicodeEncodeError : <EOL> raise appinfo_errors . InvalidHttpHeaderValue ( <EOL> '<STR_LIT>' ) <EOL> key = key . lower ( ) <EOL> printable = set ( string . printable [ : - <NUM_LIT:5> ] ) <EOL> if not all ( char in printable for char in value ) : <EOL> raise appinfo_errors . InvalidHttpHeaderValue ( <EOL> '<STR_LIT>' ) <EOL> HttpHeadersDict . ValueValidator . AssertHeaderNotTooLong ( key , value ) <EOL> return value <EOL> @ staticmethod <EOL> def AssertHeaderNotTooLong ( name , value ) : <EOL> header_length = len ( '<STR_LIT>' % ( name , value ) ) <EOL> if header_length >= HttpHeadersDict . MAX_HEADER_LENGTH : <EOL> try : <EOL> max_len = HttpHeadersDict . MAX_HEADER_VALUE_LENGTHS [ name ] <EOL> except KeyError : <EOL> raise appinfo_errors . InvalidHttpHeaderValue ( <EOL> '<STR_LIT>' ) <EOL> if len ( value ) > max_len : <EOL> insert = name , len ( value ) , max_len <EOL> raise appinfo_errors . InvalidHttpHeaderValue ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % insert ) <EOL> KEY_VALIDATOR = KeyValidator ( ) <EOL> VALUE_VALIDATOR = ValueValidator ( ) <EOL> def Get ( self , header_name ) : <EOL> """<STR_LIT>""" <EOL> for name in self : <EOL> if name . lower ( ) == header_name . lower ( ) : <EOL> return self [ name ] <EOL> def __setitem__ ( self , key , value ) : <EOL> is_addition = self . Get ( key ) is None <EOL> if is_addition and len ( self ) >= self . MAX_LEN : <EOL> raise appinfo_errors . TooManyHttpHeaders ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> % HttpHeadersDict . MAX_LEN ) <EOL> super ( HttpHeadersDict , self ) . __setitem__ ( key , value ) <EOL> class URLMap ( HandlerBase ) : <EOL> """<STR_LIT>""" <EOL> ATTRIBUTES = { <EOL> HANDLER_STATIC_FILES : validation . Optional ( _FILES_REGEX ) , <EOL> UPLOAD : validation . Optional ( _FILES_REGEX ) , <EOL> APPLICATION_READABLE : validation . Optional ( bool ) , <EOL> HANDLER_STATIC_DIR : validation . Optional ( _FILES_REGEX ) , <EOL> MIME_TYPE : validation . Optional ( str ) , <EOL> EXPIRATION : validation . Optional ( _EXPIRATION_REGEX ) , <EOL> REQUIRE_MATCHING_FILE : validation . Optional ( bool ) , <EOL> HTTP_HEADERS : validation . Optional ( HttpHeadersDict ) , <EOL> POSITION : validation . Optional ( validation . Options ( POSITION_HEAD , <EOL> POSITION_TAIL ) ) , <EOL> HANDLER_API_ENDPOINT : validation . Optional ( validation . Options ( <EOL> ( ON , ON_ALIASES ) , <EOL> ( OFF , OFF_ALIASES ) ) ) , <EOL> } <EOL> ATTRIBUTES . update ( HandlerBase . ATTRIBUTES ) <EOL> COMMON_FIELDS = set ( [ URL , LOGIN , AUTH_FAIL_ACTION , SECURE ] ) <EOL> ALLOWED_FIELDS = { <EOL> HANDLER_STATIC_FILES : ( MIME_TYPE , UPLOAD , EXPIRATION , <EOL> REQUIRE_MATCHING_FILE , HTTP_HEADERS , <EOL> APPLICATION_READABLE ) , <EOL> HANDLER_STATIC_DIR : ( MIME_TYPE , EXPIRATION , REQUIRE_MATCHING_FILE , <EOL> HTTP_HEADERS , APPLICATION_READABLE ) , <EOL> HANDLER_SCRIPT : ( POSITION ) , <EOL> HANDLER_API_ENDPOINT : ( POSITION , SCRIPT ) , <EOL> } <EOL> def GetHandler ( self ) : <EOL> """<STR_LIT>""" <EOL> return getattr ( self , self . GetHandlerType ( ) ) <EOL> def GetHandlerType ( self ) : <EOL> """<STR_LIT>""" <EOL> if getattr ( self , HANDLER_API_ENDPOINT ) is not None : <EOL> mapping_type = HANDLER_API_ENDPOINT <EOL> else : <EOL> for id_field in URLMap . ALLOWED_FIELDS . iterkeys ( ) : <EOL> if getattr ( self , id_field ) is not None : <EOL> mapping_type = id_field <EOL> break <EOL> else : <EOL> raise appinfo_errors . UnknownHandlerType ( <EOL> '<STR_LIT>' % str ( self ) ) <EOL> allowed_fields = URLMap . ALLOWED_FIELDS [ mapping_type ] <EOL> for attribute in self . ATTRIBUTES . iterkeys ( ) : <EOL> if ( getattr ( self , attribute ) is not None and <EOL> not ( attribute in allowed_fields or <EOL> attribute in URLMap . COMMON_FIELDS or <EOL> attribute == mapping_type ) ) : <EOL> raise appinfo_errors . UnexpectedHandlerAttribute ( <EOL> '<STR_LIT>' % <EOL> ( attribute , mapping_type ) ) <EOL> if mapping_type == HANDLER_STATIC_FILES and not self . upload : <EOL> raise appinfo_errors . MissingHandlerAttribute ( <EOL> '<STR_LIT>' % ( UPLOAD , self . url ) ) <EOL> return mapping_type <EOL> def CheckInitialized ( self ) : <EOL> """<STR_LIT>""" <EOL> super ( URLMap , self ) . CheckInitialized ( ) <EOL> if self . GetHandlerType ( ) in ( STATIC_DIR , STATIC_FILES ) : <EOL> self . AssertUniqueContentType ( ) <EOL> def AssertUniqueContentType ( self ) : <EOL> """<STR_LIT>""" <EOL> used_both_fields = self . mime_type and self . http_headers <EOL> if not used_both_fields : <EOL> return <EOL> content_type = self . http_headers . Get ( '<STR_LIT:Content-Type>' ) <EOL> if content_type is not None : <EOL> raise appinfo_errors . ContentTypeSpecifiedMultipleTimes ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % ( content_type , self . mime_type ) ) <EOL> def FixSecureDefaults ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . secure == SECURE_DEFAULT : <EOL> self . secure = SECURE_HTTP_OR_HTTPS <EOL> def WarnReservedURLs ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . url == '<STR_LIT>' : <EOL> logging . warning ( <EOL> '<STR_LIT>' ) <EOL> def ErrorOnPositionForAppInfo ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . position : <EOL> raise appinfo_errors . PositionUsedInAppYamlHandler ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> class AdminConsolePage ( validation . Validated ) : <EOL> """<STR_LIT>""" <EOL> ATTRIBUTES = { <EOL> URL : _URL_REGEX , <EOL> NAME : _PAGE_NAME_REGEX , <EOL> } <EOL> class AdminConsole ( validation . Validated ) : <EOL> """<STR_LIT>""" <EOL> ATTRIBUTES = { <EOL> PAGES : validation . Optional ( validation . Repeated ( AdminConsolePage ) ) , <EOL> } <EOL> @ classmethod <EOL> def Merge ( cls , adminconsole_one , adminconsole_two ) : <EOL> """<STR_LIT>""" <EOL> if not adminconsole_one or not adminconsole_two : <EOL> return adminconsole_one or adminconsole_two <EOL> if adminconsole_one . pages : <EOL> if adminconsole_two . pages : <EOL> adminconsole_one . pages . extend ( adminconsole_two . pages ) <EOL> else : <EOL> adminconsole_one . pages = adminconsole_two . pages <EOL> return adminconsole_one <EOL> class ErrorHandlers ( validation . Validated ) : <EOL> """<STR_LIT>""" <EOL> ATTRIBUTES = { <EOL> ERROR_CODE : validation . Optional ( _ERROR_CODE_REGEX ) , <EOL> FILE : _FILES_REGEX , <EOL> MIME_TYPE : validation . Optional ( str ) , <EOL> } <EOL> class BuiltinHandler ( validation . Validated ) : <EOL> """<STR_LIT>""" <EOL> class DynamicAttributes ( dict ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , return_value , ** parameters ) : <EOL> self . __return_value = return_value <EOL> dict . __init__ ( self , parameters ) <EOL> def __contains__ ( self , _ ) : <EOL> return True <EOL> def __getitem__ ( self , _ ) : <EOL> return self . __return_value <EOL> ATTRIBUTES = DynamicAttributes ( <EOL> validation . Optional ( validation . Options ( ( ON , ON_ALIASES ) , <EOL> ( OFF , OFF_ALIASES ) ) ) ) <EOL> def __init__ ( self , ** attributes ) : <EOL> """<STR_LIT>""" <EOL> self . builtin_name = '<STR_LIT>' <EOL> super ( BuiltinHandler , self ) . __init__ ( ** attributes ) <EOL> def __setattr__ ( self , key , value ) : <EOL> """<STR_LIT>""" <EOL> if key == '<STR_LIT>' : <EOL> object . __setattr__ ( self , key , value ) <EOL> elif not self . builtin_name : <EOL> self . ATTRIBUTES [ key ] = '<STR_LIT>' <EOL> self . builtin_name = key <EOL> super ( BuiltinHandler , self ) . __setattr__ ( key , value ) <EOL> else : <EOL> raise appinfo_errors . MultipleBuiltinsSpecified ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> def __getattr__ ( self , key ) : <EOL> if key . startswith ( '<STR_LIT:_>' ) : <EOL> raise AttributeError <EOL> return None <EOL> def ToDict ( self ) : <EOL> """<STR_LIT>""" <EOL> return { self . builtin_name : getattr ( self , self . builtin_name ) } <EOL> @ classmethod <EOL> def IsDefined ( cls , builtins_list , builtin_name ) : <EOL> """<STR_LIT>""" <EOL> for b in builtins_list : <EOL> if b . builtin_name == builtin_name : <EOL> return True <EOL> return False <EOL> @ classmethod <EOL> def ListToTuples ( cls , builtins_list ) : <EOL> """<STR_LIT>""" <EOL> return [ ( b . builtin_name , getattr ( b , b . builtin_name ) ) for b in builtins_list ] <EOL> @ classmethod <EOL> def Validate ( cls , builtins_list , runtime = None ) : <EOL> """<STR_LIT>""" <EOL> seen = set ( ) <EOL> for b in builtins_list : <EOL> if not b . builtin_name : <EOL> raise appinfo_errors . InvalidBuiltinFormat ( <EOL> '<STR_LIT>' <EOL> % b ) <EOL> if b . builtin_name in seen : <EOL> raise appinfo_errors . DuplicateBuiltinsSpecified ( <EOL> '<STR_LIT>' <EOL> % b . builtin_name ) <EOL> if b . builtin_name == '<STR_LIT>' and runtime == '<STR_LIT>' : <EOL> logging . warning ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> elif b . builtin_name == '<STR_LIT>' and runtime == '<STR_LIT>' : <EOL> logging . warning ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> seen . add ( b . builtin_name ) <EOL> class ApiConfigHandler ( HandlerBase ) : <EOL> """<STR_LIT>""" <EOL> ATTRIBUTES = HandlerBase . ATTRIBUTES <EOL> ATTRIBUTES . update ( { <EOL> URL : validation . Regex ( _URL_REGEX ) , <EOL> HANDLER_SCRIPT : validation . Regex ( _FILES_REGEX ) <EOL> } ) <EOL> class Library ( validation . Validated ) : <EOL> """<STR_LIT>""" <EOL> ATTRIBUTES = { '<STR_LIT:name>' : validation . Type ( str ) , <EOL> '<STR_LIT:version>' : validation . Type ( str ) } <EOL> def CheckInitialized ( self ) : <EOL> """<STR_LIT>""" <EOL> super ( Library , self ) . CheckInitialized ( ) <EOL> if self . name not in _NAME_TO_SUPPORTED_LIBRARY : <EOL> raise appinfo_errors . InvalidLibraryName ( <EOL> '<STR_LIT>' % self . name ) <EOL> supported_library = _NAME_TO_SUPPORTED_LIBRARY [ self . name ] <EOL> if self . version != '<STR_LIT>' : <EOL> if self . version not in supported_library . supported_versions : <EOL> raise appinfo_errors . InvalidLibraryVersion ( <EOL> ( '<STR_LIT>' + _USE_VERSION_FORMAT ) % ( <EOL> self . name , <EOL> self . version , <EOL> '<STR_LIT>' . join ( supported_library . non_deprecated_versions ) ) ) <EOL> elif self . version in supported_library . deprecated_versions : <EOL> logging . warning ( <EOL> ( '<STR_LIT>' + _USE_VERSION_FORMAT ) % ( <EOL> self . name , <EOL> self . version , <EOL> '<STR_LIT>' . join ( supported_library . non_deprecated_versions ) ) ) <EOL> class AutomaticScaling ( validation . Validated ) : <EOL> """<STR_LIT>""" <EOL> ATTRIBUTES = { <EOL> MINIMUM_IDLE_INSTANCES : validation . Optional ( _IDLE_INSTANCES_REGEX ) , <EOL> MAXIMUM_IDLE_INSTANCES : validation . Optional ( _IDLE_INSTANCES_REGEX ) , <EOL> MINIMUM_PENDING_LATENCY : validation . Optional ( _PENDING_LATENCY_REGEX ) , <EOL> MAXIMUM_PENDING_LATENCY : validation . Optional ( _PENDING_LATENCY_REGEX ) , <EOL> } <EOL> class ManualScaling ( validation . Validated ) : <EOL> """<STR_LIT>""" <EOL> ATTRIBUTES = { <EOL> INSTANCES : validation . Regex ( _INSTANCES_REGEX ) , <EOL> } <EOL> class BasicScaling ( validation . Validated ) : <EOL> """<STR_LIT>""" <EOL> ATTRIBUTES = { <EOL> MAX_INSTANCES : validation . Regex ( _INSTANCES_REGEX ) , <EOL> IDLE_TIMEOUT : validation . Optional ( _IDLE_TIMEOUT_REGEX ) , <EOL> } <EOL> class VmSettings ( validation . ValidatedDict ) : <EOL> """<STR_LIT>""" <EOL> KEY_VALIDATOR = validation . Regex ( '<STR_LIT>' ) <EOL> VALUE_VALIDATOR = str <EOL> @ classmethod <EOL> def Merge ( cls , vm_settings_one , vm_settings_two ) : <EOL> result_vm_settings = ( vm_settings_two or { } ) . copy ( ) <EOL> result_vm_settings . update ( vm_settings_one or { } ) <EOL> return VmSettings ( ** result_vm_settings ) if result_vm_settings else None <EOL> class EnvironmentVariables ( validation . ValidatedDict ) : <EOL> """<STR_LIT>""" <EOL> KEY_VALIDATOR = validation . Regex ( '<STR_LIT>' ) <EOL> VALUE_VALIDATOR = str <EOL> class AppInclude ( validation . Validated ) : <EOL> """<STR_LIT>""" <EOL> ATTRIBUTES = { <EOL> BUILTINS : validation . Optional ( validation . Repeated ( BuiltinHandler ) ) , <EOL> INCLUDES : validation . Optional ( validation . Type ( list ) ) , <EOL> HANDLERS : validation . Optional ( validation . Repeated ( URLMap ) ) , <EOL> ADMIN_CONSOLE : validation . Optional ( AdminConsole ) , <EOL> MANUAL_SCALING : validation . Optional ( ManualScaling ) , <EOL> VM_SETTINGS : validation . Optional ( VmSettings ) , <EOL> } <EOL> @ classmethod <EOL> def MergeManualScaling ( cls , appinclude_one , appinclude_two ) : <EOL> """<STR_LIT>""" <EOL> def _Instances ( appinclude ) : <EOL> if appinclude . manual_scaling : <EOL> if appinclude . manual_scaling . instances : <EOL> return int ( appinclude . manual_scaling . instances ) <EOL> return None <EOL> instances = max ( _Instances ( appinclude_one ) , _Instances ( appinclude_two ) ) <EOL> if instances is not None : <EOL> appinclude_one . manual_scaling = ManualScaling ( instances = str ( instances ) ) <EOL> return appinclude_one <EOL> @ classmethod <EOL> def MergeAppYamlAppInclude ( cls , appyaml , appinclude ) : <EOL> """<STR_LIT>""" <EOL> if not appinclude : <EOL> return appyaml <EOL> if appinclude . handlers : <EOL> tail = appyaml . handlers or [ ] <EOL> appyaml . handlers = [ ] <EOL> for h in appinclude . handlers : <EOL> if not h . position or h . position == '<STR_LIT>' : <EOL> appyaml . handlers . append ( h ) <EOL> else : <EOL> tail . append ( h ) <EOL> h . position = None <EOL> appyaml . handlers . extend ( tail ) <EOL> AppInclude . MergeManualScaling ( appyaml , appinclude ) <EOL> appyaml . admin_console = AdminConsole . Merge ( appyaml . admin_console , <EOL> appinclude . admin_console ) <EOL> appyaml . vm_settings = VmSettings . Merge ( appyaml . vm_settings , <EOL> appinclude . vm_settings ) <EOL> return appyaml <EOL> @ classmethod <EOL> def MergeAppIncludes ( cls , appinclude_one , appinclude_two ) : <EOL> """<STR_LIT>""" <EOL> if not appinclude_one or not appinclude_two : <EOL> return appinclude_one or appinclude_two <EOL> if appinclude_one . handlers : <EOL> if appinclude_two . handlers : <EOL> appinclude_one . handlers . extend ( appinclude_two . handlers ) <EOL> else : <EOL> appinclude_one . handlers = appinclude_two . handlers <EOL> appinclude_one = AppInclude . MergeManualScaling ( <EOL> appinclude_one , <EOL> appinclude_two ) <EOL> appinclude_one . admin_console = ( <EOL> AdminConsole . Merge ( appinclude_one . admin_console , <EOL> appinclude_two . admin_console ) ) <EOL> appinclude_one . vm_settings = VmSettings . Merge ( <EOL> appinclude_one . vm_settings , <EOL> appinclude_two . vm_settings ) <EOL> return appinclude_one <EOL> class AppInfoExternal ( validation . Validated ) : <EOL> """<STR_LIT>""" <EOL> ATTRIBUTES = { <EOL> APPLICATION : APPLICATION_RE_STRING , <EOL> SERVER : validation . Optional ( SERVER_ID_RE_STRING ) , <EOL> VERSION : validation . Optional ( SERVER_VERSION_ID_RE_STRING ) , <EOL> RUNTIME : RUNTIME_RE_STRING , <EOL> API_VERSION : API_VERSION_RE_STRING , <EOL> INSTANCE_CLASS : validation . Optional ( _INSTANCE_CLASS_REGEX ) , <EOL> SOURCE_LANGUAGE : validation . Optional ( <EOL> validation . Regex ( SOURCE_LANGUAGE_RE_STRING ) ) , <EOL> AUTOMATIC_SCALING : validation . Optional ( AutomaticScaling ) , <EOL> MANUAL_SCALING : validation . Optional ( ManualScaling ) , <EOL> BASIC_SCALING : validation . Optional ( BasicScaling ) , <EOL> VM : validation . Optional ( bool ) , <EOL> VM_SETTINGS : validation . Optional ( VmSettings ) , <EOL> BUILTINS : validation . Optional ( validation . Repeated ( BuiltinHandler ) ) , <EOL> INCLUDES : validation . Optional ( validation . Type ( list ) ) , <EOL> HANDLERS : validation . Optional ( validation . Repeated ( URLMap ) ) , <EOL> LIBRARIES : validation . Optional ( validation . Repeated ( Library ) ) , <EOL> SERVICES : validation . Optional ( validation . Repeated ( <EOL> validation . Regex ( _SERVICE_RE_STRING ) ) ) , <EOL> DEFAULT_EXPIRATION : validation . Optional ( _EXPIRATION_REGEX ) , <EOL> SKIP_FILES : validation . RegexStr ( default = DEFAULT_SKIP_FILES ) , <EOL> NOBUILD_FILES : validation . RegexStr ( default = DEFAULT_NOBUILD_FILES ) , <EOL> DERIVED_FILE_TYPE : validation . Optional ( validation . Repeated ( <EOL> validation . Options ( JAVA_PRECOMPILED , PYTHON_PRECOMPILED ) ) ) , <EOL> ADMIN_CONSOLE : validation . Optional ( AdminConsole ) , <EOL> ERROR_HANDLERS : validation . Optional ( validation . Repeated ( ErrorHandlers ) ) , <EOL> BACKENDS : validation . Optional ( validation . Repeated ( <EOL> backendinfo . BackendEntry ) ) , <EOL> THREADSAFE : validation . Optional ( bool ) , <EOL> API_CONFIG : validation . Optional ( ApiConfigHandler ) , <EOL> CODE_LOCK : validation . Optional ( bool ) , <EOL> ENV_VARIABLES : validation . Optional ( EnvironmentVariables ) , <EOL> PAGESPEED : validation . Optional ( pagespeedinfo . PagespeedEntry ) , <EOL> } <EOL> _skip_runtime_checks = False <EOL> def CheckInitialized ( self ) : <EOL> """<STR_LIT>""" <EOL> super ( AppInfoExternal , self ) . CheckInitialized ( ) <EOL> if not self . handlers and not self . builtins and not self . includes : <EOL> raise appinfo_errors . MissingURLMapping ( <EOL> '<STR_LIT>' ) <EOL> if self . handlers and len ( self . handlers ) > MAX_URL_MAPS : <EOL> raise appinfo_errors . TooManyURLMappings ( <EOL> '<STR_LIT>' % <EOL> MAX_URL_MAPS ) <EOL> if ( self . threadsafe is None and <EOL> self . runtime == '<STR_LIT>' and <EOL> not self . _skip_runtime_checks ) : <EOL> raise appinfo_errors . MissingThreadsafe ( <EOL> '<STR_LIT>' ) <EOL> if self . libraries : <EOL> if self . runtime != '<STR_LIT>' and not self . _skip_runtime_checks : <EOL> raise appinfo_errors . RuntimeDoesNotSupportLibraries ( <EOL> '<STR_LIT>' ) <EOL> library_names = [ library . name for library in self . libraries ] <EOL> for library_name in library_names : <EOL> if library_names . count ( library_name ) > <NUM_LIT:1> : <EOL> raise appinfo_errors . DuplicateLibrary ( <EOL> '<STR_LIT>' % library_name ) <EOL> if self . version and self . version . find ( ALTERNATE_HOSTNAME_SEPARATOR ) != - <NUM_LIT:1> : <EOL> raise validation . ValidationError ( <EOL> '<STR_LIT>' % ( <EOL> self . version , ALTERNATE_HOSTNAME_SEPARATOR ) ) <EOL> if self . version and self . version . startswith ( BUILTIN_NAME_PREFIX ) : <EOL> raise validation . ValidationError ( <EOL> ( '<STR_LIT>' <EOL> '<STR_LIT>' ) % ( self . version , <EOL> BUILTIN_NAME_PREFIX ) ) <EOL> if self . handlers : <EOL> api_endpoints = [ handler . url for handler in self . handlers <EOL> if handler . GetHandlerType ( ) == HANDLER_API_ENDPOINT ] <EOL> if api_endpoints and not self . api_config : <EOL> raise appinfo_errors . MissingApiConfig ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> if ( self . threadsafe and <EOL> self . runtime == '<STR_LIT>' and <EOL> not self . _skip_runtime_checks ) : <EOL> for handler in self . handlers : <EOL> if ( handler . script and ( handler . script . endswith ( '<STR_LIT>' ) or <EOL> '<STR_LIT:/>' in handler . script ) ) : <EOL> raise appinfo_errors . ThreadsafeWithCgiHandler ( <EOL> '<STR_LIT>' % <EOL> handler . script ) <EOL> if sum ( [ bool ( self . automatic_scaling ) , <EOL> bool ( self . manual_scaling ) , <EOL> bool ( self . basic_scaling ) ] ) > <NUM_LIT:1> : <EOL> raise appinfo_errors . TooManyScalingSettingsError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def GetAllLibraries ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . libraries : <EOL> return [ ] <EOL> library_names = set ( library . name for library in self . libraries ) <EOL> required_libraries = [ ] <EOL> for library in self . libraries : <EOL> for required_name , required_version in REQUIRED_LIBRARIES . get ( <EOL> ( library . name , library . version ) , [ ] ) : <EOL> if required_name not in library_names : <EOL> required_libraries . append ( Library ( name = required_name , <EOL> version = required_version ) ) <EOL> return [ Library ( ** library . ToDict ( ) ) <EOL> for library in self . libraries + required_libraries ] <EOL> def GetNormalizedLibraries ( self ) : <EOL> """<STR_LIT>""" <EOL> libraries = self . GetAllLibraries ( ) <EOL> enabled_libraries = set ( library . name for library in libraries ) <EOL> for library in _SUPPORTED_LIBRARIES : <EOL> if library . default_version and library . name not in enabled_libraries : <EOL> libraries . append ( Library ( name = library . name , <EOL> version = library . default_version ) ) <EOL> for library in libraries : <EOL> if library . version == '<STR_LIT>' : <EOL> library . version = _NAME_TO_SUPPORTED_LIBRARY [ <EOL> library . name ] . supported_versions [ - <NUM_LIT:1> ] <EOL> return libraries <EOL> def ApplyBackendSettings ( self , backend_name ) : <EOL> """<STR_LIT>""" <EOL> if backend_name is None : <EOL> return <EOL> if self . backends is None : <EOL> raise appinfo_errors . BackendNotFound <EOL> self . version = backend_name <EOL> match = None <EOL> for backend in self . backends : <EOL> if backend . name != backend_name : <EOL> continue <EOL> if match : <EOL> raise appinfo_errors . DuplicateBackend <EOL> else : <EOL> match = backend <EOL> if match is None : <EOL> raise appinfo_errors . BackendNotFound <EOL> if match . start is None : <EOL> return <EOL> start_handler = URLMap ( url = _START_PATH , script = match . start ) <EOL> self . handlers . insert ( <NUM_LIT:0> , start_handler ) <EOL> def ValidateHandlers ( handlers , is_include_file = False ) : <EOL> """<STR_LIT>""" <EOL> if not handlers : <EOL> return <EOL> for handler in handlers : <EOL> handler . FixSecureDefaults ( ) <EOL> handler . WarnReservedURLs ( ) <EOL> if not is_include_file : <EOL> handler . ErrorOnPositionForAppInfo ( ) <EOL> def LoadSingleAppInfo ( app_info ) : <EOL> """<STR_LIT>""" <EOL> builder = yaml_object . ObjectBuilder ( AppInfoExternal ) <EOL> handler = yaml_builder . BuilderHandler ( builder ) <EOL> listener = yaml_listener . EventListener ( handler ) <EOL> listener . Parse ( app_info ) <EOL> app_infos = handler . GetResults ( ) <EOL> if len ( app_infos ) < <NUM_LIT:1> : <EOL> raise appinfo_errors . EmptyConfigurationFile ( ) <EOL> if len ( app_infos ) > <NUM_LIT:1> : <EOL> raise appinfo_errors . MultipleConfigurationFile ( ) <EOL> appyaml = app_infos [ <NUM_LIT:0> ] <EOL> ValidateHandlers ( appyaml . handlers ) <EOL> if appyaml . builtins : <EOL> BuiltinHandler . Validate ( appyaml . builtins , appyaml . runtime ) <EOL> if appyaml . vm : <EOL> if not appyaml . vm_settings : <EOL> appyaml . vm_settings = VmSettings ( ) <EOL> if not '<STR_LIT>' in appyaml . vm_settings : <EOL> appyaml . vm_settings [ '<STR_LIT>' ] = appyaml . runtime <EOL> appyaml . runtime = '<STR_LIT>' <EOL> return appyaml <EOL> class AppInfoSummary ( validation . Validated ) : <EOL> """<STR_LIT>""" <EOL> ATTRIBUTES = { <EOL> APPLICATION : APPLICATION_RE_STRING , <EOL> MAJOR_VERSION : SERVER_VERSION_ID_RE_STRING , <EOL> MINOR_VERSION : validation . TYPE_LONG <EOL> } <EOL> def LoadAppInclude ( app_include ) : <EOL> """<STR_LIT>""" <EOL> builder = yaml_object . ObjectBuilder ( AppInclude ) <EOL> handler = yaml_builder . BuilderHandler ( builder ) <EOL> listener = yaml_listener . EventListener ( handler ) <EOL> listener . Parse ( app_include ) <EOL> includes = handler . GetResults ( ) <EOL> if len ( includes ) < <NUM_LIT:1> : <EOL> raise appinfo_errors . EmptyConfigurationFile ( ) <EOL> if len ( includes ) > <NUM_LIT:1> : <EOL> raise appinfo_errors . MultipleConfigurationFile ( ) <EOL> includeyaml = includes [ <NUM_LIT:0> ] <EOL> if includeyaml . handlers : <EOL> for handler in includeyaml . handlers : <EOL> handler . FixSecureDefaults ( ) <EOL> handler . WarnReservedURLs ( ) <EOL> if includeyaml . builtins : <EOL> BuiltinHandler . Validate ( includeyaml . builtins ) <EOL> return includeyaml <EOL> def ParseExpiration ( expiration ) : <EOL> """<STR_LIT>""" <EOL> delta = <NUM_LIT:0> <EOL> for match in re . finditer ( _DELTA_REGEX , expiration ) : <EOL> amount = int ( match . group ( <NUM_LIT:1> ) ) <EOL> units = _EXPIRATION_CONVERSIONS . get ( match . group ( <NUM_LIT:2> ) . lower ( ) , <NUM_LIT:1> ) <EOL> delta += amount * units <EOL> return delta <EOL> _file_path_positive_re = re . compile ( r'<STR_LIT>' ) <EOL> _file_path_negative_1_re = re . compile ( r'<STR_LIT>' ) <EOL> _file_path_negative_2_re = re . compile ( r'<STR_LIT>' ) <EOL> _file_path_negative_3_re = re . compile ( r'<STR_LIT>' ) <EOL> def ValidFilename ( filename ) : <EOL> """<STR_LIT>""" <EOL> if _file_path_positive_re . match ( filename ) is None : <EOL> return '<STR_LIT>' % filename <EOL> if _file_path_negative_1_re . search ( filename ) is not None : <EOL> return ( '<STR_LIT>' <EOL> '<STR_LIT>' % <EOL> filename ) <EOL> if _file_path_negative_2_re . search ( filename ) is not None : <EOL> return '<STR_LIT>' % filename <EOL> if _file_path_negative_3_re . search ( filename ) is not None : <EOL> return '<STR_LIT>' % filename <EOL> return '<STR_LIT>' </s>
