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 pyparsing import * | |
import unittest | |
unicode_printables = u''.join(unichr(c) for c in xrange(65536) | |
if not unichr(c).isspace()) | |
word = Word(unicode_printables) | |
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 pyparsing import * | |
import unittest | |
unicode_printables = u''.join(unichr(c) for c in xrange(65536) | |
if not unichr(c).isspace()) | |
word = Word(unicode_printables) | |
exact = QuotedString('"', unquoteResults=True, escChar='\\') | |
term = exact | word |
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 pyparsing import * | |
import unittest | |
unicode_printables = u''.join(unichr(c) for c in xrange(65536) | |
if not unichr(c).isspace()) | |
word = Word(unicode_printables) | |
exact = QuotedString('"', unquoteResults=True, escChar='\\') | |
term = exact | word |
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 pyparsing import * | |
import unittest | |
class Node(list): | |
def __eq__(self, other): | |
return list.__eq__(self, other) and self.__class__ == other.__class__ | |
def __repr__(self): | |
return '%s(%s)' % (self.__class__.__name__, list.__repr__(self)) |
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 pyparsing import * | |
import unittest | |
class Node(list): | |
def __eq__(self, other): | |
return list.__eq__(self, other) and self.__class__ == other.__class__ | |
def __repr__(self): | |
return '%s(%s)' % (self.__class__.__name__, list.__repr__(self)) |
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 pyelasticsearch import ElasticSearch, ElasticHttpNotFoundError | |
from pyparsing import * | |
import unittest | |
ELASTICSEARCH_INDEX = 'myindex' | |
ELASTICSEARCH_URL = 'http://localhost:9200/' | |
es = ElasticSearch(ELASTICSEARCH_URL) |
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
""" | |
Copies all keys from the source Redis host to the destination Redis host. | |
Useful to migrate Redis instances where commands like SLAVEOF and MIGRATE are | |
restricted (e.g. on Amazon ElastiCache). | |
The script scans through the keyspace of the given database number and uses | |
a pipeline of DUMP and RESTORE commands to migrate the keys. | |
Requires Redis 2.8.0 or higher. |
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
# Inspired by http://stackoverflow.com/a/13875412 | |
class ContextMixin(object): | |
def setup_context(self): | |
self._ctxs = [] | |
for cls in reversed(self.__class__.mro()): | |
context_method = cls.__dict__.get('context') | |
if context_method: | |
ctx = context_method(self) | |
self._ctxs.append(ctx) |