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
251,700
florianpaquet/mease
mease/registry.py
Mease._get_registry_names
def _get_registry_names(self, registry): """ Returns functions names for a registry """ return ', '.join( f.__name__ if not isinstance(f, tuple) else f[0].__name__ for f in getattr(self, registry, []))
python
def _get_registry_names(self, registry): """ Returns functions names for a registry """ return ', '.join( f.__name__ if not isinstance(f, tuple) else f[0].__name__ for f in getattr(self, registry, []))
[ "def", "_get_registry_names", "(", "self", ",", "registry", ")", ":", "return", "', '", ".", "join", "(", "f", ".", "__name__", "if", "not", "isinstance", "(", "f", ",", "tuple", ")", "else", "f", "[", "0", "]", ".", "__name__", "for", "f", "in", "...
Returns functions names for a registry
[ "Returns", "functions", "names", "for", "a", "registry" ]
b9fbd08bbe162c8890c2a2124674371170c319ef
https://github.com/florianpaquet/mease/blob/b9fbd08bbe162c8890c2a2124674371170c319ef/mease/registry.py#L33-L39
251,701
florianpaquet/mease
mease/registry.py
Mease.receiver
def receiver(self, func=None, json=False): """ Registers a receiver function """ self.receivers.append((func, json))
python
def receiver(self, func=None, json=False): """ Registers a receiver function """ self.receivers.append((func, json))
[ "def", "receiver", "(", "self", ",", "func", "=", "None", ",", "json", "=", "False", ")", ":", "self", ".", "receivers", ".", "append", "(", "(", "func", ",", "json", ")", ")" ]
Registers a receiver function
[ "Registers", "a", "receiver", "function" ]
b9fbd08bbe162c8890c2a2124674371170c319ef
https://github.com/florianpaquet/mease/blob/b9fbd08bbe162c8890c2a2124674371170c319ef/mease/registry.py#L58-L62
251,702
florianpaquet/mease
mease/registry.py
Mease.sender
def sender(self, func, routing=None, routing_re=None): """ Registers a sender function """ if routing and not isinstance(routing, list): routing = [routing] if routing_re: if not isinstance(routing_re, list): routing_re = [routing_re] ...
python
def sender(self, func, routing=None, routing_re=None): """ Registers a sender function """ if routing and not isinstance(routing, list): routing = [routing] if routing_re: if not isinstance(routing_re, list): routing_re = [routing_re] ...
[ "def", "sender", "(", "self", ",", "func", ",", "routing", "=", "None", ",", "routing_re", "=", "None", ")", ":", "if", "routing", "and", "not", "isinstance", "(", "routing", ",", "list", ")", ":", "routing", "=", "[", "routing", "]", "if", "routing_...
Registers a sender function
[ "Registers", "a", "sender", "function" ]
b9fbd08bbe162c8890c2a2124674371170c319ef
https://github.com/florianpaquet/mease/blob/b9fbd08bbe162c8890c2a2124674371170c319ef/mease/registry.py#L65-L77
251,703
florianpaquet/mease
mease/registry.py
Mease.call_openers
def call_openers(self, client, clients_list): """ Calls openers callbacks """ for func in self.openers: func(client, clients_list)
python
def call_openers(self, client, clients_list): """ Calls openers callbacks """ for func in self.openers: func(client, clients_list)
[ "def", "call_openers", "(", "self", ",", "client", ",", "clients_list", ")", ":", "for", "func", "in", "self", ".", "openers", ":", "func", "(", "client", ",", "clients_list", ")" ]
Calls openers callbacks
[ "Calls", "openers", "callbacks" ]
b9fbd08bbe162c8890c2a2124674371170c319ef
https://github.com/florianpaquet/mease/blob/b9fbd08bbe162c8890c2a2124674371170c319ef/mease/registry.py#L81-L86
251,704
florianpaquet/mease
mease/registry.py
Mease.call_closers
def call_closers(self, client, clients_list): """ Calls closers callbacks """ for func in self.closers: func(client, clients_list)
python
def call_closers(self, client, clients_list): """ Calls closers callbacks """ for func in self.closers: func(client, clients_list)
[ "def", "call_closers", "(", "self", ",", "client", ",", "clients_list", ")", ":", "for", "func", "in", "self", ".", "closers", ":", "func", "(", "client", ",", "clients_list", ")" ]
Calls closers callbacks
[ "Calls", "closers", "callbacks" ]
b9fbd08bbe162c8890c2a2124674371170c319ef
https://github.com/florianpaquet/mease/blob/b9fbd08bbe162c8890c2a2124674371170c319ef/mease/registry.py#L88-L93
251,705
florianpaquet/mease
mease/registry.py
Mease.call_receivers
def call_receivers(self, client, clients_list, message): """ Calls receivers callbacks """ # Try to parse JSON try: json_message = json.loads(message) except ValueError: json_message = None for func, to_json in self.receivers: ...
python
def call_receivers(self, client, clients_list, message): """ Calls receivers callbacks """ # Try to parse JSON try: json_message = json.loads(message) except ValueError: json_message = None for func, to_json in self.receivers: ...
[ "def", "call_receivers", "(", "self", ",", "client", ",", "clients_list", ",", "message", ")", ":", "# Try to parse JSON", "try", ":", "json_message", "=", "json", ".", "loads", "(", "message", ")", "except", "ValueError", ":", "json_message", "=", "None", "...
Calls receivers callbacks
[ "Calls", "receivers", "callbacks" ]
b9fbd08bbe162c8890c2a2124674371170c319ef
https://github.com/florianpaquet/mease/blob/b9fbd08bbe162c8890c2a2124674371170c319ef/mease/registry.py#L95-L116
251,706
florianpaquet/mease
mease/registry.py
Mease.call_senders
def call_senders(self, routing, clients_list, *args, **kwargs): """ Calls senders callbacks """ for func, routings, routings_re in self.senders: call_callback = False # Message is published globally if routing is None or (routings is None and routings...
python
def call_senders(self, routing, clients_list, *args, **kwargs): """ Calls senders callbacks """ for func, routings, routings_re in self.senders: call_callback = False # Message is published globally if routing is None or (routings is None and routings...
[ "def", "call_senders", "(", "self", ",", "routing", ",", "clients_list", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "func", ",", "routings", ",", "routings_re", "in", "self", ".", "senders", ":", "call_callback", "=", "False", "# Message...
Calls senders callbacks
[ "Calls", "senders", "callbacks" ]
b9fbd08bbe162c8890c2a2124674371170c319ef
https://github.com/florianpaquet/mease/blob/b9fbd08bbe162c8890c2a2124674371170c319ef/mease/registry.py#L118-L141
251,707
florianpaquet/mease
mease/registry.py
Mease.run_websocket_server
def run_websocket_server(self, host='localhost', port=9090, debug=False): """ Runs websocket server """ from .server import MeaseWebSocketServerFactory websocket_factory = MeaseWebSocketServerFactory( mease=self, host=host, port=port, debug=debug) websocket_f...
python
def run_websocket_server(self, host='localhost', port=9090, debug=False): """ Runs websocket server """ from .server import MeaseWebSocketServerFactory websocket_factory = MeaseWebSocketServerFactory( mease=self, host=host, port=port, debug=debug) websocket_f...
[ "def", "run_websocket_server", "(", "self", ",", "host", "=", "'localhost'", ",", "port", "=", "9090", ",", "debug", "=", "False", ")", ":", "from", ".", "server", "import", "MeaseWebSocketServerFactory", "websocket_factory", "=", "MeaseWebSocketServerFactory", "(...
Runs websocket server
[ "Runs", "websocket", "server" ]
b9fbd08bbe162c8890c2a2124674371170c319ef
https://github.com/florianpaquet/mease/blob/b9fbd08bbe162c8890c2a2124674371170c319ef/mease/registry.py#L155-L163
251,708
drcloud/stackclimber
stackclimber.py
stackclimber
def stackclimber(height=0): # http://stackoverflow.com/a/900404/48251 """ Obtain the name of the caller's module. Uses the inspect module to find the caller's position in the module hierarchy. With the optional height argument, finds the caller's caller, and so forth. """ caller = insp...
python
def stackclimber(height=0): # http://stackoverflow.com/a/900404/48251 """ Obtain the name of the caller's module. Uses the inspect module to find the caller's position in the module hierarchy. With the optional height argument, finds the caller's caller, and so forth. """ caller = insp...
[ "def", "stackclimber", "(", "height", "=", "0", ")", ":", "# http://stackoverflow.com/a/900404/48251", "caller", "=", "inspect", ".", "stack", "(", ")", "[", "height", "+", "1", "]", "scope", "=", "caller", "[", "0", "]", ".", "f_globals", "path", "=", "...
Obtain the name of the caller's module. Uses the inspect module to find the caller's position in the module hierarchy. With the optional height argument, finds the caller's caller, and so forth.
[ "Obtain", "the", "name", "of", "the", "caller", "s", "module", ".", "Uses", "the", "inspect", "module", "to", "find", "the", "caller", "s", "position", "in", "the", "module", "hierarchy", ".", "With", "the", "optional", "height", "argument", "finds", "the"...
595b66474171bc5fe08e7361622953c309d00ae5
https://github.com/drcloud/stackclimber/blob/595b66474171bc5fe08e7361622953c309d00ae5/stackclimber.py#L6-L20
251,709
EventTeam/beliefs
src/beliefs/belief_utils.py
flatten_list
def flatten_list(l): """ Nested lists to single-level list, does not split strings""" return list(chain.from_iterable(repeat(x,1) if isinstance(x,str) else x for x in l))
python
def flatten_list(l): """ Nested lists to single-level list, does not split strings""" return list(chain.from_iterable(repeat(x,1) if isinstance(x,str) else x for x in l))
[ "def", "flatten_list", "(", "l", ")", ":", "return", "list", "(", "chain", ".", "from_iterable", "(", "repeat", "(", "x", ",", "1", ")", "if", "isinstance", "(", "x", ",", "str", ")", "else", "x", "for", "x", "in", "l", ")", ")" ]
Nested lists to single-level list, does not split strings
[ "Nested", "lists", "to", "single", "-", "level", "list", "does", "not", "split", "strings" ]
c07d22b61bebeede74a72800030dde770bf64208
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/belief_utils.py#L55-L57
251,710
EventTeam/beliefs
src/beliefs/belief_utils.py
list_diff
def list_diff(list1, list2): """ Ssymetric list difference """ diff_list = [] for item in list1: if not item in list2: diff_list.append(item) for item in list2: if not item in list1: diff_list.append(item) return diff_list
python
def list_diff(list1, list2): """ Ssymetric list difference """ diff_list = [] for item in list1: if not item in list2: diff_list.append(item) for item in list2: if not item in list1: diff_list.append(item) return diff_list
[ "def", "list_diff", "(", "list1", ",", "list2", ")", ":", "diff_list", "=", "[", "]", "for", "item", "in", "list1", ":", "if", "not", "item", "in", "list2", ":", "diff_list", ".", "append", "(", "item", ")", "for", "item", "in", "list2", ":", "if",...
Ssymetric list difference
[ "Ssymetric", "list", "difference" ]
c07d22b61bebeede74a72800030dde770bf64208
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/belief_utils.py#L59-L68
251,711
EventTeam/beliefs
src/beliefs/belief_utils.py
asym_list_diff
def asym_list_diff(list1, list2): """ Asymmetric list difference """ diff_list = [] for item in list1: if not item in list2: diff_list.append(item) return diff_list
python
def asym_list_diff(list1, list2): """ Asymmetric list difference """ diff_list = [] for item in list1: if not item in list2: diff_list.append(item) return diff_list
[ "def", "asym_list_diff", "(", "list1", ",", "list2", ")", ":", "diff_list", "=", "[", "]", "for", "item", "in", "list1", ":", "if", "not", "item", "in", "list2", ":", "diff_list", ".", "append", "(", "item", ")", "return", "diff_list" ]
Asymmetric list difference
[ "Asymmetric", "list", "difference" ]
c07d22b61bebeede74a72800030dde770bf64208
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/belief_utils.py#L70-L76
251,712
EventTeam/beliefs
src/beliefs/belief_utils.py
next_tokens_in_sequence
def next_tokens_in_sequence(observed, current): """ Given the observed list of tokens, and the current list, finds out what should be next next emitted word """ idx = 0 for word in current: if observed[idx:].count(word) != 0: found_pos = observed.index(word, idx) idx ...
python
def next_tokens_in_sequence(observed, current): """ Given the observed list of tokens, and the current list, finds out what should be next next emitted word """ idx = 0 for word in current: if observed[idx:].count(word) != 0: found_pos = observed.index(word, idx) idx ...
[ "def", "next_tokens_in_sequence", "(", "observed", ",", "current", ")", ":", "idx", "=", "0", "for", "word", "in", "current", ":", "if", "observed", "[", "idx", ":", "]", ".", "count", "(", "word", ")", "!=", "0", ":", "found_pos", "=", "observed", "...
Given the observed list of tokens, and the current list, finds out what should be next next emitted word
[ "Given", "the", "observed", "list", "of", "tokens", "and", "the", "current", "list", "finds", "out", "what", "should", "be", "next", "next", "emitted", "word" ]
c07d22b61bebeede74a72800030dde770bf64208
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/belief_utils.py#L148-L161
251,713
EventTeam/beliefs
src/beliefs/cells/numeric.py
IntervalCell.to_latex
def to_latex(self): """ Returns an interval representation """ if self.low == self.high: if self.low * 10 % 10 == 0: return "{0:d}".format(int(self.low)) else: return "{0:0.2f}".format(self.low) else: t = "" if self....
python
def to_latex(self): """ Returns an interval representation """ if self.low == self.high: if self.low * 10 % 10 == 0: return "{0:d}".format(int(self.low)) else: return "{0:0.2f}".format(self.low) else: t = "" if self....
[ "def", "to_latex", "(", "self", ")", ":", "if", "self", ".", "low", "==", "self", ".", "high", ":", "if", "self", ".", "low", "*", "10", "%", "10", "==", "0", ":", "return", "\"{0:d}\"", ".", "format", "(", "int", "(", "self", ".", "low", ")", ...
Returns an interval representation
[ "Returns", "an", "interval", "representation" ]
c07d22b61bebeede74a72800030dde770bf64208
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/numeric.py#L244-L265
251,714
oubiga/respect
respect/main.py
main
def main(): """ Main entry point for the `respect` command. """ args = parse_respect_args(sys.argv[1:]) if validate_username(args['<username>']): print("processing...") else: print("@"+args['<username>'], "is not a valid username.") print("Username may only contain alpha...
python
def main(): """ Main entry point for the `respect` command. """ args = parse_respect_args(sys.argv[1:]) if validate_username(args['<username>']): print("processing...") else: print("@"+args['<username>'], "is not a valid username.") print("Username may only contain alpha...
[ "def", "main", "(", ")", ":", "args", "=", "parse_respect_args", "(", "sys", ".", "argv", "[", "1", ":", "]", ")", "if", "validate_username", "(", "args", "[", "'<username>'", "]", ")", ":", "print", "(", "\"processing...\"", ")", "else", ":", "print",...
Main entry point for the `respect` command.
[ "Main", "entry", "point", "for", "the", "respect", "command", "." ]
550554ec4d3139379d03cb8f82a8cd2d80c3ad62
https://github.com/oubiga/respect/blob/550554ec4d3139379d03cb8f82a8cd2d80c3ad62/respect/main.py#L56-L82
251,715
polysquare/polysquare-generic-file-linter
polysquarelinter/spelling.py
clear_caches
def clear_caches(): # suppress(unused-function) """Clear all caches.""" for _, reader in _spellchecker_cache.values(): reader.close() _spellchecker_cache.clear() _valid_words_cache.clear() _user_dictionary_cache.clear()
python
def clear_caches(): # suppress(unused-function) """Clear all caches.""" for _, reader in _spellchecker_cache.values(): reader.close() _spellchecker_cache.clear() _valid_words_cache.clear() _user_dictionary_cache.clear()
[ "def", "clear_caches", "(", ")", ":", "# suppress(unused-function)", "for", "_", ",", "reader", "in", "_spellchecker_cache", ".", "values", "(", ")", ":", "reader", ".", "close", "(", ")", "_spellchecker_cache", ".", "clear", "(", ")", "_valid_words_cache", "....
Clear all caches.
[ "Clear", "all", "caches", "." ]
cfc88771acd3d5551c28fa5d917bb0aeb584c4cc
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L61-L68
251,716
polysquare/polysquare-generic-file-linter
polysquarelinter/spelling.py
_comment_system_for_file
def _comment_system_for_file(contents): """For file contents, return the comment system.""" if contents[0] == "#": return FileCommentSystem(begin="#", middle="", end="", single="#") elif contents[:2] == "/*": return FileCommentSystem(begin="/*", middle="*", end="*/", single="//") elif co...
python
def _comment_system_for_file(contents): """For file contents, return the comment system.""" if contents[0] == "#": return FileCommentSystem(begin="#", middle="", end="", single="#") elif contents[:2] == "/*": return FileCommentSystem(begin="/*", middle="*", end="*/", single="//") elif co...
[ "def", "_comment_system_for_file", "(", "contents", ")", ":", "if", "contents", "[", "0", "]", "==", "\"#\"", ":", "return", "FileCommentSystem", "(", "begin", "=", "\"#\"", ",", "middle", "=", "\"\"", ",", "end", "=", "\"\"", ",", "single", "=", "\"#\""...
For file contents, return the comment system.
[ "For", "file", "contents", "return", "the", "comment", "system", "." ]
cfc88771acd3d5551c28fa5d917bb0aeb584c4cc
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L74-L89
251,717
polysquare/polysquare-generic-file-linter
polysquarelinter/spelling.py
_split_line_with_offsets
def _split_line_with_offsets(line): """Split a line by delimiter, but yield tuples of word and offset. This function works by dropping all the english-like punctuation from a line (so parenthesis preceded or succeeded by spaces, periods, etc) and then splitting on spaces. """ for delimiter in r...
python
def _split_line_with_offsets(line): """Split a line by delimiter, but yield tuples of word and offset. This function works by dropping all the english-like punctuation from a line (so parenthesis preceded or succeeded by spaces, periods, etc) and then splitting on spaces. """ for delimiter in r...
[ "def", "_split_line_with_offsets", "(", "line", ")", ":", "for", "delimiter", "in", "re", ".", "finditer", "(", "r\"[\\.,:\\;](?![^\\s])\"", ",", "line", ")", ":", "span", "=", "delimiter", ".", "span", "(", ")", "line", "=", "line", "[", ":", "span", "[...
Split a line by delimiter, but yield tuples of word and offset. This function works by dropping all the english-like punctuation from a line (so parenthesis preceded or succeeded by spaces, periods, etc) and then splitting on spaces.
[ "Split", "a", "line", "by", "delimiter", "but", "yield", "tuples", "of", "word", "and", "offset", "." ]
cfc88771acd3d5551c28fa5d917bb0aeb584c4cc
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L129-L159
251,718
polysquare/polysquare-generic-file-linter
polysquarelinter/spelling.py
read_dictionary_file
def read_dictionary_file(dictionary_path): """Return all words in dictionary file as set.""" try: return _user_dictionary_cache[dictionary_path] except KeyError: if dictionary_path and os.path.exists(dictionary_path): with open(dictionary_path, "rt") as dict_f: wo...
python
def read_dictionary_file(dictionary_path): """Return all words in dictionary file as set.""" try: return _user_dictionary_cache[dictionary_path] except KeyError: if dictionary_path and os.path.exists(dictionary_path): with open(dictionary_path, "rt") as dict_f: wo...
[ "def", "read_dictionary_file", "(", "dictionary_path", ")", ":", "try", ":", "return", "_user_dictionary_cache", "[", "dictionary_path", "]", "except", "KeyError", ":", "if", "dictionary_path", "and", "os", ".", "path", ".", "exists", "(", "dictionary_path", ")", ...
Return all words in dictionary file as set.
[ "Return", "all", "words", "in", "dictionary", "file", "as", "set", "." ]
cfc88771acd3d5551c28fa5d917bb0aeb584c4cc
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L162-L173
251,719
polysquare/polysquare-generic-file-linter
polysquarelinter/spelling.py
valid_words_set
def valid_words_set(path_to_user_dictionary=None, user_dictionary_words=None): """Get a set of valid words. If :path_to_user_dictionary: is specified, then the newline-separated words in that file will be added to the word set. """ def read_file(binary_file): """Read a b...
python
def valid_words_set(path_to_user_dictionary=None, user_dictionary_words=None): """Get a set of valid words. If :path_to_user_dictionary: is specified, then the newline-separated words in that file will be added to the word set. """ def read_file(binary_file): """Read a b...
[ "def", "valid_words_set", "(", "path_to_user_dictionary", "=", "None", ",", "user_dictionary_words", "=", "None", ")", ":", "def", "read_file", "(", "binary_file", ")", ":", "\"\"\"Read a binary file for its text lines.\"\"\"", "return", "binary_file", ".", "read", "(",...
Get a set of valid words. If :path_to_user_dictionary: is specified, then the newline-separated words in that file will be added to the word set.
[ "Get", "a", "set", "of", "valid", "words", "." ]
cfc88771acd3d5551c28fa5d917bb0aeb584c4cc
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L176-L203
251,720
polysquare/polysquare-generic-file-linter
polysquarelinter/spelling.py
_create_word_graph_file
def _create_word_graph_file(name, file_storage, word_set): """Create a word graph file and open it in memory.""" word_graph_file = file_storage.create_file(name) spelling.wordlist_to_graph_file(sorted(list(word_set)), word_graph_file) return copy_to_ram(file_storage)....
python
def _create_word_graph_file(name, file_storage, word_set): """Create a word graph file and open it in memory.""" word_graph_file = file_storage.create_file(name) spelling.wordlist_to_graph_file(sorted(list(word_set)), word_graph_file) return copy_to_ram(file_storage)....
[ "def", "_create_word_graph_file", "(", "name", ",", "file_storage", ",", "word_set", ")", ":", "word_graph_file", "=", "file_storage", ".", "create_file", "(", "name", ")", "spelling", ".", "wordlist_to_graph_file", "(", "sorted", "(", "list", "(", "word_set", "...
Create a word graph file and open it in memory.
[ "Create", "a", "word", "graph", "file", "and", "open", "it", "in", "memory", "." ]
cfc88771acd3d5551c28fa5d917bb0aeb584c4cc
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L211-L216
251,721
polysquare/polysquare-generic-file-linter
polysquarelinter/spelling.py
filter_nonspellcheckable_tokens
def filter_nonspellcheckable_tokens(line, block_out_regexes=None): """Return line with paths, urls and emails filtered out. Block out other strings of text matching :block_out_regexes: if passed in. """ all_block_out_regexes = [ r"[^\s]*:[^\s]*[/\\][^\s]*", r"[^\s]*[/\\][^\s]*", ...
python
def filter_nonspellcheckable_tokens(line, block_out_regexes=None): """Return line with paths, urls and emails filtered out. Block out other strings of text matching :block_out_regexes: if passed in. """ all_block_out_regexes = [ r"[^\s]*:[^\s]*[/\\][^\s]*", r"[^\s]*[/\\][^\s]*", ...
[ "def", "filter_nonspellcheckable_tokens", "(", "line", ",", "block_out_regexes", "=", "None", ")", ":", "all_block_out_regexes", "=", "[", "r\"[^\\s]*:[^\\s]*[/\\\\][^\\s]*\"", ",", "r\"[^\\s]*[/\\\\][^\\s]*\"", ",", "r\"\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]+\\b\"", "]",...
Return line with paths, urls and emails filtered out. Block out other strings of text matching :block_out_regexes: if passed in.
[ "Return", "line", "with", "paths", "urls", "and", "emails", "filtered", "out", "." ]
cfc88771acd3d5551c28fa5d917bb0aeb584c4cc
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L285-L301
251,722
polysquare/polysquare-generic-file-linter
polysquarelinter/spelling.py
_chunk_from_ranges
def _chunk_from_ranges(contents_lines, start_line_index, start_column_index, end_line_index, end_column_index): """Create a _ChunkInfo from a range of lines and columns. :contents_lines: is the raw lines of a file. ...
python
def _chunk_from_ranges(contents_lines, start_line_index, start_column_index, end_line_index, end_column_index): """Create a _ChunkInfo from a range of lines and columns. :contents_lines: is the raw lines of a file. ...
[ "def", "_chunk_from_ranges", "(", "contents_lines", ",", "start_line_index", ",", "start_column_index", ",", "end_line_index", ",", "end_column_index", ")", ":", "# If the start and end line are the same we have to compensate for", "# that by subtracting start_column_index from end_col...
Create a _ChunkInfo from a range of lines and columns. :contents_lines: is the raw lines of a file.
[ "Create", "a", "_ChunkInfo", "from", "a", "range", "of", "lines", "and", "columns", "." ]
cfc88771acd3d5551c28fa5d917bb0aeb584c4cc
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L334-L354
251,723
polysquare/polysquare-generic-file-linter
polysquarelinter/spelling.py
_token_at_col_in_line
def _token_at_col_in_line(line, column, token, token_len=None): """True if token is at column.""" if not token_len: token_len = len(token) remaining_len = len(line) - column return (remaining_len >= token_len and line[column:column + token_len] == token)
python
def _token_at_col_in_line(line, column, token, token_len=None): """True if token is at column.""" if not token_len: token_len = len(token) remaining_len = len(line) - column return (remaining_len >= token_len and line[column:column + token_len] == token)
[ "def", "_token_at_col_in_line", "(", "line", ",", "column", ",", "token", ",", "token_len", "=", "None", ")", ":", "if", "not", "token_len", ":", "token_len", "=", "len", "(", "token", ")", "remaining_len", "=", "len", "(", "line", ")", "-", "column", ...
True if token is at column.
[ "True", "if", "token", "is", "at", "column", "." ]
cfc88771acd3d5551c28fa5d917bb0aeb584c4cc
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L357-L365
251,724
polysquare/polysquare-generic-file-linter
polysquarelinter/spelling.py
_maybe_append_chunk
def _maybe_append_chunk(chunk_info, line_index, column, contents, chunks): """Append chunk_info to chunks if it is set.""" if chunk_info: chunks.append(_chunk_from_ranges(contents, chunk_info[0], chunk_info[1], ...
python
def _maybe_append_chunk(chunk_info, line_index, column, contents, chunks): """Append chunk_info to chunks if it is set.""" if chunk_info: chunks.append(_chunk_from_ranges(contents, chunk_info[0], chunk_info[1], ...
[ "def", "_maybe_append_chunk", "(", "chunk_info", ",", "line_index", ",", "column", ",", "contents", ",", "chunks", ")", ":", "if", "chunk_info", ":", "chunks", ".", "append", "(", "_chunk_from_ranges", "(", "contents", ",", "chunk_info", "[", "0", "]", ",", ...
Append chunk_info to chunks if it is set.
[ "Append", "chunk_info", "to", "chunks", "if", "it", "is", "set", "." ]
cfc88771acd3d5551c28fa5d917bb0aeb584c4cc
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L671-L678
251,725
polysquare/polysquare-generic-file-linter
polysquarelinter/spelling.py
_find_spellcheckable_chunks
def _find_spellcheckable_chunks(contents, comment_system): """Given some contents for a file, find chunks that can be spellchecked. This applies the following rules: 1. If the comment system comments individual lines, that whole line can be spellchecked from the poi...
python
def _find_spellcheckable_chunks(contents, comment_system): """Given some contents for a file, find chunks that can be spellchecked. This applies the following rules: 1. If the comment system comments individual lines, that whole line can be spellchecked from the poi...
[ "def", "_find_spellcheckable_chunks", "(", "contents", ",", "comment_system", ")", ":", "state", "=", "InTextParser", "(", ")", "comment_system_transitions", "=", "CommentSystemTransitions", "(", "comment_system", ")", "chunks", "=", "[", "]", "for", "line_index", "...
Given some contents for a file, find chunks that can be spellchecked. This applies the following rules: 1. If the comment system comments individual lines, that whole line can be spellchecked from the point of the comment 2. If a comment-start marker or triple quote is found, keep going u...
[ "Given", "some", "contents", "for", "a", "file", "find", "chunks", "that", "can", "be", "spellchecked", "." ]
cfc88771acd3d5551c28fa5d917bb0aeb584c4cc
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L681-L754
251,726
polysquare/polysquare-generic-file-linter
polysquarelinter/spelling.py
spellcheckable_and_shadow_contents
def spellcheckable_and_shadow_contents(contents, block_out_regexes=None): """For contents, split into spellcheckable and shadow parts. :contents: is a list of lines in a file. The return value is a tuple of (chunks, shadow_contents). chunks is a list of _ChunkInfo, each of which contain a region o...
python
def spellcheckable_and_shadow_contents(contents, block_out_regexes=None): """For contents, split into spellcheckable and shadow parts. :contents: is a list of lines in a file. The return value is a tuple of (chunks, shadow_contents). chunks is a list of _ChunkInfo, each of which contain a region o...
[ "def", "spellcheckable_and_shadow_contents", "(", "contents", ",", "block_out_regexes", "=", "None", ")", ":", "if", "not", "len", "(", "contents", ")", ":", "return", "(", "[", "]", ",", "[", "]", ")", "comment_system", "=", "_comment_system_for_file", "(", ...
For contents, split into spellcheckable and shadow parts. :contents: is a list of lines in a file. The return value is a tuple of (chunks, shadow_contents). chunks is a list of _ChunkInfo, each of which contain a region of text to be spell-checked. shadow_contents is an array of characters and int...
[ "For", "contents", "split", "into", "spellcheckable", "and", "shadow", "parts", "." ]
cfc88771acd3d5551c28fa5d917bb0aeb584c4cc
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L763-L786
251,727
polysquare/polysquare-generic-file-linter
polysquarelinter/spelling.py
_split_into_symbol_words
def _split_into_symbol_words(sym): """Split a technical looking word into a set of symbols. This handles cases where technical words are separated by dots or arrows, as is the convention in many programming languages. """ punc = r"[\s\-\*/\+\.,:\;=\)\(\[\]\{\}<>\|\?&\^\$@]" words = [w.strip() f...
python
def _split_into_symbol_words(sym): """Split a technical looking word into a set of symbols. This handles cases where technical words are separated by dots or arrows, as is the convention in many programming languages. """ punc = r"[\s\-\*/\+\.,:\;=\)\(\[\]\{\}<>\|\?&\^\$@]" words = [w.strip() f...
[ "def", "_split_into_symbol_words", "(", "sym", ")", ":", "punc", "=", "r\"[\\s\\-\\*/\\+\\.,:\\;=\\)\\(\\[\\]\\{\\}<>\\|\\?&\\^\\$@]\"", "words", "=", "[", "w", ".", "strip", "(", ")", "for", "w", "in", "re", ".", "split", "(", "punc", ",", "sym", ")", "]", ...
Split a technical looking word into a set of symbols. This handles cases where technical words are separated by dots or arrows, as is the convention in many programming languages.
[ "Split", "a", "technical", "looking", "word", "into", "a", "set", "of", "symbols", "." ]
cfc88771acd3d5551c28fa5d917bb0aeb584c4cc
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L789-L797
251,728
polysquare/polysquare-generic-file-linter
polysquarelinter/spelling.py
_error_if_word_invalid
def _error_if_word_invalid(word, valid_words_dictionary, technical_words_dictionary, line_offset, col_offset): """Return SpellcheckError if this non-technical word is invalid.""" word_lower = word.lower()...
python
def _error_if_word_invalid(word, valid_words_dictionary, technical_words_dictionary, line_offset, col_offset): """Return SpellcheckError if this non-technical word is invalid.""" word_lower = word.lower()...
[ "def", "_error_if_word_invalid", "(", "word", ",", "valid_words_dictionary", ",", "technical_words_dictionary", ",", "line_offset", ",", "col_offset", ")", ":", "word_lower", "=", "word", ".", "lower", "(", ")", "valid_words_result", "=", "valid_words_dictionary", "."...
Return SpellcheckError if this non-technical word is invalid.
[ "Return", "SpellcheckError", "if", "this", "non", "-", "technical", "word", "is", "invalid", "." ]
cfc88771acd3d5551c28fa5d917bb0aeb584c4cc
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L841-L862
251,729
polysquare/polysquare-generic-file-linter
polysquarelinter/spelling.py
_error_if_symbol_unused
def _error_if_symbol_unused(symbol_word, technical_words_dictionary, line_offset, col_offset): """Return SpellcheckError if this symbol is not used in the code.""" result = technical_words_dictionary.corrections(symbol_word, ...
python
def _error_if_symbol_unused(symbol_word, technical_words_dictionary, line_offset, col_offset): """Return SpellcheckError if this symbol is not used in the code.""" result = technical_words_dictionary.corrections(symbol_word, ...
[ "def", "_error_if_symbol_unused", "(", "symbol_word", ",", "technical_words_dictionary", ",", "line_offset", ",", "col_offset", ")", ":", "result", "=", "technical_words_dictionary", ".", "corrections", "(", "symbol_word", ",", "distance", "=", "5", ",", "prefix", "...
Return SpellcheckError if this symbol is not used in the code.
[ "Return", "SpellcheckError", "if", "this", "symbol", "is", "not", "used", "in", "the", "code", "." ]
cfc88771acd3d5551c28fa5d917bb0aeb584c4cc
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L865-L878
251,730
polysquare/polysquare-generic-file-linter
polysquarelinter/spelling.py
CommentSystemTransitions.should_terminate_now
def should_terminate_now(self, line, waiting_for): """Whether parsing within a comment should terminate now. This is used for comment systems where there is no comment-ending character. We need it for parsing disabled regions where we don't know where a comment block ends, but we know t...
python
def should_terminate_now(self, line, waiting_for): """Whether parsing within a comment should terminate now. This is used for comment systems where there is no comment-ending character. We need it for parsing disabled regions where we don't know where a comment block ends, but we know t...
[ "def", "should_terminate_now", "(", "self", ",", "line", ",", "waiting_for", ")", ":", "if", "waiting_for", "not", "in", "(", "ParserState", ".", "EOL", ",", "self", ".", "_end", ")", ":", "return", "False", "if", "self", ".", "_continue_regex", ":", "re...
Whether parsing within a comment should terminate now. This is used for comment systems where there is no comment-ending character. We need it for parsing disabled regions where we don't know where a comment block ends, but we know that a comment block could end at a line ending. It ret...
[ "Whether", "parsing", "within", "a", "comment", "should", "terminate", "now", "." ]
cfc88771acd3d5551c28fa5d917bb0aeb584c4cc
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L431-L446
251,731
polysquare/polysquare-generic-file-linter
polysquarelinter/spelling.py
ParserState.get_transition
def get_transition(self, # suppress(too-many-arguments) line, line_index, column, is_escaped, comment_system_transitions, eof=False): """Return a parser state, a move-ahead ...
python
def get_transition(self, # suppress(too-many-arguments) line, line_index, column, is_escaped, comment_system_transitions, eof=False): """Return a parser state, a move-ahead ...
[ "def", "get_transition", "(", "self", ",", "# suppress(too-many-arguments)", "line", ",", "line_index", ",", "column", ",", "is_escaped", ",", "comment_system_transitions", ",", "eof", "=", "False", ")", ":", "raise", "NotImplementedError", "(", "\"\"\"Cannot instanti...
Return a parser state, a move-ahead amount, and an append range. If this parser state should terminate and return back to the TEXT state, then return that state and also any corresponding chunk that would have been yielded as a result.
[ "Return", "a", "parser", "state", "a", "move", "-", "ahead", "amount", "and", "an", "append", "range", "." ]
cfc88771acd3d5551c28fa5d917bb0aeb584c4cc
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L467-L480
251,732
polysquare/polysquare-generic-file-linter
polysquarelinter/spelling.py
InTextParser.get_transition
def get_transition(self, # suppress(too-many-arguments) line, line_index, column, is_escaped, comment_system_transitions, eof=False): """Get transition from InTextParser."""...
python
def get_transition(self, # suppress(too-many-arguments) line, line_index, column, is_escaped, comment_system_transitions, eof=False): """Get transition from InTextParser."""...
[ "def", "get_transition", "(", "self", ",", "# suppress(too-many-arguments)", "line", ",", "line_index", ",", "column", ",", "is_escaped", ",", "comment_system_transitions", ",", "eof", "=", "False", ")", ":", "parser_transition", "=", "{", "STATE_IN_COMMENT", ":", ...
Get transition from InTextParser.
[ "Get", "transition", "from", "InTextParser", "." ]
cfc88771acd3d5551c28fa5d917bb0aeb584c4cc
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L495-L523
251,733
polysquare/polysquare-generic-file-linter
polysquarelinter/spelling.py
DisabledParser.get_transition
def get_transition(self, # suppress(too-many-arguments) line, line_index, column, is_escaped, comment_system_transitions, eof=False): """Get transition from DisabledParser."...
python
def get_transition(self, # suppress(too-many-arguments) line, line_index, column, is_escaped, comment_system_transitions, eof=False): """Get transition from DisabledParser."...
[ "def", "get_transition", "(", "self", ",", "# suppress(too-many-arguments)", "line", ",", "line_index", ",", "column", ",", "is_escaped", ",", "comment_system_transitions", ",", "eof", "=", "False", ")", ":", "# If we are at the beginning of a line, to see if we should", ...
Get transition from DisabledParser.
[ "Get", "transition", "from", "DisabledParser", "." ]
cfc88771acd3d5551c28fa5d917bb0aeb584c4cc
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L543-L593
251,734
polysquare/polysquare-generic-file-linter
polysquarelinter/spelling.py
InCommentParser.get_transition
def get_transition(self, # suppress(too-many-arguments) line, line_index, column, is_escaped, comment_system_transitions, eof=False): """Get transition from InCommentParser....
python
def get_transition(self, # suppress(too-many-arguments) line, line_index, column, is_escaped, comment_system_transitions, eof=False): """Get transition from InCommentParser....
[ "def", "get_transition", "(", "self", ",", "# suppress(too-many-arguments)", "line", ",", "line_index", ",", "column", ",", "is_escaped", ",", "comment_system_transitions", ",", "eof", "=", "False", ")", ":", "del", "comment_system_transitions", "if", "(", "_token_a...
Get transition from InCommentParser.
[ "Get", "transition", "from", "InCommentParser", "." ]
cfc88771acd3d5551c28fa5d917bb0aeb584c4cc
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L600-L641
251,735
polysquare/polysquare-generic-file-linter
polysquarelinter/spelling.py
InQuoteParser.get_transition
def get_transition(self, # suppress(too-many-arguments) line, line_index, column, is_escaped, *args, **kwargs): """Get transition from InQuoteParser.""" del line_ind...
python
def get_transition(self, # suppress(too-many-arguments) line, line_index, column, is_escaped, *args, **kwargs): """Get transition from InQuoteParser.""" del line_ind...
[ "def", "get_transition", "(", "self", ",", "# suppress(too-many-arguments)", "line", ",", "line_index", ",", "column", ",", "is_escaped", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "del", "line_index", "del", "args", "del", "kwargs", "wait_until_len"...
Get transition from InQuoteParser.
[ "Get", "transition", "from", "InQuoteParser", "." ]
cfc88771acd3d5551c28fa5d917bb0aeb584c4cc
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L648-L668
251,736
polysquare/polysquare-generic-file-linter
polysquarelinter/spelling.py
Dictionary.corrections
def corrections(self, word, prefix=1, distance=2): """Get corrections for word, if word is an invalid word. :prefix: is the number of characters the prefix of the word must have in common with the suggested corrections. :distance: is the character distance the corrections may have betw...
python
def corrections(self, word, prefix=1, distance=2): """Get corrections for word, if word is an invalid word. :prefix: is the number of characters the prefix of the word must have in common with the suggested corrections. :distance: is the character distance the corrections may have betw...
[ "def", "corrections", "(", "self", ",", "word", ",", "prefix", "=", "1", ",", "distance", "=", "2", ")", ":", "if", "word", "not", "in", "self", ".", "_words", ":", "return", "Dictionary", ".", "Result", "(", "False", ",", "self", ".", "_corrector", ...
Get corrections for word, if word is an invalid word. :prefix: is the number of characters the prefix of the word must have in common with the suggested corrections. :distance: is the character distance the corrections may have between the input word. This limits the number of availabl...
[ "Get", "corrections", "for", "word", "if", "word", "is", "an", "invalid", "word", "." ]
cfc88771acd3d5551c28fa5d917bb0aeb584c4cc
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L910-L930
251,737
edeposit/edeposit.amqp.harvester
src/edeposit/amqp/harvester/edeposit_autoparser.py
_create_dom
def _create_dom(data): """ Creates doublelinked DOM from `data`. Args: data (str/HTMLElement): Either string or HTML element. Returns: obj: HTMLElement containing double linked DOM. """ if not isinstance(data, dhtmlparser.HTMLElement): data = dhtmlparser.parseString( ...
python
def _create_dom(data): """ Creates doublelinked DOM from `data`. Args: data (str/HTMLElement): Either string or HTML element. Returns: obj: HTMLElement containing double linked DOM. """ if not isinstance(data, dhtmlparser.HTMLElement): data = dhtmlparser.parseString( ...
[ "def", "_create_dom", "(", "data", ")", ":", "if", "not", "isinstance", "(", "data", ",", "dhtmlparser", ".", "HTMLElement", ")", ":", "data", "=", "dhtmlparser", ".", "parseString", "(", "utils", ".", "handle_encodnig", "(", "data", ")", ")", "dhtmlparser...
Creates doublelinked DOM from `data`. Args: data (str/HTMLElement): Either string or HTML element. Returns: obj: HTMLElement containing double linked DOM.
[ "Creates", "doublelinked", "DOM", "from", "data", "." ]
38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e
https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/edeposit_autoparser.py#L22-L39
251,738
edeposit/edeposit.amqp.harvester
src/edeposit/amqp/harvester/edeposit_autoparser.py
_locate_element
def _locate_element(dom, el_content, transformer=None): """ Find element containing `el_content` in `dom`. Use `transformer` function to content of all elements in `dom` in order to correctly transforming them to match them with `el_content`. Args: dom (obj): HTMLElement tree. el_co...
python
def _locate_element(dom, el_content, transformer=None): """ Find element containing `el_content` in `dom`. Use `transformer` function to content of all elements in `dom` in order to correctly transforming them to match them with `el_content`. Args: dom (obj): HTMLElement tree. el_co...
[ "def", "_locate_element", "(", "dom", ",", "el_content", ",", "transformer", "=", "None", ")", ":", "return", "dom", ".", "find", "(", "None", ",", "fn", "=", "utils", ".", "content_matchs", "(", "el_content", ",", "transformer", ")", ")" ]
Find element containing `el_content` in `dom`. Use `transformer` function to content of all elements in `dom` in order to correctly transforming them to match them with `el_content`. Args: dom (obj): HTMLElement tree. el_content (str): Content of element will be picked from `dom`. t...
[ "Find", "element", "containing", "el_content", "in", "dom", ".", "Use", "transformer", "function", "to", "content", "of", "all", "elements", "in", "dom", "in", "order", "to", "correctly", "transforming", "them", "to", "match", "them", "with", "el_content", "."...
38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e
https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/edeposit_autoparser.py#L42-L64
251,739
edeposit/edeposit.amqp.harvester
src/edeposit/amqp/harvester/edeposit_autoparser.py
_match_elements
def _match_elements(dom, matches): """ Find location of elements matching patterns specified in `matches`. Args: dom (obj): HTMLElement DOM tree. matches (dict): Structure: ``{"var": {"data": "match", ..}, ..}``. Returns: dict: Structure: ``{"var": {"data": HTMLElement_obj, ..}...
python
def _match_elements(dom, matches): """ Find location of elements matching patterns specified in `matches`. Args: dom (obj): HTMLElement DOM tree. matches (dict): Structure: ``{"var": {"data": "match", ..}, ..}``. Returns: dict: Structure: ``{"var": {"data": HTMLElement_obj, ..}...
[ "def", "_match_elements", "(", "dom", ",", "matches", ")", ":", "out", "=", "{", "}", "for", "key", ",", "content", "in", "matches", ".", "items", "(", ")", ":", "pattern", "=", "content", "[", "\"data\"", "]", ".", "strip", "(", ")", "if", "\"\\n\...
Find location of elements matching patterns specified in `matches`. Args: dom (obj): HTMLElement DOM tree. matches (dict): Structure: ``{"var": {"data": "match", ..}, ..}``. Returns: dict: Structure: ``{"var": {"data": HTMLElement_obj, ..}, ..}``
[ "Find", "location", "of", "elements", "matching", "patterns", "specified", "in", "matches", "." ]
38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e
https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/edeposit_autoparser.py#L67-L120
251,740
edeposit/edeposit.amqp.harvester
src/edeposit/amqp/harvester/edeposit_autoparser.py
_collect_paths
def _collect_paths(element): """ Collect all possible path which leads to `element`. Function returns standard path from root element to this, reverse path, which uses negative indexes for path, also some pattern matches, like "this is element, which has neighbour with id 7" and so on. Args: ...
python
def _collect_paths(element): """ Collect all possible path which leads to `element`. Function returns standard path from root element to this, reverse path, which uses negative indexes for path, also some pattern matches, like "this is element, which has neighbour with id 7" and so on. Args: ...
[ "def", "_collect_paths", "(", "element", ")", ":", "output", "=", "[", "]", "# look for element by parameters - sometimes the ID is unique", "path", "=", "vectors", ".", "el_to_path_vector", "(", "element", ")", "root", "=", "path", "[", "0", "]", "params", "=", ...
Collect all possible path which leads to `element`. Function returns standard path from root element to this, reverse path, which uses negative indexes for path, also some pattern matches, like "this is element, which has neighbour with id 7" and so on. Args: element (obj): HTMLElement instanc...
[ "Collect", "all", "possible", "path", "which", "leads", "to", "element", "." ]
38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e
https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/edeposit_autoparser.py#L123-L205
251,741
edeposit/edeposit.amqp.harvester
src/edeposit/amqp/harvester/edeposit_autoparser.py
_is_working_path
def _is_working_path(dom, path, element): """ Check whether the path is working or not. Aply proper search function interpreting `path` to `dom` and check, if returned object is `element`. If so, return ``True``, otherwise ``False``. Args: dom (obj): HTMLElement DOM. path (obj): :c...
python
def _is_working_path(dom, path, element): """ Check whether the path is working or not. Aply proper search function interpreting `path` to `dom` and check, if returned object is `element`. If so, return ``True``, otherwise ``False``. Args: dom (obj): HTMLElement DOM. path (obj): :c...
[ "def", "_is_working_path", "(", "dom", ",", "path", ",", "element", ")", ":", "def", "i_or_none", "(", "el", ",", "i", ")", ":", "\"\"\"\n Return ``el[i]`` if the list is not blank, or None otherwise.\n\n Args:\n el (list, tuple): Any indexable object.\n ...
Check whether the path is working or not. Aply proper search function interpreting `path` to `dom` and check, if returned object is `element`. If so, return ``True``, otherwise ``False``. Args: dom (obj): HTMLElement DOM. path (obj): :class:`.PathCall` Instance containing informations abou...
[ "Check", "whether", "the", "path", "is", "working", "or", "not", "." ]
38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e
https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/edeposit_autoparser.py#L208-L289
251,742
edeposit/edeposit.amqp.harvester
src/edeposit/amqp/harvester/edeposit_autoparser.py
select_best_paths
def select_best_paths(examples): """ Process `examples`, select only paths that works for every example. Select best paths with highest priority. Args: examples (dict): Output from :func:`.read_config`. Returns: list: List of :class:`.PathCall` and :class:`.Chained` objects. ""...
python
def select_best_paths(examples): """ Process `examples`, select only paths that works for every example. Select best paths with highest priority. Args: examples (dict): Output from :func:`.read_config`. Returns: list: List of :class:`.PathCall` and :class:`.Chained` objects. ""...
[ "def", "select_best_paths", "(", "examples", ")", ":", "possible_paths", "=", "{", "}", "# {varname: [paths]}", "# collect list of all possible paths to all existing variables", "for", "example", "in", "examples", ":", "dom", "=", "_create_dom", "(", "example", "[", "\"...
Process `examples`, select only paths that works for every example. Select best paths with highest priority. Args: examples (dict): Output from :func:`.read_config`. Returns: list: List of :class:`.PathCall` and :class:`.Chained` objects.
[ "Process", "examples", "select", "only", "paths", "that", "works", "for", "every", "example", ".", "Select", "best", "paths", "with", "highest", "priority", "." ]
38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e
https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/edeposit_autoparser.py#L292-L349
251,743
edeposit/edeposit.amqp.storage
src/edeposit/amqp/storage/publication_storage.py
_assert_obj_type
def _assert_obj_type(pub, name="pub", obj_type=DBPublication): """ Make sure, that `pub` is instance of the `obj_type`. Args: pub (obj): Instance which will be checked. name (str): Name of the instance. Used in exception. Default `pub`. obj_type (class): Class of which the `pub` sho...
python
def _assert_obj_type(pub, name="pub", obj_type=DBPublication): """ Make sure, that `pub` is instance of the `obj_type`. Args: pub (obj): Instance which will be checked. name (str): Name of the instance. Used in exception. Default `pub`. obj_type (class): Class of which the `pub` sho...
[ "def", "_assert_obj_type", "(", "pub", ",", "name", "=", "\"pub\"", ",", "obj_type", "=", "DBPublication", ")", ":", "if", "not", "isinstance", "(", "pub", ",", "obj_type", ")", ":", "raise", "InvalidType", "(", "\"`%s` have to be instance of %s, not %s!\"", "%"...
Make sure, that `pub` is instance of the `obj_type`. Args: pub (obj): Instance which will be checked. name (str): Name of the instance. Used in exception. Default `pub`. obj_type (class): Class of which the `pub` should be instance. Default :class:`.DBPublication`. Rai...
[ "Make", "sure", "that", "pub", "is", "instance", "of", "the", "obj_type", "." ]
fb6bd326249847de04b17b64e856c878665cea92
https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/src/edeposit/amqp/storage/publication_storage.py#L30-L50
251,744
edeposit/edeposit.amqp.storage
src/edeposit/amqp/storage/publication_storage.py
save_publication
def save_publication(pub): """ Save `pub` into database and into proper indexes. Attr: pub (obj): Instance of the :class:`.DBPublication`. Returns: obj: :class:`.DBPublication` without data. Raises: InvalidType: When the `pub` is not instance of :class:`.DBPublication`. ...
python
def save_publication(pub): """ Save `pub` into database and into proper indexes. Attr: pub (obj): Instance of the :class:`.DBPublication`. Returns: obj: :class:`.DBPublication` without data. Raises: InvalidType: When the `pub` is not instance of :class:`.DBPublication`. ...
[ "def", "save_publication", "(", "pub", ")", ":", "_assert_obj_type", "(", "pub", ")", "_get_handler", "(", ")", ".", "store_object", "(", "pub", ")", "return", "pub", ".", "to_comm", "(", "light_request", "=", "True", ")" ]
Save `pub` into database and into proper indexes. Attr: pub (obj): Instance of the :class:`.DBPublication`. Returns: obj: :class:`.DBPublication` without data. Raises: InvalidType: When the `pub` is not instance of :class:`.DBPublication`. UnindexablePublication: When ther...
[ "Save", "pub", "into", "database", "and", "into", "proper", "indexes", "." ]
fb6bd326249847de04b17b64e856c878665cea92
https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/src/edeposit/amqp/storage/publication_storage.py#L53-L72
251,745
eddiejessup/agaro
agaro/runner.py
Runner.clear_dir
def clear_dir(self): """Clear the output directory of all output files.""" for snapshot in output_utils.get_filenames(self.output_dir): if snapshot.endswith('.pkl'): os.remove(snapshot)
python
def clear_dir(self): """Clear the output directory of all output files.""" for snapshot in output_utils.get_filenames(self.output_dir): if snapshot.endswith('.pkl'): os.remove(snapshot)
[ "def", "clear_dir", "(", "self", ")", ":", "for", "snapshot", "in", "output_utils", ".", "get_filenames", "(", "self", ".", "output_dir", ")", ":", "if", "snapshot", ".", "endswith", "(", "'.pkl'", ")", ":", "os", ".", "remove", "(", "snapshot", ")" ]
Clear the output directory of all output files.
[ "Clear", "the", "output", "directory", "of", "all", "output", "files", "." ]
b2feb45d6129d749088c70b3e9290af7ca7c7d33
https://github.com/eddiejessup/agaro/blob/b2feb45d6129d749088c70b3e9290af7ca7c7d33/agaro/runner.py#L99-L103
251,746
eddiejessup/agaro
agaro/runner.py
Runner.is_snapshot_time
def is_snapshot_time(self, output_every=None, t_output_every=None): """Determine whether or not the model's iteration number is one where the runner is expected to make an output snapshot. """ if t_output_every is not None: output_every = int(round(t_output_every // self.mode...
python
def is_snapshot_time(self, output_every=None, t_output_every=None): """Determine whether or not the model's iteration number is one where the runner is expected to make an output snapshot. """ if t_output_every is not None: output_every = int(round(t_output_every // self.mode...
[ "def", "is_snapshot_time", "(", "self", ",", "output_every", "=", "None", ",", "t_output_every", "=", "None", ")", ":", "if", "t_output_every", "is", "not", "None", ":", "output_every", "=", "int", "(", "round", "(", "t_output_every", "//", "self", ".", "m...
Determine whether or not the model's iteration number is one where the runner is expected to make an output snapshot.
[ "Determine", "whether", "or", "not", "the", "model", "s", "iteration", "number", "is", "one", "where", "the", "runner", "is", "expected", "to", "make", "an", "output", "snapshot", "." ]
b2feb45d6129d749088c70b3e9290af7ca7c7d33
https://github.com/eddiejessup/agaro/blob/b2feb45d6129d749088c70b3e9290af7ca7c7d33/agaro/runner.py#L105-L111
251,747
eddiejessup/agaro
agaro/runner.py
Runner.iterate
def iterate(self, n=None, n_upto=None, t=None, t_upto=None, output_every=None, t_output_every=None): """Run the model for a number of iterations, expressed in a number of options. Only one iteration argument should be passed. Only one output arguments shou...
python
def iterate(self, n=None, n_upto=None, t=None, t_upto=None, output_every=None, t_output_every=None): """Run the model for a number of iterations, expressed in a number of options. Only one iteration argument should be passed. Only one output arguments shou...
[ "def", "iterate", "(", "self", ",", "n", "=", "None", ",", "n_upto", "=", "None", ",", "t", "=", "None", ",", "t_upto", "=", "None", ",", "output_every", "=", "None", ",", "t_output_every", "=", "None", ")", ":", "if", "t", "is", "not", "None", "...
Run the model for a number of iterations, expressed in a number of options. Only one iteration argument should be passed. Only one output arguments should be passed. Parameters ---------- n: int Run the model for `n` iterations from its current point. ...
[ "Run", "the", "model", "for", "a", "number", "of", "iterations", "expressed", "in", "a", "number", "of", "options", ".", "Only", "one", "iteration", "argument", "should", "be", "passed", ".", "Only", "one", "output", "arguments", "should", "be", "passed", ...
b2feb45d6129d749088c70b3e9290af7ca7c7d33
https://github.com/eddiejessup/agaro/blob/b2feb45d6129d749088c70b3e9290af7ca7c7d33/agaro/runner.py#L113-L149
251,748
eddiejessup/agaro
agaro/runner.py
Runner.make_snapshot
def make_snapshot(self): """Output a snapshot of the current model state, as a pickle of the `Model` object in a file inside the output directory, with a name determined by its iteration number. """ filename = join(self.output_dir, '{:010d}.pkl'.format(self.model.i)) outp...
python
def make_snapshot(self): """Output a snapshot of the current model state, as a pickle of the `Model` object in a file inside the output directory, with a name determined by its iteration number. """ filename = join(self.output_dir, '{:010d}.pkl'.format(self.model.i)) outp...
[ "def", "make_snapshot", "(", "self", ")", ":", "filename", "=", "join", "(", "self", ".", "output_dir", ",", "'{:010d}.pkl'", ".", "format", "(", "self", ".", "model", ".", "i", ")", ")", "output_utils", ".", "model_to_file", "(", "self", ".", "model", ...
Output a snapshot of the current model state, as a pickle of the `Model` object in a file inside the output directory, with a name determined by its iteration number.
[ "Output", "a", "snapshot", "of", "the", "current", "model", "state", "as", "a", "pickle", "of", "the", "Model", "object", "in", "a", "file", "inside", "the", "output", "directory", "with", "a", "name", "determined", "by", "its", "iteration", "number", "." ...
b2feb45d6129d749088c70b3e9290af7ca7c7d33
https://github.com/eddiejessup/agaro/blob/b2feb45d6129d749088c70b3e9290af7ca7c7d33/agaro/runner.py#L151-L157
251,749
qzmfranklin/easyshell
easyshell/debugging_shell.py
DebuggingShell.parse_line
def parse_line(self, line): """Parser for the debugging shell. Treat everything after the first token as one literal entity. Whitespace characters between the first token and the next first non-whitespace character are preserved. For example, ' foo dicj didiw ' is parsed as...
python
def parse_line(self, line): """Parser for the debugging shell. Treat everything after the first token as one literal entity. Whitespace characters between the first token and the next first non-whitespace character are preserved. For example, ' foo dicj didiw ' is parsed as...
[ "def", "parse_line", "(", "self", ",", "line", ")", ":", "line", "=", "line", ".", "lstrip", "(", ")", "toks", "=", "shlex", ".", "split", "(", "line", ")", "cmd", "=", "toks", "[", "0", "]", "arg", "=", "line", "[", "len", "(", "cmd", ")", "...
Parser for the debugging shell. Treat everything after the first token as one literal entity. Whitespace characters between the first token and the next first non-whitespace character are preserved. For example, ' foo dicj didiw ' is parsed as ( 'foo', ' dicj didiw '...
[ "Parser", "for", "the", "debugging", "shell", "." ]
00c2e90e7767d32e7e127fc8c6875845aa308295
https://github.com/qzmfranklin/easyshell/blob/00c2e90e7767d32e7e127fc8c6875845aa308295/easyshell/debugging_shell.py#L75-L93
251,750
yv/pathconfig
py_src/pathconfig/factory.py
Factory.bind
def bind(self, **kwargs): ''' creates a copy of the object without the cached results and with the given keyword arguments as properties. ''' d = dict(self.__dict__) for k in d.keys(): if k[0] == '_': del d[k] elif k.startsw...
python
def bind(self, **kwargs): ''' creates a copy of the object without the cached results and with the given keyword arguments as properties. ''' d = dict(self.__dict__) for k in d.keys(): if k[0] == '_': del d[k] elif k.startsw...
[ "def", "bind", "(", "self", ",", "*", "*", "kwargs", ")", ":", "d", "=", "dict", "(", "self", ".", "__dict__", ")", "for", "k", "in", "d", ".", "keys", "(", ")", ":", "if", "k", "[", "0", "]", "==", "'_'", ":", "del", "d", "[", "k", "]", ...
creates a copy of the object without the cached results and with the given keyword arguments as properties.
[ "creates", "a", "copy", "of", "the", "object", "without", "the", "cached", "results", "and", "with", "the", "given", "keyword", "arguments", "as", "properties", "." ]
ae13901773b8465061e2aa93b2a53fd436ab6c69
https://github.com/yv/pathconfig/blob/ae13901773b8465061e2aa93b2a53fd436ab6c69/py_src/pathconfig/factory.py#L74-L87
251,751
yv/pathconfig
py_src/pathconfig/factory.py
Factory.get
def get(self, name, *subkey): """ retrieves a data item, or loads it if it is not present. """ if subkey == []: return self.get_atomic(name) else: return self.get_subkey(name, tuple(subkey))
python
def get(self, name, *subkey): """ retrieves a data item, or loads it if it is not present. """ if subkey == []: return self.get_atomic(name) else: return self.get_subkey(name, tuple(subkey))
[ "def", "get", "(", "self", ",", "name", ",", "*", "subkey", ")", ":", "if", "subkey", "==", "[", "]", ":", "return", "self", ".", "get_atomic", "(", "name", ")", "else", ":", "return", "self", ".", "get_subkey", "(", "name", ",", "tuple", "(", "s...
retrieves a data item, or loads it if it is not present.
[ "retrieves", "a", "data", "item", "or", "loads", "it", "if", "it", "is", "not", "present", "." ]
ae13901773b8465061e2aa93b2a53fd436ab6c69
https://github.com/yv/pathconfig/blob/ae13901773b8465061e2aa93b2a53fd436ab6c69/py_src/pathconfig/factory.py#L89-L97
251,752
yv/pathconfig
py_src/pathconfig/factory.py
Factory.val
def val(self, name): """ retrieves a value, substituting actual values for ConfigValue templates. """ v = getattr(self, name) if hasattr(v, 'retrieve_value'): v = v.retrieve_value(self.__dict__) return v
python
def val(self, name): """ retrieves a value, substituting actual values for ConfigValue templates. """ v = getattr(self, name) if hasattr(v, 'retrieve_value'): v = v.retrieve_value(self.__dict__) return v
[ "def", "val", "(", "self", ",", "name", ")", ":", "v", "=", "getattr", "(", "self", ",", "name", ")", "if", "hasattr", "(", "v", ",", "'retrieve_value'", ")", ":", "v", "=", "v", ".", "retrieve_value", "(", "self", ".", "__dict__", ")", "return", ...
retrieves a value, substituting actual values for ConfigValue templates.
[ "retrieves", "a", "value", "substituting", "actual", "values", "for", "ConfigValue", "templates", "." ]
ae13901773b8465061e2aa93b2a53fd436ab6c69
https://github.com/yv/pathconfig/blob/ae13901773b8465061e2aa93b2a53fd436ab6c69/py_src/pathconfig/factory.py#L99-L107
251,753
lsst-sqre/zenodio
zenodio/harvest.py
harvest_collection
def harvest_collection(community_name): """Harvest a Zenodo community's record metadata. Examples -------- You can harvest record metadata for a Zenodo community via its identifier name. For example, the identifier for LSST Data Management's Zenodo collection is ``'lsst-dm'``: >>> import z...
python
def harvest_collection(community_name): """Harvest a Zenodo community's record metadata. Examples -------- You can harvest record metadata for a Zenodo community via its identifier name. For example, the identifier for LSST Data Management's Zenodo collection is ``'lsst-dm'``: >>> import z...
[ "def", "harvest_collection", "(", "community_name", ")", ":", "url", "=", "zenodo_harvest_url", "(", "community_name", ")", "r", "=", "requests", ".", "get", "(", "url", ")", "r", ".", "status_code", "xml_content", "=", "r", ".", "content", "return", "Dataci...
Harvest a Zenodo community's record metadata. Examples -------- You can harvest record metadata for a Zenodo community via its identifier name. For example, the identifier for LSST Data Management's Zenodo collection is ``'lsst-dm'``: >>> import zenodio.harvest import harvest_collection >>...
[ "Harvest", "a", "Zenodo", "community", "s", "record", "metadata", "." ]
24283e84bee5714450e4f206ec024c4d32f2e761
https://github.com/lsst-sqre/zenodio/blob/24283e84bee5714450e4f206ec024c4d32f2e761/zenodio/harvest.py#L28-L61
251,754
lsst-sqre/zenodio
zenodio/harvest.py
zenodo_harvest_url
def zenodo_harvest_url(community_name, format='oai_datacite3'): """Build a URL for the Zenodo Community's metadata. Parameters ---------- community_name : str Zenodo community identifier. format : str OAI-PMH metadata specification name. See https://zenodo.org/dev. Currently...
python
def zenodo_harvest_url(community_name, format='oai_datacite3'): """Build a URL for the Zenodo Community's metadata. Parameters ---------- community_name : str Zenodo community identifier. format : str OAI-PMH metadata specification name. See https://zenodo.org/dev. Currently...
[ "def", "zenodo_harvest_url", "(", "community_name", ",", "format", "=", "'oai_datacite3'", ")", ":", "template", "=", "'http://zenodo.org/oai2d?verb=ListRecords&'", "'metadataPrefix={metadata_format}&set=user-{community}'", "return", "template", ".", "format", "(", "metadata_fo...
Build a URL for the Zenodo Community's metadata. Parameters ---------- community_name : str Zenodo community identifier. format : str OAI-PMH metadata specification name. See https://zenodo.org/dev. Currently on ``oai_datacite3`` is supported. Returns ------- url : ...
[ "Build", "a", "URL", "for", "the", "Zenodo", "Community", "s", "metadata", "." ]
24283e84bee5714450e4f206ec024c4d32f2e761
https://github.com/lsst-sqre/zenodio/blob/24283e84bee5714450e4f206ec024c4d32f2e761/zenodio/harvest.py#L64-L83
251,755
lsst-sqre/zenodio
zenodio/harvest.py
_pluralize
def _pluralize(value, item_key): """"Force the value of a datacite3 key to be a list. >>> _pluralize(xml_input['authors'], 'author') ['Sick, Jonathan', 'Economou, Frossie'] Background ---------- When `xmltodict` proceses metadata, it turns XML tags into new key-value pairs whenever possibl...
python
def _pluralize(value, item_key): """"Force the value of a datacite3 key to be a list. >>> _pluralize(xml_input['authors'], 'author') ['Sick, Jonathan', 'Economou, Frossie'] Background ---------- When `xmltodict` proceses metadata, it turns XML tags into new key-value pairs whenever possibl...
[ "def", "_pluralize", "(", "value", ",", "item_key", ")", ":", "v", "=", "value", "[", "item_key", "]", "if", "not", "isinstance", "(", "v", ",", "list", ")", ":", "# Force a singular value to be a list", "return", "[", "v", "]", "else", ":", "return", "v...
Force the value of a datacite3 key to be a list. >>> _pluralize(xml_input['authors'], 'author') ['Sick, Jonathan', 'Economou, Frossie'] Background ---------- When `xmltodict` proceses metadata, it turns XML tags into new key-value pairs whenever possible, even if the value should semantically ...
[ "Force", "the", "value", "of", "a", "datacite3", "key", "to", "be", "a", "list", "." ]
24283e84bee5714450e4f206ec024c4d32f2e761
https://github.com/lsst-sqre/zenodio/blob/24283e84bee5714450e4f206ec024c4d32f2e761/zenodio/harvest.py#L258-L317
251,756
lsst-sqre/zenodio
zenodio/harvest.py
Author.from_xmldict
def from_xmldict(cls, xml_dict): """Create an `Author` from a datacite3 metadata converted by `xmltodict`. Parameters ---------- xml_dict : :class:`collections.OrderedDict` A `dict`-like object mapping XML content for a single record (i.e., the contents o...
python
def from_xmldict(cls, xml_dict): """Create an `Author` from a datacite3 metadata converted by `xmltodict`. Parameters ---------- xml_dict : :class:`collections.OrderedDict` A `dict`-like object mapping XML content for a single record (i.e., the contents o...
[ "def", "from_xmldict", "(", "cls", ",", "xml_dict", ")", ":", "name", "=", "xml_dict", "[", "'creatorName'", "]", "kwargs", "=", "{", "}", "if", "'affiliation'", "in", "xml_dict", ":", "kwargs", "[", "'affiliation'", "]", "=", "xml_dict", "[", "'affiliatio...
Create an `Author` from a datacite3 metadata converted by `xmltodict`. Parameters ---------- xml_dict : :class:`collections.OrderedDict` A `dict`-like object mapping XML content for a single record (i.e., the contents of the ``record`` tag in OAI-PMH XML). This d...
[ "Create", "an", "Author", "from", "a", "datacite3", "metadata", "converted", "by", "xmltodict", "." ]
24283e84bee5714450e4f206ec024c4d32f2e761
https://github.com/lsst-sqre/zenodio/blob/24283e84bee5714450e4f206ec024c4d32f2e761/zenodio/harvest.py#L228-L245
251,757
minhhoit/yacms
yacms/core/managers.py
PublishedManager.published
def published(self, for_user=None): """ For non-staff users, return items with a published status and whose publish and expiry dates fall before and after the current date when specified. """ from yacms.core.models import CONTENT_STATUS_PUBLISHED if for_user is no...
python
def published(self, for_user=None): """ For non-staff users, return items with a published status and whose publish and expiry dates fall before and after the current date when specified. """ from yacms.core.models import CONTENT_STATUS_PUBLISHED if for_user is no...
[ "def", "published", "(", "self", ",", "for_user", "=", "None", ")", ":", "from", "yacms", ".", "core", ".", "models", "import", "CONTENT_STATUS_PUBLISHED", "if", "for_user", "is", "not", "None", "and", "for_user", ".", "is_staff", ":", "return", "self", "....
For non-staff users, return items with a published status and whose publish and expiry dates fall before and after the current date when specified.
[ "For", "non", "-", "staff", "users", "return", "items", "with", "a", "published", "status", "and", "whose", "publish", "and", "expiry", "dates", "fall", "before", "and", "after", "the", "current", "date", "when", "specified", "." ]
2921b706b7107c6e8c5f2bbf790ff11f85a2167f
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/managers.py#L58-L70
251,758
minhhoit/yacms
yacms/core/managers.py
SearchableQuerySet.search
def search(self, query, search_fields=None): """ Build a queryset matching words in the given search query, treating quoted terms as exact phrases and taking into account + and - symbols as modifiers controlling which terms to require and exclude. """ # ### DETER...
python
def search(self, query, search_fields=None): """ Build a queryset matching words in the given search query, treating quoted terms as exact phrases and taking into account + and - symbols as modifiers controlling which terms to require and exclude. """ # ### DETER...
[ "def", "search", "(", "self", ",", "query", ",", "search_fields", "=", "None", ")", ":", "# ### DETERMINE FIELDS TO SEARCH ###", "# Use search_fields arg if given, otherwise use search_fields", "# initially configured by the manager class.", "if", "search_fields", ":", "self", ...
Build a queryset matching words in the given search query, treating quoted terms as exact phrases and taking into account + and - symbols as modifiers controlling which terms to require and exclude.
[ "Build", "a", "queryset", "matching", "words", "in", "the", "given", "search", "query", "treating", "quoted", "terms", "as", "exact", "phrases", "and", "taking", "into", "account", "+", "and", "-", "symbols", "as", "modifiers", "controlling", "which", "terms",...
2921b706b7107c6e8c5f2bbf790ff11f85a2167f
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/managers.py#L105-L172
251,759
minhhoit/yacms
yacms/core/managers.py
SearchableQuerySet._clone
def _clone(self, *args, **kwargs): """ Ensure attributes are copied to subsequent queries. """ for attr in ("_search_terms", "_search_fields", "_search_ordered"): kwargs[attr] = getattr(self, attr) return super(SearchableQuerySet, self)._clone(*args, **kwargs)
python
def _clone(self, *args, **kwargs): """ Ensure attributes are copied to subsequent queries. """ for attr in ("_search_terms", "_search_fields", "_search_ordered"): kwargs[attr] = getattr(self, attr) return super(SearchableQuerySet, self)._clone(*args, **kwargs)
[ "def", "_clone", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "attr", "in", "(", "\"_search_terms\"", ",", "\"_search_fields\"", ",", "\"_search_ordered\"", ")", ":", "kwargs", "[", "attr", "]", "=", "getattr", "(", "self", ...
Ensure attributes are copied to subsequent queries.
[ "Ensure", "attributes", "are", "copied", "to", "subsequent", "queries", "." ]
2921b706b7107c6e8c5f2bbf790ff11f85a2167f
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/managers.py#L174-L180
251,760
minhhoit/yacms
yacms/core/managers.py
SearchableQuerySet.order_by
def order_by(self, *field_names): """ Mark the filter as being ordered if search has occurred. """ if not self._search_ordered: self._search_ordered = len(self._search_terms) > 0 return super(SearchableQuerySet, self).order_by(*field_names)
python
def order_by(self, *field_names): """ Mark the filter as being ordered if search has occurred. """ if not self._search_ordered: self._search_ordered = len(self._search_terms) > 0 return super(SearchableQuerySet, self).order_by(*field_names)
[ "def", "order_by", "(", "self", ",", "*", "field_names", ")", ":", "if", "not", "self", ".", "_search_ordered", ":", "self", ".", "_search_ordered", "=", "len", "(", "self", ".", "_search_terms", ")", ">", "0", "return", "super", "(", "SearchableQuerySet",...
Mark the filter as being ordered if search has occurred.
[ "Mark", "the", "filter", "as", "being", "ordered", "if", "search", "has", "occurred", "." ]
2921b706b7107c6e8c5f2bbf790ff11f85a2167f
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/managers.py#L182-L188
251,761
minhhoit/yacms
yacms/core/managers.py
SearchableQuerySet.iterator
def iterator(self): """ If search has occurred and no ordering has occurred, decorate each result with the number of search terms so that it can be sorted by the number of occurrence of terms. In the case of search fields that span model relationships, we cannot accurate...
python
def iterator(self): """ If search has occurred and no ordering has occurred, decorate each result with the number of search terms so that it can be sorted by the number of occurrence of terms. In the case of search fields that span model relationships, we cannot accurate...
[ "def", "iterator", "(", "self", ")", ":", "results", "=", "super", "(", "SearchableQuerySet", ",", "self", ")", ".", "iterator", "(", ")", "if", "self", ".", "_search_terms", "and", "not", "self", ".", "_search_ordered", ":", "results", "=", "list", "(",...
If search has occurred and no ordering has occurred, decorate each result with the number of search terms so that it can be sorted by the number of occurrence of terms. In the case of search fields that span model relationships, we cannot accurately match occurrences without some very ...
[ "If", "search", "has", "occurred", "and", "no", "ordering", "has", "occurred", "decorate", "each", "result", "with", "the", "number", "of", "search", "terms", "so", "that", "it", "can", "be", "sorted", "by", "the", "number", "of", "occurrence", "of", "term...
2921b706b7107c6e8c5f2bbf790ff11f85a2167f
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/managers.py#L190-L221
251,762
minhhoit/yacms
yacms/core/managers.py
SearchableManager.get_search_fields
def get_search_fields(self): """ Returns the search field names mapped to weights as a dict. Used in ``get_queryset`` below to tell ``SearchableQuerySet`` which search fields to use. Also used by ``DisplayableAdmin`` to populate Django admin's ``search_fields`` attribute. ...
python
def get_search_fields(self): """ Returns the search field names mapped to weights as a dict. Used in ``get_queryset`` below to tell ``SearchableQuerySet`` which search fields to use. Also used by ``DisplayableAdmin`` to populate Django admin's ``search_fields`` attribute. ...
[ "def", "get_search_fields", "(", "self", ")", ":", "search_fields", "=", "self", ".", "_search_fields", ".", "copy", "(", ")", "if", "not", "search_fields", ":", "for", "cls", "in", "reversed", "(", "self", ".", "model", ".", "__mro__", ")", ":", "super_...
Returns the search field names mapped to weights as a dict. Used in ``get_queryset`` below to tell ``SearchableQuerySet`` which search fields to use. Also used by ``DisplayableAdmin`` to populate Django admin's ``search_fields`` attribute. Search fields can be populated via ``Se...
[ "Returns", "the", "search", "field", "names", "mapped", "to", "weights", "as", "a", "dict", ".", "Used", "in", "get_queryset", "below", "to", "tell", "SearchableQuerySet", "which", "search", "fields", "to", "use", ".", "Also", "used", "by", "DisplayableAdmin",...
2921b706b7107c6e8c5f2bbf790ff11f85a2167f
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/managers.py#L236-L269
251,763
minhhoit/yacms
yacms/core/managers.py
SearchableManager.contribute_to_class
def contribute_to_class(self, model, name): """ Newer versions of Django explicitly prevent managers being accessed from abstract classes, which is behaviour the search API has always relied on. Here we reinstate it. """ super(SearchableManager, self).contribute_to_class(...
python
def contribute_to_class(self, model, name): """ Newer versions of Django explicitly prevent managers being accessed from abstract classes, which is behaviour the search API has always relied on. Here we reinstate it. """ super(SearchableManager, self).contribute_to_class(...
[ "def", "contribute_to_class", "(", "self", ",", "model", ",", "name", ")", ":", "super", "(", "SearchableManager", ",", "self", ")", ".", "contribute_to_class", "(", "model", ",", "name", ")", "setattr", "(", "model", ",", "name", ",", "ManagerDescriptor", ...
Newer versions of Django explicitly prevent managers being accessed from abstract classes, which is behaviour the search API has always relied on. Here we reinstate it.
[ "Newer", "versions", "of", "Django", "explicitly", "prevent", "managers", "being", "accessed", "from", "abstract", "classes", "which", "is", "behaviour", "the", "search", "API", "has", "always", "relied", "on", ".", "Here", "we", "reinstate", "it", "." ]
2921b706b7107c6e8c5f2bbf790ff11f85a2167f
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/managers.py#L275-L282
251,764
minhhoit/yacms
yacms/core/managers.py
SearchableManager.search
def search(self, *args, **kwargs): """ Proxy to queryset's search method for the manager's model and any models that subclass from this manager's model if the model is abstract. """ if not settings.SEARCH_MODEL_CHOICES: # No choices defined - build a list of l...
python
def search(self, *args, **kwargs): """ Proxy to queryset's search method for the manager's model and any models that subclass from this manager's model if the model is abstract. """ if not settings.SEARCH_MODEL_CHOICES: # No choices defined - build a list of l...
[ "def", "search", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "settings", ".", "SEARCH_MODEL_CHOICES", ":", "# No choices defined - build a list of leaf models (those", "# without subclasses) that inherit from Displayable.", "models", "="...
Proxy to queryset's search method for the manager's model and any models that subclass from this manager's model if the model is abstract.
[ "Proxy", "to", "queryset", "s", "search", "method", "for", "the", "manager", "s", "model", "and", "any", "models", "that", "subclass", "from", "this", "manager", "s", "model", "if", "the", "model", "is", "abstract", "." ]
2921b706b7107c6e8c5f2bbf790ff11f85a2167f
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/managers.py#L284-L355
251,765
minhhoit/yacms
yacms/core/managers.py
DisplayableManager.url_map
def url_map(self, for_user=None, **kwargs): """ Returns a dictionary of urls mapped to Displayable subclass instances, including a fake homepage instance if none exists. Used in ``yacms.core.sitemaps``. """ class Home: title = _("Home") home = Home() ...
python
def url_map(self, for_user=None, **kwargs): """ Returns a dictionary of urls mapped to Displayable subclass instances, including a fake homepage instance if none exists. Used in ``yacms.core.sitemaps``. """ class Home: title = _("Home") home = Home() ...
[ "def", "url_map", "(", "self", ",", "for_user", "=", "None", ",", "*", "*", "kwargs", ")", ":", "class", "Home", ":", "title", "=", "_", "(", "\"Home\"", ")", "home", "=", "Home", "(", ")", "setattr", "(", "home", ",", "\"get_absolute_url\"", ",", ...
Returns a dictionary of urls mapped to Displayable subclass instances, including a fake homepage instance if none exists. Used in ``yacms.core.sitemaps``.
[ "Returns", "a", "dictionary", "of", "urls", "mapped", "to", "Displayable", "subclass", "instances", "including", "a", "fake", "homepage", "instance", "if", "none", "exists", ".", "Used", "in", "yacms", ".", "core", ".", "sitemaps", "." ]
2921b706b7107c6e8c5f2bbf790ff11f85a2167f
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/managers.py#L390-L408
251,766
vecnet/vecnet.simulation
vecnet/simulation/sim_model.py
get_name
def get_name(model_id): """ Get the name for a model. :returns str: The model's name. If the id has no associated name, then "id = {ID} (no name)" is returned. """ name = _names.get(model_id) if name is None: name = 'id = %s (no name)' % str(model_id) return name
python
def get_name(model_id): """ Get the name for a model. :returns str: The model's name. If the id has no associated name, then "id = {ID} (no name)" is returned. """ name = _names.get(model_id) if name is None: name = 'id = %s (no name)' % str(model_id) return name
[ "def", "get_name", "(", "model_id", ")", ":", "name", "=", "_names", ".", "get", "(", "model_id", ")", "if", "name", "is", "None", ":", "name", "=", "'id = %s (no name)'", "%", "str", "(", "model_id", ")", "return", "name" ]
Get the name for a model. :returns str: The model's name. If the id has no associated name, then "id = {ID} (no name)" is returned.
[ "Get", "the", "name", "for", "a", "model", "." ]
3a4b3df7b12418c6fa8a7d9cd49656a1c031fc0e
https://github.com/vecnet/vecnet.simulation/blob/3a4b3df7b12418c6fa8a7d9cd49656a1c031fc0e/vecnet/simulation/sim_model.py#L51-L60
251,767
eisensheng/kaviar
kaviar/adapter.py
KvLoggerAdapter.define_logger_func
def define_logger_func(self, level, field_names, default=NO_DEFAULT, filters=None, include_exc_info=False): """Define a new logger function that will log the given arguments with the given predefined keys. :param level: The log level to use for each call. ...
python
def define_logger_func(self, level, field_names, default=NO_DEFAULT, filters=None, include_exc_info=False): """Define a new logger function that will log the given arguments with the given predefined keys. :param level: The log level to use for each call. ...
[ "def", "define_logger_func", "(", "self", ",", "level", ",", "field_names", ",", "default", "=", "NO_DEFAULT", ",", "filters", "=", "None", ",", "include_exc_info", "=", "False", ")", ":", "kv_formatter", "=", "KvFormatter", "(", "field_names", ",", "default",...
Define a new logger function that will log the given arguments with the given predefined keys. :param level: The log level to use for each call. :param field_names: Set of predefined keys. :param default: A default value for each key. :param f...
[ "Define", "a", "new", "logger", "function", "that", "will", "log", "the", "given", "arguments", "with", "the", "given", "predefined", "keys", "." ]
77ab934a3dd7b1cfabc0ec96acc0b8ed26edcb3f
https://github.com/eisensheng/kaviar/blob/77ab934a3dd7b1cfabc0ec96acc0b8ed26edcb3f/kaviar/adapter.py#L71-L93
251,768
eisensheng/kaviar
kaviar/adapter.py
KvLoggerAdapter.log
def log(self, level, *args, **kwargs): """Delegate a log call to the underlying logger.""" return self._log_kw(level, args, kwargs)
python
def log(self, level, *args, **kwargs): """Delegate a log call to the underlying logger.""" return self._log_kw(level, args, kwargs)
[ "def", "log", "(", "self", ",", "level", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_log_kw", "(", "level", ",", "args", ",", "kwargs", ")" ]
Delegate a log call to the underlying logger.
[ "Delegate", "a", "log", "call", "to", "the", "underlying", "logger", "." ]
77ab934a3dd7b1cfabc0ec96acc0b8ed26edcb3f
https://github.com/eisensheng/kaviar/blob/77ab934a3dd7b1cfabc0ec96acc0b8ed26edcb3f/kaviar/adapter.py#L95-L97
251,769
eisensheng/kaviar
kaviar/adapter.py
KvLoggerAdapter.exception
def exception(self, *args, **kwargs): """Delegate a exception call to the underlying logger.""" return self._log_kw(ERROR, args, kwargs, exc_info=True)
python
def exception(self, *args, **kwargs): """Delegate a exception call to the underlying logger.""" return self._log_kw(ERROR, args, kwargs, exc_info=True)
[ "def", "exception", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_log_kw", "(", "ERROR", ",", "args", ",", "kwargs", ",", "exc_info", "=", "True", ")" ]
Delegate a exception call to the underlying logger.
[ "Delegate", "a", "exception", "call", "to", "the", "underlying", "logger", "." ]
77ab934a3dd7b1cfabc0ec96acc0b8ed26edcb3f
https://github.com/eisensheng/kaviar/blob/77ab934a3dd7b1cfabc0ec96acc0b8ed26edcb3f/kaviar/adapter.py#L115-L117
251,770
eagleamon/pynetio
pynetio.py
Netio.update
def update(self): """ Update all the switch values """ self.states = [bool(int(x)) for x in self.get('port list') or '0000']
python
def update(self): """ Update all the switch values """ self.states = [bool(int(x)) for x in self.get('port list') or '0000']
[ "def", "update", "(", "self", ")", ":", "self", ".", "states", "=", "[", "bool", "(", "int", "(", "x", ")", ")", "for", "x", "in", "self", ".", "get", "(", "'port list'", ")", "or", "'0000'", "]" ]
Update all the switch values
[ "Update", "all", "the", "switch", "values" ]
3bc212cae18608de0214b964e395877d3ca4aa7b
https://github.com/eagleamon/pynetio/blob/3bc212cae18608de0214b964e395877d3ca4aa7b/pynetio.py#L46-L49
251,771
hmpf/dataporten-auth
src/dataporten/psa.py
DataportenOAuth2.check_correct_audience
def check_correct_audience(self, audience): "Assert that Dataporten sends back our own client id as audience" client_id, _ = self.get_key_and_secret() if audience != client_id: raise AuthException('Wrong audience')
python
def check_correct_audience(self, audience): "Assert that Dataporten sends back our own client id as audience" client_id, _ = self.get_key_and_secret() if audience != client_id: raise AuthException('Wrong audience')
[ "def", "check_correct_audience", "(", "self", ",", "audience", ")", ":", "client_id", ",", "_", "=", "self", ".", "get_key_and_secret", "(", ")", "if", "audience", "!=", "client_id", ":", "raise", "AuthException", "(", "'Wrong audience'", ")" ]
Assert that Dataporten sends back our own client id as audience
[ "Assert", "that", "Dataporten", "sends", "back", "our", "own", "client", "id", "as", "audience" ]
bc2ff5e11a1fce2c3d7bffe3f2b513bd7e2c0fcc
https://github.com/hmpf/dataporten-auth/blob/bc2ff5e11a1fce2c3d7bffe3f2b513bd7e2c0fcc/src/dataporten/psa.py#L52-L56
251,772
alexhayes/django-toolkit
django_toolkit/fields.py
ChoiceHumanReadable
def ChoiceHumanReadable(choices, choice): """ Return the human readable representation for a list of choices. @see https://docs.djangoproject.com/en/dev/ref/models/fields/#choices """ if choice == None: raise NoChoiceError() for _choice in choices: if _choice[0] == choice: ...
python
def ChoiceHumanReadable(choices, choice): """ Return the human readable representation for a list of choices. @see https://docs.djangoproject.com/en/dev/ref/models/fields/#choices """ if choice == None: raise NoChoiceError() for _choice in choices: if _choice[0] == choice: ...
[ "def", "ChoiceHumanReadable", "(", "choices", ",", "choice", ")", ":", "if", "choice", "==", "None", ":", "raise", "NoChoiceError", "(", ")", "for", "_choice", "in", "choices", ":", "if", "_choice", "[", "0", "]", "==", "choice", ":", "return", "_choice"...
Return the human readable representation for a list of choices. @see https://docs.djangoproject.com/en/dev/ref/models/fields/#choices
[ "Return", "the", "human", "readable", "representation", "for", "a", "list", "of", "choices", "." ]
b64106392fad596defc915b8235fe6e1d0013b5b
https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/fields.py#L15-L25
251,773
alexhayes/django-toolkit
django_toolkit/fields.py
SeparatedValuesField.get_db_prep_value
def get_db_prep_value(self, value, connection=None, prepared=False): """Returns field's value prepared for interacting with the database backend. Used by the default implementations of ``get_db_prep_save``and `get_db_prep_lookup``` """ if not value: return ...
python
def get_db_prep_value(self, value, connection=None, prepared=False): """Returns field's value prepared for interacting with the database backend. Used by the default implementations of ``get_db_prep_save``and `get_db_prep_lookup``` """ if not value: return ...
[ "def", "get_db_prep_value", "(", "self", ",", "value", ",", "connection", "=", "None", ",", "prepared", "=", "False", ")", ":", "if", "not", "value", ":", "return", "if", "prepared", ":", "return", "value", "else", ":", "assert", "(", "isinstance", "(", ...
Returns field's value prepared for interacting with the database backend. Used by the default implementations of ``get_db_prep_save``and `get_db_prep_lookup```
[ "Returns", "field", "s", "value", "prepared", "for", "interacting", "with", "the", "database", "backend", "." ]
b64106392fad596defc915b8235fe6e1d0013b5b
https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/fields.py#L58-L71
251,774
jmgilman/Neolib
neolib/user/SDB.py
SDB.load
def load(self): """ Loads the user's SDB inventory Raises parseException """ self.inventory = SDBInventory(self.usr) self.forms = self.inventory.forms
python
def load(self): """ Loads the user's SDB inventory Raises parseException """ self.inventory = SDBInventory(self.usr) self.forms = self.inventory.forms
[ "def", "load", "(", "self", ")", ":", "self", ".", "inventory", "=", "SDBInventory", "(", "self", ".", "usr", ")", "self", ".", "forms", "=", "self", ".", "inventory", ".", "forms" ]
Loads the user's SDB inventory Raises parseException
[ "Loads", "the", "user", "s", "SDB", "inventory", "Raises", "parseException" ]
228fafeaed0f3195676137732384a14820ae285c
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/user/SDB.py#L43-L50
251,775
jmgilman/Neolib
neolib/user/SDB.py
SDB.update
def update(self): """ Upates the user's SDB inventory Loops through all items on a page and checks for an item that has changed. A changed item is identified as the remove attribute being set to anything greater than 0. It will then update each page accordingly with the ...
python
def update(self): """ Upates the user's SDB inventory Loops through all items on a page and checks for an item that has changed. A changed item is identified as the remove attribute being set to anything greater than 0. It will then update each page accordingly with the ...
[ "def", "update", "(", "self", ")", ":", "for", "x", "in", "range", "(", "1", ",", "self", ".", "inventory", ".", "pages", "+", "1", ")", ":", "if", "self", ".", "_hasPageChanged", "(", "x", ")", ":", "form", "=", "self", ".", "_updateForm", "(", ...
Upates the user's SDB inventory Loops through all items on a page and checks for an item that has changed. A changed item is identified as the remove attribute being set to anything greater than 0. It will then update each page accordingly with the changed items. ...
[ "Upates", "the", "user", "s", "SDB", "inventory", "Loops", "through", "all", "items", "on", "a", "page", "and", "checks", "for", "an", "item", "that", "has", "changed", ".", "A", "changed", "item", "is", "identified", "as", "the", "remove", "attribute", ...
228fafeaed0f3195676137732384a14820ae285c
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/user/SDB.py#L52-L74
251,776
tempodb/tempodb-python
tempodb/client.py
make_series_url
def make_series_url(key): """For internal use. Given a series key, generate a valid URL to the series endpoint for that key. :param string key: the series key :rtype: string""" url = urlparse.urljoin(endpoint.SERIES_ENDPOINT, 'key/') url = urlparse.urljoin(url, urllib.quote(key)) return ur...
python
def make_series_url(key): """For internal use. Given a series key, generate a valid URL to the series endpoint for that key. :param string key: the series key :rtype: string""" url = urlparse.urljoin(endpoint.SERIES_ENDPOINT, 'key/') url = urlparse.urljoin(url, urllib.quote(key)) return ur...
[ "def", "make_series_url", "(", "key", ")", ":", "url", "=", "urlparse", ".", "urljoin", "(", "endpoint", ".", "SERIES_ENDPOINT", ",", "'key/'", ")", "url", "=", "urlparse", ".", "urljoin", "(", "url", ",", "urllib", ".", "quote", "(", "key", ")", ")", ...
For internal use. Given a series key, generate a valid URL to the series endpoint for that key. :param string key: the series key :rtype: string
[ "For", "internal", "use", ".", "Given", "a", "series", "key", "generate", "a", "valid", "URL", "to", "the", "series", "endpoint", "for", "that", "key", "." ]
8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3
https://github.com/tempodb/tempodb-python/blob/8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3/tempodb/client.py#L11-L20
251,777
tempodb/tempodb-python
tempodb/client.py
Client.create_series
def create_series(self, key=None, tags=[], attrs={}): """Create a new series with an optional string key. A list of tags and a map of attributes can also be optionally supplied. :param string key: (optional) a string key for the series :param list tags: (optional) the tags to create th...
python
def create_series(self, key=None, tags=[], attrs={}): """Create a new series with an optional string key. A list of tags and a map of attributes can also be optionally supplied. :param string key: (optional) a string key for the series :param list tags: (optional) the tags to create th...
[ "def", "create_series", "(", "self", ",", "key", "=", "None", ",", "tags", "=", "[", "]", ",", "attrs", "=", "{", "}", ")", ":", "body", "=", "protocol", ".", "make_series_key", "(", "key", ",", "tags", ",", "attrs", ")", "resp", "=", "self", "."...
Create a new series with an optional string key. A list of tags and a map of attributes can also be optionally supplied. :param string key: (optional) a string key for the series :param list tags: (optional) the tags to create the series with :param dict attrs: (optional) the attribute...
[ "Create", "a", "new", "series", "with", "an", "optional", "string", "key", ".", "A", "list", "of", "tags", "and", "a", "map", "of", "attributes", "can", "also", "be", "optionally", "supplied", "." ]
8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3
https://github.com/tempodb/tempodb-python/blob/8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3/tempodb/client.py#L133-L145
251,778
tempodb/tempodb-python
tempodb/client.py
Client.delete_series
def delete_series(self, keys=None, tags=None, attrs=None, allow_truncation=False): """Delete a series according to the given criteria. **Note:** for the key argument, the filter will return the *union* of those values. For the tag and attr arguments, the filter will retur...
python
def delete_series(self, keys=None, tags=None, attrs=None, allow_truncation=False): """Delete a series according to the given criteria. **Note:** for the key argument, the filter will return the *union* of those values. For the tag and attr arguments, the filter will retur...
[ "def", "delete_series", "(", "self", ",", "keys", "=", "None", ",", "tags", "=", "None", ",", "attrs", "=", "None", ",", "allow_truncation", "=", "False", ")", ":", "params", "=", "{", "'key'", ":", "keys", ",", "'tag'", ":", "tags", ",", "'attr'", ...
Delete a series according to the given criteria. **Note:** for the key argument, the filter will return the *union* of those values. For the tag and attr arguments, the filter will return the *intersection* of those values. :param keys: filter by one or more series keys :type ...
[ "Delete", "a", "series", "according", "to", "the", "given", "criteria", "." ]
8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3
https://github.com/tempodb/tempodb-python/blob/8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3/tempodb/client.py#L148-L174
251,779
tempodb/tempodb-python
tempodb/client.py
Client.get_series
def get_series(self, key): """Get a series object from TempoDB given its key. :param string key: a string name for the series :rtype: :class:`tempodb.response.Response` with a :class:`tempodb.protocol.objects.Series` data payload""" url = make_series_url(key) re...
python
def get_series(self, key): """Get a series object from TempoDB given its key. :param string key: a string name for the series :rtype: :class:`tempodb.response.Response` with a :class:`tempodb.protocol.objects.Series` data payload""" url = make_series_url(key) re...
[ "def", "get_series", "(", "self", ",", "key", ")", ":", "url", "=", "make_series_url", "(", "key", ")", "resp", "=", "self", ".", "session", ".", "get", "(", "url", ")", "return", "resp" ]
Get a series object from TempoDB given its key. :param string key: a string name for the series :rtype: :class:`tempodb.response.Response` with a :class:`tempodb.protocol.objects.Series` data payload
[ "Get", "a", "series", "object", "from", "TempoDB", "given", "its", "key", "." ]
8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3
https://github.com/tempodb/tempodb-python/blob/8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3/tempodb/client.py#L177-L186
251,780
tempodb/tempodb-python
tempodb/client.py
Client.list_series
def list_series(self, keys=None, tags=None, attrs=None, limit=1000): """Get a list of all series matching the given criteria. **Note:** for the key argument, the filter will return the *union* of those values. For the tag and attr arguments, the filter will return t...
python
def list_series(self, keys=None, tags=None, attrs=None, limit=1000): """Get a list of all series matching the given criteria. **Note:** for the key argument, the filter will return the *union* of those values. For the tag and attr arguments, the filter will return t...
[ "def", "list_series", "(", "self", ",", "keys", "=", "None", ",", "tags", "=", "None", ",", "attrs", "=", "None", ",", "limit", "=", "1000", ")", ":", "params", "=", "{", "'key'", ":", "keys", ",", "'tag'", ":", "tags", ",", "'attr'", ":", "attrs...
Get a list of all series matching the given criteria. **Note:** for the key argument, the filter will return the *union* of those values. For the tag and attr arguments, the filter will return the *intersection* of those values. :param keys: filter by one or more series keys :...
[ "Get", "a", "list", "of", "all", "series", "matching", "the", "given", "criteria", "." ]
8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3
https://github.com/tempodb/tempodb-python/blob/8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3/tempodb/client.py#L189-L215
251,781
tempodb/tempodb-python
tempodb/client.py
Client.aggregate_data
def aggregate_data(self, start, end, aggregation, keys=[], tags=[], attrs={}, rollup=None, period=None, interpolationf=None, interpolation_period=None, tz=None, limit=1000): """Read data from multiple series according to a filter and apply a function across ...
python
def aggregate_data(self, start, end, aggregation, keys=[], tags=[], attrs={}, rollup=None, period=None, interpolationf=None, interpolation_period=None, tz=None, limit=1000): """Read data from multiple series according to a filter and apply a function across ...
[ "def", "aggregate_data", "(", "self", ",", "start", ",", "end", ",", "aggregation", ",", "keys", "=", "[", "]", ",", "tags", "=", "[", "]", ",", "attrs", "=", "{", "}", ",", "rollup", "=", "None", ",", "period", "=", "None", ",", "interpolationf", ...
Read data from multiple series according to a filter and apply a function across all the returned series to put the datapoints together into one aggregrate series. See the :meth:`list_series` method for a description of how the filter criteria are applied, and the :meth:`read_data` meth...
[ "Read", "data", "from", "multiple", "series", "according", "to", "a", "filter", "and", "apply", "a", "function", "across", "all", "the", "returned", "series", "to", "put", "the", "datapoints", "together", "into", "one", "aggregrate", "series", "." ]
8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3
https://github.com/tempodb/tempodb-python/blob/8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3/tempodb/client.py#L433-L489
251,782
tempodb/tempodb-python
tempodb/client.py
Client.write_data
def write_data(self, key, data, tags=[], attrs={}): """Write a set a datapoints into a series by its key. For now, the tags and attributes arguments are ignored. :param string key: the series to write data into :param list data: a list of DataPoints to write :rtype: :class:`tem...
python
def write_data(self, key, data, tags=[], attrs={}): """Write a set a datapoints into a series by its key. For now, the tags and attributes arguments are ignored. :param string key: the series to write data into :param list data: a list of DataPoints to write :rtype: :class:`tem...
[ "def", "write_data", "(", "self", ",", "key", ",", "data", ",", "tags", "=", "[", "]", ",", "attrs", "=", "{", "}", ")", ":", "url", "=", "make_series_url", "(", "key", ")", "url", "=", "urlparse", ".", "urljoin", "(", "url", "+", "'/'", ",", "...
Write a set a datapoints into a series by its key. For now, the tags and attributes arguments are ignored. :param string key: the series to write data into :param list data: a list of DataPoints to write :rtype: :class:`tempodb.response.Response` object
[ "Write", "a", "set", "a", "datapoints", "into", "a", "series", "by", "its", "key", ".", "For", "now", "the", "tags", "and", "attributes", "arguments", "are", "ignored", "." ]
8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3
https://github.com/tempodb/tempodb-python/blob/8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3/tempodb/client.py#L545-L568
251,783
tempodb/tempodb-python
tempodb/client.py
Client.single_value
def single_value(self, key, ts=None, direction=None): """Return a single value for a series. You can supply a timestamp as the ts argument, otherwise the search defaults to the current time. The direction argument can be one of "exact", "before", "after", or "nearest". ...
python
def single_value(self, key, ts=None, direction=None): """Return a single value for a series. You can supply a timestamp as the ts argument, otherwise the search defaults to the current time. The direction argument can be one of "exact", "before", "after", or "nearest". ...
[ "def", "single_value", "(", "self", ",", "key", ",", "ts", "=", "None", ",", "direction", "=", "None", ")", ":", "url", "=", "make_series_url", "(", "key", ")", "url", "=", "urlparse", ".", "urljoin", "(", "url", "+", "'/'", ",", "'single'", ")", "...
Return a single value for a series. You can supply a timestamp as the ts argument, otherwise the search defaults to the current time. The direction argument can be one of "exact", "before", "after", or "nearest". :param string key: the key for the series to use :param ...
[ "Return", "a", "single", "value", "for", "a", "series", ".", "You", "can", "supply", "a", "timestamp", "as", "the", "ts", "argument", "otherwise", "the", "search", "defaults", "to", "the", "current", "time", "." ]
8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3
https://github.com/tempodb/tempodb-python/blob/8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3/tempodb/client.py#L621-L653
251,784
tempodb/tempodb-python
tempodb/client.py
Client.multi_series_single_value
def multi_series_single_value(self, keys=None, ts=None, direction=None, attrs={}, tags=[]): """Return a single value for multiple series. You can supply a timestamp as the ts argument, otherwise the search defaults to the current time. The direction ar...
python
def multi_series_single_value(self, keys=None, ts=None, direction=None, attrs={}, tags=[]): """Return a single value for multiple series. You can supply a timestamp as the ts argument, otherwise the search defaults to the current time. The direction ar...
[ "def", "multi_series_single_value", "(", "self", ",", "keys", "=", "None", ",", "ts", "=", "None", ",", "direction", "=", "None", ",", "attrs", "=", "{", "}", ",", "tags", "=", "[", "]", ")", ":", "url", "=", "'single/'", "if", "ts", "is", "not", ...
Return a single value for multiple series. You can supply a timestamp as the ts argument, otherwise the search defaults to the current time. The direction argument can be one of "exact", "before", "after", or "nearest". The id, key, tag, and attr arguments allow you to filter ...
[ "Return", "a", "single", "value", "for", "multiple", "series", ".", "You", "can", "supply", "a", "timestamp", "as", "the", "ts", "argument", "otherwise", "the", "search", "defaults", "to", "the", "current", "time", "." ]
8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3
https://github.com/tempodb/tempodb-python/blob/8ce45231bd728c6c97ef799cf0f1513ea3a9a7d3/tempodb/client.py#L656-L696
251,785
rorr73/LifeSOSpy
lifesospy/client.py
Client.async_open
async def async_open(self) -> None: """Opens connection to the LifeSOS ethernet interface.""" await self._loop.create_connection( lambda: self, self._host, self._port)
python
async def async_open(self) -> None: """Opens connection to the LifeSOS ethernet interface.""" await self._loop.create_connection( lambda: self, self._host, self._port)
[ "async", "def", "async_open", "(", "self", ")", "->", "None", ":", "await", "self", ".", "_loop", ".", "create_connection", "(", "lambda", ":", "self", ",", "self", ".", "_host", ",", "self", ".", "_port", ")" ]
Opens connection to the LifeSOS ethernet interface.
[ "Opens", "connection", "to", "the", "LifeSOS", "ethernet", "interface", "." ]
62360fbab2e90bf04d52b547093bdab2d4e389b4
https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/client.py#L44-L50
251,786
jeroyang/cateye
cateye/cateye.py
load_abbr
def load_abbr(abbr_file=ABBREVIATION_FILE): """ Load the abbr2long from file """ abbr2long = dict() with open(abbr_file) as f: lines = f.read().split('\n') for line in lines: m = re.match(r'(\w+)\t(.+)', line) if m: abbr2long[m.group(1)] = m.gr...
python
def load_abbr(abbr_file=ABBREVIATION_FILE): """ Load the abbr2long from file """ abbr2long = dict() with open(abbr_file) as f: lines = f.read().split('\n') for line in lines: m = re.match(r'(\w+)\t(.+)', line) if m: abbr2long[m.group(1)] = m.gr...
[ "def", "load_abbr", "(", "abbr_file", "=", "ABBREVIATION_FILE", ")", ":", "abbr2long", "=", "dict", "(", ")", "with", "open", "(", "abbr_file", ")", "as", "f", ":", "lines", "=", "f", ".", "read", "(", ")", ".", "split", "(", "'\\n'", ")", "for", "...
Load the abbr2long from file
[ "Load", "the", "abbr2long", "from", "file" ]
8f181d6428d113d2928e3eb31703705ce0779eae
https://github.com/jeroyang/cateye/blob/8f181d6428d113d2928e3eb31703705ce0779eae/cateye/cateye.py#L17-L28
251,787
jeroyang/cateye
cateye/cateye.py
load_spelling
def load_spelling(spell_file=SPELLING_FILE): """ Load the term_freq from spell_file """ with open(spell_file) as f: tokens = f.read().split('\n') size = len(tokens) term_freq = {token: size - i for i, token in enumerate(tokens)} return term_freq
python
def load_spelling(spell_file=SPELLING_FILE): """ Load the term_freq from spell_file """ with open(spell_file) as f: tokens = f.read().split('\n') size = len(tokens) term_freq = {token: size - i for i, token in enumerate(tokens)} return term_freq
[ "def", "load_spelling", "(", "spell_file", "=", "SPELLING_FILE", ")", ":", "with", "open", "(", "spell_file", ")", "as", "f", ":", "tokens", "=", "f", ".", "read", "(", ")", ".", "split", "(", "'\\n'", ")", "size", "=", "len", "(", "tokens", ")", "...
Load the term_freq from spell_file
[ "Load", "the", "term_freq", "from", "spell_file" ]
8f181d6428d113d2928e3eb31703705ce0779eae
https://github.com/jeroyang/cateye/blob/8f181d6428d113d2928e3eb31703705ce0779eae/cateye/cateye.py#L31-L39
251,788
jeroyang/cateye
cateye/cateye.py
load_search_freq
def load_search_freq(fp=SEARCH_FREQ_JSON): """ Load the search_freq from JSON file """ try: with open(fp) as f: return Counter(json.load(f)) except FileNotFoundError: return Counter()
python
def load_search_freq(fp=SEARCH_FREQ_JSON): """ Load the search_freq from JSON file """ try: with open(fp) as f: return Counter(json.load(f)) except FileNotFoundError: return Counter()
[ "def", "load_search_freq", "(", "fp", "=", "SEARCH_FREQ_JSON", ")", ":", "try", ":", "with", "open", "(", "fp", ")", "as", "f", ":", "return", "Counter", "(", "json", ".", "load", "(", "f", ")", ")", "except", "FileNotFoundError", ":", "return", "Count...
Load the search_freq from JSON file
[ "Load", "the", "search_freq", "from", "JSON", "file" ]
8f181d6428d113d2928e3eb31703705ce0779eae
https://github.com/jeroyang/cateye/blob/8f181d6428d113d2928e3eb31703705ce0779eae/cateye/cateye.py#L41-L49
251,789
jeroyang/cateye
cateye/cateye.py
tokenize
def tokenize(s): """ A simple tokneizer """ s = re.sub(r'(?a)(\w+)\'s', r'\1', s) # clean the 's from Crohn's disease #s = re.sub(r'(?a)\b', ' ', s) # split the borders of chinese and english chars split_pattern = r'[{} ]+'.format(re.escape(STOPCHARS)) tokens = [token for token in re.split(...
python
def tokenize(s): """ A simple tokneizer """ s = re.sub(r'(?a)(\w+)\'s', r'\1', s) # clean the 's from Crohn's disease #s = re.sub(r'(?a)\b', ' ', s) # split the borders of chinese and english chars split_pattern = r'[{} ]+'.format(re.escape(STOPCHARS)) tokens = [token for token in re.split(...
[ "def", "tokenize", "(", "s", ")", ":", "s", "=", "re", ".", "sub", "(", "r'(?a)(\\w+)\\'s'", ",", "r'\\1'", ",", "s", ")", "# clean the 's from Crohn's disease", "#s = re.sub(r'(?a)\\b', ' ', s) # split the borders of chinese and english chars", "split_pattern", "=", "r'[...
A simple tokneizer
[ "A", "simple", "tokneizer" ]
8f181d6428d113d2928e3eb31703705ce0779eae
https://github.com/jeroyang/cateye/blob/8f181d6428d113d2928e3eb31703705ce0779eae/cateye/cateye.py#L71-L80
251,790
jeroyang/cateye
cateye/cateye.py
write_spelling
def write_spelling(token_folder, spelling_file): """ Generate the spelling correction file form token_folder and save to spelling_file """ token_pattern = r'[a-z]{3,}' tokens = [] for base, dirlist, fnlist in os.walk(token_folder): for fn in fnlist: fp = os.path.join(base, fn...
python
def write_spelling(token_folder, spelling_file): """ Generate the spelling correction file form token_folder and save to spelling_file """ token_pattern = r'[a-z]{3,}' tokens = [] for base, dirlist, fnlist in os.walk(token_folder): for fn in fnlist: fp = os.path.join(base, fn...
[ "def", "write_spelling", "(", "token_folder", ",", "spelling_file", ")", ":", "token_pattern", "=", "r'[a-z]{3,}'", "tokens", "=", "[", "]", "for", "base", ",", "dirlist", ",", "fnlist", "in", "os", ".", "walk", "(", "token_folder", ")", ":", "for", "fn", ...
Generate the spelling correction file form token_folder and save to spelling_file
[ "Generate", "the", "spelling", "correction", "file", "form", "token_folder", "and", "save", "to", "spelling_file" ]
8f181d6428d113d2928e3eb31703705ce0779eae
https://github.com/jeroyang/cateye/blob/8f181d6428d113d2928e3eb31703705ce0779eae/cateye/cateye.py#L121-L136
251,791
jeroyang/cateye
cateye/cateye.py
get_hints
def get_hints(code_list, k=10, hint_folder=HINT_FOLDER, current_tokens=None): """ Fetch first k hints for given code_list """ def hint_score(v, size): """ The formula for hint score """ return 1.0 - abs(v / (size + 1) - 0.5) if len(code_list) <= 1: return []...
python
def get_hints(code_list, k=10, hint_folder=HINT_FOLDER, current_tokens=None): """ Fetch first k hints for given code_list """ def hint_score(v, size): """ The formula for hint score """ return 1.0 - abs(v / (size + 1) - 0.5) if len(code_list) <= 1: return []...
[ "def", "get_hints", "(", "code_list", ",", "k", "=", "10", ",", "hint_folder", "=", "HINT_FOLDER", ",", "current_tokens", "=", "None", ")", ":", "def", "hint_score", "(", "v", ",", "size", ")", ":", "\"\"\"\n The formula for hint score\n \"\"\"", "...
Fetch first k hints for given code_list
[ "Fetch", "first", "k", "hints", "for", "given", "code_list" ]
8f181d6428d113d2928e3eb31703705ce0779eae
https://github.com/jeroyang/cateye/blob/8f181d6428d113d2928e3eb31703705ce0779eae/cateye/cateye.py#L138-L177
251,792
jeroyang/cateye
cateye/cateye.py
fetch
def fetch(index, tokens): """ Fetch the codes from given tokens """ if len(tokens) == 0: return set() return set.intersection(*[set(index.get(token, [])) for token in tokens])
python
def fetch(index, tokens): """ Fetch the codes from given tokens """ if len(tokens) == 0: return set() return set.intersection(*[set(index.get(token, [])) for token in tokens])
[ "def", "fetch", "(", "index", ",", "tokens", ")", ":", "if", "len", "(", "tokens", ")", "==", "0", ":", "return", "set", "(", ")", "return", "set", ".", "intersection", "(", "*", "[", "set", "(", "index", ".", "get", "(", "token", ",", "[", "]"...
Fetch the codes from given tokens
[ "Fetch", "the", "codes", "from", "given", "tokens" ]
8f181d6428d113d2928e3eb31703705ce0779eae
https://github.com/jeroyang/cateye/blob/8f181d6428d113d2928e3eb31703705ce0779eae/cateye/cateye.py#L179-L185
251,793
jeroyang/cateye
cateye/cateye.py
get_snippets
def get_snippets(code_list, base=SNIPPET_FOLDER): """ Get the snippets """ output = [] for code in code_list: path = gen_path(base, code) fp = os.path.join(path, code) try: with open(fp) as f: output.append(f.read()) except FileNotFoundErro...
python
def get_snippets(code_list, base=SNIPPET_FOLDER): """ Get the snippets """ output = [] for code in code_list: path = gen_path(base, code) fp = os.path.join(path, code) try: with open(fp) as f: output.append(f.read()) except FileNotFoundErro...
[ "def", "get_snippets", "(", "code_list", ",", "base", "=", "SNIPPET_FOLDER", ")", ":", "output", "=", "[", "]", "for", "code", "in", "code_list", ":", "path", "=", "gen_path", "(", "base", ",", "code", ")", "fp", "=", "os", ".", "path", ".", "join", ...
Get the snippets
[ "Get", "the", "snippets" ]
8f181d6428d113d2928e3eb31703705ce0779eae
https://github.com/jeroyang/cateye/blob/8f181d6428d113d2928e3eb31703705ce0779eae/cateye/cateye.py#L187-L202
251,794
jeroyang/cateye
cateye/cateye.py
_ed1
def _ed1(token): """ Return tokens the edit distance of which is one from the given token """ insertion = {letter.join([token[:i], token[i:]]) for letter in string.ascii_lowercase for i in range(1, len(token) + 1)} deletion = {''.join([token[:i], token[i+1:]]) for i in range(1, len(token) + 1)} ...
python
def _ed1(token): """ Return tokens the edit distance of which is one from the given token """ insertion = {letter.join([token[:i], token[i:]]) for letter in string.ascii_lowercase for i in range(1, len(token) + 1)} deletion = {''.join([token[:i], token[i+1:]]) for i in range(1, len(token) + 1)} ...
[ "def", "_ed1", "(", "token", ")", ":", "insertion", "=", "{", "letter", ".", "join", "(", "[", "token", "[", ":", "i", "]", ",", "token", "[", "i", ":", "]", "]", ")", "for", "letter", "in", "string", ".", "ascii_lowercase", "for", "i", "in", "...
Return tokens the edit distance of which is one from the given token
[ "Return", "tokens", "the", "edit", "distance", "of", "which", "is", "one", "from", "the", "given", "token" ]
8f181d6428d113d2928e3eb31703705ce0779eae
https://github.com/jeroyang/cateye/blob/8f181d6428d113d2928e3eb31703705ce0779eae/cateye/cateye.py#L216-L224
251,795
jeroyang/cateye
cateye/cateye.py
_correct
def _correct(token, term_freq): """ Correct a single token according to the term_freq """ if token.lower() in term_freq: return token e1 = [t for t in _ed1(token) if t in term_freq] if len(e1) > 0: e1.sort(key=term_freq.get) return e1[0] e2 = [t for t in _ed2(token) i...
python
def _correct(token, term_freq): """ Correct a single token according to the term_freq """ if token.lower() in term_freq: return token e1 = [t for t in _ed1(token) if t in term_freq] if len(e1) > 0: e1.sort(key=term_freq.get) return e1[0] e2 = [t for t in _ed2(token) i...
[ "def", "_correct", "(", "token", ",", "term_freq", ")", ":", "if", "token", ".", "lower", "(", ")", "in", "term_freq", ":", "return", "token", "e1", "=", "[", "t", "for", "t", "in", "_ed1", "(", "token", ")", "if", "t", "in", "term_freq", "]", "i...
Correct a single token according to the term_freq
[ "Correct", "a", "single", "token", "according", "to", "the", "term_freq" ]
8f181d6428d113d2928e3eb31703705ce0779eae
https://github.com/jeroyang/cateye/blob/8f181d6428d113d2928e3eb31703705ce0779eae/cateye/cateye.py#L232-L246
251,796
jeroyang/cateye
cateye/cateye.py
correct
def correct(tokens, term_freq): """ Correct a list of tokens, according to the term_freq """ log = [] output = [] for token in tokens: corrected = _correct(token, term_freq) if corrected != token: log.append((token, corrected)) output.append(corrected) ret...
python
def correct(tokens, term_freq): """ Correct a list of tokens, according to the term_freq """ log = [] output = [] for token in tokens: corrected = _correct(token, term_freq) if corrected != token: log.append((token, corrected)) output.append(corrected) ret...
[ "def", "correct", "(", "tokens", ",", "term_freq", ")", ":", "log", "=", "[", "]", "output", "=", "[", "]", "for", "token", "in", "tokens", ":", "corrected", "=", "_correct", "(", "token", ",", "term_freq", ")", "if", "corrected", "!=", "token", ":",...
Correct a list of tokens, according to the term_freq
[ "Correct", "a", "list", "of", "tokens", "according", "to", "the", "term_freq" ]
8f181d6428d113d2928e3eb31703705ce0779eae
https://github.com/jeroyang/cateye/blob/8f181d6428d113d2928e3eb31703705ce0779eae/cateye/cateye.py#L248-L259
251,797
jeroyang/cateye
cateye/cateye.py
search
def search(index, query, snippet_folder=SNIPPET_FOLDER, term_freq=term_freq): """ The highest level of search function """ fallback_log = [] code_list = [] tokens = tokenize(query) tokens, abbr_log = abbr_expand(tokens) tokens, correct_log = correct(tokens, term_freq) tokens = lemmat...
python
def search(index, query, snippet_folder=SNIPPET_FOLDER, term_freq=term_freq): """ The highest level of search function """ fallback_log = [] code_list = [] tokens = tokenize(query) tokens, abbr_log = abbr_expand(tokens) tokens, correct_log = correct(tokens, term_freq) tokens = lemmat...
[ "def", "search", "(", "index", ",", "query", ",", "snippet_folder", "=", "SNIPPET_FOLDER", ",", "term_freq", "=", "term_freq", ")", ":", "fallback_log", "=", "[", "]", "code_list", "=", "[", "]", "tokens", "=", "tokenize", "(", "query", ")", "tokens", ",...
The highest level of search function
[ "The", "highest", "level", "of", "search", "function" ]
8f181d6428d113d2928e3eb31703705ce0779eae
https://github.com/jeroyang/cateye/blob/8f181d6428d113d2928e3eb31703705ce0779eae/cateye/cateye.py#L278-L308
251,798
xgvargas/smartside
smartside/signal.py
SmartSignal._do_connection
def _do_connection(self, wgt, sig, func): """ Make a connection between a GUI widget and a callable. wgt and sig are strings with widget and signal name func is a callable for that signal """ #new style (we use this) #self.btn_name.clicked.connect(self.on_btn_na...
python
def _do_connection(self, wgt, sig, func): """ Make a connection between a GUI widget and a callable. wgt and sig are strings with widget and signal name func is a callable for that signal """ #new style (we use this) #self.btn_name.clicked.connect(self.on_btn_na...
[ "def", "_do_connection", "(", "self", ",", "wgt", ",", "sig", ",", "func", ")", ":", "#new style (we use this)", "#self.btn_name.clicked.connect(self.on_btn_name_clicked)", "#old style", "#self.connect(self.btn_name, SIGNAL('clicked()'), self.on_btn_name_clicked)", "if", "hasattr"...
Make a connection between a GUI widget and a callable. wgt and sig are strings with widget and signal name func is a callable for that signal
[ "Make", "a", "connection", "between", "a", "GUI", "widget", "and", "a", "callable", "." ]
c63acb7d628b161f438e877eca12d550647de34d
https://github.com/xgvargas/smartside/blob/c63acb7d628b161f438e877eca12d550647de34d/smartside/signal.py#L17-L36
251,799
xgvargas/smartside
smartside/signal.py
SmartSignal._process_list
def _process_list(self, l): """ Processes a list of widget names. If any name is between `` then it is supposed to be a regex. """ if hasattr(self, l): t = getattr(self, l) def proc(inp): w = inp.strip() if w.startswith('...
python
def _process_list(self, l): """ Processes a list of widget names. If any name is between `` then it is supposed to be a regex. """ if hasattr(self, l): t = getattr(self, l) def proc(inp): w = inp.strip() if w.startswith('...
[ "def", "_process_list", "(", "self", ",", "l", ")", ":", "if", "hasattr", "(", "self", ",", "l", ")", ":", "t", "=", "getattr", "(", "self", ",", "l", ")", "def", "proc", "(", "inp", ")", ":", "w", "=", "inp", ".", "strip", "(", ")", "if", ...
Processes a list of widget names. If any name is between `` then it is supposed to be a regex.
[ "Processes", "a", "list", "of", "widget", "names", "." ]
c63acb7d628b161f438e877eca12d550647de34d
https://github.com/xgvargas/smartside/blob/c63acb7d628b161f438e877eca12d550647de34d/smartside/signal.py#L38-L58