thirdparty/google_appengine/google/appengine/api/appinfo.py
changeset 149 f2e327a7c5de
parent 109 620f9b141567
child 297 35211afcd563
equal deleted inserted replaced
148:37505d64e57b 149:f2e327a7c5de
    37 _URL_REGEX = r'(?!\^)/|\.|(\(.).*(?!\$).'
    37 _URL_REGEX = r'(?!\^)/|\.|(\(.).*(?!\$).'
    38 _FILES_REGEX = r'(?!\^).*(?!\$).'
    38 _FILES_REGEX = r'(?!\^).*(?!\$).'
    39 
    39 
    40 _DELTA_REGEX = r'([1-9][0-9]*)([DdHhMm]|[sS]?)'
    40 _DELTA_REGEX = r'([1-9][0-9]*)([DdHhMm]|[sS]?)'
    41 _EXPIRATION_REGEX = r'\s*(%s)(\s+%s)*\s*' % (_DELTA_REGEX, _DELTA_REGEX)
    41 _EXPIRATION_REGEX = r'\s*(%s)(\s+%s)*\s*' % (_DELTA_REGEX, _DELTA_REGEX)
       
    42 
       
    43 _EXPIRATION_CONVERSIONS = {
       
    44   'd': 60 * 60 * 24,
       
    45   'h': 60 * 60,
       
    46   'm': 60,
       
    47   's': 1,
       
    48 }
    42 
    49 
    43 APP_ID_MAX_LEN = 100
    50 APP_ID_MAX_LEN = 100
    44 MAJOR_VERSION_ID_MAX_LEN = 100
    51 MAJOR_VERSION_ID_MAX_LEN = 100
    45 MAX_URL_MAPS = 100
    52 MAX_URL_MAPS = 100
    46 
    53 
   338   if len(app_infos) > 1:
   345   if len(app_infos) > 1:
   339     raise appinfo_errors.MultipleConfigurationFile()
   346     raise appinfo_errors.MultipleConfigurationFile()
   340   return app_infos[0]
   347   return app_infos[0]
   341 
   348 
   342 
   349 
       
   350 def ParseExpiration(expiration):
       
   351   """Parses an expiration delta string.
       
   352 
       
   353   Args:
       
   354     expiration: String that matches _DELTA_REGEX.
       
   355 
       
   356   Returns:
       
   357     Time delta in seconds.
       
   358   """
       
   359   delta = 0
       
   360   for match in re.finditer(_DELTA_REGEX, expiration):
       
   361     amount = int(match.group(1))
       
   362     units = _EXPIRATION_CONVERSIONS.get(match.group(2).lower(), 1)
       
   363     delta += amount * units
       
   364   return delta
       
   365 
       
   366 
       
   367 
   343 _file_path_positive_re = re.compile(r'^[ 0-9a-zA-Z\._\+/\$-]{1,256}$')
   368 _file_path_positive_re = re.compile(r'^[ 0-9a-zA-Z\._\+/\$-]{1,256}$')
   344 
   369 
   345 _file_path_negative_1_re = re.compile(r'\.\.|^\./|\.$|/\./|^-')
   370 _file_path_negative_1_re = re.compile(r'\.\.|^\./|\.$|/\./|^-')
   346 
   371 
   347 _file_path_negative_2_re = re.compile(r'//|/$')
   372 _file_path_negative_2_re = re.compile(r'//|/$')