Exemplo n.º 1
0
	def __init__(self, dict):
		MiddleDict.__init__(self, {})
		for key, value in dict.items():
			if key == 'Attribute':
				key = 'Name'
			# @@ 2001-02-21 ce: should we always strip string fields? Probably.
			if type(value) in StringTypes and value.strip() == '':
				value = None
			self[key] = value
		match = nameRE.match(self['Name'])
		if match is None or len(match.groups()) != 1:
			raise ValueError, 'Bad name (%r) for attribute: %r.' % (self['Name'], dict)
		self._getPrefix = None
		self._setPrefix = None
Exemplo n.º 2
0
	def __init__(self, klassContainer, dict=None):
		""" Initializes a Klass definition with a raw dictionary, typically read from a file. The 'Class' field contains the name and can also contain the name of the superclass (like "Name : SuperName"). Multiple inheritance is not yet supported. """
		MiddleDict.__init__(self, {})
		self._klassContainer = klassContainer
		self._attrsList = []
		self._attrsByName = {}
		self._superklass = None
		self._subklasses = []
		self._pyClass = False   # False means never computed. None would mean computed, but not found.
		self._backObjRefAttrs = None
		self._allAttrs = None

		if dict is not None:
			self.readDict(dict)
Exemplo n.º 3
0
 def __init__(self, attr):
     MiddleDict.__init__(self, {})
     for key, value in attr.items():
         if key == "Attribute":
             key = "Name"
         if isinstance(value, basestring) and not value.strip():
             value = None
         self[key] = value
     name = self["Name"]
     match = nameRE.match(name)
     if match is None or len(match.groups()) != 1:
         raise ValueError("Bad name (%r) for attribute: %r." % (name, attr))
     match = reservedRE.match(name)
     if match is not None:
         raise ValueError("Reserved name (%r) for attribute: %r." % (name, attr))
     self._getPrefix = None
     self._setPrefix = None
Exemplo n.º 4
0
 def __init__(self, attr):
     MiddleDict.__init__(self, {})
     for key, value in attr.items():
         if key == 'Attribute':
             key = 'Name'
         if isinstance(value, basestring) and not value.strip():
             value = None
         self[key] = value
     name = self['Name']
     match = nameRE.match(name)
     if match is None or len(match.groups()) != 1:
         raise ValueError('Bad name (%r) for attribute: %r.' % (name, attr))
     match = reservedRE.match(name)
     if match is not None:
         raise ValueError('Reserved name (%r) for attribute: %r.' %
                          (name, attr))
     self._getPrefix = None
     self._setPrefix = None
Exemplo n.º 5
0
    def __init__(self, klassContainer, rawDict=None):
        """Initialize a Klass definition with a raw dictionary.

        This is typically read from a file. The 'Class' field contains the name
        and can also contain the name of the superclass (like "Name : SuperName").
        Multiple inheritance is not yet supported.
        """
        MiddleDict.__init__(self, {})
        self._klassContainer = klassContainer
        self._attrsList = []
        self._attrsByName = {}
        self._superklass = None
        self._subklasses = []
        # False means never computed; None would mean computed, but not found:
        self._pyClass = False
        self._backObjRefAttrs = None
        self._allAttrs = None
        if rawDict is not None:
            self.readDict(rawDict)