id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
240,100
zacernst/timed_dict
timed_dict/timed_dict.py
TimedDict.set_expiration
def set_expiration(self, key, ignore_missing=False, additional_seconds=None, seconds=None): ''' Alters the expiration time for a key. If the key is not present, then raise an Exception unless `ignore_missing` is set to `True`. Args: key: The key whose exp...
python
def set_expiration(self, key, ignore_missing=False, additional_seconds=None, seconds=None): ''' Alters the expiration time for a key. If the key is not present, then raise an Exception unless `ignore_missing` is set to `True`. Args: key: The key whose exp...
[ "def", "set_expiration", "(", "self", ",", "key", ",", "ignore_missing", "=", "False", ",", "additional_seconds", "=", "None", ",", "seconds", "=", "None", ")", ":", "if", "key", "not", "in", "self", ".", "time_dict", "and", "ignore_missing", ":", "return"...
Alters the expiration time for a key. If the key is not present, then raise an Exception unless `ignore_missing` is set to `True`. Args: key: The key whose expiration we are changing. ignore_missing (bool): If set, then return silently if the key does not...
[ "Alters", "the", "expiration", "time", "for", "a", "key", ".", "If", "the", "key", "is", "not", "present", "then", "raise", "an", "Exception", "unless", "ignore_missing", "is", "set", "to", "True", "." ]
01a1d145d246832e63c2e92e11d91cac5c3f2d1e
https://github.com/zacernst/timed_dict/blob/01a1d145d246832e63c2e92e11d91cac5c3f2d1e/timed_dict/timed_dict.py#L198-L221
240,101
zacernst/timed_dict
timed_dict/timed_dict.py
TimedDict.expire_key
def expire_key(self, key): ''' Expire the key, delete the value, and call the callback function if one is specified. Args: key: The ``TimedDict`` key ''' value = self.base_dict[key] del self[key] if self.callback is not None: self....
python
def expire_key(self, key): ''' Expire the key, delete the value, and call the callback function if one is specified. Args: key: The ``TimedDict`` key ''' value = self.base_dict[key] del self[key] if self.callback is not None: self....
[ "def", "expire_key", "(", "self", ",", "key", ")", ":", "value", "=", "self", ".", "base_dict", "[", "key", "]", "del", "self", "[", "key", "]", "if", "self", ".", "callback", "is", "not", "None", ":", "self", ".", "callback", "(", "key", ",", "v...
Expire the key, delete the value, and call the callback function if one is specified. Args: key: The ``TimedDict`` key
[ "Expire", "the", "key", "delete", "the", "value", "and", "call", "the", "callback", "function", "if", "one", "is", "specified", "." ]
01a1d145d246832e63c2e92e11d91cac5c3f2d1e
https://github.com/zacernst/timed_dict/blob/01a1d145d246832e63c2e92e11d91cac5c3f2d1e/timed_dict/timed_dict.py#L318-L330
240,102
pavelsof/ipalint
ipalint/read.py
Reader._open
def _open(self, file_path=None): """ Opens the file specified by the given path. Raises ValueError if there is a problem with opening or reading the file. """ if file_path is None: file_path = self.file_path if not os.path.exists(file_path): raise ValueError('Could not find file: {}'.format(file_path...
python
def _open(self, file_path=None): """ Opens the file specified by the given path. Raises ValueError if there is a problem with opening or reading the file. """ if file_path is None: file_path = self.file_path if not os.path.exists(file_path): raise ValueError('Could not find file: {}'.format(file_path...
[ "def", "_open", "(", "self", ",", "file_path", "=", "None", ")", ":", "if", "file_path", "is", "None", ":", "file_path", "=", "self", ".", "file_path", "if", "not", "os", ".", "path", ".", "exists", "(", "file_path", ")", ":", "raise", "ValueError", ...
Opens the file specified by the given path. Raises ValueError if there is a problem with opening or reading the file.
[ "Opens", "the", "file", "specified", "by", "the", "given", "path", ".", "Raises", "ValueError", "if", "there", "is", "a", "problem", "with", "opening", "or", "reading", "the", "file", "." ]
763e5979ede6980cbfc746b06fd007b379762eeb
https://github.com/pavelsof/ipalint/blob/763e5979ede6980cbfc746b06fd007b379762eeb/ipalint/read.py#L116-L133
240,103
pavelsof/ipalint
ipalint/read.py
Reader.get_dialect
def get_dialect(self): """ Returns a Dialect named tuple or None if the dataset file comprises a single column of data. If the dialect is not already known, then tries to determine it. Raises ValueError if it fails in the latter case. """ if self.is_single_col: return None if self.delimiter and self.q...
python
def get_dialect(self): """ Returns a Dialect named tuple or None if the dataset file comprises a single column of data. If the dialect is not already known, then tries to determine it. Raises ValueError if it fails in the latter case. """ if self.is_single_col: return None if self.delimiter and self.q...
[ "def", "get_dialect", "(", "self", ")", ":", "if", "self", ".", "is_single_col", ":", "return", "None", "if", "self", ".", "delimiter", "and", "self", ".", "quotechar", ":", "return", "Dialect", "(", "self", ".", "delimiter", ",", "self", ".", "quotechar...
Returns a Dialect named tuple or None if the dataset file comprises a single column of data. If the dialect is not already known, then tries to determine it. Raises ValueError if it fails in the latter case.
[ "Returns", "a", "Dialect", "named", "tuple", "or", "None", "if", "the", "dataset", "file", "comprises", "a", "single", "column", "of", "data", ".", "If", "the", "dialect", "is", "not", "already", "known", "then", "tries", "to", "determine", "it", ".", "R...
763e5979ede6980cbfc746b06fd007b379762eeb
https://github.com/pavelsof/ipalint/blob/763e5979ede6980cbfc746b06fd007b379762eeb/ipalint/read.py#L136-L174
240,104
pavelsof/ipalint
ipalint/read.py
Reader._get_csv_reader
def _get_csv_reader(self, f, dialect): """ Returns a csv.reader for the given file handler and csv Dialect named tuple. If the file has a header, it already will be gone through. Also, if self.ipa_col is not set, an attempt will be made to infer which the IPA column is. ValueError would be raised otherwise. ...
python
def _get_csv_reader(self, f, dialect): """ Returns a csv.reader for the given file handler and csv Dialect named tuple. If the file has a header, it already will be gone through. Also, if self.ipa_col is not set, an attempt will be made to infer which the IPA column is. ValueError would be raised otherwise. ...
[ "def", "_get_csv_reader", "(", "self", ",", "f", ",", "dialect", ")", ":", "reader", "=", "csv", ".", "reader", "(", "f", ",", "delimiter", "=", "dialect", ".", "delimiter", ",", "quotechar", "=", "dialect", ".", "quotechar", ",", "doublequote", "=", "...
Returns a csv.reader for the given file handler and csv Dialect named tuple. If the file has a header, it already will be gone through. Also, if self.ipa_col is not set, an attempt will be made to infer which the IPA column is. ValueError would be raised otherwise.
[ "Returns", "a", "csv", ".", "reader", "for", "the", "given", "file", "handler", "and", "csv", "Dialect", "named", "tuple", ".", "If", "the", "file", "has", "a", "header", "it", "already", "will", "be", "gone", "through", "." ]
763e5979ede6980cbfc746b06fd007b379762eeb
https://github.com/pavelsof/ipalint/blob/763e5979ede6980cbfc746b06fd007b379762eeb/ipalint/read.py#L221-L250
240,105
pavelsof/ipalint
ipalint/read.py
Reader.gen_ipa_data
def gen_ipa_data(self): """ Generator for iterating over the IPA strings found in the dataset file. Yields the IPA data string paired with the respective line number. """ dialect = self.get_dialect() f = self._open() try: if dialect: for res in self._gen_csv_data(f, dialect): yield res els...
python
def gen_ipa_data(self): """ Generator for iterating over the IPA strings found in the dataset file. Yields the IPA data string paired with the respective line number. """ dialect = self.get_dialect() f = self._open() try: if dialect: for res in self._gen_csv_data(f, dialect): yield res els...
[ "def", "gen_ipa_data", "(", "self", ")", ":", "dialect", "=", "self", ".", "get_dialect", "(", ")", "f", "=", "self", ".", "_open", "(", ")", "try", ":", "if", "dialect", ":", "for", "res", "in", "self", ".", "_gen_csv_data", "(", "f", ",", "dialec...
Generator for iterating over the IPA strings found in the dataset file. Yields the IPA data string paired with the respective line number.
[ "Generator", "for", "iterating", "over", "the", "IPA", "strings", "found", "in", "the", "dataset", "file", ".", "Yields", "the", "IPA", "data", "string", "paired", "with", "the", "respective", "line", "number", "." ]
763e5979ede6980cbfc746b06fd007b379762eeb
https://github.com/pavelsof/ipalint/blob/763e5979ede6980cbfc746b06fd007b379762eeb/ipalint/read.py#L289-L306
240,106
fdb/aufmachen
aufmachen/BeautifulSoup.py
PageElement._findAll
def _findAll(self, name, attrs, text, limit, generator, **kwargs): "Iterates over a generator looking for things that match." if isinstance(name, SoupStrainer): strainer = name # (Possibly) special case some findAll*(...) searches elif text is None and not limit and not attr...
python
def _findAll(self, name, attrs, text, limit, generator, **kwargs): "Iterates over a generator looking for things that match." if isinstance(name, SoupStrainer): strainer = name # (Possibly) special case some findAll*(...) searches elif text is None and not limit and not attr...
[ "def", "_findAll", "(", "self", ",", "name", ",", "attrs", ",", "text", ",", "limit", ",", "generator", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "name", ",", "SoupStrainer", ")", ":", "strainer", "=", "name", "# (Possibly) special case...
Iterates over a generator looking for things that match.
[ "Iterates", "over", "a", "generator", "looking", "for", "things", "that", "match", "." ]
f2986a0cf087ac53969f82b84d872e3f1c6986f4
https://github.com/fdb/aufmachen/blob/f2986a0cf087ac53969f82b84d872e3f1c6986f4/aufmachen/BeautifulSoup.py#L333-L367
240,107
fdb/aufmachen
aufmachen/BeautifulSoup.py
Tag.decompose
def decompose(self): """Recursively destroys the contents of this tree.""" self.extract() if len(self.contents) == 0: return current = self.contents[0] while current is not None: next = current.next if isinstance(current, Tag): ...
python
def decompose(self): """Recursively destroys the contents of this tree.""" self.extract() if len(self.contents) == 0: return current = self.contents[0] while current is not None: next = current.next if isinstance(current, Tag): ...
[ "def", "decompose", "(", "self", ")", ":", "self", ".", "extract", "(", ")", "if", "len", "(", "self", ".", "contents", ")", "==", "0", ":", "return", "current", "=", "self", ".", "contents", "[", "0", "]", "while", "current", "is", "not", "None", ...
Recursively destroys the contents of this tree.
[ "Recursively", "destroys", "the", "contents", "of", "this", "tree", "." ]
f2986a0cf087ac53969f82b84d872e3f1c6986f4
https://github.com/fdb/aufmachen/blob/f2986a0cf087ac53969f82b84d872e3f1c6986f4/aufmachen/BeautifulSoup.py#L778-L793
240,108
fdb/aufmachen
aufmachen/BeautifulSoup.py
BeautifulStoneSoup._smartPop
def _smartPop(self, name): """We need to pop up to the previous tag of this type, unless one of this tag's nesting reset triggers comes between this tag and the previous tag of this type, OR unless this tag is a generic nesting trigger and another generic nesting trigger comes b...
python
def _smartPop(self, name): """We need to pop up to the previous tag of this type, unless one of this tag's nesting reset triggers comes between this tag and the previous tag of this type, OR unless this tag is a generic nesting trigger and another generic nesting trigger comes b...
[ "def", "_smartPop", "(", "self", ",", "name", ")", ":", "nestingResetTriggers", "=", "self", ".", "NESTABLE_TAGS", ".", "get", "(", "name", ")", "isNestable", "=", "nestingResetTriggers", "!=", "None", "isResetNesting", "=", "self", ".", "RESET_NESTING_TAGS", ...
We need to pop up to the previous tag of this type, unless one of this tag's nesting reset triggers comes between this tag and the previous tag of this type, OR unless this tag is a generic nesting trigger and another generic nesting trigger comes between this tag and the previous tag of...
[ "We", "need", "to", "pop", "up", "to", "the", "previous", "tag", "of", "this", "type", "unless", "one", "of", "this", "tag", "s", "nesting", "reset", "triggers", "comes", "between", "this", "tag", "and", "the", "previous", "tag", "of", "this", "type", ...
f2986a0cf087ac53969f82b84d872e3f1c6986f4
https://github.com/fdb/aufmachen/blob/f2986a0cf087ac53969f82b84d872e3f1c6986f4/aufmachen/BeautifulSoup.py#L1281-L1325
240,109
fdb/aufmachen
aufmachen/BeautifulSoup.py
UnicodeDammit._subMSChar
def _subMSChar(self, orig): """Changes a MS smart quote character to an XML or HTML entity.""" sub = self.MS_CHARS.get(orig) if isinstance(sub, tuple): if self.smartQuotesTo == 'xml': sub = '&#x%s;' % sub[1] else: sub = '&%s;' % sub...
python
def _subMSChar(self, orig): """Changes a MS smart quote character to an XML or HTML entity.""" sub = self.MS_CHARS.get(orig) if isinstance(sub, tuple): if self.smartQuotesTo == 'xml': sub = '&#x%s;' % sub[1] else: sub = '&%s;' % sub...
[ "def", "_subMSChar", "(", "self", ",", "orig", ")", ":", "sub", "=", "self", ".", "MS_CHARS", ".", "get", "(", "orig", ")", "if", "isinstance", "(", "sub", ",", "tuple", ")", ":", "if", "self", ".", "smartQuotesTo", "==", "'xml'", ":", "sub", "=", ...
Changes a MS smart quote character to an XML or HTML entity.
[ "Changes", "a", "MS", "smart", "quote", "character", "to", "an", "XML", "or", "HTML", "entity", "." ]
f2986a0cf087ac53969f82b84d872e3f1c6986f4
https://github.com/fdb/aufmachen/blob/f2986a0cf087ac53969f82b84d872e3f1c6986f4/aufmachen/BeautifulSoup.py#L1800-L1809
240,110
mkurnikov/typed-env
typed_env/read_dot_env.py
read_file_values
def read_file_values(env_file, fail_silently=True): """ Borrowed from Honcho. """ env_data = {} try: with open(env_file) as f: content = f.read() except IOError: if fail_silently: logging.error("Could not read file '{0}'".format(env_file)) retu...
python
def read_file_values(env_file, fail_silently=True): """ Borrowed from Honcho. """ env_data = {} try: with open(env_file) as f: content = f.read() except IOError: if fail_silently: logging.error("Could not read file '{0}'".format(env_file)) retu...
[ "def", "read_file_values", "(", "env_file", ",", "fail_silently", "=", "True", ")", ":", "env_data", "=", "{", "}", "try", ":", "with", "open", "(", "env_file", ")", "as", "f", ":", "content", "=", "f", ".", "read", "(", ")", "except", "IOError", ":"...
Borrowed from Honcho.
[ "Borrowed", "from", "Honcho", "." ]
d0f3e947f0d5561c9fd1679d6faa9830de24d870
https://github.com/mkurnikov/typed-env/blob/d0f3e947f0d5561c9fd1679d6faa9830de24d870/typed_env/read_dot_env.py#L8-L37
240,111
edeposit/edeposit.amqp.ltp
src/edeposit/amqp/ltp/fn_composers.py
_get_suffix
def _get_suffix(path): """ Return suffix from `path`. ``/home/xex/somefile.txt`` --> ``txt``. Args: path (str): Full file path. Returns: str: Suffix. Raises: UserWarning: When ``/`` is detected in suffix. """ suffix = os.path.basename(path).split(".")[-1] ...
python
def _get_suffix(path): """ Return suffix from `path`. ``/home/xex/somefile.txt`` --> ``txt``. Args: path (str): Full file path. Returns: str: Suffix. Raises: UserWarning: When ``/`` is detected in suffix. """ suffix = os.path.basename(path).split(".")[-1] ...
[ "def", "_get_suffix", "(", "path", ")", ":", "suffix", "=", "os", ".", "path", ".", "basename", "(", "path", ")", ".", "split", "(", "\".\"", ")", "[", "-", "1", "]", "if", "\"/\"", "in", "suffix", ":", "raise", "UserWarning", "(", "\"Filename can't ...
Return suffix from `path`. ``/home/xex/somefile.txt`` --> ``txt``. Args: path (str): Full file path. Returns: str: Suffix. Raises: UserWarning: When ``/`` is detected in suffix.
[ "Return", "suffix", "from", "path", "." ]
df9ac7ec6cbdbeaaeed438ca66df75ea967b6d8e
https://github.com/edeposit/edeposit.amqp.ltp/blob/df9ac7ec6cbdbeaaeed438ca66df75ea967b6d8e/src/edeposit/amqp/ltp/fn_composers.py#L14-L34
240,112
chamrc/to
to/layers/sru.py
SRU_Compute_CPU
def SRU_Compute_CPU(activation_type, d, bidirectional=False, scale_x=1): """CPU version of the core SRU computation. Has the same interface as SRU_Compute_GPU() but is a regular Python function instead of a torch.autograd.Function because we don't implement backward() explicitly. """ def sru_c...
python
def SRU_Compute_CPU(activation_type, d, bidirectional=False, scale_x=1): """CPU version of the core SRU computation. Has the same interface as SRU_Compute_GPU() but is a regular Python function instead of a torch.autograd.Function because we don't implement backward() explicitly. """ def sru_c...
[ "def", "SRU_Compute_CPU", "(", "activation_type", ",", "d", ",", "bidirectional", "=", "False", ",", "scale_x", "=", "1", ")", ":", "def", "sru_compute_cpu", "(", "u", ",", "x", ",", "bias", ",", "init", "=", "None", ",", "mask_h", "=", "None", ")", ...
CPU version of the core SRU computation. Has the same interface as SRU_Compute_GPU() but is a regular Python function instead of a torch.autograd.Function because we don't implement backward() explicitly.
[ "CPU", "version", "of", "the", "core", "SRU", "computation", "." ]
ea1122bef08615b6c19904dadf2608e10c20c960
https://github.com/chamrc/to/blob/ea1122bef08615b6c19904dadf2608e10c20c960/to/layers/sru.py#L502-L567
240,113
brbsix/subnuker
subnuker.py
get_encoding
def get_encoding(binary): """Return the encoding type.""" try: from chardet import detect except ImportError: LOGGER.error("Please install the 'chardet' module") sys.exit(1) encoding = detect(binary).get('encoding') return 'iso-8859-1' if encoding == 'CP949' else encoding
python
def get_encoding(binary): """Return the encoding type.""" try: from chardet import detect except ImportError: LOGGER.error("Please install the 'chardet' module") sys.exit(1) encoding = detect(binary).get('encoding') return 'iso-8859-1' if encoding == 'CP949' else encoding
[ "def", "get_encoding", "(", "binary", ")", ":", "try", ":", "from", "chardet", "import", "detect", "except", "ImportError", ":", "LOGGER", ".", "error", "(", "\"Please install the 'chardet' module\"", ")", "sys", ".", "exit", "(", "1", ")", "encoding", "=", ...
Return the encoding type.
[ "Return", "the", "encoding", "type", "." ]
a94260a6e84b790a9e39e0b1793443ffd4e1f496
https://github.com/brbsix/subnuker/blob/a94260a6e84b790a9e39e0b1793443ffd4e1f496/subnuker.py#L334-L345
240,114
brbsix/subnuker
subnuker.py
getch
def getch(): """Request a single character input from the user.""" if sys.platform in ['darwin', 'linux']: import termios import tty file_descriptor = sys.stdin.fileno() settings = termios.tcgetattr(file_descriptor) try: tty.setraw(file_descriptor) ...
python
def getch(): """Request a single character input from the user.""" if sys.platform in ['darwin', 'linux']: import termios import tty file_descriptor = sys.stdin.fileno() settings = termios.tcgetattr(file_descriptor) try: tty.setraw(file_descriptor) ...
[ "def", "getch", "(", ")", ":", "if", "sys", ".", "platform", "in", "[", "'darwin'", ",", "'linux'", "]", ":", "import", "termios", "import", "tty", "file_descriptor", "=", "sys", ".", "stdin", ".", "fileno", "(", ")", "settings", "=", "termios", ".", ...
Request a single character input from the user.
[ "Request", "a", "single", "character", "input", "from", "the", "user", "." ]
a94260a6e84b790a9e39e0b1793443ffd4e1f496
https://github.com/brbsix/subnuker/blob/a94260a6e84b790a9e39e0b1793443ffd4e1f496/subnuker.py#L348-L363
240,115
brbsix/subnuker
subnuker.py
ismatch
def ismatch(text, pattern): """Test whether text contains string or matches regex.""" if hasattr(pattern, 'search'): return pattern.search(text) is not None else: return pattern in text if Config.options.case_sensitive \ else pattern.lower() in text.lower()
python
def ismatch(text, pattern): """Test whether text contains string or matches regex.""" if hasattr(pattern, 'search'): return pattern.search(text) is not None else: return pattern in text if Config.options.case_sensitive \ else pattern.lower() in text.lower()
[ "def", "ismatch", "(", "text", ",", "pattern", ")", ":", "if", "hasattr", "(", "pattern", ",", "'search'", ")", ":", "return", "pattern", ".", "search", "(", "text", ")", "is", "not", "None", "else", ":", "return", "pattern", "in", "text", "if", "Con...
Test whether text contains string or matches regex.
[ "Test", "whether", "text", "contains", "string", "or", "matches", "regex", "." ]
a94260a6e84b790a9e39e0b1793443ffd4e1f496
https://github.com/brbsix/subnuker/blob/a94260a6e84b790a9e39e0b1793443ffd4e1f496/subnuker.py#L366-L373
240,116
brbsix/subnuker
subnuker.py
logger
def logger(): """Configure program logger.""" scriptlogger = logging.getLogger(__program__) # ensure logger is not reconfigured if not scriptlogger.hasHandlers(): # set log level scriptlogger.setLevel(logging.INFO) fmt = '%(name)s:%(levelname)s: %(message)s' # config...
python
def logger(): """Configure program logger.""" scriptlogger = logging.getLogger(__program__) # ensure logger is not reconfigured if not scriptlogger.hasHandlers(): # set log level scriptlogger.setLevel(logging.INFO) fmt = '%(name)s:%(levelname)s: %(message)s' # config...
[ "def", "logger", "(", ")", ":", "scriptlogger", "=", "logging", ".", "getLogger", "(", "__program__", ")", "# ensure logger is not reconfigured", "if", "not", "scriptlogger", ".", "hasHandlers", "(", ")", ":", "# set log level", "scriptlogger", ".", "setLevel", "(...
Configure program logger.
[ "Configure", "program", "logger", "." ]
a94260a6e84b790a9e39e0b1793443ffd4e1f496
https://github.com/brbsix/subnuker/blob/a94260a6e84b790a9e39e0b1793443ffd4e1f496/subnuker.py#L376-L392
240,117
brbsix/subnuker
subnuker.py
pattern_logic_aeidon
def pattern_logic_aeidon(): """Return patterns to be used for searching subtitles via aeidon.""" if Config.options.pattern_files: return prep_patterns(Config.options.pattern_files) elif Config.options.regex: return Config.REGEX else: return Config.TERMS
python
def pattern_logic_aeidon(): """Return patterns to be used for searching subtitles via aeidon.""" if Config.options.pattern_files: return prep_patterns(Config.options.pattern_files) elif Config.options.regex: return Config.REGEX else: return Config.TERMS
[ "def", "pattern_logic_aeidon", "(", ")", ":", "if", "Config", ".", "options", ".", "pattern_files", ":", "return", "prep_patterns", "(", "Config", ".", "options", ".", "pattern_files", ")", "elif", "Config", ".", "options", ".", "regex", ":", "return", "Conf...
Return patterns to be used for searching subtitles via aeidon.
[ "Return", "patterns", "to", "be", "used", "for", "searching", "subtitles", "via", "aeidon", "." ]
a94260a6e84b790a9e39e0b1793443ffd4e1f496
https://github.com/brbsix/subnuker/blob/a94260a6e84b790a9e39e0b1793443ffd4e1f496/subnuker.py#L491-L499
240,118
brbsix/subnuker
subnuker.py
pattern_logic_srt
def pattern_logic_srt(): """Return patterns to be used for searching srt subtitles.""" if Config.options.pattern_files and Config.options.regex: return prep_regex(prep_patterns(Config.options.pattern_files)) elif Config.options.pattern_files: return prep_patterns(Config.options.pattern_file...
python
def pattern_logic_srt(): """Return patterns to be used for searching srt subtitles.""" if Config.options.pattern_files and Config.options.regex: return prep_regex(prep_patterns(Config.options.pattern_files)) elif Config.options.pattern_files: return prep_patterns(Config.options.pattern_file...
[ "def", "pattern_logic_srt", "(", ")", ":", "if", "Config", ".", "options", ".", "pattern_files", "and", "Config", ".", "options", ".", "regex", ":", "return", "prep_regex", "(", "prep_patterns", "(", "Config", ".", "options", ".", "pattern_files", ")", ")", ...
Return patterns to be used for searching srt subtitles.
[ "Return", "patterns", "to", "be", "used", "for", "searching", "srt", "subtitles", "." ]
a94260a6e84b790a9e39e0b1793443ffd4e1f496
https://github.com/brbsix/subnuker/blob/a94260a6e84b790a9e39e0b1793443ffd4e1f496/subnuker.py#L502-L512
240,119
brbsix/subnuker
subnuker.py
prep_patterns
def prep_patterns(filenames): """Load pattern files passed via options and return list of patterns.""" patterns = [] for filename in filenames: try: with open(filename) as file: patterns += [l.rstrip('\n') for l in file] except: # pylint: disable=W0702 ...
python
def prep_patterns(filenames): """Load pattern files passed via options and return list of patterns.""" patterns = [] for filename in filenames: try: with open(filename) as file: patterns += [l.rstrip('\n') for l in file] except: # pylint: disable=W0702 ...
[ "def", "prep_patterns", "(", "filenames", ")", ":", "patterns", "=", "[", "]", "for", "filename", "in", "filenames", ":", "try", ":", "with", "open", "(", "filename", ")", "as", "file", ":", "patterns", "+=", "[", "l", ".", "rstrip", "(", "'\\n'", ")...
Load pattern files passed via options and return list of patterns.
[ "Load", "pattern", "files", "passed", "via", "options", "and", "return", "list", "of", "patterns", "." ]
a94260a6e84b790a9e39e0b1793443ffd4e1f496
https://github.com/brbsix/subnuker/blob/a94260a6e84b790a9e39e0b1793443ffd4e1f496/subnuker.py#L530-L548
240,120
brbsix/subnuker
subnuker.py
prep_regex
def prep_regex(patterns): """Compile regex patterns.""" flags = 0 if Config.options.case_sensitive else re.I return [re.compile(pattern, flags) for pattern in patterns]
python
def prep_regex(patterns): """Compile regex patterns.""" flags = 0 if Config.options.case_sensitive else re.I return [re.compile(pattern, flags) for pattern in patterns]
[ "def", "prep_regex", "(", "patterns", ")", ":", "flags", "=", "0", "if", "Config", ".", "options", ".", "case_sensitive", "else", "re", ".", "I", "return", "[", "re", ".", "compile", "(", "pattern", ",", "flags", ")", "for", "pattern", "in", "patterns"...
Compile regex patterns.
[ "Compile", "regex", "patterns", "." ]
a94260a6e84b790a9e39e0b1793443ffd4e1f496
https://github.com/brbsix/subnuker/blob/a94260a6e84b790a9e39e0b1793443ffd4e1f496/subnuker.py#L551-L556
240,121
brbsix/subnuker
subnuker.py
prerequisites
def prerequisites(): """Display information about obtaining the aeidon module.""" url = "http://home.gna.org/gaupol/download.html" debian = "sudo apt-get install python3-aeidon" other = "python3 setup.py --user --without-gaupol clean install" LOGGER.error( "The aeidon module is missing!\n\...
python
def prerequisites(): """Display information about obtaining the aeidon module.""" url = "http://home.gna.org/gaupol/download.html" debian = "sudo apt-get install python3-aeidon" other = "python3 setup.py --user --without-gaupol clean install" LOGGER.error( "The aeidon module is missing!\n\...
[ "def", "prerequisites", "(", ")", ":", "url", "=", "\"http://home.gna.org/gaupol/download.html\"", "debian", "=", "\"sudo apt-get install python3-aeidon\"", "other", "=", "\"python3 setup.py --user --without-gaupol clean install\"", "LOGGER", ".", "error", "(", "\"The aeidon modu...
Display information about obtaining the aeidon module.
[ "Display", "information", "about", "obtaining", "the", "aeidon", "module", "." ]
a94260a6e84b790a9e39e0b1793443ffd4e1f496
https://github.com/brbsix/subnuker/blob/a94260a6e84b790a9e39e0b1793443ffd4e1f496/subnuker.py#L559-L571
240,122
brbsix/subnuker
subnuker.py
remove_elements
def remove_elements(target, indices): """Remove multiple elements from a list and return result. This implementation is faster than the alternative below. Also note the creation of a new list to avoid altering the original. We don't have any current use for the original intact list, but may in the f...
python
def remove_elements(target, indices): """Remove multiple elements from a list and return result. This implementation is faster than the alternative below. Also note the creation of a new list to avoid altering the original. We don't have any current use for the original intact list, but may in the f...
[ "def", "remove_elements", "(", "target", ",", "indices", ")", ":", "copied", "=", "list", "(", "target", ")", "for", "index", "in", "reversed", "(", "indices", ")", ":", "del", "copied", "[", "index", "]", "return", "copied" ]
Remove multiple elements from a list and return result. This implementation is faster than the alternative below. Also note the creation of a new list to avoid altering the original. We don't have any current use for the original intact list, but may in the future...
[ "Remove", "multiple", "elements", "from", "a", "list", "and", "return", "result", ".", "This", "implementation", "is", "faster", "than", "the", "alternative", "below", ".", "Also", "note", "the", "creation", "of", "a", "new", "list", "to", "avoid", "altering...
a94260a6e84b790a9e39e0b1793443ffd4e1f496
https://github.com/brbsix/subnuker/blob/a94260a6e84b790a9e39e0b1793443ffd4e1f496/subnuker.py#L574-L585
240,123
brbsix/subnuker
subnuker.py
start_aeidon
def start_aeidon(): """Prepare filenames and patterns then process subtitles with aeidon.""" extensions = ['ass', 'srt', 'ssa', 'sub'] Config.filenames = prep_files(Config.args, extensions) Config.patterns = pattern_logic_aeidon() for filename in Config.filenames: AeidonProject(filename)
python
def start_aeidon(): """Prepare filenames and patterns then process subtitles with aeidon.""" extensions = ['ass', 'srt', 'ssa', 'sub'] Config.filenames = prep_files(Config.args, extensions) Config.patterns = pattern_logic_aeidon() for filename in Config.filenames: AeidonProject(filename)
[ "def", "start_aeidon", "(", ")", ":", "extensions", "=", "[", "'ass'", ",", "'srt'", ",", "'ssa'", ",", "'sub'", "]", "Config", ".", "filenames", "=", "prep_files", "(", "Config", ".", "args", ",", "extensions", ")", "Config", ".", "patterns", "=", "pa...
Prepare filenames and patterns then process subtitles with aeidon.
[ "Prepare", "filenames", "and", "patterns", "then", "process", "subtitles", "with", "aeidon", "." ]
a94260a6e84b790a9e39e0b1793443ffd4e1f496
https://github.com/brbsix/subnuker/blob/a94260a6e84b790a9e39e0b1793443ffd4e1f496/subnuker.py#L593-L602
240,124
brbsix/subnuker
subnuker.py
start_srt
def start_srt(): """Prepare filenames and patterns then process srt subtitles.""" extensions = ['srt'] Config.filenames = prep_files(Config.args, extensions) Config.patterns = pattern_logic_srt() for filename in Config.filenames: SrtProject(filename)
python
def start_srt(): """Prepare filenames and patterns then process srt subtitles.""" extensions = ['srt'] Config.filenames = prep_files(Config.args, extensions) Config.patterns = pattern_logic_srt() for filename in Config.filenames: SrtProject(filename)
[ "def", "start_srt", "(", ")", ":", "extensions", "=", "[", "'srt'", "]", "Config", ".", "filenames", "=", "prep_files", "(", "Config", ".", "args", ",", "extensions", ")", "Config", ".", "patterns", "=", "pattern_logic_srt", "(", ")", "for", "filename", ...
Prepare filenames and patterns then process srt subtitles.
[ "Prepare", "filenames", "and", "patterns", "then", "process", "srt", "subtitles", "." ]
a94260a6e84b790a9e39e0b1793443ffd4e1f496
https://github.com/brbsix/subnuker/blob/a94260a6e84b790a9e39e0b1793443ffd4e1f496/subnuker.py#L605-L614
240,125
brbsix/subnuker
subnuker.py
AeidonProject.fixchars
def fixchars(self): """Replace characters or strings within subtitle file.""" for key in Config.CHARFIXES: self.project.set_search_string(key) self.project.set_search_replacement(Config.CHARFIXES[key]) self.project.replace_all()
python
def fixchars(self): """Replace characters or strings within subtitle file.""" for key in Config.CHARFIXES: self.project.set_search_string(key) self.project.set_search_replacement(Config.CHARFIXES[key]) self.project.replace_all()
[ "def", "fixchars", "(", "self", ")", ":", "for", "key", "in", "Config", ".", "CHARFIXES", ":", "self", ".", "project", ".", "set_search_string", "(", "key", ")", "self", ".", "project", ".", "set_search_replacement", "(", "Config", ".", "CHARFIXES", "[", ...
Replace characters or strings within subtitle file.
[ "Replace", "characters", "or", "strings", "within", "subtitle", "file", "." ]
a94260a6e84b790a9e39e0b1793443ffd4e1f496
https://github.com/brbsix/subnuker/blob/a94260a6e84b790a9e39e0b1793443ffd4e1f496/subnuker.py#L87-L92
240,126
brbsix/subnuker
subnuker.py
AeidonProject.open
def open(self): """Open the subtitle file into an Aeidon project.""" try: self.project.open_main(self.filename) except UnicodeDecodeError: with open(self.filename, 'rb') as openfile: encoding = get_encoding(openfile.read()) try: ...
python
def open(self): """Open the subtitle file into an Aeidon project.""" try: self.project.open_main(self.filename) except UnicodeDecodeError: with open(self.filename, 'rb') as openfile: encoding = get_encoding(openfile.read()) try: ...
[ "def", "open", "(", "self", ")", ":", "try", ":", "self", ".", "project", ".", "open_main", "(", "self", ".", "filename", ")", "except", "UnicodeDecodeError", ":", "with", "open", "(", "self", ".", "filename", ",", "'rb'", ")", "as", "openfile", ":", ...
Open the subtitle file into an Aeidon project.
[ "Open", "the", "subtitle", "file", "into", "an", "Aeidon", "project", "." ]
a94260a6e84b790a9e39e0b1793443ffd4e1f496
https://github.com/brbsix/subnuker/blob/a94260a6e84b790a9e39e0b1793443ffd4e1f496/subnuker.py#L99-L117
240,127
brbsix/subnuker
subnuker.py
AeidonProject.save
def save(self): """Save subtitle file.""" try: # ensure file is encoded properly while saving self.project.main_file.encoding = 'utf_8' self.project.save_main() if self.fix: LOGGER.info("Saved changes to '%s'", self.filename) except...
python
def save(self): """Save subtitle file.""" try: # ensure file is encoded properly while saving self.project.main_file.encoding = 'utf_8' self.project.save_main() if self.fix: LOGGER.info("Saved changes to '%s'", self.filename) except...
[ "def", "save", "(", "self", ")", ":", "try", ":", "# ensure file is encoded properly while saving", "self", ".", "project", ".", "main_file", ".", "encoding", "=", "'utf_8'", "self", ".", "project", ".", "save_main", "(", ")", "if", "self", ".", "fix", ":", ...
Save subtitle file.
[ "Save", "subtitle", "file", "." ]
a94260a6e84b790a9e39e0b1793443ffd4e1f496
https://github.com/brbsix/subnuker/blob/a94260a6e84b790a9e39e0b1793443ffd4e1f496/subnuker.py#L146-L156
240,128
brbsix/subnuker
subnuker.py
AeidonProject.search
def search(self): """Search srt in project for cells matching list of terms.""" matches = [] for pattern in Config.patterns: matches += self.termfinder(pattern) return sorted(set(matches), key=int)
python
def search(self): """Search srt in project for cells matching list of terms.""" matches = [] for pattern in Config.patterns: matches += self.termfinder(pattern) return sorted(set(matches), key=int)
[ "def", "search", "(", "self", ")", ":", "matches", "=", "[", "]", "for", "pattern", "in", "Config", ".", "patterns", ":", "matches", "+=", "self", ".", "termfinder", "(", "pattern", ")", "return", "sorted", "(", "set", "(", "matches", ")", ",", "key"...
Search srt in project for cells matching list of terms.
[ "Search", "srt", "in", "project", "for", "cells", "matching", "list", "of", "terms", "." ]
a94260a6e84b790a9e39e0b1793443ffd4e1f496
https://github.com/brbsix/subnuker/blob/a94260a6e84b790a9e39e0b1793443ffd4e1f496/subnuker.py#L158-L165
240,129
brbsix/subnuker
subnuker.py
AeidonProject.termfinder
def termfinder(self, pattern): """Search srt in project for cells matching term.""" if Config.options.regex: flags = re.M | re.S | \ (0 if Config.options.case_sensitive else re.I) self.project.set_search_regex( pattern, flags=flags) else: ...
python
def termfinder(self, pattern): """Search srt in project for cells matching term.""" if Config.options.regex: flags = re.M | re.S | \ (0 if Config.options.case_sensitive else re.I) self.project.set_search_regex( pattern, flags=flags) else: ...
[ "def", "termfinder", "(", "self", ",", "pattern", ")", ":", "if", "Config", ".", "options", ".", "regex", ":", "flags", "=", "re", ".", "M", "|", "re", ".", "S", "|", "(", "0", "if", "Config", ".", "options", ".", "case_sensitive", "else", "re", ...
Search srt in project for cells matching term.
[ "Search", "srt", "in", "project", "for", "cells", "matching", "term", "." ]
a94260a6e84b790a9e39e0b1793443ffd4e1f496
https://github.com/brbsix/subnuker/blob/a94260a6e84b790a9e39e0b1793443ffd4e1f496/subnuker.py#L167-L195
240,130
brbsix/subnuker
subnuker.py
SrtProject.fixchars
def fixchars(self, text): """Find and replace problematic characters.""" keys = ''.join(Config.CHARFIXES.keys()) values = ''.join(Config.CHARFIXES.values()) fixed = text.translate(str.maketrans(keys, values)) if fixed != text: self.modified = True return fixed
python
def fixchars(self, text): """Find and replace problematic characters.""" keys = ''.join(Config.CHARFIXES.keys()) values = ''.join(Config.CHARFIXES.values()) fixed = text.translate(str.maketrans(keys, values)) if fixed != text: self.modified = True return fixed
[ "def", "fixchars", "(", "self", ",", "text", ")", ":", "keys", "=", "''", ".", "join", "(", "Config", ".", "CHARFIXES", ".", "keys", "(", ")", ")", "values", "=", "''", ".", "join", "(", "Config", ".", "CHARFIXES", ".", "values", "(", ")", ")", ...
Find and replace problematic characters.
[ "Find", "and", "replace", "problematic", "characters", "." ]
a94260a6e84b790a9e39e0b1793443ffd4e1f496
https://github.com/brbsix/subnuker/blob/a94260a6e84b790a9e39e0b1793443ffd4e1f496/subnuker.py#L229-L236
240,131
brbsix/subnuker
subnuker.py
SrtProject.prompt
def prompt(self, matches): """Prompt user to remove cells from subtitle file.""" if Config.options.autoyes: return matches deletions = [] for match in matches: os.system('clear') print(self.cells[match]) print('--------------------------...
python
def prompt(self, matches): """Prompt user to remove cells from subtitle file.""" if Config.options.autoyes: return matches deletions = [] for match in matches: os.system('clear') print(self.cells[match]) print('--------------------------...
[ "def", "prompt", "(", "self", ",", "matches", ")", ":", "if", "Config", ".", "options", ".", "autoyes", ":", "return", "matches", "deletions", "=", "[", "]", "for", "match", "in", "matches", ":", "os", ".", "system", "(", "'clear'", ")", "print", "("...
Prompt user to remove cells from subtitle file.
[ "Prompt", "user", "to", "remove", "cells", "from", "subtitle", "file", "." ]
a94260a6e84b790a9e39e0b1793443ffd4e1f496
https://github.com/brbsix/subnuker/blob/a94260a6e84b790a9e39e0b1793443ffd4e1f496/subnuker.py#L256-L281
240,132
brbsix/subnuker
subnuker.py
SrtProject.renumber
def renumber(self): """Re-number cells.""" num = 0 for cell in self.cells: cell_split = cell.splitlines() if len(cell_split) >= 2: num += 1 cell_split[0] = str(num) yield '\n'.join(cell_split)
python
def renumber(self): """Re-number cells.""" num = 0 for cell in self.cells: cell_split = cell.splitlines() if len(cell_split) >= 2: num += 1 cell_split[0] = str(num) yield '\n'.join(cell_split)
[ "def", "renumber", "(", "self", ")", ":", "num", "=", "0", "for", "cell", "in", "self", ".", "cells", ":", "cell_split", "=", "cell", ".", "splitlines", "(", ")", "if", "len", "(", "cell_split", ")", ">=", "2", ":", "num", "+=", "1", "cell_split", ...
Re-number cells.
[ "Re", "-", "number", "cells", "." ]
a94260a6e84b790a9e39e0b1793443ffd4e1f496
https://github.com/brbsix/subnuker/blob/a94260a6e84b790a9e39e0b1793443ffd4e1f496/subnuker.py#L283-L292
240,133
brbsix/subnuker
subnuker.py
SrtProject.save
def save(self): """Format and save cells.""" # re-number cells self.cells = list(self.renumber()) # add a newline to the last line if necessary if not self.cells[-1].endswith('\n'): self.cells[-1] += '\n' # save the rejoined the list of cells with o...
python
def save(self): """Format and save cells.""" # re-number cells self.cells = list(self.renumber()) # add a newline to the last line if necessary if not self.cells[-1].endswith('\n'): self.cells[-1] += '\n' # save the rejoined the list of cells with o...
[ "def", "save", "(", "self", ")", ":", "# re-number cells", "self", ".", "cells", "=", "list", "(", "self", ".", "renumber", "(", ")", ")", "# add a newline to the last line if necessary", "if", "not", "self", ".", "cells", "[", "-", "1", "]", ".", "endswit...
Format and save cells.
[ "Format", "and", "save", "cells", "." ]
a94260a6e84b790a9e39e0b1793443ffd4e1f496
https://github.com/brbsix/subnuker/blob/a94260a6e84b790a9e39e0b1793443ffd4e1f496/subnuker.py#L294-L306
240,134
brbsix/subnuker
subnuker.py
SrtProject.search
def search(self): """Return list of cells to be removed.""" matches = [] for index, cell in enumerate(self.cells): for pattern in Config.patterns: if ismatch(cell, pattern): matches.append(index) break return matches
python
def search(self): """Return list of cells to be removed.""" matches = [] for index, cell in enumerate(self.cells): for pattern in Config.patterns: if ismatch(cell, pattern): matches.append(index) break return matches
[ "def", "search", "(", "self", ")", ":", "matches", "=", "[", "]", "for", "index", ",", "cell", "in", "enumerate", "(", "self", ".", "cells", ")", ":", "for", "pattern", "in", "Config", ".", "patterns", ":", "if", "ismatch", "(", "cell", ",", "patte...
Return list of cells to be removed.
[ "Return", "list", "of", "cells", "to", "be", "removed", "." ]
a94260a6e84b790a9e39e0b1793443ffd4e1f496
https://github.com/brbsix/subnuker/blob/a94260a6e84b790a9e39e0b1793443ffd4e1f496/subnuker.py#L308-L318
240,135
brbsix/subnuker
subnuker.py
SrtProject.split
def split(self, text): """Split text into a list of cells.""" import re if re.search('\n\n', text): return text.split('\n\n') elif re.search('\r\n\r\n', text): return text.split('\r\n\r\n') else: LOGGER.error("'%s' does not appear to be a 'srt...
python
def split(self, text): """Split text into a list of cells.""" import re if re.search('\n\n', text): return text.split('\n\n') elif re.search('\r\n\r\n', text): return text.split('\r\n\r\n') else: LOGGER.error("'%s' does not appear to be a 'srt...
[ "def", "split", "(", "self", ",", "text", ")", ":", "import", "re", "if", "re", ".", "search", "(", "'\\n\\n'", ",", "text", ")", ":", "return", "text", ".", "split", "(", "'\\n\\n'", ")", "elif", "re", ".", "search", "(", "'\\r\\n\\r\\n'", ",", "t...
Split text into a list of cells.
[ "Split", "text", "into", "a", "list", "of", "cells", "." ]
a94260a6e84b790a9e39e0b1793443ffd4e1f496
https://github.com/brbsix/subnuker/blob/a94260a6e84b790a9e39e0b1793443ffd4e1f496/subnuker.py#L320-L331
240,136
sunlightlabs/django-locksmith
locksmith/hub/dataviews.py
keys
def keys(request): """Lists API keys. Compatible with jQuery DataTables.""" iDisplayStart = parse_int_param(request, 'iDisplayStart') iDisplayLength = parse_int_param(request, 'iDisplayLength') sEcho = parse_int_param(request, 'sEcho') iSortCol_0 = parse_int_param(request, 'iSortCol_0') sSortDir...
python
def keys(request): """Lists API keys. Compatible with jQuery DataTables.""" iDisplayStart = parse_int_param(request, 'iDisplayStart') iDisplayLength = parse_int_param(request, 'iDisplayLength') sEcho = parse_int_param(request, 'sEcho') iSortCol_0 = parse_int_param(request, 'iSortCol_0') sSortDir...
[ "def", "keys", "(", "request", ")", ":", "iDisplayStart", "=", "parse_int_param", "(", "request", ",", "'iDisplayStart'", ")", "iDisplayLength", "=", "parse_int_param", "(", "request", ",", "'iDisplayLength'", ")", "sEcho", "=", "parse_int_param", "(", "request", ...
Lists API keys. Compatible with jQuery DataTables.
[ "Lists", "API", "keys", ".", "Compatible", "with", "jQuery", "DataTables", "." ]
eef5b7c25404560aaad50b6e622594f89239b74b
https://github.com/sunlightlabs/django-locksmith/blob/eef5b7c25404560aaad50b6e622594f89239b74b/locksmith/hub/dataviews.py#L468-L507
240,137
MacHu-GWU/angora-project
angora/algorithm/iterable.py
grouper_dict
def grouper_dict(d, n): """Evenly divide dictionary into fixed-length piece, no filled value if chunk size smaller than fixed-length. Usage:: >>> list(grouper_dict({1: 'A', 2: 'B', 3: 'C', 4: 'D', 5: 'E', 6: 'F', 7: 'G', 8: 'H', 9: 'I', 10: 'J'})) [{1: 'A', 2...
python
def grouper_dict(d, n): """Evenly divide dictionary into fixed-length piece, no filled value if chunk size smaller than fixed-length. Usage:: >>> list(grouper_dict({1: 'A', 2: 'B', 3: 'C', 4: 'D', 5: 'E', 6: 'F', 7: 'G', 8: 'H', 9: 'I', 10: 'J'})) [{1: 'A', 2...
[ "def", "grouper_dict", "(", "d", ",", "n", ")", ":", "chunk", "=", "dict", "(", ")", "counter", "=", "0", "for", "k", ",", "v", "in", "d", ".", "items", "(", ")", ":", "counter", "+=", "1", "chunk", "[", "k", "]", "=", "v", "print", "(", "c...
Evenly divide dictionary into fixed-length piece, no filled value if chunk size smaller than fixed-length. Usage:: >>> list(grouper_dict({1: 'A', 2: 'B', 3: 'C', 4: 'D', 5: 'E', 6: 'F', 7: 'G', 8: 'H', 9: 'I', 10: 'J'})) [{1: 'A', 2: 'B', 3: 'C'}, {4: 'D', 5: 'E'...
[ "Evenly", "divide", "dictionary", "into", "fixed", "-", "length", "piece", "no", "filled", "value", "if", "chunk", "size", "smaller", "than", "fixed", "-", "length", "." ]
689a60da51cd88680ddbe26e28dbe81e6b01d275
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/algorithm/iterable.py#L169-L191
240,138
MacHu-GWU/angora-project
angora/algorithm/iterable.py
running_windows
def running_windows(iterable, size): """Generate n-size running windows. Usage:: >>> for i in running_windows([1, 2, 3, 4, 5], size=3): ... print(i) [1, 2, 3] [2, 3, 4] [3, 4, 5] """ fifo = collections.deque(maxlen=size) for i in iterable: fifo.a...
python
def running_windows(iterable, size): """Generate n-size running windows. Usage:: >>> for i in running_windows([1, 2, 3, 4, 5], size=3): ... print(i) [1, 2, 3] [2, 3, 4] [3, 4, 5] """ fifo = collections.deque(maxlen=size) for i in iterable: fifo.a...
[ "def", "running_windows", "(", "iterable", ",", "size", ")", ":", "fifo", "=", "collections", ".", "deque", "(", "maxlen", "=", "size", ")", "for", "i", "in", "iterable", ":", "fifo", ".", "append", "(", "i", ")", "if", "len", "(", "fifo", ")", "==...
Generate n-size running windows. Usage:: >>> for i in running_windows([1, 2, 3, 4, 5], size=3): ... print(i) [1, 2, 3] [2, 3, 4] [3, 4, 5]
[ "Generate", "n", "-", "size", "running", "windows", "." ]
689a60da51cd88680ddbe26e28dbe81e6b01d275
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/algorithm/iterable.py#L194-L209
240,139
MacHu-GWU/angora-project
angora/algorithm/iterable.py
shift_to_the_left
def shift_to_the_left(array, dist, pad=True, trim=True): """Shift array to the left. :param array: An iterable object. :type array: iterable object :param dist: how far you want to shift :type disk: int :param pad: pad array[-1] to the right. :type pad: boolean (default True) :param tri...
python
def shift_to_the_left(array, dist, pad=True, trim=True): """Shift array to the left. :param array: An iterable object. :type array: iterable object :param dist: how far you want to shift :type disk: int :param pad: pad array[-1] to the right. :type pad: boolean (default True) :param tri...
[ "def", "shift_to_the_left", "(", "array", ",", "dist", ",", "pad", "=", "True", ",", "trim", "=", "True", ")", ":", "if", "dist", "<", "0", ":", "raise", "ValueError", "(", "\"Shift distance has to greater or equal than 0.\"", ")", "if", "pad", ":", "if", ...
Shift array to the left. :param array: An iterable object. :type array: iterable object :param dist: how far you want to shift :type disk: int :param pad: pad array[-1] to the right. :type pad: boolean (default True) :param trim: trim the first ``#dist`` items. :type trim: boolean (defa...
[ "Shift", "array", "to", "the", "left", "." ]
689a60da51cd88680ddbe26e28dbe81e6b01d275
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/algorithm/iterable.py#L274-L316
240,140
MacHu-GWU/angora-project
angora/algorithm/iterable.py
count_generator
def count_generator(generator, memory_efficient=True): """Count number of item in generator. memory_efficient=True, 3 times slower, but memory_efficient. memory_efficient=False, faster, but cost more memory. """ if memory_efficient: counter = 0 for _ in generator: counte...
python
def count_generator(generator, memory_efficient=True): """Count number of item in generator. memory_efficient=True, 3 times slower, but memory_efficient. memory_efficient=False, faster, but cost more memory. """ if memory_efficient: counter = 0 for _ in generator: counte...
[ "def", "count_generator", "(", "generator", ",", "memory_efficient", "=", "True", ")", ":", "if", "memory_efficient", ":", "counter", "=", "0", "for", "_", "in", "generator", ":", "counter", "+=", "1", "return", "counter", "else", ":", "return", "len", "("...
Count number of item in generator. memory_efficient=True, 3 times slower, but memory_efficient. memory_efficient=False, faster, but cost more memory.
[ "Count", "number", "of", "item", "in", "generator", "." ]
689a60da51cd88680ddbe26e28dbe81e6b01d275
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/algorithm/iterable.py#L364-L376
240,141
MacHu-GWU/pyknackhq-project
pyknackhq/schema.py
Object.get_field_key
def get_field_key(self, key, using_name=True): """Given a field key or name, return it's field key. """ try: if using_name: return self.f_name[key].key else: return self.f[key].key except KeyError: raise ValueError("'%s'...
python
def get_field_key(self, key, using_name=True): """Given a field key or name, return it's field key. """ try: if using_name: return self.f_name[key].key else: return self.f[key].key except KeyError: raise ValueError("'%s'...
[ "def", "get_field_key", "(", "self", ",", "key", ",", "using_name", "=", "True", ")", ":", "try", ":", "if", "using_name", ":", "return", "self", ".", "f_name", "[", "key", "]", ".", "key", "else", ":", "return", "self", ".", "f", "[", "key", "]", ...
Given a field key or name, return it's field key.
[ "Given", "a", "field", "key", "or", "name", "return", "it", "s", "field", "key", "." ]
dd937f24d7b0a351ba3818eb746c31b29a8cc341
https://github.com/MacHu-GWU/pyknackhq-project/blob/dd937f24d7b0a351ba3818eb746c31b29a8cc341/pyknackhq/schema.py#L80-L89
240,142
MacHu-GWU/pyknackhq-project
pyknackhq/schema.py
Application.get_object_key
def get_object_key(self, key, using_name=True): """Given a object key or name, return it's object key. """ try: if using_name: return self.o_name[key].key else: return self.o[key].key except KeyError: raise ValueError("'...
python
def get_object_key(self, key, using_name=True): """Given a object key or name, return it's object key. """ try: if using_name: return self.o_name[key].key else: return self.o[key].key except KeyError: raise ValueError("'...
[ "def", "get_object_key", "(", "self", ",", "key", ",", "using_name", "=", "True", ")", ":", "try", ":", "if", "using_name", ":", "return", "self", ".", "o_name", "[", "key", "]", ".", "key", "else", ":", "return", "self", ".", "o", "[", "key", "]",...
Given a object key or name, return it's object key.
[ "Given", "a", "object", "key", "or", "name", "return", "it", "s", "object", "key", "." ]
dd937f24d7b0a351ba3818eb746c31b29a8cc341
https://github.com/MacHu-GWU/pyknackhq-project/blob/dd937f24d7b0a351ba3818eb746c31b29a8cc341/pyknackhq/schema.py#L149-L158
240,143
MacHu-GWU/angora-project
angora/filesystem/winzip.py
zip_a_folder
def zip_a_folder(src, dst): """Add a folder and everything inside to zip archive. Example:: |---paper |--- algorithm.pdf |--- images |--- 1.jpg zip_a_folder("paper", "paper.zip") paper.zip |---paper |--- algorithm.pd...
python
def zip_a_folder(src, dst): """Add a folder and everything inside to zip archive. Example:: |---paper |--- algorithm.pdf |--- images |--- 1.jpg zip_a_folder("paper", "paper.zip") paper.zip |---paper |--- algorithm.pd...
[ "def", "zip_a_folder", "(", "src", ",", "dst", ")", ":", "src", ",", "dst", "=", "os", ".", "path", ".", "abspath", "(", "src", ")", ",", "os", ".", "path", ".", "abspath", "(", "dst", ")", "cwd", "=", "os", ".", "getcwd", "(", ")", "todo", "...
Add a folder and everything inside to zip archive. Example:: |---paper |--- algorithm.pdf |--- images |--- 1.jpg zip_a_folder("paper", "paper.zip") paper.zip |---paper |--- algorithm.pdf |--- images ...
[ "Add", "a", "folder", "and", "everything", "inside", "to", "zip", "archive", "." ]
689a60da51cd88680ddbe26e28dbe81e6b01d275
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/winzip.py#L67-L104
240,144
MacHu-GWU/angora-project
angora/filesystem/winzip.py
zip_many_files
def zip_many_files(list_of_abspath, dst): """Add many files to a zip archive. **中文文档** 将一系列的文件压缩到一个压缩包中, 若有重复的文件名, 在zip中保留所有的副本。 """ base_dir = os.getcwd() with ZipFile(dst, "w") as f: for abspath in list_of_abspath: dirname, basename = os.path.split(abspath) o...
python
def zip_many_files(list_of_abspath, dst): """Add many files to a zip archive. **中文文档** 将一系列的文件压缩到一个压缩包中, 若有重复的文件名, 在zip中保留所有的副本。 """ base_dir = os.getcwd() with ZipFile(dst, "w") as f: for abspath in list_of_abspath: dirname, basename = os.path.split(abspath) o...
[ "def", "zip_many_files", "(", "list_of_abspath", ",", "dst", ")", ":", "base_dir", "=", "os", ".", "getcwd", "(", ")", "with", "ZipFile", "(", "dst", ",", "\"w\"", ")", "as", "f", ":", "for", "abspath", "in", "list_of_abspath", ":", "dirname", ",", "ba...
Add many files to a zip archive. **中文文档** 将一系列的文件压缩到一个压缩包中, 若有重复的文件名, 在zip中保留所有的副本。
[ "Add", "many", "files", "to", "a", "zip", "archive", "." ]
689a60da51cd88680ddbe26e28dbe81e6b01d275
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/winzip.py#L145-L160
240,145
MacHu-GWU/angora-project
angora/filesystem/winzip.py
write_gzip
def write_gzip(content, abspath): """Write binary content to gzip file. **中文文档** 将二进制内容压缩后编码写入gzip压缩文件。 """ with gzip.open(abspath, "wb") as f: f.write(content)
python
def write_gzip(content, abspath): """Write binary content to gzip file. **中文文档** 将二进制内容压缩后编码写入gzip压缩文件。 """ with gzip.open(abspath, "wb") as f: f.write(content)
[ "def", "write_gzip", "(", "content", ",", "abspath", ")", ":", "with", "gzip", ".", "open", "(", "abspath", ",", "\"wb\"", ")", "as", "f", ":", "f", ".", "write", "(", "content", ")" ]
Write binary content to gzip file. **中文文档** 将二进制内容压缩后编码写入gzip压缩文件。
[ "Write", "binary", "content", "to", "gzip", "file", "." ]
689a60da51cd88680ddbe26e28dbe81e6b01d275
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/winzip.py#L163-L171
240,146
klmitch/metatools
metatools.py
MetaMeta.iter_bases
def iter_bases(bases): """ Performs MRO linearization of a set of base classes. Yields each base class in turn. """ sequences = ([list(inspect.getmro(base)) for base in bases] + [list(bases)]) # Loop over sequences while True: s...
python
def iter_bases(bases): """ Performs MRO linearization of a set of base classes. Yields each base class in turn. """ sequences = ([list(inspect.getmro(base)) for base in bases] + [list(bases)]) # Loop over sequences while True: s...
[ "def", "iter_bases", "(", "bases", ")", ":", "sequences", "=", "(", "[", "list", "(", "inspect", ".", "getmro", "(", "base", ")", ")", "for", "base", "in", "bases", "]", "+", "[", "list", "(", "bases", ")", "]", ")", "# Loop over sequences", "while",...
Performs MRO linearization of a set of base classes. Yields each base class in turn.
[ "Performs", "MRO", "linearization", "of", "a", "set", "of", "base", "classes", ".", "Yields", "each", "base", "class", "in", "turn", "." ]
7161cf22ef2b194cfd4406e85b81e39a49104d9d
https://github.com/klmitch/metatools/blob/7161cf22ef2b194cfd4406e85b81e39a49104d9d/metatools.py#L53-L86
240,147
klmitch/metatools
metatools.py
MetaMeta.inherit_dict
def inherit_dict(base, namespace, attr_name, inherit=lambda k, v: True): """ Perform inheritance of dictionaries. Returns a list of key and value pairs for values that were inherited, for post-processing. :param base: The base class being considered; see ...
python
def inherit_dict(base, namespace, attr_name, inherit=lambda k, v: True): """ Perform inheritance of dictionaries. Returns a list of key and value pairs for values that were inherited, for post-processing. :param base: The base class being considered; see ...
[ "def", "inherit_dict", "(", "base", ",", "namespace", ",", "attr_name", ",", "inherit", "=", "lambda", "k", ",", "v", ":", "True", ")", ":", "items", "=", "[", "]", "# Get the dicts to compare", "base_dict", "=", "getattr", "(", "base", ",", "attr_name", ...
Perform inheritance of dictionaries. Returns a list of key and value pairs for values that were inherited, for post-processing. :param base: The base class being considered; see ``iter_bases()``. :param namespace: The dictionary of the new class being built. ...
[ "Perform", "inheritance", "of", "dictionaries", ".", "Returns", "a", "list", "of", "key", "and", "value", "pairs", "for", "values", "that", "were", "inherited", "for", "post", "-", "processing", "." ]
7161cf22ef2b194cfd4406e85b81e39a49104d9d
https://github.com/klmitch/metatools/blob/7161cf22ef2b194cfd4406e85b81e39a49104d9d/metatools.py#L89-L131
240,148
klmitch/metatools
metatools.py
MetaMeta.inherit_set
def inherit_set(base, namespace, attr_name, inherit=lambda i: True): """ Perform inheritance of sets. Returns a list of items that were inherited, for post-processing. :param base: The base class being considered; see ``iter_bases()``. :...
python
def inherit_set(base, namespace, attr_name, inherit=lambda i: True): """ Perform inheritance of sets. Returns a list of items that were inherited, for post-processing. :param base: The base class being considered; see ``iter_bases()``. :...
[ "def", "inherit_set", "(", "base", ",", "namespace", ",", "attr_name", ",", "inherit", "=", "lambda", "i", ":", "True", ")", ":", "items", "=", "[", "]", "# Get the sets to compare", "base_set", "=", "getattr", "(", "base", ",", "attr_name", ",", "set", ...
Perform inheritance of sets. Returns a list of items that were inherited, for post-processing. :param base: The base class being considered; see ``iter_bases()``. :param namespace: The dictionary of the new class being built. :param attr_name: The name of the attri...
[ "Perform", "inheritance", "of", "sets", ".", "Returns", "a", "list", "of", "items", "that", "were", "inherited", "for", "post", "-", "processing", "." ]
7161cf22ef2b194cfd4406e85b81e39a49104d9d
https://github.com/klmitch/metatools/blob/7161cf22ef2b194cfd4406e85b81e39a49104d9d/metatools.py#L134-L173
240,149
EnigmaBridge/client.py
ebclient/process_data.py
ProcessData.decrypt_result
def decrypt_result(self, *args, **kwargs): """ Decrypts ProcessData result with comm keys :param args: :param kwargs: :return: """ if self.response is None: raise ValueError('Empty response') if self.response.response is None \ ...
python
def decrypt_result(self, *args, **kwargs): """ Decrypts ProcessData result with comm keys :param args: :param kwargs: :return: """ if self.response is None: raise ValueError('Empty response') if self.response.response is None \ ...
[ "def", "decrypt_result", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "response", "is", "None", ":", "raise", "ValueError", "(", "'Empty response'", ")", "if", "self", ".", "response", ".", "response", "is", "Non...
Decrypts ProcessData result with comm keys :param args: :param kwargs: :return:
[ "Decrypts", "ProcessData", "result", "with", "comm", "keys" ]
0fafe3902da394da88e9f960751d695ca65bbabd
https://github.com/EnigmaBridge/client.py/blob/0fafe3902da394da88e9f960751d695ca65bbabd/ebclient/process_data.py#L94-L147
240,150
langloisjp/tstore
tstore/tstore.py
TStore.get
def get(self, cls, rid): """Return record of given type with key `rid` >>> s = teststore() >>> s.create('tstoretest', {'id': '1', 'name': 'Toto'}) >>> r = s.get('tstoretest', '1') >>> r['name'] 'Toto' >>> s.get('badcls', '1') Traceback (most recent call l...
python
def get(self, cls, rid): """Return record of given type with key `rid` >>> s = teststore() >>> s.create('tstoretest', {'id': '1', 'name': 'Toto'}) >>> r = s.get('tstoretest', '1') >>> r['name'] 'Toto' >>> s.get('badcls', '1') Traceback (most recent call l...
[ "def", "get", "(", "self", ",", "cls", ",", "rid", ")", ":", "self", ".", "validate_record_type", "(", "cls", ")", "rows", "=", "self", ".", "db", ".", "select", "(", "cls", ",", "where", "=", "{", "ID", ":", "rid", "}", ",", "limit", "=", "1",...
Return record of given type with key `rid` >>> s = teststore() >>> s.create('tstoretest', {'id': '1', 'name': 'Toto'}) >>> r = s.get('tstoretest', '1') >>> r['name'] 'Toto' >>> s.get('badcls', '1') Traceback (most recent call last): ... ValueE...
[ "Return", "record", "of", "given", "type", "with", "key", "rid" ]
b438f8aaf09117bf6f922ba06ae5cf46b7b97a57
https://github.com/langloisjp/tstore/blob/b438f8aaf09117bf6f922ba06ae5cf46b7b97a57/tstore/tstore.py#L118-L139
240,151
langloisjp/tstore
tstore/tstore.py
TStore.create
def create(self, cls, record, user='undefined'): """Persist new record >>> s = teststore() >>> s.create('tstoretest', {'id': '1', 'name': 'Toto'}) >>> s.create('tstoretest', {'id': '2', 'name': 'Tata'}, user='jane') >>> r = s.get('tstoretest', '2') >>> r[CREATOR] ...
python
def create(self, cls, record, user='undefined'): """Persist new record >>> s = teststore() >>> s.create('tstoretest', {'id': '1', 'name': 'Toto'}) >>> s.create('tstoretest', {'id': '2', 'name': 'Tata'}, user='jane') >>> r = s.get('tstoretest', '2') >>> r[CREATOR] ...
[ "def", "create", "(", "self", ",", "cls", ",", "record", ",", "user", "=", "'undefined'", ")", ":", "self", ".", "validate_record", "(", "cls", ",", "record", ")", "record", "[", "CREATION_DATE", "]", "=", "record", "[", "UPDATE_DATE", "]", "=", "self"...
Persist new record >>> s = teststore() >>> s.create('tstoretest', {'id': '1', 'name': 'Toto'}) >>> s.create('tstoretest', {'id': '2', 'name': 'Tata'}, user='jane') >>> r = s.get('tstoretest', '2') >>> r[CREATOR] 'jane' >>> s.create('badcls', {'id': '1', 'name': '...
[ "Persist", "new", "record" ]
b438f8aaf09117bf6f922ba06ae5cf46b7b97a57
https://github.com/langloisjp/tstore/blob/b438f8aaf09117bf6f922ba06ae5cf46b7b97a57/tstore/tstore.py#L141-L184
240,152
langloisjp/tstore
tstore/tstore.py
TStore.update
def update(self, cls, rid, partialrecord, user='undefined'): """Update existing record >>> s = teststore() >>> s.create('tstoretest', {'id': '1', 'name': 'Toto'}) >>> r = s.get('tstoretest', '1') >>> r['age'] >>> s.update('tstoretest', '1', {'age': 25}) >>> r = s...
python
def update(self, cls, rid, partialrecord, user='undefined'): """Update existing record >>> s = teststore() >>> s.create('tstoretest', {'id': '1', 'name': 'Toto'}) >>> r = s.get('tstoretest', '1') >>> r['age'] >>> s.update('tstoretest', '1', {'age': 25}) >>> r = s...
[ "def", "update", "(", "self", ",", "cls", ",", "rid", ",", "partialrecord", ",", "user", "=", "'undefined'", ")", ":", "self", ".", "validate_partial_record", "(", "cls", ",", "partialrecord", ")", "partialrecord", "[", "UPDATE_DATE", "]", "=", "self", "."...
Update existing record >>> s = teststore() >>> s.create('tstoretest', {'id': '1', 'name': 'Toto'}) >>> r = s.get('tstoretest', '1') >>> r['age'] >>> s.update('tstoretest', '1', {'age': 25}) >>> r = s.get('tstoretest', '1') >>> r['age'] 25 >>> s.up...
[ "Update", "existing", "record" ]
b438f8aaf09117bf6f922ba06ae5cf46b7b97a57
https://github.com/langloisjp/tstore/blob/b438f8aaf09117bf6f922ba06ae5cf46b7b97a57/tstore/tstore.py#L186-L235
240,153
langloisjp/tstore
tstore/tstore.py
TStore.delete
def delete(self, cls, rid, user='undefined'): """ Delete a record by id. `user` currently unused. Would be used with soft deletes. >>> s = teststore() >>> s.create('tstoretest', {'id': '1', 'name': 'Toto'}) >>> len(s.list('tstoretest')) 1 >>> s.delete('t...
python
def delete(self, cls, rid, user='undefined'): """ Delete a record by id. `user` currently unused. Would be used with soft deletes. >>> s = teststore() >>> s.create('tstoretest', {'id': '1', 'name': 'Toto'}) >>> len(s.list('tstoretest')) 1 >>> s.delete('t...
[ "def", "delete", "(", "self", ",", "cls", ",", "rid", ",", "user", "=", "'undefined'", ")", ":", "self", ".", "validate_record_type", "(", "cls", ")", "deletedcount", "=", "self", ".", "db", ".", "delete", "(", "cls", ",", "{", "ID", ":", "rid", "}...
Delete a record by id. `user` currently unused. Would be used with soft deletes. >>> s = teststore() >>> s.create('tstoretest', {'id': '1', 'name': 'Toto'}) >>> len(s.list('tstoretest')) 1 >>> s.delete('tstoretest', '1') >>> len(s.list('tstoretest')) 0 ...
[ "Delete", "a", "record", "by", "id", "." ]
b438f8aaf09117bf6f922ba06ae5cf46b7b97a57
https://github.com/langloisjp/tstore/blob/b438f8aaf09117bf6f922ba06ae5cf46b7b97a57/tstore/tstore.py#L248-L269
240,154
langloisjp/tstore
tstore/tstore.py
TStore.validate_record_type
def validate_record_type(self, cls): """ Validate given record is acceptable. >>> s = teststore() >>> s.validate_record_type('tstoretest') >>> s.validate_record_type('bad') Traceback (most recent call last): ... ValueError: Unsupported record type "ba...
python
def validate_record_type(self, cls): """ Validate given record is acceptable. >>> s = teststore() >>> s.validate_record_type('tstoretest') >>> s.validate_record_type('bad') Traceback (most recent call last): ... ValueError: Unsupported record type "ba...
[ "def", "validate_record_type", "(", "self", ",", "cls", ")", ":", "if", "self", ".", "record_types", "and", "cls", "not", "in", "self", ".", "record_types", ":", "raise", "ValueError", "(", "'Unsupported record type \"'", "+", "cls", "+", "'\"'", ")" ]
Validate given record is acceptable. >>> s = teststore() >>> s.validate_record_type('tstoretest') >>> s.validate_record_type('bad') Traceback (most recent call last): ... ValueError: Unsupported record type "bad"
[ "Validate", "given", "record", "is", "acceptable", "." ]
b438f8aaf09117bf6f922ba06ae5cf46b7b97a57
https://github.com/langloisjp/tstore/blob/b438f8aaf09117bf6f922ba06ae5cf46b7b97a57/tstore/tstore.py#L271-L283
240,155
langloisjp/tstore
tstore/tstore.py
TStore.as_record
def as_record(self, cls, content_type, strdata): """ Returns a record from serialized string representation. >>> s = teststore() >>> s.as_record('tstoretest', 'application/json', ... '{"id": "1", "name": "Toto"}') {u'id': u'1', u'name': u'Toto'} """ self....
python
def as_record(self, cls, content_type, strdata): """ Returns a record from serialized string representation. >>> s = teststore() >>> s.as_record('tstoretest', 'application/json', ... '{"id": "1", "name": "Toto"}') {u'id': u'1', u'name': u'Toto'} """ self....
[ "def", "as_record", "(", "self", ",", "cls", ",", "content_type", ",", "strdata", ")", ":", "self", ".", "validate_record_type", "(", "cls", ")", "parsedrecord", "=", "self", ".", "deserialize", "(", "content_type", ",", "strdata", ")", "return", "self", "...
Returns a record from serialized string representation. >>> s = teststore() >>> s.as_record('tstoretest', 'application/json', ... '{"id": "1", "name": "Toto"}') {u'id': u'1', u'name': u'Toto'}
[ "Returns", "a", "record", "from", "serialized", "string", "representation", "." ]
b438f8aaf09117bf6f922ba06ae5cf46b7b97a57
https://github.com/langloisjp/tstore/blob/b438f8aaf09117bf6f922ba06ae5cf46b7b97a57/tstore/tstore.py#L285-L296
240,156
langloisjp/tstore
tstore/tstore.py
TStore.serialize
def serialize(self, cls, record): """ Serialize the record to JSON. cls unused in this implementation. >>> s = teststore() >>> s.serialize('tstoretest', {'id': '1', 'name': 'Toto'}) '{"id": "1", "name": "Toto"}' """ return json.dumps(record, cls=self.encoder)
python
def serialize(self, cls, record): """ Serialize the record to JSON. cls unused in this implementation. >>> s = teststore() >>> s.serialize('tstoretest', {'id': '1', 'name': 'Toto'}) '{"id": "1", "name": "Toto"}' """ return json.dumps(record, cls=self.encoder)
[ "def", "serialize", "(", "self", ",", "cls", ",", "record", ")", ":", "return", "json", ".", "dumps", "(", "record", ",", "cls", "=", "self", ".", "encoder", ")" ]
Serialize the record to JSON. cls unused in this implementation. >>> s = teststore() >>> s.serialize('tstoretest', {'id': '1', 'name': 'Toto'}) '{"id": "1", "name": "Toto"}'
[ "Serialize", "the", "record", "to", "JSON", ".", "cls", "unused", "in", "this", "implementation", "." ]
b438f8aaf09117bf6f922ba06ae5cf46b7b97a57
https://github.com/langloisjp/tstore/blob/b438f8aaf09117bf6f922ba06ae5cf46b7b97a57/tstore/tstore.py#L298-L306
240,157
langloisjp/tstore
tstore/tstore.py
TStore.deserialize
def deserialize(self, content_type, strdata): """Deserialize string of given content type. `self` unused in this implementation. >>> s = teststore() >>> s.deserialize('application/json', '{"id": "1", "name": "Toto"}') {u'id': u'1', u'name': u'Toto'} >>> s.deserialize('t...
python
def deserialize(self, content_type, strdata): """Deserialize string of given content type. `self` unused in this implementation. >>> s = teststore() >>> s.deserialize('application/json', '{"id": "1", "name": "Toto"}') {u'id': u'1', u'name': u'Toto'} >>> s.deserialize('t...
[ "def", "deserialize", "(", "self", ",", "content_type", ",", "strdata", ")", ":", "if", "content_type", "!=", "'application/json'", ":", "raise", "ValueError", "(", "'Unsupported content type \"'", "+", "content_type", "+", "'\"'", ")", "return", "json", ".", "l...
Deserialize string of given content type. `self` unused in this implementation. >>> s = teststore() >>> s.deserialize('application/json', '{"id": "1", "name": "Toto"}') {u'id': u'1', u'name': u'Toto'} >>> s.deserialize('text/plain', 'id: 1, name: Toto') Traceback (most ...
[ "Deserialize", "string", "of", "given", "content", "type", "." ]
b438f8aaf09117bf6f922ba06ae5cf46b7b97a57
https://github.com/langloisjp/tstore/blob/b438f8aaf09117bf6f922ba06ae5cf46b7b97a57/tstore/tstore.py#L308-L323
240,158
klmitch/tendril
tendril/framers.py
IdentityFramer.frameify
def frameify(self, state, data): """Yield the data as a single frame.""" try: yield state.recv_buf + data except FrameSwitch: pass finally: state.recv_buf = ''
python
def frameify(self, state, data): """Yield the data as a single frame.""" try: yield state.recv_buf + data except FrameSwitch: pass finally: state.recv_buf = ''
[ "def", "frameify", "(", "self", ",", "state", ",", "data", ")", ":", "try", ":", "yield", "state", ".", "recv_buf", "+", "data", "except", "FrameSwitch", ":", "pass", "finally", ":", "state", ".", "recv_buf", "=", "''" ]
Yield the data as a single frame.
[ "Yield", "the", "data", "as", "a", "single", "frame", "." ]
207102c83e88f8f1fa7ba605ef0aab2ae9078b36
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/framers.py#L167-L175
240,159
klmitch/tendril
tendril/framers.py
ChunkFramer.frameify
def frameify(self, state, data): """Yield chunk data as a single frame, and buffer the rest.""" # If we've pulled in all the chunk data, buffer the data if state.chunk_remaining <= 0: state.recv_buf += data return # Pull in any partially-processed data d...
python
def frameify(self, state, data): """Yield chunk data as a single frame, and buffer the rest.""" # If we've pulled in all the chunk data, buffer the data if state.chunk_remaining <= 0: state.recv_buf += data return # Pull in any partially-processed data d...
[ "def", "frameify", "(", "self", ",", "state", ",", "data", ")", ":", "# If we've pulled in all the chunk data, buffer the data", "if", "state", ".", "chunk_remaining", "<=", "0", ":", "state", ".", "recv_buf", "+=", "data", "return", "# Pull in any partially-processed...
Yield chunk data as a single frame, and buffer the rest.
[ "Yield", "chunk", "data", "as", "a", "single", "frame", "and", "buffer", "the", "rest", "." ]
207102c83e88f8f1fa7ba605ef0aab2ae9078b36
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/framers.py#L207-L235
240,160
klmitch/tendril
tendril/framers.py
LineFramer.frameify
def frameify(self, state, data): """Split data into a sequence of lines.""" # Pull in any partially-processed data data = state.recv_buf + data # Loop over the data while data: line, sep, rest = data.partition('\n') # Did we have a whole line? ...
python
def frameify(self, state, data): """Split data into a sequence of lines.""" # Pull in any partially-processed data data = state.recv_buf + data # Loop over the data while data: line, sep, rest = data.partition('\n') # Did we have a whole line? ...
[ "def", "frameify", "(", "self", ",", "state", ",", "data", ")", ":", "# Pull in any partially-processed data", "data", "=", "state", ".", "recv_buf", "+", "data", "# Loop over the data", "while", "data", ":", "line", ",", "sep", ",", "rest", "=", "data", "."...
Split data into a sequence of lines.
[ "Split", "data", "into", "a", "sequence", "of", "lines", "." ]
207102c83e88f8f1fa7ba605ef0aab2ae9078b36
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/framers.py#L261-L289
240,161
klmitch/tendril
tendril/framers.py
StuffingFramer.streamify
def streamify(self, state, frame): """Prepare frame for output as a byte-stuffed stream.""" # Split the frame apart for stuffing... pieces = frame.split(self.prefix) return '%s%s%s%s%s' % (self.prefix, self.begin, (self.prefix + self.nop).join(pieces), ...
python
def streamify(self, state, frame): """Prepare frame for output as a byte-stuffed stream.""" # Split the frame apart for stuffing... pieces = frame.split(self.prefix) return '%s%s%s%s%s' % (self.prefix, self.begin, (self.prefix + self.nop).join(pieces), ...
[ "def", "streamify", "(", "self", ",", "state", ",", "frame", ")", ":", "# Split the frame apart for stuffing...", "pieces", "=", "frame", ".", "split", "(", "self", ".", "prefix", ")", "return", "'%s%s%s%s%s'", "%", "(", "self", ".", "prefix", ",", "self", ...
Prepare frame for output as a byte-stuffed stream.
[ "Prepare", "frame", "for", "output", "as", "a", "byte", "-", "stuffed", "stream", "." ]
207102c83e88f8f1fa7ba605ef0aab2ae9078b36
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/framers.py#L481-L489
240,162
klmitch/tendril
tendril/framers.py
COBSFramer._get_tab
def _get_tab(cls): """Generate and return the COBS table.""" if not cls._tabs['dec_cobs']: # Compute the COBS table for decoding cls._tabs['dec_cobs']['\xff'] = (255, '') cls._tabs['dec_cobs'].update(dict((chr(l), (l, '\0')) ...
python
def _get_tab(cls): """Generate and return the COBS table.""" if not cls._tabs['dec_cobs']: # Compute the COBS table for decoding cls._tabs['dec_cobs']['\xff'] = (255, '') cls._tabs['dec_cobs'].update(dict((chr(l), (l, '\0')) ...
[ "def", "_get_tab", "(", "cls", ")", ":", "if", "not", "cls", ".", "_tabs", "[", "'dec_cobs'", "]", ":", "# Compute the COBS table for decoding", "cls", ".", "_tabs", "[", "'dec_cobs'", "]", "[", "'\\xff'", "]", "=", "(", "255", ",", "''", ")", "cls", "...
Generate and return the COBS table.
[ "Generate", "and", "return", "the", "COBS", "table", "." ]
207102c83e88f8f1fa7ba605ef0aab2ae9078b36
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/framers.py#L507-L522
240,163
klmitch/tendril
tendril/framers.py
COBSFramer._get_tab_zpe
def _get_tab_zpe(cls): """Generate and return the COBS ZPE table.""" if not cls._tabs['dec_cobs_zpe']: # Compute the COBS ZPE table for decoding cls._tabs['dec_cobs_zpe']['\xe0'] = (224, '') cls._tabs['dec_cobs_zpe'].update(dict((chr(l), (l, '\0')) ...
python
def _get_tab_zpe(cls): """Generate and return the COBS ZPE table.""" if not cls._tabs['dec_cobs_zpe']: # Compute the COBS ZPE table for decoding cls._tabs['dec_cobs_zpe']['\xe0'] = (224, '') cls._tabs['dec_cobs_zpe'].update(dict((chr(l), (l, '\0')) ...
[ "def", "_get_tab_zpe", "(", "cls", ")", ":", "if", "not", "cls", ".", "_tabs", "[", "'dec_cobs_zpe'", "]", ":", "# Compute the COBS ZPE table for decoding", "cls", ".", "_tabs", "[", "'dec_cobs_zpe'", "]", "[", "'\\xe0'", "]", "=", "(", "224", ",", "''", "...
Generate and return the COBS ZPE table.
[ "Generate", "and", "return", "the", "COBS", "ZPE", "table", "." ]
207102c83e88f8f1fa7ba605ef0aab2ae9078b36
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/framers.py#L525-L544
240,164
klmitch/tendril
tendril/framers.py
COBSFramer._decode
def _decode(frame, tab): """Decode a frame with the help of the table.""" blocks = [] # Decode each block while frame: length, endseq = tab[frame[0]] blocks.extend([frame[1:length], endseq]) frame = frame[length:] # Remove one (and only one)...
python
def _decode(frame, tab): """Decode a frame with the help of the table.""" blocks = [] # Decode each block while frame: length, endseq = tab[frame[0]] blocks.extend([frame[1:length], endseq]) frame = frame[length:] # Remove one (and only one)...
[ "def", "_decode", "(", "frame", ",", "tab", ")", ":", "blocks", "=", "[", "]", "# Decode each block", "while", "frame", ":", "length", ",", "endseq", "=", "tab", "[", "frame", "[", "0", "]", "]", "blocks", ".", "extend", "(", "[", "frame", "[", "1"...
Decode a frame with the help of the table.
[ "Decode", "a", "frame", "with", "the", "help", "of", "the", "table", "." ]
207102c83e88f8f1fa7ba605ef0aab2ae9078b36
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/framers.py#L547-L563
240,165
klmitch/tendril
tendril/framers.py
COBSFramer.streamify
def streamify(self, state, frame): """Prepare frame for output as a COBS-encoded stream.""" # Get the encoding table enc_tab = self._tables[1][:] # Need the special un-trailed block length and code untrail_len, untrail_code = enc_tab.pop(0) # Set up a repository to rec...
python
def streamify(self, state, frame): """Prepare frame for output as a COBS-encoded stream.""" # Get the encoding table enc_tab = self._tables[1][:] # Need the special un-trailed block length and code untrail_len, untrail_code = enc_tab.pop(0) # Set up a repository to rec...
[ "def", "streamify", "(", "self", ",", "state", ",", "frame", ")", ":", "# Get the encoding table", "enc_tab", "=", "self", ".", "_tables", "[", "1", "]", "[", ":", "]", "# Need the special un-trailed block length and code", "untrail_len", ",", "untrail_code", "=",...
Prepare frame for output as a COBS-encoded stream.
[ "Prepare", "frame", "for", "output", "as", "a", "COBS", "-", "encoded", "stream", "." ]
207102c83e88f8f1fa7ba605ef0aab2ae9078b36
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/framers.py#L603-L650
240,166
rmed/flask-waffleconf
flask_waffleconf/core.py
_WaffleState.parse_conf
def parse_conf(self, keys=[]): """Parse configuration values from the database. The extension must have been previously initialized. If a key is not found in the database, it will be created with the default value specified. Arguments: keys (list[str]): list of key...
python
def parse_conf(self, keys=[]): """Parse configuration values from the database. The extension must have been previously initialized. If a key is not found in the database, it will be created with the default value specified. Arguments: keys (list[str]): list of key...
[ "def", "parse_conf", "(", "self", ",", "keys", "=", "[", "]", ")", ":", "confs", "=", "self", ".", "app", ".", "config", ".", "get", "(", "'WAFFLE_CONFS'", ",", "{", "}", ")", "if", "not", "keys", ":", "keys", "=", "confs", ".", "keys", "(", ")...
Parse configuration values from the database. The extension must have been previously initialized. If a key is not found in the database, it will be created with the default value specified. Arguments: keys (list[str]): list of keys to parse. If the list is empty, then ...
[ "Parse", "configuration", "values", "from", "the", "database", "." ]
a75ed69101796c9f3f42eff9f91e91dc6dd13869
https://github.com/rmed/flask-waffleconf/blob/a75ed69101796c9f3f42eff9f91e91dc6dd13869/flask_waffleconf/core.py#L58-L102
240,167
rmed/flask-waffleconf
flask_waffleconf/core.py
_WaffleState.update_db
def update_db(self, new_values): """Update database values and application configuration. The provided keys must be defined in the ``WAFFLE_CONFS`` setting. Arguments: new_values (dict): dict of configuration variables and their values The dict has the following str...
python
def update_db(self, new_values): """Update database values and application configuration. The provided keys must be defined in the ``WAFFLE_CONFS`` setting. Arguments: new_values (dict): dict of configuration variables and their values The dict has the following str...
[ "def", "update_db", "(", "self", ",", "new_values", ")", ":", "confs", "=", "self", ".", "app", ".", "config", ".", "get", "(", "'WAFFLE_CONFS'", ",", "{", "}", ")", "to_update", "=", "{", "}", "for", "key", "in", "new_values", ".", "keys", "(", ")...
Update database values and application configuration. The provided keys must be defined in the ``WAFFLE_CONFS`` setting. Arguments: new_values (dict): dict of configuration variables and their values The dict has the following structure: { ...
[ "Update", "database", "values", "and", "application", "configuration", "." ]
a75ed69101796c9f3f42eff9f91e91dc6dd13869
https://github.com/rmed/flask-waffleconf/blob/a75ed69101796c9f3f42eff9f91e91dc6dd13869/flask_waffleconf/core.py#L104-L144
240,168
rmed/flask-waffleconf
flask_waffleconf/core.py
_WaffleState.update_conf
def update_conf(self): """Update configuration values from database. This method should be called when there is an update notification. """ parsed = self.parse_conf() if not parsed: return None # Update app config self.app.config.update(parsed)
python
def update_conf(self): """Update configuration values from database. This method should be called when there is an update notification. """ parsed = self.parse_conf() if not parsed: return None # Update app config self.app.config.update(parsed)
[ "def", "update_conf", "(", "self", ")", ":", "parsed", "=", "self", ".", "parse_conf", "(", ")", "if", "not", "parsed", ":", "return", "None", "# Update app config", "self", ".", "app", ".", "config", ".", "update", "(", "parsed", ")" ]
Update configuration values from database. This method should be called when there is an update notification.
[ "Update", "configuration", "values", "from", "database", "." ]
a75ed69101796c9f3f42eff9f91e91dc6dd13869
https://github.com/rmed/flask-waffleconf/blob/a75ed69101796c9f3f42eff9f91e91dc6dd13869/flask_waffleconf/core.py#L146-L157
240,169
rmed/flask-waffleconf
flask_waffleconf/core.py
WaffleConf.init_app
def init_app(self, app, configstore): """Initialize the extension for the given application and store. Parse the configuration values stored in the database obtained from the ``WAFFLE_CONFS`` value of the configuration. Arguments: app: Flask application instance ...
python
def init_app(self, app, configstore): """Initialize the extension for the given application and store. Parse the configuration values stored in the database obtained from the ``WAFFLE_CONFS`` value of the configuration. Arguments: app: Flask application instance ...
[ "def", "init_app", "(", "self", ",", "app", ",", "configstore", ")", ":", "if", "not", "hasattr", "(", "app", ",", "'extensions'", ")", ":", "app", ".", "extensions", "=", "{", "}", "self", ".", "state", "=", "_WaffleState", "(", "app", ",", "configs...
Initialize the extension for the given application and store. Parse the configuration values stored in the database obtained from the ``WAFFLE_CONFS`` value of the configuration. Arguments: app: Flask application instance configstore (WaffleStore): database store.
[ "Initialize", "the", "extension", "for", "the", "given", "application", "and", "store", "." ]
a75ed69101796c9f3f42eff9f91e91dc6dd13869
https://github.com/rmed/flask-waffleconf/blob/a75ed69101796c9f3f42eff9f91e91dc6dd13869/flask_waffleconf/core.py#L177-L192
240,170
smbapps/isolcss
isolcss/main.py
isolcss
def isolcss(prefix, css): """ Returns `css` with all selectors prefixed by `prefix`, or replacing "&" as SASS and LESS both do. Tries to parse strictly then falls back, with a warning, to forgiving parse if necessary. """ try: # Attempt full strict parse, raise exception on failure....
python
def isolcss(prefix, css): """ Returns `css` with all selectors prefixed by `prefix`, or replacing "&" as SASS and LESS both do. Tries to parse strictly then falls back, with a warning, to forgiving parse if necessary. """ try: # Attempt full strict parse, raise exception on failure....
[ "def", "isolcss", "(", "prefix", ",", "css", ")", ":", "try", ":", "# Attempt full strict parse, raise exception on failure.", "all", "(", "True", "for", "m", "in", "matchiter", "(", "selrule_or_atom_re", ",", "css", ")", ")", "except", "ValueError", "as", "e", ...
Returns `css` with all selectors prefixed by `prefix`, or replacing "&" as SASS and LESS both do. Tries to parse strictly then falls back, with a warning, to forgiving parse if necessary.
[ "Returns", "css", "with", "all", "selectors", "prefixed", "by", "prefix", "or", "replacing", "&", "as", "SASS", "and", "LESS", "both", "do", "." ]
1613dfd297f64292af1216855b6d096f2bed82fe
https://github.com/smbapps/isolcss/blob/1613dfd297f64292af1216855b6d096f2bed82fe/isolcss/main.py#L11-L50
240,171
lewisjared/credkeep
credkeep/decrypt.py
decrypt_file
def decrypt_file(filename, set_env=True, override_env=False): """ Decrypts a JSON file containing encrypted secrets. This file should contain an object mapping the key names to encrypted secrets. This encrypted file can be created using `credkeep.encrypt_file` or the commandline utility. :param filenam...
python
def decrypt_file(filename, set_env=True, override_env=False): """ Decrypts a JSON file containing encrypted secrets. This file should contain an object mapping the key names to encrypted secrets. This encrypted file can be created using `credkeep.encrypt_file` or the commandline utility. :param filenam...
[ "def", "decrypt_file", "(", "filename", ",", "set_env", "=", "True", ",", "override_env", "=", "False", ")", ":", "data", "=", "json", ".", "load", "(", "open", "(", "filename", ")", ")", "results", "=", "{", "}", "for", "key", ",", "v", "in", "dat...
Decrypts a JSON file containing encrypted secrets. This file should contain an object mapping the key names to encrypted secrets. This encrypted file can be created using `credkeep.encrypt_file` or the commandline utility. :param filename: filename of the JSON file :param set_env: If True, an environment ...
[ "Decrypts", "a", "JSON", "file", "containing", "encrypted", "secrets", ".", "This", "file", "should", "contain", "an", "object", "mapping", "the", "key", "names", "to", "encrypted", "secrets", ".", "This", "encrypted", "file", "can", "be", "created", "using", ...
63638ced094992552a28109b91839bcbbbe9230a
https://github.com/lewisjared/credkeep/blob/63638ced094992552a28109b91839bcbbbe9230a/credkeep/decrypt.py#L13-L37
240,172
lewisjared/credkeep
credkeep/decrypt.py
decrypt_or_cache
def decrypt_or_cache(filename, **kwargs): """ Attempts to load a local version of decrypted secrets before making external api calls. This is useful as it allows credkeep secrets to be used offline. Options for decrypt_filename can be passed to this function. :param filename: filename of encrypted ...
python
def decrypt_or_cache(filename, **kwargs): """ Attempts to load a local version of decrypted secrets before making external api calls. This is useful as it allows credkeep secrets to be used offline. Options for decrypt_filename can be passed to this function. :param filename: filename of encrypted ...
[ "def", "decrypt_or_cache", "(", "filename", ",", "*", "*", "kwargs", ")", ":", "clear_fname", "=", "enc_to_clear_filename", "(", "filename", ")", "if", "clear_fname", ":", "return", "json", ".", "load", "(", "open", "(", "clear_fname", ")", ")", "return", ...
Attempts to load a local version of decrypted secrets before making external api calls. This is useful as it allows credkeep secrets to be used offline. Options for decrypt_filename can be passed to this function. :param filename: filename of encrypted JSON file :return: Dict containing decrypted keys
[ "Attempts", "to", "load", "a", "local", "version", "of", "decrypted", "secrets", "before", "making", "external", "api", "calls", "." ]
63638ced094992552a28109b91839bcbbbe9230a
https://github.com/lewisjared/credkeep/blob/63638ced094992552a28109b91839bcbbbe9230a/credkeep/decrypt.py#L40-L53
240,173
datakortet/dkfileutils
dkfileutils/path.py
Path.list
def list(self, filterfn=lambda x: True): """Return all direct descendands of directory `self` for which `filterfn` returns True. """ return [self / p for p in self.listdir() if filterfn(self / p)]
python
def list(self, filterfn=lambda x: True): """Return all direct descendands of directory `self` for which `filterfn` returns True. """ return [self / p for p in self.listdir() if filterfn(self / p)]
[ "def", "list", "(", "self", ",", "filterfn", "=", "lambda", "x", ":", "True", ")", ":", "return", "[", "self", "/", "p", "for", "p", "in", "self", ".", "listdir", "(", ")", "if", "filterfn", "(", "self", "/", "p", ")", "]" ]
Return all direct descendands of directory `self` for which `filterfn` returns True.
[ "Return", "all", "direct", "descendands", "of", "directory", "self", "for", "which", "filterfn", "returns", "True", "." ]
924098d6e2edf88ad9b3ffdec9c74530f80a7d77
https://github.com/datakortet/dkfileutils/blob/924098d6e2edf88ad9b3ffdec9c74530f80a7d77/dkfileutils/path.py#L329-L333
240,174
datakortet/dkfileutils
dkfileutils/path.py
Path.rm
def rm(self, fname=None): """Remove a file, don't raise exception if file does not exist. """ if fname is not None: return (self / fname).rm() try: self.remove() except OSError: pass
python
def rm(self, fname=None): """Remove a file, don't raise exception if file does not exist. """ if fname is not None: return (self / fname).rm() try: self.remove() except OSError: pass
[ "def", "rm", "(", "self", ",", "fname", "=", "None", ")", ":", "if", "fname", "is", "not", "None", ":", "return", "(", "self", "/", "fname", ")", ".", "rm", "(", ")", "try", ":", "self", ".", "remove", "(", ")", "except", "OSError", ":", "pass"...
Remove a file, don't raise exception if file does not exist.
[ "Remove", "a", "file", "don", "t", "raise", "exception", "if", "file", "does", "not", "exist", "." ]
924098d6e2edf88ad9b3ffdec9c74530f80a7d77
https://github.com/datakortet/dkfileutils/blob/924098d6e2edf88ad9b3ffdec9c74530f80a7d77/dkfileutils/path.py#L372-L380
240,175
oczkers/pyllegro
pyllegro/core.py
chunked
def chunked(l, n): """Chunk one big list into few small lists.""" return [l[i:i + n] for i in range(0, len(l), n)]
python
def chunked(l, n): """Chunk one big list into few small lists.""" return [l[i:i + n] for i in range(0, len(l), n)]
[ "def", "chunked", "(", "l", ",", "n", ")", ":", "return", "[", "l", "[", "i", ":", "i", "+", "n", "]", "for", "i", "in", "range", "(", "0", ",", "len", "(", "l", ")", ",", "n", ")", "]" ]
Chunk one big list into few small lists.
[ "Chunk", "one", "big", "list", "into", "few", "small", "lists", "." ]
c6d7090560cb9e579f7f769a9eec131a3db2c258
https://github.com/oczkers/pyllegro/blob/c6d7090560cb9e579f7f769a9eec131a3db2c258/pyllegro/core.py#L40-L42
240,176
oczkers/pyllegro
pyllegro/core.py
Allegro.getBids
def getBids(self, auction_id): """Retrieve all bids in given auction.""" bids = {} rc = self.__ask__('doGetBidItem2', itemId=auction_id) if rc: for i in rc: i = i['bidsArray'] bids[long(i['item'][1])] = { 'price': Decimal(i[...
python
def getBids(self, auction_id): """Retrieve all bids in given auction.""" bids = {} rc = self.__ask__('doGetBidItem2', itemId=auction_id) if rc: for i in rc: i = i['bidsArray'] bids[long(i['item'][1])] = { 'price': Decimal(i[...
[ "def", "getBids", "(", "self", ",", "auction_id", ")", ":", "bids", "=", "{", "}", "rc", "=", "self", ".", "__ask__", "(", "'doGetBidItem2'", ",", "itemId", "=", "auction_id", ")", "if", "rc", ":", "for", "i", "in", "rc", ":", "i", "=", "i", "[",...
Retrieve all bids in given auction.
[ "Retrieve", "all", "bids", "in", "given", "auction", "." ]
c6d7090560cb9e579f7f769a9eec131a3db2c258
https://github.com/oczkers/pyllegro/blob/c6d7090560cb9e579f7f769a9eec131a3db2c258/pyllegro/core.py#L150-L162
240,177
oczkers/pyllegro
pyllegro/core.py
Allegro.getBuyerInfo
def getBuyerInfo(self, auction_id, buyer_id): """Return buyer info.""" # TODO: add price from getBids rc = self.__ask__('doGetPostBuyData', itemsArray=self.ArrayOfLong([auction_id]), buyerFilterArray=self.ArrayOfLong([buyer_id])) rc = rc[0]['usersPostBuyData']['item'][0]['userData'] ...
python
def getBuyerInfo(self, auction_id, buyer_id): """Return buyer info.""" # TODO: add price from getBids rc = self.__ask__('doGetPostBuyData', itemsArray=self.ArrayOfLong([auction_id]), buyerFilterArray=self.ArrayOfLong([buyer_id])) rc = rc[0]['usersPostBuyData']['item'][0]['userData'] ...
[ "def", "getBuyerInfo", "(", "self", ",", "auction_id", ",", "buyer_id", ")", ":", "# TODO: add price from getBids", "rc", "=", "self", ".", "__ask__", "(", "'doGetPostBuyData'", ",", "itemsArray", "=", "self", ".", "ArrayOfLong", "(", "[", "auction_id", "]", "...
Return buyer info.
[ "Return", "buyer", "info", "." ]
c6d7090560cb9e579f7f769a9eec131a3db2c258
https://github.com/oczkers/pyllegro/blob/c6d7090560cb9e579f7f769a9eec131a3db2c258/pyllegro/core.py#L164-L179
240,178
oczkers/pyllegro
pyllegro/core.py
Allegro.getOrders
def getOrders(self, auction_ids): """Return orders details.""" orders = {} # chunk list (only 25 auction_ids per request) for chunk in chunked(auction_ids, 25): # auctions = [{'item': auction_id} for auction_id in chunk] # TODO?: is it needed? auctions = self.Arr...
python
def getOrders(self, auction_ids): """Return orders details.""" orders = {} # chunk list (only 25 auction_ids per request) for chunk in chunked(auction_ids, 25): # auctions = [{'item': auction_id} for auction_id in chunk] # TODO?: is it needed? auctions = self.Arr...
[ "def", "getOrders", "(", "self", ",", "auction_ids", ")", ":", "orders", "=", "{", "}", "# chunk list (only 25 auction_ids per request)", "for", "chunk", "in", "chunked", "(", "auction_ids", ",", "25", ")", ":", "# auctions = [{'item': auction_id} for auction_id in chun...
Return orders details.
[ "Return", "orders", "details", "." ]
c6d7090560cb9e579f7f769a9eec131a3db2c258
https://github.com/oczkers/pyllegro/blob/c6d7090560cb9e579f7f769a9eec131a3db2c258/pyllegro/core.py#L181-L217
240,179
oczkers/pyllegro
pyllegro/core.py
Allegro.getJournalDeals
def getJournalDeals(self, start=None): """Return all journal events from start.""" # 1 - utworzenie aktu zakupowego (deala), 2 - utworzenie formularza pozakupowego (karta platnosci), 3 - anulowanie formularza pozakupowego (karta platnosci), 4 - zakończenie (opłacenie) transakcji przez PzA if sta...
python
def getJournalDeals(self, start=None): """Return all journal events from start.""" # 1 - utworzenie aktu zakupowego (deala), 2 - utworzenie formularza pozakupowego (karta platnosci), 3 - anulowanie formularza pozakupowego (karta platnosci), 4 - zakończenie (opłacenie) transakcji przez PzA if sta...
[ "def", "getJournalDeals", "(", "self", ",", "start", "=", "None", ")", ":", "# 1 - utworzenie aktu zakupowego (deala), 2 - utworzenie formularza pozakupowego (karta platnosci), 3 - anulowanie formularza pozakupowego (karta platnosci), 4 - zakończenie (opłacenie) transakcji przez PzA", "if", ...
Return all journal events from start.
[ "Return", "all", "journal", "events", "from", "start", "." ]
c6d7090560cb9e579f7f769a9eec131a3db2c258
https://github.com/oczkers/pyllegro/blob/c6d7090560cb9e579f7f769a9eec131a3db2c258/pyllegro/core.py#L254-L275
240,180
oczkers/pyllegro
pyllegro/core.py
Allegro.getWaitingFeedbacks
def getWaitingFeedbacks(self): """Return all waiting feedbacks from buyers.""" # TODO: return sorted dictionary (negative/positive/neutral) feedbacks = [] offset = 0 amount = self.__ask__('doGetWaitingFeedbacksCount') while amount > 0: rc = self.__ask__('doGet...
python
def getWaitingFeedbacks(self): """Return all waiting feedbacks from buyers.""" # TODO: return sorted dictionary (negative/positive/neutral) feedbacks = [] offset = 0 amount = self.__ask__('doGetWaitingFeedbacksCount') while amount > 0: rc = self.__ask__('doGet...
[ "def", "getWaitingFeedbacks", "(", "self", ")", ":", "# TODO: return sorted dictionary (negative/positive/neutral)", "feedbacks", "=", "[", "]", "offset", "=", "0", "amount", "=", "self", ".", "__ask__", "(", "'doGetWaitingFeedbacksCount'", ")", "while", "amount", ">"...
Return all waiting feedbacks from buyers.
[ "Return", "all", "waiting", "feedbacks", "from", "buyers", "." ]
c6d7090560cb9e579f7f769a9eec131a3db2c258
https://github.com/oczkers/pyllegro/blob/c6d7090560cb9e579f7f769a9eec131a3db2c258/pyllegro/core.py#L278-L290
240,181
jeffrimko/Auxly
lib/auxly/shell.py
silent
def silent(cmd, **kwargs): """Calls the given shell command. Output will not be displayed. Returns the status code. **Examples**: :: auxly.shell.silent("ls") """ return call(cmd, shell=True, stdout=NULL, stderr=NULL, **kwargs)
python
def silent(cmd, **kwargs): """Calls the given shell command. Output will not be displayed. Returns the status code. **Examples**: :: auxly.shell.silent("ls") """ return call(cmd, shell=True, stdout=NULL, stderr=NULL, **kwargs)
[ "def", "silent", "(", "cmd", ",", "*", "*", "kwargs", ")", ":", "return", "call", "(", "cmd", ",", "shell", "=", "True", ",", "stdout", "=", "NULL", ",", "stderr", "=", "NULL", ",", "*", "*", "kwargs", ")" ]
Calls the given shell command. Output will not be displayed. Returns the status code. **Examples**: :: auxly.shell.silent("ls")
[ "Calls", "the", "given", "shell", "command", ".", "Output", "will", "not", "be", "displayed", ".", "Returns", "the", "status", "code", "." ]
5aae876bcb6ca117c81d904f9455764cdc78cd48
https://github.com/jeffrimko/Auxly/blob/5aae876bcb6ca117c81d904f9455764cdc78cd48/lib/auxly/shell.py#L32-L40
240,182
jeffrimko/Auxly
lib/auxly/shell.py
has
def has(cmd): """Returns true if the give shell command is available. **Examples**: :: auxly.shell.has("ls") # True """ helps = ["--help", "-h", "--version"] if "nt" == os.name: helps.insert(0, "/?") fakecmd = "fakecmd" cmderr = strerr(fakecmd).replace(fakecmd, cmd) ...
python
def has(cmd): """Returns true if the give shell command is available. **Examples**: :: auxly.shell.has("ls") # True """ helps = ["--help", "-h", "--version"] if "nt" == os.name: helps.insert(0, "/?") fakecmd = "fakecmd" cmderr = strerr(fakecmd).replace(fakecmd, cmd) ...
[ "def", "has", "(", "cmd", ")", ":", "helps", "=", "[", "\"--help\"", ",", "\"-h\"", ",", "\"--version\"", "]", "if", "\"nt\"", "==", "os", ".", "name", ":", "helps", ".", "insert", "(", "0", ",", "\"/?\"", ")", "fakecmd", "=", "\"fakecmd\"", "cmderr"...
Returns true if the give shell command is available. **Examples**: :: auxly.shell.has("ls") # True
[ "Returns", "true", "if", "the", "give", "shell", "command", "is", "available", "." ]
5aae876bcb6ca117c81d904f9455764cdc78cd48
https://github.com/jeffrimko/Auxly/blob/5aae876bcb6ca117c81d904f9455764cdc78cd48/lib/auxly/shell.py#L42-L62
240,183
mayfield/shellish
shellish/tools/csvpretty.py
csvpretty
def csvpretty(csvfile: csvfile=sys.stdin): """ Pretty print a CSV file. """ shellish.tabulate(csv.reader(csvfile))
python
def csvpretty(csvfile: csvfile=sys.stdin): """ Pretty print a CSV file. """ shellish.tabulate(csv.reader(csvfile))
[ "def", "csvpretty", "(", "csvfile", ":", "csvfile", "=", "sys", ".", "stdin", ")", ":", "shellish", ".", "tabulate", "(", "csv", ".", "reader", "(", "csvfile", ")", ")" ]
Pretty print a CSV file.
[ "Pretty", "print", "a", "CSV", "file", "." ]
df0f0e4612d138c34d8cb99b66ab5b8e47f1414a
https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/tools/csvpretty.py#L10-L12
240,184
jpscaletti/moar
moar/storage.py
Storage.get_key
def get_key(self, path, geometry, filters, options): """Generates the thumbnail's key from it's arguments. If the arguments doesn't change the key will not change """ seed = u' '.join([ str(path), str(geometry), str(filters), str(options), ...
python
def get_key(self, path, geometry, filters, options): """Generates the thumbnail's key from it's arguments. If the arguments doesn't change the key will not change """ seed = u' '.join([ str(path), str(geometry), str(filters), str(options), ...
[ "def", "get_key", "(", "self", ",", "path", ",", "geometry", ",", "filters", ",", "options", ")", ":", "seed", "=", "u' '", ".", "join", "(", "[", "str", "(", "path", ")", ",", "str", "(", "geometry", ")", ",", "str", "(", "filters", ")", ",", ...
Generates the thumbnail's key from it's arguments. If the arguments doesn't change the key will not change
[ "Generates", "the", "thumbnail", "s", "key", "from", "it", "s", "arguments", ".", "If", "the", "arguments", "doesn", "t", "change", "the", "key", "will", "not", "change" ]
22694e5671b6adaccc4c9c87db7bdd701d20e734
https://github.com/jpscaletti/moar/blob/22694e5671b6adaccc4c9c87db7bdd701d20e734/moar/storage.py#L33-L43
240,185
jpscaletti/moar
moar/storage.py
Storage.get_source
def get_source(self, path_or_url): """Returns the source image file descriptor. path_or_url: Path to the source image as an absolute path, a path relative to `self.base_path` or a URL beginning with `http[s]` """ if path_or_url.startswith(('http://', 'https://')...
python
def get_source(self, path_or_url): """Returns the source image file descriptor. path_or_url: Path to the source image as an absolute path, a path relative to `self.base_path` or a URL beginning with `http[s]` """ if path_or_url.startswith(('http://', 'https://')...
[ "def", "get_source", "(", "self", ",", "path_or_url", ")", ":", "if", "path_or_url", ".", "startswith", "(", "(", "'http://'", ",", "'https://'", ")", ")", ":", "try", ":", "return", "urlopen", "(", "path_or_url", ")", "except", "IOError", ":", "return", ...
Returns the source image file descriptor. path_or_url: Path to the source image as an absolute path, a path relative to `self.base_path` or a URL beginning with `http[s]`
[ "Returns", "the", "source", "image", "file", "descriptor", "." ]
22694e5671b6adaccc4c9c87db7bdd701d20e734
https://github.com/jpscaletti/moar/blob/22694e5671b6adaccc4c9c87db7bdd701d20e734/moar/storage.py#L45-L65
240,186
jpscaletti/moar
moar/storage.py
Storage.get_thumb
def get_thumb(self, path, key, format): """Get the stored thumbnail if exists. path: path of the source image key: key of the thumbnail format: thumbnail's file extension """ thumbpath = self.get_thumbpath(path, key, format) fu...
python
def get_thumb(self, path, key, format): """Get the stored thumbnail if exists. path: path of the source image key: key of the thumbnail format: thumbnail's file extension """ thumbpath = self.get_thumbpath(path, key, format) fu...
[ "def", "get_thumb", "(", "self", ",", "path", ",", "key", ",", "format", ")", ":", "thumbpath", "=", "self", ".", "get_thumbpath", "(", "path", ",", "key", ",", "format", ")", "fullpath", "=", "os", ".", "path", ".", "join", "(", "self", ".", "out_...
Get the stored thumbnail if exists. path: path of the source image key: key of the thumbnail format: thumbnail's file extension
[ "Get", "the", "stored", "thumbnail", "if", "exists", "." ]
22694e5671b6adaccc4c9c87db7bdd701d20e734
https://github.com/jpscaletti/moar/blob/22694e5671b6adaccc4c9c87db7bdd701d20e734/moar/storage.py#L67-L82
240,187
jpscaletti/moar
moar/storage.py
Storage.get_thumbpath
def get_thumbpath(self, path, key, format): """Return the relative path of the thumbnail. path: path of the source image key: key of the thumbnail format: thumbnail file extension """ relpath = os.path.dirname(path) thumbsdir =...
python
def get_thumbpath(self, path, key, format): """Return the relative path of the thumbnail. path: path of the source image key: key of the thumbnail format: thumbnail file extension """ relpath = os.path.dirname(path) thumbsdir =...
[ "def", "get_thumbpath", "(", "self", ",", "path", ",", "key", ",", "format", ")", ":", "relpath", "=", "os", ".", "path", ".", "dirname", "(", "path", ")", "thumbsdir", "=", "self", ".", "get_thumbsdir", "(", "path", ")", "name", ",", "_", "=", "os...
Return the relative path of the thumbnail. path: path of the source image key: key of the thumbnail format: thumbnail file extension
[ "Return", "the", "relative", "path", "of", "the", "thumbnail", "." ]
22694e5671b6adaccc4c9c87db7bdd701d20e734
https://github.com/jpscaletti/moar/blob/22694e5671b6adaccc4c9c87db7bdd701d20e734/moar/storage.py#L84-L98
240,188
jpscaletti/moar
moar/storage.py
Storage.save
def save(self, path, key, format, data): """Save a newly generated thumbnail. path: path of the source image key: key of the thumbnail format: thumbnail's file extension data: thumbnail's binary data """ thumbpath =...
python
def save(self, path, key, format, data): """Save a newly generated thumbnail. path: path of the source image key: key of the thumbnail format: thumbnail's file extension data: thumbnail's binary data """ thumbpath =...
[ "def", "save", "(", "self", ",", "path", ",", "key", ",", "format", ",", "data", ")", ":", "thumbpath", "=", "self", ".", "get_thumbpath", "(", "path", ",", "key", ",", "format", ")", "fullpath", "=", "os", ".", "path", ".", "join", "(", "self", ...
Save a newly generated thumbnail. path: path of the source image key: key of the thumbnail format: thumbnail's file extension data: thumbnail's binary data
[ "Save", "a", "newly", "generated", "thumbnail", "." ]
22694e5671b6adaccc4c9c87db7bdd701d20e734
https://github.com/jpscaletti/moar/blob/22694e5671b6adaccc4c9c87db7bdd701d20e734/moar/storage.py#L112-L129
240,189
Vito2015/pyextend
pyextend/core/log.py
add_handler
def add_handler(cls, level, fmt, colorful, **kwargs): """Add a configured handler to the global logger.""" global g_logger if isinstance(level, str): level = getattr(logging, level.upper(), logging.DEBUG) handler = cls(**kwargs) handler.setLevel(level) if colorful: formatte...
python
def add_handler(cls, level, fmt, colorful, **kwargs): """Add a configured handler to the global logger.""" global g_logger if isinstance(level, str): level = getattr(logging, level.upper(), logging.DEBUG) handler = cls(**kwargs) handler.setLevel(level) if colorful: formatte...
[ "def", "add_handler", "(", "cls", ",", "level", ",", "fmt", ",", "colorful", ",", "*", "*", "kwargs", ")", ":", "global", "g_logger", "if", "isinstance", "(", "level", ",", "str", ")", ":", "level", "=", "getattr", "(", "logging", ",", "level", ".", ...
Add a configured handler to the global logger.
[ "Add", "a", "configured", "handler", "to", "the", "global", "logger", "." ]
36861dfe1087e437ffe9b5a1da9345c85b4fa4a1
https://github.com/Vito2015/pyextend/blob/36861dfe1087e437ffe9b5a1da9345c85b4fa4a1/pyextend/core/log.py#L115-L133
240,190
Vito2015/pyextend
pyextend/core/log.py
add_filehandler
def add_filehandler(level, fmt, filename, mode, backup_count, limit, when): """Add a file handler to the global logger.""" kwargs = {} # If the filename is not set, use the default filename if filename is None: filename = getattr(sys.modules['__main__'], '__file__', 'log.py') filename ...
python
def add_filehandler(level, fmt, filename, mode, backup_count, limit, when): """Add a file handler to the global logger.""" kwargs = {} # If the filename is not set, use the default filename if filename is None: filename = getattr(sys.modules['__main__'], '__file__', 'log.py') filename ...
[ "def", "add_filehandler", "(", "level", ",", "fmt", ",", "filename", ",", "mode", ",", "backup_count", ",", "limit", ",", "when", ")", ":", "kwargs", "=", "{", "}", "# If the filename is not set, use the default filename", "if", "filename", "is", "None", ":", ...
Add a file handler to the global logger.
[ "Add", "a", "file", "handler", "to", "the", "global", "logger", "." ]
36861dfe1087e437ffe9b5a1da9345c85b4fa4a1
https://github.com/Vito2015/pyextend/blob/36861dfe1087e437ffe9b5a1da9345c85b4fa4a1/pyextend/core/log.py#L141-L171
240,191
Vito2015/pyextend
pyextend/core/log.py
init_logger
def init_logger(name=None): """Reload the global logger.""" global g_logger if g_logger is None: g_logger = logging.getLogger(name=name) else: logging.shutdown() g_logger.handlers = [] g_logger.setLevel(logging.DEBUG)
python
def init_logger(name=None): """Reload the global logger.""" global g_logger if g_logger is None: g_logger = logging.getLogger(name=name) else: logging.shutdown() g_logger.handlers = [] g_logger.setLevel(logging.DEBUG)
[ "def", "init_logger", "(", "name", "=", "None", ")", ":", "global", "g_logger", "if", "g_logger", "is", "None", ":", "g_logger", "=", "logging", ".", "getLogger", "(", "name", "=", "name", ")", "else", ":", "logging", ".", "shutdown", "(", ")", "g_logg...
Reload the global logger.
[ "Reload", "the", "global", "logger", "." ]
36861dfe1087e437ffe9b5a1da9345c85b4fa4a1
https://github.com/Vito2015/pyextend/blob/36861dfe1087e437ffe9b5a1da9345c85b4fa4a1/pyextend/core/log.py#L174-L184
240,192
Vito2015/pyextend
pyextend/core/log.py
set_logger
def set_logger(name=None, filename=None, mode='a', level='NOTSET:NOTSET', fmt= '%(asctime)s %(filename)s:%(lineno)d [PID:%(process)-5d THD:%(thread)-5d %(levelname)-7s] %(message)s', # fmt='[%(levelname)s] %(asctime)s %(message)s', backup_count=5, limit=20480,...
python
def set_logger(name=None, filename=None, mode='a', level='NOTSET:NOTSET', fmt= '%(asctime)s %(filename)s:%(lineno)d [PID:%(process)-5d THD:%(thread)-5d %(levelname)-7s] %(message)s', # fmt='[%(levelname)s] %(asctime)s %(message)s', backup_count=5, limit=20480,...
[ "def", "set_logger", "(", "name", "=", "None", ",", "filename", "=", "None", ",", "mode", "=", "'a'", ",", "level", "=", "'NOTSET:NOTSET'", ",", "fmt", "=", "'%(asctime)s %(filename)s:%(lineno)d [PID:%(process)-5d THD:%(thread)-5d %(levelname)-7s] %(message)s'", ",", "#...
Configure the global logger.
[ "Configure", "the", "global", "logger", "." ]
36861dfe1087e437ffe9b5a1da9345c85b4fa4a1
https://github.com/Vito2015/pyextend/blob/36861dfe1087e437ffe9b5a1da9345c85b4fa4a1/pyextend/core/log.py#L192-L212
240,193
Vito2015/pyextend
pyextend/core/log.py
import_log_funcs
def import_log_funcs(): """Import the common log functions from the global logger to the module.""" global g_logger curr_mod = sys.modules[__name__] for func_name in _logging_funcs: func = getattr(g_logger, func_name) setattr(curr_mod, func_name, func)
python
def import_log_funcs(): """Import the common log functions from the global logger to the module.""" global g_logger curr_mod = sys.modules[__name__] for func_name in _logging_funcs: func = getattr(g_logger, func_name) setattr(curr_mod, func_name, func)
[ "def", "import_log_funcs", "(", ")", ":", "global", "g_logger", "curr_mod", "=", "sys", ".", "modules", "[", "__name__", "]", "for", "func_name", "in", "_logging_funcs", ":", "func", "=", "getattr", "(", "g_logger", ",", "func_name", ")", "setattr", "(", "...
Import the common log functions from the global logger to the module.
[ "Import", "the", "common", "log", "functions", "from", "the", "global", "logger", "to", "the", "module", "." ]
36861dfe1087e437ffe9b5a1da9345c85b4fa4a1
https://github.com/Vito2015/pyextend/blob/36861dfe1087e437ffe9b5a1da9345c85b4fa4a1/pyextend/core/log.py#L215-L223
240,194
lvh/maxims
maxims/indirection.py
powerupIndirector
def powerupIndirector(interface): """ A decorator for a powerup indirector from a single interface to a single in-memory implementation. The in-memory implementation that is being indirected to must be created in the ``activate`` callback, and then assigned to ``self.indirected``, which is an `...
python
def powerupIndirector(interface): """ A decorator for a powerup indirector from a single interface to a single in-memory implementation. The in-memory implementation that is being indirected to must be created in the ``activate`` callback, and then assigned to ``self.indirected``, which is an `...
[ "def", "powerupIndirector", "(", "interface", ")", ":", "def", "decorator", "(", "cls", ")", ":", "zi", ".", "implementer", "(", "iaxiom", ".", "IPowerupIndirector", ")", "(", "cls", ")", "cls", ".", "powerupInterfaces", "=", "[", "interface", "]", "cls", ...
A decorator for a powerup indirector from a single interface to a single in-memory implementation. The in-memory implementation that is being indirected to must be created in the ``activate`` callback, and then assigned to ``self.indirected``, which is an ``inmemory`` attribute.
[ "A", "decorator", "for", "a", "powerup", "indirector", "from", "a", "single", "interface", "to", "a", "single", "in", "-", "memory", "implementation", "." ]
5c53b25d2cc4ccecbfe90193ade9ce0dbfbe4623
https://github.com/lvh/maxims/blob/5c53b25d2cc4ccecbfe90193ade9ce0dbfbe4623/maxims/indirection.py#L8-L23
240,195
pavelsof/ipalint
ipalint/core.py
Core.lint
def lint(self, dataset=None, col=None, no_header=False, ignore_nfd=False, ignore_ws=False, linewise=False, no_lines=False): """ Returns a string containing all the issues found in the dataset defined by the given file path. """ reader = Reader(dataset, has_header=not no_header, ipa_col=col) recog = Rec...
python
def lint(self, dataset=None, col=None, no_header=False, ignore_nfd=False, ignore_ws=False, linewise=False, no_lines=False): """ Returns a string containing all the issues found in the dataset defined by the given file path. """ reader = Reader(dataset, has_header=not no_header, ipa_col=col) recog = Rec...
[ "def", "lint", "(", "self", ",", "dataset", "=", "None", ",", "col", "=", "None", ",", "no_header", "=", "False", ",", "ignore_nfd", "=", "False", ",", "ignore_ws", "=", "False", ",", "linewise", "=", "False", ",", "no_lines", "=", "False", ")", ":",...
Returns a string containing all the issues found in the dataset defined by the given file path.
[ "Returns", "a", "string", "containing", "all", "the", "issues", "found", "in", "the", "dataset", "defined", "by", "the", "given", "file", "path", "." ]
763e5979ede6980cbfc746b06fd007b379762eeb
https://github.com/pavelsof/ipalint/blob/763e5979ede6980cbfc746b06fd007b379762eeb/ipalint/core.py#L58-L77
240,196
Naught0/lolrune
lolrune/utils.py
parse_rune_links
def parse_rune_links(html: str) -> dict: """A function which parses the main Runeforge website into dict format. Parameters ---------- html : str The string representation of the html obtained via a GET request. Returns ------- dict The nested rune_links champ rune pages fr...
python
def parse_rune_links(html: str) -> dict: """A function which parses the main Runeforge website into dict format. Parameters ---------- html : str The string representation of the html obtained via a GET request. Returns ------- dict The nested rune_links champ rune pages fr...
[ "def", "parse_rune_links", "(", "html", ":", "str", ")", "->", "dict", ":", "soup", "=", "BeautifulSoup", "(", "html", ",", "'lxml'", ")", "# Champs with only a single runepage", "single_page_raw", "=", "soup", ".", "find_all", "(", "'li'", ",", "class_", "=",...
A function which parses the main Runeforge website into dict format. Parameters ---------- html : str The string representation of the html obtained via a GET request. Returns ------- dict The nested rune_links champ rune pages from runeforge.
[ "A", "function", "which", "parses", "the", "main", "Runeforge", "website", "into", "dict", "format", "." ]
99f67b9137e42a78198ba369ceb371e473759f11
https://github.com/Naught0/lolrune/blob/99f67b9137e42a78198ba369ceb371e473759f11/lolrune/utils.py#L7-L39
240,197
fdb/aufmachen
aufmachen/websites/immoweb.py
find_string
def find_string(regex, s): """Find a string using a given regular expression. If the string cannot be found, returns None. The regex should contain one matching group, as only the result of the first group is returned. s - The string to search. regex - A string containing the regular expressi...
python
def find_string(regex, s): """Find a string using a given regular expression. If the string cannot be found, returns None. The regex should contain one matching group, as only the result of the first group is returned. s - The string to search. regex - A string containing the regular expressi...
[ "def", "find_string", "(", "regex", ",", "s", ")", ":", "m", "=", "re", ".", "search", "(", "regex", ",", "s", ")", "if", "m", "is", "None", ":", "return", "None", "return", "m", ".", "groups", "(", ")", "[", "0", "]" ]
Find a string using a given regular expression. If the string cannot be found, returns None. The regex should contain one matching group, as only the result of the first group is returned. s - The string to search. regex - A string containing the regular expression. Returns a unicode str...
[ "Find", "a", "string", "using", "a", "given", "regular", "expression", ".", "If", "the", "string", "cannot", "be", "found", "returns", "None", ".", "The", "regex", "should", "contain", "one", "matching", "group", "as", "only", "the", "result", "of", "the",...
f2986a0cf087ac53969f82b84d872e3f1c6986f4
https://github.com/fdb/aufmachen/blob/f2986a0cf087ac53969f82b84d872e3f1c6986f4/aufmachen/websites/immoweb.py#L99-L113
240,198
fdb/aufmachen
aufmachen/websites/immoweb.py
clean_text
def clean_text(s): """Removes all cruft from the text.""" SPACES_RE = re.compile(r'\s+') SPECIAL_CHARS_RE = re.compile(r'[^\w\s\.\-\(\)]') s = SPACES_RE.sub(' ', s) s = s.strip() s = SPECIAL_CHARS_RE.sub('', s) return s
python
def clean_text(s): """Removes all cruft from the text.""" SPACES_RE = re.compile(r'\s+') SPECIAL_CHARS_RE = re.compile(r'[^\w\s\.\-\(\)]') s = SPACES_RE.sub(' ', s) s = s.strip() s = SPECIAL_CHARS_RE.sub('', s) return s
[ "def", "clean_text", "(", "s", ")", ":", "SPACES_RE", "=", "re", ".", "compile", "(", "r'\\s+'", ")", "SPECIAL_CHARS_RE", "=", "re", ".", "compile", "(", "r'[^\\w\\s\\.\\-\\(\\)]'", ")", "s", "=", "SPACES_RE", ".", "sub", "(", "' '", ",", "s", ")", "s"...
Removes all cruft from the text.
[ "Removes", "all", "cruft", "from", "the", "text", "." ]
f2986a0cf087ac53969f82b84d872e3f1c6986f4
https://github.com/fdb/aufmachen/blob/f2986a0cf087ac53969f82b84d872e3f1c6986f4/aufmachen/websites/immoweb.py#L154-L161
240,199
fdb/aufmachen
aufmachen/websites/immoweb.py
parse_immoweb_link
def parse_immoweb_link(url): """Parses an Immoweb estate detail URL and returns the Immoweb estate id. Returns a string with the Immoweb estate id. """ IMMOWEB_ID_RE = re.compile(r'.*?IdBien=([0-9]+).*?') return IMMOWEB_ID_RE.match(url).groups()[0]
python
def parse_immoweb_link(url): """Parses an Immoweb estate detail URL and returns the Immoweb estate id. Returns a string with the Immoweb estate id. """ IMMOWEB_ID_RE = re.compile(r'.*?IdBien=([0-9]+).*?') return IMMOWEB_ID_RE.match(url).groups()[0]
[ "def", "parse_immoweb_link", "(", "url", ")", ":", "IMMOWEB_ID_RE", "=", "re", ".", "compile", "(", "r'.*?IdBien=([0-9]+).*?'", ")", "return", "IMMOWEB_ID_RE", ".", "match", "(", "url", ")", ".", "groups", "(", ")", "[", "0", "]" ]
Parses an Immoweb estate detail URL and returns the Immoweb estate id. Returns a string with the Immoweb estate id.
[ "Parses", "an", "Immoweb", "estate", "detail", "URL", "and", "returns", "the", "Immoweb", "estate", "id", "." ]
f2986a0cf087ac53969f82b84d872e3f1c6986f4
https://github.com/fdb/aufmachen/blob/f2986a0cf087ac53969f82b84d872e3f1c6986f4/aufmachen/websites/immoweb.py#L163-L169