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 — deepdiff/deepdiff/helper.py at master · sreecodeslayer/deepdiff Expand file tree/ Copy pathhelper.pyMore file actions 115 lines (87 loc) · 2.98 KB / Copy pathhelper.pyFile metadata and controls115 lines (87 loc) · 2.98 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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 # -*- coding: utf-8 -*- import sys import datetime from decimal import Decimal from collections import namedtuple import logging logger = logging.getLogger(__name__) py_major_version = sys.version[0] py_minor_version = sys.version[2] py3 = py_major_version == '3' if (py_major_version, py_minor_version) == (2.6): # pragma: no cover sys.exit('Python 2.6 is not supported.') pypy3 = py3 and hasattr(sys, "pypy_translation_info") if py3: # pragma: no cover from builtins import int strings = (str, bytes) # which are both basestring unicode_type = str bytes_type = bytes numbers = (int, float, complex, datetime.datetime, datetime.date, Decimal) items = 'items' else: # pragma: no cover int = int strings = (str, unicode) unicode_type = unicode bytes_type = str numbers = (int, float, long, complex, datetime.datetime, datetime.date, Decimal) items = 'iteritems' IndexedHash = namedtuple('IndexedHash', 'indexes item') EXPANDED_KEY_MAP = { # pragma: no cover 'dic_item_added': 'dictionary_item_added', 'dic_item_removed': 'dictionary_item_removed', 'newindexes': 'new_indexes', 'newrepeat': 'new_repeat', 'newtype': 'new_type', 'newvalue': 'new_value', 'oldindexes': 'old_indexes', 'oldrepeat': 'old_repeat', 'oldtype': 'old_type', 'oldvalue': 'old_value'} def short_repr(item, max_length=15): """Short representation of item if it is too long""" item = repr(item) if len(item) > max_length: item = '{}...{}'.format(item[:max_length - 3], item[-1]) return item class ListItemRemovedOrAdded(object): # pragma: no cover """Class of conditions to be checked""" pass class NotPresent(object): # pragma: no cover """ In a change tree, this indicated that a previously existing object has been removed -- or will only be added in the future. We previously used None for this but this caused problem when users actually added and removed None. Srsly guys? :D """ def __repr__(self): return "Not Present" def __str__(self): return self.__repr__() notpresent = NotPresent() WARNING_NUM = 0 def warn(*args, **kwargs): global WARNING_NUM if WARNING_NUM < 10: WARNING_NUM += 1 logger.warning(*args, **kwargs) class RemapDict(dict): """ Remap Dictionary. For keys that have a new, longer name, remap the old key to the new key. Other keys that don't have a new name are handled as before. """ def __getitem__(self, old_key): new_key = EXPANDED_KEY_MAP.get(old_key, old_key) if new_key != old_key: warn( "DeepDiff Deprecation: %s is renamed to %s. Please start using " "the new unified naming convention.", old_key, new_key) if new_key in self: return self.get(new_key) else: # pragma: no cover raise KeyError(new_key) class Verbose(object): """ Global verbose level """ level = 1 |
| You are visitor 01402775 — 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. |