/usr/lib/pypy/dist-packages/rply/utils.py is in pypy-rply 0.7.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | import sys
from collections import MutableMapping
class IdentityDict(MutableMapping):
def __init__(self):
self._contents = {}
self._keepalive = []
def __getitem__(self, key):
return self._contents[id(key)][1]
def __setitem__(self, key, value):
idx = len(self._keepalive)
self._keepalive.append(key)
self._contents[id(key)] = key, value, idx
def __delitem__(self, key):
del self._contents[id(key)]
for idx, obj in enumerate(self._keepalive):
if obj is key:
del self._keepalive[idx]
break
def __len__(self):
return len(self._contents)
def __iter__(self):
for key, _, _ in itervalues(self._contents):
yield key
class Counter(object):
def __init__(self):
self.value = 0
def incr(self):
self.value += 1
if sys.version_info >= (3,):
def itervalues(d):
return d.values()
def iteritems(d):
return d.items()
else:
def itervalues(d):
return d.itervalues()
def iteritems(d):
return d.iteritems()
|