Beispiel #1
0
 def __init__(self, filePath=None, key=None):
     OrderedDict.__init__(self)
     if filePath != None and os.path.isfile(filePath):
         self.read(filePath, key)
     else:
         self._filename = filePath
     self.curStanza = None
    def test_init(self):
        self.assertRaises(TypeError, OrderedDict, ([('a', 1), ('b', 2)], None))
        # too many args
        pairs = [('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e', 5)]
        self.assertEqual(sorted(OrderedDict(dict(pairs)).items()),
                         pairs)  # dict input
        self.assertEqual(sorted(OrderedDict(**dict(pairs)).items()),
                         pairs)  # kwds input
        self.assertEqual(list(OrderedDict(pairs).items()),
                         pairs)  # pairs input
        self.assertEqual(
            list(
                OrderedDict([('a', 1), ('b', 2), ('c', 9), ('d', 4)], c=3,
                            e=5).items()), pairs)  # mixed input

        # make sure no positional args conflict with possible kwdargs
        self.assertEqual(
            inspect.getargspec(OrderedDict.__dict__['__init__'])[0], ['self'])

        # Make sure that direct calls to __init__ do not clear previous contents
        d = OrderedDict([('a', 1), ('b', 2), ('c', 3), ('d', 44), ('e', 55)])
        d.__init__([('e', 5), ('f', 6)], g=7, d=4)
        self.assertEqual(list(d.items()), [('a', 1), ('b', 2), ('c', 3),
                                           ('d', 4), ('e', 5), ('f', 6),
                                           ('g', 7)])
Beispiel #3
0
 def __init__(self, filePath=None, key=None):
     OrderedDict.__init__(self)
     if filePath != None and os.path.isfile(filePath):
         self.read(filePath, key)
     else:
         self._filename = filePath
     self.curStanza = None
Beispiel #4
0
 def __init__(self, datafile=None,xml=None,atoms=None):
     OrderedDict.__init__(self)
     if datafile is not None:
         self.read(datafile)
     elif xml is not None:
         self.read_xml(xml)
     elif atoms is not None:
         self.update_from_atoms(atoms)
Beispiel #5
0
 def __init__(self, key=None, value=None):
     OrderedDict.__init__(self)
     if key != None and value != None:
         self[key] = value
         self._name = value
         self._nametype = key
     else:
         self._name = ''
         self._nametype = ''
    def __init__(self, *args, **kwargs):
        """
		This method initializes the class.

		:param \*args: Arguments. ( \* )
		:param \*\*kwargs: Key / Value pairs. ( Key / Value pairs )
		"""

        OrderedDict.__init__(self, *args, **kwargs)
	def __init__(self, *args, **kwargs):
		"""
		Initializes the class.

		:param \*args: Arguments.
		:type \*args: \*
		:param \*\*kwargs: Key / Value pairs.
		:type \*\*kwargs: dict
		"""

		OrderedDict.__init__(self, *args, **kwargs)
    def __init__(self, *args, **kwargs):
        """
		Initializes the class.

		:param \*args: Arguments.
		:type \*args: \*
		:param \*\*kwargs: Key / Value pairs.
		:type \*\*kwargs: dict
		"""

        OrderedDict.__init__(self, *args, **kwargs)
    def test_init(self):
        self.assertRaises(TypeError, OrderedDict, ([('a', 1), ('b', 2)], None))
                # too many args
        pairs = [('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e', 5)]
        self.assertEqual(sorted(OrderedDict(dict(pairs)).items()), pairs)           # dict input
        self.assertEqual(sorted(OrderedDict(**dict(pairs)).items()), pairs)         # kwds input
        self.assertEqual(list(OrderedDict(pairs).items()), pairs)                   # pairs input
        self.assertEqual(list(OrderedDict([('a', 1), ('b', 2), ('c', 9), ('d', 4)],
                                          c=3, e=5).items()), pairs)                # mixed input

        # make sure no positional args conflict with possible kwdargs
        self.assertEqual(inspect.getargspec(OrderedDict.__dict__['__init__'])[0],
                         ['self'])

        # Make sure that direct calls to __init__ do not clear previous contents
        d = OrderedDict([('a', 1), ('b', 2), ('c', 3), ('d', 44), ('e', 55)])
        d.__init__([('e', 5), ('f', 6)], g=7, d=4)
        self.assertEqual(list(d.items()),
            [('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e', 5), ('f', 6), ('g', 7)])
Beispiel #10
0
    def __init__(self, filename=None, domain=None):
        """Build a MessageCatalog, either by reading from a .po-file or
        specifying a domain."""
        OrderedDict.__init__(self, None)

        # XOR
        assert not (filename and domain)
        assert filename or domain

        self.commentary_header = DEFAULT_PO_HEADER
        self.mime_header = OrderedDict()
        for key, value in DEFAULT_PO_MIME:
            self.mime_header[key] = value

        self.filename = filename
        self.domain = domain
        self.encoding = 'utf-8'

        if filename:
            self._initialize_with(filename)
        elif domain:
            self.mime_header['Domain'] = domain
Beispiel #11
0
    def __init__(self, filename=None, domain=None):
        """Build a MessageCatalog, either by reading from a .po-file or
        specifying a domain."""
        OrderedDict.__init__(self, None)

        # XOR
        assert not (filename and domain)
        assert filename or domain

        self.commentary_header = DEFAULT_PO_HEADER
        self.mime_header = OrderedDict()
        for key, value in DEFAULT_PO_MIME:
            self.mime_header[key] = value

        self.filename = filename
        self.domain = domain
        self.encoding = 'utf-8'

        if filename:
            self._initialize_with(filename)
        elif domain:
            self.mime_header['Domain'] = domain
Beispiel #12
0
 def __init__(self, fileName, *args, **kw):
     OrderedDict.__init__(self, *args, **kw)
     self.readingFile = fileName
Beispiel #13
0
    def __init__(self, maxsize=100):
        OrderedDict.__init__(self)

        self._maxsize = maxsize
Beispiel #14
0
 def __init__(self, s=None, D=None):
    OrderedDict.__init__(self)
    if s is not None:
       self.read(s)
    if D is not None:
       self.update(D)
Beispiel #15
0
 def __init__(self, source=None):
     OrderedDict.__init__(self)
     if source is not None:
         self.read(source)
Beispiel #16
0
 def __init__(self, cellfile=None, xml=None):
     OrderedDict.__init__(self)
     if cellfile is not None:
         self.read(cellfile)
     elif xml is not None:
         self.read_xml(xml)
Beispiel #17
0
 def __init__(self, paramfile=None, xml=None):
     OrderedDict.__init__(self)
     if paramfile is not None:
         self.read(paramfile)
     elif xml is not None:
         self.read_xml(xml)
 def __init__(self, *args, **kwargs):
     OrderedDict.__init__(self, *args, **kwargs)
     if not "cls_name" in self:
         self["cls_name"] = self.__class__.__name__
     if not "cls_attr" in self:
         self["cls_attr"] = ""
Beispiel #19
0
 def __init__(self, fileName, *args, **kw):
     OrderedDict.__init__(self, *args, **kw)
     self.readingFile = fileName