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
partition
stringclasses
1 value
SheffieldML/GPyOpt
GPyOpt/acquisitions/EI.py
AcquisitionEI._compute_acq
def _compute_acq(self, x): """ Computes the Expected Improvement per unit of cost """ m, s = self.model.predict(x) fmin = self.model.get_fmin() phi, Phi, u = get_quantiles(self.jitter, fmin, m, s) f_acqu = s * (u * Phi + phi) return f_acqu
python
def _compute_acq(self, x): """ Computes the Expected Improvement per unit of cost """ m, s = self.model.predict(x) fmin = self.model.get_fmin() phi, Phi, u = get_quantiles(self.jitter, fmin, m, s) f_acqu = s * (u * Phi + phi) return f_acqu
[ "def", "_compute_acq", "(", "self", ",", "x", ")", ":", "m", ",", "s", "=", "self", ".", "model", ".", "predict", "(", "x", ")", "fmin", "=", "self", ".", "model", ".", "get_fmin", "(", ")", "phi", ",", "Phi", ",", "u", "=", "get_quantiles", "(...
Computes the Expected Improvement per unit of cost
[ "Computes", "the", "Expected", "Improvement", "per", "unit", "of", "cost" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/EI.py#L32-L40
train
SheffieldML/GPyOpt
GPyOpt/interface/config_parser.py
update_config
def update_config(config_new, config_default): ''' Updates the loaded method configuration with default values. ''' if any([isinstance(v, dict) for v in list(config_new.values())]): for k,v in list(config_new.items()): if isinstance(v,dict) and k in config_default: u...
python
def update_config(config_new, config_default): ''' Updates the loaded method configuration with default values. ''' if any([isinstance(v, dict) for v in list(config_new.values())]): for k,v in list(config_new.items()): if isinstance(v,dict) and k in config_default: u...
[ "def", "update_config", "(", "config_new", ",", "config_default", ")", ":", "if", "any", "(", "[", "isinstance", "(", "v", ",", "dict", ")", "for", "v", "in", "list", "(", "config_new", ".", "values", "(", ")", ")", "]", ")", ":", "for", "k", ",", ...
Updates the loaded method configuration with default values.
[ "Updates", "the", "loaded", "method", "configuration", "with", "default", "values", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/interface/config_parser.py#L62-L75
train
SheffieldML/GPyOpt
GPyOpt/interface/config_parser.py
parser
def parser(input_file_path='config.json'): ''' Parser for the .json file containing the configuration of the method. ''' # --- Read .json file try: with open(input_file_path, 'r') as config_file: config_new = json.load(config_file) config_file.close() except: ...
python
def parser(input_file_path='config.json'): ''' Parser for the .json file containing the configuration of the method. ''' # --- Read .json file try: with open(input_file_path, 'r') as config_file: config_new = json.load(config_file) config_file.close() except: ...
[ "def", "parser", "(", "input_file_path", "=", "'config.json'", ")", ":", "try", ":", "with", "open", "(", "input_file_path", ",", "'r'", ")", "as", "config_file", ":", "config_new", "=", "json", ".", "load", "(", "config_file", ")", "config_file", ".", "cl...
Parser for the .json file containing the configuration of the method.
[ "Parser", "for", "the", ".", "json", "file", "containing", "the", "configuration", "of", "the", "method", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/interface/config_parser.py#L78-L94
train
SheffieldML/GPyOpt
GPyOpt/util/mcmc_sampler.py
AffineInvariantEnsembleSampler.get_samples
def get_samples(self, n_samples, log_p_function, burn_in_steps=50): """ Generates samples. Parameters: n_samples - number of samples to generate log_p_function - a function that returns log density for a specific sample burn_in_steps - number of burn-in steps...
python
def get_samples(self, n_samples, log_p_function, burn_in_steps=50): """ Generates samples. Parameters: n_samples - number of samples to generate log_p_function - a function that returns log density for a specific sample burn_in_steps - number of burn-in steps...
[ "def", "get_samples", "(", "self", ",", "n_samples", ",", "log_p_function", ",", "burn_in_steps", "=", "50", ")", ":", "restarts", "=", "initial_design", "(", "'random'", ",", "self", ".", "space", ",", "n_samples", ")", "sampler", "=", "emcee", ".", "Ense...
Generates samples. Parameters: n_samples - number of samples to generate log_p_function - a function that returns log density for a specific sample burn_in_steps - number of burn-in steps for sampling Returns a tuple of two array: (samples, log_p_function values for...
[ "Generates", "samples", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/util/mcmc_sampler.py#L39-L59
train
SheffieldML/GPyOpt
GPyOpt/core/bo.py
BO.suggest_next_locations
def suggest_next_locations(self, context = None, pending_X = None, ignored_X = None): """ Run a single optimization step and return the next locations to evaluate the objective. Number of suggested locations equals to batch_size. :param context: fixes specified variables to a particular...
python
def suggest_next_locations(self, context = None, pending_X = None, ignored_X = None): """ Run a single optimization step and return the next locations to evaluate the objective. Number of suggested locations equals to batch_size. :param context: fixes specified variables to a particular...
[ "def", "suggest_next_locations", "(", "self", ",", "context", "=", "None", ",", "pending_X", "=", "None", ",", "ignored_X", "=", "None", ")", ":", "self", ".", "model_parameters_iterations", "=", "None", "self", ".", "num_acquisitions", "=", "0", "self", "."...
Run a single optimization step and return the next locations to evaluate the objective. Number of suggested locations equals to batch_size. :param context: fixes specified variables to a particular context (values) for the optimization run (default, None). :param pending_X: matrix of input conf...
[ "Run", "a", "single", "optimization", "step", "and", "return", "the", "next", "locations", "to", "evaluate", "the", "objective", ".", "Number", "of", "suggested", "locations", "equals", "to", "batch_size", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/bo.py#L55-L71
train
SheffieldML/GPyOpt
GPyOpt/core/bo.py
BO._print_convergence
def _print_convergence(self): """ Prints the reason why the optimization stopped. """ if self.verbosity: if (self.num_acquisitions == self.max_iter) and (not self.initial_iter): print(' ** Maximum number of iterations reached **') return 1 ...
python
def _print_convergence(self): """ Prints the reason why the optimization stopped. """ if self.verbosity: if (self.num_acquisitions == self.max_iter) and (not self.initial_iter): print(' ** Maximum number of iterations reached **') return 1 ...
[ "def", "_print_convergence", "(", "self", ")", ":", "if", "self", ".", "verbosity", ":", "if", "(", "self", ".", "num_acquisitions", "==", "self", ".", "max_iter", ")", "and", "(", "not", "self", ".", "initial_iter", ")", ":", "print", "(", "' ** Maxim...
Prints the reason why the optimization stopped.
[ "Prints", "the", "reason", "why", "the", "optimization", "stopped", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/bo.py#L172-L190
train
SheffieldML/GPyOpt
GPyOpt/core/bo.py
BO.evaluate_objective
def evaluate_objective(self): """ Evaluates the objective """ self.Y_new, cost_new = self.objective.evaluate(self.suggested_sample) self.cost.update_cost_model(self.suggested_sample, cost_new) self.Y = np.vstack((self.Y,self.Y_new))
python
def evaluate_objective(self): """ Evaluates the objective """ self.Y_new, cost_new = self.objective.evaluate(self.suggested_sample) self.cost.update_cost_model(self.suggested_sample, cost_new) self.Y = np.vstack((self.Y,self.Y_new))
[ "def", "evaluate_objective", "(", "self", ")", ":", "self", ".", "Y_new", ",", "cost_new", "=", "self", ".", "objective", ".", "evaluate", "(", "self", ".", "suggested_sample", ")", "self", ".", "cost", ".", "update_cost_model", "(", "self", ".", "suggeste...
Evaluates the objective
[ "Evaluates", "the", "objective" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/bo.py#L193-L199
train
SheffieldML/GPyOpt
GPyOpt/core/bo.py
BO._compute_results
def _compute_results(self): """ Computes the optimum and its value. """ self.Y_best = best_value(self.Y) self.x_opt = self.X[np.argmin(self.Y),:] self.fx_opt = np.min(self.Y)
python
def _compute_results(self): """ Computes the optimum and its value. """ self.Y_best = best_value(self.Y) self.x_opt = self.X[np.argmin(self.Y),:] self.fx_opt = np.min(self.Y)
[ "def", "_compute_results", "(", "self", ")", ":", "self", ".", "Y_best", "=", "best_value", "(", "self", ".", "Y", ")", "self", ".", "x_opt", "=", "self", ".", "X", "[", "np", ".", "argmin", "(", "self", ".", "Y", ")", ",", ":", "]", "self", "....
Computes the optimum and its value.
[ "Computes", "the", "optimum", "and", "its", "value", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/bo.py#L201-L207
train
SheffieldML/GPyOpt
GPyOpt/core/bo.py
BO._distance_last_evaluations
def _distance_last_evaluations(self): """ Computes the distance between the last two evaluations. """ if self.X.shape[0] < 2: # less than 2 evaluations return np.inf return np.sqrt(np.sum((self.X[-1, :] - self.X[-2, :]) ** 2))
python
def _distance_last_evaluations(self): """ Computes the distance between the last two evaluations. """ if self.X.shape[0] < 2: # less than 2 evaluations return np.inf return np.sqrt(np.sum((self.X[-1, :] - self.X[-2, :]) ** 2))
[ "def", "_distance_last_evaluations", "(", "self", ")", ":", "if", "self", ".", "X", ".", "shape", "[", "0", "]", "<", "2", ":", "return", "np", ".", "inf", "return", "np", ".", "sqrt", "(", "np", ".", "sum", "(", "(", "self", ".", "X", "[", "-"...
Computes the distance between the last two evaluations.
[ "Computes", "the", "distance", "between", "the", "last", "two", "evaluations", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/bo.py#L209-L216
train
SheffieldML/GPyOpt
GPyOpt/core/bo.py
BO.save_evaluations
def save_evaluations(self, evaluations_file = None): """ Saves evaluations at each iteration of the optimization :param evaluations_file: name of the file in which the results are saved. """ iterations = np.array(range(1, self.Y.shape[0] + 1))[:, None] results = np.hsta...
python
def save_evaluations(self, evaluations_file = None): """ Saves evaluations at each iteration of the optimization :param evaluations_file: name of the file in which the results are saved. """ iterations = np.array(range(1, self.Y.shape[0] + 1))[:, None] results = np.hsta...
[ "def", "save_evaluations", "(", "self", ",", "evaluations_file", "=", "None", ")", ":", "iterations", "=", "np", ".", "array", "(", "range", "(", "1", ",", "self", ".", "Y", ".", "shape", "[", "0", "]", "+", "1", ")", ")", "[", ":", ",", "None", ...
Saves evaluations at each iteration of the optimization :param evaluations_file: name of the file in which the results are saved.
[ "Saves", "evaluations", "at", "each", "iteration", "of", "the", "optimization" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/bo.py#L367-L378
train
SheffieldML/GPyOpt
GPyOpt/core/bo.py
BO.save_models
def save_models(self, models_file): """ Saves model parameters at each iteration of the optimization :param models_file: name of the file or a file buffer, in which the results are saved. """ if self.model_parameters_iterations is None: raise ValueError("No iteration...
python
def save_models(self, models_file): """ Saves model parameters at each iteration of the optimization :param models_file: name of the file or a file buffer, in which the results are saved. """ if self.model_parameters_iterations is None: raise ValueError("No iteration...
[ "def", "save_models", "(", "self", ",", "models_file", ")", ":", "if", "self", ".", "model_parameters_iterations", "is", "None", ":", "raise", "ValueError", "(", "\"No iterations have been carried out yet and hence no iterations of the BO can be saved\"", ")", "iterations", ...
Saves model parameters at each iteration of the optimization :param models_file: name of the file or a file buffer, in which the results are saved.
[ "Saves", "model", "parameters", "at", "each", "iteration", "of", "the", "optimization" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/bo.py#L380-L394
train
SheffieldML/GPyOpt
GPyOpt/methods/bayesian_optimization.py
BayesianOptimization._init_design_chooser
def _init_design_chooser(self): """ Initializes the choice of X and Y based on the selected initial design and number of points selected. """ # If objective function was not provided, we require some initial sample data if self.f is None and (self.X is None or self.Y is None): ...
python
def _init_design_chooser(self): """ Initializes the choice of X and Y based on the selected initial design and number of points selected. """ # If objective function was not provided, we require some initial sample data if self.f is None and (self.X is None or self.Y is None): ...
[ "def", "_init_design_chooser", "(", "self", ")", ":", "if", "self", ".", "f", "is", "None", "and", "(", "self", ".", "X", "is", "None", "or", "self", ".", "Y", "is", "None", ")", ":", "raise", "InvalidConfigError", "(", "\"Initial data for both X and Y is ...
Initializes the choice of X and Y based on the selected initial design and number of points selected.
[ "Initializes", "the", "choice", "of", "X", "and", "Y", "based", "on", "the", "selected", "initial", "design", "and", "number", "of", "points", "selected", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/methods/bayesian_optimization.py#L183-L198
train
coleifer/huey
huey/api.py
crontab
def crontab(minute='*', hour='*', day='*', month='*', day_of_week='*'): """ Convert a "crontab"-style set of parameters into a test function that will return True when the given datetime matches the parameters set forth in the crontab. For day-of-week, 0=Sunday and 6=Saturday. Acceptable input...
python
def crontab(minute='*', hour='*', day='*', month='*', day_of_week='*'): """ Convert a "crontab"-style set of parameters into a test function that will return True when the given datetime matches the parameters set forth in the crontab. For day-of-week, 0=Sunday and 6=Saturday. Acceptable input...
[ "def", "crontab", "(", "minute", "=", "'*'", ",", "hour", "=", "'*'", ",", "day", "=", "'*'", ",", "month", "=", "'*'", ",", "day_of_week", "=", "'*'", ")", ":", "validation", "=", "(", "(", "'m'", ",", "month", ",", "range", "(", "1", ",", "13...
Convert a "crontab"-style set of parameters into a test function that will return True when the given datetime matches the parameters set forth in the crontab. For day-of-week, 0=Sunday and 6=Saturday. Acceptable inputs: * = every distinct value */n = run every "n" times, i.e. hours='*/4' == 0...
[ "Convert", "a", "crontab", "-", "style", "set", "of", "parameters", "into", "a", "test", "function", "that", "will", "return", "True", "when", "the", "given", "datetime", "matches", "the", "parameters", "set", "forth", "in", "the", "crontab", "." ]
416e8da1ca18442c08431a91bce373de7d2d200f
https://github.com/coleifer/huey/blob/416e8da1ca18442c08431a91bce373de7d2d200f/huey/api.py#L913-L990
train
coleifer/huey
huey/storage.py
BaseStorage.put_if_empty
def put_if_empty(self, key, value): """ Atomically write data only if the key is not already set. :param bytes key: Key to check/set. :param bytes value: Arbitrary data. :return: Boolean whether key/value was set. """ if self.has_data_for_key(key): re...
python
def put_if_empty(self, key, value): """ Atomically write data only if the key is not already set. :param bytes key: Key to check/set. :param bytes value: Arbitrary data. :return: Boolean whether key/value was set. """ if self.has_data_for_key(key): re...
[ "def", "put_if_empty", "(", "self", ",", "key", ",", "value", ")", ":", "if", "self", ".", "has_data_for_key", "(", "key", ")", ":", "return", "False", "self", ".", "put_data", "(", "key", ",", "value", ")", "return", "True" ]
Atomically write data only if the key is not already set. :param bytes key: Key to check/set. :param bytes value: Arbitrary data. :return: Boolean whether key/value was set.
[ "Atomically", "write", "data", "only", "if", "the", "key", "is", "not", "already", "set", "." ]
416e8da1ca18442c08431a91bce373de7d2d200f
https://github.com/coleifer/huey/blob/416e8da1ca18442c08431a91bce373de7d2d200f/huey/storage.py#L190-L201
train
coleifer/huey
huey/utils.py
make_naive
def make_naive(dt): """ Makes an aware datetime.datetime naive in local time zone. """ tt = dt.utctimetuple() ts = calendar.timegm(tt) local_tt = time.localtime(ts) return datetime.datetime(*local_tt[:6])
python
def make_naive(dt): """ Makes an aware datetime.datetime naive in local time zone. """ tt = dt.utctimetuple() ts = calendar.timegm(tt) local_tt = time.localtime(ts) return datetime.datetime(*local_tt[:6])
[ "def", "make_naive", "(", "dt", ")", ":", "tt", "=", "dt", ".", "utctimetuple", "(", ")", "ts", "=", "calendar", ".", "timegm", "(", "tt", ")", "local_tt", "=", "time", ".", "localtime", "(", "ts", ")", "return", "datetime", ".", "datetime", "(", "...
Makes an aware datetime.datetime naive in local time zone.
[ "Makes", "an", "aware", "datetime", ".", "datetime", "naive", "in", "local", "time", "zone", "." ]
416e8da1ca18442c08431a91bce373de7d2d200f
https://github.com/coleifer/huey/blob/416e8da1ca18442c08431a91bce373de7d2d200f/huey/utils.py#L48-L55
train
coleifer/huey
huey/consumer.py
BaseProcess.sleep_for_interval
def sleep_for_interval(self, start_ts, nseconds): """ Sleep for a given interval with respect to the start timestamp. So, if the start timestamp is 1337 and nseconds is 10, the method will actually sleep for nseconds - (current_timestamp - start_timestamp). So if the current tim...
python
def sleep_for_interval(self, start_ts, nseconds): """ Sleep for a given interval with respect to the start timestamp. So, if the start timestamp is 1337 and nseconds is 10, the method will actually sleep for nseconds - (current_timestamp - start_timestamp). So if the current tim...
[ "def", "sleep_for_interval", "(", "self", ",", "start_ts", ",", "nseconds", ")", ":", "sleep_time", "=", "nseconds", "-", "(", "time", ".", "time", "(", ")", "-", "start_ts", ")", "if", "sleep_time", "<=", "0", ":", "return", "self", ".", "_logger", "....
Sleep for a given interval with respect to the start timestamp. So, if the start timestamp is 1337 and nseconds is 10, the method will actually sleep for nseconds - (current_timestamp - start_timestamp). So if the current timestamp is 1340, we'll only sleep for 7 seconds (the goal being...
[ "Sleep", "for", "a", "given", "interval", "with", "respect", "to", "the", "start", "timestamp", "." ]
416e8da1ca18442c08431a91bce373de7d2d200f
https://github.com/coleifer/huey/blob/416e8da1ca18442c08431a91bce373de7d2d200f/huey/consumer.py#L39-L56
train
coleifer/huey
huey/consumer.py
Consumer.start
def start(self): """ Start all consumer processes and register signal handlers. """ if self.huey.immediate: raise ConfigurationError( 'Consumer cannot be run with Huey instances where immediate ' 'is enabled. Please check your configuration and...
python
def start(self): """ Start all consumer processes and register signal handlers. """ if self.huey.immediate: raise ConfigurationError( 'Consumer cannot be run with Huey instances where immediate ' 'is enabled. Please check your configuration and...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "huey", ".", "immediate", ":", "raise", "ConfigurationError", "(", "'Consumer cannot be run with Huey instances where immediate '", "'is enabled. Please check your configuration and ensure that '", "'\"huey.immediate = Fal...
Start all consumer processes and register signal handlers.
[ "Start", "all", "consumer", "processes", "and", "register", "signal", "handlers", "." ]
416e8da1ca18442c08431a91bce373de7d2d200f
https://github.com/coleifer/huey/blob/416e8da1ca18442c08431a91bce373de7d2d200f/huey/consumer.py#L344-L383
train
coleifer/huey
huey/consumer.py
Consumer.stop
def stop(self, graceful=False): """ Set the stop-flag. If `graceful=True`, this method blocks until the workers to finish executing any tasks they might be currently working on. """ self.stop_flag.set() if graceful: self._logger.info('Shutting down gr...
python
def stop(self, graceful=False): """ Set the stop-flag. If `graceful=True`, this method blocks until the workers to finish executing any tasks they might be currently working on. """ self.stop_flag.set() if graceful: self._logger.info('Shutting down gr...
[ "def", "stop", "(", "self", ",", "graceful", "=", "False", ")", ":", "self", ".", "stop_flag", ".", "set", "(", ")", "if", "graceful", ":", "self", ".", "_logger", ".", "info", "(", "'Shutting down gracefully...'", ")", "try", ":", "for", "_", ",", "...
Set the stop-flag. If `graceful=True`, this method blocks until the workers to finish executing any tasks they might be currently working on.
[ "Set", "the", "stop", "-", "flag", "." ]
416e8da1ca18442c08431a91bce373de7d2d200f
https://github.com/coleifer/huey/blob/416e8da1ca18442c08431a91bce373de7d2d200f/huey/consumer.py#L385-L403
train
coleifer/huey
huey/consumer.py
Consumer.run
def run(self): """ Run the consumer. """ self.start() timeout = self._stop_flag_timeout health_check_ts = time.time() while True: try: self.stop_flag.wait(timeout=timeout) except KeyboardInterrupt: self._log...
python
def run(self): """ Run the consumer. """ self.start() timeout = self._stop_flag_timeout health_check_ts = time.time() while True: try: self.stop_flag.wait(timeout=timeout) except KeyboardInterrupt: self._log...
[ "def", "run", "(", "self", ")", ":", "self", ".", "start", "(", ")", "timeout", "=", "self", ".", "_stop_flag_timeout", "health_check_ts", "=", "time", ".", "time", "(", ")", "while", "True", ":", "try", ":", "self", ".", "stop_flag", ".", "wait", "(...
Run the consumer.
[ "Run", "the", "consumer", "." ]
416e8da1ca18442c08431a91bce373de7d2d200f
https://github.com/coleifer/huey/blob/416e8da1ca18442c08431a91bce373de7d2d200f/huey/consumer.py#L405-L440
train
coleifer/huey
huey/consumer.py
Consumer.check_worker_health
def check_worker_health(self): """ Check the health of the worker processes. Workers that have died will be replaced with new workers. """ self._logger.debug('Checking worker health.') workers = [] restart_occurred = False for i, (worker, worker_t) in enum...
python
def check_worker_health(self): """ Check the health of the worker processes. Workers that have died will be replaced with new workers. """ self._logger.debug('Checking worker health.') workers = [] restart_occurred = False for i, (worker, worker_t) in enum...
[ "def", "check_worker_health", "(", "self", ")", ":", "self", ".", "_logger", ".", "debug", "(", "'Checking worker health.'", ")", "workers", "=", "[", "]", "restart_occurred", "=", "False", "for", "i", ",", "(", "worker", ",", "worker_t", ")", "in", "enume...
Check the health of the worker processes. Workers that have died will be replaced with new workers.
[ "Check", "the", "health", "of", "the", "worker", "processes", ".", "Workers", "that", "have", "died", "will", "be", "replaced", "with", "new", "workers", "." ]
416e8da1ca18442c08431a91bce373de7d2d200f
https://github.com/coleifer/huey/blob/416e8da1ca18442c08431a91bce373de7d2d200f/huey/consumer.py#L442-L472
train
coleifer/huey
huey/contrib/djhuey/__init__.py
close_db
def close_db(fn): """Decorator to be used with tasks that may operate on the database.""" @wraps(fn) def inner(*args, **kwargs): try: return fn(*args, **kwargs) finally: if not HUEY.immediate: close_old_connections() return inner
python
def close_db(fn): """Decorator to be used with tasks that may operate on the database.""" @wraps(fn) def inner(*args, **kwargs): try: return fn(*args, **kwargs) finally: if not HUEY.immediate: close_old_connections() return inner
[ "def", "close_db", "(", "fn", ")", ":", "@", "wraps", "(", "fn", ")", "def", "inner", "(", "*", "args", ",", "**", "kwargs", ")", ":", "try", ":", "return", "fn", "(", "*", "args", ",", "**", "kwargs", ")", "finally", ":", "if", "not", "HUEY", ...
Decorator to be used with tasks that may operate on the database.
[ "Decorator", "to", "be", "used", "with", "tasks", "that", "may", "operate", "on", "the", "database", "." ]
416e8da1ca18442c08431a91bce373de7d2d200f
https://github.com/coleifer/huey/blob/416e8da1ca18442c08431a91bce373de7d2d200f/huey/contrib/djhuey/__init__.py#L123-L132
train
johnwheeler/flask-ask
samples/purchase/model.py
Product.list
def list(self): """ return list of purchasable and not entitled products""" mylist = [] for prod in self.product_list: if self.purchasable(prod) and not self.entitled(prod): mylist.append(prod) return mylist
python
def list(self): """ return list of purchasable and not entitled products""" mylist = [] for prod in self.product_list: if self.purchasable(prod) and not self.entitled(prod): mylist.append(prod) return mylist
[ "def", "list", "(", "self", ")", ":", "mylist", "=", "[", "]", "for", "prod", "in", "self", ".", "product_list", ":", "if", "self", ".", "purchasable", "(", "prod", ")", "and", "not", "self", ".", "entitled", "(", "prod", ")", ":", "mylist", ".", ...
return list of purchasable and not entitled products
[ "return", "list", "of", "purchasable", "and", "not", "entitled", "products" ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/samples/purchase/model.py#L51-L57
train
johnwheeler/flask-ask
samples/tidepooler/tidepooler.py
_find_tide_info
def _find_tide_info(predictions): """ Algorithm to find the 2 high tides for the day, the first of which is smaller and occurs mid-day, the second of which is larger and typically in the evening. """ last_prediction = None first_high_tide = None second_high_tide = None low_tide = None...
python
def _find_tide_info(predictions): """ Algorithm to find the 2 high tides for the day, the first of which is smaller and occurs mid-day, the second of which is larger and typically in the evening. """ last_prediction = None first_high_tide = None second_high_tide = None low_tide = None...
[ "def", "_find_tide_info", "(", "predictions", ")", ":", "last_prediction", "=", "None", "first_high_tide", "=", "None", "second_high_tide", "=", "None", "low_tide", "=", "None", "first_tide_done", "=", "False", "for", "prediction", "in", "predictions", ":", "if", ...
Algorithm to find the 2 high tides for the day, the first of which is smaller and occurs mid-day, the second of which is larger and typically in the evening.
[ "Algorithm", "to", "find", "the", "2", "high", "tides", "for", "the", "day", "the", "first", "of", "which", "is", "smaller", "and", "occurs", "mid", "-", "day", "the", "second", "of", "which", "is", "larger", "and", "typically", "in", "the", "evening", ...
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/samples/tidepooler/tidepooler.py#L252-L290
train
johnwheeler/flask-ask
flask_ask/models.py
audio.enqueue
def enqueue(self, stream_url, offset=0, opaque_token=None): """Adds stream to the queue. Does not impact the currently playing stream.""" directive = self._play_directive('ENQUEUE') audio_item = self._audio_item(stream_url=stream_url, offset=offset, ...
python
def enqueue(self, stream_url, offset=0, opaque_token=None): """Adds stream to the queue. Does not impact the currently playing stream.""" directive = self._play_directive('ENQUEUE') audio_item = self._audio_item(stream_url=stream_url, offset=offset, ...
[ "def", "enqueue", "(", "self", ",", "stream_url", ",", "offset", "=", "0", ",", "opaque_token", "=", "None", ")", ":", "directive", "=", "self", ".", "_play_directive", "(", "'ENQUEUE'", ")", "audio_item", "=", "self", ".", "_audio_item", "(", "stream_url"...
Adds stream to the queue. Does not impact the currently playing stream.
[ "Adds", "stream", "to", "the", "queue", ".", "Does", "not", "impact", "the", "currently", "playing", "stream", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/models.py#L364-L375
train
johnwheeler/flask-ask
flask_ask/models.py
audio.play_next
def play_next(self, stream_url=None, offset=0, opaque_token=None): """Replace all streams in the queue but does not impact the currently playing stream.""" directive = self._play_directive('REPLACE_ENQUEUED') directive['audioItem'] = self._audio_item(stream_url=stream_url, offset=offset, opaque...
python
def play_next(self, stream_url=None, offset=0, opaque_token=None): """Replace all streams in the queue but does not impact the currently playing stream.""" directive = self._play_directive('REPLACE_ENQUEUED') directive['audioItem'] = self._audio_item(stream_url=stream_url, offset=offset, opaque...
[ "def", "play_next", "(", "self", ",", "stream_url", "=", "None", ",", "offset", "=", "0", ",", "opaque_token", "=", "None", ")", ":", "directive", "=", "self", ".", "_play_directive", "(", "'REPLACE_ENQUEUED'", ")", "directive", "[", "'audioItem'", "]", "=...
Replace all streams in the queue but does not impact the currently playing stream.
[ "Replace", "all", "streams", "in", "the", "queue", "but", "does", "not", "impact", "the", "currently", "playing", "stream", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/models.py#L377-L383
train
johnwheeler/flask-ask
flask_ask/models.py
audio.resume
def resume(self): """Sends Play Directive to resume playback at the paused offset""" directive = self._play_directive('REPLACE_ALL') directive['audioItem'] = self._audio_item() self._response['directives'].append(directive) return self
python
def resume(self): """Sends Play Directive to resume playback at the paused offset""" directive = self._play_directive('REPLACE_ALL') directive['audioItem'] = self._audio_item() self._response['directives'].append(directive) return self
[ "def", "resume", "(", "self", ")", ":", "directive", "=", "self", ".", "_play_directive", "(", "'REPLACE_ALL'", ")", "directive", "[", "'audioItem'", "]", "=", "self", ".", "_audio_item", "(", ")", "self", ".", "_response", "[", "'directives'", "]", ".", ...
Sends Play Directive to resume playback at the paused offset
[ "Sends", "Play", "Directive", "to", "resume", "playback", "at", "the", "paused", "offset" ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/models.py#L385-L390
train
johnwheeler/flask-ask
flask_ask/models.py
audio._audio_item
def _audio_item(self, stream_url=None, offset=0, push_buffer=True, opaque_token=None): """Builds an AudioPlayer Directive's audioItem and updates current_stream""" audio_item = {'stream': {}} stream = audio_item['stream'] # existing stream if not stream_url: # stream...
python
def _audio_item(self, stream_url=None, offset=0, push_buffer=True, opaque_token=None): """Builds an AudioPlayer Directive's audioItem and updates current_stream""" audio_item = {'stream': {}} stream = audio_item['stream'] # existing stream if not stream_url: # stream...
[ "def", "_audio_item", "(", "self", ",", "stream_url", "=", "None", ",", "offset", "=", "0", ",", "push_buffer", "=", "True", ",", "opaque_token", "=", "None", ")", ":", "audio_item", "=", "{", "'stream'", ":", "{", "}", "}", "stream", "=", "audio_item"...
Builds an AudioPlayer Directive's audioItem and updates current_stream
[ "Builds", "an", "AudioPlayer", "Directive", "s", "audioItem", "and", "updates", "current_stream" ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/models.py#L398-L418
train
johnwheeler/flask-ask
flask_ask/models.py
audio.clear_queue
def clear_queue(self, stop=False): """Clears queued streams and optionally stops current stream. Keyword Arguments: stop {bool} set True to stop current current stream and clear queued streams. set False to clear queued streams and allow current stream to finish ...
python
def clear_queue(self, stop=False): """Clears queued streams and optionally stops current stream. Keyword Arguments: stop {bool} set True to stop current current stream and clear queued streams. set False to clear queued streams and allow current stream to finish ...
[ "def", "clear_queue", "(", "self", ",", "stop", "=", "False", ")", ":", "directive", "=", "{", "}", "directive", "[", "'type'", "]", "=", "'AudioPlayer.ClearQueue'", "if", "stop", ":", "directive", "[", "'clearBehavior'", "]", "=", "'CLEAR_ALL'", "else", "...
Clears queued streams and optionally stops current stream. Keyword Arguments: stop {bool} set True to stop current current stream and clear queued streams. set False to clear queued streams and allow current stream to finish default: {False}
[ "Clears", "queued", "streams", "and", "optionally", "stops", "current", "stream", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/models.py#L425-L442
train
johnwheeler/flask-ask
flask_ask/core.py
find_ask
def find_ask(): """ Find our instance of Ask, navigating Local's and possible blueprints. Note: This only supports returning a reference to the first instance of Ask found. """ if hasattr(current_app, 'ask'): return getattr(current_app, 'ask') else: if hasattr(current_app, '...
python
def find_ask(): """ Find our instance of Ask, navigating Local's and possible blueprints. Note: This only supports returning a reference to the first instance of Ask found. """ if hasattr(current_app, 'ask'): return getattr(current_app, 'ask') else: if hasattr(current_app, '...
[ "def", "find_ask", "(", ")", ":", "if", "hasattr", "(", "current_app", ",", "'ask'", ")", ":", "return", "getattr", "(", "current_app", ",", "'ask'", ")", "else", ":", "if", "hasattr", "(", "current_app", ",", "'blueprints'", ")", ":", "blueprints", "=",...
Find our instance of Ask, navigating Local's and possible blueprints. Note: This only supports returning a reference to the first instance of Ask found.
[ "Find", "our", "instance", "of", "Ask", "navigating", "Local", "s", "and", "possible", "blueprints", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L21-L35
train
johnwheeler/flask-ask
flask_ask/core.py
Ask.init_app
def init_app(self, app, path='templates.yaml'): """Initializes Ask app by setting configuration variables, loading templates, and maps Ask route to a flask view. The Ask instance is given the following configuration variables by calling on Flask's configuration: `ASK_APPLICATION_ID`: ...
python
def init_app(self, app, path='templates.yaml'): """Initializes Ask app by setting configuration variables, loading templates, and maps Ask route to a flask view. The Ask instance is given the following configuration variables by calling on Flask's configuration: `ASK_APPLICATION_ID`: ...
[ "def", "init_app", "(", "self", ",", "app", ",", "path", "=", "'templates.yaml'", ")", ":", "if", "self", ".", "_route", "is", "None", ":", "raise", "TypeError", "(", "\"route is a required argument when app is not None\"", ")", "self", ".", "app", "=", "app",...
Initializes Ask app by setting configuration variables, loading templates, and maps Ask route to a flask view. The Ask instance is given the following configuration variables by calling on Flask's configuration: `ASK_APPLICATION_ID`: Turn on application ID verification by setting this var...
[ "Initializes", "Ask", "app", "by", "setting", "configuration", "variables", "loading", "templates", "and", "maps", "Ask", "route", "to", "a", "flask", "view", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L101-L142
train
johnwheeler/flask-ask
flask_ask/core.py
Ask.launch
def launch(self, f): """Decorator maps a view function as the endpoint for an Alexa LaunchRequest and starts the skill. @ask.launch def launched(): return question('Welcome to Foo') The wrapped function is registered as the launch view function and renders the response ...
python
def launch(self, f): """Decorator maps a view function as the endpoint for an Alexa LaunchRequest and starts the skill. @ask.launch def launched(): return question('Welcome to Foo') The wrapped function is registered as the launch view function and renders the response ...
[ "def", "launch", "(", "self", ",", "f", ")", ":", "self", ".", "_launch_view_func", "=", "f", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "**", "kw", ")", ":", "self", ".", "_flask_view_func", "(", "*", "args", ",", "**"...
Decorator maps a view function as the endpoint for an Alexa LaunchRequest and starts the skill. @ask.launch def launched(): return question('Welcome to Foo') The wrapped function is registered as the launch view function and renders the response for requests to the Launch U...
[ "Decorator", "maps", "a", "view", "function", "as", "the", "endpoint", "for", "an", "Alexa", "LaunchRequest", "and", "starts", "the", "skill", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L192-L212
train
johnwheeler/flask-ask
flask_ask/core.py
Ask.session_ended
def session_ended(self, f): """Decorator routes Alexa SessionEndedRequest to the wrapped view function to end the skill. @ask.session_ended def session_ended(): return "{}", 200 The wrapped function is registered as the session_ended view function and renders the re...
python
def session_ended(self, f): """Decorator routes Alexa SessionEndedRequest to the wrapped view function to end the skill. @ask.session_ended def session_ended(): return "{}", 200 The wrapped function is registered as the session_ended view function and renders the re...
[ "def", "session_ended", "(", "self", ",", "f", ")", ":", "self", ".", "_session_ended_view_func", "=", "f", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "**", "kw", ")", ":", "self", ".", "_flask_view_func", "(", "*", "args",...
Decorator routes Alexa SessionEndedRequest to the wrapped view function to end the skill. @ask.session_ended def session_ended(): return "{}", 200 The wrapped function is registered as the session_ended view function and renders the response for requests to the end of the s...
[ "Decorator", "routes", "Alexa", "SessionEndedRequest", "to", "the", "wrapped", "view", "function", "to", "end", "the", "skill", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L214-L232
train
johnwheeler/flask-ask
flask_ask/core.py
Ask.intent
def intent(self, intent_name, mapping={}, convert={}, default={}): """Decorator routes an Alexa IntentRequest and provides the slot parameters to the wrapped function. Functions decorated as an intent are registered as the view function for the Intent's URL, and provide the backend responses to...
python
def intent(self, intent_name, mapping={}, convert={}, default={}): """Decorator routes an Alexa IntentRequest and provides the slot parameters to the wrapped function. Functions decorated as an intent are registered as the view function for the Intent's URL, and provide the backend responses to...
[ "def", "intent", "(", "self", ",", "intent_name", ",", "mapping", "=", "{", "}", ",", "convert", "=", "{", "}", ",", "default", "=", "{", "}", ")", ":", "def", "decorator", "(", "f", ")", ":", "self", ".", "_intent_view_funcs", "[", "intent_name", ...
Decorator routes an Alexa IntentRequest and provides the slot parameters to the wrapped function. Functions decorated as an intent are registered as the view function for the Intent's URL, and provide the backend responses to give your Skill its functionality. @ask.intent('WeatherIntent', mapp...
[ "Decorator", "routes", "an", "Alexa", "IntentRequest", "and", "provides", "the", "slot", "parameters", "to", "the", "wrapped", "function", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L234-L268
train
johnwheeler/flask-ask
flask_ask/core.py
Ask.default_intent
def default_intent(self, f): """Decorator routes any Alexa IntentRequest that is not matched by any existing @ask.intent routing.""" self._default_intent_view_func = f @wraps(f) def wrapper(*args, **kw): self._flask_view_func(*args, **kw) return f
python
def default_intent(self, f): """Decorator routes any Alexa IntentRequest that is not matched by any existing @ask.intent routing.""" self._default_intent_view_func = f @wraps(f) def wrapper(*args, **kw): self._flask_view_func(*args, **kw) return f
[ "def", "default_intent", "(", "self", ",", "f", ")", ":", "self", ".", "_default_intent_view_func", "=", "f", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "**", "kw", ")", ":", "self", ".", "_flask_view_func", "(", "*", "args...
Decorator routes any Alexa IntentRequest that is not matched by any existing @ask.intent routing.
[ "Decorator", "routes", "any", "Alexa", "IntentRequest", "that", "is", "not", "matched", "by", "any", "existing" ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L270-L277
train
johnwheeler/flask-ask
flask_ask/core.py
Ask.display_element_selected
def display_element_selected(self, f): """Decorator routes Alexa Display.ElementSelected request to the wrapped view function. @ask.display_element_selected def eval_element(): return "", 200 The wrapped function is registered as the display_element_selected view function ...
python
def display_element_selected(self, f): """Decorator routes Alexa Display.ElementSelected request to the wrapped view function. @ask.display_element_selected def eval_element(): return "", 200 The wrapped function is registered as the display_element_selected view function ...
[ "def", "display_element_selected", "(", "self", ",", "f", ")", ":", "self", ".", "_display_element_selected_func", "=", "f", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "**", "kw", ")", ":", "self", ".", "_flask_view_func", "(",...
Decorator routes Alexa Display.ElementSelected request to the wrapped view function. @ask.display_element_selected def eval_element(): return "", 200 The wrapped function is registered as the display_element_selected view function and renders the response for requests. ...
[ "Decorator", "routes", "Alexa", "Display", ".", "ElementSelected", "request", "to", "the", "wrapped", "view", "function", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L279-L297
train
johnwheeler/flask-ask
flask_ask/core.py
Ask.on_purchase_completed
def on_purchase_completed(self, mapping={'payload': 'payload','name':'name','status':'status','token':'token'}, convert={}, default={}): """Decorator routes an Connections.Response to the wrapped function. Request is sent when Alexa completes the purchase flow. See https://developer.amazon.co...
python
def on_purchase_completed(self, mapping={'payload': 'payload','name':'name','status':'status','token':'token'}, convert={}, default={}): """Decorator routes an Connections.Response to the wrapped function. Request is sent when Alexa completes the purchase flow. See https://developer.amazon.co...
[ "def", "on_purchase_completed", "(", "self", ",", "mapping", "=", "{", "'payload'", ":", "'payload'", ",", "'name'", ":", "'name'", ",", "'status'", ":", "'status'", ",", "'token'", ":", "'token'", "}", ",", "convert", "=", "{", "}", ",", "default", "=",...
Decorator routes an Connections.Response to the wrapped function. Request is sent when Alexa completes the purchase flow. See https://developer.amazon.com/docs/in-skill-purchase/add-isps-to-a-skill.html#handle-results The wrapped view function may accept parameters from the Request. ...
[ "Decorator", "routes", "an", "Connections", ".", "Response", "to", "the", "wrapped", "function", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L300-L328
train
johnwheeler/flask-ask
flask_ask/core.py
Ask.run_aws_lambda
def run_aws_lambda(self, event): """Invoke the Flask Ask application from an AWS Lambda function handler. Use this method to service AWS Lambda requests from a custom Alexa skill. This method will invoke your Flask application providing a WSGI-compatible environment that wraps the origi...
python
def run_aws_lambda(self, event): """Invoke the Flask Ask application from an AWS Lambda function handler. Use this method to service AWS Lambda requests from a custom Alexa skill. This method will invoke your Flask application providing a WSGI-compatible environment that wraps the origi...
[ "def", "run_aws_lambda", "(", "self", ",", "event", ")", ":", "self", ".", "app", ".", "config", "[", "'ASK_VERIFY_REQUESTS'", "]", "=", "False", "enc", ",", "esc", "=", "sys", ".", "getfilesystemencoding", "(", ")", ",", "'surrogateescape'", "def", "unico...
Invoke the Flask Ask application from an AWS Lambda function handler. Use this method to service AWS Lambda requests from a custom Alexa skill. This method will invoke your Flask application providing a WSGI-compatible environment that wraps the original Alexa event provided to the AWS ...
[ "Invoke", "the", "Flask", "Ask", "application", "from", "an", "AWS", "Lambda", "function", "handler", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L585-L683
train
johnwheeler/flask-ask
flask_ask/core.py
Ask._parse_timestamp
def _parse_timestamp(timestamp): """ Parse a given timestamp value, raising ValueError if None or Flasey """ if timestamp: try: return aniso8601.parse_datetime(timestamp) except AttributeError: # raised by aniso8601 if raw_timestamp...
python
def _parse_timestamp(timestamp): """ Parse a given timestamp value, raising ValueError if None or Flasey """ if timestamp: try: return aniso8601.parse_datetime(timestamp) except AttributeError: # raised by aniso8601 if raw_timestamp...
[ "def", "_parse_timestamp", "(", "timestamp", ")", ":", "if", "timestamp", ":", "try", ":", "return", "aniso8601", ".", "parse_datetime", "(", "timestamp", ")", "except", "AttributeError", ":", "try", ":", "return", "datetime", ".", "utcfromtimestamp", "(", "ti...
Parse a given timestamp value, raising ValueError if None or Flasey
[ "Parse", "a", "given", "timestamp", "value", "raising", "ValueError", "if", "None", "or", "Flasey" ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L724-L740
train
johnwheeler/flask-ask
flask_ask/core.py
Ask._map_player_request_to_func
def _map_player_request_to_func(self, player_request_type): """Provides appropriate parameters to the on_playback functions.""" # calbacks for on_playback requests are optional view_func = self._intent_view_funcs.get(player_request_type, lambda: None) argspec = inspect.getargspec(view_f...
python
def _map_player_request_to_func(self, player_request_type): """Provides appropriate parameters to the on_playback functions.""" # calbacks for on_playback requests are optional view_func = self._intent_view_funcs.get(player_request_type, lambda: None) argspec = inspect.getargspec(view_f...
[ "def", "_map_player_request_to_func", "(", "self", ",", "player_request_type", ")", ":", "view_func", "=", "self", ".", "_intent_view_funcs", ".", "get", "(", "player_request_type", ",", "lambda", ":", "None", ")", "argspec", "=", "inspect", ".", "getargspec", "...
Provides appropriate parameters to the on_playback functions.
[ "Provides", "appropriate", "parameters", "to", "the", "on_playback", "functions", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L842-L851
train
johnwheeler/flask-ask
flask_ask/core.py
Ask._map_purchase_request_to_func
def _map_purchase_request_to_func(self, purchase_request_type): """Provides appropriate parameters to the on_purchase functions.""" if purchase_request_type in self._intent_view_funcs: view_func = self._intent_view_funcs[purchase_request_type] else: raise NotImpl...
python
def _map_purchase_request_to_func(self, purchase_request_type): """Provides appropriate parameters to the on_purchase functions.""" if purchase_request_type in self._intent_view_funcs: view_func = self._intent_view_funcs[purchase_request_type] else: raise NotImpl...
[ "def", "_map_purchase_request_to_func", "(", "self", ",", "purchase_request_type", ")", ":", "if", "purchase_request_type", "in", "self", ".", "_intent_view_funcs", ":", "view_func", "=", "self", ".", "_intent_view_funcs", "[", "purchase_request_type", "]", "else", ":...
Provides appropriate parameters to the on_purchase functions.
[ "Provides", "appropriate", "parameters", "to", "the", "on_purchase", "functions", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L853-L866
train
johnwheeler/flask-ask
flask_ask/cache.py
push_stream
def push_stream(cache, user_id, stream): """ Push a stream onto the stream stack in cache. :param cache: werkzeug BasicCache-like object :param user_id: id of user, used as key in cache :param stream: stream object to push onto stack :return: True on successful update, False if fa...
python
def push_stream(cache, user_id, stream): """ Push a stream onto the stream stack in cache. :param cache: werkzeug BasicCache-like object :param user_id: id of user, used as key in cache :param stream: stream object to push onto stack :return: True on successful update, False if fa...
[ "def", "push_stream", "(", "cache", ",", "user_id", ",", "stream", ")", ":", "stack", "=", "cache", ".", "get", "(", "user_id", ")", "if", "stack", "is", "None", ":", "stack", "=", "[", "]", "if", "stream", ":", "stack", ".", "append", "(", "stream...
Push a stream onto the stream stack in cache. :param cache: werkzeug BasicCache-like object :param user_id: id of user, used as key in cache :param stream: stream object to push onto stack :return: True on successful update, False if failed to update, None if invalid input wa...
[ "Push", "a", "stream", "onto", "the", "stream", "stack", "in", "cache", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/cache.py#L6-L24
train
johnwheeler/flask-ask
flask_ask/cache.py
pop_stream
def pop_stream(cache, user_id): """ Pop an item off the stack in the cache. If stack is empty after pop, it deletes the stack. :param cache: werkzeug BasicCache-like object :param user_id: id of user, used as key in cache :return: top item from stack, otherwise None """ stack = cache.g...
python
def pop_stream(cache, user_id): """ Pop an item off the stack in the cache. If stack is empty after pop, it deletes the stack. :param cache: werkzeug BasicCache-like object :param user_id: id of user, used as key in cache :return: top item from stack, otherwise None """ stack = cache.g...
[ "def", "pop_stream", "(", "cache", ",", "user_id", ")", ":", "stack", "=", "cache", ".", "get", "(", "user_id", ")", "if", "stack", "is", "None", ":", "return", "None", "result", "=", "stack", ".", "pop", "(", ")", "if", "len", "(", "stack", ")", ...
Pop an item off the stack in the cache. If stack is empty after pop, it deletes the stack. :param cache: werkzeug BasicCache-like object :param user_id: id of user, used as key in cache :return: top item from stack, otherwise None
[ "Pop", "an", "item", "off", "the", "stack", "in", "the", "cache", ".", "If", "stack", "is", "empty", "after", "pop", "it", "deletes", "the", "stack", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/cache.py#L27-L48
train
johnwheeler/flask-ask
flask_ask/cache.py
top_stream
def top_stream(cache, user_id): """ Peek at the top of the stack in the cache. :param cache: werkzeug BasicCache-like object :param user_id: id of user, used as key in cache :return: top item in user's cached stack, otherwise None """ if not user_id: return None stack = ca...
python
def top_stream(cache, user_id): """ Peek at the top of the stack in the cache. :param cache: werkzeug BasicCache-like object :param user_id: id of user, used as key in cache :return: top item in user's cached stack, otherwise None """ if not user_id: return None stack = ca...
[ "def", "top_stream", "(", "cache", ",", "user_id", ")", ":", "if", "not", "user_id", ":", "return", "None", "stack", "=", "cache", ".", "get", "(", "user_id", ")", "if", "stack", "is", "None", ":", "return", "None", "return", "stack", ".", "pop", "("...
Peek at the top of the stack in the cache. :param cache: werkzeug BasicCache-like object :param user_id: id of user, used as key in cache :return: top item in user's cached stack, otherwise None
[ "Peek", "at", "the", "top", "of", "the", "stack", "in", "the", "cache", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/cache.py#L65-L80
train
ecederstrand/exchangelib
exchangelib/transport.py
wrap
def wrap(content, version, account=None): """ Generate the necessary boilerplate XML for a raw SOAP request. The XML is specific to the server version. ExchangeImpersonation allows to act as the user we want to impersonate. """ envelope = create_element('s:Envelope', nsmap=ns_translation) header...
python
def wrap(content, version, account=None): """ Generate the necessary boilerplate XML for a raw SOAP request. The XML is specific to the server version. ExchangeImpersonation allows to act as the user we want to impersonate. """ envelope = create_element('s:Envelope', nsmap=ns_translation) header...
[ "def", "wrap", "(", "content", ",", "version", ",", "account", "=", "None", ")", ":", "envelope", "=", "create_element", "(", "'s:Envelope'", ",", "nsmap", "=", "ns_translation", ")", "header", "=", "create_element", "(", "'s:Header'", ")", "requestserverversi...
Generate the necessary boilerplate XML for a raw SOAP request. The XML is specific to the server version. ExchangeImpersonation allows to act as the user we want to impersonate.
[ "Generate", "the", "necessary", "boilerplate", "XML", "for", "a", "raw", "SOAP", "request", ".", "The", "XML", "is", "specific", "to", "the", "server", "version", ".", "ExchangeImpersonation", "allows", "to", "act", "as", "the", "user", "we", "want", "to", ...
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/transport.py#L49-L73
train
ecederstrand/exchangelib
exchangelib/autodiscover.py
discover
def discover(email, credentials): """ Performs the autodiscover dance and returns the primary SMTP address of the account and a Protocol on success. The autodiscover and EWS server might not be the same, so we use a different Protocol to do the autodiscover request, and return a hopefully-cached Protoco...
python
def discover(email, credentials): """ Performs the autodiscover dance and returns the primary SMTP address of the account and a Protocol on success. The autodiscover and EWS server might not be the same, so we use a different Protocol to do the autodiscover request, and return a hopefully-cached Protoco...
[ "def", "discover", "(", "email", ",", "credentials", ")", ":", "log", ".", "debug", "(", "'Attempting autodiscover on email %s'", ",", "email", ")", "if", "not", "isinstance", "(", "credentials", ",", "Credentials", ")", ":", "raise", "ValueError", "(", "\"'cr...
Performs the autodiscover dance and returns the primary SMTP address of the account and a Protocol on success. The autodiscover and EWS server might not be the same, so we use a different Protocol to do the autodiscover request, and return a hopefully-cached Protocol to the callee.
[ "Performs", "the", "autodiscover", "dance", "and", "returns", "the", "primary", "SMTP", "address", "of", "the", "account", "and", "a", "Protocol", "on", "success", ".", "The", "autodiscover", "and", "EWS", "server", "might", "not", "be", "the", "same", "so",...
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/autodiscover.py#L173-L223
train
ecederstrand/exchangelib
exchangelib/properties.py
TimeZone.to_server_timezone
def to_server_timezone(self, timezones, for_year): """Returns the Microsoft timezone ID corresponding to this timezone. There may not be a match at all, and there may be multiple matches. If so, we return a random timezone ID. :param timezones: A list of server timezones, as returned by ...
python
def to_server_timezone(self, timezones, for_year): """Returns the Microsoft timezone ID corresponding to this timezone. There may not be a match at all, and there may be multiple matches. If so, we return a random timezone ID. :param timezones: A list of server timezones, as returned by ...
[ "def", "to_server_timezone", "(", "self", ",", "timezones", ",", "for_year", ")", ":", "candidates", "=", "set", "(", ")", "for", "tz_id", ",", "tz_name", ",", "tz_periods", ",", "tz_transitions", ",", "tz_transitions_groups", "in", "timezones", ":", "candidat...
Returns the Microsoft timezone ID corresponding to this timezone. There may not be a match at all, and there may be multiple matches. If so, we return a random timezone ID. :param timezones: A list of server timezones, as returned by list(account.protocol.get_timezones(return_full_timezone_...
[ "Returns", "the", "Microsoft", "timezone", "ID", "corresponding", "to", "this", "timezone", ".", "There", "may", "not", "be", "a", "match", "at", "all", "and", "there", "may", "be", "multiple", "matches", ".", "If", "so", "we", "return", "a", "random", "...
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/properties.py#L560-L603
train
ecederstrand/exchangelib
exchangelib/protocol.py
BaseProtocol.decrease_poolsize
def decrease_poolsize(self): """Decreases the session pool size in response to error messages from the server requesting to rate-limit requests. We decrease by one session per call. """ # Take a single session from the pool and discard it. We need to protect this with a lock while we are...
python
def decrease_poolsize(self): """Decreases the session pool size in response to error messages from the server requesting to rate-limit requests. We decrease by one session per call. """ # Take a single session from the pool and discard it. We need to protect this with a lock while we are...
[ "def", "decrease_poolsize", "(", "self", ")", ":", "if", "self", ".", "_session_pool_size", "<=", "1", ":", "raise", "SessionPoolMinSizeReached", "(", "'Session pool size cannot be decreased further'", ")", "with", "self", ".", "_session_pool_lock", ":", "if", "self",...
Decreases the session pool size in response to error messages from the server requesting to rate-limit requests. We decrease by one session per call.
[ "Decreases", "the", "session", "pool", "size", "in", "response", "to", "error", "messages", "from", "the", "server", "requesting", "to", "rate", "-", "limit", "requests", ".", "We", "decrease", "by", "one", "session", "per", "call", "." ]
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/protocol.py#L100-L115
train
ecederstrand/exchangelib
exchangelib/util.py
is_iterable
def is_iterable(value, generators_allowed=False): """ Checks if value is a list-like object. Don't match generators and generator-like objects here by default, because callers don't necessarily guarantee that they only iterate the value once. Take care to not match string types and bytes. :param va...
python
def is_iterable(value, generators_allowed=False): """ Checks if value is a list-like object. Don't match generators and generator-like objects here by default, because callers don't necessarily guarantee that they only iterate the value once. Take care to not match string types and bytes. :param va...
[ "def", "is_iterable", "(", "value", ",", "generators_allowed", "=", "False", ")", ":", "if", "generators_allowed", ":", "if", "not", "isinstance", "(", "value", ",", "string_types", "+", "(", "bytes", ",", ")", ")", "and", "hasattr", "(", "value", ",", "...
Checks if value is a list-like object. Don't match generators and generator-like objects here by default, because callers don't necessarily guarantee that they only iterate the value once. Take care to not match string types and bytes. :param value: any type of object :param generators_allowed: if True...
[ "Checks", "if", "value", "is", "a", "list", "-", "like", "object", ".", "Don", "t", "match", "generators", "and", "generator", "-", "like", "objects", "here", "by", "default", "because", "callers", "don", "t", "necessarily", "guarantee", "that", "they", "o...
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/util.py#L64-L80
train
ecederstrand/exchangelib
exchangelib/util.py
chunkify
def chunkify(iterable, chunksize): """ Splits an iterable into chunks of size ``chunksize``. The last chunk may be smaller than ``chunksize``. """ from .queryset import QuerySet if hasattr(iterable, '__getitem__') and not isinstance(iterable, QuerySet): # tuple, list. QuerySet has __getitem_...
python
def chunkify(iterable, chunksize): """ Splits an iterable into chunks of size ``chunksize``. The last chunk may be smaller than ``chunksize``. """ from .queryset import QuerySet if hasattr(iterable, '__getitem__') and not isinstance(iterable, QuerySet): # tuple, list. QuerySet has __getitem_...
[ "def", "chunkify", "(", "iterable", ",", "chunksize", ")", ":", "from", ".", "queryset", "import", "QuerySet", "if", "hasattr", "(", "iterable", ",", "'__getitem__'", ")", "and", "not", "isinstance", "(", "iterable", ",", "QuerySet", ")", ":", "for", "i", ...
Splits an iterable into chunks of size ``chunksize``. The last chunk may be smaller than ``chunksize``.
[ "Splits", "an", "iterable", "into", "chunks", "of", "size", "chunksize", ".", "The", "last", "chunk", "may", "be", "smaller", "than", "chunksize", "." ]
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/util.py#L83-L101
train
ecederstrand/exchangelib
exchangelib/util.py
peek
def peek(iterable): """ Checks if an iterable is empty and returns status and the rewinded iterable """ from .queryset import QuerySet if isinstance(iterable, QuerySet): # QuerySet has __len__ but that evaluates the entire query greedily. We don't want that here. Instead, peek() # sh...
python
def peek(iterable): """ Checks if an iterable is empty and returns status and the rewinded iterable """ from .queryset import QuerySet if isinstance(iterable, QuerySet): # QuerySet has __len__ but that evaluates the entire query greedily. We don't want that here. Instead, peek() # sh...
[ "def", "peek", "(", "iterable", ")", ":", "from", ".", "queryset", "import", "QuerySet", "if", "isinstance", "(", "iterable", ",", "QuerySet", ")", ":", "raise", "ValueError", "(", "'Cannot peek on a QuerySet'", ")", "if", "hasattr", "(", "iterable", ",", "'...
Checks if an iterable is empty and returns status and the rewinded iterable
[ "Checks", "if", "an", "iterable", "is", "empty", "and", "returns", "status", "and", "the", "rewinded", "iterable" ]
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/util.py#L104-L122
train
ecederstrand/exchangelib
exchangelib/util.py
xml_to_str
def xml_to_str(tree, encoding=None, xml_declaration=False): """Serialize an XML tree. Returns unicode if 'encoding' is None. Otherwise, we return encoded 'bytes'.""" if xml_declaration and not encoding: raise ValueError("'xml_declaration' is not supported when 'encoding' is None") if encoding: ...
python
def xml_to_str(tree, encoding=None, xml_declaration=False): """Serialize an XML tree. Returns unicode if 'encoding' is None. Otherwise, we return encoded 'bytes'.""" if xml_declaration and not encoding: raise ValueError("'xml_declaration' is not supported when 'encoding' is None") if encoding: ...
[ "def", "xml_to_str", "(", "tree", ",", "encoding", "=", "None", ",", "xml_declaration", "=", "False", ")", ":", "if", "xml_declaration", "and", "not", "encoding", ":", "raise", "ValueError", "(", "\"'xml_declaration' is not supported when 'encoding' is None\"", ")", ...
Serialize an XML tree. Returns unicode if 'encoding' is None. Otherwise, we return encoded 'bytes'.
[ "Serialize", "an", "XML", "tree", ".", "Returns", "unicode", "if", "encoding", "is", "None", ".", "Otherwise", "we", "return", "encoded", "bytes", "." ]
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/util.py#L125-L131
train
ecederstrand/exchangelib
exchangelib/util.py
is_xml
def is_xml(text): """ Helper function. Lightweight test if response is an XML doc """ # BOM_UTF8 is an UTF-8 byte order mark which may precede the XML from an Exchange server bom_len = len(BOM_UTF8) if text[:bom_len] == BOM_UTF8: return text[bom_len:bom_len + 5] == b'<?xml' return te...
python
def is_xml(text): """ Helper function. Lightweight test if response is an XML doc """ # BOM_UTF8 is an UTF-8 byte order mark which may precede the XML from an Exchange server bom_len = len(BOM_UTF8) if text[:bom_len] == BOM_UTF8: return text[bom_len:bom_len + 5] == b'<?xml' return te...
[ "def", "is_xml", "(", "text", ")", ":", "bom_len", "=", "len", "(", "BOM_UTF8", ")", "if", "text", "[", ":", "bom_len", "]", "==", "BOM_UTF8", ":", "return", "text", "[", "bom_len", ":", "bom_len", "+", "5", "]", "==", "b'<?xml'", "return", "text", ...
Helper function. Lightweight test if response is an XML doc
[ "Helper", "function", ".", "Lightweight", "test", "if", "response", "is", "an", "XML", "doc" ]
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/util.py#L391-L399
train
ecederstrand/exchangelib
exchangelib/services.py
GetItem.call
def call(self, items, additional_fields, shape): """ Returns all items in an account that correspond to a list of ID's, in stable order. :param items: a list of (id, changekey) tuples or Item objects :param additional_fields: the extra fields that should be returned with the item, as Fi...
python
def call(self, items, additional_fields, shape): """ Returns all items in an account that correspond to a list of ID's, in stable order. :param items: a list of (id, changekey) tuples or Item objects :param additional_fields: the extra fields that should be returned with the item, as Fi...
[ "def", "call", "(", "self", ",", "items", ",", "additional_fields", ",", "shape", ")", ":", "return", "self", ".", "_pool_requests", "(", "payload_func", "=", "self", ".", "get_payload", ",", "**", "dict", "(", "items", "=", "items", ",", "additional_field...
Returns all items in an account that correspond to a list of ID's, in stable order. :param items: a list of (id, changekey) tuples or Item objects :param additional_fields: the extra fields that should be returned with the item, as FieldPath objects :param shape: The shape of returned objects ...
[ "Returns", "all", "items", "in", "an", "account", "that", "correspond", "to", "a", "list", "of", "ID", "s", "in", "stable", "order", "." ]
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/services.py#L689-L702
train
ecederstrand/exchangelib
exchangelib/services.py
FindFolder.call
def call(self, additional_fields, restriction, shape, depth, max_items, offset): """ Find subfolders of a folder. :param additional_fields: the extra fields that should be returned with the folder, as FieldPath objects :param shape: The set of attributes to return :param depth: ...
python
def call(self, additional_fields, restriction, shape, depth, max_items, offset): """ Find subfolders of a folder. :param additional_fields: the extra fields that should be returned with the folder, as FieldPath objects :param shape: The set of attributes to return :param depth: ...
[ "def", "call", "(", "self", ",", "additional_fields", ",", "restriction", ",", "shape", ",", "depth", ",", "max_items", ",", "offset", ")", ":", "from", ".", "folders", "import", "Folder", "roots", "=", "{", "f", ".", "root", "for", "f", "in", "self", ...
Find subfolders of a folder. :param additional_fields: the extra fields that should be returned with the folder, as FieldPath objects :param shape: The set of attributes to return :param depth: How deep in the folder structure to search for folders :param max_items: The maximum number o...
[ "Find", "subfolders", "of", "a", "folder", "." ]
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/services.py#L1067-L1094
train
ecederstrand/exchangelib
exchangelib/services.py
GetFolder.call
def call(self, folders, additional_fields, shape): """ Takes a folder ID and returns the full information for that folder. :param folders: a list of Folder objects :param additional_fields: the extra fields that should be returned with the folder, as FieldPath objects :param sha...
python
def call(self, folders, additional_fields, shape): """ Takes a folder ID and returns the full information for that folder. :param folders: a list of Folder objects :param additional_fields: the extra fields that should be returned with the folder, as FieldPath objects :param sha...
[ "def", "call", "(", "self", ",", "folders", ",", "additional_fields", ",", "shape", ")", ":", "from", ".", "folders", "import", "Folder", ",", "DistinguishedFolderId", ",", "RootOfHierarchy", "folders_list", "=", "list", "(", "folders", ")", "for", "folder", ...
Takes a folder ID and returns the full information for that folder. :param folders: a list of Folder objects :param additional_fields: the extra fields that should be returned with the folder, as FieldPath objects :param shape: The set of attributes to return :return: XML elements for t...
[ "Takes", "a", "folder", "ID", "and", "returns", "the", "full", "information", "for", "that", "folder", "." ]
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/services.py#L1132-L1172
train
ecederstrand/exchangelib
exchangelib/services.py
UploadItems.get_payload
def get_payload(self, items): """Upload given items to given account data is an iterable of tuples where the first element is a Folder instance representing the ParentFolder that the item will be placed in and the second element is a Data string returned from an ExportItems call...
python
def get_payload(self, items): """Upload given items to given account data is an iterable of tuples where the first element is a Folder instance representing the ParentFolder that the item will be placed in and the second element is a Data string returned from an ExportItems call...
[ "def", "get_payload", "(", "self", ",", "items", ")", ":", "from", ".", "properties", "import", "ParentFolderId", "uploaditems", "=", "create_element", "(", "'m:%s'", "%", "self", ".", "SERVICE_NAME", ")", "itemselement", "=", "create_element", "(", "'m:Items'",...
Upload given items to given account data is an iterable of tuples where the first element is a Folder instance representing the ParentFolder that the item will be placed in and the second element is a Data string returned from an ExportItems call.
[ "Upload", "given", "items", "to", "given", "account" ]
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/services.py#L1880-L1898
train
ecederstrand/exchangelib
exchangelib/folders.py
FolderCollection.find_items
def find_items(self, q, shape=ID_ONLY, depth=SHALLOW, additional_fields=None, order_fields=None, calendar_view=None, page_size=None, max_items=None, offset=0): """ Private method to call the FindItem service :param q: a Q instance containing any restrictions :param sh...
python
def find_items(self, q, shape=ID_ONLY, depth=SHALLOW, additional_fields=None, order_fields=None, calendar_view=None, page_size=None, max_items=None, offset=0): """ Private method to call the FindItem service :param q: a Q instance containing any restrictions :param sh...
[ "def", "find_items", "(", "self", ",", "q", ",", "shape", "=", "ID_ONLY", ",", "depth", "=", "SHALLOW", ",", "additional_fields", "=", "None", ",", "order_fields", "=", "None", ",", "calendar_view", "=", "None", ",", "page_size", "=", "None", ",", "max_i...
Private method to call the FindItem service :param q: a Q instance containing any restrictions :param shape: controls whether to return (id, chanegkey) tuples or Item objects. If additional_fields is non-null, we always return Item objects. :param depth: controls the whether to r...
[ "Private", "method", "to", "call", "the", "FindItem", "service" ]
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/folders.py#L185-L257
train
ecederstrand/exchangelib
exchangelib/folders.py
RootOfHierarchy.get_distinguished
def get_distinguished(cls, account): """Gets the distinguished folder for this folder class""" if not cls.DISTINGUISHED_FOLDER_ID: raise ValueError('Class %s must have a DISTINGUISHED_FOLDER_ID value' % cls) folders = list(FolderCollection( account=account, fo...
python
def get_distinguished(cls, account): """Gets the distinguished folder for this folder class""" if not cls.DISTINGUISHED_FOLDER_ID: raise ValueError('Class %s must have a DISTINGUISHED_FOLDER_ID value' % cls) folders = list(FolderCollection( account=account, fo...
[ "def", "get_distinguished", "(", "cls", ",", "account", ")", ":", "if", "not", "cls", ".", "DISTINGUISHED_FOLDER_ID", ":", "raise", "ValueError", "(", "'Class %s must have a DISTINGUISHED_FOLDER_ID value'", "%", "cls", ")", "folders", "=", "list", "(", "FolderCollec...
Gets the distinguished folder for this folder class
[ "Gets", "the", "distinguished", "folder", "for", "this", "folder", "class" ]
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/folders.py#L1489-L1507
train
ecederstrand/exchangelib
exchangelib/folders.py
RootOfHierarchy.folder_cls_from_folder_name
def folder_cls_from_folder_name(cls, folder_name, locale): """Returns the folder class that matches a localized folder name. locale is a string, e.g. 'da_DK' """ for folder_cls in cls.WELLKNOWN_FOLDERS + NON_DELETEABLE_FOLDERS: if folder_name.lower() in folder_cls.localized_...
python
def folder_cls_from_folder_name(cls, folder_name, locale): """Returns the folder class that matches a localized folder name. locale is a string, e.g. 'da_DK' """ for folder_cls in cls.WELLKNOWN_FOLDERS + NON_DELETEABLE_FOLDERS: if folder_name.lower() in folder_cls.localized_...
[ "def", "folder_cls_from_folder_name", "(", "cls", ",", "folder_name", ",", "locale", ")", ":", "for", "folder_cls", "in", "cls", ".", "WELLKNOWN_FOLDERS", "+", "NON_DELETEABLE_FOLDERS", ":", "if", "folder_name", ".", "lower", "(", ")", "in", "folder_cls", ".", ...
Returns the folder class that matches a localized folder name. locale is a string, e.g. 'da_DK'
[ "Returns", "the", "folder", "class", "that", "matches", "a", "localized", "folder", "name", "." ]
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/folders.py#L1594-L1602
train
ecederstrand/exchangelib
exchangelib/items.py
RegisterMixIn.register
def register(cls, attr_name, attr_cls): """ Register a custom extended property in this item class so they can be accessed just like any other attribute """ if not cls.INSERT_AFTER_FIELD: raise ValueError('Class %s is missing INSERT_AFTER_FIELD value' % cls) try: ...
python
def register(cls, attr_name, attr_cls): """ Register a custom extended property in this item class so they can be accessed just like any other attribute """ if not cls.INSERT_AFTER_FIELD: raise ValueError('Class %s is missing INSERT_AFTER_FIELD value' % cls) try: ...
[ "def", "register", "(", "cls", ",", "attr_name", ",", "attr_cls", ")", ":", "if", "not", "cls", ".", "INSERT_AFTER_FIELD", ":", "raise", "ValueError", "(", "'Class %s is missing INSERT_AFTER_FIELD value'", "%", "cls", ")", "try", ":", "cls", ".", "get_field_by_f...
Register a custom extended property in this item class so they can be accessed just like any other attribute
[ "Register", "a", "custom", "extended", "property", "in", "this", "item", "class", "so", "they", "can", "be", "accessed", "just", "like", "any", "other", "attribute" ]
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/items.py#L92-L113
train
ecederstrand/exchangelib
exchangelib/items.py
Item.attach
def attach(self, attachments): """Add an attachment, or a list of attachments, to this item. If the item has already been saved, the attachments will be created on the server immediately. If the item has not yet been saved, the attachments will be created on the server the item is saved. ...
python
def attach(self, attachments): """Add an attachment, or a list of attachments, to this item. If the item has already been saved, the attachments will be created on the server immediately. If the item has not yet been saved, the attachments will be created on the server the item is saved. ...
[ "def", "attach", "(", "self", ",", "attachments", ")", ":", "if", "not", "is_iterable", "(", "attachments", ",", "generators_allowed", "=", "True", ")", ":", "attachments", "=", "[", "attachments", "]", "for", "a", "in", "attachments", ":", "if", "not", ...
Add an attachment, or a list of attachments, to this item. If the item has already been saved, the attachments will be created on the server immediately. If the item has not yet been saved, the attachments will be created on the server the item is saved. Adding attachments to an existing item w...
[ "Add", "an", "attachment", "or", "a", "list", "of", "attachments", "to", "this", "item", ".", "If", "the", "item", "has", "already", "been", "saved", "the", "attachments", "will", "be", "created", "on", "the", "server", "immediately", ".", "If", "the", "...
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/items.py#L426-L442
train
ecederstrand/exchangelib
exchangelib/items.py
Item.detach
def detach(self, attachments): """Remove an attachment, or a list of attachments, from this item. If the item has already been saved, the attachments will be deleted on the server immediately. If the item has not yet been saved, the attachments will simply not be created on the server the item i...
python
def detach(self, attachments): """Remove an attachment, or a list of attachments, from this item. If the item has already been saved, the attachments will be deleted on the server immediately. If the item has not yet been saved, the attachments will simply not be created on the server the item i...
[ "def", "detach", "(", "self", ",", "attachments", ")", ":", "if", "not", "is_iterable", "(", "attachments", ",", "generators_allowed", "=", "True", ")", ":", "attachments", "=", "[", "attachments", "]", "for", "a", "in", "attachments", ":", "if", "a", "....
Remove an attachment, or a list of attachments, from this item. If the item has already been saved, the attachments will be deleted on the server immediately. If the item has not yet been saved, the attachments will simply not be created on the server the item is saved. Removing attachments fro...
[ "Remove", "an", "attachment", "or", "a", "list", "of", "attachments", "from", "this", "item", ".", "If", "the", "item", "has", "already", "been", "saved", "the", "attachments", "will", "be", "deleted", "on", "the", "server", "immediately", ".", "If", "the"...
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/items.py#L444-L460
train
ecederstrand/exchangelib
exchangelib/credentials.py
ServiceAccount.back_off_until
def back_off_until(self): """Returns the back off value as a datetime. Resets the current back off value if it has expired.""" if self._back_off_until is None: return None with self._back_off_lock: if self._back_off_until is None: return None i...
python
def back_off_until(self): """Returns the back off value as a datetime. Resets the current back off value if it has expired.""" if self._back_off_until is None: return None with self._back_off_lock: if self._back_off_until is None: return None i...
[ "def", "back_off_until", "(", "self", ")", ":", "if", "self", ".", "_back_off_until", "is", "None", ":", "return", "None", "with", "self", ".", "_back_off_lock", ":", "if", "self", ".", "_back_off_until", "is", "None", ":", "return", "None", "if", "self", ...
Returns the back off value as a datetime. Resets the current back off value if it has expired.
[ "Returns", "the", "back", "off", "value", "as", "a", "datetime", ".", "Resets", "the", "current", "back", "off", "value", "if", "it", "has", "expired", "." ]
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/credentials.py#L103-L113
train
ecederstrand/exchangelib
exchangelib/winzone.py
generate_map
def generate_map(timeout=10): """ Helper method to update the map if the CLDR database is updated """ r = requests.get(CLDR_WINZONE_URL, timeout=timeout) if r.status_code != 200: raise ValueError('Unexpected response: %s' % r) tz_map = {} for e in to_xml(r.content).find('windowsZones').find(...
python
def generate_map(timeout=10): """ Helper method to update the map if the CLDR database is updated """ r = requests.get(CLDR_WINZONE_URL, timeout=timeout) if r.status_code != 200: raise ValueError('Unexpected response: %s' % r) tz_map = {} for e in to_xml(r.content).find('windowsZones').find(...
[ "def", "generate_map", "(", "timeout", "=", "10", ")", ":", "r", "=", "requests", ".", "get", "(", "CLDR_WINZONE_URL", ",", "timeout", "=", "timeout", ")", "if", "r", ".", "status_code", "!=", "200", ":", "raise", "ValueError", "(", "'Unexpected response: ...
Helper method to update the map if the CLDR database is updated
[ "Helper", "method", "to", "update", "the", "map", "if", "the", "CLDR", "database", "is", "updated" ]
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/winzone.py#L11-L23
train
tanghaibao/goatools
scripts/compare_gos.py
run
def run(): """Compare two or more sets of GO IDs. Best done using sections.""" obj = CompareGOsCli() obj.write(obj.kws.get('xlsx'), obj.kws.get('ofile'), obj.kws.get('verbose', False))
python
def run(): """Compare two or more sets of GO IDs. Best done using sections.""" obj = CompareGOsCli() obj.write(obj.kws.get('xlsx'), obj.kws.get('ofile'), obj.kws.get('verbose', False))
[ "def", "run", "(", ")", ":", "obj", "=", "CompareGOsCli", "(", ")", "obj", ".", "write", "(", "obj", ".", "kws", ".", "get", "(", "'xlsx'", ")", ",", "obj", ".", "kws", ".", "get", "(", "'ofile'", ")", ",", "obj", ".", "kws", ".", "get", "(",...
Compare two or more sets of GO IDs. Best done using sections.
[ "Compare", "two", "or", "more", "sets", "of", "GO", "IDs", ".", "Best", "done", "using", "sections", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/scripts/compare_gos.py#L10-L13
train
tanghaibao/goatools
goatools/grouper/sorter_gos.py
SorterGoIds.sortby
def sortby(self, ntd): """Return function for sorting.""" if 'reldepth' in self.grprobj.gosubdag.prt_attr['flds']: return [ntd.NS, -1*ntd.dcnt, ntd.reldepth] else: return [ntd.NS, -1*ntd.dcnt, ntd.depth]
python
def sortby(self, ntd): """Return function for sorting.""" if 'reldepth' in self.grprobj.gosubdag.prt_attr['flds']: return [ntd.NS, -1*ntd.dcnt, ntd.reldepth] else: return [ntd.NS, -1*ntd.dcnt, ntd.depth]
[ "def", "sortby", "(", "self", ",", "ntd", ")", ":", "if", "'reldepth'", "in", "self", ".", "grprobj", ".", "gosubdag", ".", "prt_attr", "[", "'flds'", "]", ":", "return", "[", "ntd", ".", "NS", ",", "-", "1", "*", "ntd", ".", "dcnt", ",", "ntd", ...
Return function for sorting.
[ "Return", "function", "for", "sorting", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/sorter_gos.py#L33-L38
train
tanghaibao/goatools
goatools/grouper/sorter_gos.py
SorterGoIds.get_nts_sorted
def get_nts_sorted(self, hdrgo_prt, hdrgos, hdrgo_sort): """Return a flat list of grouped and sorted GO terms.""" nts_flat = [] self.get_sorted_hdrgo2usrgos(hdrgos, nts_flat, hdrgo_prt, hdrgo_sort) return nts_flat
python
def get_nts_sorted(self, hdrgo_prt, hdrgos, hdrgo_sort): """Return a flat list of grouped and sorted GO terms.""" nts_flat = [] self.get_sorted_hdrgo2usrgos(hdrgos, nts_flat, hdrgo_prt, hdrgo_sort) return nts_flat
[ "def", "get_nts_sorted", "(", "self", ",", "hdrgo_prt", ",", "hdrgos", ",", "hdrgo_sort", ")", ":", "nts_flat", "=", "[", "]", "self", ".", "get_sorted_hdrgo2usrgos", "(", "hdrgos", ",", "nts_flat", ",", "hdrgo_prt", ",", "hdrgo_sort", ")", "return", "nts_fl...
Return a flat list of grouped and sorted GO terms.
[ "Return", "a", "flat", "list", "of", "grouped", "and", "sorted", "GO", "terms", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/sorter_gos.py#L64-L68
train
tanghaibao/goatools
goatools/grouper/sorter_gos.py
SorterGoIds.get_sorted_hdrgo2usrgos
def get_sorted_hdrgo2usrgos(self, hdrgos, flat_list=None, hdrgo_prt=True, hdrgo_sort=True): """Return GO IDs sorting using go2nt's namedtuple.""" # Return user-specfied sort or default sort of header and user GO IDs sorted_hdrgos_usrgos = [] h2u_get = self.grprobj.hdrgo2usrgos.get ...
python
def get_sorted_hdrgo2usrgos(self, hdrgos, flat_list=None, hdrgo_prt=True, hdrgo_sort=True): """Return GO IDs sorting using go2nt's namedtuple.""" # Return user-specfied sort or default sort of header and user GO IDs sorted_hdrgos_usrgos = [] h2u_get = self.grprobj.hdrgo2usrgos.get ...
[ "def", "get_sorted_hdrgo2usrgos", "(", "self", ",", "hdrgos", ",", "flat_list", "=", "None", ",", "hdrgo_prt", "=", "True", ",", "hdrgo_sort", "=", "True", ")", ":", "sorted_hdrgos_usrgos", "=", "[", "]", "h2u_get", "=", "self", ".", "grprobj", ".", "hdrgo...
Return GO IDs sorting using go2nt's namedtuple.
[ "Return", "GO", "IDs", "sorting", "using", "go2nt", "s", "namedtuple", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/sorter_gos.py#L70-L94
train
tanghaibao/goatools
goatools/grouper/sorter_gos.py
SorterGoIds._get_go2nt
def _get_go2nt(self, goids): """Get go2nt for given goids.""" go2nt_all = self.grprobj.go2nt return {go:go2nt_all[go] for go in goids}
python
def _get_go2nt(self, goids): """Get go2nt for given goids.""" go2nt_all = self.grprobj.go2nt return {go:go2nt_all[go] for go in goids}
[ "def", "_get_go2nt", "(", "self", ",", "goids", ")", ":", "go2nt_all", "=", "self", ".", "grprobj", ".", "go2nt", "return", "{", "go", ":", "go2nt_all", "[", "go", "]", "for", "go", "in", "goids", "}" ]
Get go2nt for given goids.
[ "Get", "go2nt", "for", "given", "goids", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/sorter_gos.py#L96-L99
train
tanghaibao/goatools
goatools/grouper/sorter_gos.py
SorterGoIds._init_hdrgo_sortby
def _init_hdrgo_sortby(self, hdrgo_sortby, sortby): """Initialize header sort function.""" if hdrgo_sortby is not None: return hdrgo_sortby if sortby is not None: return sortby return self.sortby
python
def _init_hdrgo_sortby(self, hdrgo_sortby, sortby): """Initialize header sort function.""" if hdrgo_sortby is not None: return hdrgo_sortby if sortby is not None: return sortby return self.sortby
[ "def", "_init_hdrgo_sortby", "(", "self", ",", "hdrgo_sortby", ",", "sortby", ")", ":", "if", "hdrgo_sortby", "is", "not", "None", ":", "return", "hdrgo_sortby", "if", "sortby", "is", "not", "None", ":", "return", "sortby", "return", "self", ".", "sortby" ]
Initialize header sort function.
[ "Initialize", "header", "sort", "function", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/sorter_gos.py#L101-L107
train
tanghaibao/goatools
goatools/godag_plot.py
plot_goid2goobj
def plot_goid2goobj(fout_png, goid2goobj, *args, **kws): """Given a dict containing GO id and its goobj, create a plot of paths from GO ids.""" engine = kws['engine'] if 'engine' in kws else 'pydot' godagsmall = OboToGoDagSmall(goid2goobj=goid2goobj).godag godagplot = GODagSmallPlot(godagsmall, *args, *...
python
def plot_goid2goobj(fout_png, goid2goobj, *args, **kws): """Given a dict containing GO id and its goobj, create a plot of paths from GO ids.""" engine = kws['engine'] if 'engine' in kws else 'pydot' godagsmall = OboToGoDagSmall(goid2goobj=goid2goobj).godag godagplot = GODagSmallPlot(godagsmall, *args, *...
[ "def", "plot_goid2goobj", "(", "fout_png", ",", "goid2goobj", ",", "*", "args", ",", "**", "kws", ")", ":", "engine", "=", "kws", "[", "'engine'", "]", "if", "'engine'", "in", "kws", "else", "'pydot'", "godagsmall", "=", "OboToGoDagSmall", "(", "goid2goobj...
Given a dict containing GO id and its goobj, create a plot of paths from GO ids.
[ "Given", "a", "dict", "containing", "GO", "id", "and", "its", "goobj", "create", "a", "plot", "of", "paths", "from", "GO", "ids", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag_plot.py#L19-L24
train
tanghaibao/goatools
goatools/godag_plot.py
GODagSmallPlot._init_study_items_max
def _init_study_items_max(self): """User can limit the number of genes printed in a GO term.""" if self.study_items is None: return None if self.study_items is True: return None if isinstance(self.study_items, int): return self.study_items retu...
python
def _init_study_items_max(self): """User can limit the number of genes printed in a GO term.""" if self.study_items is None: return None if self.study_items is True: return None if isinstance(self.study_items, int): return self.study_items retu...
[ "def", "_init_study_items_max", "(", "self", ")", ":", "if", "self", ".", "study_items", "is", "None", ":", "return", "None", "if", "self", ".", "study_items", "is", "True", ":", "return", "None", "if", "isinstance", "(", "self", ".", "study_items", ",", ...
User can limit the number of genes printed in a GO term.
[ "User", "can", "limit", "the", "number", "of", "genes", "printed", "in", "a", "GO", "term", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag_plot.py#L105-L113
train
tanghaibao/goatools
goatools/godag_plot.py
GODagSmallPlot._init_go2res
def _init_go2res(**kws): """Initialize GOEA results.""" if 'goea_results' in kws: return {res.GO:res for res in kws['goea_results']} if 'go2nt' in kws: return kws['go2nt']
python
def _init_go2res(**kws): """Initialize GOEA results.""" if 'goea_results' in kws: return {res.GO:res for res in kws['goea_results']} if 'go2nt' in kws: return kws['go2nt']
[ "def", "_init_go2res", "(", "**", "kws", ")", ":", "if", "'goea_results'", "in", "kws", ":", "return", "{", "res", ".", "GO", ":", "res", "for", "res", "in", "kws", "[", "'goea_results'", "]", "}", "if", "'go2nt'", "in", "kws", ":", "return", "kws", ...
Initialize GOEA results.
[ "Initialize", "GOEA", "results", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag_plot.py#L116-L121
train
tanghaibao/goatools
goatools/godag_plot.py
GODagSmallPlot._get_pydot
def _get_pydot(self): """Return pydot package. Load pydot, if necessary.""" if self.pydot: return self.pydot self.pydot = __import__("pydot") return self.pydot
python
def _get_pydot(self): """Return pydot package. Load pydot, if necessary.""" if self.pydot: return self.pydot self.pydot = __import__("pydot") return self.pydot
[ "def", "_get_pydot", "(", "self", ")", ":", "if", "self", ".", "pydot", ":", "return", "self", ".", "pydot", "self", ".", "pydot", "=", "__import__", "(", "\"pydot\"", ")", "return", "self", ".", "pydot" ]
Return pydot package. Load pydot, if necessary.
[ "Return", "pydot", "package", ".", "Load", "pydot", "if", "necessary", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag_plot.py#L217-L222
train
tanghaibao/goatools
goatools/wr_tbl.py
wr_xlsx
def wr_xlsx(fout_xlsx, data_xlsx, **kws): """Write a spreadsheet into a xlsx file.""" from goatools.wr_tbl_class import WrXlsx # optional keyword args: fld2col_widths hdrs prt_if sort_by fld2fmt prt_flds items_str = kws.get("items", "items") if "items" not in kws else kws["items"] if data_xlsx: ...
python
def wr_xlsx(fout_xlsx, data_xlsx, **kws): """Write a spreadsheet into a xlsx file.""" from goatools.wr_tbl_class import WrXlsx # optional keyword args: fld2col_widths hdrs prt_if sort_by fld2fmt prt_flds items_str = kws.get("items", "items") if "items" not in kws else kws["items"] if data_xlsx: ...
[ "def", "wr_xlsx", "(", "fout_xlsx", ",", "data_xlsx", ",", "**", "kws", ")", ":", "from", "goatools", ".", "wr_tbl_class", "import", "WrXlsx", "items_str", "=", "kws", ".", "get", "(", "\"items\"", ",", "\"items\"", ")", "if", "\"items\"", "not", "in", "...
Write a spreadsheet into a xlsx file.
[ "Write", "a", "spreadsheet", "into", "a", "xlsx", "file", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl.py#L63-L84
train
tanghaibao/goatools
goatools/wr_tbl.py
wr_xlsx_sections
def wr_xlsx_sections(fout_xlsx, xlsx_data, **kws): """Write xlsx file containing section names followed by lines of namedtuple data.""" from goatools.wr_tbl_class import WrXlsx items_str = "items" if "items" not in kws else kws["items"] prt_hdr_min = 10 num_items = 0 if xlsx_data: # Basi...
python
def wr_xlsx_sections(fout_xlsx, xlsx_data, **kws): """Write xlsx file containing section names followed by lines of namedtuple data.""" from goatools.wr_tbl_class import WrXlsx items_str = "items" if "items" not in kws else kws["items"] prt_hdr_min = 10 num_items = 0 if xlsx_data: # Basi...
[ "def", "wr_xlsx_sections", "(", "fout_xlsx", ",", "xlsx_data", ",", "**", "kws", ")", ":", "from", "goatools", ".", "wr_tbl_class", "import", "WrXlsx", "items_str", "=", "\"items\"", "if", "\"items\"", "not", "in", "kws", "else", "kws", "[", "\"items\"", "]"...
Write xlsx file containing section names followed by lines of namedtuple data.
[ "Write", "xlsx", "file", "containing", "section", "names", "followed", "by", "lines", "of", "namedtuple", "data", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl.py#L86-L117
train
tanghaibao/goatools
goatools/wr_tbl.py
wr_tsv
def wr_tsv(fout_tsv, tsv_data, **kws): """Write a file of tab-separated table data""" items_str = "items" if "items" not in kws else kws["items"] if tsv_data: ifstrm = sys.stdout if fout_tsv is None else open(fout_tsv, 'w') num_items = prt_tsv(ifstrm, tsv_data, **kws) if fout_tsv is ...
python
def wr_tsv(fout_tsv, tsv_data, **kws): """Write a file of tab-separated table data""" items_str = "items" if "items" not in kws else kws["items"] if tsv_data: ifstrm = sys.stdout if fout_tsv is None else open(fout_tsv, 'w') num_items = prt_tsv(ifstrm, tsv_data, **kws) if fout_tsv is ...
[ "def", "wr_tsv", "(", "fout_tsv", ",", "tsv_data", ",", "**", "kws", ")", ":", "items_str", "=", "\"items\"", "if", "\"items\"", "not", "in", "kws", "else", "kws", "[", "\"items\"", "]", "if", "tsv_data", ":", "ifstrm", "=", "sys", ".", "stdout", "if",...
Write a file of tab-separated table data
[ "Write", "a", "file", "of", "tab", "-", "separated", "table", "data" ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl.py#L119-L131
train
tanghaibao/goatools
goatools/wr_tbl.py
prt_tsv_sections
def prt_tsv_sections(prt, tsv_data, **kws): """Write tsv file containing section names followed by lines of namedtuple data.""" prt_hdr_min = 10 # Print hdr on the 1st section and for any following 'large' sections num_items = 0 if tsv_data: # Basic data checks assert len(tsv_data[0]) =...
python
def prt_tsv_sections(prt, tsv_data, **kws): """Write tsv file containing section names followed by lines of namedtuple data.""" prt_hdr_min = 10 # Print hdr on the 1st section and for any following 'large' sections num_items = 0 if tsv_data: # Basic data checks assert len(tsv_data[0]) =...
[ "def", "prt_tsv_sections", "(", "prt", ",", "tsv_data", ",", "**", "kws", ")", ":", "prt_hdr_min", "=", "10", "num_items", "=", "0", "if", "tsv_data", ":", "assert", "len", "(", "tsv_data", "[", "0", "]", ")", "==", "2", ",", "\"wr_tsv_sections EXPECTED:...
Write tsv file containing section names followed by lines of namedtuple data.
[ "Write", "tsv", "file", "containing", "section", "names", "followed", "by", "lines", "of", "namedtuple", "data", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl.py#L133-L155
train
tanghaibao/goatools
goatools/wr_tbl.py
prt_tsv
def prt_tsv(prt, data_nts, **kws): """Print tab-separated table headers and data""" # User-controlled printing options prt_tsv_hdr(prt, data_nts, **kws) return prt_tsv_dat(prt, data_nts, **kws)
python
def prt_tsv(prt, data_nts, **kws): """Print tab-separated table headers and data""" # User-controlled printing options prt_tsv_hdr(prt, data_nts, **kws) return prt_tsv_dat(prt, data_nts, **kws)
[ "def", "prt_tsv", "(", "prt", ",", "data_nts", ",", "**", "kws", ")", ":", "prt_tsv_hdr", "(", "prt", ",", "data_nts", ",", "**", "kws", ")", "return", "prt_tsv_dat", "(", "prt", ",", "data_nts", ",", "**", "kws", ")" ]
Print tab-separated table headers and data
[ "Print", "tab", "-", "separated", "table", "headers", "and", "data" ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl.py#L157-L161
train
tanghaibao/goatools
goatools/wr_tbl.py
prt_tsv_hdr
def prt_tsv_hdr(prt, data_nts, **kws): """Print tab-separated table headers""" sep = "\t" if 'sep' not in kws else kws['sep'] flds_all = data_nts[0]._fields hdrs = get_hdrs(flds_all, **kws) prt.write("# {}\n".format(sep.join(hdrs)))
python
def prt_tsv_hdr(prt, data_nts, **kws): """Print tab-separated table headers""" sep = "\t" if 'sep' not in kws else kws['sep'] flds_all = data_nts[0]._fields hdrs = get_hdrs(flds_all, **kws) prt.write("# {}\n".format(sep.join(hdrs)))
[ "def", "prt_tsv_hdr", "(", "prt", ",", "data_nts", ",", "**", "kws", ")", ":", "sep", "=", "\"\\t\"", "if", "'sep'", "not", "in", "kws", "else", "kws", "[", "'sep'", "]", "flds_all", "=", "data_nts", "[", "0", "]", ".", "_fields", "hdrs", "=", "get...
Print tab-separated table headers
[ "Print", "tab", "-", "separated", "table", "headers" ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl.py#L163-L168
train
tanghaibao/goatools
goatools/wr_tbl.py
prt_tsv_dat
def prt_tsv_dat(prt, data_nts, **kws): """Print tab-separated table data""" sep = "\t" if 'sep' not in kws else kws['sep'] fld2fmt = None if 'fld2fmt' not in kws else kws['fld2fmt'] if 'sort_by' in kws: data_nts = sorted(data_nts, key=kws['sort_by']) prt_if = kws['prt_if'] if 'prt_if' in kws...
python
def prt_tsv_dat(prt, data_nts, **kws): """Print tab-separated table data""" sep = "\t" if 'sep' not in kws else kws['sep'] fld2fmt = None if 'fld2fmt' not in kws else kws['fld2fmt'] if 'sort_by' in kws: data_nts = sorted(data_nts, key=kws['sort_by']) prt_if = kws['prt_if'] if 'prt_if' in kws...
[ "def", "prt_tsv_dat", "(", "prt", ",", "data_nts", ",", "**", "kws", ")", ":", "sep", "=", "\"\\t\"", "if", "'sep'", "not", "in", "kws", "else", "kws", "[", "'sep'", "]", "fld2fmt", "=", "None", "if", "'fld2fmt'", "not", "in", "kws", "else", "kws", ...
Print tab-separated table data
[ "Print", "tab", "-", "separated", "table", "data" ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl.py#L170-L188
train
tanghaibao/goatools
goatools/wr_tbl.py
_chk_flds_fmt
def _chk_flds_fmt(nt_fields, prtfmt): """Check that all fields in the prtfmt have corresponding data in the namedtuple.""" fmtflds = get_fmtflds(prtfmt) missing_data = set(fmtflds).difference(set(nt_fields)) # All data needed for print is present, return. if not missing_data: return #rai...
python
def _chk_flds_fmt(nt_fields, prtfmt): """Check that all fields in the prtfmt have corresponding data in the namedtuple.""" fmtflds = get_fmtflds(prtfmt) missing_data = set(fmtflds).difference(set(nt_fields)) # All data needed for print is present, return. if not missing_data: return #rai...
[ "def", "_chk_flds_fmt", "(", "nt_fields", ",", "prtfmt", ")", ":", "fmtflds", "=", "get_fmtflds", "(", "prtfmt", ")", "missing_data", "=", "set", "(", "fmtflds", ")", ".", "difference", "(", "set", "(", "nt_fields", ")", ")", "if", "not", "missing_data", ...
Check that all fields in the prtfmt have corresponding data in the namedtuple.
[ "Check", "that", "all", "fields", "in", "the", "prtfmt", "have", "corresponding", "data", "in", "the", "namedtuple", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl.py#L199-L211
train
tanghaibao/goatools
goatools/wr_tbl.py
_prt_txt_hdr
def _prt_txt_hdr(prt, prtfmt): """Print header for text report.""" tblhdrs = get_fmtfldsdict(prtfmt) # If needed, reformat for format_string for header, which has strings, not floats. hdrfmt = re.sub(r':(\d+)\.\S+}', r':\1}', prtfmt) hdrfmt = re.sub(r':(0+)(\d+)}', r':\2}', hdrfmt) prt.write("#{...
python
def _prt_txt_hdr(prt, prtfmt): """Print header for text report.""" tblhdrs = get_fmtfldsdict(prtfmt) # If needed, reformat for format_string for header, which has strings, not floats. hdrfmt = re.sub(r':(\d+)\.\S+}', r':\1}', prtfmt) hdrfmt = re.sub(r':(0+)(\d+)}', r':\2}', hdrfmt) prt.write("#{...
[ "def", "_prt_txt_hdr", "(", "prt", ",", "prtfmt", ")", ":", "tblhdrs", "=", "get_fmtfldsdict", "(", "prtfmt", ")", "hdrfmt", "=", "re", ".", "sub", "(", "r':(\\d+)\\.\\S+}'", ",", "r':\\1}'", ",", "prtfmt", ")", "hdrfmt", "=", "re", ".", "sub", "(", "r...
Print header for text report.
[ "Print", "header", "for", "text", "report", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl.py#L223-L229
train
tanghaibao/goatools
goatools/wr_tbl.py
mk_fmtfld
def mk_fmtfld(nt_item, joinchr=" ", eol="\n"): """Given a namedtuple, return a format_field string.""" fldstrs = [] # Default formats based on fieldname fld2fmt = { 'hdrgo' : lambda f: "{{{FLD}:1,}}".format(FLD=f), 'dcnt' : lambda f: "{{{FLD}:6,}}".format(FLD=f), 'level' : lambda...
python
def mk_fmtfld(nt_item, joinchr=" ", eol="\n"): """Given a namedtuple, return a format_field string.""" fldstrs = [] # Default formats based on fieldname fld2fmt = { 'hdrgo' : lambda f: "{{{FLD}:1,}}".format(FLD=f), 'dcnt' : lambda f: "{{{FLD}:6,}}".format(FLD=f), 'level' : lambda...
[ "def", "mk_fmtfld", "(", "nt_item", ",", "joinchr", "=", "\" \"", ",", "eol", "=", "\"\\n\"", ")", ":", "fldstrs", "=", "[", "]", "fld2fmt", "=", "{", "'hdrgo'", ":", "lambda", "f", ":", "\"{{{FLD}:1,}}\"", ".", "format", "(", "FLD", "=", "f", ")", ...
Given a namedtuple, return a format_field string.
[ "Given", "a", "namedtuple", "return", "a", "format_field", "string", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl.py#L231-L247
train
tanghaibao/goatools
goatools/cli/compare_gos.py
CompareGOsCli._get_prtfmt
def _get_prtfmt(self, objgowr, verbose): """Get print format containing markers.""" prtfmt = objgowr.get_prtfmt('fmt') prtfmt = prtfmt.replace('# ', '') # print('PPPPPPPPPPP', prtfmt) if not verbose: prtfmt = prtfmt.replace('{hdr1usr01:2}', '') prtfmt = pr...
python
def _get_prtfmt(self, objgowr, verbose): """Get print format containing markers.""" prtfmt = objgowr.get_prtfmt('fmt') prtfmt = prtfmt.replace('# ', '') # print('PPPPPPPPPPP', prtfmt) if not verbose: prtfmt = prtfmt.replace('{hdr1usr01:2}', '') prtfmt = pr...
[ "def", "_get_prtfmt", "(", "self", ",", "objgowr", ",", "verbose", ")", ":", "prtfmt", "=", "objgowr", ".", "get_prtfmt", "(", "'fmt'", ")", "prtfmt", "=", "prtfmt", ".", "replace", "(", "'# '", ",", "''", ")", "if", "not", "verbose", ":", "prtfmt", ...
Get print format containing markers.
[ "Get", "print", "format", "containing", "markers", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/compare_gos.py#L113-L126
train
tanghaibao/goatools
goatools/cli/compare_gos.py
CompareGOsCli._wr_ver_n_key
def _wr_ver_n_key(self, fout_txt, verbose): """Write GO DAG version and key indicating presence of GO ID in a list.""" with open(fout_txt, 'w') as prt: self._prt_ver_n_key(prt, verbose) print(' WROTE: {TXT}'.format(TXT=fout_txt))
python
def _wr_ver_n_key(self, fout_txt, verbose): """Write GO DAG version and key indicating presence of GO ID in a list.""" with open(fout_txt, 'w') as prt: self._prt_ver_n_key(prt, verbose) print(' WROTE: {TXT}'.format(TXT=fout_txt))
[ "def", "_wr_ver_n_key", "(", "self", ",", "fout_txt", ",", "verbose", ")", ":", "with", "open", "(", "fout_txt", ",", "'w'", ")", "as", "prt", ":", "self", ".", "_prt_ver_n_key", "(", "prt", ",", "verbose", ")", "print", "(", "' WROTE: {TXT}'...
Write GO DAG version and key indicating presence of GO ID in a list.
[ "Write", "GO", "DAG", "version", "and", "key", "indicating", "presence", "of", "GO", "ID", "in", "a", "list", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/compare_gos.py#L153-L157
train
tanghaibao/goatools
goatools/cli/compare_gos.py
CompareGOsCli._prt_ver_n_key
def _prt_ver_n_key(self, prt, verbose): """Print GO DAG version and key indicating presence of GO ID in a list.""" pre = '# ' prt.write('# ----------------------------------------------------------------\n') prt.write('# - Description of GO ID fields\n') prt.write('# ------------...
python
def _prt_ver_n_key(self, prt, verbose): """Print GO DAG version and key indicating presence of GO ID in a list.""" pre = '# ' prt.write('# ----------------------------------------------------------------\n') prt.write('# - Description of GO ID fields\n') prt.write('# ------------...
[ "def", "_prt_ver_n_key", "(", "self", ",", "prt", ",", "verbose", ")", ":", "pre", "=", "'# '", "prt", ".", "write", "(", "'# ----------------------------------------------------------------\\n'", ")", "prt", ".", "write", "(", "'# - Description of GO ID fields\\n'", ...
Print GO DAG version and key indicating presence of GO ID in a list.
[ "Print", "GO", "DAG", "version", "and", "key", "indicating", "presence", "of", "GO", "ID", "in", "a", "list", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/compare_gos.py#L160-L197
train
tanghaibao/goatools
goatools/cli/compare_gos.py
_Init.get_grouped
def get_grouped(self, go_ntsets, go_all, gosubdag, **kws): """Get Grouped object.""" kws_grpd = {k:v for k, v in kws.items() if k in Grouped.kws_dict} kws_grpd['go2nt'] = self._init_go2ntpresent(go_ntsets, go_all, gosubdag) return Grouped(gosubdag, self.godag.version, **kws_grpd)
python
def get_grouped(self, go_ntsets, go_all, gosubdag, **kws): """Get Grouped object.""" kws_grpd = {k:v for k, v in kws.items() if k in Grouped.kws_dict} kws_grpd['go2nt'] = self._init_go2ntpresent(go_ntsets, go_all, gosubdag) return Grouped(gosubdag, self.godag.version, **kws_grpd)
[ "def", "get_grouped", "(", "self", ",", "go_ntsets", ",", "go_all", ",", "gosubdag", ",", "**", "kws", ")", ":", "kws_grpd", "=", "{", "k", ":", "v", "for", "k", ",", "v", "in", "kws", ".", "items", "(", ")", "if", "k", "in", "Grouped", ".", "k...
Get Grouped object.
[ "Get", "Grouped", "object", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/compare_gos.py#L214-L218
train
tanghaibao/goatools
goatools/cli/compare_gos.py
_Init._init_go2ntpresent
def _init_go2ntpresent(go_ntsets, go_all, gosubdag): """Mark all GO IDs with an X if present in the user GO list.""" go2ntpresent = {} ntobj = namedtuple('NtPresent', " ".join(nt.hdr for nt in go_ntsets)) # Get present marks for GO sources for goid_all in go_all: pres...
python
def _init_go2ntpresent(go_ntsets, go_all, gosubdag): """Mark all GO IDs with an X if present in the user GO list.""" go2ntpresent = {} ntobj = namedtuple('NtPresent', " ".join(nt.hdr for nt in go_ntsets)) # Get present marks for GO sources for goid_all in go_all: pres...
[ "def", "_init_go2ntpresent", "(", "go_ntsets", ",", "go_all", ",", "gosubdag", ")", ":", "go2ntpresent", "=", "{", "}", "ntobj", "=", "namedtuple", "(", "'NtPresent'", ",", "\" \"", ".", "join", "(", "nt", ".", "hdr", "for", "nt", "in", "go_ntsets", ")",...
Mark all GO IDs with an X if present in the user GO list.
[ "Mark", "all", "GO", "IDs", "with", "an", "X", "if", "present", "in", "the", "user", "GO", "list", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/compare_gos.py#L221-L236
train
tanghaibao/goatools
goatools/cli/compare_gos.py
_Init.get_go_ntsets
def get_go_ntsets(self, go_fins): """For each file containing GOs, extract GO IDs, store filename and header.""" nts = [] ntobj = namedtuple('NtGOFiles', 'hdr go_set, go_fin') go_sets = self._init_go_sets(go_fins) hdrs = [os.path.splitext(os.path.basename(f))[0] for f in go_fins]...
python
def get_go_ntsets(self, go_fins): """For each file containing GOs, extract GO IDs, store filename and header.""" nts = [] ntobj = namedtuple('NtGOFiles', 'hdr go_set, go_fin') go_sets = self._init_go_sets(go_fins) hdrs = [os.path.splitext(os.path.basename(f))[0] for f in go_fins]...
[ "def", "get_go_ntsets", "(", "self", ",", "go_fins", ")", ":", "nts", "=", "[", "]", "ntobj", "=", "namedtuple", "(", "'NtGOFiles'", ",", "'hdr go_set, go_fin'", ")", "go_sets", "=", "self", ".", "_init_go_sets", "(", "go_fins", ")", "hdrs", "=", "[", "o...
For each file containing GOs, extract GO IDs, store filename and header.
[ "For", "each", "file", "containing", "GOs", "extract", "GO", "IDs", "store", "filename", "and", "header", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/compare_gos.py#L238-L248
train
tanghaibao/goatools
goatools/cli/compare_gos.py
_Init._init_go_sets
def _init_go_sets(self, go_fins): """Get lists of GO IDs.""" go_sets = [] assert go_fins, "EXPECTED FILES CONTAINING GO IDs" assert len(go_fins) >= 2, "EXPECTED 2+ GO LISTS. FOUND: {L}".format( L=' '.join(go_fins)) obj = GetGOs(self.godag) for fin in go_fins: ...
python
def _init_go_sets(self, go_fins): """Get lists of GO IDs.""" go_sets = [] assert go_fins, "EXPECTED FILES CONTAINING GO IDs" assert len(go_fins) >= 2, "EXPECTED 2+ GO LISTS. FOUND: {L}".format( L=' '.join(go_fins)) obj = GetGOs(self.godag) for fin in go_fins: ...
[ "def", "_init_go_sets", "(", "self", ",", "go_fins", ")", ":", "go_sets", "=", "[", "]", "assert", "go_fins", ",", "\"EXPECTED FILES CONTAINING GO IDs\"", "assert", "len", "(", "go_fins", ")", ">=", "2", ",", "\"EXPECTED 2+ GO LISTS. FOUND: {L}\"", ".", "format", ...
Get lists of GO IDs.
[ "Get", "lists", "of", "GO", "IDs", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/compare_gos.py#L250-L260
train
tanghaibao/goatools
goatools/gosubdag/godag_rcnt.py
CountRelatives.get_parents_letters
def get_parents_letters(self, goobj): """Get the letters representing all parent terms which are depth-01 GO terms.""" parents_all = set.union(self.go2parents[goobj.id]) parents_all.add(goobj.id) # print "{}({}) D{:02}".format(goobj.id, goobj.name, goobj.depth), parents_all paren...
python
def get_parents_letters(self, goobj): """Get the letters representing all parent terms which are depth-01 GO terms.""" parents_all = set.union(self.go2parents[goobj.id]) parents_all.add(goobj.id) # print "{}({}) D{:02}".format(goobj.id, goobj.name, goobj.depth), parents_all paren...
[ "def", "get_parents_letters", "(", "self", ",", "goobj", ")", ":", "parents_all", "=", "set", ".", "union", "(", "self", ".", "go2parents", "[", "goobj", ".", "id", "]", ")", "parents_all", ".", "add", "(", "goobj", ".", "id", ")", "parents_d1", "=", ...
Get the letters representing all parent terms which are depth-01 GO terms.
[ "Get", "the", "letters", "representing", "all", "parent", "terms", "which", "are", "depth", "-", "01", "GO", "terms", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/godag_rcnt.py#L28-L34
train
tanghaibao/goatools
goatools/gosubdag/godag_rcnt.py
CountRelatives.get_d1str
def get_d1str(self, goobj, reverse=False): """Get D1-string representing all parent terms which are depth-01 GO terms.""" return "".join(sorted(self.get_parents_letters(goobj), reverse=reverse))
python
def get_d1str(self, goobj, reverse=False): """Get D1-string representing all parent terms which are depth-01 GO terms.""" return "".join(sorted(self.get_parents_letters(goobj), reverse=reverse))
[ "def", "get_d1str", "(", "self", ",", "goobj", ",", "reverse", "=", "False", ")", ":", "return", "\"\"", ".", "join", "(", "sorted", "(", "self", ".", "get_parents_letters", "(", "goobj", ")", ",", "reverse", "=", "reverse", ")", ")" ]
Get D1-string representing all parent terms which are depth-01 GO terms.
[ "Get", "D1", "-", "string", "representing", "all", "parent", "terms", "which", "are", "depth", "-", "01", "GO", "terms", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/godag_rcnt.py#L36-L38
train
tanghaibao/goatools
goatools/gosubdag/go_most_specific.py
get_most_specific_dcnt
def get_most_specific_dcnt(goids, go2nt): """Get the GO ID with the lowest descendants count.""" # go2nt_usr = {go:go2nt[go] for go in goids} # return min(go2nt_usr.items(), key=lambda t: t[1].dcnt)[0] return min(_get_go2nt(goids, go2nt), key=lambda t: t[1].dcnt)[0]
python
def get_most_specific_dcnt(goids, go2nt): """Get the GO ID with the lowest descendants count.""" # go2nt_usr = {go:go2nt[go] for go in goids} # return min(go2nt_usr.items(), key=lambda t: t[1].dcnt)[0] return min(_get_go2nt(goids, go2nt), key=lambda t: t[1].dcnt)[0]
[ "def", "get_most_specific_dcnt", "(", "goids", ",", "go2nt", ")", ":", "return", "min", "(", "_get_go2nt", "(", "goids", ",", "go2nt", ")", ",", "key", "=", "lambda", "t", ":", "t", "[", "1", "]", ".", "dcnt", ")", "[", "0", "]" ]
Get the GO ID with the lowest descendants count.
[ "Get", "the", "GO", "ID", "with", "the", "lowest", "descendants", "count", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_most_specific.py#L7-L11
train
tanghaibao/goatools
goatools/gosubdag/go_most_specific.py
_get_go2nt
def _get_go2nt(goids, go2nt_all): """Get user go2nt using main GO IDs, not alt IDs.""" go_nt_list = [] goids_seen = set() for goid_usr in goids: ntgo = go2nt_all[goid_usr] goid_main = ntgo.id if goid_main not in goids_seen: goids_seen.add(goid_main) go_nt_...
python
def _get_go2nt(goids, go2nt_all): """Get user go2nt using main GO IDs, not alt IDs.""" go_nt_list = [] goids_seen = set() for goid_usr in goids: ntgo = go2nt_all[goid_usr] goid_main = ntgo.id if goid_main not in goids_seen: goids_seen.add(goid_main) go_nt_...
[ "def", "_get_go2nt", "(", "goids", ",", "go2nt_all", ")", ":", "go_nt_list", "=", "[", "]", "goids_seen", "=", "set", "(", ")", "for", "goid_usr", "in", "goids", ":", "ntgo", "=", "go2nt_all", "[", "goid_usr", "]", "goid_main", "=", "ntgo", ".", "id", ...
Get user go2nt using main GO IDs, not alt IDs.
[ "Get", "user", "go2nt", "using", "main", "GO", "IDs", "not", "alt", "IDs", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_most_specific.py#L25-L35
train
tanghaibao/goatools
goatools/grouper/aart_geneproducts_one.py
AArtGeneProductSetsOne.prt_gos_grouped
def prt_gos_grouped(self, prt, **kws_grp): """Print grouped GO list.""" prtfmt = self.datobj.kws['fmtgo'] wrobj = WrXlsxSortedGos(self.name, self.sortobj) # Keyword arguments: control content: hdrgo_prt section_prt top_n use_sections desc2nts = self.sortobj.get_desc2nts(**kws_grp...
python
def prt_gos_grouped(self, prt, **kws_grp): """Print grouped GO list.""" prtfmt = self.datobj.kws['fmtgo'] wrobj = WrXlsxSortedGos(self.name, self.sortobj) # Keyword arguments: control content: hdrgo_prt section_prt top_n use_sections desc2nts = self.sortobj.get_desc2nts(**kws_grp...
[ "def", "prt_gos_grouped", "(", "self", ",", "prt", ",", "**", "kws_grp", ")", ":", "prtfmt", "=", "self", ".", "datobj", ".", "kws", "[", "'fmtgo'", "]", "wrobj", "=", "WrXlsxSortedGos", "(", "self", ".", "name", ",", "self", ".", "sortobj", ")", "de...
Print grouped GO list.
[ "Print", "grouped", "GO", "list", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/aart_geneproducts_one.py#L74-L80
train
tanghaibao/goatools
goatools/grouper/aart_geneproducts_one.py
AArtGeneProductSetsOne.prt_gos_flat
def prt_gos_flat(self, prt): """Print flat GO list.""" prtfmt = self.datobj.kws['fmtgo'] _go2nt = self.sortobj.grprobj.go2nt go2nt = {go:_go2nt[go] for go in self.go2nt} prt.write("\n{N} GO IDs:\n".format(N=len(go2nt))) _sortby = self._get_sortgo() for ntgo in sor...
python
def prt_gos_flat(self, prt): """Print flat GO list.""" prtfmt = self.datobj.kws['fmtgo'] _go2nt = self.sortobj.grprobj.go2nt go2nt = {go:_go2nt[go] for go in self.go2nt} prt.write("\n{N} GO IDs:\n".format(N=len(go2nt))) _sortby = self._get_sortgo() for ntgo in sor...
[ "def", "prt_gos_flat", "(", "self", ",", "prt", ")", ":", "prtfmt", "=", "self", ".", "datobj", ".", "kws", "[", "'fmtgo'", "]", "_go2nt", "=", "self", ".", "sortobj", ".", "grprobj", ".", "go2nt", "go2nt", "=", "{", "go", ":", "_go2nt", "[", "go",...
Print flat GO list.
[ "Print", "flat", "GO", "list", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/aart_geneproducts_one.py#L82-L90
train
tanghaibao/goatools
goatools/grouper/aart_geneproducts_one.py
AArtGeneProductSetsOne._get_sortgo
def _get_sortgo(self): """Get function for sorting GO terms in a list of namedtuples.""" if 'sortgo' in self.datobj.kws: return self.datobj.kws['sortgo'] return self.datobj.grprdflt.gosubdag.prt_attr['sort'] + "\n"
python
def _get_sortgo(self): """Get function for sorting GO terms in a list of namedtuples.""" if 'sortgo' in self.datobj.kws: return self.datobj.kws['sortgo'] return self.datobj.grprdflt.gosubdag.prt_attr['sort'] + "\n"
[ "def", "_get_sortgo", "(", "self", ")", ":", "if", "'sortgo'", "in", "self", ".", "datobj", ".", "kws", ":", "return", "self", ".", "datobj", ".", "kws", "[", "'sortgo'", "]", "return", "self", ".", "datobj", ".", "grprdflt", ".", "gosubdag", ".", "p...
Get function for sorting GO terms in a list of namedtuples.
[ "Get", "function", "for", "sorting", "GO", "terms", "in", "a", "list", "of", "namedtuples", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/aart_geneproducts_one.py#L93-L97
train
tanghaibao/goatools
goatools/grouper/aart_geneproducts_one.py
AArtGeneProductSetsOne.get_gene2binvec
def get_gene2binvec(self): """Return a boolean vector for each gene representing GO section membership.""" _sec2chr = self.sec2chr return {g:[s in s2gos for s in _sec2chr] for g, s2gos in self.gene2section2gos.items()}
python
def get_gene2binvec(self): """Return a boolean vector for each gene representing GO section membership.""" _sec2chr = self.sec2chr return {g:[s in s2gos for s in _sec2chr] for g, s2gos in self.gene2section2gos.items()}
[ "def", "get_gene2binvec", "(", "self", ")", ":", "_sec2chr", "=", "self", ".", "sec2chr", "return", "{", "g", ":", "[", "s", "in", "s2gos", "for", "s", "in", "_sec2chr", "]", "for", "g", ",", "s2gos", "in", "self", ".", "gene2section2gos", ".", "item...
Return a boolean vector for each gene representing GO section membership.
[ "Return", "a", "boolean", "vector", "for", "each", "gene", "representing", "GO", "section", "membership", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/aart_geneproducts_one.py#L140-L143
train
tanghaibao/goatools
goatools/grouper/aart_geneproducts_one.py
_Init.get_go2nt
def get_go2nt(self, goea_results): """Return go2nt with added formatted string versions of the P-values.""" go2obj = self.objaartall.grprdflt.gosubdag.go2obj # Add string version of P-values goea_nts = MgrNtGOEAs(goea_results).get_nts_strpval() return {go2obj[nt.GO].id:nt for nt ...
python
def get_go2nt(self, goea_results): """Return go2nt with added formatted string versions of the P-values.""" go2obj = self.objaartall.grprdflt.gosubdag.go2obj # Add string version of P-values goea_nts = MgrNtGOEAs(goea_results).get_nts_strpval() return {go2obj[nt.GO].id:nt for nt ...
[ "def", "get_go2nt", "(", "self", ",", "goea_results", ")", ":", "go2obj", "=", "self", ".", "objaartall", ".", "grprdflt", ".", "gosubdag", ".", "go2obj", "goea_nts", "=", "MgrNtGOEAs", "(", "goea_results", ")", ".", "get_nts_strpval", "(", ")", "return", ...
Return go2nt with added formatted string versions of the P-values.
[ "Return", "go2nt", "with", "added", "formatted", "string", "versions", "of", "the", "P", "-", "values", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/aart_geneproducts_one.py#L151-L156
train