This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.defineProperty(Object.prototype, "setdefault", { | |
value: function(key, value) { | |
if (!this.hasOwnProperty(key)) { | |
if (typeof value === 'undefined') value = null; | |
this[key] = value; | |
return value; | |
} | |
return this[key]; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import difflib | |
import re | |
def html_diff(list1, list2, title='', left='', right=''): | |
"""Returns HTML as string representing a visual diff for the given lists.""" | |
diff_html = difflib.HtmlDiff().make_file(list1, list2, left, right) | |
diff_html = re.sub(r'<title>.*</title>', '<title>%s</title>' % title, diff_html) | |
diff_html = diff_html.replace('content="text/html; charset=ISO-8859-1"', | |
'content="text/html; charset=UTF-8"') | |
diff_html = diff_html.encode('ascii', 'xmlcharrefreplace') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import MutableSet as _MutableSet, OrderedDict as _OrderedDict | |
from itertools import chain as _chain | |
class SetQueue(_MutableSet): | |
def __init__(self, iterable=(), maxlen=None): | |
self._queue = _OrderedDict() | |
self._maxlen = maxlen | |
self.update(iterable) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import OrderedDict as _OrderedDict | |
try: | |
from thread import get_ident as _get_ident | |
except ImportError: | |
from dummy_thread import get_ident as _get_ident | |
class ListDict(_OrderedDict): | |
def __init__(self, *args, **kwds): | |
try: |