xmlclass/xmlclass.py
changeset 2439 f0a040f1de1b
parent 2434 07f48018b6f5
child 2450 5024c19ca8f0
equal deleted inserted replaced
2438:0f2e5303f212 2439:f0a040f1de1b
    59 
    59 
    60 
    60 
    61 # Regular expression models for checking all kind of
    61 # Regular expression models for checking all kind of
    62 # string values defined in XML standard
    62 # string values defined in XML standard
    63 
    63 
    64 Name_model = re.compile('([a-zA-Z_\:][\w\.\-\:]*)$')
    64 Name_model = re.compile(r'([a-zA-Z_\:][\w\.\-\:]*)$')
    65 Names_model = re.compile('([a-zA-Z_\:][\w\.\-\:]*(?: [a-zA-Z_\:][\w\.\-\:]*)*)$')
    65 Names_model = re.compile(r'([a-zA-Z_\:][\w\.\-\:]*(?: [a-zA-Z_\:][\w\.\-\:]*)*)$')
    66 NMToken_model = re.compile('([\w\.\-\:]*)$')
    66 NMToken_model = re.compile(r'([\w\.\-\:]*)$')
    67 NMTokens_model = re.compile('([\w\.\-\:]*(?: [\w\.\-\:]*)*)$')
    67 NMTokens_model = re.compile(r'([\w\.\-\:]*(?: [\w\.\-\:]*)*)$')
    68 QName_model = re.compile('((?:[a-zA-Z_][\w]*:)?[a-zA-Z_][\w]*)$')
    68 QName_model = re.compile(r'((?:[a-zA-Z_][\w]*:)?[a-zA-Z_][\w]*)$')
    69 QNames_model = re.compile('((?:[a-zA-Z_][\w]*:)?[a-zA-Z_][\w]*(?: (?:[a-zA-Z_][\w]*:)?[a-zA-Z_][\w]*)*)$')
    69 QNames_model = re.compile(r'((?:[a-zA-Z_][\w]*:)?[a-zA-Z_][\w]*(?: (?:[a-zA-Z_][\w]*:)?[a-zA-Z_][\w]*)*)$')
    70 NCName_model = re.compile('([a-zA-Z_][\w]*)$')
    70 NCName_model = re.compile(r'([a-zA-Z_][\w]*)$')
    71 URI_model = re.compile('((?:htt(p|ps)://|/)?(?:[\w.-]*/?)*)$')
    71 URI_model = re.compile(r'((?:htt(p|ps)://|/)?(?:[\w.-]*/?)*)$')
    72 LANGUAGE_model = re.compile('([a-zA-Z]{1,8}(?:-[a-zA-Z0-9]{1,8})*)$')
    72 LANGUAGE_model = re.compile(r'([a-zA-Z]{1,8}(?:-[a-zA-Z0-9]{1,8})*)$')
    73 
    73 
    74 ONLY_ANNOTATION = re.compile("((?:annotation )?)")
    74 ONLY_ANNOTATION = re.compile(r"((?:annotation )?)")
    75 
    75 
    76 """
    76 """
    77 Regular expression models for extracting dates and times from a string
    77 Regular expression models for extracting dates and times from a string
    78 """
    78 """
    79 time_model = re.compile('([0-9]{2}):([0-9]{2}):([0-9]{2}(?:\.[0-9]*)?)(?:Z)?$')
    79 time_model = re.compile(r'([0-9]{2}):([0-9]{2}):([0-9]{2}(?:\.[0-9]*)?)(?:Z)?$')
    80 date_model = re.compile('([0-9]{4})-([0-9]{2})-([0-9]{2})((?:[\-\+][0-9]{2}:[0-9]{2})|Z)?$')
    80 date_model = re.compile(r'([0-9]{4})-([0-9]{2})-([0-9]{2})((?:[\-\+][0-9]{2}:[0-9]{2})|Z)?$')
    81 datetime_model = re.compile('([0-9]{4})-([0-9]{2})-([0-9]{2})[ T]([0-9]{2}):([0-9]{2}):([0-9]{2}(?:\.[0-9]*)?)((?:[\-\+][0-9]{2}:[0-9]{2})|Z)?$')
    81 datetime_model = re.compile(r'([0-9]{4})-([0-9]{2})-([0-9]{2})[ T]([0-9]{2}):([0-9]{2}):([0-9]{2}(?:\.[0-9]*)?)((?:[\-\+][0-9]{2}:[0-9]{2})|Z)?$')
    82 
    82 
    83 
    83 
    84 class xml_timezone(datetime.tzinfo):
    84 class xml_timezone(datetime.tzinfo):
    85 
    85 
    86     def SetOffset(self, offset):
    86     def SetOffset(self, offset):
  1247     elements = []
  1247     elements = []
  1248     for element in classinfos["elements"]:
  1248     for element in classinfos["elements"]:
  1249         if element["type"] == ANY:
  1249         if element["type"] == ANY:
  1250             infos = element.copy()
  1250             infos = element.copy()
  1251             infos["minOccurs"] = 0
  1251             infos["minOccurs"] = 0
  1252             elements.append(ComputeMultiplicity("#text |#cdata-section |\w* ", infos))
  1252             elements.append(ComputeMultiplicity(r"#text |#cdata-section |\w* ", infos))
  1253         elif element["type"] == CHOICE:
  1253         elif element["type"] == CHOICE:
  1254             choices = []
  1254             choices = []
  1255             for infos in element["choices"]:
  1255             for infos in element["choices"]:
  1256                 if infos["type"] == "sequence":
  1256                 if infos["type"] == "sequence":
  1257                     structure = "(?:%s)" % GetStructurePattern(infos)
  1257                     structure = "(?:%s)" % GetStructurePattern(infos)
  1719     def countMethod(self):
  1719     def countMethod(self):
  1720         return len(getattr(self, attr))
  1720         return len(getattr(self, attr))
  1721     return countMethod
  1721     return countMethod
  1722 
  1722 
  1723 
  1723 
  1724 NAMESPACE_PATTERN = re.compile("xmlns(?:\:[^\=]*)?=\"[^\"]*\" ")
  1724 NAMESPACE_PATTERN = re.compile(r"xmlns(?:\:[^\=]*)?=\"[^\"]*\" ")
  1725 
  1725 
  1726 
  1726 
  1727 class DefaultElementClass(etree.ElementBase):
  1727 class DefaultElementClass(etree.ElementBase):
  1728 
  1728 
  1729     StructurePattern = re.compile("$")
  1729     StructurePattern = re.compile("$")