GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — python-github3/pygithub3/core/compat.py at master · copitux/python-github3
This repository was archived by the owner on Oct 24, 2022. It is now read-only.
Expand file tree/ Copy pathcompat.pyMore file actions 100 lines (76 loc) · 2.51 KB / Copy pathcompat.pyFile metadata and controls100 lines (76 loc) · 2.51 KB 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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 #!/usr/bin/env python # -*- encoding: utf-8 -*- """ Utils to support python 2.6 compatibility """ from collections import MutableMapping def _import_module(module_uri): return __import__(module_uri, {}, {}, ['']) def import_module(module_uri): """ Import module by string 'from.path.module' To support python 2.6 """ try: from importlib import import_module callback = import_module except ImportError: callback = _import_module return callback(module_uri) class _OrderedDict(dict, MutableMapping): """ Src: http://code.activestate.com/recipes/576669/ Author: Raymond Hettinger (Promoter of PEP which introduces OrderDict into colletions module in python >2.7) """ # Methods with direct access to underlying attributes def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at 1 argument, got %d', len(args)) if not hasattr(self, '_keys'): self._keys = [] self.update(*args, **kwds) def clear(self): del self._keys[:] dict.clear(self) def __setitem__(self, key, value): if key not in self: self._keys.append(key) dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __iter__(self): return iter(self._keys) def __reversed__(self): return reversed(self._keys) def popitem(self): if not self: raise KeyError key = self._keys.pop() value = dict.pop(self, key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] inst_dict = vars(self).copy() inst_dict.pop('_keys', None) return (self.__class__, (items,), inst_dict) # Methods with indirect access via the above methods setdefault = MutableMapping.setdefault update = MutableMapping.update pop = MutableMapping.pop keys = MutableMapping.keys values = MutableMapping.values items = MutableMapping.items def __repr__(self): pairs = ', '.join(map('%r: %r'.__mod__, self.items())) return '%s({%s})' % (self.__class__.__name__, pairs) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d try: from collections import OrderedDict except ImportError: OrderedDict = _OrderedDict |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |