id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
221,900
automl/HpBandSter
hpbandster/optimizers/config_generators/lcnet.py
LCNetWrapper.get_config
def get_config(self, budget): """ function to sample a new configuration This function is called inside Hyperband to query a new configuration Parameters: ----------- budget: float the budget for which this configuration is scheduled...
python
def get_config(self, budget): """ function to sample a new configuration This function is called inside Hyperband to query a new configuration Parameters: ----------- budget: float the budget for which this configuration is scheduled...
[ "def", "get_config", "(", "self", ",", "budget", ")", ":", "self", ".", "lock", ".", "acquire", "(", ")", "if", "not", "self", ".", "is_trained", ":", "c", "=", "self", ".", "config_space", ".", "sample_configuration", "(", ")", ".", "get_array", "(", ...
function to sample a new configuration This function is called inside Hyperband to query a new configuration Parameters: ----------- budget: float the budget for which this configuration is scheduled returns: config should r...
[ "function", "to", "sample", "a", "new", "configuration" ]
841db4b827f342e5eb7f725723ea6461ac52d45a
https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/optimizers/config_generators/lcnet.py#L63-L103
221,901
automl/HpBandSter
hpbandster/core/result.py
extract_HBS_learning_curves
def extract_HBS_learning_curves(runs): """ function to get the hyperband learning curves This is an example function showing the interface to use the HB_result.get_learning_curves method. Parameters ---------- runs: list of HB_result.run objects the performed runs for an unspecified config Returns ------...
python
def extract_HBS_learning_curves(runs): """ function to get the hyperband learning curves This is an example function showing the interface to use the HB_result.get_learning_curves method. Parameters ---------- runs: list of HB_result.run objects the performed runs for an unspecified config Returns ------...
[ "def", "extract_HBS_learning_curves", "(", "runs", ")", ":", "sr", "=", "sorted", "(", "runs", ",", "key", "=", "lambda", "r", ":", "r", ".", "budget", ")", "lc", "=", "list", "(", "filter", "(", "lambda", "t", ":", "not", "t", "[", "1", "]", "is...
function to get the hyperband learning curves This is an example function showing the interface to use the HB_result.get_learning_curves method. Parameters ---------- runs: list of HB_result.run objects the performed runs for an unspecified config Returns ------- list of learning curves: list of lists of...
[ "function", "to", "get", "the", "hyperband", "learning", "curves" ]
841db4b827f342e5eb7f725723ea6461ac52d45a
https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/result.py#L35-L61
221,902
automl/HpBandSter
hpbandster/core/result.py
logged_results_to_HBS_result
def logged_results_to_HBS_result(directory): """ function to import logged 'live-results' and return a HB_result object You can load live run results with this function and the returned HB_result object gives you access to the results the same way a finished run would. Parameters ---------- directory: str ...
python
def logged_results_to_HBS_result(directory): """ function to import logged 'live-results' and return a HB_result object You can load live run results with this function and the returned HB_result object gives you access to the results the same way a finished run would. Parameters ---------- directory: str ...
[ "def", "logged_results_to_HBS_result", "(", "directory", ")", ":", "data", "=", "{", "}", "time_ref", "=", "float", "(", "'inf'", ")", "budget_set", "=", "set", "(", ")", "with", "open", "(", "os", ".", "path", ".", "join", "(", "directory", ",", "'con...
function to import logged 'live-results' and return a HB_result object You can load live run results with this function and the returned HB_result object gives you access to the results the same way a finished run would. Parameters ---------- directory: str the directory containing the results.json and confi...
[ "function", "to", "import", "logged", "live", "-", "results", "and", "return", "a", "HB_result", "object" ]
841db4b827f342e5eb7f725723ea6461ac52d45a
https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/result.py#L139-L200
221,903
automl/HpBandSter
hpbandster/core/result.py
Result.get_incumbent_id
def get_incumbent_id(self): """ Find the config_id of the incumbent. The incumbent here is the configuration with the smallest loss among all runs on the maximum budget! If no run finishes on the maximum budget, None is returned! """ tmp_list = [] for k,v in self.data.items(): try: # only things...
python
def get_incumbent_id(self): """ Find the config_id of the incumbent. The incumbent here is the configuration with the smallest loss among all runs on the maximum budget! If no run finishes on the maximum budget, None is returned! """ tmp_list = [] for k,v in self.data.items(): try: # only things...
[ "def", "get_incumbent_id", "(", "self", ")", ":", "tmp_list", "=", "[", "]", "for", "k", ",", "v", "in", "self", ".", "data", ".", "items", "(", ")", ":", "try", ":", "# only things run for the max budget are considered", "res", "=", "v", ".", "results", ...
Find the config_id of the incumbent. The incumbent here is the configuration with the smallest loss among all runs on the maximum budget! If no run finishes on the maximum budget, None is returned!
[ "Find", "the", "config_id", "of", "the", "incumbent", "." ]
841db4b827f342e5eb7f725723ea6461ac52d45a
https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/result.py#L219-L241
221,904
automl/HpBandSter
hpbandster/core/result.py
Result.get_runs_by_id
def get_runs_by_id(self, config_id): """ returns a list of runs for a given config id The runs are sorted by ascending budget, so '-1' will give the longest run for this config. """ d = self.data[config_id] runs = [] for b in d.results.keys(): try: err_logs = d.exceptions.get(b, None) if d...
python
def get_runs_by_id(self, config_id): """ returns a list of runs for a given config id The runs are sorted by ascending budget, so '-1' will give the longest run for this config. """ d = self.data[config_id] runs = [] for b in d.results.keys(): try: err_logs = d.exceptions.get(b, None) if d...
[ "def", "get_runs_by_id", "(", "self", ",", "config_id", ")", ":", "d", "=", "self", ".", "data", "[", "config_id", "]", "runs", "=", "[", "]", "for", "b", "in", "d", ".", "results", ".", "keys", "(", ")", ":", "try", ":", "err_logs", "=", "d", ...
returns a list of runs for a given config id The runs are sorted by ascending budget, so '-1' will give the longest run for this config.
[ "returns", "a", "list", "of", "runs", "for", "a", "given", "config", "id" ]
841db4b827f342e5eb7f725723ea6461ac52d45a
https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/result.py#L319-L341
221,905
automl/HpBandSter
hpbandster/core/result.py
Result.get_learning_curves
def get_learning_curves(self, lc_extractor=extract_HBS_learning_curves, config_ids=None): """ extracts all learning curves from all run configurations Parameters ---------- lc_extractor: callable a function to return a list of learning_curves. defaults to hpbanster.HB_result.extract_HP_learning_curv...
python
def get_learning_curves(self, lc_extractor=extract_HBS_learning_curves, config_ids=None): """ extracts all learning curves from all run configurations Parameters ---------- lc_extractor: callable a function to return a list of learning_curves. defaults to hpbanster.HB_result.extract_HP_learning_curv...
[ "def", "get_learning_curves", "(", "self", ",", "lc_extractor", "=", "extract_HBS_learning_curves", ",", "config_ids", "=", "None", ")", ":", "config_ids", "=", "self", ".", "data", ".", "keys", "(", ")", "if", "config_ids", "is", "None", "else", "config_ids",...
extracts all learning curves from all run configurations Parameters ---------- lc_extractor: callable a function to return a list of learning_curves. defaults to hpbanster.HB_result.extract_HP_learning_curves config_ids: list of valid config ids if only a subset of the config ids is wanted Ret...
[ "extracts", "all", "learning", "curves", "from", "all", "run", "configurations" ]
841db4b827f342e5eb7f725723ea6461ac52d45a
https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/result.py#L344-L371
221,906
automl/HpBandSter
hpbandster/core/result.py
Result.get_all_runs
def get_all_runs(self, only_largest_budget=False): """ returns all runs performed Parameters ---------- only_largest_budget: boolean if True, only the largest budget for each configuration is returned. This makes sense if the runs are continued across budgets and the info field contains the info...
python
def get_all_runs(self, only_largest_budget=False): """ returns all runs performed Parameters ---------- only_largest_budget: boolean if True, only the largest budget for each configuration is returned. This makes sense if the runs are continued across budgets and the info field contains the info...
[ "def", "get_all_runs", "(", "self", ",", "only_largest_budget", "=", "False", ")", ":", "all_runs", "=", "[", "]", "for", "k", "in", "self", ".", "data", ".", "keys", "(", ")", ":", "runs", "=", "self", ".", "get_runs_by_id", "(", "k", ")", "if", "...
returns all runs performed Parameters ---------- only_largest_budget: boolean if True, only the largest budget for each configuration is returned. This makes sense if the runs are continued across budgets and the info field contains the information you care about. If False, all runs of a configu...
[ "returns", "all", "runs", "performed" ]
841db4b827f342e5eb7f725723ea6461ac52d45a
https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/result.py#L374-L398
221,907
automl/HpBandSter
hpbandster/core/result.py
Result.get_id2config_mapping
def get_id2config_mapping(self): """ returns a dict where the keys are the config_ids and the values are the actual configurations """ new_dict = {} for k, v in self.data.items(): new_dict[k] = {} new_dict[k]['config'] = copy.deepcopy(v.config) try: new_dict[k]['config_info'] = copy.deepcopy(v....
python
def get_id2config_mapping(self): """ returns a dict where the keys are the config_ids and the values are the actual configurations """ new_dict = {} for k, v in self.data.items(): new_dict[k] = {} new_dict[k]['config'] = copy.deepcopy(v.config) try: new_dict[k]['config_info'] = copy.deepcopy(v....
[ "def", "get_id2config_mapping", "(", "self", ")", ":", "new_dict", "=", "{", "}", "for", "k", ",", "v", "in", "self", ".", "data", ".", "items", "(", ")", ":", "new_dict", "[", "k", "]", "=", "{", "}", "new_dict", "[", "k", "]", "[", "'config'", ...
returns a dict where the keys are the config_ids and the values are the actual configurations
[ "returns", "a", "dict", "where", "the", "keys", "are", "the", "config_ids", "and", "the", "values", "are", "the", "actual", "configurations" ]
841db4b827f342e5eb7f725723ea6461ac52d45a
https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/result.py#L400-L413
221,908
automl/HpBandSter
hpbandster/core/result.py
Result._merge_results
def _merge_results(self): """ hidden function to merge the list of results into one dictionary and 'normalize' the time stamps """ new_dict = {} for it in self.data: new_dict.update(it) for k,v in new_dict.items(): for kk, vv in v.time_stamps.items(): for kkk,vvv in vv.items(): new_dict[k]...
python
def _merge_results(self): """ hidden function to merge the list of results into one dictionary and 'normalize' the time stamps """ new_dict = {} for it in self.data: new_dict.update(it) for k,v in new_dict.items(): for kk, vv in v.time_stamps.items(): for kkk,vvv in vv.items(): new_dict[k]...
[ "def", "_merge_results", "(", "self", ")", ":", "new_dict", "=", "{", "}", "for", "it", "in", "self", ".", "data", ":", "new_dict", ".", "update", "(", "it", ")", "for", "k", ",", "v", "in", "new_dict", ".", "items", "(", ")", ":", "for", "kk", ...
hidden function to merge the list of results into one dictionary and 'normalize' the time stamps
[ "hidden", "function", "to", "merge", "the", "list", "of", "results", "into", "one", "dictionary", "and", "normalize", "the", "time", "stamps" ]
841db4b827f342e5eb7f725723ea6461ac52d45a
https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/result.py#L415-L429
221,909
Koed00/django-q
django_q/core_signing.py
TimestampSigner.unsign
def unsign(self, value, max_age=None): """ Retrieve original value and check it wasn't signed more than max_age seconds ago. """ result = super(TimestampSigner, self).unsign(value) value, timestamp = result.rsplit(self.sep, 1) timestamp = baseconv.base62.decode(ti...
python
def unsign(self, value, max_age=None): """ Retrieve original value and check it wasn't signed more than max_age seconds ago. """ result = super(TimestampSigner, self).unsign(value) value, timestamp = result.rsplit(self.sep, 1) timestamp = baseconv.base62.decode(ti...
[ "def", "unsign", "(", "self", ",", "value", ",", "max_age", "=", "None", ")", ":", "result", "=", "super", "(", "TimestampSigner", ",", "self", ")", ".", "unsign", "(", "value", ")", "value", ",", "timestamp", "=", "result", ".", "rsplit", "(", "self...
Retrieve original value and check it wasn't signed more than max_age seconds ago.
[ "Retrieve", "original", "value", "and", "check", "it", "wasn", "t", "signed", "more", "than", "max_age", "seconds", "ago", "." ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/core_signing.py#L63-L79
221,910
Koed00/django-q
django_q/humanhash.py
HumanHasher.humanize
def humanize(self, hexdigest, words=4, separator='-'): """ Humanize a given hexadecimal digest. Change the number of words output by specifying `words`. Change the word separator with `separator`. >>> digest = '60ad8d0d871b6095808297' >>> HumanHasher().humanize...
python
def humanize(self, hexdigest, words=4, separator='-'): """ Humanize a given hexadecimal digest. Change the number of words output by specifying `words`. Change the word separator with `separator`. >>> digest = '60ad8d0d871b6095808297' >>> HumanHasher().humanize...
[ "def", "humanize", "(", "self", ",", "hexdigest", ",", "words", "=", "4", ",", "separator", "=", "'-'", ")", ":", "# Gets a list of byte values between 0-255.", "bytes", "=", "[", "int", "(", "x", ",", "16", ")", "for", "x", "in", "list", "(", "map", "...
Humanize a given hexadecimal digest. Change the number of words output by specifying `words`. Change the word separator with `separator`. >>> digest = '60ad8d0d871b6095808297' >>> HumanHasher().humanize(digest) 'sodium-magnesium-nineteen-hydrogen'
[ "Humanize", "a", "given", "hexadecimal", "digest", "." ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/humanhash.py#L73-L91
221,911
Koed00/django-q
django_q/humanhash.py
HumanHasher.compress
def compress(bytes, target): """ Compress a list of byte values to a fixed target length. >>> bytes = [96, 173, 141, 13, 135, 27, 96, 149, 128, 130, 151] >>> HumanHasher.compress(bytes, 4) [205, 128, 156, 96] Attempting to compress a smaller number of bytes...
python
def compress(bytes, target): """ Compress a list of byte values to a fixed target length. >>> bytes = [96, 173, 141, 13, 135, 27, 96, 149, 128, 130, 151] >>> HumanHasher.compress(bytes, 4) [205, 128, 156, 96] Attempting to compress a smaller number of bytes...
[ "def", "compress", "(", "bytes", ",", "target", ")", ":", "length", "=", "len", "(", "bytes", ")", "if", "target", ">", "length", ":", "raise", "ValueError", "(", "\"Fewer input bytes than requested output\"", ")", "# Split `bytes` into `target` segments.", "seg_siz...
Compress a list of byte values to a fixed target length. >>> bytes = [96, 173, 141, 13, 135, 27, 96, 149, 128, 130, 151] >>> HumanHasher.compress(bytes, 4) [205, 128, 156, 96] Attempting to compress a smaller number of bytes to a larger number is an error: ...
[ "Compress", "a", "list", "of", "byte", "values", "to", "a", "fixed", "target", "length", "." ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/humanhash.py#L94-L126
221,912
Koed00/django-q
django_q/humanhash.py
HumanHasher.uuid
def uuid(self, **params): """ Generate a UUID with a human-readable representation. Returns `(human_repr, full_digest)`. Accepts the same keyword arguments as :meth:`humanize` (they'll be passed straight through). """ digest = str(uuidlib.uuid4()).replace('-', '') ...
python
def uuid(self, **params): """ Generate a UUID with a human-readable representation. Returns `(human_repr, full_digest)`. Accepts the same keyword arguments as :meth:`humanize` (they'll be passed straight through). """ digest = str(uuidlib.uuid4()).replace('-', '') ...
[ "def", "uuid", "(", "self", ",", "*", "*", "params", ")", ":", "digest", "=", "str", "(", "uuidlib", ".", "uuid4", "(", ")", ")", ".", "replace", "(", "'-'", ",", "''", ")", "return", "self", ".", "humanize", "(", "digest", ",", "*", "*", "para...
Generate a UUID with a human-readable representation. Returns `(human_repr, full_digest)`. Accepts the same keyword arguments as :meth:`humanize` (they'll be passed straight through).
[ "Generate", "a", "UUID", "with", "a", "human", "-", "readable", "representation", "." ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/humanhash.py#L128-L138
221,913
Koed00/django-q
django_q/tasks.py
async_task
def async_task(func, *args, **kwargs): """Queue a task for the cluster.""" keywords = kwargs.copy() opt_keys = ( 'hook', 'group', 'save', 'sync', 'cached', 'ack_failure', 'iter_count', 'iter_cached', 'chain', 'broker') q_options = keywords.pop('q_options', {}) # get an id tag = uuid() # ...
python
def async_task(func, *args, **kwargs): """Queue a task for the cluster.""" keywords = kwargs.copy() opt_keys = ( 'hook', 'group', 'save', 'sync', 'cached', 'ack_failure', 'iter_count', 'iter_cached', 'chain', 'broker') q_options = keywords.pop('q_options', {}) # get an id tag = uuid() # ...
[ "def", "async_task", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "keywords", "=", "kwargs", ".", "copy", "(", ")", "opt_keys", "=", "(", "'hook'", ",", "'group'", ",", "'save'", ",", "'sync'", ",", "'cached'", ",", "'ack_failure...
Queue a task for the cluster.
[ "Queue", "a", "task", "for", "the", "cluster", "." ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L21-L62
221,914
Koed00/django-q
django_q/tasks.py
schedule
def schedule(func, *args, **kwargs): """ Create a schedule. :param func: function to schedule. :param args: function arguments. :param name: optional name for the schedule. :param hook: optional result hook function. :type schedule_type: Schedule.TYPE :param repeats: how many times to r...
python
def schedule(func, *args, **kwargs): """ Create a schedule. :param func: function to schedule. :param args: function arguments. :param name: optional name for the schedule. :param hook: optional result hook function. :type schedule_type: Schedule.TYPE :param repeats: how many times to r...
[ "def", "schedule", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "name", "=", "kwargs", ".", "pop", "(", "'name'", ",", "None", ")", "hook", "=", "kwargs", ".", "pop", "(", "'hook'", ",", "None", ")", "schedule_type", "=", "kw...
Create a schedule. :param func: function to schedule. :param args: function arguments. :param name: optional name for the schedule. :param hook: optional result hook function. :type schedule_type: Schedule.TYPE :param repeats: how many times to repeat. 0=never, -1=always. :param next_run: N...
[ "Create", "a", "schedule", "." ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L65-L102
221,915
Koed00/django-q
django_q/tasks.py
result
def result(task_id, wait=0, cached=Conf.CACHED): """ Return the result of the named task. :type task_id: str or uuid :param task_id: the task name or uuid :type wait: int :param wait: number of milliseconds to wait for a result :param bool cached: run this against the cache backend :ret...
python
def result(task_id, wait=0, cached=Conf.CACHED): """ Return the result of the named task. :type task_id: str or uuid :param task_id: the task name or uuid :type wait: int :param wait: number of milliseconds to wait for a result :param bool cached: run this against the cache backend :ret...
[ "def", "result", "(", "task_id", ",", "wait", "=", "0", ",", "cached", "=", "Conf", ".", "CACHED", ")", ":", "if", "cached", ":", "return", "result_cached", "(", "task_id", ",", "wait", ")", "start", "=", "time", "(", ")", "while", "True", ":", "r"...
Return the result of the named task. :type task_id: str or uuid :param task_id: the task name or uuid :type wait: int :param wait: number of milliseconds to wait for a result :param bool cached: run this against the cache backend :return: the result object of this task :rtype: object
[ "Return", "the", "result", "of", "the", "named", "task", "." ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L105-L126
221,916
Koed00/django-q
django_q/tasks.py
result_cached
def result_cached(task_id, wait=0, broker=None): """ Return the result from the cache backend """ if not broker: broker = get_broker() start = time() while True: r = broker.cache.get('{}:{}'.format(broker.list_key, task_id)) if r: return SignedPackage.loads(r...
python
def result_cached(task_id, wait=0, broker=None): """ Return the result from the cache backend """ if not broker: broker = get_broker() start = time() while True: r = broker.cache.get('{}:{}'.format(broker.list_key, task_id)) if r: return SignedPackage.loads(r...
[ "def", "result_cached", "(", "task_id", ",", "wait", "=", "0", ",", "broker", "=", "None", ")", ":", "if", "not", "broker", ":", "broker", "=", "get_broker", "(", ")", "start", "=", "time", "(", ")", "while", "True", ":", "r", "=", "broker", ".", ...
Return the result from the cache backend
[ "Return", "the", "result", "from", "the", "cache", "backend" ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L129-L142
221,917
Koed00/django-q
django_q/tasks.py
result_group
def result_group(group_id, failures=False, wait=0, count=None, cached=Conf.CACHED): """ Return a list of results for a task group. :param str group_id: the group id :param bool failures: set to True to include failures :param int count: Block until there are this many results in the group :para...
python
def result_group(group_id, failures=False, wait=0, count=None, cached=Conf.CACHED): """ Return a list of results for a task group. :param str group_id: the group id :param bool failures: set to True to include failures :param int count: Block until there are this many results in the group :para...
[ "def", "result_group", "(", "group_id", ",", "failures", "=", "False", ",", "wait", "=", "0", ",", "count", "=", "None", ",", "cached", "=", "Conf", ".", "CACHED", ")", ":", "if", "cached", ":", "return", "result_group_cached", "(", "group_id", ",", "f...
Return a list of results for a task group. :param str group_id: the group id :param bool failures: set to True to include failures :param int count: Block until there are this many results in the group :param bool cached: run this against the cache backend :return: list or results
[ "Return", "a", "list", "of", "results", "for", "a", "task", "group", "." ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L145-L169
221,918
Koed00/django-q
django_q/tasks.py
result_group_cached
def result_group_cached(group_id, failures=False, wait=0, count=None, broker=None): """ Return a list of results for a task group from the cache backend """ if not broker: broker = get_broker() start = time() if count: while True: if count_group_cached(group_id) == co...
python
def result_group_cached(group_id, failures=False, wait=0, count=None, broker=None): """ Return a list of results for a task group from the cache backend """ if not broker: broker = get_broker() start = time() if count: while True: if count_group_cached(group_id) == co...
[ "def", "result_group_cached", "(", "group_id", ",", "failures", "=", "False", ",", "wait", "=", "0", ",", "count", "=", "None", ",", "broker", "=", "None", ")", ":", "if", "not", "broker", ":", "broker", "=", "get_broker", "(", ")", "start", "=", "ti...
Return a list of results for a task group from the cache backend
[ "Return", "a", "list", "of", "results", "for", "a", "task", "group", "from", "the", "cache", "backend" ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L172-L195
221,919
Koed00/django-q
django_q/tasks.py
fetch
def fetch(task_id, wait=0, cached=Conf.CACHED): """ Return the processed task. :param task_id: the task name or uuid :type task_id: str or uuid :param wait: the number of milliseconds to wait for a result :type wait: int :param bool cached: run this against the cache backend :return: th...
python
def fetch(task_id, wait=0, cached=Conf.CACHED): """ Return the processed task. :param task_id: the task name or uuid :type task_id: str or uuid :param wait: the number of milliseconds to wait for a result :type wait: int :param bool cached: run this against the cache backend :return: th...
[ "def", "fetch", "(", "task_id", ",", "wait", "=", "0", ",", "cached", "=", "Conf", ".", "CACHED", ")", ":", "if", "cached", ":", "return", "fetch_cached", "(", "task_id", ",", "wait", ")", "start", "=", "time", "(", ")", "while", "True", ":", "t", ...
Return the processed task. :param task_id: the task name or uuid :type task_id: str or uuid :param wait: the number of milliseconds to wait for a result :type wait: int :param bool cached: run this against the cache backend :return: the full task object :rtype: Task
[ "Return", "the", "processed", "task", "." ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L198-L219
221,920
Koed00/django-q
django_q/tasks.py
fetch_cached
def fetch_cached(task_id, wait=0, broker=None): """ Return the processed task from the cache backend """ if not broker: broker = get_broker() start = time() while True: r = broker.cache.get('{}:{}'.format(broker.list_key, task_id)) if r: task = SignedPackage.l...
python
def fetch_cached(task_id, wait=0, broker=None): """ Return the processed task from the cache backend """ if not broker: broker = get_broker() start = time() while True: r = broker.cache.get('{}:{}'.format(broker.list_key, task_id)) if r: task = SignedPackage.l...
[ "def", "fetch_cached", "(", "task_id", ",", "wait", "=", "0", ",", "broker", "=", "None", ")", ":", "if", "not", "broker", ":", "broker", "=", "get_broker", "(", ")", "start", "=", "time", "(", ")", "while", "True", ":", "r", "=", "broker", ".", ...
Return the processed task from the cache backend
[ "Return", "the", "processed", "task", "from", "the", "cache", "backend" ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L222-L246
221,921
Koed00/django-q
django_q/tasks.py
fetch_group
def fetch_group(group_id, failures=True, wait=0, count=None, cached=Conf.CACHED): """ Return a list of Tasks for a task group. :param str group_id: the group id :param bool failures: set to False to exclude failures :param bool cached: run this against the cache backend :return: list of Tasks ...
python
def fetch_group(group_id, failures=True, wait=0, count=None, cached=Conf.CACHED): """ Return a list of Tasks for a task group. :param str group_id: the group id :param bool failures: set to False to exclude failures :param bool cached: run this against the cache backend :return: list of Tasks ...
[ "def", "fetch_group", "(", "group_id", ",", "failures", "=", "True", ",", "wait", "=", "0", ",", "count", "=", "None", ",", "cached", "=", "Conf", ".", "CACHED", ")", ":", "if", "cached", ":", "return", "fetch_group_cached", "(", "group_id", ",", "fail...
Return a list of Tasks for a task group. :param str group_id: the group id :param bool failures: set to False to exclude failures :param bool cached: run this against the cache backend :return: list of Tasks
[ "Return", "a", "list", "of", "Tasks", "for", "a", "task", "group", "." ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L249-L272
221,922
Koed00/django-q
django_q/tasks.py
fetch_group_cached
def fetch_group_cached(group_id, failures=True, wait=0, count=None, broker=None): """ Return a list of Tasks for a task group in the cache backend """ if not broker: broker = get_broker() start = time() if count: while True: if count_group_cached(group_id) == count or...
python
def fetch_group_cached(group_id, failures=True, wait=0, count=None, broker=None): """ Return a list of Tasks for a task group in the cache backend """ if not broker: broker = get_broker() start = time() if count: while True: if count_group_cached(group_id) == count or...
[ "def", "fetch_group_cached", "(", "group_id", ",", "failures", "=", "True", ",", "wait", "=", "0", ",", "count", "=", "None", ",", "broker", "=", "None", ")", ":", "if", "not", "broker", ":", "broker", "=", "get_broker", "(", ")", "start", "=", "time...
Return a list of Tasks for a task group in the cache backend
[ "Return", "a", "list", "of", "Tasks", "for", "a", "task", "group", "in", "the", "cache", "backend" ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L275-L309
221,923
Koed00/django-q
django_q/tasks.py
count_group
def count_group(group_id, failures=False, cached=Conf.CACHED): """ Count the results in a group. :param str group_id: the group id :param bool failures: Returns failure count if True :param bool cached: run this against the cache backend :return: the number of tasks/results in a group :rtyp...
python
def count_group(group_id, failures=False, cached=Conf.CACHED): """ Count the results in a group. :param str group_id: the group id :param bool failures: Returns failure count if True :param bool cached: run this against the cache backend :return: the number of tasks/results in a group :rtyp...
[ "def", "count_group", "(", "group_id", ",", "failures", "=", "False", ",", "cached", "=", "Conf", ".", "CACHED", ")", ":", "if", "cached", ":", "return", "count_group_cached", "(", "group_id", ",", "failures", ")", "return", "Task", ".", "get_group_count", ...
Count the results in a group. :param str group_id: the group id :param bool failures: Returns failure count if True :param bool cached: run this against the cache backend :return: the number of tasks/results in a group :rtype: int
[ "Count", "the", "results", "in", "a", "group", "." ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L312-L324
221,924
Koed00/django-q
django_q/tasks.py
count_group_cached
def count_group_cached(group_id, failures=False, broker=None): """ Count the results in a group in the cache backend """ if not broker: broker = get_broker() group_list = broker.cache.get('{}:{}:keys'.format(broker.list_key, group_id)) if group_list: if not failures: ...
python
def count_group_cached(group_id, failures=False, broker=None): """ Count the results in a group in the cache backend """ if not broker: broker = get_broker() group_list = broker.cache.get('{}:{}:keys'.format(broker.list_key, group_id)) if group_list: if not failures: ...
[ "def", "count_group_cached", "(", "group_id", ",", "failures", "=", "False", ",", "broker", "=", "None", ")", ":", "if", "not", "broker", ":", "broker", "=", "get_broker", "(", ")", "group_list", "=", "broker", ".", "cache", ".", "get", "(", "'{}:{}:keys...
Count the results in a group in the cache backend
[ "Count", "the", "results", "in", "a", "group", "in", "the", "cache", "backend" ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L327-L342
221,925
Koed00/django-q
django_q/tasks.py
delete_group_cached
def delete_group_cached(group_id, broker=None): """ Delete a group from the cache backend """ if not broker: broker = get_broker() group_key = '{}:{}:keys'.format(broker.list_key, group_id) group_list = broker.cache.get(group_key) broker.cache.delete_many(group_list) broker.cache...
python
def delete_group_cached(group_id, broker=None): """ Delete a group from the cache backend """ if not broker: broker = get_broker() group_key = '{}:{}:keys'.format(broker.list_key, group_id) group_list = broker.cache.get(group_key) broker.cache.delete_many(group_list) broker.cache...
[ "def", "delete_group_cached", "(", "group_id", ",", "broker", "=", "None", ")", ":", "if", "not", "broker", ":", "broker", "=", "get_broker", "(", ")", "group_key", "=", "'{}:{}:keys'", ".", "format", "(", "broker", ".", "list_key", ",", "group_id", ")", ...
Delete a group from the cache backend
[ "Delete", "a", "group", "from", "the", "cache", "backend" ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L360-L369
221,926
Koed00/django-q
django_q/tasks.py
delete_cached
def delete_cached(task_id, broker=None): """ Delete a task from the cache backend """ if not broker: broker = get_broker() return broker.cache.delete('{}:{}'.format(broker.list_key, task_id))
python
def delete_cached(task_id, broker=None): """ Delete a task from the cache backend """ if not broker: broker = get_broker() return broker.cache.delete('{}:{}'.format(broker.list_key, task_id))
[ "def", "delete_cached", "(", "task_id", ",", "broker", "=", "None", ")", ":", "if", "not", "broker", ":", "broker", "=", "get_broker", "(", ")", "return", "broker", ".", "cache", ".", "delete", "(", "'{}:{}'", ".", "format", "(", "broker", ".", "list_k...
Delete a task from the cache backend
[ "Delete", "a", "task", "from", "the", "cache", "backend" ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L372-L378
221,927
Koed00/django-q
django_q/tasks.py
async_iter
def async_iter(func, args_iter, **kwargs): """ enqueues a function with iterable arguments """ iter_count = len(args_iter) iter_group = uuid()[1] # clean up the kwargs options = kwargs.get('q_options', kwargs) options.pop('hook', None) options['broker'] = options.get('broker', get_br...
python
def async_iter(func, args_iter, **kwargs): """ enqueues a function with iterable arguments """ iter_count = len(args_iter) iter_group = uuid()[1] # clean up the kwargs options = kwargs.get('q_options', kwargs) options.pop('hook', None) options['broker'] = options.get('broker', get_br...
[ "def", "async_iter", "(", "func", ",", "args_iter", ",", "*", "*", "kwargs", ")", ":", "iter_count", "=", "len", "(", "args_iter", ")", "iter_group", "=", "uuid", "(", ")", "[", "1", "]", "# clean up the kwargs", "options", "=", "kwargs", ".", "get", "...
enqueues a function with iterable arguments
[ "enqueues", "a", "function", "with", "iterable", "arguments" ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L395-L417
221,928
Koed00/django-q
django_q/tasks.py
_sync
def _sync(pack): """Simulate a package travelling through the cluster.""" task_queue = Queue() result_queue = Queue() task = SignedPackage.loads(pack) task_queue.put(task) task_queue.put('STOP') worker(task_queue, result_queue, Value('f', -1)) result_queue.put('STOP') monitor(result_...
python
def _sync(pack): """Simulate a package travelling through the cluster.""" task_queue = Queue() result_queue = Queue() task = SignedPackage.loads(pack) task_queue.put(task) task_queue.put('STOP') worker(task_queue, result_queue, Value('f', -1)) result_queue.put('STOP') monitor(result_...
[ "def", "_sync", "(", "pack", ")", ":", "task_queue", "=", "Queue", "(", ")", "result_queue", "=", "Queue", "(", ")", "task", "=", "SignedPackage", ".", "loads", "(", "pack", ")", "task_queue", ".", "put", "(", "task", ")", "task_queue", ".", "put", "...
Simulate a package travelling through the cluster.
[ "Simulate", "a", "package", "travelling", "through", "the", "cluster", "." ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L677-L691
221,929
Koed00/django-q
django_q/tasks.py
Iter.append
def append(self, *args): """ add arguments to the set """ self.args.append(args) if self.started: self.started = False return self.length()
python
def append(self, *args): """ add arguments to the set """ self.args.append(args) if self.started: self.started = False return self.length()
[ "def", "append", "(", "self", ",", "*", "args", ")", ":", "self", ".", "args", ".", "append", "(", "args", ")", "if", "self", ".", "started", ":", "self", ".", "started", "=", "False", "return", "self", ".", "length", "(", ")" ]
add arguments to the set
[ "add", "arguments", "to", "the", "set" ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L460-L467
221,930
Koed00/django-q
django_q/admin.py
retry_failed
def retry_failed(FailAdmin, request, queryset): """Submit selected tasks back to the queue.""" for task in queryset: async_task(task.func, *task.args or (), hook=task.hook, **task.kwargs or {}) task.delete()
python
def retry_failed(FailAdmin, request, queryset): """Submit selected tasks back to the queue.""" for task in queryset: async_task(task.func, *task.args or (), hook=task.hook, **task.kwargs or {}) task.delete()
[ "def", "retry_failed", "(", "FailAdmin", ",", "request", ",", "queryset", ")", ":", "for", "task", "in", "queryset", ":", "async_task", "(", "task", ".", "func", ",", "*", "task", ".", "args", "or", "(", ")", ",", "hook", "=", "task", ".", "hook", ...
Submit selected tasks back to the queue.
[ "Submit", "selected", "tasks", "back", "to", "the", "queue", "." ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/admin.py#L40-L44
221,931
Koed00/django-q
django_q/admin.py
TaskAdmin.get_queryset
def get_queryset(self, request): """Only show successes.""" qs = super(TaskAdmin, self).get_queryset(request) return qs.filter(success=True)
python
def get_queryset(self, request): """Only show successes.""" qs = super(TaskAdmin, self).get_queryset(request) return qs.filter(success=True)
[ "def", "get_queryset", "(", "self", ",", "request", ")", ":", "qs", "=", "super", "(", "TaskAdmin", ",", "self", ")", ".", "get_queryset", "(", "request", ")", "return", "qs", ".", "filter", "(", "success", "=", "True", ")" ]
Only show successes.
[ "Only", "show", "successes", "." ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/admin.py#L26-L29
221,932
Koed00/django-q
django_q/admin.py
TaskAdmin.get_readonly_fields
def get_readonly_fields(self, request, obj=None): """Set all fields readonly.""" return list(self.readonly_fields) + [field.name for field in obj._meta.fields]
python
def get_readonly_fields(self, request, obj=None): """Set all fields readonly.""" return list(self.readonly_fields) + [field.name for field in obj._meta.fields]
[ "def", "get_readonly_fields", "(", "self", ",", "request", ",", "obj", "=", "None", ")", ":", "return", "list", "(", "self", ".", "readonly_fields", ")", "+", "[", "field", ".", "name", "for", "field", "in", "obj", ".", "_meta", ".", "fields", "]" ]
Set all fields readonly.
[ "Set", "all", "fields", "readonly", "." ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/admin.py#L35-L37
221,933
Koed00/django-q
django_q/cluster.py
save_task
def save_task(task, broker): """ Saves the task package to Django or the cache """ # SAVE LIMIT < 0 : Don't save success if not task.get('save', Conf.SAVE_LIMIT >= 0) and task['success']: return # enqueues next in a chain if task.get('chain', None): django_q.tasks.async_chain...
python
def save_task(task, broker): """ Saves the task package to Django or the cache """ # SAVE LIMIT < 0 : Don't save success if not task.get('save', Conf.SAVE_LIMIT >= 0) and task['success']: return # enqueues next in a chain if task.get('chain', None): django_q.tasks.async_chain...
[ "def", "save_task", "(", "task", ",", "broker", ")", ":", "# SAVE LIMIT < 0 : Don't save success", "if", "not", "task", ".", "get", "(", "'save'", ",", "Conf", ".", "SAVE_LIMIT", ">=", "0", ")", "and", "task", "[", "'success'", "]", ":", "return", "# enque...
Saves the task package to Django or the cache
[ "Saves", "the", "task", "package", "to", "Django", "or", "the", "cache" ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/cluster.py#L400-L438
221,934
Koed00/django-q
django_q/cluster.py
scheduler
def scheduler(broker=None): """ Creates a task from a schedule at the scheduled time and schedules next run """ if not broker: broker = get_broker() db.close_old_connections() try: for s in Schedule.objects.exclude(repeats=0).filter(next_run__lt=timezone.now()): args ...
python
def scheduler(broker=None): """ Creates a task from a schedule at the scheduled time and schedules next run """ if not broker: broker = get_broker() db.close_old_connections() try: for s in Schedule.objects.exclude(repeats=0).filter(next_run__lt=timezone.now()): args ...
[ "def", "scheduler", "(", "broker", "=", "None", ")", ":", "if", "not", "broker", ":", "broker", "=", "get_broker", "(", ")", "db", ".", "close_old_connections", "(", ")", "try", ":", "for", "s", "in", "Schedule", ".", "objects", ".", "exclude", "(", ...
Creates a task from a schedule at the scheduled time and schedules next run
[ "Creates", "a", "task", "from", "a", "schedule", "at", "the", "scheduled", "time", "and", "schedules", "next", "run" ]
c84fd11a67c9a47d821786dfcdc189bb258c6f54
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/cluster.py#L486-L557
221,935
google/python-adb
adb/adb_commands.py
AdbCommands._get_service_connection
def _get_service_connection(self, service, service_command=None, create=True, timeout_ms=None): """ Based on the service, get the AdbConnection for that service or create one if it doesnt exist :param service: :param service_command: Additional service parameters to append :para...
python
def _get_service_connection(self, service, service_command=None, create=True, timeout_ms=None): """ Based on the service, get the AdbConnection for that service or create one if it doesnt exist :param service: :param service_command: Additional service parameters to append :para...
[ "def", "_get_service_connection", "(", "self", ",", "service", ",", "service_command", "=", "None", ",", "create", "=", "True", ",", "timeout_ms", "=", "None", ")", ":", "connection", "=", "self", ".", "_service_connections", ".", "get", "(", "service", ",",...
Based on the service, get the AdbConnection for that service or create one if it doesnt exist :param service: :param service_command: Additional service parameters to append :param create: If False, dont create a connection if it does not exist :return:
[ "Based", "on", "the", "service", "get", "the", "AdbConnection", "for", "that", "service", "or", "create", "one", "if", "it", "doesnt", "exist" ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_commands.py#L71-L99
221,936
google/python-adb
adb/adb_commands.py
AdbCommands.ConnectDevice
def ConnectDevice(self, port_path=None, serial=None, default_timeout_ms=None, **kwargs): """Convenience function to setup a transport handle for the adb device from usb path or serial then connect to it. Args: port_path: The filename of usb port to use. serial: The seri...
python
def ConnectDevice(self, port_path=None, serial=None, default_timeout_ms=None, **kwargs): """Convenience function to setup a transport handle for the adb device from usb path or serial then connect to it. Args: port_path: The filename of usb port to use. serial: The seri...
[ "def", "ConnectDevice", "(", "self", ",", "port_path", "=", "None", ",", "serial", "=", "None", ",", "default_timeout_ms", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# If there isnt a handle override (used by tests), build one here", "if", "'handle'", "in", ...
Convenience function to setup a transport handle for the adb device from usb path or serial then connect to it. Args: port_path: The filename of usb port to use. serial: The serial number of the device to use. default_timeout_ms: The default timeout in milliseconds to...
[ "Convenience", "function", "to", "setup", "a", "transport", "handle", "for", "the", "adb", "device", "from", "usb", "path", "or", "serial", "then", "connect", "to", "it", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_commands.py#L101-L144
221,937
google/python-adb
adb/adb_commands.py
AdbCommands.Install
def Install(self, apk_path, destination_dir='', replace_existing=True, grant_permissions=False, timeout_ms=None, transfer_progress_callback=None): """Install an apk to the device. Doesn't support verifier file, instead allows destination directory to be overridden. Args...
python
def Install(self, apk_path, destination_dir='', replace_existing=True, grant_permissions=False, timeout_ms=None, transfer_progress_callback=None): """Install an apk to the device. Doesn't support verifier file, instead allows destination directory to be overridden. Args...
[ "def", "Install", "(", "self", ",", "apk_path", ",", "destination_dir", "=", "''", ",", "replace_existing", "=", "True", ",", "grant_permissions", "=", "False", ",", "timeout_ms", "=", "None", ",", "transfer_progress_callback", "=", "None", ")", ":", "if", "...
Install an apk to the device. Doesn't support verifier file, instead allows destination directory to be overridden. Args: apk_path: Local path to apk to install. destination_dir: Optional destination directory. Use /system/app/ for persistent applications. ...
[ "Install", "an", "apk", "to", "the", "device", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_commands.py#L192-L230
221,938
google/python-adb
adb/adb_commands.py
AdbCommands.Uninstall
def Uninstall(self, package_name, keep_data=False, timeout_ms=None): """Removes a package from the device. Args: package_name: Package name of target package. keep_data: whether to keep the data and cache directories timeout_ms: Expected timeout for pushing and installing....
python
def Uninstall(self, package_name, keep_data=False, timeout_ms=None): """Removes a package from the device. Args: package_name: Package name of target package. keep_data: whether to keep the data and cache directories timeout_ms: Expected timeout for pushing and installing....
[ "def", "Uninstall", "(", "self", ",", "package_name", ",", "keep_data", "=", "False", ",", "timeout_ms", "=", "None", ")", ":", "cmd", "=", "[", "'pm uninstall'", "]", "if", "keep_data", ":", "cmd", ".", "append", "(", "'-k'", ")", "cmd", ".", "append"...
Removes a package from the device. Args: package_name: Package name of target package. keep_data: whether to keep the data and cache directories timeout_ms: Expected timeout for pushing and installing. Returns: The pm uninstall output.
[ "Removes", "a", "package", "from", "the", "device", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_commands.py#L232-L248
221,939
google/python-adb
adb/adb_commands.py
AdbCommands.Push
def Push(self, source_file, device_filename, mtime='0', timeout_ms=None, progress_callback=None, st_mode=None): """Push a file or directory to the device. Args: source_file: Either a filename, a directory or file-like object to push to the device. device_filen...
python
def Push(self, source_file, device_filename, mtime='0', timeout_ms=None, progress_callback=None, st_mode=None): """Push a file or directory to the device. Args: source_file: Either a filename, a directory or file-like object to push to the device. device_filen...
[ "def", "Push", "(", "self", ",", "source_file", ",", "device_filename", ",", "mtime", "=", "'0'", ",", "timeout_ms", "=", "None", ",", "progress_callback", "=", "None", ",", "st_mode", "=", "None", ")", ":", "if", "isinstance", "(", "source_file", ",", "...
Push a file or directory to the device. Args: source_file: Either a filename, a directory or file-like object to push to the device. device_filename: Destination on the device to write to. mtime: Optional, modification time to set on the file. time...
[ "Push", "a", "file", "or", "directory", "to", "the", "device", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_commands.py#L250-L281
221,940
google/python-adb
adb/adb_commands.py
AdbCommands.Pull
def Pull(self, device_filename, dest_file=None, timeout_ms=None, progress_callback=None): """Pull a file from the device. Args: device_filename: Filename on the device to pull. dest_file: If set, a filename or writable file-like object. timeout_ms: Expected timeout for any...
python
def Pull(self, device_filename, dest_file=None, timeout_ms=None, progress_callback=None): """Pull a file from the device. Args: device_filename: Filename on the device to pull. dest_file: If set, a filename or writable file-like object. timeout_ms: Expected timeout for any...
[ "def", "Pull", "(", "self", ",", "device_filename", ",", "dest_file", "=", "None", ",", "timeout_ms", "=", "None", ",", "progress_callback", "=", "None", ")", ":", "if", "not", "dest_file", ":", "dest_file", "=", "io", ".", "BytesIO", "(", ")", "elif", ...
Pull a file from the device. Args: device_filename: Filename on the device to pull. dest_file: If set, a filename or writable file-like object. timeout_ms: Expected timeout for any part of the pull. progress_callback: callback method that accepts filename, bytes_written ...
[ "Pull", "a", "file", "from", "the", "device", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_commands.py#L283-L318
221,941
google/python-adb
adb/adb_commands.py
AdbCommands.List
def List(self, device_path): """Return a directory listing of the given path. Args: device_path: Directory to list. """ connection = self.protocol_handler.Open(self._handle, destination=b'sync:') listing = self.filesync_handler.List(connection, device_path) con...
python
def List(self, device_path): """Return a directory listing of the given path. Args: device_path: Directory to list. """ connection = self.protocol_handler.Open(self._handle, destination=b'sync:') listing = self.filesync_handler.List(connection, device_path) con...
[ "def", "List", "(", "self", ",", "device_path", ")", ":", "connection", "=", "self", ".", "protocol_handler", ".", "Open", "(", "self", ".", "_handle", ",", "destination", "=", "b'sync:'", ")", "listing", "=", "self", ".", "filesync_handler", ".", "List", ...
Return a directory listing of the given path. Args: device_path: Directory to list.
[ "Return", "a", "directory", "listing", "of", "the", "given", "path", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_commands.py#L328-L337
221,942
google/python-adb
adb/adb_commands.py
AdbCommands.Shell
def Shell(self, command, timeout_ms=None): """Run command on the device, returning the output. Args: command: Shell command to run timeout_ms: Maximum time to allow the command to run. """ return self.protocol_handler.Command( self._handle, service=b'shel...
python
def Shell(self, command, timeout_ms=None): """Run command on the device, returning the output. Args: command: Shell command to run timeout_ms: Maximum time to allow the command to run. """ return self.protocol_handler.Command( self._handle, service=b'shel...
[ "def", "Shell", "(", "self", ",", "command", ",", "timeout_ms", "=", "None", ")", ":", "return", "self", ".", "protocol_handler", ".", "Command", "(", "self", ".", "_handle", ",", "service", "=", "b'shell'", ",", "command", "=", "command", ",", "timeout_...
Run command on the device, returning the output. Args: command: Shell command to run timeout_ms: Maximum time to allow the command to run.
[ "Run", "command", "on", "the", "device", "returning", "the", "output", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_commands.py#L367-L376
221,943
google/python-adb
adb/adb_commands.py
AdbCommands.StreamingShell
def StreamingShell(self, command, timeout_ms=None): """Run command on the device, yielding each line of output. Args: command: Command to run on the target. timeout_ms: Maximum time to allow the command to run. Yields: The responses from the shell command. ...
python
def StreamingShell(self, command, timeout_ms=None): """Run command on the device, yielding each line of output. Args: command: Command to run on the target. timeout_ms: Maximum time to allow the command to run. Yields: The responses from the shell command. ...
[ "def", "StreamingShell", "(", "self", ",", "command", ",", "timeout_ms", "=", "None", ")", ":", "return", "self", ".", "protocol_handler", ".", "StreamingCommand", "(", "self", ".", "_handle", ",", "service", "=", "b'shell'", ",", "command", "=", "command", ...
Run command on the device, yielding each line of output. Args: command: Command to run on the target. timeout_ms: Maximum time to allow the command to run. Yields: The responses from the shell command.
[ "Run", "command", "on", "the", "device", "yielding", "each", "line", "of", "output", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_commands.py#L378-L390
221,944
google/python-adb
adb/adb_commands.py
AdbCommands.InteractiveShell
def InteractiveShell(self, cmd=None, strip_cmd=True, delim=None, strip_delim=True): """Get stdout from the currently open interactive shell and optionally run a command on the device, returning all output. Args: cmd: Optional. Command to run on the target. strip_cmd: Opt...
python
def InteractiveShell(self, cmd=None, strip_cmd=True, delim=None, strip_delim=True): """Get stdout from the currently open interactive shell and optionally run a command on the device, returning all output. Args: cmd: Optional. Command to run on the target. strip_cmd: Opt...
[ "def", "InteractiveShell", "(", "self", ",", "cmd", "=", "None", ",", "strip_cmd", "=", "True", ",", "delim", "=", "None", ",", "strip_delim", "=", "True", ")", ":", "conn", "=", "self", ".", "_get_service_connection", "(", "b'shell:'", ")", "return", "s...
Get stdout from the currently open interactive shell and optionally run a command on the device, returning all output. Args: cmd: Optional. Command to run on the target. strip_cmd: Optional (default True). Strip command name from stdout. delim: Optional. Delimiter to l...
[ "Get", "stdout", "from", "the", "currently", "open", "interactive", "shell", "and", "optionally", "run", "a", "command", "on", "the", "device", "returning", "all", "output", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_commands.py#L401-L419
221,945
google/python-adb
adb/common.py
InterfaceMatcher
def InterfaceMatcher(clazz, subclass, protocol): """Returns a matcher that returns the setting with the given interface.""" interface = (clazz, subclass, protocol) def Matcher(device): for setting in device.iterSettings(): if GetInterface(setting) == interface: return se...
python
def InterfaceMatcher(clazz, subclass, protocol): """Returns a matcher that returns the setting with the given interface.""" interface = (clazz, subclass, protocol) def Matcher(device): for setting in device.iterSettings(): if GetInterface(setting) == interface: return se...
[ "def", "InterfaceMatcher", "(", "clazz", ",", "subclass", ",", "protocol", ")", ":", "interface", "=", "(", "clazz", ",", "subclass", ",", "protocol", ")", "def", "Matcher", "(", "device", ")", ":", "for", "setting", "in", "device", ".", "iterSettings", ...
Returns a matcher that returns the setting with the given interface.
[ "Returns", "a", "matcher", "that", "returns", "the", "setting", "with", "the", "given", "interface", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/common.py#L40-L49
221,946
google/python-adb
adb/common.py
UsbHandle.Open
def Open(self): """Opens the USB device for this setting, and claims the interface.""" # Make sure we close any previous handle open to this usb device. port_path = tuple(self.port_path) with self._HANDLE_CACHE_LOCK: old_handle = self._HANDLE_CACHE.get(port_path) ...
python
def Open(self): """Opens the USB device for this setting, and claims the interface.""" # Make sure we close any previous handle open to this usb device. port_path = tuple(self.port_path) with self._HANDLE_CACHE_LOCK: old_handle = self._HANDLE_CACHE.get(port_path) ...
[ "def", "Open", "(", "self", ")", ":", "# Make sure we close any previous handle open to this usb device.", "port_path", "=", "tuple", "(", "self", ".", "port_path", ")", "with", "self", ".", "_HANDLE_CACHE_LOCK", ":", "old_handle", "=", "self", ".", "_HANDLE_CACHE", ...
Opens the USB device for this setting, and claims the interface.
[ "Opens", "the", "USB", "device", "for", "this", "setting", "and", "claims", "the", "interface", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/common.py#L94-L135
221,947
google/python-adb
adb/common.py
UsbHandle.PortPathMatcher
def PortPathMatcher(cls, port_path): """Returns a device matcher for the given port path.""" if isinstance(port_path, str): # Convert from sysfs path to port_path. port_path = [int(part) for part in SYSFS_PORT_SPLIT_RE.split(port_path)] return lambda device: device.port_p...
python
def PortPathMatcher(cls, port_path): """Returns a device matcher for the given port path.""" if isinstance(port_path, str): # Convert from sysfs path to port_path. port_path = [int(part) for part in SYSFS_PORT_SPLIT_RE.split(port_path)] return lambda device: device.port_p...
[ "def", "PortPathMatcher", "(", "cls", ",", "port_path", ")", ":", "if", "isinstance", "(", "port_path", ",", "str", ")", ":", "# Convert from sysfs path to port_path.", "port_path", "=", "[", "int", "(", "part", ")", "for", "part", "in", "SYSFS_PORT_SPLIT_RE", ...
Returns a device matcher for the given port path.
[ "Returns", "a", "device", "matcher", "for", "the", "given", "port", "path", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/common.py#L203-L208
221,948
google/python-adb
adb/common.py
UsbHandle.Find
def Find(cls, setting_matcher, port_path=None, serial=None, timeout_ms=None): """Gets the first device that matches according to the keyword args.""" if port_path: device_matcher = cls.PortPathMatcher(port_path) usb_info = port_path elif serial: device_matcher...
python
def Find(cls, setting_matcher, port_path=None, serial=None, timeout_ms=None): """Gets the first device that matches according to the keyword args.""" if port_path: device_matcher = cls.PortPathMatcher(port_path) usb_info = port_path elif serial: device_matcher...
[ "def", "Find", "(", "cls", ",", "setting_matcher", ",", "port_path", "=", "None", ",", "serial", "=", "None", ",", "timeout_ms", "=", "None", ")", ":", "if", "port_path", ":", "device_matcher", "=", "cls", ".", "PortPathMatcher", "(", "port_path", ")", "...
Gets the first device that matches according to the keyword args.
[ "Gets", "the", "first", "device", "that", "matches", "according", "to", "the", "keyword", "args", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/common.py#L226-L238
221,949
google/python-adb
adb/common.py
UsbHandle.FindFirst
def FindFirst(cls, setting_matcher, device_matcher=None, **kwargs): """Find and return the first matching device. Args: setting_matcher: See cls.FindDevices. device_matcher: See cls.FindDevices. **kwargs: See cls.FindDevices. Returns: An instance of UsbH...
python
def FindFirst(cls, setting_matcher, device_matcher=None, **kwargs): """Find and return the first matching device. Args: setting_matcher: See cls.FindDevices. device_matcher: See cls.FindDevices. **kwargs: See cls.FindDevices. Returns: An instance of UsbH...
[ "def", "FindFirst", "(", "cls", ",", "setting_matcher", ",", "device_matcher", "=", "None", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "next", "(", "cls", ".", "FindDevices", "(", "setting_matcher", ",", "device_matcher", "=", "device_matcher",...
Find and return the first matching device. Args: setting_matcher: See cls.FindDevices. device_matcher: See cls.FindDevices. **kwargs: See cls.FindDevices. Returns: An instance of UsbHandle. Raises: DeviceNotFoundError: Raised if the device is ...
[ "Find", "and", "return", "the", "first", "matching", "device", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/common.py#L241-L260
221,950
google/python-adb
adb/common.py
UsbHandle.FindDevices
def FindDevices(cls, setting_matcher, device_matcher=None, usb_info='', timeout_ms=None): """Find and yield the devices that match. Args: setting_matcher: Function that returns the setting to use given a usb1.USBDevice, or None if the device doesn't have a vali...
python
def FindDevices(cls, setting_matcher, device_matcher=None, usb_info='', timeout_ms=None): """Find and yield the devices that match. Args: setting_matcher: Function that returns the setting to use given a usb1.USBDevice, or None if the device doesn't have a vali...
[ "def", "FindDevices", "(", "cls", ",", "setting_matcher", ",", "device_matcher", "=", "None", ",", "usb_info", "=", "''", ",", "timeout_ms", "=", "None", ")", ":", "ctx", "=", "usb1", ".", "USBContext", "(", ")", "for", "device", "in", "ctx", ".", "get...
Find and yield the devices that match. Args: setting_matcher: Function that returns the setting to use given a usb1.USBDevice, or None if the device doesn't have a valid setting. device_matcher: Function that returns True if the given UsbHandle is valid. None to matc...
[ "Find", "and", "yield", "the", "devices", "that", "match", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/common.py#L263-L286
221,951
google/python-adb
adb/adb_protocol.py
_AdbConnection.Write
def Write(self, data): """Write a packet and expect an Ack.""" self._Send(b'WRTE', arg0=self.local_id, arg1=self.remote_id, data=data) # Expect an ack in response. cmd, okay_data = self.ReadUntil(b'OKAY') if cmd != b'OKAY': if cmd == b'FAIL': raise usb...
python
def Write(self, data): """Write a packet and expect an Ack.""" self._Send(b'WRTE', arg0=self.local_id, arg1=self.remote_id, data=data) # Expect an ack in response. cmd, okay_data = self.ReadUntil(b'OKAY') if cmd != b'OKAY': if cmd == b'FAIL': raise usb...
[ "def", "Write", "(", "self", ",", "data", ")", ":", "self", ".", "_Send", "(", "b'WRTE'", ",", "arg0", "=", "self", ".", "local_id", ",", "arg1", "=", "self", ".", "remote_id", ",", "data", "=", "data", ")", "# Expect an ack in response.", "cmd", ",", ...
Write a packet and expect an Ack.
[ "Write", "a", "packet", "and", "expect", "an", "Ack", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_protocol.py#L109-L121
221,952
google/python-adb
adb/adb_protocol.py
_AdbConnection.ReadUntil
def ReadUntil(self, *expected_cmds): """Read a packet, Ack any write packets.""" cmd, remote_id, local_id, data = AdbMessage.Read( self.usb, expected_cmds, self.timeout_ms) if local_id != 0 and self.local_id != local_id: raise InterleavedDataError("We don't support multip...
python
def ReadUntil(self, *expected_cmds): """Read a packet, Ack any write packets.""" cmd, remote_id, local_id, data = AdbMessage.Read( self.usb, expected_cmds, self.timeout_ms) if local_id != 0 and self.local_id != local_id: raise InterleavedDataError("We don't support multip...
[ "def", "ReadUntil", "(", "self", ",", "*", "expected_cmds", ")", ":", "cmd", ",", "remote_id", ",", "local_id", ",", "data", "=", "AdbMessage", ".", "Read", "(", "self", ".", "usb", ",", "expected_cmds", ",", "self", ".", "timeout_ms", ")", "if", "loca...
Read a packet, Ack any write packets.
[ "Read", "a", "packet", "Ack", "any", "write", "packets", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_protocol.py#L126-L139
221,953
google/python-adb
adb/adb_protocol.py
_AdbConnection.ReadUntilClose
def ReadUntilClose(self): """Yield packets until a Close packet is received.""" while True: cmd, data = self.ReadUntil(b'CLSE', b'WRTE') if cmd == b'CLSE': self._Send(b'CLSE', arg0=self.local_id, arg1=self.remote_id) break if cmd != b'W...
python
def ReadUntilClose(self): """Yield packets until a Close packet is received.""" while True: cmd, data = self.ReadUntil(b'CLSE', b'WRTE') if cmd == b'CLSE': self._Send(b'CLSE', arg0=self.local_id, arg1=self.remote_id) break if cmd != b'W...
[ "def", "ReadUntilClose", "(", "self", ")", ":", "while", "True", ":", "cmd", ",", "data", "=", "self", ".", "ReadUntil", "(", "b'CLSE'", ",", "b'WRTE'", ")", "if", "cmd", "==", "b'CLSE'", ":", "self", ".", "_Send", "(", "b'CLSE'", ",", "arg0", "=", ...
Yield packets until a Close packet is received.
[ "Yield", "packets", "until", "a", "Close", "packet", "is", "received", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_protocol.py#L141-L154
221,954
google/python-adb
adb/adb_protocol.py
AdbMessage.Pack
def Pack(self): """Returns this message in an over-the-wire format.""" return struct.pack(self.format, self.command, self.arg0, self.arg1, len(self.data), self.checksum, self.magic)
python
def Pack(self): """Returns this message in an over-the-wire format.""" return struct.pack(self.format, self.command, self.arg0, self.arg1, len(self.data), self.checksum, self.magic)
[ "def", "Pack", "(", "self", ")", ":", "return", "struct", ".", "pack", "(", "self", ".", "format", ",", "self", ".", "command", ",", "self", ".", "arg0", ",", "self", ".", "arg1", ",", "len", "(", "self", ".", "data", ")", ",", "self", ".", "ch...
Returns this message in an over-the-wire format.
[ "Returns", "this", "message", "in", "an", "over", "-", "the", "-", "wire", "format", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_protocol.py#L217-L220
221,955
google/python-adb
adb/adb_protocol.py
AdbMessage.Send
def Send(self, usb, timeout_ms=None): """Send this message over USB.""" usb.BulkWrite(self.Pack(), timeout_ms) usb.BulkWrite(self.data, timeout_ms)
python
def Send(self, usb, timeout_ms=None): """Send this message over USB.""" usb.BulkWrite(self.Pack(), timeout_ms) usb.BulkWrite(self.data, timeout_ms)
[ "def", "Send", "(", "self", ",", "usb", ",", "timeout_ms", "=", "None", ")", ":", "usb", ".", "BulkWrite", "(", "self", ".", "Pack", "(", ")", ",", "timeout_ms", ")", "usb", ".", "BulkWrite", "(", "self", ".", "data", ",", "timeout_ms", ")" ]
Send this message over USB.
[ "Send", "this", "message", "over", "USB", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_protocol.py#L231-L234
221,956
google/python-adb
adb/adb_protocol.py
AdbMessage.Read
def Read(cls, usb, expected_cmds, timeout_ms=None, total_timeout_ms=None): """Receive a response from the device.""" total_timeout_ms = usb.Timeout(total_timeout_ms) start = time.time() while True: msg = usb.BulkRead(24, timeout_ms) cmd, arg0, arg1, data_length, d...
python
def Read(cls, usb, expected_cmds, timeout_ms=None, total_timeout_ms=None): """Receive a response from the device.""" total_timeout_ms = usb.Timeout(total_timeout_ms) start = time.time() while True: msg = usb.BulkRead(24, timeout_ms) cmd, arg0, arg1, data_length, d...
[ "def", "Read", "(", "cls", ",", "usb", ",", "expected_cmds", ",", "timeout_ms", "=", "None", ",", "total_timeout_ms", "=", "None", ")", ":", "total_timeout_ms", "=", "usb", ".", "Timeout", "(", "total_timeout_ms", ")", "start", "=", "time", ".", "time", ...
Receive a response from the device.
[ "Receive", "a", "response", "from", "the", "device", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_protocol.py#L237-L273
221,957
google/python-adb
adb/adb_protocol.py
AdbMessage.Connect
def Connect(cls, usb, banner=b'notadb', rsa_keys=None, auth_timeout_ms=100): """Establish a new connection to the device. Args: usb: A USBHandle with BulkRead and BulkWrite methods. banner: A string to send as a host identifier. rsa_keys: List of AuthSigner subclass instan...
python
def Connect(cls, usb, banner=b'notadb', rsa_keys=None, auth_timeout_ms=100): """Establish a new connection to the device. Args: usb: A USBHandle with BulkRead and BulkWrite methods. banner: A string to send as a host identifier. rsa_keys: List of AuthSigner subclass instan...
[ "def", "Connect", "(", "cls", ",", "usb", ",", "banner", "=", "b'notadb'", ",", "rsa_keys", "=", "None", ",", "auth_timeout_ms", "=", "100", ")", ":", "# In py3, convert unicode to bytes. In py2, convert str to bytes.", "# It's later joined into a byte string, so in py2, th...
Establish a new connection to the device. Args: usb: A USBHandle with BulkRead and BulkWrite methods. banner: A string to send as a host identifier. rsa_keys: List of AuthSigner subclass instances to be used for authentication. The device can either accept one of the...
[ "Establish", "a", "new", "connection", "to", "the", "device", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_protocol.py#L276-L348
221,958
google/python-adb
adb/adb_protocol.py
AdbMessage.Open
def Open(cls, usb, destination, timeout_ms=None): """Opens a new connection to the device via an OPEN message. Not the same as the posix 'open' or any other google3 Open methods. Args: usb: USB device handle with BulkRead and BulkWrite methods. destination: The service:comm...
python
def Open(cls, usb, destination, timeout_ms=None): """Opens a new connection to the device via an OPEN message. Not the same as the posix 'open' or any other google3 Open methods. Args: usb: USB device handle with BulkRead and BulkWrite methods. destination: The service:comm...
[ "def", "Open", "(", "cls", ",", "usb", ",", "destination", ",", "timeout_ms", "=", "None", ")", ":", "local_id", "=", "1", "msg", "=", "cls", "(", "command", "=", "b'OPEN'", ",", "arg0", "=", "local_id", ",", "arg1", "=", "0", ",", "data", "=", "...
Opens a new connection to the device via an OPEN message. Not the same as the posix 'open' or any other google3 Open methods. Args: usb: USB device handle with BulkRead and BulkWrite methods. destination: The service:command string. timeout_ms: Timeout in milliseconds for...
[ "Opens", "a", "new", "connection", "to", "the", "device", "via", "an", "OPEN", "message", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_protocol.py#L351-L388
221,959
google/python-adb
adb/fastboot.py
FastbootCommands.ConnectDevice
def ConnectDevice(self, port_path=None, serial=None, default_timeout_ms=None, chunk_kb=1024, **kwargs): """Convenience function to get an adb device from usb path or serial. Args: port_path: The filename of usb port to use. serial: The serial number of the device to use. d...
python
def ConnectDevice(self, port_path=None, serial=None, default_timeout_ms=None, chunk_kb=1024, **kwargs): """Convenience function to get an adb device from usb path or serial. Args: port_path: The filename of usb port to use. serial: The serial number of the device to use. d...
[ "def", "ConnectDevice", "(", "self", ",", "port_path", "=", "None", ",", "serial", "=", "None", ",", "default_timeout_ms", "=", "None", ",", "chunk_kb", "=", "1024", ",", "*", "*", "kwargs", ")", ":", "if", "'handle'", "in", "kwargs", ":", "self", ".",...
Convenience function to get an adb device from usb path or serial. Args: port_path: The filename of usb port to use. serial: The serial number of the device to use. default_timeout_ms: The default timeout in milliseconds to use. chunk_kb: Amount of data, in kilobytes, to...
[ "Convenience", "function", "to", "get", "an", "adb", "device", "from", "usb", "path", "or", "serial", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/fastboot.py#L225-L261
221,960
google/python-adb
adb/common_cli.py
_DocToArgs
def _DocToArgs(doc): """Converts a docstring documenting arguments into a dict.""" m = None offset = None in_arg = False out = {} for l in doc.splitlines(): if l.strip() == 'Args:': in_arg = True elif in_arg: if not l.strip(): break ...
python
def _DocToArgs(doc): """Converts a docstring documenting arguments into a dict.""" m = None offset = None in_arg = False out = {} for l in doc.splitlines(): if l.strip() == 'Args:': in_arg = True elif in_arg: if not l.strip(): break ...
[ "def", "_DocToArgs", "(", "doc", ")", ":", "m", "=", "None", "offset", "=", "None", "in_arg", "=", "False", "out", "=", "{", "}", "for", "l", "in", "doc", ".", "splitlines", "(", ")", ":", "if", "l", ".", "strip", "(", ")", "==", "'Args:'", ":"...
Converts a docstring documenting arguments into a dict.
[ "Converts", "a", "docstring", "documenting", "arguments", "into", "a", "dict", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/common_cli.py#L66-L86
221,961
google/python-adb
adb/common_cli.py
MakeSubparser
def MakeSubparser(subparsers, parents, method, arguments=None): """Returns an argparse subparser to create a 'subcommand' to adb.""" name = ('-'.join(re.split(r'([A-Z][a-z]+)', method.__name__)[1:-1:2])).lower() help = method.__doc__.splitlines()[0] subparser = subparsers.add_parser( name=name, ...
python
def MakeSubparser(subparsers, parents, method, arguments=None): """Returns an argparse subparser to create a 'subcommand' to adb.""" name = ('-'.join(re.split(r'([A-Z][a-z]+)', method.__name__)[1:-1:2])).lower() help = method.__doc__.splitlines()[0] subparser = subparsers.add_parser( name=name, ...
[ "def", "MakeSubparser", "(", "subparsers", ",", "parents", ",", "method", ",", "arguments", "=", "None", ")", ":", "name", "=", "(", "'-'", ".", "join", "(", "re", ".", "split", "(", "r'([A-Z][a-z]+)'", ",", "method", ".", "__name__", ")", "[", "1", ...
Returns an argparse subparser to create a 'subcommand' to adb.
[ "Returns", "an", "argparse", "subparser", "to", "create", "a", "subcommand", "to", "adb", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/common_cli.py#L89-L121
221,962
google/python-adb
adb/common_cli.py
_RunMethod
def _RunMethod(dev, args, extra): """Runs a method registered via MakeSubparser.""" logging.info('%s(%s)', args.method.__name__, ', '.join(args.positional)) result = args.method(dev, *args.positional, **extra) if result is not None: if isinstance(result, io.StringIO): sys.stdout.writ...
python
def _RunMethod(dev, args, extra): """Runs a method registered via MakeSubparser.""" logging.info('%s(%s)', args.method.__name__, ', '.join(args.positional)) result = args.method(dev, *args.positional, **extra) if result is not None: if isinstance(result, io.StringIO): sys.stdout.writ...
[ "def", "_RunMethod", "(", "dev", ",", "args", ",", "extra", ")", ":", "logging", ".", "info", "(", "'%s(%s)'", ",", "args", ".", "method", ".", "__name__", ",", "', '", ".", "join", "(", "args", ".", "positional", ")", ")", "result", "=", "args", "...
Runs a method registered via MakeSubparser.
[ "Runs", "a", "method", "registered", "via", "MakeSubparser", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/common_cli.py#L124-L143
221,963
google/python-adb
adb/common_cli.py
StartCli
def StartCli(args, adb_commands, extra=None, **device_kwargs): """Starts a common CLI interface for this usb path and protocol.""" try: dev = adb_commands() dev.ConnectDevice(port_path=args.port_path, serial=args.serial, default_timeout_ms=args.timeout_ms, **device_kwar...
python
def StartCli(args, adb_commands, extra=None, **device_kwargs): """Starts a common CLI interface for this usb path and protocol.""" try: dev = adb_commands() dev.ConnectDevice(port_path=args.port_path, serial=args.serial, default_timeout_ms=args.timeout_ms, **device_kwar...
[ "def", "StartCli", "(", "args", ",", "adb_commands", ",", "extra", "=", "None", ",", "*", "*", "device_kwargs", ")", ":", "try", ":", "dev", "=", "adb_commands", "(", ")", "dev", ".", "ConnectDevice", "(", "port_path", "=", "args", ".", "port_path", ",...
Starts a common CLI interface for this usb path and protocol.
[ "Starts", "a", "common", "CLI", "interface", "for", "this", "usb", "path", "and", "protocol", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/common_cli.py#L146-L164
221,964
google/python-adb
adb/filesync_protocol.py
FilesyncProtocol.Pull
def Pull(cls, connection, filename, dest_file, progress_callback): """Pull a file from the device into the file-like dest_file.""" if progress_callback: total_bytes = cls.Stat(connection, filename)[1] progress = cls._HandleProgress(lambda current: progress_callback(filename, curr...
python
def Pull(cls, connection, filename, dest_file, progress_callback): """Pull a file from the device into the file-like dest_file.""" if progress_callback: total_bytes = cls.Stat(connection, filename)[1] progress = cls._HandleProgress(lambda current: progress_callback(filename, curr...
[ "def", "Pull", "(", "cls", ",", "connection", ",", "filename", ",", "dest_file", ",", "progress_callback", ")", ":", "if", "progress_callback", ":", "total_bytes", "=", "cls", ".", "Stat", "(", "connection", ",", "filename", ")", "[", "1", "]", "progress",...
Pull a file from the device into the file-like dest_file.
[ "Pull", "a", "file", "from", "the", "device", "into", "the", "file", "-", "like", "dest_file", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/filesync_protocol.py#L84-L101
221,965
google/python-adb
adb/filesync_protocol.py
FileSyncConnection.Read
def Read(self, expected_ids, read_data=True): """Read ADB messages and return FileSync packets.""" if self.send_idx: self._Flush() # Read one filesync packet off the recv buffer. header_data = self._ReadBuffered(self.recv_header_len) header = struct.unpack(self.recv_...
python
def Read(self, expected_ids, read_data=True): """Read ADB messages and return FileSync packets.""" if self.send_idx: self._Flush() # Read one filesync packet off the recv buffer. header_data = self._ReadBuffered(self.recv_header_len) header = struct.unpack(self.recv_...
[ "def", "Read", "(", "self", ",", "expected_ids", ",", "read_data", "=", "True", ")", ":", "if", "self", ".", "send_idx", ":", "self", ".", "_Flush", "(", ")", "# Read one filesync packet off the recv buffer.", "header_data", "=", "self", ".", "_ReadBuffered", ...
Read ADB messages and return FileSync packets.
[ "Read", "ADB", "messages", "and", "return", "FileSync", "packets", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/filesync_protocol.py#L212-L238
221,966
google/python-adb
adb/filesync_protocol.py
FileSyncConnection.ReadUntil
def ReadUntil(self, expected_ids, *finish_ids): """Useful wrapper around Read.""" while True: cmd_id, header, data = self.Read(expected_ids + finish_ids) yield cmd_id, header, data if cmd_id in finish_ids: break
python
def ReadUntil(self, expected_ids, *finish_ids): """Useful wrapper around Read.""" while True: cmd_id, header, data = self.Read(expected_ids + finish_ids) yield cmd_id, header, data if cmd_id in finish_ids: break
[ "def", "ReadUntil", "(", "self", ",", "expected_ids", ",", "*", "finish_ids", ")", ":", "while", "True", ":", "cmd_id", ",", "header", ",", "data", "=", "self", ".", "Read", "(", "expected_ids", "+", "finish_ids", ")", "yield", "cmd_id", ",", "header", ...
Useful wrapper around Read.
[ "Useful", "wrapper", "around", "Read", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/filesync_protocol.py#L240-L246
221,967
google/python-adb
adb/adb_debug.py
Devices
def Devices(args): """Lists the available devices. Mimics 'adb devices' output: List of devices attached 015DB7591102001A device 1,2 """ for d in adb_commands.AdbCommands.Devices(): if args.output_port_path: print('%s\tdevice\t%s' % ( d.seri...
python
def Devices(args): """Lists the available devices. Mimics 'adb devices' output: List of devices attached 015DB7591102001A device 1,2 """ for d in adb_commands.AdbCommands.Devices(): if args.output_port_path: print('%s\tdevice\t%s' % ( d.seri...
[ "def", "Devices", "(", "args", ")", ":", "for", "d", "in", "adb_commands", ".", "AdbCommands", ".", "Devices", "(", ")", ":", "if", "args", ".", "output_port_path", ":", "print", "(", "'%s\\tdevice\\t%s'", "%", "(", "d", ".", "serial_number", ",", "','",...
Lists the available devices. Mimics 'adb devices' output: List of devices attached 015DB7591102001A device 1,2
[ "Lists", "the", "available", "devices", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_debug.py#L47-L60
221,968
google/python-adb
adb/adb_debug.py
List
def List(device, device_path): """Prints a directory listing. Args: device_path: Directory to list. """ files = device.List(device_path) files.sort(key=lambda x: x.filename) maxname = max(len(f.filename) for f in files) maxsize = max(len(str(f.size)) for f in files) for f in files...
python
def List(device, device_path): """Prints a directory listing. Args: device_path: Directory to list. """ files = device.List(device_path) files.sort(key=lambda x: x.filename) maxname = max(len(f.filename) for f in files) maxsize = max(len(str(f.size)) for f in files) for f in files...
[ "def", "List", "(", "device", ",", "device_path", ")", ":", "files", "=", "device", ".", "List", "(", "device_path", ")", "files", ".", "sort", "(", "key", "=", "lambda", "x", ":", "x", ".", "filename", ")", "maxname", "=", "max", "(", "len", "(", ...
Prints a directory listing. Args: device_path: Directory to list.
[ "Prints", "a", "directory", "listing", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_debug.py#L63-L89
221,969
google/python-adb
adb/adb_debug.py
Shell
def Shell(device, *command): """Runs a command on the device and prints the stdout. Args: command: Command to run on the target. """ if command: return device.StreamingShell(' '.join(command)) else: # Retrieve the initial terminal prompt to use as a delimiter for future reads ...
python
def Shell(device, *command): """Runs a command on the device and prints the stdout. Args: command: Command to run on the target. """ if command: return device.StreamingShell(' '.join(command)) else: # Retrieve the initial terminal prompt to use as a delimiter for future reads ...
[ "def", "Shell", "(", "device", ",", "*", "command", ")", ":", "if", "command", ":", "return", "device", ".", "StreamingShell", "(", "' '", ".", "join", "(", "command", ")", ")", "else", ":", "# Retrieve the initial terminal prompt to use as a delimiter for future ...
Runs a command on the device and prints the stdout. Args: command: Command to run on the target.
[ "Runs", "a", "command", "on", "the", "device", "and", "prints", "the", "stdout", "." ]
d9b94b2dda555c14674c19806debb8449c0e9652
https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_debug.py#L98-L125
221,970
retext-project/retext
ReText/tab.py
ReTextTab.updateActiveMarkupClass
def updateActiveMarkupClass(self): ''' Update the active markup class based on the default class and the current filename. If the active markup class changes, the highlighter is rerun on the input text, the markup object of this tab is replaced with one of the new class and the activeMarkupChanged signal is...
python
def updateActiveMarkupClass(self): ''' Update the active markup class based on the default class and the current filename. If the active markup class changes, the highlighter is rerun on the input text, the markup object of this tab is replaced with one of the new class and the activeMarkupChanged signal is...
[ "def", "updateActiveMarkupClass", "(", "self", ")", ":", "previousMarkupClass", "=", "self", ".", "activeMarkupClass", "self", ".", "activeMarkupClass", "=", "find_markup_class_by_name", "(", "globalSettings", ".", "defaultMarkup", ")", "if", "self", ".", "_fileName",...
Update the active markup class based on the default class and the current filename. If the active markup class changes, the highlighter is rerun on the input text, the markup object of this tab is replaced with one of the new class and the activeMarkupChanged signal is emitted.
[ "Update", "the", "active", "markup", "class", "based", "on", "the", "default", "class", "and", "the", "current", "filename", ".", "If", "the", "active", "markup", "class", "changes", "the", "highlighter", "is", "rerun", "on", "the", "input", "text", "the", ...
ad70435341dd89c7a74742df9d1f9af70859a969
https://github.com/retext-project/retext/blob/ad70435341dd89c7a74742df9d1f9af70859a969/ReText/tab.py#L145-L168
221,971
retext-project/retext
ReText/tab.py
ReTextTab.detectFileEncoding
def detectFileEncoding(self, fileName): ''' Detect content encoding of specific file. It will return None if it can't determine the encoding. ''' try: import chardet except ImportError: return with open(fileName, 'rb') as inputFile: raw = inputFile.read(2048) result = chardet.detect(raw) i...
python
def detectFileEncoding(self, fileName): ''' Detect content encoding of specific file. It will return None if it can't determine the encoding. ''' try: import chardet except ImportError: return with open(fileName, 'rb') as inputFile: raw = inputFile.read(2048) result = chardet.detect(raw) i...
[ "def", "detectFileEncoding", "(", "self", ",", "fileName", ")", ":", "try", ":", "import", "chardet", "except", "ImportError", ":", "return", "with", "open", "(", "fileName", ",", "'rb'", ")", "as", "inputFile", ":", "raw", "=", "inputFile", ".", "read", ...
Detect content encoding of specific file. It will return None if it can't determine the encoding.
[ "Detect", "content", "encoding", "of", "specific", "file", "." ]
ad70435341dd89c7a74742df9d1f9af70859a969
https://github.com/retext-project/retext/blob/ad70435341dd89c7a74742df9d1f9af70859a969/ReText/tab.py#L296-L317
221,972
retext-project/retext
ReText/tab.py
ReTextTab.openSourceFile
def openSourceFile(self, fileToOpen): """Finds and opens the source file for link target fileToOpen. When links like [test](test) are clicked, the file test.md is opened. It has to be located next to the current opened file. Relative paths like [test](../test) or [test](folder/test) are also possible. """ ...
python
def openSourceFile(self, fileToOpen): """Finds and opens the source file for link target fileToOpen. When links like [test](test) are clicked, the file test.md is opened. It has to be located next to the current opened file. Relative paths like [test](../test) or [test](folder/test) are also possible. """ ...
[ "def", "openSourceFile", "(", "self", ",", "fileToOpen", ")", ":", "if", "self", ".", "fileName", ":", "currentExt", "=", "splitext", "(", "self", ".", "fileName", ")", "[", "1", "]", "basename", ",", "ext", "=", "splitext", "(", "fileToOpen", ")", "if...
Finds and opens the source file for link target fileToOpen. When links like [test](test) are clicked, the file test.md is opened. It has to be located next to the current opened file. Relative paths like [test](../test) or [test](folder/test) are also possible.
[ "Finds", "and", "opens", "the", "source", "file", "for", "link", "target", "fileToOpen", "." ]
ad70435341dd89c7a74742df9d1f9af70859a969
https://github.com/retext-project/retext/blob/ad70435341dd89c7a74742df9d1f9af70859a969/ReText/tab.py#L443-L458
221,973
retext-project/retext
ReText/mdx_posmap.py
PosMapExtension.extendMarkdown
def extendMarkdown(self, md): """ Insert the PosMapExtension blockprocessor before any other extensions to make sure our own markers, inserted by the preprocessor, are removed before any other extensions get confused by them. """ md.preprocessors.register(PosM...
python
def extendMarkdown(self, md): """ Insert the PosMapExtension blockprocessor before any other extensions to make sure our own markers, inserted by the preprocessor, are removed before any other extensions get confused by them. """ md.preprocessors.register(PosM...
[ "def", "extendMarkdown", "(", "self", ",", "md", ")", ":", "md", ".", "preprocessors", ".", "register", "(", "PosMapMarkPreprocessor", "(", "md", ")", ",", "'posmap_mark'", ",", "50", ")", "md", ".", "preprocessors", ".", "register", "(", "PosMapCleanPreproc...
Insert the PosMapExtension blockprocessor before any other extensions to make sure our own markers, inserted by the preprocessor, are removed before any other extensions get confused by them.
[ "Insert", "the", "PosMapExtension", "blockprocessor", "before", "any", "other", "extensions", "to", "make", "sure", "our", "own", "markers", "inserted", "by", "the", "preprocessor", "are", "removed", "before", "any", "other", "extensions", "get", "confused", "by",...
ad70435341dd89c7a74742df9d1f9af70859a969
https://github.com/retext-project/retext/blob/ad70435341dd89c7a74742df9d1f9af70859a969/ReText/mdx_posmap.py#L39-L65
221,974
retext-project/retext
ReText/window.py
ReTextWindow.tabFileNameChanged
def tabFileNameChanged(self, tab): ''' Perform all UI state changes that need to be done when the filename of the current tab has changed. ''' if tab == self.currentTab: if tab.fileName: self.setWindowTitle("") if globalSettings.windowTitleFullPath: self.setWindowTitle(tab.fileName + '[*]') ...
python
def tabFileNameChanged(self, tab): ''' Perform all UI state changes that need to be done when the filename of the current tab has changed. ''' if tab == self.currentTab: if tab.fileName: self.setWindowTitle("") if globalSettings.windowTitleFullPath: self.setWindowTitle(tab.fileName + '[*]') ...
[ "def", "tabFileNameChanged", "(", "self", ",", "tab", ")", ":", "if", "tab", "==", "self", ".", "currentTab", ":", "if", "tab", ".", "fileName", ":", "self", ".", "setWindowTitle", "(", "\"\"", ")", "if", "globalSettings", ".", "windowTitleFullPath", ":", ...
Perform all UI state changes that need to be done when the filename of the current tab has changed.
[ "Perform", "all", "UI", "state", "changes", "that", "need", "to", "be", "done", "when", "the", "filename", "of", "the", "current", "tab", "has", "changed", "." ]
ad70435341dd89c7a74742df9d1f9af70859a969
https://github.com/retext-project/retext/blob/ad70435341dd89c7a74742df9d1f9af70859a969/ReText/window.py#L462-L482
221,975
retext-project/retext
ReText/window.py
ReTextWindow.tabActiveMarkupChanged
def tabActiveMarkupChanged(self, tab): ''' Perform all UI state changes that need to be done when the active markup class of the current tab has changed. ''' if tab == self.currentTab: markupClass = tab.getActiveMarkupClass() dtMarkdown = (markupClass == markups.MarkdownMarkup) dtMkdOrReST = dtMarkdo...
python
def tabActiveMarkupChanged(self, tab): ''' Perform all UI state changes that need to be done when the active markup class of the current tab has changed. ''' if tab == self.currentTab: markupClass = tab.getActiveMarkupClass() dtMarkdown = (markupClass == markups.MarkdownMarkup) dtMkdOrReST = dtMarkdo...
[ "def", "tabActiveMarkupChanged", "(", "self", ",", "tab", ")", ":", "if", "tab", "==", "self", ".", "currentTab", ":", "markupClass", "=", "tab", ".", "getActiveMarkupClass", "(", ")", "dtMarkdown", "=", "(", "markupClass", "==", "markups", ".", "MarkdownMar...
Perform all UI state changes that need to be done when the active markup class of the current tab has changed.
[ "Perform", "all", "UI", "state", "changes", "that", "need", "to", "be", "done", "when", "the", "active", "markup", "class", "of", "the", "current", "tab", "has", "changed", "." ]
ad70435341dd89c7a74742df9d1f9af70859a969
https://github.com/retext-project/retext/blob/ad70435341dd89c7a74742df9d1f9af70859a969/ReText/window.py#L484-L497
221,976
retext-project/retext
ReText/window.py
ReTextWindow.tabModificationStateChanged
def tabModificationStateChanged(self, tab): ''' Perform all UI state changes that need to be done when the modification state of the current tab has changed. ''' if tab == self.currentTab: changed = tab.editBox.document().isModified() if self.autoSaveActive(tab): changed = False self.actionSave.s...
python
def tabModificationStateChanged(self, tab): ''' Perform all UI state changes that need to be done when the modification state of the current tab has changed. ''' if tab == self.currentTab: changed = tab.editBox.document().isModified() if self.autoSaveActive(tab): changed = False self.actionSave.s...
[ "def", "tabModificationStateChanged", "(", "self", ",", "tab", ")", ":", "if", "tab", "==", "self", ".", "currentTab", ":", "changed", "=", "tab", ".", "editBox", ".", "document", "(", ")", ".", "isModified", "(", ")", "if", "self", ".", "autoSaveActive"...
Perform all UI state changes that need to be done when the modification state of the current tab has changed.
[ "Perform", "all", "UI", "state", "changes", "that", "need", "to", "be", "done", "when", "the", "modification", "state", "of", "the", "current", "tab", "has", "changed", "." ]
ad70435341dd89c7a74742df9d1f9af70859a969
https://github.com/retext-project/retext/blob/ad70435341dd89c7a74742df9d1f9af70859a969/ReText/window.py#L499-L509
221,977
retext-project/retext
ReText/window.py
ReTextWindow.getPageSizeByName
def getPageSizeByName(self, pageSizeName): """ Returns a validated PageSize instance corresponding to the given name. Returns None if the name is not a valid PageSize. """ pageSize = None lowerCaseNames = {pageSize.lower(): pageSize for pageSize in self.availablePageSizes()} if pageSize...
python
def getPageSizeByName(self, pageSizeName): """ Returns a validated PageSize instance corresponding to the given name. Returns None if the name is not a valid PageSize. """ pageSize = None lowerCaseNames = {pageSize.lower(): pageSize for pageSize in self.availablePageSizes()} if pageSize...
[ "def", "getPageSizeByName", "(", "self", ",", "pageSizeName", ")", ":", "pageSize", "=", "None", "lowerCaseNames", "=", "{", "pageSize", ".", "lower", "(", ")", ":", "pageSize", "for", "pageSize", "in", "self", ".", "availablePageSizes", "(", ")", "}", "if...
Returns a validated PageSize instance corresponding to the given name. Returns None if the name is not a valid PageSize.
[ "Returns", "a", "validated", "PageSize", "instance", "corresponding", "to", "the", "given", "name", ".", "Returns", "None", "if", "the", "name", "is", "not", "a", "valid", "PageSize", "." ]
ad70435341dd89c7a74742df9d1f9af70859a969
https://github.com/retext-project/retext/blob/ad70435341dd89c7a74742df9d1f9af70859a969/ReText/window.py#L995-L1006
221,978
retext-project/retext
ReText/window.py
ReTextWindow.availablePageSizes
def availablePageSizes(self): """ List available page sizes. """ sizes = [x for x in dir(QPagedPaintDevice) if type(getattr(QPagedPaintDevice, x)) == QPagedPaintDevice.PageSize] return sizes
python
def availablePageSizes(self): """ List available page sizes. """ sizes = [x for x in dir(QPagedPaintDevice) if type(getattr(QPagedPaintDevice, x)) == QPagedPaintDevice.PageSize] return sizes
[ "def", "availablePageSizes", "(", "self", ")", ":", "sizes", "=", "[", "x", "for", "x", "in", "dir", "(", "QPagedPaintDevice", ")", "if", "type", "(", "getattr", "(", "QPagedPaintDevice", ",", "x", ")", ")", "==", "QPagedPaintDevice", ".", "PageSize", "]...
List available page sizes.
[ "List", "available", "page", "sizes", "." ]
ad70435341dd89c7a74742df9d1f9af70859a969
https://github.com/retext-project/retext/blob/ad70435341dd89c7a74742df9d1f9af70859a969/ReText/window.py#L1008-L1013
221,979
scikit-tda/kepler-mapper
kmapper/kmapper.py
KeplerMapper.data_from_cluster_id
def data_from_cluster_id(self, cluster_id, graph, data): """Returns the original data of each cluster member for a given cluster ID Parameters ---------- cluster_id : String ID of the cluster. graph : dict The resulting dictionary after applying map() ...
python
def data_from_cluster_id(self, cluster_id, graph, data): """Returns the original data of each cluster member for a given cluster ID Parameters ---------- cluster_id : String ID of the cluster. graph : dict The resulting dictionary after applying map() ...
[ "def", "data_from_cluster_id", "(", "self", ",", "cluster_id", ",", "graph", ",", "data", ")", ":", "if", "cluster_id", "in", "graph", "[", "\"nodes\"", "]", ":", "cluster_members", "=", "graph", "[", "\"nodes\"", "]", "[", "cluster_id", "]", "cluster_member...
Returns the original data of each cluster member for a given cluster ID Parameters ---------- cluster_id : String ID of the cluster. graph : dict The resulting dictionary after applying map() data : Numpy Array Original dataset. Accepts both 1...
[ "Returns", "the", "original", "data", "of", "each", "cluster", "member", "for", "a", "given", "cluster", "ID" ]
d4ed39f6392b0a134dd573d7d9c4aa65fbef3a7d
https://github.com/scikit-tda/kepler-mapper/blob/d4ed39f6392b0a134dd573d7d9c4aa65fbef3a7d/kmapper/kmapper.py#L807-L830
221,980
scikit-tda/kepler-mapper
kmapper/visuals.py
_colors_to_rgb
def _colors_to_rgb(colorscale): """ Ensure that the color scale is formatted in rgb strings. If the colorscale is a hex string, then convert to rgb. """ if colorscale[0][1][0] == "#": plotly_colors = np.array(colorscale)[:, 1].tolist() for k, hexcode in enumerate(plotly_colors): ...
python
def _colors_to_rgb(colorscale): """ Ensure that the color scale is formatted in rgb strings. If the colorscale is a hex string, then convert to rgb. """ if colorscale[0][1][0] == "#": plotly_colors = np.array(colorscale)[:, 1].tolist() for k, hexcode in enumerate(plotly_colors): ...
[ "def", "_colors_to_rgb", "(", "colorscale", ")", ":", "if", "colorscale", "[", "0", "]", "[", "1", "]", "[", "0", "]", "==", "\"#\"", ":", "plotly_colors", "=", "np", ".", "array", "(", "colorscale", ")", "[", ":", ",", "1", "]", ".", "tolist", "...
Ensure that the color scale is formatted in rgb strings. If the colorscale is a hex string, then convert to rgb.
[ "Ensure", "that", "the", "color", "scale", "is", "formatted", "in", "rgb", "strings", ".", "If", "the", "colorscale", "is", "a", "hex", "string", "then", "convert", "to", "rgb", "." ]
d4ed39f6392b0a134dd573d7d9c4aa65fbef3a7d
https://github.com/scikit-tda/kepler-mapper/blob/d4ed39f6392b0a134dd573d7d9c4aa65fbef3a7d/kmapper/visuals.py#L60-L74
221,981
scikit-tda/kepler-mapper
kmapper/visuals.py
build_histogram
def build_histogram(data, colorscale=None, nbins=10): """ Build histogram of data based on values of color_function """ if colorscale is None: colorscale = colorscale_default # TODO: we should weave this method of handling colors into the normal build_histogram and combine both functions c...
python
def build_histogram(data, colorscale=None, nbins=10): """ Build histogram of data based on values of color_function """ if colorscale is None: colorscale = colorscale_default # TODO: we should weave this method of handling colors into the normal build_histogram and combine both functions c...
[ "def", "build_histogram", "(", "data", ",", "colorscale", "=", "None", ",", "nbins", "=", "10", ")", ":", "if", "colorscale", "is", "None", ":", "colorscale", "=", "colorscale_default", "# TODO: we should weave this method of handling colors into the normal build_histogra...
Build histogram of data based on values of color_function
[ "Build", "histogram", "of", "data", "based", "on", "values", "of", "color_function" ]
d4ed39f6392b0a134dd573d7d9c4aa65fbef3a7d
https://github.com/scikit-tda/kepler-mapper/blob/d4ed39f6392b0a134dd573d7d9c4aa65fbef3a7d/kmapper/visuals.py#L212-L236
221,982
scikit-tda/kepler-mapper
kmapper/drawing.py
draw_matplotlib
def draw_matplotlib(g, ax=None, fig=None): """Draw the graph using NetworkX drawing functionality. Parameters ------------ g: graph object returned by ``map`` The Mapper graph as constructed by ``KeplerMapper.map`` ax: matplotlib Axes object A matplotlib axes object to plot graph ...
python
def draw_matplotlib(g, ax=None, fig=None): """Draw the graph using NetworkX drawing functionality. Parameters ------------ g: graph object returned by ``map`` The Mapper graph as constructed by ``KeplerMapper.map`` ax: matplotlib Axes object A matplotlib axes object to plot graph ...
[ "def", "draw_matplotlib", "(", "g", ",", "ax", "=", "None", ",", "fig", "=", "None", ")", ":", "import", "networkx", "as", "nx", "import", "matplotlib", ".", "pyplot", "as", "plt", "fig", "=", "fig", "if", "fig", "else", "plt", ".", "figure", "(", ...
Draw the graph using NetworkX drawing functionality. Parameters ------------ g: graph object returned by ``map`` The Mapper graph as constructed by ``KeplerMapper.map`` ax: matplotlib Axes object A matplotlib axes object to plot graph on. If none, then use ``plt.gca()`` fig: ...
[ "Draw", "the", "graph", "using", "NetworkX", "drawing", "functionality", "." ]
d4ed39f6392b0a134dd573d7d9c4aa65fbef3a7d
https://github.com/scikit-tda/kepler-mapper/blob/d4ed39f6392b0a134dd573d7d9c4aa65fbef3a7d/kmapper/drawing.py#L11-L65
221,983
scikit-tda/kepler-mapper
kmapper/plotlyviz.py
get_kmgraph_meta
def get_kmgraph_meta(mapper_summary): """ Extract info from mapper summary to be displayed below the graph plot """ d = mapper_summary["custom_meta"] meta = ( "<b>N_cubes:</b> " + str(d["n_cubes"]) + " <b>Perc_overlap:</b> " + str(d["perc_overlap"]) ) me...
python
def get_kmgraph_meta(mapper_summary): """ Extract info from mapper summary to be displayed below the graph plot """ d = mapper_summary["custom_meta"] meta = ( "<b>N_cubes:</b> " + str(d["n_cubes"]) + " <b>Perc_overlap:</b> " + str(d["perc_overlap"]) ) me...
[ "def", "get_kmgraph_meta", "(", "mapper_summary", ")", ":", "d", "=", "mapper_summary", "[", "\"custom_meta\"", "]", "meta", "=", "(", "\"<b>N_cubes:</b> \"", "+", "str", "(", "d", "[", "\"n_cubes\"", "]", ")", "+", "\" <b>Perc_overlap:</b> \"", "+", "str", "(...
Extract info from mapper summary to be displayed below the graph plot
[ "Extract", "info", "from", "mapper", "summary", "to", "be", "displayed", "below", "the", "graph", "plot" ]
d4ed39f6392b0a134dd573d7d9c4aa65fbef3a7d
https://github.com/scikit-tda/kepler-mapper/blob/d4ed39f6392b0a134dd573d7d9c4aa65fbef3a7d/kmapper/plotlyviz.py#L403-L424
221,984
scikit-tda/kepler-mapper
kmapper/plotlyviz.py
summary_fig
def summary_fig( mapper_summary, width=600, height=500, top=60, left=20, bottom=60, right=20, bgcolor="rgb(240,240,240)", ): """Define a dummy figure that displays info on the algorithms and sklearn class instances or methods used Returns a FigureWidget ob...
python
def summary_fig( mapper_summary, width=600, height=500, top=60, left=20, bottom=60, right=20, bgcolor="rgb(240,240,240)", ): """Define a dummy figure that displays info on the algorithms and sklearn class instances or methods used Returns a FigureWidget ob...
[ "def", "summary_fig", "(", "mapper_summary", ",", "width", "=", "600", ",", "height", "=", "500", ",", "top", "=", "60", ",", "left", "=", "20", ",", "bottom", "=", "60", ",", "right", "=", "20", ",", "bgcolor", "=", "\"rgb(240,240,240)\"", ",", ")",...
Define a dummy figure that displays info on the algorithms and sklearn class instances or methods used Returns a FigureWidget object representing the figure
[ "Define", "a", "dummy", "figure", "that", "displays", "info", "on", "the", "algorithms", "and", "sklearn", "class", "instances", "or", "methods", "used", "Returns", "a", "FigureWidget", "object", "representing", "the", "figure" ]
d4ed39f6392b0a134dd573d7d9c4aa65fbef3a7d
https://github.com/scikit-tda/kepler-mapper/blob/d4ed39f6392b0a134dd573d7d9c4aa65fbef3a7d/kmapper/plotlyviz.py#L543-L583
221,985
scikit-tda/kepler-mapper
kmapper/nerve.py
GraphNerve.compute
def compute(self, nodes): """Helper function to find edges of the overlapping clusters. Parameters ---------- nodes: A dictionary with entires `{node id}:{list of ids in node}` Returns ------- edges: A 1-skeleton of the nerve (intersectin...
python
def compute(self, nodes): """Helper function to find edges of the overlapping clusters. Parameters ---------- nodes: A dictionary with entires `{node id}:{list of ids in node}` Returns ------- edges: A 1-skeleton of the nerve (intersectin...
[ "def", "compute", "(", "self", ",", "nodes", ")", ":", "result", "=", "defaultdict", "(", "list", ")", "# Create links when clusters from different hypercubes have members with the same sample id.", "candidates", "=", "itertools", ".", "combinations", "(", "nodes", ".", ...
Helper function to find edges of the overlapping clusters. Parameters ---------- nodes: A dictionary with entires `{node id}:{list of ids in node}` Returns ------- edges: A 1-skeleton of the nerve (intersecting nodes) simplicies: ...
[ "Helper", "function", "to", "find", "edges", "of", "the", "overlapping", "clusters", "." ]
d4ed39f6392b0a134dd573d7d9c4aa65fbef3a7d
https://github.com/scikit-tda/kepler-mapper/blob/d4ed39f6392b0a134dd573d7d9c4aa65fbef3a7d/kmapper/nerve.py#L35-L67
221,986
scikit-tda/kepler-mapper
kmapper/cover.py
Cover.fit
def fit(self, data): """ Fit a cover on the data. This method constructs centers and radii in each dimension given the `perc_overlap` and `n_cube`. Parameters ============ data: array-like Data to apply the cover to. Warning: First column must be an index column. R...
python
def fit(self, data): """ Fit a cover on the data. This method constructs centers and radii in each dimension given the `perc_overlap` and `n_cube`. Parameters ============ data: array-like Data to apply the cover to. Warning: First column must be an index column. R...
[ "def", "fit", "(", "self", ",", "data", ")", ":", "# TODO: support indexing into any columns", "di", "=", "np", ".", "array", "(", "range", "(", "1", ",", "data", ".", "shape", "[", "1", "]", ")", ")", "indexless_data", "=", "data", "[", ":", ",", "d...
Fit a cover on the data. This method constructs centers and radii in each dimension given the `perc_overlap` and `n_cube`. Parameters ============ data: array-like Data to apply the cover to. Warning: First column must be an index column. Returns ======== ...
[ "Fit", "a", "cover", "on", "the", "data", ".", "This", "method", "constructs", "centers", "and", "radii", "in", "each", "dimension", "given", "the", "perc_overlap", "and", "n_cube", "." ]
d4ed39f6392b0a134dd573d7d9c4aa65fbef3a7d
https://github.com/scikit-tda/kepler-mapper/blob/d4ed39f6392b0a134dd573d7d9c4aa65fbef3a7d/kmapper/cover.py#L135-L214
221,987
scikit-tda/kepler-mapper
kmapper/cover.py
Cover.transform_single
def transform_single(self, data, center, i=0): """ Compute entries of `data` in hypercube centered at `center` Parameters =========== data: array-like Data to find in entries in cube. Warning: first column must be index column. center: array-like Center ...
python
def transform_single(self, data, center, i=0): """ Compute entries of `data` in hypercube centered at `center` Parameters =========== data: array-like Data to find in entries in cube. Warning: first column must be index column. center: array-like Center ...
[ "def", "transform_single", "(", "self", ",", "data", ",", "center", ",", "i", "=", "0", ")", ":", "lowerbounds", ",", "upperbounds", "=", "center", "-", "self", ".", "radius_", ",", "center", "+", "self", ".", "radius_", "# Slice the hypercube", "entries",...
Compute entries of `data` in hypercube centered at `center` Parameters =========== data: array-like Data to find in entries in cube. Warning: first column must be index column. center: array-like Center points for the cube. Cube is found as all data in `[center-...
[ "Compute", "entries", "of", "data", "in", "hypercube", "centered", "at", "center" ]
d4ed39f6392b0a134dd573d7d9c4aa65fbef3a7d
https://github.com/scikit-tda/kepler-mapper/blob/d4ed39f6392b0a134dd573d7d9c4aa65fbef3a7d/kmapper/cover.py#L216-L244
221,988
scikit-tda/kepler-mapper
kmapper/cover.py
Cover.transform
def transform(self, data, centers=None): """ Find entries of all hypercubes. If `centers=None`, then use `self.centers_` as computed in `self.fit`. Empty hypercubes are removed from the result Parameters =========== data: array-like Data to find in ...
python
def transform(self, data, centers=None): """ Find entries of all hypercubes. If `centers=None`, then use `self.centers_` as computed in `self.fit`. Empty hypercubes are removed from the result Parameters =========== data: array-like Data to find in ...
[ "def", "transform", "(", "self", ",", "data", ",", "centers", "=", "None", ")", ":", "centers", "=", "centers", "or", "self", ".", "centers_", "hypercubes", "=", "[", "self", ".", "transform_single", "(", "data", ",", "cube", ",", "i", ")", "for", "i...
Find entries of all hypercubes. If `centers=None`, then use `self.centers_` as computed in `self.fit`. Empty hypercubes are removed from the result Parameters =========== data: array-like Data to find in entries in cube. Warning: first column must be index ...
[ "Find", "entries", "of", "all", "hypercubes", ".", "If", "centers", "=", "None", "then", "use", "self", ".", "centers_", "as", "computed", "in", "self", ".", "fit", ".", "Empty", "hypercubes", "are", "removed", "from", "the", "result" ]
d4ed39f6392b0a134dd573d7d9c4aa65fbef3a7d
https://github.com/scikit-tda/kepler-mapper/blob/d4ed39f6392b0a134dd573d7d9c4aa65fbef3a7d/kmapper/cover.py#L246-L273
221,989
scikit-tda/kepler-mapper
kmapper/adapter.py
to_networkx
def to_networkx(graph): """ Convert a Mapper 1-complex to a networkx graph. Parameters ----------- graph: dictionary, graph object returned from `kmapper.map` Returns -------- g: graph as networkx.Graph() object """ # import here so networkx is not always required. import n...
python
def to_networkx(graph): """ Convert a Mapper 1-complex to a networkx graph. Parameters ----------- graph: dictionary, graph object returned from `kmapper.map` Returns -------- g: graph as networkx.Graph() object """ # import here so networkx is not always required. import n...
[ "def", "to_networkx", "(", "graph", ")", ":", "# import here so networkx is not always required.", "import", "networkx", "as", "nx", "nodes", "=", "graph", "[", "\"nodes\"", "]", ".", "keys", "(", ")", "edges", "=", "[", "[", "start", ",", "end", "]", "for",...
Convert a Mapper 1-complex to a networkx graph. Parameters ----------- graph: dictionary, graph object returned from `kmapper.map` Returns -------- g: graph as networkx.Graph() object
[ "Convert", "a", "Mapper", "1", "-", "complex", "to", "a", "networkx", "graph", "." ]
d4ed39f6392b0a134dd573d7d9c4aa65fbef3a7d
https://github.com/scikit-tda/kepler-mapper/blob/d4ed39f6392b0a134dd573d7d9c4aa65fbef3a7d/kmapper/adapter.py#L8-L35
221,990
PyThaiNLP/pythainlp
pythainlp/corpus/__init__.py
get_corpus
def get_corpus(filename: str) -> frozenset: """ Read corpus from file and return a frozenset :param string filename: file corpus """ lines = [] with open(os.path.join(corpus_path(), filename), "r", encoding="utf-8-sig") as fh: lines = fh.read().splitlines() return frozenset(lines)
python
def get_corpus(filename: str) -> frozenset: """ Read corpus from file and return a frozenset :param string filename: file corpus """ lines = [] with open(os.path.join(corpus_path(), filename), "r", encoding="utf-8-sig") as fh: lines = fh.read().splitlines() return frozenset(lines)
[ "def", "get_corpus", "(", "filename", ":", "str", ")", "->", "frozenset", ":", "lines", "=", "[", "]", "with", "open", "(", "os", ".", "path", ".", "join", "(", "corpus_path", "(", ")", ",", "filename", ")", ",", "\"r\"", ",", "encoding", "=", "\"u...
Read corpus from file and return a frozenset :param string filename: file corpus
[ "Read", "corpus", "from", "file", "and", "return", "a", "frozenset" ]
e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca
https://github.com/PyThaiNLP/pythainlp/blob/e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca/pythainlp/corpus/__init__.py#L41-L51
221,991
PyThaiNLP/pythainlp
pythainlp/corpus/__init__.py
get_corpus_path
def get_corpus_path(name: str) -> [str, None]: """ Get corpus path :param string name: corpus name """ db = TinyDB(corpus_db_path()) temp = Query() if len(db.search(temp.name == name)) > 0: path = get_full_data_path(db.search(temp.name == name)[0]["file"]) db.close() ...
python
def get_corpus_path(name: str) -> [str, None]: """ Get corpus path :param string name: corpus name """ db = TinyDB(corpus_db_path()) temp = Query() if len(db.search(temp.name == name)) > 0: path = get_full_data_path(db.search(temp.name == name)[0]["file"]) db.close() ...
[ "def", "get_corpus_path", "(", "name", ":", "str", ")", "->", "[", "str", ",", "None", "]", ":", "db", "=", "TinyDB", "(", "corpus_db_path", "(", ")", ")", "temp", "=", "Query", "(", ")", "if", "len", "(", "db", ".", "search", "(", "temp", ".", ...
Get corpus path :param string name: corpus name
[ "Get", "corpus", "path" ]
e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca
https://github.com/PyThaiNLP/pythainlp/blob/e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca/pythainlp/corpus/__init__.py#L54-L72
221,992
PyThaiNLP/pythainlp
pythainlp/summarize/__init__.py
summarize
def summarize( text: str, n: int, engine: str = "frequency", tokenizer: str = "newmm" ) -> List[str]: """ Thai text summarization :param str text: text to be summarized :param int n: number of sentences to be included in the summary :param str engine: text summarization engine :param str to...
python
def summarize( text: str, n: int, engine: str = "frequency", tokenizer: str = "newmm" ) -> List[str]: """ Thai text summarization :param str text: text to be summarized :param int n: number of sentences to be included in the summary :param str engine: text summarization engine :param str to...
[ "def", "summarize", "(", "text", ":", "str", ",", "n", ":", "int", ",", "engine", ":", "str", "=", "\"frequency\"", ",", "tokenizer", ":", "str", "=", "\"newmm\"", ")", "->", "List", "[", "str", "]", ":", "sents", "=", "[", "]", "if", "engine", "...
Thai text summarization :param str text: text to be summarized :param int n: number of sentences to be included in the summary :param str engine: text summarization engine :param str tokenizer: word tokenizer :return List[str] summary: list of selected sentences
[ "Thai", "text", "summarization" ]
e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca
https://github.com/PyThaiNLP/pythainlp/blob/e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca/pythainlp/summarize/__init__.py#L13-L32
221,993
PyThaiNLP/pythainlp
pythainlp/corpus/conceptnet.py
edges
def edges(word: str, lang: str = "th"): """ Get edges from ConceptNet API :param str word: word :param str lang: language """ obj = requests.get(f"http://api.conceptnet.io/c/{lang}/{word}").json() return obj["edges"]
python
def edges(word: str, lang: str = "th"): """ Get edges from ConceptNet API :param str word: word :param str lang: language """ obj = requests.get(f"http://api.conceptnet.io/c/{lang}/{word}").json() return obj["edges"]
[ "def", "edges", "(", "word", ":", "str", ",", "lang", ":", "str", "=", "\"th\"", ")", ":", "obj", "=", "requests", ".", "get", "(", "f\"http://api.conceptnet.io/c/{lang}/{word}\"", ")", ".", "json", "(", ")", "return", "obj", "[", "\"edges\"", "]" ]
Get edges from ConceptNet API :param str word: word :param str lang: language
[ "Get", "edges", "from", "ConceptNet", "API" ]
e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca
https://github.com/PyThaiNLP/pythainlp/blob/e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca/pythainlp/corpus/conceptnet.py#L8-L17
221,994
PyThaiNLP/pythainlp
pythainlp/util/wordtonum.py
thaiword_to_num
def thaiword_to_num(word: str) -> int: """ Converts a Thai number spellout word to actual number value :param str word: a Thai number spellout :return: number """ if not word: return None tokens = [] if isinstance(word, str): tokens = _TOKENIZER.word_tokenize(word) ...
python
def thaiword_to_num(word: str) -> int: """ Converts a Thai number spellout word to actual number value :param str word: a Thai number spellout :return: number """ if not word: return None tokens = [] if isinstance(word, str): tokens = _TOKENIZER.word_tokenize(word) ...
[ "def", "thaiword_to_num", "(", "word", ":", "str", ")", "->", "int", ":", "if", "not", "word", ":", "return", "None", "tokens", "=", "[", "]", "if", "isinstance", "(", "word", ",", "str", ")", ":", "tokens", "=", "_TOKENIZER", ".", "word_tokenize", "...
Converts a Thai number spellout word to actual number value :param str word: a Thai number spellout :return: number
[ "Converts", "a", "Thai", "number", "spellout", "word", "to", "actual", "number", "value" ]
e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca
https://github.com/PyThaiNLP/pythainlp/blob/e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca/pythainlp/util/wordtonum.py#L69-L97
221,995
PyThaiNLP/pythainlp
pythainlp/tag/__init__.py
pos_tag
def pos_tag( words: List[str], engine: str = "perceptron", corpus: str = "orchid" ) -> List[Tuple[str, str]]: """ Part of Speech tagging function. :param list words: a list of tokenized words :param str engine: * unigram - unigram tagger * perceptron - perceptron tagger (default) ...
python
def pos_tag( words: List[str], engine: str = "perceptron", corpus: str = "orchid" ) -> List[Tuple[str, str]]: """ Part of Speech tagging function. :param list words: a list of tokenized words :param str engine: * unigram - unigram tagger * perceptron - perceptron tagger (default) ...
[ "def", "pos_tag", "(", "words", ":", "List", "[", "str", "]", ",", "engine", ":", "str", "=", "\"perceptron\"", ",", "corpus", ":", "str", "=", "\"orchid\"", ")", "->", "List", "[", "Tuple", "[", "str", ",", "str", "]", "]", ":", "_corpus", "=", ...
Part of Speech tagging function. :param list words: a list of tokenized words :param str engine: * unigram - unigram tagger * perceptron - perceptron tagger (default) * artagger - RDR POS tagger :param str corpus: * orchid - annotated Thai academic articles (default) ...
[ "Part", "of", "Speech", "tagging", "function", "." ]
e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca
https://github.com/PyThaiNLP/pythainlp/blob/e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca/pythainlp/tag/__init__.py#L122-L157
221,996
PyThaiNLP/pythainlp
pythainlp/tag/__init__.py
pos_tag_sents
def pos_tag_sents( sentences: List[List[str]], engine: str = "perceptron", corpus: str = "orchid" ) -> List[List[Tuple[str, str]]]: """ Part of Speech tagging Sentence function. :param list sentences: a list of lists of tokenized words :param str engine: * unigram - unigram tagger *...
python
def pos_tag_sents( sentences: List[List[str]], engine: str = "perceptron", corpus: str = "orchid" ) -> List[List[Tuple[str, str]]]: """ Part of Speech tagging Sentence function. :param list sentences: a list of lists of tokenized words :param str engine: * unigram - unigram tagger *...
[ "def", "pos_tag_sents", "(", "sentences", ":", "List", "[", "List", "[", "str", "]", "]", ",", "engine", ":", "str", "=", "\"perceptron\"", ",", "corpus", ":", "str", "=", "\"orchid\"", ")", "->", "List", "[", "List", "[", "Tuple", "[", "str", ",", ...
Part of Speech tagging Sentence function. :param list sentences: a list of lists of tokenized words :param str engine: * unigram - unigram tagger * perceptron - perceptron tagger (default) * artagger - RDR POS tagger :param str corpus: * orchid - annotated Thai academic arti...
[ "Part", "of", "Speech", "tagging", "Sentence", "function", "." ]
e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca
https://github.com/PyThaiNLP/pythainlp/blob/e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca/pythainlp/tag/__init__.py#L160-L180
221,997
PyThaiNLP/pythainlp
pythainlp/spell/pn.py
_keep
def _keep( word_freq: int, min_freq: int, min_len: int, max_len: int, dict_filter: Callable[[str], bool], ): """ Keep only Thai words with at least min_freq frequency and has length between min_len and max_len characters """ if not word_freq or word_freq[1] < min_freq: re...
python
def _keep( word_freq: int, min_freq: int, min_len: int, max_len: int, dict_filter: Callable[[str], bool], ): """ Keep only Thai words with at least min_freq frequency and has length between min_len and max_len characters """ if not word_freq or word_freq[1] < min_freq: re...
[ "def", "_keep", "(", "word_freq", ":", "int", ",", "min_freq", ":", "int", ",", "min_len", ":", "int", ",", "max_len", ":", "int", ",", "dict_filter", ":", "Callable", "[", "[", "str", "]", ",", "bool", "]", ",", ")", ":", "if", "not", "word_freq",...
Keep only Thai words with at least min_freq frequency and has length between min_len and max_len characters
[ "Keep", "only", "Thai", "words", "with", "at", "least", "min_freq", "frequency", "and", "has", "length", "between", "min_len", "and", "max_len", "characters" ]
e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca
https://github.com/PyThaiNLP/pythainlp/blob/e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca/pythainlp/spell/pn.py#L31-L49
221,998
PyThaiNLP/pythainlp
pythainlp/spell/pn.py
_edits1
def _edits1(word: str) -> Set[str]: """ Return a set of words with edit distance of 1 from the input word """ splits = [(word[:i], word[i:]) for i in range(len(word) + 1)] deletes = [L + R[1:] for L, R in splits if R] transposes = [L + R[1] + R[0] + R[2:] for L, R in splits if len(R) > 1] re...
python
def _edits1(word: str) -> Set[str]: """ Return a set of words with edit distance of 1 from the input word """ splits = [(word[:i], word[i:]) for i in range(len(word) + 1)] deletes = [L + R[1:] for L, R in splits if R] transposes = [L + R[1] + R[0] + R[2:] for L, R in splits if len(R) > 1] re...
[ "def", "_edits1", "(", "word", ":", "str", ")", "->", "Set", "[", "str", "]", ":", "splits", "=", "[", "(", "word", "[", ":", "i", "]", ",", "word", "[", "i", ":", "]", ")", "for", "i", "in", "range", "(", "len", "(", "word", ")", "+", "1...
Return a set of words with edit distance of 1 from the input word
[ "Return", "a", "set", "of", "words", "with", "edit", "distance", "of", "1", "from", "the", "input", "word" ]
e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca
https://github.com/PyThaiNLP/pythainlp/blob/e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca/pythainlp/spell/pn.py#L52-L62
221,999
PyThaiNLP/pythainlp
pythainlp/spell/pn.py
_edits2
def _edits2(word: str) -> Set[str]: """ Return a set of words with edit distance of 2 from the input word """ return set(e2 for e1 in _edits1(word) for e2 in _edits1(e1))
python
def _edits2(word: str) -> Set[str]: """ Return a set of words with edit distance of 2 from the input word """ return set(e2 for e1 in _edits1(word) for e2 in _edits1(e1))
[ "def", "_edits2", "(", "word", ":", "str", ")", "->", "Set", "[", "str", "]", ":", "return", "set", "(", "e2", "for", "e1", "in", "_edits1", "(", "word", ")", "for", "e2", "in", "_edits1", "(", "e1", ")", ")" ]
Return a set of words with edit distance of 2 from the input word
[ "Return", "a", "set", "of", "words", "with", "edit", "distance", "of", "2", "from", "the", "input", "word" ]
e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca
https://github.com/PyThaiNLP/pythainlp/blob/e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca/pythainlp/spell/pn.py#L65-L69