Ejemplo n.º 1
0
    def update(self, *args, **kwargs):

        if len(args) > 1:
            raise TypeError("update() takes at most 1 positional "
                            "arguments ({} given)".format(len(args)))
        if len(args) >= 1:
            other = args[0]
            if isinstance(other, KeyedList):
                # Merge
                for key, value in other.all_items():
                    self[key] = value
            else:
                MutableMapping.update(self, other)

        for key, value in kwargs.items():
            if isinstance(value, KeyedList):
                try:
                    subkl = self[key]
                except KeyError:
                    subkl = KeyedList()
                    self[key] = subkl
                else:
                    if not isinstance(subkl, KeyedList):
                        raise KeyError(
                            'target key "%s" is a value, cannot '
                            'update value against another keyed list' %
                            (key, ))
                subkl.update(value)
            else:
                self[key] = value
    def update(self, *args, **kwargs):

        if len(args) > 1:
            raise TypeError("update() takes at most 1 positional "
                            "arguments ({} given)".format(len(args)))
        if len(args) >= 1:
            other = args[0]
            if isinstance(other, KeyedList):
                # Merge
                for key, value in other.all_items():
                    self[key] = value
            else:
                MutableMapping.update(self, other)

        for key, value in kwargs.items():
            if isinstance(value, KeyedList):
                try:
                    subkl = self[key]
                except KeyError:
                    subkl = KeyedList()
                    self[key] = subkl
                else:
                    if not isinstance(subkl, KeyedList):
                        raise KeyError('target key "%s" is a value, cannot '
                                'update value against another keyed list' %
                                (key,))
                subkl.update(value)
            else:
                self[key] = value
Ejemplo n.º 3
0
    def update(*args, **kwds):
        self = args[0]

        with FastInserter(self.cursor):
            MutableMapping.update(*args, **kwds)
            # make table and index stored contiguously
            self.cursor.execute("VACUUM")
Ejemplo n.º 4
0
    def update(*args, **kwds):
        self = args[0]

        with FastInserter(self.cursor):
            MutableMapping.update(*args, **kwds)
            # make table and index stored contiguously
            self.cursor.execute('VACUUM')
Ejemplo n.º 5
0
 def update(self, *args, **kw):
     if args:
         lst = args[0]
         if len(lst) != len(dict(lst)):
             # this does not catch the cases where we overwrite existing
             # keys, but those would produce too many warning
             msg = (
                 "Behavior of MultiDict.update() has changed "
                 "and overwrites duplicate keys. Consider using .extend()")
             warnings.warn(msg, UserWarning, stacklevel=2)
     MutableMapping.update(self, *args, **kw)
Ejemplo n.º 6
0
 def update(self, *args, **kw):
     if args:
         lst = args[0]
         if len(lst) != len(dict(lst)):
             # this does not catch the cases where we overwrite existing
             # keys, but those would produce too many warning
             msg = ("Behavior of MultiDict.update() has changed "
                 "and overwrites duplicate keys. Consider using .extend()"
             )
             warnings.warn(msg, UserWarning, stacklevel=2)
     MutableMapping.update(self, *args, **kw)
Ejemplo n.º 7
0
 def __init__(*args, **kwargs):
     if not args:
         raise TypeError("OrderedDict.__init__() needs an instance as the first argument")
     self = args[0]
     args = args[1:]
     if len(args) > 1:
         raise TypeError("OrderedDict() takes at most 1 positional argument, got %d" % len(args))
     dict.__init__(self)
     if not self:
         self._keys = []
     MutableMapping.update(self, *args, **kwargs)
Ejemplo n.º 8
0
 def __init__(*args, **kwargs):
     if not args:
         raise TypeError(
             "OrderedDict.__init__() needs an instance as the first argument"
         )
     self = args[0]
     args = args[1:]
     if len(args) > 1:
         raise TypeError(
             "OrderedDict() takes at most 1 positional argument, got %d" %
             len(args))
     dict.__init__(self)
     if not self:
         self._keys = []
     MutableMapping.update(self, *args, **kwargs)