mirror of
https://github.com/python/cpython.git
synced 2025-07-28 21:55:21 +00:00
collections.Mapping is not available for setup.py. Remove the dependency the old-fashioned way (copy and paste).
This commit is contained in:
parent
3bae626fd2
commit
44d8bb0891
1 changed files with 32 additions and 2 deletions
|
@ -88,7 +88,7 @@ ConfigParser -- responsible for parsing a list of
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from collections import Mapping, OrderedDict as _default_dict
|
from collections import OrderedDict as _default_dict
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# fallback for setup.py which hasn't yet built _collections
|
# fallback for setup.py which hasn't yet built _collections
|
||||||
_default_dict = dict
|
_default_dict = dict
|
||||||
|
@ -515,7 +515,7 @@ class RawConfigParser:
|
||||||
if e:
|
if e:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
class _Chainmap(Mapping):
|
class _Chainmap:
|
||||||
"""Combine multiple mappings for successive lookups.
|
"""Combine multiple mappings for successive lookups.
|
||||||
|
|
||||||
For example, to emulate Python's normal lookup sequence:
|
For example, to emulate Python's normal lookup sequence:
|
||||||
|
@ -548,6 +548,36 @@ class _Chainmap(Mapping):
|
||||||
s.update(*self.maps)
|
s.update(*self.maps)
|
||||||
return len(s)
|
return len(s)
|
||||||
|
|
||||||
|
def get(self, key, default=None):
|
||||||
|
try:
|
||||||
|
return self[key]
|
||||||
|
except KeyError:
|
||||||
|
return default
|
||||||
|
|
||||||
|
def __contains__(self, key):
|
||||||
|
try:
|
||||||
|
self[key]
|
||||||
|
except KeyError:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
def keys(self):
|
||||||
|
return list(self)
|
||||||
|
|
||||||
|
def items(self):
|
||||||
|
return [(k, self[k]) for k in self]
|
||||||
|
|
||||||
|
def values(self):
|
||||||
|
return [self[k] for k in self]
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
return dict(self.items()) == dict(other.items())
|
||||||
|
|
||||||
|
def __ne__(self, other):
|
||||||
|
return not (self == other)
|
||||||
|
|
||||||
|
|
||||||
class ConfigParser(RawConfigParser):
|
class ConfigParser(RawConfigParser):
|
||||||
|
|
||||||
def get(self, section, option, raw=False, vars=None):
|
def get(self, section, option, raw=False, vars=None):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue