repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
wgnet/webium | webium/cookie.py | add_cookies_to_web_driver | def add_cookies_to_web_driver(driver, cookies):
"""
Sets cookies in an existing WebDriver session.
"""
for cookie in cookies:
driver.add_cookie(convert_cookie_to_dict(cookie))
return driver | python | def add_cookies_to_web_driver(driver, cookies):
"""
Sets cookies in an existing WebDriver session.
"""
for cookie in cookies:
driver.add_cookie(convert_cookie_to_dict(cookie))
return driver | [
"def",
"add_cookies_to_web_driver",
"(",
"driver",
",",
"cookies",
")",
":",
"for",
"cookie",
"in",
"cookies",
":",
"driver",
".",
"add_cookie",
"(",
"convert_cookie_to_dict",
"(",
"cookie",
")",
")",
"return",
"driver"
] | Sets cookies in an existing WebDriver session. | [
"Sets",
"cookies",
"in",
"an",
"existing",
"WebDriver",
"session",
"."
] | train | https://github.com/wgnet/webium/blob/ccb09876a201e75f5c5810392d4db7a8708b90cb/webium/cookie.py#L41-L47 |
wgnet/webium | webium/plugins/browser_closer.py | BrowserCloserPlugin.configure | def configure(self, options, conf):
"""Configure plugin. Plugin is enabled by default.
"""
self.conf = conf
self.when = options.browser_closer_when | python | def configure(self, options, conf):
"""Configure plugin. Plugin is enabled by default.
"""
self.conf = conf
self.when = options.browser_closer_when | [
"def",
"configure",
"(",
"self",
",",
"options",
",",
"conf",
")",
":",
"self",
".",
"conf",
"=",
"conf",
"self",
".",
"when",
"=",
"options",
".",
"browser_closer_when"
] | Configure plugin. Plugin is enabled by default. | [
"Configure",
"plugin",
".",
"Plugin",
"is",
"enabled",
"by",
"default",
"."
] | train | https://github.com/wgnet/webium/blob/ccb09876a201e75f5c5810392d4db7a8708b90cb/webium/plugins/browser_closer.py#L25-L29 |
alecthomas/importmagic | importmagic/index.py | SymbolIndex.index_path | def index_path(self, root):
"""Index a path.
:param root: Either a package directory, a .so or a .py module.
"""
basename = os.path.basename(root)
if os.path.splitext(basename)[0] != '__init__' and basename.startswith('_'):
return
location = self._determine_l... | python | def index_path(self, root):
"""Index a path.
:param root: Either a package directory, a .so or a .py module.
"""
basename = os.path.basename(root)
if os.path.splitext(basename)[0] != '__init__' and basename.startswith('_'):
return
location = self._determine_l... | [
"def",
"index_path",
"(",
"self",
",",
"root",
")",
":",
"basename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"root",
")",
"if",
"os",
".",
"path",
".",
"splitext",
"(",
"basename",
")",
"[",
"0",
"]",
"!=",
"'__init__'",
"and",
"basename",
".... | Index a path.
:param root: Either a package directory, a .so or a .py module. | [
"Index",
"a",
"path",
"."
] | train | https://github.com/alecthomas/importmagic/blob/c00f2b282d933e0a9780146a20792f9e31fc8e6f/importmagic/index.py#L148-L160 |
alecthomas/importmagic | importmagic/index.py | SymbolIndex.get_or_create_index | def get_or_create_index(self, paths=None, name=None, refresh=False):
"""
Get index with given name from cache. Create if it doesn't exists.
"""
if not paths:
paths = sys.path
if not name:
name = 'default'
self._name = name
idx_dir = get_ca... | python | def get_or_create_index(self, paths=None, name=None, refresh=False):
"""
Get index with given name from cache. Create if it doesn't exists.
"""
if not paths:
paths = sys.path
if not name:
name = 'default'
self._name = name
idx_dir = get_ca... | [
"def",
"get_or_create_index",
"(",
"self",
",",
"paths",
"=",
"None",
",",
"name",
"=",
"None",
",",
"refresh",
"=",
"False",
")",
":",
"if",
"not",
"paths",
":",
"paths",
"=",
"sys",
".",
"path",
"if",
"not",
"name",
":",
"name",
"=",
"'default'",
... | Get index with given name from cache. Create if it doesn't exists. | [
"Get",
"index",
"with",
"given",
"name",
"from",
"cache",
".",
"Create",
"if",
"it",
"doesn",
"t",
"exists",
"."
] | train | https://github.com/alecthomas/importmagic/blob/c00f2b282d933e0a9780146a20792f9e31fc8e6f/importmagic/index.py#L208-L229 |
alecthomas/importmagic | importmagic/index.py | SymbolIndex.symbol_scores | def symbol_scores(self, symbol):
"""Find matches for symbol.
:param symbol: A . separated symbol. eg. 'os.path.basename'
:returns: A list of tuples of (score, package, reference|None),
ordered by score from highest to lowest.
"""
scores = []
path = []
... | python | def symbol_scores(self, symbol):
"""Find matches for symbol.
:param symbol: A . separated symbol. eg. 'os.path.basename'
:returns: A list of tuples of (score, package, reference|None),
ordered by score from highest to lowest.
"""
scores = []
path = []
... | [
"def",
"symbol_scores",
"(",
"self",
",",
"symbol",
")",
":",
"scores",
"=",
"[",
"]",
"path",
"=",
"[",
"]",
"# sys.path sys path -> import sys",
"# os.path.basename os.path basename -> import os.path",
"# basename os.path basename ... | Find matches for symbol.
:param symbol: A . separated symbol. eg. 'os.path.basename'
:returns: A list of tuples of (score, package, reference|None),
ordered by score from highest to lowest. | [
"Find",
"matches",
"for",
"symbol",
"."
] | train | https://github.com/alecthomas/importmagic/blob/c00f2b282d933e0a9780146a20792f9e31fc8e6f/importmagic/index.py#L231-L280 |
alecthomas/importmagic | importmagic/index.py | SymbolIndex.find | def find(self, path):
"""Return the node for a path, or None."""
path = path.split('.')
node = self
while node._parent:
node = node._parent
for name in path:
node = node._tree.get(name, None)
if node is None or type(node) is float:
... | python | def find(self, path):
"""Return the node for a path, or None."""
path = path.split('.')
node = self
while node._parent:
node = node._parent
for name in path:
node = node._tree.get(name, None)
if node is None or type(node) is float:
... | [
"def",
"find",
"(",
"self",
",",
"path",
")",
":",
"path",
"=",
"path",
".",
"split",
"(",
"'.'",
")",
"node",
"=",
"self",
"while",
"node",
".",
"_parent",
":",
"node",
"=",
"node",
".",
"_parent",
"for",
"name",
"in",
"path",
":",
"node",
"=",
... | Return the node for a path, or None. | [
"Return",
"the",
"node",
"for",
"a",
"path",
"or",
"None",
"."
] | train | https://github.com/alecthomas/importmagic/blob/c00f2b282d933e0a9780146a20792f9e31fc8e6f/importmagic/index.py#L302-L312 |
alecthomas/importmagic | importmagic/index.py | SymbolIndex.location_for | def location_for(self, path):
"""Return the location code for a path."""
path = path.split('.')
node = self
while node._parent:
node = node._parent
location = node.location
for name in path:
tree = node._tree.get(name, None)
if tree is ... | python | def location_for(self, path):
"""Return the location code for a path."""
path = path.split('.')
node = self
while node._parent:
node = node._parent
location = node.location
for name in path:
tree = node._tree.get(name, None)
if tree is ... | [
"def",
"location_for",
"(",
"self",
",",
"path",
")",
":",
"path",
"=",
"path",
".",
"split",
"(",
"'.'",
")",
"node",
"=",
"self",
"while",
"node",
".",
"_parent",
":",
"node",
"=",
"node",
".",
"_parent",
"location",
"=",
"node",
".",
"location",
... | Return the location code for a path. | [
"Return",
"the",
"location",
"code",
"for",
"a",
"path",
"."
] | train | https://github.com/alecthomas/importmagic/blob/c00f2b282d933e0a9780146a20792f9e31fc8e6f/importmagic/index.py#L314-L326 |
wgnet/webium | webium/controls/select.py | Select.select_option | def select_option(self, option):
"""
Performs selection of provided item from Web List
@params option - string item name
"""
items_list = self.get_options()
for item in items_list:
if item.get_attribute("value") == option:
item.click()
... | python | def select_option(self, option):
"""
Performs selection of provided item from Web List
@params option - string item name
"""
items_list = self.get_options()
for item in items_list:
if item.get_attribute("value") == option:
item.click()
... | [
"def",
"select_option",
"(",
"self",
",",
"option",
")",
":",
"items_list",
"=",
"self",
".",
"get_options",
"(",
")",
"for",
"item",
"in",
"items_list",
":",
"if",
"item",
".",
"get_attribute",
"(",
"\"value\"",
")",
"==",
"option",
":",
"item",
".",
... | Performs selection of provided item from Web List
@params option - string item name | [
"Performs",
"selection",
"of",
"provided",
"item",
"from",
"Web",
"List"
] | train | https://github.com/wgnet/webium/blob/ccb09876a201e75f5c5810392d4db7a8708b90cb/webium/controls/select.py#L15-L25 |
wgnet/webium | webium/controls/select.py | Select.get_attribute_selected | def get_attribute_selected(self, attribute):
"""
Performs search of selected item from Web List
Return attribute of selected item
@params attribute - string attribute name
"""
items_list = self.get_options()
return next(iter([item.get_attribute(attribute) for ite... | python | def get_attribute_selected(self, attribute):
"""
Performs search of selected item from Web List
Return attribute of selected item
@params attribute - string attribute name
"""
items_list = self.get_options()
return next(iter([item.get_attribute(attribute) for ite... | [
"def",
"get_attribute_selected",
"(",
"self",
",",
"attribute",
")",
":",
"items_list",
"=",
"self",
".",
"get_options",
"(",
")",
"return",
"next",
"(",
"iter",
"(",
"[",
"item",
".",
"get_attribute",
"(",
"attribute",
")",
"for",
"item",
"in",
"items_lis... | Performs search of selected item from Web List
Return attribute of selected item
@params attribute - string attribute name | [
"Performs",
"search",
"of",
"selected",
"item",
"from",
"Web",
"List",
"Return",
"attribute",
"of",
"selected",
"item"
] | train | https://github.com/wgnet/webium/blob/ccb09876a201e75f5c5810392d4db7a8708b90cb/webium/controls/select.py#L33-L41 |
wgnet/webium | webium/controls/select.py | Select.select_by_visible_text | def select_by_visible_text(self, text):
"""
Performs search of selected item from Web List
@params text - string visible text
"""
xpath = './/option[normalize-space(.) = {0}]'.format(self._escape_string(text))
opts = self.find_elements_by_xpath(xpath)
matched = F... | python | def select_by_visible_text(self, text):
"""
Performs search of selected item from Web List
@params text - string visible text
"""
xpath = './/option[normalize-space(.) = {0}]'.format(self._escape_string(text))
opts = self.find_elements_by_xpath(xpath)
matched = F... | [
"def",
"select_by_visible_text",
"(",
"self",
",",
"text",
")",
":",
"xpath",
"=",
"'.//option[normalize-space(.) = {0}]'",
".",
"format",
"(",
"self",
".",
"_escape_string",
"(",
"text",
")",
")",
"opts",
"=",
"self",
".",
"find_elements_by_xpath",
"(",
"xpath"... | Performs search of selected item from Web List
@params text - string visible text | [
"Performs",
"search",
"of",
"selected",
"item",
"from",
"Web",
"List"
] | train | https://github.com/wgnet/webium/blob/ccb09876a201e75f5c5810392d4db7a8708b90cb/webium/controls/select.py#L57-L87 |
wgnet/webium | webium/wait.py | wait | def wait(*args, **kwargs):
"""
Wrapping 'wait()' method of 'waiting' library with default parameter values.
WebDriverException is ignored in the expected exceptions by default.
"""
kwargs.setdefault('sleep_seconds', (1, None))
kwargs.setdefault('expected_exceptions', WebDriverException)
kwar... | python | def wait(*args, **kwargs):
"""
Wrapping 'wait()' method of 'waiting' library with default parameter values.
WebDriverException is ignored in the expected exceptions by default.
"""
kwargs.setdefault('sleep_seconds', (1, None))
kwargs.setdefault('expected_exceptions', WebDriverException)
kwar... | [
"def",
"wait",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'sleep_seconds'",
",",
"(",
"1",
",",
"None",
")",
")",
"kwargs",
".",
"setdefault",
"(",
"'expected_exceptions'",
",",
"WebDriverException",
")",
"kwa... | Wrapping 'wait()' method of 'waiting' library with default parameter values.
WebDriverException is ignored in the expected exceptions by default. | [
"Wrapping",
"wait",
"()",
"method",
"of",
"waiting",
"library",
"with",
"default",
"parameter",
"values",
".",
"WebDriverException",
"is",
"ignored",
"in",
"the",
"expected",
"exceptions",
"by",
"default",
"."
] | train | https://github.com/wgnet/webium/blob/ccb09876a201e75f5c5810392d4db7a8708b90cb/webium/wait.py#L7-L16 |
alecthomas/importmagic | importmagic/util.py | parse_ast | def parse_ast(source, filename=None):
"""Parse source into a Python AST, taking care of encoding."""
if isinstance(source, text_type) and sys.version_info[0] == 2:
# ast.parse() on Python 2 doesn't like encoding declarations
# in Unicode strings
source = CODING_COOKIE_RE.sub(r'\1', sourc... | python | def parse_ast(source, filename=None):
"""Parse source into a Python AST, taking care of encoding."""
if isinstance(source, text_type) and sys.version_info[0] == 2:
# ast.parse() on Python 2 doesn't like encoding declarations
# in Unicode strings
source = CODING_COOKIE_RE.sub(r'\1', sourc... | [
"def",
"parse_ast",
"(",
"source",
",",
"filename",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"source",
",",
"text_type",
")",
"and",
"sys",
".",
"version_info",
"[",
"0",
"]",
"==",
"2",
":",
"# ast.parse() on Python 2 doesn't like encoding declarations",... | Parse source into a Python AST, taking care of encoding. | [
"Parse",
"source",
"into",
"a",
"Python",
"AST",
"taking",
"care",
"of",
"encoding",
"."
] | train | https://github.com/alecthomas/importmagic/blob/c00f2b282d933e0a9780146a20792f9e31fc8e6f/importmagic/util.py#L14-L20 |
alecthomas/importmagic | importmagic/symbols.py | Scope.find_unresolved_and_unreferenced_symbols | def find_unresolved_and_unreferenced_symbols(self):
"""Find any unresolved symbols, and unreferenced symbols from this scope.
:returns: ({unresolved}, {unreferenced})
"""
unresolved = set()
unreferenced = self._definitions.copy()
self._collect_unresolved_and_unreferenced... | python | def find_unresolved_and_unreferenced_symbols(self):
"""Find any unresolved symbols, and unreferenced symbols from this scope.
:returns: ({unresolved}, {unreferenced})
"""
unresolved = set()
unreferenced = self._definitions.copy()
self._collect_unresolved_and_unreferenced... | [
"def",
"find_unresolved_and_unreferenced_symbols",
"(",
"self",
")",
":",
"unresolved",
"=",
"set",
"(",
")",
"unreferenced",
"=",
"self",
".",
"_definitions",
".",
"copy",
"(",
")",
"self",
".",
"_collect_unresolved_and_unreferenced",
"(",
"set",
"(",
")",
",",... | Find any unresolved symbols, and unreferenced symbols from this scope.
:returns: ({unresolved}, {unreferenced}) | [
"Find",
"any",
"unresolved",
"symbols",
"and",
"unreferenced",
"symbols",
"from",
"this",
"scope",
"."
] | train | https://github.com/alecthomas/importmagic/blob/c00f2b282d933e0a9780146a20792f9e31fc8e6f/importmagic/symbols.py#L116-L125 |
netpieio/microgear-python | microgear/cache.py | get_item | def get_item(key):
"""Return content in cached file in JSON format"""
CACHED_KEY_FILE = os.path.join(CURRENT_DIR, key)
try:
return json.loads(open(CACHED_KEY_FILE, "rb").read().decode('UTF-8'))["_"]
except (IOError, ValueError):
return None | python | def get_item(key):
"""Return content in cached file in JSON format"""
CACHED_KEY_FILE = os.path.join(CURRENT_DIR, key)
try:
return json.loads(open(CACHED_KEY_FILE, "rb").read().decode('UTF-8'))["_"]
except (IOError, ValueError):
return None | [
"def",
"get_item",
"(",
"key",
")",
":",
"CACHED_KEY_FILE",
"=",
"os",
".",
"path",
".",
"join",
"(",
"CURRENT_DIR",
",",
"key",
")",
"try",
":",
"return",
"json",
".",
"loads",
"(",
"open",
"(",
"CACHED_KEY_FILE",
",",
"\"rb\"",
")",
".",
"read",
"(... | Return content in cached file in JSON format | [
"Return",
"content",
"in",
"cached",
"file",
"in",
"JSON",
"format"
] | train | https://github.com/netpieio/microgear-python/blob/ea9bb352c7dd84b92f3462177645eaa4d448d50b/microgear/cache.py#L9-L16 |
netpieio/microgear-python | microgear/cache.py | set_item | def set_item(key,value):
"""Write JSON content from value argument to cached file and return"""
CACHED_KEY_FILE = os.path.join(CURRENT_DIR, key)
open(CACHED_KEY_FILE, "wb").write(json.dumps({"_": value}).encode('UTF-8'))
return value | python | def set_item(key,value):
"""Write JSON content from value argument to cached file and return"""
CACHED_KEY_FILE = os.path.join(CURRENT_DIR, key)
open(CACHED_KEY_FILE, "wb").write(json.dumps({"_": value}).encode('UTF-8'))
return value | [
"def",
"set_item",
"(",
"key",
",",
"value",
")",
":",
"CACHED_KEY_FILE",
"=",
"os",
".",
"path",
".",
"join",
"(",
"CURRENT_DIR",
",",
"key",
")",
"open",
"(",
"CACHED_KEY_FILE",
",",
"\"wb\"",
")",
".",
"write",
"(",
"json",
".",
"dumps",
"(",
"{",... | Write JSON content from value argument to cached file and return | [
"Write",
"JSON",
"content",
"from",
"value",
"argument",
"to",
"cached",
"file",
"and",
"return"
] | train | https://github.com/netpieio/microgear-python/blob/ea9bb352c7dd84b92f3462177645eaa4d448d50b/microgear/cache.py#L19-L25 |
netpieio/microgear-python | microgear/cache.py | delete_item | def delete_item(key):
"""Delete cached file if present"""
CACHED_KEY_FILE = os.path.join(CURRENT_DIR, key)
if os.path.isfile(CACHED_KEY_FILE):
os.remove(CACHED_KEY_FILE) | python | def delete_item(key):
"""Delete cached file if present"""
CACHED_KEY_FILE = os.path.join(CURRENT_DIR, key)
if os.path.isfile(CACHED_KEY_FILE):
os.remove(CACHED_KEY_FILE) | [
"def",
"delete_item",
"(",
"key",
")",
":",
"CACHED_KEY_FILE",
"=",
"os",
".",
"path",
".",
"join",
"(",
"CURRENT_DIR",
",",
"key",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"CACHED_KEY_FILE",
")",
":",
"os",
".",
"remove",
"(",
"CACHED_KEY_FIL... | Delete cached file if present | [
"Delete",
"cached",
"file",
"if",
"present"
] | train | https://github.com/netpieio/microgear-python/blob/ea9bb352c7dd84b92f3462177645eaa4d448d50b/microgear/cache.py#L28-L33 |
s1s1ty/py-jsonq | pyjsonq/query.py | JsonQ.__parse_json_data | def __parse_json_data(self, data):
"""Process Json data
:@param data
:@type data: json/dict
:throws TypeError
"""
if isinstance(data, dict) or isinstance(data, list):
self._raw_data = data
self._json_data = copy.deepcopy(self._raw_data)
e... | python | def __parse_json_data(self, data):
"""Process Json data
:@param data
:@type data: json/dict
:throws TypeError
"""
if isinstance(data, dict) or isinstance(data, list):
self._raw_data = data
self._json_data = copy.deepcopy(self._raw_data)
e... | [
"def",
"__parse_json_data",
"(",
"self",
",",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
"or",
"isinstance",
"(",
"data",
",",
"list",
")",
":",
"self",
".",
"_raw_data",
"=",
"data",
"self",
".",
"_json_data",
"=",
"copy",
... | Process Json data
:@param data
:@type data: json/dict
:throws TypeError | [
"Process",
"Json",
"data"
] | train | https://github.com/s1s1ty/py-jsonq/blob/9625597a2578bddcbed4e540174d5253b1fc3b75/pyjsonq/query.py#L32-L44 |
s1s1ty/py-jsonq | pyjsonq/query.py | JsonQ.__parse_json_file | def __parse_json_file(self, file_path):
"""Process Json file data
:@param file_path
:@type file_path: string
:@throws IOError
"""
if file_path == '' or os.path.splitext(file_path)[1] != '.json':
raise IOError('Invalid Json file')
with open(file_path... | python | def __parse_json_file(self, file_path):
"""Process Json file data
:@param file_path
:@type file_path: string
:@throws IOError
"""
if file_path == '' or os.path.splitext(file_path)[1] != '.json':
raise IOError('Invalid Json file')
with open(file_path... | [
"def",
"__parse_json_file",
"(",
"self",
",",
"file_path",
")",
":",
"if",
"file_path",
"==",
"''",
"or",
"os",
".",
"path",
".",
"splitext",
"(",
"file_path",
")",
"[",
"1",
"]",
"!=",
"'.json'",
":",
"raise",
"IOError",
"(",
"'Invalid Json file'",
")",... | Process Json file data
:@param file_path
:@type file_path: string
:@throws IOError | [
"Process",
"Json",
"file",
"data"
] | train | https://github.com/s1s1ty/py-jsonq/blob/9625597a2578bddcbed4e540174d5253b1fc3b75/pyjsonq/query.py#L46-L60 |
s1s1ty/py-jsonq | pyjsonq/query.py | JsonQ.__get_value_from_data | def __get_value_from_data(self, key, data):
"""Find value from json data
:@pram key
:@type: string
:@pram data
:@type data: dict
:@return object
:@throws KeyError
"""
if key.isdigit():
return data[int(key)]
if key not in dat... | python | def __get_value_from_data(self, key, data):
"""Find value from json data
:@pram key
:@type: string
:@pram data
:@type data: dict
:@return object
:@throws KeyError
"""
if key.isdigit():
return data[int(key)]
if key not in dat... | [
"def",
"__get_value_from_data",
"(",
"self",
",",
"key",
",",
"data",
")",
":",
"if",
"key",
".",
"isdigit",
"(",
")",
":",
"return",
"data",
"[",
"int",
"(",
"key",
")",
"]",
"if",
"key",
"not",
"in",
"data",
":",
"raise",
"KeyError",
"(",
"\"Key ... | Find value from json data
:@pram key
:@type: string
:@pram data
:@type data: dict
:@return object
:@throws KeyError | [
"Find",
"value",
"from",
"json",
"data"
] | train | https://github.com/s1s1ty/py-jsonq/blob/9625597a2578bddcbed4e540174d5253b1fc3b75/pyjsonq/query.py#L62-L80 |
s1s1ty/py-jsonq | pyjsonq/query.py | JsonQ.at | def at(self, root):
"""Set root where PyJsonq start to prepare
:@param root
:@type root: string
:@return self
:@throws KeyError
"""
leafs = root.strip(" ").split('.')
for leaf in leafs:
if leaf:
self._json_data = self.__get_va... | python | def at(self, root):
"""Set root where PyJsonq start to prepare
:@param root
:@type root: string
:@return self
:@throws KeyError
"""
leafs = root.strip(" ").split('.')
for leaf in leafs:
if leaf:
self._json_data = self.__get_va... | [
"def",
"at",
"(",
"self",
",",
"root",
")",
":",
"leafs",
"=",
"root",
".",
"strip",
"(",
"\" \"",
")",
".",
"split",
"(",
"'.'",
")",
"for",
"leaf",
"in",
"leafs",
":",
"if",
"leaf",
":",
"self",
".",
"_json_data",
"=",
"self",
".",
"__get_value... | Set root where PyJsonq start to prepare
:@param root
:@type root: string
:@return self
:@throws KeyError | [
"Set",
"root",
"where",
"PyJsonq",
"start",
"to",
"prepare"
] | train | https://github.com/s1s1ty/py-jsonq/blob/9625597a2578bddcbed4e540174d5253b1fc3b75/pyjsonq/query.py#L101-L114 |
s1s1ty/py-jsonq | pyjsonq/query.py | JsonQ.reset | def reset(self, data={}):
"""JsonQuery object cen be reset to new data
according to given data or previously given raw Json data
:@param data: {}
:@type data: json/dict
:@return self
"""
if data and (isinstance(data, dict) or isinstance(data, list)):
... | python | def reset(self, data={}):
"""JsonQuery object cen be reset to new data
according to given data or previously given raw Json data
:@param data: {}
:@type data: json/dict
:@return self
"""
if data and (isinstance(data, dict) or isinstance(data, list)):
... | [
"def",
"reset",
"(",
"self",
",",
"data",
"=",
"{",
"}",
")",
":",
"if",
"data",
"and",
"(",
"isinstance",
"(",
"data",
",",
"dict",
")",
"or",
"isinstance",
"(",
"data",
",",
"list",
")",
")",
":",
"self",
".",
"_json_data",
"=",
"data",
"else",... | JsonQuery object cen be reset to new data
according to given data or previously given raw Json data
:@param data: {}
:@type data: json/dict
:@return self | [
"JsonQuery",
"object",
"cen",
"be",
"reset",
"to",
"new",
"data"
] | train | https://github.com/s1s1ty/py-jsonq/blob/9625597a2578bddcbed4e540174d5253b1fc3b75/pyjsonq/query.py#L120-L136 |
s1s1ty/py-jsonq | pyjsonq/query.py | JsonQ.__store_query | def __store_query(self, query_items):
"""Make where clause
:@param query_items
:@type query_items: dict
"""
temp_index = self._current_query_index
if len(self._queries) - 1 < temp_index:
self._queries.append([])
self._queries[temp_index].append(query... | python | def __store_query(self, query_items):
"""Make where clause
:@param query_items
:@type query_items: dict
"""
temp_index = self._current_query_index
if len(self._queries) - 1 < temp_index:
self._queries.append([])
self._queries[temp_index].append(query... | [
"def",
"__store_query",
"(",
"self",
",",
"query_items",
")",
":",
"temp_index",
"=",
"self",
".",
"_current_query_index",
"if",
"len",
"(",
"self",
".",
"_queries",
")",
"-",
"1",
"<",
"temp_index",
":",
"self",
".",
"_queries",
".",
"append",
"(",
"[",... | Make where clause
:@param query_items
:@type query_items: dict | [
"Make",
"where",
"clause"
] | train | https://github.com/s1s1ty/py-jsonq/blob/9625597a2578bddcbed4e540174d5253b1fc3b75/pyjsonq/query.py#L138-L148 |
s1s1ty/py-jsonq | pyjsonq/query.py | JsonQ.__execute_queries | def __execute_queries(self):
"""Execute all condition and filter result data"""
def func(item):
or_check = False
for queries in self._queries:
and_check = True
for query in queries:
and_check &= self._matcher._match(
... | python | def __execute_queries(self):
"""Execute all condition and filter result data"""
def func(item):
or_check = False
for queries in self._queries:
and_check = True
for query in queries:
and_check &= self._matcher._match(
... | [
"def",
"__execute_queries",
"(",
"self",
")",
":",
"def",
"func",
"(",
"item",
")",
":",
"or_check",
"=",
"False",
"for",
"queries",
"in",
"self",
".",
"_queries",
":",
"and_check",
"=",
"True",
"for",
"query",
"in",
"queries",
":",
"and_check",
"&=",
... | Execute all condition and filter result data | [
"Execute",
"all",
"condition",
"and",
"filter",
"result",
"data"
] | train | https://github.com/s1s1ty/py-jsonq/blob/9625597a2578bddcbed4e540174d5253b1fc3b75/pyjsonq/query.py#L157-L173 |
s1s1ty/py-jsonq | pyjsonq/query.py | JsonQ.where | def where(self, key, operator, value):
"""Make where clause
:@param key
:@param operator
:@param value
:@type key,operator,value: string
:@return self
"""
self.__store_query({"key": key, "operator": operator, "value": value})
return self | python | def where(self, key, operator, value):
"""Make where clause
:@param key
:@param operator
:@param value
:@type key,operator,value: string
:@return self
"""
self.__store_query({"key": key, "operator": operator, "value": value})
return self | [
"def",
"where",
"(",
"self",
",",
"key",
",",
"operator",
",",
"value",
")",
":",
"self",
".",
"__store_query",
"(",
"{",
"\"key\"",
":",
"key",
",",
"\"operator\"",
":",
"operator",
",",
"\"value\"",
":",
"value",
"}",
")",
"return",
"self"
] | Make where clause
:@param key
:@param operator
:@param value
:@type key,operator,value: string
:@return self | [
"Make",
"where",
"clause"
] | train | https://github.com/s1s1ty/py-jsonq/blob/9625597a2578bddcbed4e540174d5253b1fc3b75/pyjsonq/query.py#L177-L188 |
s1s1ty/py-jsonq | pyjsonq/query.py | JsonQ.or_where | def or_where(self, key, operator, value):
"""Make or_where clause
:@param key
:@param operator
:@param value
:@type key, operator, value: string
:@return self
"""
if len(self._queries) > 0:
self._current_query_index += 1
self.__store_... | python | def or_where(self, key, operator, value):
"""Make or_where clause
:@param key
:@param operator
:@param value
:@type key, operator, value: string
:@return self
"""
if len(self._queries) > 0:
self._current_query_index += 1
self.__store_... | [
"def",
"or_where",
"(",
"self",
",",
"key",
",",
"operator",
",",
"value",
")",
":",
"if",
"len",
"(",
"self",
".",
"_queries",
")",
">",
"0",
":",
"self",
".",
"_current_query_index",
"+=",
"1",
"self",
".",
"__store_query",
"(",
"{",
"\"key\"",
":"... | Make or_where clause
:@param key
:@param operator
:@param value
:@type key, operator, value: string
:@return self | [
"Make",
"or_where",
"clause"
] | train | https://github.com/s1s1ty/py-jsonq/blob/9625597a2578bddcbed4e540174d5253b1fc3b75/pyjsonq/query.py#L190-L203 |
s1s1ty/py-jsonq | pyjsonq/query.py | JsonQ.nth | def nth(self, index):
"""Getting the nth element of the collection
:@param index
:@type index: int
:@return object
"""
self.__prepare()
return None if self.count() < math.fabs(index) else self._json_data[index] | python | def nth(self, index):
"""Getting the nth element of the collection
:@param index
:@type index: int
:@return object
"""
self.__prepare()
return None if self.count() < math.fabs(index) else self._json_data[index] | [
"def",
"nth",
"(",
"self",
",",
"index",
")",
":",
"self",
".",
"__prepare",
"(",
")",
"return",
"None",
"if",
"self",
".",
"count",
"(",
")",
"<",
"math",
".",
"fabs",
"(",
"index",
")",
"else",
"self",
".",
"_json_data",
"[",
"index",
"]"
] | Getting the nth element of the collection
:@param index
:@type index: int
:@return object | [
"Getting",
"the",
"nth",
"element",
"of",
"the",
"collection"
] | train | https://github.com/s1s1ty/py-jsonq/blob/9625597a2578bddcbed4e540174d5253b1fc3b75/pyjsonq/query.py#L321-L330 |
s1s1ty/py-jsonq | pyjsonq/query.py | JsonQ.sum | def sum(self, property):
"""Getting the sum according to the given property
:@param property
:@type property: string
:@return int/float
"""
self.__prepare()
total = 0
for i in self._json_data:
total += i.get(property)
return total | python | def sum(self, property):
"""Getting the sum according to the given property
:@param property
:@type property: string
:@return int/float
"""
self.__prepare()
total = 0
for i in self._json_data:
total += i.get(property)
return total | [
"def",
"sum",
"(",
"self",
",",
"property",
")",
":",
"self",
".",
"__prepare",
"(",
")",
"total",
"=",
"0",
"for",
"i",
"in",
"self",
".",
"_json_data",
":",
"total",
"+=",
"i",
".",
"get",
"(",
"property",
")",
"return",
"total"
] | Getting the sum according to the given property
:@param property
:@type property: string
:@return int/float | [
"Getting",
"the",
"sum",
"according",
"to",
"the",
"given",
"property"
] | train | https://github.com/s1s1ty/py-jsonq/blob/9625597a2578bddcbed4e540174d5253b1fc3b75/pyjsonq/query.py#L332-L345 |
s1s1ty/py-jsonq | pyjsonq/query.py | JsonQ.max | def max(self, property):
"""Getting the maximum value from the prepared data
:@param property
:@type property: string
:@return object
:@throws KeyError
"""
self.__prepare()
try:
return max(self._json_data, key=lambda x: x[property]).get(prope... | python | def max(self, property):
"""Getting the maximum value from the prepared data
:@param property
:@type property: string
:@return object
:@throws KeyError
"""
self.__prepare()
try:
return max(self._json_data, key=lambda x: x[property]).get(prope... | [
"def",
"max",
"(",
"self",
",",
"property",
")",
":",
"self",
".",
"__prepare",
"(",
")",
"try",
":",
"return",
"max",
"(",
"self",
".",
"_json_data",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
"[",
"property",
"]",
")",
".",
"get",
"(",
"property... | Getting the maximum value from the prepared data
:@param property
:@type property: string
:@return object
:@throws KeyError | [
"Getting",
"the",
"maximum",
"value",
"from",
"the",
"prepared",
"data"
] | train | https://github.com/s1s1ty/py-jsonq/blob/9625597a2578bddcbed4e540174d5253b1fc3b75/pyjsonq/query.py#L347-L360 |
s1s1ty/py-jsonq | pyjsonq/query.py | JsonQ.avg | def avg(self, property):
"""Getting average according to given property
:@param property
:@type property: string
:@return average: int/float
"""
self.__prepare()
return self.sum(property) / self.count() | python | def avg(self, property):
"""Getting average according to given property
:@param property
:@type property: string
:@return average: int/float
"""
self.__prepare()
return self.sum(property) / self.count() | [
"def",
"avg",
"(",
"self",
",",
"property",
")",
":",
"self",
".",
"__prepare",
"(",
")",
"return",
"self",
".",
"sum",
"(",
"property",
")",
"/",
"self",
".",
"count",
"(",
")"
] | Getting average according to given property
:@param property
:@type property: string
:@return average: int/float | [
"Getting",
"average",
"according",
"to",
"given",
"property"
] | train | https://github.com/s1s1ty/py-jsonq/blob/9625597a2578bddcbed4e540174d5253b1fc3b75/pyjsonq/query.py#L377-L386 |
s1s1ty/py-jsonq | pyjsonq/query.py | JsonQ.chunk | def chunk(self, size=0):
"""Group the resulted collection to multiple chunk
:@param size: 0
:@type size: integer
:@return Chunked List
"""
if size == 0:
raise ValueError('Invalid chunk size')
self.__prepare()
_new_content = []
whil... | python | def chunk(self, size=0):
"""Group the resulted collection to multiple chunk
:@param size: 0
:@type size: integer
:@return Chunked List
"""
if size == 0:
raise ValueError('Invalid chunk size')
self.__prepare()
_new_content = []
whil... | [
"def",
"chunk",
"(",
"self",
",",
"size",
"=",
"0",
")",
":",
"if",
"size",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"'Invalid chunk size'",
")",
"self",
".",
"__prepare",
"(",
")",
"_new_content",
"=",
"[",
"]",
"while",
"(",
"len",
"(",
"self",
... | Group the resulted collection to multiple chunk
:@param size: 0
:@type size: integer
:@return Chunked List | [
"Group",
"the",
"resulted",
"collection",
"to",
"multiple",
"chunk"
] | train | https://github.com/s1s1ty/py-jsonq/blob/9625597a2578bddcbed4e540174d5253b1fc3b75/pyjsonq/query.py#L388-L409 |
s1s1ty/py-jsonq | pyjsonq/query.py | JsonQ.group_by | def group_by(self, property):
"""Getting the grouped result by the given property
:@param property
:@type property: string
:@return self
"""
self.__prepare()
group_data = {}
for data in self._json_data:
if data[property] not in group_data:
... | python | def group_by(self, property):
"""Getting the grouped result by the given property
:@param property
:@type property: string
:@return self
"""
self.__prepare()
group_data = {}
for data in self._json_data:
if data[property] not in group_data:
... | [
"def",
"group_by",
"(",
"self",
",",
"property",
")",
":",
"self",
".",
"__prepare",
"(",
")",
"group_data",
"=",
"{",
"}",
"for",
"data",
"in",
"self",
".",
"_json_data",
":",
"if",
"data",
"[",
"property",
"]",
"not",
"in",
"group_data",
":",
"grou... | Getting the grouped result by the given property
:@param property
:@type property: string
:@return self | [
"Getting",
"the",
"grouped",
"result",
"by",
"the",
"given",
"property"
] | train | https://github.com/s1s1ty/py-jsonq/blob/9625597a2578bddcbed4e540174d5253b1fc3b75/pyjsonq/query.py#L411-L427 |
s1s1ty/py-jsonq | pyjsonq/query.py | JsonQ.sort | def sort(self, order="asc"):
"""Getting the sorted result of the given list
:@param order: "asc"
:@type order: string
:@return self
"""
self.__prepare()
if isinstance(self._json_data, list):
if order == "asc":
self._json_data = sorted... | python | def sort(self, order="asc"):
"""Getting the sorted result of the given list
:@param order: "asc"
:@type order: string
:@return self
"""
self.__prepare()
if isinstance(self._json_data, list):
if order == "asc":
self._json_data = sorted... | [
"def",
"sort",
"(",
"self",
",",
"order",
"=",
"\"asc\"",
")",
":",
"self",
".",
"__prepare",
"(",
")",
"if",
"isinstance",
"(",
"self",
".",
"_json_data",
",",
"list",
")",
":",
"if",
"order",
"==",
"\"asc\"",
":",
"self",
".",
"_json_data",
"=",
... | Getting the sorted result of the given list
:@param order: "asc"
:@type order: string
:@return self | [
"Getting",
"the",
"sorted",
"result",
"of",
"the",
"given",
"list"
] | train | https://github.com/s1s1ty/py-jsonq/blob/9625597a2578bddcbed4e540174d5253b1fc3b75/pyjsonq/query.py#L429-L444 |
s1s1ty/py-jsonq | pyjsonq/query.py | JsonQ.sort_by | def sort_by(self, property, order="asc"):
"""Getting the sorted result by the given property
:@param property, order: "asc"
:@type property, order: string
:@return self
"""
self.__prepare()
if isinstance(self._json_data, list):
if order == "asc":
... | python | def sort_by(self, property, order="asc"):
"""Getting the sorted result by the given property
:@param property, order: "asc"
:@type property, order: string
:@return self
"""
self.__prepare()
if isinstance(self._json_data, list):
if order == "asc":
... | [
"def",
"sort_by",
"(",
"self",
",",
"property",
",",
"order",
"=",
"\"asc\"",
")",
":",
"self",
".",
"__prepare",
"(",
")",
"if",
"isinstance",
"(",
"self",
".",
"_json_data",
",",
"list",
")",
":",
"if",
"order",
"==",
"\"asc\"",
":",
"self",
".",
... | Getting the sorted result by the given property
:@param property, order: "asc"
:@type property, order: string
:@return self | [
"Getting",
"the",
"sorted",
"result",
"by",
"the",
"given",
"property"
] | train | https://github.com/s1s1ty/py-jsonq/blob/9625597a2578bddcbed4e540174d5253b1fc3b75/pyjsonq/query.py#L446-L468 |
s1s1ty/py-jsonq | pyjsonq/matcher.py | Matcher._match | def _match(self, x, op, y):
"""Compare the given `x` and `y` based on `op`
:@param x, y, op
:@type x, y: mixed
:@type op: string
:@return bool
:@throws ValueError
"""
if (op not in self.condition_mapper):
raise ValueError('Invalid where condi... | python | def _match(self, x, op, y):
"""Compare the given `x` and `y` based on `op`
:@param x, y, op
:@type x, y: mixed
:@type op: string
:@return bool
:@throws ValueError
"""
if (op not in self.condition_mapper):
raise ValueError('Invalid where condi... | [
"def",
"_match",
"(",
"self",
",",
"x",
",",
"op",
",",
"y",
")",
":",
"if",
"(",
"op",
"not",
"in",
"self",
".",
"condition_mapper",
")",
":",
"raise",
"ValueError",
"(",
"'Invalid where condition given'",
")",
"func",
"=",
"getattr",
"(",
"self",
","... | Compare the given `x` and `y` based on `op`
:@param x, y, op
:@type x, y: mixed
:@type op: string
:@return bool
:@throws ValueError | [
"Compare",
"the",
"given",
"x",
"and",
"y",
"based",
"on",
"op"
] | train | https://github.com/s1s1ty/py-jsonq/blob/9625597a2578bddcbed4e540174d5253b1fc3b75/pyjsonq/matcher.py#L162-L176 |
mkorpela/overrides | overrides/overrides.py | overrides | def overrides(method):
"""Decorator to indicate that the decorated method overrides a method in
superclass.
The decorator code is executed while loading class. Using this method
should have minimal runtime performance implications.
This is based on my idea about how to do this and fwc:s highly impr... | python | def overrides(method):
"""Decorator to indicate that the decorated method overrides a method in
superclass.
The decorator code is executed while loading class. Using this method
should have minimal runtime performance implications.
This is based on my idea about how to do this and fwc:s highly impr... | [
"def",
"overrides",
"(",
"method",
")",
":",
"for",
"super_class",
"in",
"_get_base_classes",
"(",
"sys",
".",
"_getframe",
"(",
"2",
")",
",",
"method",
".",
"__globals__",
")",
":",
"if",
"hasattr",
"(",
"super_class",
",",
"method",
".",
"__name__",
"... | Decorator to indicate that the decorated method overrides a method in
superclass.
The decorator code is executed while loading class. Using this method
should have minimal runtime performance implications.
This is based on my idea about how to do this and fwc:s highly improved
algorithm for the imp... | [
"Decorator",
"to",
"indicate",
"that",
"the",
"decorated",
"method",
"overrides",
"a",
"method",
"in",
"superclass",
".",
"The",
"decorator",
"code",
"is",
"executed",
"while",
"loading",
"class",
".",
"Using",
"this",
"method",
"should",
"have",
"minimal",
"r... | train | https://github.com/mkorpela/overrides/blob/196c2fa3c79fe7a7d319d2ade25bb25f6d78f1c2/overrides/overrides.py#L30-L70 |
mkorpela/overrides | overrides/overrides.py | _get_base_class_names | def _get_base_class_names(frame):
""" Get baseclass names from the code object """
co, lasti = frame.f_code, frame.f_lasti
code = co.co_code
extends = []
for (op, oparg) in op_stream(code, lasti):
if op in dis.hasconst:
if type(co.co_consts[oparg]) == str:
extend... | python | def _get_base_class_names(frame):
""" Get baseclass names from the code object """
co, lasti = frame.f_code, frame.f_lasti
code = co.co_code
extends = []
for (op, oparg) in op_stream(code, lasti):
if op in dis.hasconst:
if type(co.co_consts[oparg]) == str:
extend... | [
"def",
"_get_base_class_names",
"(",
"frame",
")",
":",
"co",
",",
"lasti",
"=",
"frame",
".",
"f_code",
",",
"frame",
".",
"f_lasti",
"code",
"=",
"co",
".",
"co_code",
"extends",
"=",
"[",
"]",
"for",
"(",
"op",
",",
"oparg",
")",
"in",
"op_stream"... | Get baseclass names from the code object | [
"Get",
"baseclass",
"names",
"from",
"the",
"code",
"object"
] | train | https://github.com/mkorpela/overrides/blob/196c2fa3c79fe7a7d319d2ade25bb25f6d78f1c2/overrides/overrides.py#L126-L155 |
firecat53/urlscan | urlscan/urlscan.py | get_charset | def get_charset(message, default="utf-8"):
"""Get the message charset"""
if message.get_content_charset():
return message.get_content_charset()
if message.get_charset():
return message.get_charset()
return default | python | def get_charset(message, default="utf-8"):
"""Get the message charset"""
if message.get_content_charset():
return message.get_content_charset()
if message.get_charset():
return message.get_charset()
return default | [
"def",
"get_charset",
"(",
"message",
",",
"default",
"=",
"\"utf-8\"",
")",
":",
"if",
"message",
".",
"get_content_charset",
"(",
")",
":",
"return",
"message",
".",
"get_content_charset",
"(",
")",
"if",
"message",
".",
"get_charset",
"(",
")",
":",
"re... | Get the message charset | [
"Get",
"the",
"message",
"charset"
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlscan.py#L30-L36 |
firecat53/urlscan | urlscan/urlscan.py | load_tlds | def load_tlds():
"""Load all legal TLD extensions from assets
"""
file = os.path.join(os.path.dirname(__file__),
'assets',
'tlds-alpha-by-domain.txt')
with open(file) as fobj:
return [elem for elem in fobj.read().lower().splitlines()[1:]
... | python | def load_tlds():
"""Load all legal TLD extensions from assets
"""
file = os.path.join(os.path.dirname(__file__),
'assets',
'tlds-alpha-by-domain.txt')
with open(file) as fobj:
return [elem for elem in fobj.read().lower().splitlines()[1:]
... | [
"def",
"load_tlds",
"(",
")",
":",
"file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'assets'",
",",
"'tlds-alpha-by-domain.txt'",
")",
"with",
"open",
"(",
"file",
")",
"as",
"fobj",
":"... | Load all legal TLD extensions from assets | [
"Load",
"all",
"legal",
"TLD",
"extensions",
"from",
"assets"
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlscan.py#L268-L277 |
firecat53/urlscan | urlscan/urlscan.py | parse_text_urls | def parse_text_urls(mesg):
"""Parse a block of text, splitting it into its url and non-url
components."""
rval = []
loc = 0
for match in URLRE.finditer(mesg):
if loc < match.start():
rval.append(Chunk(mesg[loc:match.start()], None))
# Turn email addresses into mailto: ... | python | def parse_text_urls(mesg):
"""Parse a block of text, splitting it into its url and non-url
components."""
rval = []
loc = 0
for match in URLRE.finditer(mesg):
if loc < match.start():
rval.append(Chunk(mesg[loc:match.start()], None))
# Turn email addresses into mailto: ... | [
"def",
"parse_text_urls",
"(",
"mesg",
")",
":",
"rval",
"=",
"[",
"]",
"loc",
"=",
"0",
"for",
"match",
"in",
"URLRE",
".",
"finditer",
"(",
"mesg",
")",
":",
"if",
"loc",
"<",
"match",
".",
"start",
"(",
")",
":",
"rval",
".",
"append",
"(",
... | Parse a block of text, splitting it into its url and non-url
components. | [
"Parse",
"a",
"block",
"of",
"text",
"splitting",
"it",
"into",
"its",
"url",
"and",
"non",
"-",
"url",
"components",
"."
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlscan.py#L309-L332 |
firecat53/urlscan | urlscan/urlscan.py | extract_with_context | def extract_with_context(lst, pred, before_context, after_context):
"""Extract URL and context from a given chunk.
"""
rval = []
start = 0
length = 0
while start < len(lst):
usedfirst = False
usedlast = False
# Extend to the next match.
while start + length < le... | python | def extract_with_context(lst, pred, before_context, after_context):
"""Extract URL and context from a given chunk.
"""
rval = []
start = 0
length = 0
while start < len(lst):
usedfirst = False
usedlast = False
# Extend to the next match.
while start + length < le... | [
"def",
"extract_with_context",
"(",
"lst",
",",
"pred",
",",
"before_context",
",",
"after_context",
")",
":",
"rval",
"=",
"[",
"]",
"start",
"=",
"0",
"length",
"=",
"0",
"while",
"start",
"<",
"len",
"(",
"lst",
")",
":",
"usedfirst",
"=",
"False",
... | Extract URL and context from a given chunk. | [
"Extract",
"URL",
"and",
"context",
"from",
"a",
"given",
"chunk",
"."
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlscan.py#L335-L394 |
firecat53/urlscan | urlscan/urlscan.py | extracturls | def extracturls(mesg):
"""Given a text message, extract all the URLs found in the message, along
with their surrounding context. The output is a list of sequences of Chunk
objects, corresponding to the contextual regions extracted from the string.
"""
lines = NLRE.split(mesg)
# The number of ... | python | def extracturls(mesg):
"""Given a text message, extract all the URLs found in the message, along
with their surrounding context. The output is a list of sequences of Chunk
objects, corresponding to the contextual regions extracted from the string.
"""
lines = NLRE.split(mesg)
# The number of ... | [
"def",
"extracturls",
"(",
"mesg",
")",
":",
"lines",
"=",
"NLRE",
".",
"split",
"(",
"mesg",
")",
"# The number of lines of context above to provide.",
"# above_context = 1",
"# The number of lines of context below to provide.",
"# below_context = 1",
"# Plan here is to first tr... | Given a text message, extract all the URLs found in the message, along
with their surrounding context. The output is a list of sequences of Chunk
objects, corresponding to the contextual regions extracted from the string. | [
"Given",
"a",
"text",
"message",
"extract",
"all",
"the",
"URLs",
"found",
"in",
"the",
"message",
"along",
"with",
"their",
"surrounding",
"context",
".",
"The",
"output",
"is",
"a",
"list",
"of",
"sequences",
"of",
"Chunk",
"objects",
"corresponding",
"to"... | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlscan.py#L400-L424 |
firecat53/urlscan | urlscan/urlscan.py | extracthtmlurls | def extracthtmlurls(mesg):
"""Extract URLs with context from html type message. Similar to extracturls.
"""
chunk = HTMLChunker()
chunk.feed(mesg)
chunk.close()
# above_context = 1
# below_context = 1
def somechunkisurl(chunks):
for chnk in chunks:
if chnk.url is no... | python | def extracthtmlurls(mesg):
"""Extract URLs with context from html type message. Similar to extracturls.
"""
chunk = HTMLChunker()
chunk.feed(mesg)
chunk.close()
# above_context = 1
# below_context = 1
def somechunkisurl(chunks):
for chnk in chunks:
if chnk.url is no... | [
"def",
"extracthtmlurls",
"(",
"mesg",
")",
":",
"chunk",
"=",
"HTMLChunker",
"(",
")",
"chunk",
".",
"feed",
"(",
"mesg",
")",
"chunk",
".",
"close",
"(",
")",
"# above_context = 1",
"# below_context = 1",
"def",
"somechunkisurl",
"(",
"chunks",
")",
":",
... | Extract URLs with context from html type message. Similar to extracturls. | [
"Extract",
"URLs",
"with",
"context",
"from",
"html",
"type",
"message",
".",
"Similar",
"to",
"extracturls",
"."
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlscan.py#L427-L443 |
firecat53/urlscan | urlscan/urlscan.py | decode_bytes | def decode_bytes(byt, enc='utf-8'):
"""Given a string or bytes input, return a string.
Args: bytes - bytes or string
enc - encoding to use for decoding the byte string.
"""
try:
strg = byt.decode(enc)
except UnicodeDecodeError as err:
strg = "Unable to decode mess... | python | def decode_bytes(byt, enc='utf-8'):
"""Given a string or bytes input, return a string.
Args: bytes - bytes or string
enc - encoding to use for decoding the byte string.
"""
try:
strg = byt.decode(enc)
except UnicodeDecodeError as err:
strg = "Unable to decode mess... | [
"def",
"decode_bytes",
"(",
"byt",
",",
"enc",
"=",
"'utf-8'",
")",
":",
"try",
":",
"strg",
"=",
"byt",
".",
"decode",
"(",
"enc",
")",
"except",
"UnicodeDecodeError",
"as",
"err",
":",
"strg",
"=",
"\"Unable to decode message:\\n{}\\n{}\"",
".",
"format",
... | Given a string or bytes input, return a string.
Args: bytes - bytes or string
enc - encoding to use for decoding the byte string. | [
"Given",
"a",
"string",
"or",
"bytes",
"input",
"return",
"a",
"string",
"."
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlscan.py#L446-L460 |
firecat53/urlscan | urlscan/urlscan.py | decode_msg | def decode_msg(msg, enc='utf-8'):
"""
Decodes a message fragment.
Args: msg - A Message object representing the fragment
enc - The encoding to use for decoding the message
"""
# We avoid the get_payload decoding machinery for raw
# content-transfer-encodings potentially containing non... | python | def decode_msg(msg, enc='utf-8'):
"""
Decodes a message fragment.
Args: msg - A Message object representing the fragment
enc - The encoding to use for decoding the message
"""
# We avoid the get_payload decoding machinery for raw
# content-transfer-encodings potentially containing non... | [
"def",
"decode_msg",
"(",
"msg",
",",
"enc",
"=",
"'utf-8'",
")",
":",
"# We avoid the get_payload decoding machinery for raw",
"# content-transfer-encodings potentially containing non-ascii characters,",
"# such as 8bit or binary, as these are encoded using raw-unicode-escape which",
"# s... | Decodes a message fragment.
Args: msg - A Message object representing the fragment
enc - The encoding to use for decoding the message | [
"Decodes",
"a",
"message",
"fragment",
"."
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlscan.py#L463-L477 |
firecat53/urlscan | urlscan/urlscan.py | msgurls | def msgurls(msg, urlidx=1):
"""Main entry function for urlscan.py
"""
# Written as a generator so I can easily choose only
# one subpart in the future (e.g., for
# multipart/alternative). Actually, I might even add
# a browser for the message structure?
enc = get_charset(msg)
if msg.is... | python | def msgurls(msg, urlidx=1):
"""Main entry function for urlscan.py
"""
# Written as a generator so I can easily choose only
# one subpart in the future (e.g., for
# multipart/alternative). Actually, I might even add
# a browser for the message structure?
enc = get_charset(msg)
if msg.is... | [
"def",
"msgurls",
"(",
"msg",
",",
"urlidx",
"=",
"1",
")",
":",
"# Written as a generator so I can easily choose only",
"# one subpart in the future (e.g., for",
"# multipart/alternative). Actually, I might even add",
"# a browser for the message structure?",
"enc",
"=",
"get_chars... | Main entry function for urlscan.py | [
"Main",
"entry",
"function",
"for",
"urlscan",
".",
"py"
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlscan.py#L480-L503 |
firecat53/urlscan | urlscan/urlchoose.py | shorten_url | def shorten_url(url, cols, shorten):
"""Shorten long URLs to fit on one line.
"""
cols = ((cols - 6) * .85) # 6 cols for urlref and don't use while line
if shorten is False or len(url) < cols:
return url
split = int(cols * .5)
return url[:split] + "..." + url[-split:] | python | def shorten_url(url, cols, shorten):
"""Shorten long URLs to fit on one line.
"""
cols = ((cols - 6) * .85) # 6 cols for urlref and don't use while line
if shorten is False or len(url) < cols:
return url
split = int(cols * .5)
return url[:split] + "..." + url[-split:] | [
"def",
"shorten_url",
"(",
"url",
",",
"cols",
",",
"shorten",
")",
":",
"cols",
"=",
"(",
"(",
"cols",
"-",
"6",
")",
"*",
".85",
")",
"# 6 cols for urlref and don't use while line",
"if",
"shorten",
"is",
"False",
"or",
"len",
"(",
"url",
")",
"<",
"... | Shorten long URLs to fit on one line. | [
"Shorten",
"long",
"URLs",
"to",
"fit",
"on",
"one",
"line",
"."
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L43-L51 |
firecat53/urlscan | urlscan/urlchoose.py | grp_list | def grp_list(items):
"""Organize list of items [a,2,3,4,a,4,2,a,1, etc...] like:
[[a,2,3,4], [a,4,2], [a,1]], where 'a' is a urwid.Divider
"""
grp = []
res = []
for item in items:
if isinstance(item, urwid.Divider):
res.append(grp)
grp = [items[0]]
el... | python | def grp_list(items):
"""Organize list of items [a,2,3,4,a,4,2,a,1, etc...] like:
[[a,2,3,4], [a,4,2], [a,1]], where 'a' is a urwid.Divider
"""
grp = []
res = []
for item in items:
if isinstance(item, urwid.Divider):
res.append(grp)
grp = [items[0]]
el... | [
"def",
"grp_list",
"(",
"items",
")",
":",
"grp",
"=",
"[",
"]",
"res",
"=",
"[",
"]",
"for",
"item",
"in",
"items",
":",
"if",
"isinstance",
"(",
"item",
",",
"urwid",
".",
"Divider",
")",
":",
"res",
".",
"append",
"(",
"grp",
")",
"grp",
"="... | Organize list of items [a,2,3,4,a,4,2,a,1, etc...] like:
[[a,2,3,4], [a,4,2], [a,1]], where 'a' is a urwid.Divider | [
"Organize",
"list",
"of",
"items",
"[",
"a",
"2",
"3",
"4",
"a",
"4",
"2",
"a",
"1",
"etc",
"...",
"]",
"like",
":",
"[[",
"a",
"2",
"3",
"4",
"]",
"[",
"a",
"4",
"2",
"]",
"[",
"a",
"1",
"]]",
"where",
"a",
"is",
"a",
"urwid",
".",
"Di... | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L54-L68 |
firecat53/urlscan | urlscan/urlchoose.py | splittext | def splittext(text, search, attr):
"""Split a text string by search string and add Urwid display attribute to
the search term.
Args: text - string
search - search string
attr - attribute string to add
Returns: urwid markup list ["string", ("default", " mo"), "re string"]
... | python | def splittext(text, search, attr):
"""Split a text string by search string and add Urwid display attribute to
the search term.
Args: text - string
search - search string
attr - attribute string to add
Returns: urwid markup list ["string", ("default", " mo"), "re string"]
... | [
"def",
"splittext",
"(",
"text",
",",
"search",
",",
"attr",
")",
":",
"if",
"search",
":",
"pat",
"=",
"re",
".",
"compile",
"(",
"\"({})\"",
".",
"format",
"(",
"re",
".",
"escape",
"(",
"search",
")",
")",
",",
"re",
".",
"IGNORECASE",
")",
"e... | Split a text string by search string and add Urwid display attribute to
the search term.
Args: text - string
search - search string
attr - attribute string to add
Returns: urwid markup list ["string", ("default", " mo"), "re string"]
for search="mo", text="string more stri... | [
"Split",
"a",
"text",
"string",
"by",
"search",
"string",
"and",
"add",
"Urwid",
"display",
"attribute",
"to",
"the",
"search",
"term",
"."
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L71-L89 |
firecat53/urlscan | urlscan/urlchoose.py | URLChooser.main | def main(self):
"""Urwid main event loop
"""
self.loop = urwid.MainLoop(self.top, self.palettes[self.palette_names[0]], screen=self.tui,
handle_mouse=False, input_filter=self.handle_keys,
unhandled_input=self.unhandled)
... | python | def main(self):
"""Urwid main event loop
"""
self.loop = urwid.MainLoop(self.top, self.palettes[self.palette_names[0]], screen=self.tui,
handle_mouse=False, input_filter=self.handle_keys,
unhandled_input=self.unhandled)
... | [
"def",
"main",
"(",
"self",
")",
":",
"self",
".",
"loop",
"=",
"urwid",
".",
"MainLoop",
"(",
"self",
".",
"top",
",",
"self",
".",
"palettes",
"[",
"self",
".",
"palette_names",
"[",
"0",
"]",
"]",
",",
"screen",
"=",
"self",
".",
"tui",
",",
... | Urwid main event loop | [
"Urwid",
"main",
"event",
"loop"
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L213-L220 |
firecat53/urlscan | urlscan/urlchoose.py | URLChooser.handle_keys | def handle_keys(self, keys, raw):
"""Handle widget default keys
- 'Enter' or 'space' to load URL
- 'Enter' to end search mode
- add 'space' to search string in search mode
- Workaround some small positioning bugs
"""
for j, k in enumerate(keys):
... | python | def handle_keys(self, keys, raw):
"""Handle widget default keys
- 'Enter' or 'space' to load URL
- 'Enter' to end search mode
- add 'space' to search string in search mode
- Workaround some small positioning bugs
"""
for j, k in enumerate(keys):
... | [
"def",
"handle_keys",
"(",
"self",
",",
"keys",
",",
"raw",
")",
":",
"for",
"j",
",",
"k",
"in",
"enumerate",
"(",
"keys",
")",
":",
"if",
"self",
".",
"search",
"is",
"True",
":",
"text",
"=",
"\"Search: {}\"",
".",
"format",
"(",
"self",
".",
... | Handle widget default keys
- 'Enter' or 'space' to load URL
- 'Enter' to end search mode
- add 'space' to search string in search mode
- Workaround some small positioning bugs | [
"Handle",
"widget",
"default",
"keys"
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L222-L271 |
firecat53/urlscan | urlscan/urlchoose.py | URLChooser.unhandled | def unhandled(self, key):
"""Handle other keyboard actions not handled by the ListBox widget.
"""
self.key = key
self.size = self.tui.get_cols_rows()
if self.search is True:
if self.enter is False and self.no_matches is False:
if len(key) == 1 and key... | python | def unhandled(self, key):
"""Handle other keyboard actions not handled by the ListBox widget.
"""
self.key = key
self.size = self.tui.get_cols_rows()
if self.search is True:
if self.enter is False and self.no_matches is False:
if len(key) == 1 and key... | [
"def",
"unhandled",
"(",
"self",
",",
"key",
")",
":",
"self",
".",
"key",
"=",
"key",
"self",
".",
"size",
"=",
"self",
".",
"tui",
".",
"get_cols_rows",
"(",
")",
"if",
"self",
".",
"search",
"is",
"True",
":",
"if",
"self",
".",
"enter",
"is",... | Handle other keyboard actions not handled by the ListBox widget. | [
"Handle",
"other",
"keyboard",
"actions",
"not",
"handled",
"by",
"the",
"ListBox",
"widget",
"."
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L273-L294 |
firecat53/urlscan | urlscan/urlchoose.py | URLChooser._open_url | def _open_url(self):
"""<Enter> or <space>"""
load_text = "Loading URL..." if not self.run else "Executing: {}".format(self.run)
if os.environ.get('BROWSER') not in ['elinks', 'links', 'w3m', 'lynx']:
self._footer_start_thread(load_text, 5) | python | def _open_url(self):
"""<Enter> or <space>"""
load_text = "Loading URL..." if not self.run else "Executing: {}".format(self.run)
if os.environ.get('BROWSER') not in ['elinks', 'links', 'w3m', 'lynx']:
self._footer_start_thread(load_text, 5) | [
"def",
"_open_url",
"(",
"self",
")",
":",
"load_text",
"=",
"\"Loading URL...\"",
"if",
"not",
"self",
".",
"run",
"else",
"\"Executing: {}\"",
".",
"format",
"(",
"self",
".",
"run",
")",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"'BROWSER'",
")",
... | <Enter> or <space> | [
"<Enter",
">",
"or",
"<space",
">"
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L300-L304 |
firecat53/urlscan | urlscan/urlchoose.py | URLChooser._help_menu | def _help_menu(self):
"""F1"""
if self.help_menu is False:
self.focus_pos_saved = self.top.body.focus_position
help_men = "\n".join(["{} - {}".format(i, j.__name__.strip('_'))
for i, j in self.keys.items() if j.__name__ !=
... | python | def _help_menu(self):
"""F1"""
if self.help_menu is False:
self.focus_pos_saved = self.top.body.focus_position
help_men = "\n".join(["{} - {}".format(i, j.__name__.strip('_'))
for i, j in self.keys.items() if j.__name__ !=
... | [
"def",
"_help_menu",
"(",
"self",
")",
":",
"if",
"self",
".",
"help_menu",
"is",
"False",
":",
"self",
".",
"focus_pos_saved",
"=",
"self",
".",
"top",
".",
"body",
".",
"focus_position",
"help_men",
"=",
"\"\\n\"",
".",
"join",
"(",
"[",
"\"{} - {}\"",... | F1 | [
"F1"
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L306-L337 |
firecat53/urlscan | urlscan/urlchoose.py | URLChooser._search_key | def _search_key(self):
""" / """
if self.urls:
self.search = True
if self.compact is True:
self.compact = False
self.items, self.items_com = self.items_com, self.items
else:
return
self.no_matches = False
self.se... | python | def _search_key(self):
""" / """
if self.urls:
self.search = True
if self.compact is True:
self.compact = False
self.items, self.items_com = self.items_com, self.items
else:
return
self.no_matches = False
self.se... | [
"def",
"_search_key",
"(",
"self",
")",
":",
"if",
"self",
".",
"urls",
":",
"self",
".",
"search",
"=",
"True",
"if",
"self",
".",
"compact",
"is",
"True",
":",
"self",
".",
"compact",
"=",
"False",
"self",
".",
"items",
",",
"self",
".",
"items_c... | / | [
"/"
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L339-L355 |
firecat53/urlscan | urlscan/urlchoose.py | URLChooser._digits | def _digits(self):
""" 0-9 """
self.number += self.key
try:
if self.compact is False:
self.top.body.focus_position = \
self.items.index(self.items_com[max(int(self.number) - 1, 0)])
else:
self.top.body.focus_position = \... | python | def _digits(self):
""" 0-9 """
self.number += self.key
try:
if self.compact is False:
self.top.body.focus_position = \
self.items.index(self.items_com[max(int(self.number) - 1, 0)])
else:
self.top.body.focus_position = \... | [
"def",
"_digits",
"(",
"self",
")",
":",
"self",
".",
"number",
"+=",
"self",
".",
"key",
"try",
":",
"if",
"self",
".",
"compact",
"is",
"False",
":",
"self",
".",
"top",
".",
"body",
".",
"focus_position",
"=",
"self",
".",
"items",
".",
"index",... | 0-9 | [
"0",
"-",
"9"
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L357-L371 |
firecat53/urlscan | urlscan/urlchoose.py | URLChooser._top | def _top(self):
""" g """
# Goto top of the list
self.top.body.focus_position = 2 if self.compact is False else 0
self.top.keypress(self.size, "") | python | def _top(self):
""" g """
# Goto top of the list
self.top.body.focus_position = 2 if self.compact is False else 0
self.top.keypress(self.size, "") | [
"def",
"_top",
"(",
"self",
")",
":",
"# Goto top of the list",
"self",
".",
"top",
".",
"body",
".",
"focus_position",
"=",
"2",
"if",
"self",
".",
"compact",
"is",
"False",
"else",
"0",
"self",
".",
"top",
".",
"keypress",
"(",
"self",
".",
"size",
... | g | [
"g"
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L385-L389 |
firecat53/urlscan | urlscan/urlchoose.py | URLChooser._bottom | def _bottom(self):
""" G """
# Goto bottom of the list
self.top.body.focus_position = len(self.items) - 1
self.top.keypress(self.size, "") | python | def _bottom(self):
""" G """
# Goto bottom of the list
self.top.body.focus_position = len(self.items) - 1
self.top.keypress(self.size, "") | [
"def",
"_bottom",
"(",
"self",
")",
":",
"# Goto bottom of the list",
"self",
".",
"top",
".",
"body",
".",
"focus_position",
"=",
"len",
"(",
"self",
".",
"items",
")",
"-",
"1",
"self",
".",
"top",
".",
"keypress",
"(",
"self",
".",
"size",
",",
"\... | G | [
"G"
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L391-L395 |
firecat53/urlscan | urlscan/urlchoose.py | URLChooser._shorten | def _shorten(self):
""" s """
# Toggle shortened URL for selected item
fpo = self.top.body.focus_position
url_idx = len([i for i in self.items[:fpo + 1]
if isinstance(i, urwid.Columns)]) - 1
if self.compact is False and fpo <= 1:
return
... | python | def _shorten(self):
""" s """
# Toggle shortened URL for selected item
fpo = self.top.body.focus_position
url_idx = len([i for i in self.items[:fpo + 1]
if isinstance(i, urwid.Columns)]) - 1
if self.compact is False and fpo <= 1:
return
... | [
"def",
"_shorten",
"(",
"self",
")",
":",
"# Toggle shortened URL for selected item",
"fpo",
"=",
"self",
".",
"top",
".",
"body",
".",
"focus_position",
"url_idx",
"=",
"len",
"(",
"[",
"i",
"for",
"i",
"in",
"self",
".",
"items",
"[",
":",
"fpo",
"+",
... | s | [
"s"
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L397-L407 |
firecat53/urlscan | urlscan/urlchoose.py | URLChooser._all_shorten | def _all_shorten(self):
""" S """
# Toggle all shortened URLs
self.shorten = not self.shorten
urls = iter(self.urls)
for item in self.items:
# Each Column has (Text, Button). Update the Button label
if isinstance(item, urwid.Columns):
item[... | python | def _all_shorten(self):
""" S """
# Toggle all shortened URLs
self.shorten = not self.shorten
urls = iter(self.urls)
for item in self.items:
# Each Column has (Text, Button). Update the Button label
if isinstance(item, urwid.Columns):
item[... | [
"def",
"_all_shorten",
"(",
"self",
")",
":",
"# Toggle all shortened URLs",
"self",
".",
"shorten",
"=",
"not",
"self",
".",
"shorten",
"urls",
"=",
"iter",
"(",
"self",
".",
"urls",
")",
"for",
"item",
"in",
"self",
".",
"items",
":",
"# Each Column has ... | S | [
"S"
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L409-L419 |
firecat53/urlscan | urlscan/urlchoose.py | URLChooser._all_escape | def _all_escape(self):
""" u """
# Toggle all escaped URLs
self.unesc = not self.unesc
self.urls, self.urls_unesc = self.urls_unesc, self.urls
urls = iter(self.urls)
for item in self.items:
# Each Column has (Text, Button). Update the Button label
... | python | def _all_escape(self):
""" u """
# Toggle all escaped URLs
self.unesc = not self.unesc
self.urls, self.urls_unesc = self.urls_unesc, self.urls
urls = iter(self.urls)
for item in self.items:
# Each Column has (Text, Button). Update the Button label
... | [
"def",
"_all_escape",
"(",
"self",
")",
":",
"# Toggle all escaped URLs",
"self",
".",
"unesc",
"=",
"not",
"self",
".",
"unesc",
"self",
".",
"urls",
",",
"self",
".",
"urls_unesc",
"=",
"self",
".",
"urls_unesc",
",",
"self",
".",
"urls",
"urls",
"=",
... | u | [
"u"
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L420-L431 |
firecat53/urlscan | urlscan/urlchoose.py | URLChooser._context | def _context(self):
""" c """
# Show/hide context
if self.search_string:
# Reset search when toggling compact mode
footerwid = urwid.AttrMap(urwid.Text(""), 'default')
self.top.footer = footerwid
self.search_string = ""
self.items = sel... | python | def _context(self):
""" c """
# Show/hide context
if self.search_string:
# Reset search when toggling compact mode
footerwid = urwid.AttrMap(urwid.Text(""), 'default')
self.top.footer = footerwid
self.search_string = ""
self.items = sel... | [
"def",
"_context",
"(",
"self",
")",
":",
"# Show/hide context",
"if",
"self",
".",
"search_string",
":",
"# Reset search when toggling compact mode",
"footerwid",
"=",
"urwid",
".",
"AttrMap",
"(",
"urwid",
".",
"Text",
"(",
"\"\"",
")",
",",
"'default'",
")",
... | c | [
"c"
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L433-L446 |
firecat53/urlscan | urlscan/urlchoose.py | URLChooser._clipboard | def _clipboard(self, pri=False):
""" C """
# Copy highlighted url to clipboard
fpo = self.top.body.focus_position
url_idx = len([i for i in self.items[:fpo + 1]
if isinstance(i, urwid.Columns)]) - 1
if self.compact is False and fpo <= 1:
return
... | python | def _clipboard(self, pri=False):
""" C """
# Copy highlighted url to clipboard
fpo = self.top.body.focus_position
url_idx = len([i for i in self.items[:fpo + 1]
if isinstance(i, urwid.Columns)]) - 1
if self.compact is False and fpo <= 1:
return
... | [
"def",
"_clipboard",
"(",
"self",
",",
"pri",
"=",
"False",
")",
":",
"# Copy highlighted url to clipboard",
"fpo",
"=",
"self",
".",
"top",
".",
"body",
".",
"focus_position",
"url_idx",
"=",
"len",
"(",
"[",
"i",
"for",
"i",
"in",
"self",
".",
"items",... | C | [
"C"
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L448-L469 |
firecat53/urlscan | urlscan/urlchoose.py | URLChooser._palette | def _palette(self):
""" p """
# Loop through available palettes
self.palette_idx += 1
try:
self.loop.screen.register_palette(self.palettes[self.palette_names[self.palette_idx]])
except IndexError:
self.loop.screen.register_palette(self.palettes[self.palett... | python | def _palette(self):
""" p """
# Loop through available palettes
self.palette_idx += 1
try:
self.loop.screen.register_palette(self.palettes[self.palette_names[self.palette_idx]])
except IndexError:
self.loop.screen.register_palette(self.palettes[self.palett... | [
"def",
"_palette",
"(",
"self",
")",
":",
"# Loop through available palettes",
"self",
".",
"palette_idx",
"+=",
"1",
"try",
":",
"self",
".",
"loop",
".",
"screen",
".",
"register_palette",
"(",
"self",
".",
"palettes",
"[",
"self",
".",
"palette_names",
"[... | p | [
"p"
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L476-L485 |
firecat53/urlscan | urlscan/urlchoose.py | URLChooser._config_create | def _config_create(self):
""" --genconf """
# Create ~/.config/urlscan/config.json if if doesn't exist
if not exists(self.conf):
try:
# Python 2/3 compatible recursive directory creation
os.makedirs(dirname(expanduser(self.conf)))
except OS... | python | def _config_create(self):
""" --genconf """
# Create ~/.config/urlscan/config.json if if doesn't exist
if not exists(self.conf):
try:
# Python 2/3 compatible recursive directory creation
os.makedirs(dirname(expanduser(self.conf)))
except OS... | [
"def",
"_config_create",
"(",
"self",
")",
":",
"# Create ~/.config/urlscan/config.json if if doesn't exist",
"if",
"not",
"exists",
"(",
"self",
".",
"conf",
")",
":",
"try",
":",
"# Python 2/3 compatible recursive directory creation",
"os",
".",
"makedirs",
"(",
"dirn... | --genconf | [
"--",
"genconf"
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L487-L504 |
firecat53/urlscan | urlscan/urlchoose.py | URLChooser._footer_start_thread | def _footer_start_thread(self, text, time):
"""Display given text in the footer. Clears after <time> seconds
"""
footerwid = urwid.AttrMap(urwid.Text(text), 'footer')
self.top.footer = footerwid
load_thread = Thread(target=self._loading_thread, args=(time,))
load_thread.... | python | def _footer_start_thread(self, text, time):
"""Display given text in the footer. Clears after <time> seconds
"""
footerwid = urwid.AttrMap(urwid.Text(text), 'footer')
self.top.footer = footerwid
load_thread = Thread(target=self._loading_thread, args=(time,))
load_thread.... | [
"def",
"_footer_start_thread",
"(",
"self",
",",
"text",
",",
"time",
")",
":",
"footerwid",
"=",
"urwid",
".",
"AttrMap",
"(",
"urwid",
".",
"Text",
"(",
"text",
")",
",",
"'footer'",
")",
"self",
".",
"top",
".",
"footer",
"=",
"footerwid",
"load_thr... | Display given text in the footer. Clears after <time> seconds | [
"Display",
"given",
"text",
"in",
"the",
"footer",
".",
"Clears",
"after",
"<time",
">",
"seconds"
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L507-L515 |
firecat53/urlscan | urlscan/urlchoose.py | URLChooser._loading_thread | def _loading_thread(self, time):
"""Simple thread to wait <time> seconds after launching a URL or
displaying a URL selection number, clearing the screen and clearing the
footer loading message.
"""
sleep(time)
self.number = "" # Clear URL selection number
text =... | python | def _loading_thread(self, time):
"""Simple thread to wait <time> seconds after launching a URL or
displaying a URL selection number, clearing the screen and clearing the
footer loading message.
"""
sleep(time)
self.number = "" # Clear URL selection number
text =... | [
"def",
"_loading_thread",
"(",
"self",
",",
"time",
")",
":",
"sleep",
"(",
"time",
")",
"self",
".",
"number",
"=",
"\"\"",
"# Clear URL selection number",
"text",
"=",
"\"Search: {}\"",
".",
"format",
"(",
"self",
".",
"search_string",
")",
"if",
"self",
... | Simple thread to wait <time> seconds after launching a URL or
displaying a URL selection number, clearing the screen and clearing the
footer loading message. | [
"Simple",
"thread",
"to",
"wait",
"<time",
">",
"seconds",
"after",
"launching",
"a",
"URL",
"or",
"displaying",
"a",
"URL",
"selection",
"number",
"clearing",
"the",
"screen",
"and",
"clearing",
"the",
"footer",
"loading",
"message",
"."
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L517-L534 |
firecat53/urlscan | urlscan/urlchoose.py | URLChooser._search | def _search(self):
""" Search - search URLs and text.
"""
text = "Search: {}".format(self.search_string)
footerwid = urwid.AttrMap(urwid.Text(text), 'footer')
self.top.footer = footerwid
search_items = []
for grp in self.items_org:
done = False
... | python | def _search(self):
""" Search - search URLs and text.
"""
text = "Search: {}".format(self.search_string)
footerwid = urwid.AttrMap(urwid.Text(text), 'footer')
self.top.footer = footerwid
search_items = []
for grp in self.items_org:
done = False
... | [
"def",
"_search",
"(",
"self",
")",
":",
"text",
"=",
"\"Search: {}\"",
".",
"format",
"(",
"self",
".",
"search_string",
")",
"footerwid",
"=",
"urwid",
".",
"AttrMap",
"(",
"urwid",
".",
"Text",
"(",
"text",
")",
",",
"'footer'",
")",
"self",
".",
... | Search - search URLs and text. | [
"Search",
"-",
"search",
"URLs",
"and",
"text",
"."
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L547-L586 |
firecat53/urlscan | urlscan/urlchoose.py | URLChooser.draw_screen | def draw_screen(self, size):
"""Render curses screen
"""
self.tui.clear()
canvas = self.top.render(size, focus=True)
self.tui.draw_screen(size, canvas) | python | def draw_screen(self, size):
"""Render curses screen
"""
self.tui.clear()
canvas = self.top.render(size, focus=True)
self.tui.draw_screen(size, canvas) | [
"def",
"draw_screen",
"(",
"self",
",",
"size",
")",
":",
"self",
".",
"tui",
".",
"clear",
"(",
")",
"canvas",
"=",
"self",
".",
"top",
".",
"render",
"(",
"size",
",",
"focus",
"=",
"True",
")",
"self",
".",
"tui",
".",
"draw_screen",
"(",
"siz... | Render curses screen | [
"Render",
"curses",
"screen"
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L588-L594 |
firecat53/urlscan | urlscan/urlchoose.py | URLChooser.mkbrowseto | def mkbrowseto(self, url):
"""Create the urwid callback function to open the web browser or call
another function with the URL.
"""
# Try-except block to work around webbrowser module bug
# https://bugs.python.org/issue31014
try:
browser = os.environ['BROWSER... | python | def mkbrowseto(self, url):
"""Create the urwid callback function to open the web browser or call
another function with the URL.
"""
# Try-except block to work around webbrowser module bug
# https://bugs.python.org/issue31014
try:
browser = os.environ['BROWSER... | [
"def",
"mkbrowseto",
"(",
"self",
",",
"url",
")",
":",
"# Try-except block to work around webbrowser module bug",
"# https://bugs.python.org/issue31014",
"try",
":",
"browser",
"=",
"os",
".",
"environ",
"[",
"'BROWSER'",
"]",
"except",
"KeyError",
":",
"pass",
"else... | Create the urwid callback function to open the web browser or call
another function with the URL. | [
"Create",
"the",
"urwid",
"callback",
"function",
"to",
"open",
"the",
"web",
"browser",
"or",
"call",
"another",
"function",
"with",
"the",
"URL",
"."
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L599-L634 |
firecat53/urlscan | urlscan/urlchoose.py | URLChooser.process_urls | def process_urls(self, extractedurls, dedupe, shorten):
"""Process the 'extractedurls' and ready them for either the curses browser
or non-interactive output
Args: extractedurls
dedupe - Remove duplicate URLs from list
Returns: items - List of widgets for the ListBox
... | python | def process_urls(self, extractedurls, dedupe, shorten):
"""Process the 'extractedurls' and ready them for either the curses browser
or non-interactive output
Args: extractedurls
dedupe - Remove duplicate URLs from list
Returns: items - List of widgets for the ListBox
... | [
"def",
"process_urls",
"(",
"self",
",",
"extractedurls",
",",
"dedupe",
",",
"shorten",
")",
":",
"cols",
",",
"_",
"=",
"urwid",
".",
"raw_display",
".",
"Screen",
"(",
")",
".",
"get_cols_rows",
"(",
")",
"items",
"=",
"[",
"]",
"urls",
"=",
"[",
... | Process the 'extractedurls' and ready them for either the curses browser
or non-interactive output
Args: extractedurls
dedupe - Remove duplicate URLs from list
Returns: items - List of widgets for the ListBox
urls - List of all URLs | [
"Process",
"the",
"extractedurls",
"and",
"ready",
"them",
"for",
"either",
"the",
"curses",
"browser",
"or",
"non",
"-",
"interactive",
"output"
] | train | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L636-L711 |
TheRealLink/pylgtv | pylgtv/webos_client.py | WebOsClient._get_key_file_path | def _get_key_file_path():
"""Return the key file path."""
if os.getenv(USER_HOME) is not None and os.access(os.getenv(USER_HOME),
os.W_OK):
return os.path.join(os.getenv(USER_HOME), KEY_FILE_NAME)
return os.path.join(os.getcw... | python | def _get_key_file_path():
"""Return the key file path."""
if os.getenv(USER_HOME) is not None and os.access(os.getenv(USER_HOME),
os.W_OK):
return os.path.join(os.getenv(USER_HOME), KEY_FILE_NAME)
return os.path.join(os.getcw... | [
"def",
"_get_key_file_path",
"(",
")",
":",
"if",
"os",
".",
"getenv",
"(",
"USER_HOME",
")",
"is",
"not",
"None",
"and",
"os",
".",
"access",
"(",
"os",
".",
"getenv",
"(",
"USER_HOME",
")",
",",
"os",
".",
"W_OK",
")",
":",
"return",
"os",
".",
... | Return the key file path. | [
"Return",
"the",
"key",
"file",
"path",
"."
] | train | https://github.com/TheRealLink/pylgtv/blob/a7d9ad87ce47e77180fe9262da785465219f4ed6/pylgtv/webos_client.py#L39-L45 |
TheRealLink/pylgtv | pylgtv/webos_client.py | WebOsClient.load_key_file | def load_key_file(self):
"""Try to load the client key for the current ip."""
self.client_key = None
if self.key_file_path:
key_file_path = self.key_file_path
else:
key_file_path = self._get_key_file_path()
key_dict = {}
logger.debug('load keyfile... | python | def load_key_file(self):
"""Try to load the client key for the current ip."""
self.client_key = None
if self.key_file_path:
key_file_path = self.key_file_path
else:
key_file_path = self._get_key_file_path()
key_dict = {}
logger.debug('load keyfile... | [
"def",
"load_key_file",
"(",
"self",
")",
":",
"self",
".",
"client_key",
"=",
"None",
"if",
"self",
".",
"key_file_path",
":",
"key_file_path",
"=",
"self",
".",
"key_file_path",
"else",
":",
"key_file_path",
"=",
"self",
".",
"_get_key_file_path",
"(",
")"... | Try to load the client key for the current ip. | [
"Try",
"to",
"load",
"the",
"client",
"key",
"for",
"the",
"current",
"ip",
"."
] | train | https://github.com/TheRealLink/pylgtv/blob/a7d9ad87ce47e77180fe9262da785465219f4ed6/pylgtv/webos_client.py#L47-L66 |
TheRealLink/pylgtv | pylgtv/webos_client.py | WebOsClient.save_key_file | def save_key_file(self):
"""Save the current client key."""
if self.client_key is None:
return
if self.key_file_path:
key_file_path = self.key_file_path
else:
key_file_path = self._get_key_file_path()
logger.debug('save keyfile to %s', key_fi... | python | def save_key_file(self):
"""Save the current client key."""
if self.client_key is None:
return
if self.key_file_path:
key_file_path = self.key_file_path
else:
key_file_path = self._get_key_file_path()
logger.debug('save keyfile to %s', key_fi... | [
"def",
"save_key_file",
"(",
"self",
")",
":",
"if",
"self",
".",
"client_key",
"is",
"None",
":",
"return",
"if",
"self",
".",
"key_file_path",
":",
"key_file_path",
"=",
"self",
".",
"key_file_path",
"else",
":",
"key_file_path",
"=",
"self",
".",
"_get_... | Save the current client key. | [
"Save",
"the",
"current",
"client",
"key",
"."
] | train | https://github.com/TheRealLink/pylgtv/blob/a7d9ad87ce47e77180fe9262da785465219f4ed6/pylgtv/webos_client.py#L68-L89 |
TheRealLink/pylgtv | pylgtv/webos_client.py | WebOsClient._send_register_payload | def _send_register_payload(self, websocket):
"""Send the register payload."""
file = os.path.join(os.path.dirname(__file__), HANDSHAKE_FILE_NAME)
data = codecs.open(file, 'r', 'utf-8')
raw_handshake = data.read()
handshake = json.loads(raw_handshake)
handshake['payload'... | python | def _send_register_payload(self, websocket):
"""Send the register payload."""
file = os.path.join(os.path.dirname(__file__), HANDSHAKE_FILE_NAME)
data = codecs.open(file, 'r', 'utf-8')
raw_handshake = data.read()
handshake = json.loads(raw_handshake)
handshake['payload'... | [
"def",
"_send_register_payload",
"(",
"self",
",",
"websocket",
")",
":",
"file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"HANDSHAKE_FILE_NAME",
")",
"data",
"=",
"codecs",
".",
"open",
"(... | Send the register payload. | [
"Send",
"the",
"register",
"payload",
"."
] | train | https://github.com/TheRealLink/pylgtv/blob/a7d9ad87ce47e77180fe9262da785465219f4ed6/pylgtv/webos_client.py#L92-L112 |
TheRealLink/pylgtv | pylgtv/webos_client.py | WebOsClient._register | def _register(self):
"""Register wrapper."""
logger.debug('register on %s', "ws://{}:{}".format(self.ip, self.port));
try:
websocket = yield from websockets.connect(
"ws://{}:{}".format(self.ip, self.port), timeout=self.timeout_connect)
except:
lo... | python | def _register(self):
"""Register wrapper."""
logger.debug('register on %s', "ws://{}:{}".format(self.ip, self.port));
try:
websocket = yield from websockets.connect(
"ws://{}:{}".format(self.ip, self.port), timeout=self.timeout_connect)
except:
lo... | [
"def",
"_register",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"'register on %s'",
",",
"\"ws://{}:{}\"",
".",
"format",
"(",
"self",
".",
"ip",
",",
"self",
".",
"port",
")",
")",
"try",
":",
"websocket",
"=",
"yield",
"from",
"websockets",
"... | Register wrapper. | [
"Register",
"wrapper",
"."
] | train | https://github.com/TheRealLink/pylgtv/blob/a7d9ad87ce47e77180fe9262da785465219f4ed6/pylgtv/webos_client.py#L119-L137 |
TheRealLink/pylgtv | pylgtv/webos_client.py | WebOsClient.register | def register(self):
"""Pair client with tv."""
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(self._register()) | python | def register(self):
"""Pair client with tv."""
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(self._register()) | [
"def",
"register",
"(",
"self",
")",
":",
"loop",
"=",
"asyncio",
".",
"new_event_loop",
"(",
")",
"asyncio",
".",
"set_event_loop",
"(",
"loop",
")",
"loop",
".",
"run_until_complete",
"(",
"self",
".",
"_register",
"(",
")",
")"
] | Pair client with tv. | [
"Pair",
"client",
"with",
"tv",
"."
] | train | https://github.com/TheRealLink/pylgtv/blob/a7d9ad87ce47e77180fe9262da785465219f4ed6/pylgtv/webos_client.py#L139-L143 |
TheRealLink/pylgtv | pylgtv/webos_client.py | WebOsClient._command | def _command(self, msg):
"""Send a command to the tv."""
logger.debug('send command to %s', "ws://{}:{}".format(self.ip, self.port));
try:
websocket = yield from websockets.connect(
"ws://{}:{}".format(self.ip, self.port), timeout=self.timeout_connect)
except:... | python | def _command(self, msg):
"""Send a command to the tv."""
logger.debug('send command to %s', "ws://{}:{}".format(self.ip, self.port));
try:
websocket = yield from websockets.connect(
"ws://{}:{}".format(self.ip, self.port), timeout=self.timeout_connect)
except:... | [
"def",
"_command",
"(",
"self",
",",
"msg",
")",
":",
"logger",
".",
"debug",
"(",
"'send command to %s'",
",",
"\"ws://{}:{}\"",
".",
"format",
"(",
"self",
".",
"ip",
",",
"self",
".",
"port",
")",
")",
"try",
":",
"websocket",
"=",
"yield",
"from",
... | Send a command to the tv. | [
"Send",
"a",
"command",
"to",
"the",
"tv",
"."
] | train | https://github.com/TheRealLink/pylgtv/blob/a7d9ad87ce47e77180fe9262da785465219f4ed6/pylgtv/webos_client.py#L146-L172 |
TheRealLink/pylgtv | pylgtv/webos_client.py | WebOsClient.command | def command(self, request_type, uri, payload):
"""Build and send a command."""
self.command_count += 1
if payload is None:
payload = {}
message = {
'id': "{}_{}".format(type, self.command_count),
'type': request_type,
'uri': "ssap://{}".f... | python | def command(self, request_type, uri, payload):
"""Build and send a command."""
self.command_count += 1
if payload is None:
payload = {}
message = {
'id': "{}_{}".format(type, self.command_count),
'type': request_type,
'uri': "ssap://{}".f... | [
"def",
"command",
"(",
"self",
",",
"request_type",
",",
"uri",
",",
"payload",
")",
":",
"self",
".",
"command_count",
"+=",
"1",
"if",
"payload",
"is",
"None",
":",
"payload",
"=",
"{",
"}",
"message",
"=",
"{",
"'id'",
":",
"\"{}_{}\"",
".",
"form... | Build and send a command. | [
"Build",
"and",
"send",
"a",
"command",
"."
] | train | https://github.com/TheRealLink/pylgtv/blob/a7d9ad87ce47e77180fe9262da785465219f4ed6/pylgtv/webos_client.py#L174-L195 |
TheRealLink/pylgtv | pylgtv/webos_client.py | WebOsClient.send_message | def send_message(self, message, icon_path=None):
"""Show a floating message."""
icon_encoded_string = ''
icon_extension = ''
if icon_path is not None:
icon_extension = os.path.splitext(icon_path)[1][1:]
with open(icon_path, 'rb') as icon_file:
ico... | python | def send_message(self, message, icon_path=None):
"""Show a floating message."""
icon_encoded_string = ''
icon_extension = ''
if icon_path is not None:
icon_extension = os.path.splitext(icon_path)[1][1:]
with open(icon_path, 'rb') as icon_file:
ico... | [
"def",
"send_message",
"(",
"self",
",",
"message",
",",
"icon_path",
"=",
"None",
")",
":",
"icon_encoded_string",
"=",
"''",
"icon_extension",
"=",
"''",
"if",
"icon_path",
"is",
"not",
"None",
":",
"icon_extension",
"=",
"os",
".",
"path",
".",
"splitex... | Show a floating message. | [
"Show",
"a",
"floating",
"message",
"."
] | train | https://github.com/TheRealLink/pylgtv/blob/a7d9ad87ce47e77180fe9262da785465219f4ed6/pylgtv/webos_client.py#L201-L215 |
TheRealLink/pylgtv | pylgtv/webos_client.py | WebOsClient.get_apps | def get_apps(self):
"""Return all apps."""
self.request(EP_GET_APPS)
return {} if self.last_response is None else self.last_response.get('payload').get('launchPoints') | python | def get_apps(self):
"""Return all apps."""
self.request(EP_GET_APPS)
return {} if self.last_response is None else self.last_response.get('payload').get('launchPoints') | [
"def",
"get_apps",
"(",
"self",
")",
":",
"self",
".",
"request",
"(",
"EP_GET_APPS",
")",
"return",
"{",
"}",
"if",
"self",
".",
"last_response",
"is",
"None",
"else",
"self",
".",
"last_response",
".",
"get",
"(",
"'payload'",
")",
".",
"get",
"(",
... | Return all apps. | [
"Return",
"all",
"apps",
"."
] | train | https://github.com/TheRealLink/pylgtv/blob/a7d9ad87ce47e77180fe9262da785465219f4ed6/pylgtv/webos_client.py#L218-L221 |
TheRealLink/pylgtv | pylgtv/webos_client.py | WebOsClient.get_current_app | def get_current_app(self):
"""Get the current app id."""
self.request(EP_GET_CURRENT_APP_INFO)
return None if self.last_response is None else self.last_response.get('payload').get('appId') | python | def get_current_app(self):
"""Get the current app id."""
self.request(EP_GET_CURRENT_APP_INFO)
return None if self.last_response is None else self.last_response.get('payload').get('appId') | [
"def",
"get_current_app",
"(",
"self",
")",
":",
"self",
".",
"request",
"(",
"EP_GET_CURRENT_APP_INFO",
")",
"return",
"None",
"if",
"self",
".",
"last_response",
"is",
"None",
"else",
"self",
".",
"last_response",
".",
"get",
"(",
"'payload'",
")",
".",
... | Get the current app id. | [
"Get",
"the",
"current",
"app",
"id",
"."
] | train | https://github.com/TheRealLink/pylgtv/blob/a7d9ad87ce47e77180fe9262da785465219f4ed6/pylgtv/webos_client.py#L223-L226 |
TheRealLink/pylgtv | pylgtv/webos_client.py | WebOsClient.get_services | def get_services(self):
"""Get all services."""
self.request(EP_GET_SERVICES)
return {} if self.last_response is None else self.last_response.get('payload').get('services') | python | def get_services(self):
"""Get all services."""
self.request(EP_GET_SERVICES)
return {} if self.last_response is None else self.last_response.get('payload').get('services') | [
"def",
"get_services",
"(",
"self",
")",
":",
"self",
".",
"request",
"(",
"EP_GET_SERVICES",
")",
"return",
"{",
"}",
"if",
"self",
".",
"last_response",
"is",
"None",
"else",
"self",
".",
"last_response",
".",
"get",
"(",
"'payload'",
")",
".",
"get",
... | Get all services. | [
"Get",
"all",
"services",
"."
] | train | https://github.com/TheRealLink/pylgtv/blob/a7d9ad87ce47e77180fe9262da785465219f4ed6/pylgtv/webos_client.py#L255-L258 |
TheRealLink/pylgtv | pylgtv/webos_client.py | WebOsClient.get_software_info | def get_software_info(self):
"""Return the current software status."""
self.request(EP_GET_SOFTWARE_INFO)
return {} if self.last_response is None else self.last_response.get('payload') | python | def get_software_info(self):
"""Return the current software status."""
self.request(EP_GET_SOFTWARE_INFO)
return {} if self.last_response is None else self.last_response.get('payload') | [
"def",
"get_software_info",
"(",
"self",
")",
":",
"self",
".",
"request",
"(",
"EP_GET_SOFTWARE_INFO",
")",
"return",
"{",
"}",
"if",
"self",
".",
"last_response",
"is",
"None",
"else",
"self",
".",
"last_response",
".",
"get",
"(",
"'payload'",
")"
] | Return the current software status. | [
"Return",
"the",
"current",
"software",
"status",
"."
] | train | https://github.com/TheRealLink/pylgtv/blob/a7d9ad87ce47e77180fe9262da785465219f4ed6/pylgtv/webos_client.py#L260-L263 |
TheRealLink/pylgtv | pylgtv/webos_client.py | WebOsClient.get_inputs | def get_inputs(self):
"""Get all inputs."""
self.request(EP_GET_INPUTS)
return {} if self.last_response is None else self.last_response.get('payload').get('devices') | python | def get_inputs(self):
"""Get all inputs."""
self.request(EP_GET_INPUTS)
return {} if self.last_response is None else self.last_response.get('payload').get('devices') | [
"def",
"get_inputs",
"(",
"self",
")",
":",
"self",
".",
"request",
"(",
"EP_GET_INPUTS",
")",
"return",
"{",
"}",
"if",
"self",
".",
"last_response",
"is",
"None",
"else",
"self",
".",
"last_response",
".",
"get",
"(",
"'payload'",
")",
".",
"get",
"(... | Get all inputs. | [
"Get",
"all",
"inputs",
"."
] | train | https://github.com/TheRealLink/pylgtv/blob/a7d9ad87ce47e77180fe9262da785465219f4ed6/pylgtv/webos_client.py#L283-L286 |
TheRealLink/pylgtv | pylgtv/webos_client.py | WebOsClient.get_audio_status | def get_audio_status(self):
"""Get the current audio status"""
self.request(EP_GET_AUDIO_STATUS)
return {} if self.last_response is None else self.last_response.get('payload') | python | def get_audio_status(self):
"""Get the current audio status"""
self.request(EP_GET_AUDIO_STATUS)
return {} if self.last_response is None else self.last_response.get('payload') | [
"def",
"get_audio_status",
"(",
"self",
")",
":",
"self",
".",
"request",
"(",
"EP_GET_AUDIO_STATUS",
")",
"return",
"{",
"}",
"if",
"self",
".",
"last_response",
"is",
"None",
"else",
"self",
".",
"last_response",
".",
"get",
"(",
"'payload'",
")"
] | Get the current audio status | [
"Get",
"the",
"current",
"audio",
"status"
] | train | https://github.com/TheRealLink/pylgtv/blob/a7d9ad87ce47e77180fe9262da785465219f4ed6/pylgtv/webos_client.py#L299-L302 |
TheRealLink/pylgtv | pylgtv/webos_client.py | WebOsClient.get_volume | def get_volume(self):
"""Get the current volume."""
self.request(EP_GET_VOLUME)
return 0 if self.last_response is None else self.last_response.get('payload').get('volume') | python | def get_volume(self):
"""Get the current volume."""
self.request(EP_GET_VOLUME)
return 0 if self.last_response is None else self.last_response.get('payload').get('volume') | [
"def",
"get_volume",
"(",
"self",
")",
":",
"self",
".",
"request",
"(",
"EP_GET_VOLUME",
")",
"return",
"0",
"if",
"self",
".",
"last_response",
"is",
"None",
"else",
"self",
".",
"last_response",
".",
"get",
"(",
"'payload'",
")",
".",
"get",
"(",
"'... | Get the current volume. | [
"Get",
"the",
"current",
"volume",
"."
] | train | https://github.com/TheRealLink/pylgtv/blob/a7d9ad87ce47e77180fe9262da785465219f4ed6/pylgtv/webos_client.py#L314-L317 |
TheRealLink/pylgtv | pylgtv/webos_client.py | WebOsClient.set_volume | def set_volume(self, volume):
"""Set volume."""
volume = max(0, volume)
self.request(EP_SET_VOLUME, {
'volume': volume
}) | python | def set_volume(self, volume):
"""Set volume."""
volume = max(0, volume)
self.request(EP_SET_VOLUME, {
'volume': volume
}) | [
"def",
"set_volume",
"(",
"self",
",",
"volume",
")",
":",
"volume",
"=",
"max",
"(",
"0",
",",
"volume",
")",
"self",
".",
"request",
"(",
"EP_SET_VOLUME",
",",
"{",
"'volume'",
":",
"volume",
"}",
")"
] | Set volume. | [
"Set",
"volume",
"."
] | train | https://github.com/TheRealLink/pylgtv/blob/a7d9ad87ce47e77180fe9262da785465219f4ed6/pylgtv/webos_client.py#L319-L324 |
TheRealLink/pylgtv | pylgtv/webos_client.py | WebOsClient.get_channels | def get_channels(self):
"""Get all tv channels."""
self.request(EP_GET_TV_CHANNELS)
return {} if self.last_response is None else self.last_response.get('payload').get('channelList') | python | def get_channels(self):
"""Get all tv channels."""
self.request(EP_GET_TV_CHANNELS)
return {} if self.last_response is None else self.last_response.get('payload').get('channelList') | [
"def",
"get_channels",
"(",
"self",
")",
":",
"self",
".",
"request",
"(",
"EP_GET_TV_CHANNELS",
")",
"return",
"{",
"}",
"if",
"self",
".",
"last_response",
"is",
"None",
"else",
"self",
".",
"last_response",
".",
"get",
"(",
"'payload'",
")",
".",
"get... | Get all tv channels. | [
"Get",
"all",
"tv",
"channels",
"."
] | train | https://github.com/TheRealLink/pylgtv/blob/a7d9ad87ce47e77180fe9262da785465219f4ed6/pylgtv/webos_client.py#L343-L346 |
TheRealLink/pylgtv | pylgtv/webos_client.py | WebOsClient.get_current_channel | def get_current_channel(self):
"""Get the current tv channel."""
self.request(EP_GET_CURRENT_CHANNEL)
return {} if self.last_response is None else self.last_response.get('payload') | python | def get_current_channel(self):
"""Get the current tv channel."""
self.request(EP_GET_CURRENT_CHANNEL)
return {} if self.last_response is None else self.last_response.get('payload') | [
"def",
"get_current_channel",
"(",
"self",
")",
":",
"self",
".",
"request",
"(",
"EP_GET_CURRENT_CHANNEL",
")",
"return",
"{",
"}",
"if",
"self",
".",
"last_response",
"is",
"None",
"else",
"self",
".",
"last_response",
".",
"get",
"(",
"'payload'",
")"
] | Get the current tv channel. | [
"Get",
"the",
"current",
"tv",
"channel",
"."
] | train | https://github.com/TheRealLink/pylgtv/blob/a7d9ad87ce47e77180fe9262da785465219f4ed6/pylgtv/webos_client.py#L348-L351 |
TheRealLink/pylgtv | pylgtv/webos_client.py | WebOsClient.get_channel_info | def get_channel_info(self):
"""Get the current channel info."""
self.request(EP_GET_CHANNEL_INFO)
return {} if self.last_response is None else self.last_response.get('payload') | python | def get_channel_info(self):
"""Get the current channel info."""
self.request(EP_GET_CHANNEL_INFO)
return {} if self.last_response is None else self.last_response.get('payload') | [
"def",
"get_channel_info",
"(",
"self",
")",
":",
"self",
".",
"request",
"(",
"EP_GET_CHANNEL_INFO",
")",
"return",
"{",
"}",
"if",
"self",
".",
"last_response",
"is",
"None",
"else",
"self",
".",
"last_response",
".",
"get",
"(",
"'payload'",
")"
] | Get the current channel info. | [
"Get",
"the",
"current",
"channel",
"info",
"."
] | train | https://github.com/TheRealLink/pylgtv/blob/a7d9ad87ce47e77180fe9262da785465219f4ed6/pylgtv/webos_client.py#L353-L356 |
ssato/python-anyconfig | src/anyconfig/processors.py | _load_plugins_itr | def _load_plugins_itr(pgroup, safe=True):
"""
.. seealso:: the doc of :func:`load_plugins`
"""
for res in pkg_resources.iter_entry_points(pgroup):
try:
yield res.load()
except ImportError:
if safe:
continue
raise | python | def _load_plugins_itr(pgroup, safe=True):
"""
.. seealso:: the doc of :func:`load_plugins`
"""
for res in pkg_resources.iter_entry_points(pgroup):
try:
yield res.load()
except ImportError:
if safe:
continue
raise | [
"def",
"_load_plugins_itr",
"(",
"pgroup",
",",
"safe",
"=",
"True",
")",
":",
"for",
"res",
"in",
"pkg_resources",
".",
"iter_entry_points",
"(",
"pgroup",
")",
":",
"try",
":",
"yield",
"res",
".",
"load",
"(",
")",
"except",
"ImportError",
":",
"if",
... | .. seealso:: the doc of :func:`load_plugins` | [
"..",
"seealso",
"::",
"the",
"doc",
"of",
":",
"func",
":",
"load_plugins"
] | train | https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/processors.py#L27-L37 |
ssato/python-anyconfig | src/anyconfig/processors.py | select_by_key | def select_by_key(items, sort_fn=sorted):
"""
:param items: A list of tuples of keys and values, [([key], val)]
:return: A list of tuples of key and values, [(key, [val])]
>>> select_by_key([(["a", "aaa"], 1), (["b", "bb"], 2), (["a"], 3)])
[('a', [1, 3]), ('aaa', [1]), ('b', [2]), ('bb', [2])]
... | python | def select_by_key(items, sort_fn=sorted):
"""
:param items: A list of tuples of keys and values, [([key], val)]
:return: A list of tuples of key and values, [(key, [val])]
>>> select_by_key([(["a", "aaa"], 1), (["b", "bb"], 2), (["a"], 3)])
[('a', [1, 3]), ('aaa', [1]), ('b', [2]), ('bb', [2])]
... | [
"def",
"select_by_key",
"(",
"items",
",",
"sort_fn",
"=",
"sorted",
")",
":",
"itr",
"=",
"anyconfig",
".",
"utils",
".",
"concat",
"(",
"(",
"(",
"k",
",",
"v",
")",
"for",
"k",
"in",
"ks",
")",
"for",
"ks",
",",
"v",
"in",
"items",
")",
"ret... | :param items: A list of tuples of keys and values, [([key], val)]
:return: A list of tuples of key and values, [(key, [val])]
>>> select_by_key([(["a", "aaa"], 1), (["b", "bb"], 2), (["a"], 3)])
[('a', [1, 3]), ('aaa', [1]), ('b', [2]), ('bb', [2])] | [
":",
"param",
"items",
":",
"A",
"list",
"of",
"tuples",
"of",
"keys",
"and",
"values",
"[",
"(",
"[",
"key",
"]",
"val",
")",
"]",
":",
"return",
":",
"A",
"list",
"of",
"tuples",
"of",
"key",
"and",
"values",
"[",
"(",
"key",
"[",
"val",
"]",... | train | https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/processors.py#L57-L68 |
ssato/python-anyconfig | src/anyconfig/processors.py | list_by_x | def list_by_x(prs, key):
"""
:param key: Grouping key, "type" or "extensions"
:return:
A list of :class:`Processor` or its children classes grouped by
given 'item', [(cid, [:class:`Processor`)]] by default
"""
if key == "type":
kfn = operator.methodcaller(key)
res = s... | python | def list_by_x(prs, key):
"""
:param key: Grouping key, "type" or "extensions"
:return:
A list of :class:`Processor` or its children classes grouped by
given 'item', [(cid, [:class:`Processor`)]] by default
"""
if key == "type":
kfn = operator.methodcaller(key)
res = s... | [
"def",
"list_by_x",
"(",
"prs",
",",
"key",
")",
":",
"if",
"key",
"==",
"\"type\"",
":",
"kfn",
"=",
"operator",
".",
"methodcaller",
"(",
"key",
")",
"res",
"=",
"sorted",
"(",
"(",
"(",
"k",
",",
"sort_by_prio",
"(",
"g",
")",
")",
"for",
"k",... | :param key: Grouping key, "type" or "extensions"
:return:
A list of :class:`Processor` or its children classes grouped by
given 'item', [(cid, [:class:`Processor`)]] by default | [
":",
"param",
"key",
":",
"Grouping",
"key",
"type",
"or",
"extensions",
":",
"return",
":",
"A",
"list",
"of",
":",
"class",
":",
"Processor",
"or",
"its",
"children",
"classes",
"grouped",
"by",
"given",
"item",
"[",
"(",
"cid",
"[",
":",
"class",
... | train | https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/processors.py#L71-L91 |
ssato/python-anyconfig | src/anyconfig/processors.py | findall_with_pred | def findall_with_pred(predicate, prs):
"""
:param predicate: any callable to filter results
:param prs: A list of :class:`anyconfig.models.processor.Processor` classes
:return: A list of appropriate processor classes or []
"""
return sorted((p for p in prs if predicate(p)),
key... | python | def findall_with_pred(predicate, prs):
"""
:param predicate: any callable to filter results
:param prs: A list of :class:`anyconfig.models.processor.Processor` classes
:return: A list of appropriate processor classes or []
"""
return sorted((p for p in prs if predicate(p)),
key... | [
"def",
"findall_with_pred",
"(",
"predicate",
",",
"prs",
")",
":",
"return",
"sorted",
"(",
"(",
"p",
"for",
"p",
"in",
"prs",
"if",
"predicate",
"(",
"p",
")",
")",
",",
"key",
"=",
"operator",
".",
"methodcaller",
"(",
"\"priority\"",
")",
",",
"r... | :param predicate: any callable to filter results
:param prs: A list of :class:`anyconfig.models.processor.Processor` classes
:return: A list of appropriate processor classes or [] | [
":",
"param",
"predicate",
":",
"any",
"callable",
"to",
"filter",
"results",
":",
"param",
"prs",
":",
"A",
"list",
"of",
":",
"class",
":",
"anyconfig",
".",
"models",
".",
"processor",
".",
"Processor",
"classes",
":",
"return",
":",
"A",
"list",
"o... | train | https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/processors.py#L94-L101 |
ssato/python-anyconfig | src/anyconfig/processors.py | maybe_processor | def maybe_processor(type_or_id, cls=anyconfig.models.processor.Processor):
"""
:param type_or_id:
Type of the data to process or ID of the processor class or
:class:`anyconfig.models.processor.Processor` class object or its
instance
:param cls: A class object to compare with 'type_or... | python | def maybe_processor(type_or_id, cls=anyconfig.models.processor.Processor):
"""
:param type_or_id:
Type of the data to process or ID of the processor class or
:class:`anyconfig.models.processor.Processor` class object or its
instance
:param cls: A class object to compare with 'type_or... | [
"def",
"maybe_processor",
"(",
"type_or_id",
",",
"cls",
"=",
"anyconfig",
".",
"models",
".",
"processor",
".",
"Processor",
")",
":",
"if",
"isinstance",
"(",
"type_or_id",
",",
"cls",
")",
":",
"return",
"type_or_id",
"if",
"type",
"(",
"type_or_id",
")... | :param type_or_id:
Type of the data to process or ID of the processor class or
:class:`anyconfig.models.processor.Processor` class object or its
instance
:param cls: A class object to compare with 'type_or_id'
:return: Processor instance or None | [
":",
"param",
"type_or_id",
":",
"Type",
"of",
"the",
"data",
"to",
"process",
"or",
"ID",
"of",
"the",
"processor",
"class",
"or",
":",
"class",
":",
"anyconfig",
".",
"models",
".",
"processor",
".",
"Processor",
"class",
"object",
"or",
"its",
"instan... | train | https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/processors.py#L104-L119 |
ssato/python-anyconfig | src/anyconfig/processors.py | find_by_type_or_id | def find_by_type_or_id(type_or_id, prs):
"""
:param type_or_id: Type of the data to process or ID of the processor class
:param prs: A list of :class:`anyconfig.models.processor.Processor` classes
:return:
A list of processor classes to process files of given data type or
processor 'type... | python | def find_by_type_or_id(type_or_id, prs):
"""
:param type_or_id: Type of the data to process or ID of the processor class
:param prs: A list of :class:`anyconfig.models.processor.Processor` classes
:return:
A list of processor classes to process files of given data type or
processor 'type... | [
"def",
"find_by_type_or_id",
"(",
"type_or_id",
",",
"prs",
")",
":",
"def",
"pred",
"(",
"pcls",
")",
":",
"\"\"\"Predicate\"\"\"",
"return",
"pcls",
".",
"cid",
"(",
")",
"==",
"type_or_id",
"or",
"pcls",
".",
"type",
"(",
")",
"==",
"type_or_id",
"pcl... | :param type_or_id: Type of the data to process or ID of the processor class
:param prs: A list of :class:`anyconfig.models.processor.Processor` classes
:return:
A list of processor classes to process files of given data type or
processor 'type_or_id' found by its ID
:raises: UnknownProcessor... | [
":",
"param",
"type_or_id",
":",
"Type",
"of",
"the",
"data",
"to",
"process",
"or",
"ID",
"of",
"the",
"processor",
"class",
":",
"param",
"prs",
":",
"A",
"list",
"of",
":",
"class",
":",
"anyconfig",
".",
"models",
".",
"processor",
".",
"Processor"... | train | https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/processors.py#L122-L139 |
ssato/python-anyconfig | src/anyconfig/processors.py | find_by_fileext | def find_by_fileext(fileext, prs):
"""
:param fileext: File extension
:param prs: A list of :class:`anyconfig.models.processor.Processor` classes
:return: A list of processor class to processor files with given extension
:raises: UnknownFileTypeError
"""
def pred(pcls):
"""Predicate"... | python | def find_by_fileext(fileext, prs):
"""
:param fileext: File extension
:param prs: A list of :class:`anyconfig.models.processor.Processor` classes
:return: A list of processor class to processor files with given extension
:raises: UnknownFileTypeError
"""
def pred(pcls):
"""Predicate"... | [
"def",
"find_by_fileext",
"(",
"fileext",
",",
"prs",
")",
":",
"def",
"pred",
"(",
"pcls",
")",
":",
"\"\"\"Predicate\"\"\"",
"return",
"fileext",
"in",
"pcls",
".",
"extensions",
"(",
")",
"pclss",
"=",
"findall_with_pred",
"(",
"pred",
",",
"prs",
")",
... | :param fileext: File extension
:param prs: A list of :class:`anyconfig.models.processor.Processor` classes
:return: A list of processor class to processor files with given extension
:raises: UnknownFileTypeError | [
":",
"param",
"fileext",
":",
"File",
"extension",
":",
"param",
"prs",
":",
"A",
"list",
"of",
":",
"class",
":",
"anyconfig",
".",
"models",
".",
"processor",
".",
"Processor",
"classes",
":",
"return",
":",
"A",
"list",
"of",
"processor",
"class",
"... | train | https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/processors.py#L142-L157 |
ssato/python-anyconfig | src/anyconfig/processors.py | find_by_maybe_file | def find_by_maybe_file(obj, prs):
"""
:param obj:
a file path, file or file-like object, pathlib.Path object or an
'anyconfig.globals.IOInfo' (namedtuple) object
:param cps_by_ext: A list of processor classes
:return: A list of processor classes to process given (maybe) file
:raises:... | python | def find_by_maybe_file(obj, prs):
"""
:param obj:
a file path, file or file-like object, pathlib.Path object or an
'anyconfig.globals.IOInfo' (namedtuple) object
:param cps_by_ext: A list of processor classes
:return: A list of processor classes to process given (maybe) file
:raises:... | [
"def",
"find_by_maybe_file",
"(",
"obj",
",",
"prs",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"IOInfo",
")",
":",
"obj",
"=",
"anyconfig",
".",
"ioinfo",
".",
"make",
"(",
"obj",
")",
"return",
"find_by_fileext",
"(",
"obj",
".",
"extensio... | :param obj:
a file path, file or file-like object, pathlib.Path object or an
'anyconfig.globals.IOInfo' (namedtuple) object
:param cps_by_ext: A list of processor classes
:return: A list of processor classes to process given (maybe) file
:raises: UnknownFileTypeError | [
":",
"param",
"obj",
":",
"a",
"file",
"path",
"file",
"or",
"file",
"-",
"like",
"object",
"pathlib",
".",
"Path",
"object",
"or",
"an",
"anyconfig",
".",
"globals",
".",
"IOInfo",
"(",
"namedtuple",
")",
"object",
":",
"param",
"cps_by_ext",
":",
"A"... | train | https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/processors.py#L160-L172 |
ssato/python-anyconfig | src/anyconfig/processors.py | findall | def findall(obj, prs, forced_type=None,
cls=anyconfig.models.processor.Processor):
"""
:param obj:
a file path, file, file-like object, pathlib.Path object or an
'anyconfig.globals.IOInfo` (namedtuple) object
:param prs: A list of :class:`anyconfig.models.processor.Processor` cla... | python | def findall(obj, prs, forced_type=None,
cls=anyconfig.models.processor.Processor):
"""
:param obj:
a file path, file, file-like object, pathlib.Path object or an
'anyconfig.globals.IOInfo` (namedtuple) object
:param prs: A list of :class:`anyconfig.models.processor.Processor` cla... | [
"def",
"findall",
"(",
"obj",
",",
"prs",
",",
"forced_type",
"=",
"None",
",",
"cls",
"=",
"anyconfig",
".",
"models",
".",
"processor",
".",
"Processor",
")",
":",
"if",
"(",
"obj",
"is",
"None",
"or",
"not",
"obj",
")",
"and",
"forced_type",
"is",... | :param obj:
a file path, file, file-like object, pathlib.Path object or an
'anyconfig.globals.IOInfo` (namedtuple) object
:param prs: A list of :class:`anyconfig.models.processor.Processor` classes
:param forced_type:
Forced processor type of the data to process or ID of the processor
... | [
":",
"param",
"obj",
":",
"a",
"file",
"path",
"file",
"file",
"-",
"like",
"object",
"pathlib",
".",
"Path",
"object",
"or",
"an",
"anyconfig",
".",
"globals",
".",
"IOInfo",
"(",
"namedtuple",
")",
"object",
":",
"param",
"prs",
":",
"A",
"list",
"... | train | https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/processors.py#L175-L200 |
ssato/python-anyconfig | src/anyconfig/processors.py | find | def find(obj, prs, forced_type=None, cls=anyconfig.models.processor.Processor):
"""
:param obj:
a file path, file, file-like object, pathlib.Path object or an
'anyconfig.globals.IOInfo' (namedtuple) object
:param prs: A list of :class:`anyconfig.models.processor.Processor` classes
:param... | python | def find(obj, prs, forced_type=None, cls=anyconfig.models.processor.Processor):
"""
:param obj:
a file path, file, file-like object, pathlib.Path object or an
'anyconfig.globals.IOInfo' (namedtuple) object
:param prs: A list of :class:`anyconfig.models.processor.Processor` classes
:param... | [
"def",
"find",
"(",
"obj",
",",
"prs",
",",
"forced_type",
"=",
"None",
",",
"cls",
"=",
"anyconfig",
".",
"models",
".",
"processor",
".",
"Processor",
")",
":",
"if",
"forced_type",
"is",
"not",
"None",
":",
"processor",
"=",
"maybe_processor",
"(",
... | :param obj:
a file path, file, file-like object, pathlib.Path object or an
'anyconfig.globals.IOInfo' (namedtuple) object
:param prs: A list of :class:`anyconfig.models.processor.Processor` classes
:param forced_type:
Forced processor type of the data to process or ID of the processor
... | [
":",
"param",
"obj",
":",
"a",
"file",
"path",
"file",
"file",
"-",
"like",
"object",
"pathlib",
".",
"Path",
"object",
"or",
"an",
"anyconfig",
".",
"globals",
".",
"IOInfo",
"(",
"namedtuple",
")",
"object",
":",
"param",
"prs",
":",
"A",
"list",
"... | train | https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/processors.py#L203-L224 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.