コード例 #1
0
 def __repr__(self):
     attrs = [
         ('%s=%r' % (keyword_identifier(normalize_unicode(t[0])), t[1]))
         for t in self._attribs.items()
     ]
     cl = self.__class__
     return "%s.%s(%s)" % (cl.__module__, cl.__name__, ", ".join(attrs))
コード例 #2
0
ファイル: POMparse.py プロジェクト: bharathi26/pycopia
 def startElement(self, name, atts):
     "Handle an event for the beginning of an element."
     try:
         klass = self._get_class(name)
     except AttributeError:
         raise POM.ValidationError("Undefined element tag: " + name)
     attr = {}
     for name, value in atts.items():
         attr[keyword_identifier(POM.normalize_unicode(name))] = POM.unescape(value)
     obj = klass(**attr)
     self.stack.append(obj)
コード例 #3
0
 def _add_element_attlist(self, element, xmlattribute, ident):
     try:
         attrmap = element.get_attribute("ATTRIBUTES")
         kwattrmap = element.get_attribute("KWATTRIBUTES")
     except KeyError:
         element.add_attribute("ATTRIBUTES", AttributeMap())
         element.add_attribute("KWATTRIBUTES", AttributeMap())
         attrmap = element.get_attribute("ATTRIBUTES")
         kwattrmap = element.get_attribute("KWATTRIBUTES")
     attrmap[xmlattribute.name] = ident
     keywordname = keyword_identifier(normalize_unicode(xmlattribute.name))
     kwattrmap[keywordname] = ident
コード例 #4
0
ファイル: DTD.py プロジェクト: animeshinvinci/pycopia
 def _add_element_attlist(self, element, xmlattribute, ident):
     try:
         attrmap = element.get_attribute("ATTRIBUTES")
         kwattrmap = element.get_attribute("KWATTRIBUTES")
     except KeyError:
         element.add_attribute("ATTRIBUTES", AttributeMap())
         element.add_attribute("KWATTRIBUTES", AttributeMap())
         attrmap = element.get_attribute("ATTRIBUTES")
         kwattrmap = element.get_attribute("KWATTRIBUTES")
     attrmap[xmlattribute.name] = ident
     keywordname = keyword_identifier(normalize_unicode(xmlattribute.name))
     kwattrmap[keywordname] = ident
コード例 #5
0
ファイル: POMparse.py プロジェクト: wildone/pycopia
 def startElement(self, name, atts):
     "Handle an event for the beginning of an element."
     try:
         klass = self._get_class(name)
     except AttributeError:
         raise POM.ValidationError("Undefined element tag: " + name)
     attr = {}
     for name, value in atts.items():
         attr[keyword_identifier(
             POM.normalize_unicode(name))] = POM.unescape(value)
     obj = klass(**attr)
     self.stack.append(obj)
コード例 #6
0
 def new_attribute(self, elem, a_name, a_type, a_decl, a_def):
     "Receives the declaration of a new attribute."
     attr = XMLAttribute(a_name, a_type, a_decl, a_def)
     ident = attr.get_identifier()
     self._allattributes[ident] = attr
     try:
         element = self.elements[elem]
     except KeyError:
         # Got a forward attribute definition (defined before element)
         try:
             fwdattribs, fwdkwattribs = self._forwardattributes[elem]
         except KeyError:
             fwdattribs = AttributeMap()
             fwdkwattribs = AttributeMap()
             self._forwardattributes[elem] = (fwdattribs, fwdkwattribs)
         fwdattribs[a_name] = ident
         keywordname = keyword_identifier(normalize_unicode(a_name))
         fwdkwattribs[keywordname] = ident
     else:
         self._add_element_attlist(element, attr, ident)
コード例 #7
0
ファイル: DTD.py プロジェクト: animeshinvinci/pycopia
 def new_attribute(self, elem, a_name, a_type, a_decl, a_def):
     "Receives the declaration of a new attribute."
     attr = XMLAttribute(a_name, a_type, a_decl, a_def)
     ident = attr.get_identifier()
     self._allattributes[ident] = attr
     try:
         element = self.elements[elem]
     except KeyError:
         # Got a forward attribute definition (defined before element)
         try:
             fwdattribs, fwdkwattribs = self._forwardattributes[elem]
         except KeyError:
             fwdattribs = AttributeMap()
             fwdkwattribs = AttributeMap()
             self._forwardattributes[elem] = (fwdattribs, fwdkwattribs)
         fwdattribs[a_name] = ident
         keywordname = keyword_identifier(normalize_unicode(a_name))
         fwdkwattribs[keywordname] = ident
     else:
         self._add_element_attlist(element, attr, ident)