Python UserDict.DictMixin.items() Examples

The following are 30 code examples of UserDict.DictMixin.items(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module UserDict.DictMixin , or try the search function .
Example #1
Source File: inirama.py    From linter-pylama with MIT License 6 votes vote down vote up
def write(self, f):
        """ Write namespace as INI file.

        :param f: File object or path to file.

        """
        if isinstance(f, str):
            f = io.open(f, 'w', encoding='utf-8')

        if not hasattr(f, 'read'):
            raise AttributeError("Wrong type of file: {0}".format(type(f)))

        NS_LOGGER.info('Write to `{0}`'.format(f.name))
        for section in self.sections.keys():
            f.write('[{0}]\n'.format(section))
            for k, v in self[section].items():
                f.write('{0:15}= {1}\n'.format(k, v))
            f.write('\n')
        f.close() 
Example #2
Source File: ordereddict.py    From splunk-ref-pas-code with Apache License 2.0 5 votes vote down vote up
def __eq__(self, other):
        if isinstance(other, OrderedDict):
            if len(self) != len(other):
                return False
            for p, q in  zip(self.items(), other.items()):
                if p != q:
                    return False
            return True
        return dict.__eq__(self, other) 
Example #3
Source File: ordDict.py    From teleport with Apache License 2.0 5 votes vote down vote up
def __eq__(self, other):
        if isinstance(other, OrderedDict):
            if len(self) != len(other):
                return False
            for p, q in zip(self.items(), other.items()):
                if p != q:
                    return False
            return True
        return dict.__eq__(self, other) 
Example #4
Source File: ordereddict.py    From SA-ctf_scoreboard_admin with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
def __reduce__(self):
        items = [[k, self[k]] for k in self]
        tmp = self.__map, self.__end
        del self.__map, self.__end
        inst_dict = vars(self).copy()
        self.__map, self.__end = tmp
        if inst_dict:
            return (self.__class__, (items,), inst_dict)
        return self.__class__, (items,) 
Example #5
Source File: ordereddict.py    From SA-ctf_scoreboard_admin with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
def __repr__(self):
        if not self:
            return '%s()' % (self.__class__.__name__,)
        return '%s(%r)' % (self.__class__.__name__, self.items()) 
Example #6
Source File: ordDict.py    From teleport with Apache License 2.0 5 votes vote down vote up
def __repr__(self):
        if not self:
            return '%s()' % (self.__class__.__name__,)
        return '%s(%r)' % (self.__class__.__name__, self.items()) 
Example #7
Source File: _ordereddict.py    From teleport with Apache License 2.0 5 votes vote down vote up
def __repr__(self):
            if not self:
                return '%s()' % (self.__class__.__name__,)
            return '%s(%r)' % (self.__class__.__name__, self.items()) 
Example #8
Source File: _ordereddict.py    From teleport with Apache License 2.0 5 votes vote down vote up
def __reduce__(self):
            items = [[k, self[k]] for k in self]
            tmp = self.__map, self.__end
            del self.__map, self.__end
            inst_dict = vars(self).copy()
            self.__map, self.__end = tmp
            if inst_dict:
                return (self.__class__, (items,), inst_dict)
            return self.__class__, (items,) 
Example #9
Source File: ordDict.py    From teleport with Apache License 2.0 5 votes vote down vote up
def __repr__(self):
        if not self:
            return '%s()' % (self.__class__.__name__,)
        return '%s(%r)' % (self.__class__.__name__, self.items()) 
Example #10
Source File: ordDict.py    From teleport with Apache License 2.0 5 votes vote down vote up
def __reduce__(self):
        items = [[k, self[k]] for k in self]
        tmp = self.__map, self.__end
        del self.__map, self.__end
        inst_dict = vars(self).copy()
        self.__map, self.__end = tmp
        if inst_dict:
            return (self.__class__, (items,), inst_dict)
        return self.__class__, (items,) 
Example #11
Source File: _ordereddict.py    From teleport with Apache License 2.0 5 votes vote down vote up
def __eq__(self, other):
            if isinstance(other, OrderedDict):
                if len(self) != len(other):
                    return False
                for p, q in zip(self.items(), other.items()):
                    if p != q:
                        return False
                return True
            return dict.__eq__(self, other) 
Example #12
Source File: _ordereddict.py    From bioforum with MIT License 5 votes vote down vote up
def __reduce__(self):
            items = [[k, self[k]] for k in self]
            tmp = self.__map, self.__end
            del self.__map, self.__end
            inst_dict = vars(self).copy()
            self.__map, self.__end = tmp
            if inst_dict:
                return (self.__class__, (items,), inst_dict)
            return self.__class__, (items,) 
Example #13
Source File: ordereddict.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def __eq__(self, other):
        if isinstance(other, OrderedDict):
            if len(self) != len(other):
                return False
            for p, q in  zip(self.items(), other.items()):
                if p != q:
                    return False
            return True
        return dict.__eq__(self, other) 
Example #14
Source File: ordereddict.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def __repr__(self):
        if not self:
            return '%s()' % (self.__class__.__name__,)
        return '%s(%r)' % (self.__class__.__name__, self.items()) 
Example #15
Source File: ordereddict.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def __reduce__(self):
        items = [[k, self[k]] for k in self]
        tmp = self.__map, self.__end
        del self.__map, self.__end
        inst_dict = vars(self).copy()
        self.__map, self.__end = tmp
        if inst_dict:
            return (self.__class__, (items,), inst_dict)
        return self.__class__, (items,) 
Example #16
Source File: _ordereddict.py    From bioforum with MIT License 5 votes vote down vote up
def __repr__(self):
            if not self:
                return '%s()' % (self.__class__.__name__,)
            return '%s(%r)' % (self.__class__.__name__, self.items()) 
Example #17
Source File: ordereddict.py    From splunk-ref-pas-code with Apache License 2.0 5 votes vote down vote up
def __repr__(self):
        if not self:
            return '%s()' % (self.__class__.__name__,)
        return '%s(%r)' % (self.__class__.__name__, self.items()) 
Example #18
Source File: ordereddict.py    From splunk-ref-pas-code with Apache License 2.0 5 votes vote down vote up
def __reduce__(self):
        items = [[k, self[k]] for k in self]
        tmp = self.__map, self.__end
        del self.__map, self.__end
        inst_dict = vars(self).copy()
        self.__map, self.__end = tmp
        if inst_dict:
            return (self.__class__, (items,), inst_dict)
        return self.__class__, (items,) 
Example #19
Source File: ordereddict.py    From kobo-predict with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def __eq__(self, other):
        if isinstance(other, OrderedDict):
            if len(self) != len(other):
                return False
            for p, q in  zip(self.items(), other.items()):
                if p != q:
                    return False
            return True
        return dict.__eq__(self, other) 
Example #20
Source File: ordereddict.py    From kobo-predict with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def __repr__(self):
        if not self:
            return '%s()' % (self.__class__.__name__,)
        return '%s(%r)' % (self.__class__.__name__, self.items()) 
Example #21
Source File: ordereddict.py    From kobo-predict with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def __reduce__(self):
        items = [[k, self[k]] for k in self]
        tmp = self.__map, self.__end
        del self.__map, self.__end
        inst_dict = vars(self).copy()
        self.__map, self.__end = tmp
        if inst_dict:
            return (self.__class__, (items,), inst_dict)
        return self.__class__, (items,) 
Example #22
Source File: python2x.py    From D-VAE with MIT License 5 votes vote down vote up
def __repr__(self):
            if not self:
                return '%s()' % self.__class__.__name__
            items = ', '.join(map('%r: %r'.__mod__, self.most_common()))
            return '%s({%s})' % (self.__class__.__name__, items)

        # Multiset-style mathematical operations discussed in:
        #       Knuth TAOCP Volume II section 4.6.3 exercise 19
        #       and at http://en.wikipedia.org/wiki/Multiset
        #
        # Outputs guaranteed to only include positive counts.
        #
        # To strip negative and zero counts, add-in an empty counter:
        #       c += Counter() 
Example #23
Source File: python2x.py    From D-VAE with MIT License 5 votes vote down vote up
def __eq__(self, other):
            if isinstance(other, OrderedDict):
                if len(self) != len(other):
                    return False
                for p, q in zip(self.items(), other.items()):
                    if p != q:
                        return False
                return True
            return dict.__eq__(self, other) 
Example #24
Source File: python2x.py    From D-VAE with MIT License 5 votes vote down vote up
def __repr__(self):
            if not self:
                return '%s()' % (self.__class__.__name__,)
            return '%s(%r)' % (self.__class__.__name__, list(self.items())) 
Example #25
Source File: python2x.py    From D-VAE with MIT License 5 votes vote down vote up
def __reduce__(self):
            items = [[k, self[k]] for k in self]
            tmp = self.__map, self.__end
            del self.__map, self.__end
            inst_dict = vars(self).copy()
            self.__map, self.__end = tmp
            if inst_dict:
                return (self.__class__, (items,), inst_dict)
            return self.__class__, (items,) 
Example #26
Source File: ordereddict.py    From OpenMTC with Eclipse Public License 1.0 5 votes vote down vote up
def __eq__(self, other):
        if isinstance(other, OrderedDict):
            if len(self) != len(other):
                return False
            for p, q in  zip(self.items(), other.items()):
                if p != q:
                    return False
            return True
        return dict.__eq__(self, other) 
Example #27
Source File: ordereddict.py    From OpenMTC with Eclipse Public License 1.0 5 votes vote down vote up
def __repr__(self):
        if not self:
            return '%s()' % (self.__class__.__name__,)
        return '%s(%r)' % (self.__class__.__name__, self.items()) 
Example #28
Source File: ordereddict.py    From OpenMTC with Eclipse Public License 1.0 5 votes vote down vote up
def __reduce__(self):
        items = [[k, self[k]] for k in self]
        tmp = self.__map, self.__end
        del self.__map, self.__end
        inst_dict = vars(self).copy()
        self.__map, self.__end = tmp
        if inst_dict:
            return (self.__class__, (items,), inst_dict)
        return self.__class__, (items,) 
Example #29
Source File: ordereddict.py    From tf-pose with Apache License 2.0 5 votes vote down vote up
def __eq__(self, other):
            if isinstance(other, OrderedDict):
                if len(self) != len(other):
                    return False
                for p, q in  zip(self.items(), other.items()):
                    if p != q:
                        return False
                return True
            return dict.__eq__(self, other) 
Example #30
Source File: ordereddict.py    From tf-pose with Apache License 2.0 5 votes vote down vote up
def __repr__(self):
            if not self:
                return '%s()' % (self.__class__.__name__,)
            return '%s(%r)' % (self.__class__.__name__, self.items())