repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
AASHE/python-membersuite-api-client
membersuite_api_client/mixins.py
run_object_query
def run_object_query(client, base_object_query, start_record, limit_to, verbose=False): """inline method to take advantage of retry""" if verbose: print("[start: %d limit: %d]" % (start_record, limit_to)) start = datetime.datetime.now() result = client.execute_object_query( ...
python
def run_object_query(client, base_object_query, start_record, limit_to, verbose=False): """inline method to take advantage of retry""" if verbose: print("[start: %d limit: %d]" % (start_record, limit_to)) start = datetime.datetime.now() result = client.execute_object_query( ...
[ "def", "run_object_query", "(", "client", ",", "base_object_query", ",", "start_record", ",", "limit_to", ",", "verbose", "=", "False", ")", ":", "if", "verbose", ":", "print", "(", "\"[start: %d limit: %d]\"", "%", "(", "start_record", ",", "limit_to", ")", "...
inline method to take advantage of retry
[ "inline", "method", "to", "take", "advantage", "of", "retry" ]
221f5ed8bc7d4424237a4669c5af9edc11819ee9
https://github.com/AASHE/python-membersuite-api-client/blob/221f5ed8bc7d4424237a4669c5af9edc11819ee9/membersuite_api_client/mixins.py#L10-L23
train
inline method to take advantage of retry
AASHE/python-membersuite-api-client
membersuite_api_client/mixins.py
ChunkQueryMixin.get_long_query
def get_long_query(self, base_object_query, limit_to=100, max_calls=None, start_record=0, verbose=False): """ Takes a base query for all objects and recursively requests them :param str base_object_query: the base query to be executed :param int limit_to: how many...
python
def get_long_query(self, base_object_query, limit_to=100, max_calls=None, start_record=0, verbose=False): """ Takes a base query for all objects and recursively requests them :param str base_object_query: the base query to be executed :param int limit_to: how many...
[ "def", "get_long_query", "(", "self", ",", "base_object_query", ",", "limit_to", "=", "100", ",", "max_calls", "=", "None", ",", "start_record", "=", "0", ",", "verbose", "=", "False", ")", ":", "if", "verbose", ":", "print", "(", "base_object_query", ")",...
Takes a base query for all objects and recursively requests them :param str base_object_query: the base query to be executed :param int limit_to: how many rows to query for in each chunk :param int max_calls: the max calls(chunks to request) None is infinite :param int start_record: the...
[ "Takes", "a", "base", "query", "for", "all", "objects", "and", "recursively", "requests", "them" ]
221f5ed8bc7d4424237a4669c5af9edc11819ee9
https://github.com/AASHE/python-membersuite-api-client/blob/221f5ed8bc7d4424237a4669c5af9edc11819ee9/membersuite_api_client/mixins.py#L35-L95
train
Takes a base query for all objects and returns a list of Organization objects that are in the long query.
AASHE/python-membersuite-api-client
membersuite_api_client/mixins.py
ChunkQueryMixin.result_to_models
def result_to_models(self, result): """ this is the 'transorm' part of ETL: converts the result of the SQL to Models """ mysql_result = result['body']['ExecuteMSQLResult'] if not mysql_result['Errors']: obj_result = mysql_result['ResultValue']['Object...
python
def result_to_models(self, result): """ this is the 'transorm' part of ETL: converts the result of the SQL to Models """ mysql_result = result['body']['ExecuteMSQLResult'] if not mysql_result['Errors']: obj_result = mysql_result['ResultValue']['Object...
[ "def", "result_to_models", "(", "self", ",", "result", ")", ":", "mysql_result", "=", "result", "[", "'body'", "]", "[", "'ExecuteMSQLResult'", "]", "if", "not", "mysql_result", "[", "'Errors'", "]", ":", "obj_result", "=", "mysql_result", "[", "'ResultValue'"...
this is the 'transorm' part of ETL: converts the result of the SQL to Models
[ "this", "is", "the", "transorm", "part", "of", "ETL", ":", "converts", "the", "result", "of", "the", "SQL", "to", "Models" ]
221f5ed8bc7d4424237a4669c5af9edc11819ee9
https://github.com/AASHE/python-membersuite-api-client/blob/221f5ed8bc7d4424237a4669c5af9edc11819ee9/membersuite_api_client/mixins.py#L97-L118
train
Convert the result of the SQL to Models
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.logger
def logger(self): """The logger of this organizer""" if self._experiment: return logging.getLogger('.'.join([self.name, self.experiment])) elif self._projectname: return logging.getLogger('.'.join([self.name, self.projectname])) else: return logging.ge...
python
def logger(self): """The logger of this organizer""" if self._experiment: return logging.getLogger('.'.join([self.name, self.experiment])) elif self._projectname: return logging.getLogger('.'.join([self.name, self.projectname])) else: return logging.ge...
[ "def", "logger", "(", "self", ")", ":", "if", "self", ".", "_experiment", ":", "return", "logging", ".", "getLogger", "(", "'.'", ".", "join", "(", "[", "self", ".", "name", ",", "self", ".", "experiment", "]", ")", ")", "elif", "self", ".", "_proj...
The logger of this organizer
[ "The", "logger", "of", "this", "organizer" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L98-L105
train
Returns the logger of this organizer
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.main
def main(cls, args=None): """ Run the organizer from the command line Parameters ---------- name: str The name of the program args: list The arguments that are parsed to the argument parser """ organizer = cls() organizer.p...
python
def main(cls, args=None): """ Run the organizer from the command line Parameters ---------- name: str The name of the program args: list The arguments that are parsed to the argument parser """ organizer = cls() organizer.p...
[ "def", "main", "(", "cls", ",", "args", "=", "None", ")", ":", "organizer", "=", "cls", "(", ")", "organizer", ".", "parse_args", "(", "args", ")", "if", "not", "organizer", ".", "no_modification", ":", "organizer", ".", "config", ".", "save", "(", "...
Run the organizer from the command line Parameters ---------- name: str The name of the program args: list The arguments that are parsed to the argument parser
[ "Run", "the", "organizer", "from", "the", "command", "line" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L141-L155
train
Run the organizer from the command line
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.start
def start(self, **kwargs): """ Start the commands of this organizer Parameters ---------- ``**kwargs`` Any keyword from the :attr:`commands` or :attr:`parser_commands` attribute Returns ------- argparse.Namespace The n...
python
def start(self, **kwargs): """ Start the commands of this organizer Parameters ---------- ``**kwargs`` Any keyword from the :attr:`commands` or :attr:`parser_commands` attribute Returns ------- argparse.Namespace The n...
[ "def", "start", "(", "self", ",", "*", "*", "kwargs", ")", ":", "ts", "=", "{", "}", "ret", "=", "{", "}", "info_parts", "=", "{", "'info'", ",", "'get-value'", ",", "'get_value'", "}", "for", "cmd", "in", "self", ".", "commands", ":", "parser_cmd"...
Start the commands of this organizer Parameters ---------- ``**kwargs`` Any keyword from the :attr:`commands` or :attr:`parser_commands` attribute Returns ------- argparse.Namespace The namespace with the commands as given in ``**kwar...
[ "Start", "the", "commands", "of", "this", "organizer" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L159-L204
train
Start the commands of this organizer and return the corresponding namespace.
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.projectname
def projectname(self): """The name of the project that is currently processed""" if self._projectname is None: exps = self.config.experiments if self._experiment is not None and self._experiment in exps: return exps[self._experiment]['project'] try: ...
python
def projectname(self): """The name of the project that is currently processed""" if self._projectname is None: exps = self.config.experiments if self._experiment is not None and self._experiment in exps: return exps[self._experiment]['project'] try: ...
[ "def", "projectname", "(", "self", ")", ":", "if", "self", ".", "_projectname", "is", "None", ":", "exps", "=", "self", ".", "config", ".", "experiments", "if", "self", ".", "_experiment", "is", "not", "None", "and", "self", ".", "_experiment", "in", "...
The name of the project that is currently processed
[ "The", "name", "of", "the", "project", "that", "is", "currently", "processed" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L215-L227
train
The name of the project that is currently processed
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.experiment
def experiment(self): """The identifier or the experiment that is currently processed""" if self._experiment is None: self._experiment = list(self.config.experiments.keys())[-1] return self._experiment
python
def experiment(self): """The identifier or the experiment that is currently processed""" if self._experiment is None: self._experiment = list(self.config.experiments.keys())[-1] return self._experiment
[ "def", "experiment", "(", "self", ")", ":", "if", "self", ".", "_experiment", "is", "None", ":", "self", ".", "_experiment", "=", "list", "(", "self", ".", "config", ".", "experiments", ".", "keys", "(", ")", ")", "[", "-", "1", "]", "return", "sel...
The identifier or the experiment that is currently processed
[ "The", "identifier", "or", "the", "experiment", "that", "is", "currently", "processed" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L235-L239
train
The identifier of the experiment that is currently processed
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.app_main
def app_main(self, experiment=None, last=False, new=False, verbose=False, verbosity_level=None, no_modification=False, match=False): """ The main function for parsing global arguments Parameters ---------- experiment: str The id of t...
python
def app_main(self, experiment=None, last=False, new=False, verbose=False, verbosity_level=None, no_modification=False, match=False): """ The main function for parsing global arguments Parameters ---------- experiment: str The id of t...
[ "def", "app_main", "(", "self", ",", "experiment", "=", "None", ",", "last", "=", "False", ",", "new", "=", "False", ",", "verbose", "=", "False", ",", "verbosity_level", "=", "None", ",", "no_modification", "=", "False", ",", "match", "=", "False", ")...
The main function for parsing global arguments Parameters ---------- experiment: str The id of the experiment to use last: bool If True, the last experiment is used new: bool If True, a new experiment is created verbose: bool ...
[ "The", "main", "function", "for", "parsing", "global", "arguments" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L248-L307
train
This function is called by the application level to parse the global arguments and call the application function.
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.get_app_main_kwargs
def get_app_main_kwargs(self, kwargs, keep=False): """ Extract the keyword arguments for the :meth:`app_main` method Parameters ---------- kwargs: dict A mapping containing keyword arguments for the :meth:`app_main` method keep: bool I...
python
def get_app_main_kwargs(self, kwargs, keep=False): """ Extract the keyword arguments for the :meth:`app_main` method Parameters ---------- kwargs: dict A mapping containing keyword arguments for the :meth:`app_main` method keep: bool I...
[ "def", "get_app_main_kwargs", "(", "self", ",", "kwargs", ",", "keep", "=", "False", ")", ":", "if", "not", "keep", ":", "return", "{", "key", ":", "kwargs", ".", "pop", "(", "key", ")", "for", "key", "in", "list", "(", "kwargs", ")", "if", "key", ...
Extract the keyword arguments for the :meth:`app_main` method Parameters ---------- kwargs: dict A mapping containing keyword arguments for the :meth:`app_main` method keep: bool If True, the keywords are kept in the `kwargs`. Otherwise, they are ...
[ "Extract", "the", "keyword", "arguments", "for", "the", ":", "meth", ":", "app_main", "method" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L331-L358
train
Extract the keyword arguments for the app_main method.
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.setup
def setup(self, root_dir, projectname=None, link=False, **kwargs): """ Perform the initial setup for the project Parameters ---------- root_dir: str The path to the root directory where the experiments, etc. will be stored projectname: str ...
python
def setup(self, root_dir, projectname=None, link=False, **kwargs): """ Perform the initial setup for the project Parameters ---------- root_dir: str The path to the root directory where the experiments, etc. will be stored projectname: str ...
[ "def", "setup", "(", "self", ",", "root_dir", ",", "projectname", "=", "None", ",", "link", "=", "False", ",", "*", "*", "kwargs", ")", ":", "projects", "=", "self", ".", "config", ".", "projects", "if", "not", "projects", "and", "projectname", "is", ...
Perform the initial setup for the project Parameters ---------- root_dir: str The path to the root directory where the experiments, etc. will be stored projectname: str The name of the project that shall be initialized at `root_dir`. A new...
[ "Perform", "the", "initial", "setup", "for", "the", "project" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L366-L411
train
Initializes the A class.
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.init
def init(self, projectname=None, description=None, **kwargs): """ Initialize a new experiment Parameters ---------- projectname: str The name of the project that shall be used. If None, the last one created will be used description: str ...
python
def init(self, projectname=None, description=None, **kwargs): """ Initialize a new experiment Parameters ---------- projectname: str The name of the project that shall be used. If None, the last one created will be used description: str ...
[ "def", "init", "(", "self", ",", "projectname", "=", "None", ",", "description", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "app_main", "(", "*", "*", "kwargs", ")", "experiments", "=", "self", ".", "config", ".", "experiments", "ex...
Initialize a new experiment Parameters ---------- projectname: str The name of the project that shall be used. If None, the last one created will be used description: str A short summary of the experiment ``**kwargs`` Keyword argum...
[ "Initialize", "a", "new", "experiment" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L418-L471
train
Initialize a new object of the class.
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.archive
def archive(self, odir=None, aname=None, fmt=None, projectname=None, experiments=None, current_project=False, no_append=False, no_project_paths=False, exclude=None, keep_exp=False, rm_project=False, dry_run=False, dereference=False, **kwargs): """ Archive ...
python
def archive(self, odir=None, aname=None, fmt=None, projectname=None, experiments=None, current_project=False, no_append=False, no_project_paths=False, exclude=None, keep_exp=False, rm_project=False, dry_run=False, dereference=False, **kwargs): """ Archive ...
[ "def", "archive", "(", "self", ",", "odir", "=", "None", ",", "aname", "=", "None", ",", "fmt", "=", "None", ",", "projectname", "=", "None", ",", "experiments", "=", "None", ",", "current_project", "=", "False", ",", "no_append", "=", "False", ",", ...
Archive one or more experiments or a project instance This method may be used to archive experiments in order to minimize the amount of necessary configuration files Parameters ---------- odir: str The path where to store the archive aname: str T...
[ "Archive", "one", "or", "more", "experiments", "or", "a", "project", "instance" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L478-L681
train
Archive the configuration files for a specific project instance or a specific experiment.
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.unarchive
def unarchive(self, experiments=None, archive=None, complete=False, project_data=False, replace_project_config=False, root=None, projectname=None, fmt=None, force=False, **kwargs): """ Extract archived experiments Parameters ---------- experim...
python
def unarchive(self, experiments=None, archive=None, complete=False, project_data=False, replace_project_config=False, root=None, projectname=None, fmt=None, force=False, **kwargs): """ Extract archived experiments Parameters ---------- experim...
[ "def", "unarchive", "(", "self", ",", "experiments", "=", "None", ",", "archive", "=", "None", ",", "complete", "=", "False", ",", "project_data", "=", "False", ",", "replace_project_config", "=", "False", ",", "root", "=", "None", ",", "projectname", "=",...
Extract archived experiments Parameters ---------- experiments: list of str The experiments to extract. If None the current experiment is used archive: str The path to an archive to extract the experiments from. If None, we assume that the path to the...
[ "Extract", "archived", "experiments" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L702-L896
train
Unarchives the current project from the given archive.
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.remove
def remove(self, projectname=None, complete=False, yes=False, all_projects=False, **kwargs): """ Delete an existing experiment and/or projectname Parameters ---------- projectname: str The name for which the data shall be removed. If True, the ...
python
def remove(self, projectname=None, complete=False, yes=False, all_projects=False, **kwargs): """ Delete an existing experiment and/or projectname Parameters ---------- projectname: str The name for which the data shall be removed. If True, the ...
[ "def", "remove", "(", "self", ",", "projectname", "=", "None", ",", "complete", "=", "False", ",", "yes", "=", "False", ",", "all_projects", "=", "False", ",", "*", "*", "kwargs", ")", ":", "self", ".", "app_main", "(", "*", "*", "kwargs", ")", "if...
Delete an existing experiment and/or projectname Parameters ---------- projectname: str The name for which the data shall be removed. If True, the project will be determined by the experiment. If not None, all experiments for the given project will be removed...
[ "Delete", "an", "existing", "experiment", "and", "/", "or", "projectname" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L912-L980
train
Delete an existing experiment and or project.
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.info
def info(self, exp_path=False, project_path=False, global_path=False, config_path=False, complete=False, no_fix=False, on_projects=False, on_globals=False, projectname=None, return_dict=False, insert_id=True, only_keys=False, archives=False, **kwargs): """ ...
python
def info(self, exp_path=False, project_path=False, global_path=False, config_path=False, complete=False, no_fix=False, on_projects=False, on_globals=False, projectname=None, return_dict=False, insert_id=True, only_keys=False, archives=False, **kwargs): """ ...
[ "def", "info", "(", "self", ",", "exp_path", "=", "False", ",", "project_path", "=", "False", ",", "global_path", "=", "False", ",", "config_path", "=", "False", ",", "complete", "=", "False", ",", "no_fix", "=", "False", ",", "on_projects", "=", "False"...
Print information on the experiments Parameters ---------- exp_path: bool If True/set, print the filename of the experiment configuration project_path: bool If True/set, print the filename on the project configuration global_path: bool If True...
[ "Print", "information", "on", "the", "experiments" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L1000-L1127
train
Print information on the current project and all the experiments in the current project.
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.get_value
def get_value(self, keys, exp_path=False, project_path=False, complete=False, on_projects=False, on_globals=False, projectname=None, no_fix=False, only_keys=False, base='', return_list=False, archives=False, **kwargs): """ Get one or more values in t...
python
def get_value(self, keys, exp_path=False, project_path=False, complete=False, on_projects=False, on_globals=False, projectname=None, no_fix=False, only_keys=False, base='', return_list=False, archives=False, **kwargs): """ Get one or more values in t...
[ "def", "get_value", "(", "self", ",", "keys", ",", "exp_path", "=", "False", ",", "project_path", "=", "False", ",", "complete", "=", "False", ",", "on_projects", "=", "False", ",", "on_globals", "=", "False", ",", "projectname", "=", "None", ",", "no_fi...
Get one or more values in the configuration Parameters ---------- keys: list of str A list of keys to get the values of. %(get_value_note)s %(ModelOrganizer.info.parameters.exp_path|project_path)s %(ModelOrganizer.info.common_params)s %(ModelOrganizer.info.pa...
[ "Get", "one", "or", "more", "values", "in", "the", "configuration" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L1159-L1201
train
Get one or more values from the configuration.
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.del_value
def del_value(self, keys, complete=False, on_projects=False, on_globals=False, projectname=None, base='', dtype=None, **kwargs): """ Delete a value in the configuration Parameters ---------- keys: list of str A list of keys to be d...
python
def del_value(self, keys, complete=False, on_projects=False, on_globals=False, projectname=None, base='', dtype=None, **kwargs): """ Delete a value in the configuration Parameters ---------- keys: list of str A list of keys to be d...
[ "def", "del_value", "(", "self", ",", "keys", ",", "complete", "=", "False", ",", "on_projects", "=", "False", ",", "on_globals", "=", "False", ",", "projectname", "=", "None", ",", "base", "=", "''", ",", "dtype", "=", "None", ",", "*", "*", "kwargs...
Delete a value in the configuration Parameters ---------- keys: list of str A list of keys to be deleted. %(get_value_note)s %(ModelOrganizer.info.common_params)s base: str A base string that shall be put in front of each key in `values` to av...
[ "Delete", "a", "value", "in", "the", "configuration" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L1219-L1241
train
Delete a value in the configuration
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.configure
def configure(self, global_config=False, project_config=False, ifile=None, forcing=None, serial=False, nprocs=None, update_from=None, **kwargs): """ Configure the project and experiments Parameters ---------- global_config: bool If...
python
def configure(self, global_config=False, project_config=False, ifile=None, forcing=None, serial=False, nprocs=None, update_from=None, **kwargs): """ Configure the project and experiments Parameters ---------- global_config: bool If...
[ "def", "configure", "(", "self", ",", "global_config", "=", "False", ",", "project_config", "=", "False", ",", "ifile", "=", "None", ",", "forcing", "=", "None", ",", "serial", "=", "False", ",", "nprocs", "=", "None", ",", "update_from", "=", "None", ...
Configure the project and experiments Parameters ---------- global_config: bool If True/set, the configuration are applied globally (already existing and configured experiments are not impacted) project_config: bool Apply the configuration on the enti...
[ "Configure", "the", "project", "and", "experiments" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L1259-L1317
train
Configure the current instance of the current object.
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.set_value
def set_value(self, items, complete=False, on_projects=False, on_globals=False, projectname=None, base='', dtype=None, **kwargs): """ Set a value in the configuration Parameters ---------- items: dict A dictionary whose keys corres...
python
def set_value(self, items, complete=False, on_projects=False, on_globals=False, projectname=None, base='', dtype=None, **kwargs): """ Set a value in the configuration Parameters ---------- items: dict A dictionary whose keys corres...
[ "def", "set_value", "(", "self", ",", "items", ",", "complete", "=", "False", ",", "on_projects", "=", "False", ",", "on_globals", "=", "False", ",", "projectname", "=", "None", ",", "base", "=", "''", ",", "dtype", "=", "None", ",", "*", "*", "kwarg...
Set a value in the configuration Parameters ---------- items: dict A dictionary whose keys correspond to the item in the configuration and whose values are what shall be inserted. %(get_value_note)s %(ModelOrganizer.info.common_params)s base: str ...
[ "Set", "a", "value", "in", "the", "configuration" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L1331-L1368
train
Set a value in the configuration
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.fix_paths
def fix_paths(self, *args, **kwargs): """ Fix the paths in the given dictionary to get absolute paths Parameters ---------- %(ExperimentsConfig.fix_paths.parameters)s Returns ------- %(ExperimentsConfig.fix_paths.returns)s Notes ----- ...
python
def fix_paths(self, *args, **kwargs): """ Fix the paths in the given dictionary to get absolute paths Parameters ---------- %(ExperimentsConfig.fix_paths.parameters)s Returns ------- %(ExperimentsConfig.fix_paths.returns)s Notes ----- ...
[ "def", "fix_paths", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "config", ".", "experiments", ".", "fix_paths", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
Fix the paths in the given dictionary to get absolute paths Parameters ---------- %(ExperimentsConfig.fix_paths.parameters)s Returns ------- %(ExperimentsConfig.fix_paths.returns)s Notes ----- d is modified in place!
[ "Fix", "the", "paths", "in", "the", "given", "dictionary", "to", "get", "absolute", "paths" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L1392-L1407
train
Fix the paths in the given dictionary to get absolute paths
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.rel_paths
def rel_paths(self, *args, **kwargs): """ Fix the paths in the given dictionary to get relative paths Parameters ---------- %(ExperimentsConfig.rel_paths.parameters)s Returns ------- %(ExperimentsConfig.rel_paths.returns)s Notes ----- ...
python
def rel_paths(self, *args, **kwargs): """ Fix the paths in the given dictionary to get relative paths Parameters ---------- %(ExperimentsConfig.rel_paths.parameters)s Returns ------- %(ExperimentsConfig.rel_paths.returns)s Notes ----- ...
[ "def", "rel_paths", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "config", ".", "experiments", ".", "rel_paths", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
Fix the paths in the given dictionary to get relative paths Parameters ---------- %(ExperimentsConfig.rel_paths.parameters)s Returns ------- %(ExperimentsConfig.rel_paths.returns)s Notes ----- d is modified in place!
[ "Fix", "the", "paths", "in", "the", "given", "dictionary", "to", "get", "relative", "paths" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L1410-L1425
train
Returns a list of relative paths for the given arguments.
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.abspath
def abspath(self, path, project=None, root=None): """Returns the path from the current working directory We only store the paths relative to the root directory of the project. This method fixes those path to be applicable from the working directory Parameters ----------...
python
def abspath(self, path, project=None, root=None): """Returns the path from the current working directory We only store the paths relative to the root directory of the project. This method fixes those path to be applicable from the working directory Parameters ----------...
[ "def", "abspath", "(", "self", ",", "path", ",", "project", "=", "None", ",", "root", "=", "None", ")", ":", "if", "root", "is", "None", ":", "root", "=", "self", ".", "config", ".", "projects", "[", "project", "or", "self", ".", "projectname", "]"...
Returns the path from the current working directory We only store the paths relative to the root directory of the project. This method fixes those path to be applicable from the working directory Parameters ---------- path: str The original path as it is sto...
[ "Returns", "the", "path", "from", "the", "current", "working", "directory" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L1440-L1463
train
Returns the absolute path from the current working directory
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.relpath
def relpath(self, path, project=None, root=None): """Returns the relative path from the root directory of the project We only store the paths relative to the root directory of the project. This method gives you this path from a path that is accessible from the current working directory ...
python
def relpath(self, path, project=None, root=None): """Returns the relative path from the root directory of the project We only store the paths relative to the root directory of the project. This method gives you this path from a path that is accessible from the current working directory ...
[ "def", "relpath", "(", "self", ",", "path", ",", "project", "=", "None", ",", "root", "=", "None", ")", ":", "if", "root", "is", "None", ":", "root", "=", "self", ".", "config", ".", "projects", "[", "project", "or", "self", ".", "projectname", "]"...
Returns the relative path from the root directory of the project We only store the paths relative to the root directory of the project. This method gives you this path from a path that is accessible from the current working directory Parameters ---------- path: str ...
[ "Returns", "the", "relative", "path", "from", "the", "root", "directory", "of", "the", "project" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L1465-L1488
train
Returns the relative path from the root directory of the project
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.setup_parser
def setup_parser(self, parser=None, subparsers=None): """ Create the argument parser for this instance This method uses the functions defined in the :attr:`commands` attribute to create a command line utility via the :class:`FuncArgParser` class. Each command in the :attr:`comma...
python
def setup_parser(self, parser=None, subparsers=None): """ Create the argument parser for this instance This method uses the functions defined in the :attr:`commands` attribute to create a command line utility via the :class:`FuncArgParser` class. Each command in the :attr:`comma...
[ "def", "setup_parser", "(", "self", ",", "parser", "=", "None", ",", "subparsers", "=", "None", ")", ":", "commands", "=", "self", ".", "commands", "[", ":", "]", "parser_cmds", "=", "self", ".", "parser_commands", ".", "copy", "(", ")", "if", "subpars...
Create the argument parser for this instance This method uses the functions defined in the :attr:`commands` attribute to create a command line utility via the :class:`FuncArgParser` class. Each command in the :attr:`commands` attribute is interpreted as on subparser and setup initially ...
[ "Create", "the", "argument", "parser", "for", "this", "instance" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L1495-L1552
train
Create the argument parser for this instance.
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.parse_args
def parse_args(self, args=None): """ Parse the arguments from the command line (or directly) to the parser of this organizer Parameters ---------- args: list A list of arguments to parse. If None, the :attr:`sys.argv` argument is used Ret...
python
def parse_args(self, args=None): """ Parse the arguments from the command line (or directly) to the parser of this organizer Parameters ---------- args: list A list of arguments to parse. If None, the :attr:`sys.argv` argument is used Ret...
[ "def", "parse_args", "(", "self", ",", "args", "=", "None", ")", ":", "if", "self", ".", "parser", "is", "None", ":", "self", ".", "setup_parser", "(", ")", "if", "not", "self", ".", "_parser_set_up", ":", "self", ".", "_finish_parser", "(", ")", "re...
Parse the arguments from the command line (or directly) to the parser of this organizer Parameters ---------- args: list A list of arguments to parse. If None, the :attr:`sys.argv` argument is used Returns ------- %(ModelOrganizer.start.r...
[ "Parse", "the", "arguments", "from", "the", "command", "line", "(", "or", "directly", ")", "to", "the", "parser", "of", "this", "organizer" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L1561-L1581
train
Parse the arguments from the command line or directly to the parser
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.get_parser
def get_parser(cls): """Function returning the command line parser for this class""" organizer = cls() organizer.setup_parser() organizer._finish_parser() return organizer.parser
python
def get_parser(cls): """Function returning the command line parser for this class""" organizer = cls() organizer.setup_parser() organizer._finish_parser() return organizer.parser
[ "def", "get_parser", "(", "cls", ")", ":", "organizer", "=", "cls", "(", ")", "organizer", ".", "setup_parser", "(", ")", "organizer", ".", "_finish_parser", "(", ")", "return", "organizer", ".", "parser" ]
Function returning the command line parser for this class
[ "Function", "returning", "the", "command", "line", "parser", "for", "this", "class" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L1584-L1589
train
Function returning the command line parser for this class
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer.is_archived
def is_archived(self, experiment, ignore_missing=True): """ Convenience function to determine whether the given experiment has been archived already Parameters ---------- experiment: str The experiment to check Returns ------- str or ...
python
def is_archived(self, experiment, ignore_missing=True): """ Convenience function to determine whether the given experiment has been archived already Parameters ---------- experiment: str The experiment to check Returns ------- str or ...
[ "def", "is_archived", "(", "self", ",", "experiment", ",", "ignore_missing", "=", "True", ")", ":", "if", "ignore_missing", ":", "if", "isinstance", "(", "self", ".", "config", ".", "experiments", ".", "get", "(", "experiment", ",", "True", ")", ",", "Ar...
Convenience function to determine whether the given experiment has been archived already Parameters ---------- experiment: str The experiment to check Returns ------- str or None The path to the archive if it has been archived, otherwise ...
[ "Convenience", "function", "to", "determine", "whether", "the", "given", "experiment", "has", "been", "archived", "already" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L1595-L1616
train
Returns the path to the archive if it has been archived already
Chilipp/model-organization
model_organization/__init__.py
ModelOrganizer._archive_extensions
def _archive_extensions(): """Create translations from file extension to archive format Returns ------- dict The mapping from file extension to archive format dict The mapping from archive format to default file extension """ if six.PY3: ...
python
def _archive_extensions(): """Create translations from file extension to archive format Returns ------- dict The mapping from file extension to archive format dict The mapping from archive format to default file extension """ if six.PY3: ...
[ "def", "_archive_extensions", "(", ")", ":", "if", "six", ".", "PY3", ":", "ext_map", "=", "{", "}", "fmt_map", "=", "{", "}", "for", "key", ",", "exts", ",", "desc", "in", "shutil", ".", "get_unpack_formats", "(", ")", ":", "fmt_map", "[", "key", ...
Create translations from file extension to archive format Returns ------- dict The mapping from file extension to archive format dict The mapping from archive format to default file extension
[ "Create", "translations", "from", "file", "extension", "to", "archive", "format" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L1619-L1650
train
Create translations from file extensions to archive format
a1ezzz/wasp-general
wasp_general/network/beacon/beacon.py
WBeaconHandler.setup_handler
def setup_handler(self, io_loop): """ :meth:`.WIOLoopServiceHandler.setup_handler` implementation. When this object is in 'non-server mode' (client mode), then beacon message is sent """ WNativeSocketHandler.setup_handler(self, io_loop) if self.server_mode() is False: self.io_handler().transport_socket().s...
python
def setup_handler(self, io_loop): """ :meth:`.WIOLoopServiceHandler.setup_handler` implementation. When this object is in 'non-server mode' (client mode), then beacon message is sent """ WNativeSocketHandler.setup_handler(self, io_loop) if self.server_mode() is False: self.io_handler().transport_socket().s...
[ "def", "setup_handler", "(", "self", ",", "io_loop", ")", ":", "WNativeSocketHandler", ".", "setup_handler", "(", "self", ",", "io_loop", ")", "if", "self", ".", "server_mode", "(", ")", "is", "False", ":", "self", ".", "io_handler", "(", ")", ".", "tran...
:meth:`.WIOLoopServiceHandler.setup_handler` implementation. When this object is in 'non-server mode' (client mode), then beacon message is sent
[ ":", "meth", ":", ".", "WIOLoopServiceHandler", ".", "setup_handler", "implementation", ".", "When", "this", "object", "is", "in", "non", "-", "server", "mode", "(", "client", "mode", ")", "then", "beacon", "message", "is", "sent" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/beacon/beacon.py#L182-L191
train
This method is called by the object s setup_handler method.
Addvilz/hemp
hemp/gitutils.py
remote_tags
def remote_tags(url): # type: (str) -> list """ List all available remote tags naturally sorted as version strings :rtype: list :param url: Remote URL of the repository :return: list of available tags """ tags = [] remote_git = Git() for line in remote_git.ls_remote('--tags', '--...
python
def remote_tags(url): # type: (str) -> list """ List all available remote tags naturally sorted as version strings :rtype: list :param url: Remote URL of the repository :return: list of available tags """ tags = [] remote_git = Git() for line in remote_git.ls_remote('--tags', '--...
[ "def", "remote_tags", "(", "url", ")", ":", "# type: (str) -> list", "tags", "=", "[", "]", "remote_git", "=", "Git", "(", ")", "for", "line", "in", "remote_git", ".", "ls_remote", "(", "'--tags'", ",", "'--quiet'", ",", "url", ")", ".", "split", "(", ...
List all available remote tags naturally sorted as version strings :rtype: list :param url: Remote URL of the repository :return: list of available tags
[ "List", "all", "available", "remote", "tags", "naturally", "sorted", "as", "version", "strings", ":", "rtype", ":", "list", ":", "param", "url", ":", "Remote", "URL", "of", "the", "repository", ":", "return", ":", "list", "of", "available", "tags" ]
80d189f15ba20068a61efc2591070c80549c9d06
https://github.com/Addvilz/hemp/blob/80d189f15ba20068a61efc2591070c80549c9d06/hemp/gitutils.py#L8-L21
train
Returns a list of all available remote tags naturally sorted as version strings
Addvilz/hemp
hemp/gitutils.py
clone
def clone(url, directory, single_branch=None): print_info('Cloning {0} to {1} {2}'.format( url, directory, '[full clone]' if single_branch is None else '[{0}]'.format(single_branch) )) # type: (str, str, str) -> Repo """ Clone a repository, optionally using shallow clone ...
python
def clone(url, directory, single_branch=None): print_info('Cloning {0} to {1} {2}'.format( url, directory, '[full clone]' if single_branch is None else '[{0}]'.format(single_branch) )) # type: (str, str, str) -> Repo """ Clone a repository, optionally using shallow clone ...
[ "def", "clone", "(", "url", ",", "directory", ",", "single_branch", "=", "None", ")", ":", "print_info", "(", "'Cloning {0} to {1} {2}'", ".", "format", "(", "url", ",", "directory", ",", "'[full clone]'", "if", "single_branch", "is", "None", "else", "'[{0}]'"...
Clone a repository, optionally using shallow clone :rtype: Repo :param url: URL of the repository :param directory: Directory to clone to :param single_branch: branch to clone if shallow clone is preferred :return: GitPython repository object of the newly cloned repository
[ "Clone", "a", "repository", "optionally", "using", "shallow", "clone", ":", "rtype", ":", "Repo", ":", "param", "url", ":", "URL", "of", "the", "repository", ":", "param", "directory", ":", "Directory", "to", "clone", "to", ":", "param", "single_branch", "...
80d189f15ba20068a61efc2591070c80549c9d06
https://github.com/Addvilz/hemp/blob/80d189f15ba20068a61efc2591070c80549c9d06/hemp/gitutils.py#L36-L63
train
Clone a GitPython repository to a specific directory.
Addvilz/hemp
hemp/gitutils.py
repo_url_to_project_name
def repo_url_to_project_name(url, normalize=True): # type: (str, bool) -> str """ Extract project title from GIT repository URL, either https or ssh. Should work fine with github, bitbucket :rtype: str :param url: Url of the repository :param normalize: Title-case the project name :retur...
python
def repo_url_to_project_name(url, normalize=True): # type: (str, bool) -> str """ Extract project title from GIT repository URL, either https or ssh. Should work fine with github, bitbucket :rtype: str :param url: Url of the repository :param normalize: Title-case the project name :retur...
[ "def", "repo_url_to_project_name", "(", "url", ",", "normalize", "=", "True", ")", ":", "# type: (str, bool) -> str", "if", "url", ".", "startswith", "(", "'http'", ")", ":", "http_url", "=", "urlparse", "(", "url", ")", "name", "=", "http_url", ".", "path",...
Extract project title from GIT repository URL, either https or ssh. Should work fine with github, bitbucket :rtype: str :param url: Url of the repository :param normalize: Title-case the project name :return: Project name
[ "Extract", "project", "title", "from", "GIT", "repository", "URL", "either", "https", "or", "ssh", ".", "Should", "work", "fine", "with", "github", "bitbucket", ":", "rtype", ":", "str", ":", "param", "url", ":", "Url", "of", "the", "repository", ":", "p...
80d189f15ba20068a61efc2591070c80549c9d06
https://github.com/Addvilz/hemp/blob/80d189f15ba20068a61efc2591070c80549c9d06/hemp/gitutils.py#L66-L83
train
Extract project name from GIT repository URL.
olitheolix/qtmacs
qtmacs/applets/pdf_reader.py
PDFReader.loadFile
def loadFile(self, fileName): """ Load and display the PDF file specified by ``fileName``. """ # Test if the file exists. if not QtCore.QFile(fileName).exists(): msg = "File <b>{}</b> does not exist".format(self.qteAppletID()) self.qteLogger.info(msg) ...
python
def loadFile(self, fileName): """ Load and display the PDF file specified by ``fileName``. """ # Test if the file exists. if not QtCore.QFile(fileName).exists(): msg = "File <b>{}</b> does not exist".format(self.qteAppletID()) self.qteLogger.info(msg) ...
[ "def", "loadFile", "(", "self", ",", "fileName", ")", ":", "# Test if the file exists.", "if", "not", "QtCore", ".", "QFile", "(", "fileName", ")", ".", "exists", "(", ")", ":", "msg", "=", "\"File <b>{}</b> does not exist\"", ".", "format", "(", "self", "."...
Load and display the PDF file specified by ``fileName``.
[ "Load", "and", "display", "the", "PDF", "file", "specified", "by", "fileName", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/applets/pdf_reader.py#L82-L119
train
Load and display the PDF file specified by fileName.
AASHE/python-membersuite-api-client
membersuite_api_client/financial/services.py
get_product
def get_product(membersuite_id, client=None): """Return a Product object by ID. """ if not membersuite_id: return None client = client or get_new_client(request_session=True) object_query = "SELECT Object() FROM PRODUCT WHERE ID = '{}'".format( membersuite_id) result = client....
python
def get_product(membersuite_id, client=None): """Return a Product object by ID. """ if not membersuite_id: return None client = client or get_new_client(request_session=True) object_query = "SELECT Object() FROM PRODUCT WHERE ID = '{}'".format( membersuite_id) result = client....
[ "def", "get_product", "(", "membersuite_id", ",", "client", "=", "None", ")", ":", "if", "not", "membersuite_id", ":", "return", "None", "client", "=", "client", "or", "get_new_client", "(", "request_session", "=", "True", ")", "object_query", "=", "\"SELECT O...
Return a Product object by ID.
[ "Return", "a", "Product", "object", "by", "ID", "." ]
221f5ed8bc7d4424237a4669c5af9edc11819ee9
https://github.com/AASHE/python-membersuite-api-client/blob/221f5ed8bc7d4424237a4669c5af9edc11819ee9/membersuite_api_client/financial/services.py#L6-L27
train
Return a Product object by ID.
a1ezzz/wasp-general
wasp_general/signals/signals.py
WSignalSource.__watchers_callbacks_exec
def __watchers_callbacks_exec(self, signal_name): """ Generate callback for a queue :param signal_name: name of a signal that callback is generated for :type signal_name: str :rtype: callable """ def callback_fn(): for watcher in self.__watchers_callbacks[signal_name]: if watcher is not None: ...
python
def __watchers_callbacks_exec(self, signal_name): """ Generate callback for a queue :param signal_name: name of a signal that callback is generated for :type signal_name: str :rtype: callable """ def callback_fn(): for watcher in self.__watchers_callbacks[signal_name]: if watcher is not None: ...
[ "def", "__watchers_callbacks_exec", "(", "self", ",", "signal_name", ")", ":", "def", "callback_fn", "(", ")", ":", "for", "watcher", "in", "self", ".", "__watchers_callbacks", "[", "signal_name", "]", ":", "if", "watcher", "is", "not", "None", ":", "watcher...
Generate callback for a queue :param signal_name: name of a signal that callback is generated for :type signal_name: str :rtype: callable
[ "Generate", "callback", "for", "a", "queue" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/signals/signals.py#L126-L138
train
Generate callback for a queue_node
a1ezzz/wasp-general
wasp_general/signals/signals.py
WSignalSource.send_signal
def send_signal(self, signal_name, signal_args=None): """ :meth:`.WSignalSourceProto.send_signal` implementation """ try: self.__queues[signal_name].push(signal_args) for callback in self.__direct_callbacks[signal_name]: if callback is not None: callback(self, signal_name, signal_args) except Key...
python
def send_signal(self, signal_name, signal_args=None): """ :meth:`.WSignalSourceProto.send_signal` implementation """ try: self.__queues[signal_name].push(signal_args) for callback in self.__direct_callbacks[signal_name]: if callback is not None: callback(self, signal_name, signal_args) except Key...
[ "def", "send_signal", "(", "self", ",", "signal_name", ",", "signal_args", "=", "None", ")", ":", "try", ":", "self", ".", "__queues", "[", "signal_name", "]", ".", "push", "(", "signal_args", ")", "for", "callback", "in", "self", ".", "__direct_callbacks"...
:meth:`.WSignalSourceProto.send_signal` implementation
[ ":", "meth", ":", ".", "WSignalSourceProto", ".", "send_signal", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/signals/signals.py#L141-L150
train
method for sending a signal
a1ezzz/wasp-general
wasp_general/signals/signals.py
WSignalSource.watch
def watch(self, signal_name): """ :meth:`.WSignalSourceProto.watch` implementation :rtype: watcher: WSignalSource.Watcher """ watcher = WSignalSource.Watcher( self.__queues[signal_name], lambda x: self.__watchers_callbacks[signal_name].remove(x) ) self.__watchers_callbacks[signal_name].add(watcher) re...
python
def watch(self, signal_name): """ :meth:`.WSignalSourceProto.watch` implementation :rtype: watcher: WSignalSource.Watcher """ watcher = WSignalSource.Watcher( self.__queues[signal_name], lambda x: self.__watchers_callbacks[signal_name].remove(x) ) self.__watchers_callbacks[signal_name].add(watcher) re...
[ "def", "watch", "(", "self", ",", "signal_name", ")", ":", "watcher", "=", "WSignalSource", ".", "Watcher", "(", "self", ".", "__queues", "[", "signal_name", "]", ",", "lambda", "x", ":", "self", ".", "__watchers_callbacks", "[", "signal_name", "]", ".", ...
:meth:`.WSignalSourceProto.watch` implementation :rtype: watcher: WSignalSource.Watcher
[ ":", "meth", ":", ".", "WSignalSourceProto", ".", "watch", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/signals/signals.py#L158-L167
train
meth :. WSignalSourceProto. watch implementation
a1ezzz/wasp-general
wasp_general/signals/signals.py
WSignalSource.remove_callback
def remove_callback(self, signal_name, callback): """ :meth:`.WSignalSourceProto.remove_callback` implementation """ try: self.__direct_callbacks[signal_name].remove(callback) except KeyError: raise ValueError('Signal "%s" does not have the specified callback' % signal_name)
python
def remove_callback(self, signal_name, callback): """ :meth:`.WSignalSourceProto.remove_callback` implementation """ try: self.__direct_callbacks[signal_name].remove(callback) except KeyError: raise ValueError('Signal "%s" does not have the specified callback' % signal_name)
[ "def", "remove_callback", "(", "self", ",", "signal_name", ",", "callback", ")", ":", "try", ":", "self", ".", "__direct_callbacks", "[", "signal_name", "]", ".", "remove", "(", "callback", ")", "except", "KeyError", ":", "raise", "ValueError", "(", "'Signal...
:meth:`.WSignalSourceProto.remove_callback` implementation
[ ":", "meth", ":", ".", "WSignalSourceProto", ".", "remove_callback", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/signals/signals.py#L186-L192
train
Removes a callback from the list of callbacks for a given signal.
a1ezzz/wasp-general
wasp_general/signals/signals.py
WSignalProxy.proxy
def proxy(self, signal_source, *signal_names, weak_ref=False): """ :meth:`.WSignalProxyProto.proxy` implementation """ callback = self.__callback if weak_ref is False else self.__weak_ref_callback for signal_name in signal_names: signal_source.callback(signal_name, callback)
python
def proxy(self, signal_source, *signal_names, weak_ref=False): """ :meth:`.WSignalProxyProto.proxy` implementation """ callback = self.__callback if weak_ref is False else self.__weak_ref_callback for signal_name in signal_names: signal_source.callback(signal_name, callback)
[ "def", "proxy", "(", "self", ",", "signal_source", ",", "*", "signal_names", ",", "weak_ref", "=", "False", ")", ":", "callback", "=", "self", ".", "__callback", "if", "weak_ref", "is", "False", "else", "self", ".", "__weak_ref_callback", "for", "signal_name...
:meth:`.WSignalProxyProto.proxy` implementation
[ ":", "meth", ":", ".", "WSignalProxyProto", ".", "proxy", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/signals/signals.py#L291-L296
train
Implementation of the WSignalProxyProto. proxy method.
a1ezzz/wasp-general
wasp_general/signals/signals.py
WSignalProxy.stop_proxying
def stop_proxying(self, signal_source, *signal_names, weak_ref=False): """ :meth:`.WSignalProxyProto.stop_proxying` implementation """ callback = self.__callback if weak_ref is False else self.__weak_ref_callback for signal_name in signal_names: signal_source.remove_callback(signal_name, callback)
python
def stop_proxying(self, signal_source, *signal_names, weak_ref=False): """ :meth:`.WSignalProxyProto.stop_proxying` implementation """ callback = self.__callback if weak_ref is False else self.__weak_ref_callback for signal_name in signal_names: signal_source.remove_callback(signal_name, callback)
[ "def", "stop_proxying", "(", "self", ",", "signal_source", ",", "*", "signal_names", ",", "weak_ref", "=", "False", ")", ":", "callback", "=", "self", ".", "__callback", "if", "weak_ref", "is", "False", "else", "self", ".", "__weak_ref_callback", "for", "sig...
:meth:`.WSignalProxyProto.stop_proxying` implementation
[ ":", "meth", ":", ".", "WSignalProxyProto", ".", "stop_proxying", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/signals/signals.py#L299-L304
train
Implementation of the ISignalProxyProto. stop_proxying method.
weijia/djangoautoconf
djangoautoconf/ajax_select_utils/channel_creator_for_model.py
create_channels_for_related_fields_in_model
def create_channels_for_related_fields_in_model(model_class): """ Create channel for the fields of the model, the channel name can be got by calling get_ajax_config_for_relation_fields :param model_class: :return: """ need_to_create_channel = [] for field in enum_model_fields(model_class): ...
python
def create_channels_for_related_fields_in_model(model_class): """ Create channel for the fields of the model, the channel name can be got by calling get_ajax_config_for_relation_fields :param model_class: :return: """ need_to_create_channel = [] for field in enum_model_fields(model_class): ...
[ "def", "create_channels_for_related_fields_in_model", "(", "model_class", ")", ":", "need_to_create_channel", "=", "[", "]", "for", "field", "in", "enum_model_fields", "(", "model_class", ")", ":", "if", "type", "(", "field", ")", "in", "get_relation_field_types", "...
Create channel for the fields of the model, the channel name can be got by calling get_ajax_config_for_relation_fields :param model_class: :return:
[ "Create", "channel", "for", "the", "fields", "of", "the", "model", "the", "channel", "name", "can", "be", "got", "by", "calling", "get_ajax_config_for_relation_fields", ":", "param", "model_class", ":", ":", "return", ":" ]
b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0
https://github.com/weijia/djangoautoconf/blob/b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0/djangoautoconf/ajax_select_utils/channel_creator_for_model.py#L9-L30
train
Create a list of channels for the fields of the model.
Loudr/pale
pale/utils.py
py_doc_trim
def py_doc_trim(docstring): """Trim a python doc string. This example is nipped from https://www.python.org/dev/peps/pep-0257/, which describes how to conventionally format and trim docstrings. It has been modified to replace single newlines with a space, but leave multiple consecutive newlines in...
python
def py_doc_trim(docstring): """Trim a python doc string. This example is nipped from https://www.python.org/dev/peps/pep-0257/, which describes how to conventionally format and trim docstrings. It has been modified to replace single newlines with a space, but leave multiple consecutive newlines in...
[ "def", "py_doc_trim", "(", "docstring", ")", ":", "if", "not", "docstring", ":", "return", "''", "# Convert tabs to spaces (following the normal Python rules)", "# and split into a list of lines:", "lines", "=", "docstring", ".", "expandtabs", "(", ")", ".", "splitlines",...
Trim a python doc string. This example is nipped from https://www.python.org/dev/peps/pep-0257/, which describes how to conventionally format and trim docstrings. It has been modified to replace single newlines with a space, but leave multiple consecutive newlines in tact.
[ "Trim", "a", "python", "doc", "string", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/utils.py#L11-L44
train
Trim a python doc string.
Loudr/pale
pale/resource.py
Resource._fix_up_fields
def _fix_up_fields(cls): """Add names to all of the Resource fields. This method will get called on class declaration because of Resource's metaclass. The functionality is based on Google's NDB implementation. `Endpoint` does something similar for `arguments`. """ ...
python
def _fix_up_fields(cls): """Add names to all of the Resource fields. This method will get called on class declaration because of Resource's metaclass. The functionality is based on Google's NDB implementation. `Endpoint` does something similar for `arguments`. """ ...
[ "def", "_fix_up_fields", "(", "cls", ")", ":", "cls", ".", "_fields", "=", "{", "}", "if", "cls", ".", "__module__", "==", "__name__", "and", "cls", ".", "__name__", "!=", "'DebugResource'", ":", "return", "for", "name", "in", "set", "(", "dir", "(", ...
Add names to all of the Resource fields. This method will get called on class declaration because of Resource's metaclass. The functionality is based on Google's NDB implementation. `Endpoint` does something similar for `arguments`.
[ "Add", "names", "to", "all", "of", "the", "Resource", "fields", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/resource.py#L19-L42
train
Add names to all of the Resource fields.
Loudr/pale
pale/resource.py
Resource._render_serializable
def _render_serializable(self, obj, context): """Renders a JSON-serializable version of the object passed in. Usually this means turning a Python object into a dict, but sometimes it might make sense to render a list, or a string, or a tuple. In this base class, we provide a default imp...
python
def _render_serializable(self, obj, context): """Renders a JSON-serializable version of the object passed in. Usually this means turning a Python object into a dict, but sometimes it might make sense to render a list, or a string, or a tuple. In this base class, we provide a default imp...
[ "def", "_render_serializable", "(", "self", ",", "obj", ",", "context", ")", ":", "logging", ".", "info", "(", "\"\"\"Careful, you're calling ._render_serializable on the\n base resource, which is probably not what you actually want to be\n doing!\"\"\"", ")", "if", "...
Renders a JSON-serializable version of the object passed in. Usually this means turning a Python object into a dict, but sometimes it might make sense to render a list, or a string, or a tuple. In this base class, we provide a default implementation that assumes some things about your a...
[ "Renders", "a", "JSON", "-", "serializable", "version", "of", "the", "object", "passed", "in", ".", "Usually", "this", "means", "turning", "a", "Python", "object", "into", "a", "dict", "but", "sometimes", "it", "might", "make", "sense", "to", "render", "a"...
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/resource.py#L59-L89
train
Renders a JSON - serializable version of the object passed in.
Loudr/pale
pale/resource.py
ResourceList._render_serializable
def _render_serializable(self, list_of_objs, context): """Iterates through the passed in `list_of_objs` and calls the `_render_serializable` method of each object's Resource type. This will probably support heterogeneous types at some point (hence the `item_types` initialization, as opp...
python
def _render_serializable(self, list_of_objs, context): """Iterates through the passed in `list_of_objs` and calls the `_render_serializable` method of each object's Resource type. This will probably support heterogeneous types at some point (hence the `item_types` initialization, as opp...
[ "def", "_render_serializable", "(", "self", ",", "list_of_objs", ",", "context", ")", ":", "output", "=", "[", "]", "for", "obj", "in", "list_of_objs", ":", "if", "obj", "is", "not", "None", ":", "item", "=", "self", ".", "_item_resource", ".", "_render_...
Iterates through the passed in `list_of_objs` and calls the `_render_serializable` method of each object's Resource type. This will probably support heterogeneous types at some point (hence the `item_types` initialization, as opposed to just item_type), but that might be better suited t...
[ "Iterates", "through", "the", "passed", "in", "list_of_objs", "and", "calls", "the", "_render_serializable", "method", "of", "each", "object", "s", "Resource", "type", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/resource.py#L116-L132
train
Returns a list of JSON - serializable items for the passed in list_of_objs.
a1ezzz/wasp-general
wasp_general/thread.py
critical_section_dynamic_lock
def critical_section_dynamic_lock(lock_fn, blocking=True, timeout=None, raise_exception=True): """ Protect a function with a lock, that was get from the specified function. If a lock can not be acquire, then no function call will be made :param lock_fn: callable that returns a lock, with which a function may be pro...
python
def critical_section_dynamic_lock(lock_fn, blocking=True, timeout=None, raise_exception=True): """ Protect a function with a lock, that was get from the specified function. If a lock can not be acquire, then no function call will be made :param lock_fn: callable that returns a lock, with which a function may be pro...
[ "def", "critical_section_dynamic_lock", "(", "lock_fn", ",", "blocking", "=", "True", ",", "timeout", "=", "None", ",", "raise_exception", "=", "True", ")", ":", "if", "blocking", "is", "False", "or", "timeout", "is", "None", ":", "timeout", "=", "-", "1",...
Protect a function with a lock, that was get from the specified function. If a lock can not be acquire, then no function call will be made :param lock_fn: callable that returns a lock, with which a function may be protected :param blocking: whenever to block operations with lock acquiring :param timeout: timeout w...
[ "Protect", "a", "function", "with", "a", "lock", "that", "was", "get", "from", "the", "specified", "function", ".", "If", "a", "lock", "can", "not", "be", "acquire", "then", "no", "function", "call", "will", "be", "made" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/thread.py#L42-L70
train
This is a decorator that protects a function with a lock that was get from the specified function.
a1ezzz/wasp-general
wasp_general/thread.py
critical_section_lock
def critical_section_lock(lock=None, blocking=True, timeout=None, raise_exception=True): """ An a wrapper for :func:`.critical_section_dynamic_lock` function call, but uses a static lock object instead of a function that returns a lock with which a function protection will be made :param lock: lock with which a fun...
python
def critical_section_lock(lock=None, blocking=True, timeout=None, raise_exception=True): """ An a wrapper for :func:`.critical_section_dynamic_lock` function call, but uses a static lock object instead of a function that returns a lock with which a function protection will be made :param lock: lock with which a fun...
[ "def", "critical_section_lock", "(", "lock", "=", "None", ",", "blocking", "=", "True", ",", "timeout", "=", "None", ",", "raise_exception", "=", "True", ")", ":", "def", "lock_getter", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "lo...
An a wrapper for :func:`.critical_section_dynamic_lock` function call, but uses a static lock object instead of a function that returns a lock with which a function protection will be made :param lock: lock with which a function will be protected :param blocking: same as blocking in :func:`.critical_section_dynamic...
[ "An", "a", "wrapper", "for", ":", "func", ":", ".", "critical_section_dynamic_lock", "function", "call", "but", "uses", "a", "static", "lock", "object", "instead", "of", "a", "function", "that", "returns", "a", "lock", "with", "which", "a", "function", "prot...
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/thread.py#L76-L93
train
A decorator for the critical section dynamic lock function.
Loudr/pale
pale/doc.py
clean_description
def clean_description(string): """Clean strings returned from API resources and endpoints: - remove newlines and leading whitespace - replace colons with &#58; to avoid problems with RAML validation - remove things like: <pale.fields.string.StringField object at 0x106edbed0> - replac...
python
def clean_description(string): """Clean strings returned from API resources and endpoints: - remove newlines and leading whitespace - replace colons with &#58; to avoid problems with RAML validation - remove things like: <pale.fields.string.StringField object at 0x106edbed0> - replac...
[ "def", "clean_description", "(", "string", ")", ":", "leading_whitespace", "=", "re", ".", "compile", "(", "r\"(\\A\\s+)\"", ")", "multiple_spaces", "=", "re", ".", "compile", "(", "r\"(\\s+\\s+)\"", ")", "newlines", "=", "re", ".", "compile", "(", "r\"\\n\"",...
Clean strings returned from API resources and endpoints: - remove newlines and leading whitespace - replace colons with &#58; to avoid problems with RAML validation - remove things like: <pale.fields.string.StringField object at 0x106edbed0> - replace double spaces with single spaces ...
[ "Clean", "strings", "returned", "from", "API", "resources", "and", "endpoints", ":", "-", "remove", "newlines", "and", "leading", "whitespace", "-", "replace", "colons", "with", "&#58", ";", "to", "avoid", "problems", "with", "RAML", "validation", "-", "remove...
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/doc.py#L47-L78
train
Clean a string returned from API resources and endpoints
Loudr/pale
pale/doc.py
generate_json_docs
def generate_json_docs(module, pretty_print=False, user=None): """Return a JSON string format of a Pale module's documentation. This string can either be printed out, written to a file, or piped to some other tool. This method is a shorthand for calling `generate_doc_dict` and passing it into a js...
python
def generate_json_docs(module, pretty_print=False, user=None): """Return a JSON string format of a Pale module's documentation. This string can either be printed out, written to a file, or piped to some other tool. This method is a shorthand for calling `generate_doc_dict` and passing it into a js...
[ "def", "generate_json_docs", "(", "module", ",", "pretty_print", "=", "False", ",", "user", "=", "None", ")", ":", "indent", "=", "None", "separators", "=", "(", "','", ",", "':'", ")", "if", "pretty_print", ":", "indent", "=", "4", "separators", "=", ...
Return a JSON string format of a Pale module's documentation. This string can either be printed out, written to a file, or piped to some other tool. This method is a shorthand for calling `generate_doc_dict` and passing it into a json serializer. The user argument is optional. If included, it exp...
[ "Return", "a", "JSON", "string", "format", "of", "a", "Pale", "module", "s", "documentation", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/doc.py#L81-L104
train
Return a JSON string format of a Pale module s documentation.
Loudr/pale
pale/doc.py
generate_raml_docs
def generate_raml_docs(module, fields, shared_types, user=None, title="My API", version="v1", api_root="api", base_uri="http://mysite.com/{version}"): """Return a RAML file of a Pale module's documentation as a string. The user argument is optional. If included, it expects the user to be an object with an "is_...
python
def generate_raml_docs(module, fields, shared_types, user=None, title="My API", version="v1", api_root="api", base_uri="http://mysite.com/{version}"): """Return a RAML file of a Pale module's documentation as a string. The user argument is optional. If included, it expects the user to be an object with an "is_...
[ "def", "generate_raml_docs", "(", "module", ",", "fields", ",", "shared_types", ",", "user", "=", "None", ",", "title", "=", "\"My API\"", ",", "version", "=", "\"v1\"", ",", "api_root", "=", "\"api\"", ",", "base_uri", "=", "\"http://mysite.com/{version}\"", ...
Return a RAML file of a Pale module's documentation as a string. The user argument is optional. If included, it expects the user to be an object with an "is_admin" boolean attribute. Any endpoint protected with a "@requires_permission" decorator will require user.is_admin == True to display documentation o...
[ "Return", "a", "RAML", "file", "of", "a", "Pale", "module", "s", "documentation", "as", "a", "string", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/doc.py#L107-L169
train
Generates a RAML file of a Pale module s documentation as a string.
Loudr/pale
pale/doc.py
generate_type_docs
def generate_type_docs(types): """Parse an object of types and generate RAML documentation for them. Expects each type to be either a regular type or a list/array. If a type is a list, it must specify what type to use for each item. """ output = StringIO() indent = " " # 2 # loop through...
python
def generate_type_docs(types): """Parse an object of types and generate RAML documentation for them. Expects each type to be either a regular type or a list/array. If a type is a list, it must specify what type to use for each item. """ output = StringIO() indent = " " # 2 # loop through...
[ "def", "generate_type_docs", "(", "types", ")", ":", "output", "=", "StringIO", "(", ")", "indent", "=", "\" \"", "# 2", "# loop through the basic types and add them to the RAML formatted output", "for", "type_name", "in", "types", ":", "if", "types", "[", "type_name...
Parse an object of types and generate RAML documentation for them. Expects each type to be either a regular type or a list/array. If a type is a list, it must specify what type to use for each item.
[ "Parse", "an", "object", "of", "types", "and", "generate", "RAML", "documentation", "for", "them", ".", "Expects", "each", "type", "to", "be", "either", "a", "regular", "type", "or", "a", "list", "/", "array", ".", "If", "a", "type", "is", "a", "list",...
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/doc.py#L172-L212
train
Parse an object of types and generate RAML documentation for each type.
Loudr/pale
pale/doc.py
generate_basic_type_docs
def generate_basic_type_docs(fields, existing_types): """Map resource types to their RAML equivalents. Expects fields to be a list of modules - each module would be something like pale.fields. Expects existing_types to be a list of dict of existing types, which will take precedence and prevent a new typ...
python
def generate_basic_type_docs(fields, existing_types): """Map resource types to their RAML equivalents. Expects fields to be a list of modules - each module would be something like pale.fields. Expects existing_types to be a list of dict of existing types, which will take precedence and prevent a new typ...
[ "def", "generate_basic_type_docs", "(", "fields", ",", "existing_types", ")", ":", "# These types are standard in RAML 1.0", "# They should not be defined in the RAML file that we return", "# We will inherit from them in the types we define", "raml_built_in_types", "=", "{", "\"any\"", ...
Map resource types to their RAML equivalents. Expects fields to be a list of modules - each module would be something like pale.fields. Expects existing_types to be a list of dict of existing types, which will take precedence and prevent a new type with the same name from being added. For more on RAML ...
[ "Map", "resource", "types", "to", "their", "RAML", "equivalents", ".", "Expects", "fields", "to", "be", "a", "list", "of", "modules", "-", "each", "module", "would", "be", "something", "like", "pale", ".", "fields", ".", "Expects", "existing_types", "to", ...
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/doc.py#L215-L346
train
Generate basic type documentation for a resource type.
Loudr/pale
pale/doc.py
generate_raml_resource_types
def generate_raml_resource_types(module): """Compile a Pale module's resource documentation into RAML format. RAML calls Pale resources 'resourceTypes'. This function converts Pale resources into the RAML resourceType format. The returned string should be appended to the RAML documentation string ...
python
def generate_raml_resource_types(module): """Compile a Pale module's resource documentation into RAML format. RAML calls Pale resources 'resourceTypes'. This function converts Pale resources into the RAML resourceType format. The returned string should be appended to the RAML documentation string ...
[ "def", "generate_raml_resource_types", "(", "module", ")", ":", "from", "pale", "import", "extract_endpoints", ",", "extract_resources", ",", "is_pale_module", "if", "not", "is_pale_module", "(", "module", ")", ":", "raise", "ValueError", "(", "\"\"\"The passed in `mo...
Compile a Pale module's resource documentation into RAML format. RAML calls Pale resources 'resourceTypes'. This function converts Pale resources into the RAML resourceType format. The returned string should be appended to the RAML documentation string before it is returned.
[ "Compile", "a", "Pale", "module", "s", "resource", "documentation", "into", "RAML", "format", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/doc.py#L349-L464
train
Generates a RAML resource types list from a Pale module s resource types.
Loudr/pale
pale/doc.py
generate_raml_tree
def generate_raml_tree(flat_resources, api_root): """Generate a dict of OrderedDicts, using the URIs of the Pale endpoints as the structure for the tree. Each level of the tree will contain a "path" property and an "endpoint" property. The "path" will contain further nested endpoints, sorted alphabetically....
python
def generate_raml_tree(flat_resources, api_root): """Generate a dict of OrderedDicts, using the URIs of the Pale endpoints as the structure for the tree. Each level of the tree will contain a "path" property and an "endpoint" property. The "path" will contain further nested endpoints, sorted alphabetically....
[ "def", "generate_raml_tree", "(", "flat_resources", ",", "api_root", ")", ":", "def", "clean_angle_brackets", "(", "string", ")", ":", "\"\"\"Remove the angle brackets from a string and return the cleaned string\"\"\"", "if", "string", "==", "None", ":", "result", "=", "N...
Generate a dict of OrderedDicts, using the URIs of the Pale endpoints as the structure for the tree. Each level of the tree will contain a "path" property and an "endpoint" property. The "path" will contain further nested endpoints, sorted alphabetically. The "endpoint" will contain the documentation on the...
[ "Generate", "a", "dict", "of", "OrderedDicts", "using", "the", "URIs", "of", "the", "Pale", "endpoints", "as", "the", "structure", "for", "the", "tree", ".", "Each", "level", "of", "the", "tree", "will", "contain", "a", "path", "property", "and", "an", "...
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/doc.py#L468-L570
train
Generates a dict of OrderedDicts using the URIs of the Pale endpoints as the structure for the tree.
Loudr/pale
pale/doc.py
generate_raml_resources
def generate_raml_resources(module, api_root, user): """Compile a Pale module's endpoint documentation into RAML format. RAML calls Pale endpoints 'resources'. This function converts Pale endpoints into RAML resource format. The returned string should be appended to the RAML documentation file bef...
python
def generate_raml_resources(module, api_root, user): """Compile a Pale module's endpoint documentation into RAML format. RAML calls Pale endpoints 'resources'. This function converts Pale endpoints into RAML resource format. The returned string should be appended to the RAML documentation file bef...
[ "def", "generate_raml_resources", "(", "module", ",", "api_root", ",", "user", ")", ":", "from", "pale", "import", "extract_endpoints", ",", "extract_resources", ",", "is_pale_module", "if", "not", "is_pale_module", "(", "module", ")", ":", "raise", "ValueError", ...
Compile a Pale module's endpoint documentation into RAML format. RAML calls Pale endpoints 'resources'. This function converts Pale endpoints into RAML resource format. The returned string should be appended to the RAML documentation file before it is returned.
[ "Compile", "a", "Pale", "module", "s", "endpoint", "documentation", "into", "RAML", "format", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/doc.py#L576-L777
train
Generates a RAML resource file from a Pale module s endpoint documentation.
Loudr/pale
pale/doc.py
generate_doc_dict
def generate_doc_dict(module, user): """Compile a Pale module's documentation into a python dictionary. The returned dictionary is suitable to be rendered by a JSON formatter, or passed to a template engine, or manipulated in some other way. """ from pale import extract_endpoints, extract_resources...
python
def generate_doc_dict(module, user): """Compile a Pale module's documentation into a python dictionary. The returned dictionary is suitable to be rendered by a JSON formatter, or passed to a template engine, or manipulated in some other way. """ from pale import extract_endpoints, extract_resources...
[ "def", "generate_doc_dict", "(", "module", ",", "user", ")", ":", "from", "pale", "import", "extract_endpoints", ",", "extract_resources", ",", "is_pale_module", "if", "not", "is_pale_module", "(", "module", ")", ":", "raise", "ValueError", "(", "\"\"\"The passed ...
Compile a Pale module's documentation into a python dictionary. The returned dictionary is suitable to be rendered by a JSON formatter, or passed to a template engine, or manipulated in some other way.
[ "Compile", "a", "Pale", "module", "s", "documentation", "into", "a", "python", "dictionary", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/doc.py#L781-L815
train
Compile a Pale module s documentation into a python dictionary.
Loudr/pale
pale/doc.py
document_endpoint
def document_endpoint(endpoint): """Extract the full documentation dictionary from the endpoint.""" descr = clean_description(py_doc_trim(endpoint.__doc__)) docs = { 'name': endpoint._route_name, 'http_method': endpoint._http_method, 'uri': endpoint._uri, 'description': descr...
python
def document_endpoint(endpoint): """Extract the full documentation dictionary from the endpoint.""" descr = clean_description(py_doc_trim(endpoint.__doc__)) docs = { 'name': endpoint._route_name, 'http_method': endpoint._http_method, 'uri': endpoint._uri, 'description': descr...
[ "def", "document_endpoint", "(", "endpoint", ")", ":", "descr", "=", "clean_description", "(", "py_doc_trim", "(", "endpoint", ".", "__doc__", ")", ")", "docs", "=", "{", "'name'", ":", "endpoint", ".", "_route_name", ",", "'http_method'", ":", "endpoint", "...
Extract the full documentation dictionary from the endpoint.
[ "Extract", "the", "full", "documentation", "dictionary", "from", "the", "endpoint", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/doc.py#L818-L833
train
Extract the full documentation dictionary from the endpoint.
Loudr/pale
pale/doc.py
extract_endpoint_arguments
def extract_endpoint_arguments(endpoint): """Extract the argument documentation from the endpoint.""" ep_args = endpoint._arguments if ep_args is None: return None arg_docs = { k: format_endpoint_argument_doc(a) \ for k, a in ep_args.iteritems() } return arg_docs
python
def extract_endpoint_arguments(endpoint): """Extract the argument documentation from the endpoint.""" ep_args = endpoint._arguments if ep_args is None: return None arg_docs = { k: format_endpoint_argument_doc(a) \ for k, a in ep_args.iteritems() } return arg_docs
[ "def", "extract_endpoint_arguments", "(", "endpoint", ")", ":", "ep_args", "=", "endpoint", ".", "_arguments", "if", "ep_args", "is", "None", ":", "return", "None", "arg_docs", "=", "{", "k", ":", "format_endpoint_argument_doc", "(", "a", ")", "for", "k", ",...
Extract the argument documentation from the endpoint.
[ "Extract", "the", "argument", "documentation", "from", "the", "endpoint", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/doc.py#L836-L845
train
Extract the argument documentation from the endpoint.
Loudr/pale
pale/doc.py
format_endpoint_argument_doc
def format_endpoint_argument_doc(argument): """Return documentation about the argument that an endpoint accepts.""" doc = argument.doc_dict() # Trim the strings a bit doc['description'] = clean_description(py_doc_trim(doc['description'])) details = doc.get('detailed_description', None) if detai...
python
def format_endpoint_argument_doc(argument): """Return documentation about the argument that an endpoint accepts.""" doc = argument.doc_dict() # Trim the strings a bit doc['description'] = clean_description(py_doc_trim(doc['description'])) details = doc.get('detailed_description', None) if detai...
[ "def", "format_endpoint_argument_doc", "(", "argument", ")", ":", "doc", "=", "argument", ".", "doc_dict", "(", ")", "# Trim the strings a bit", "doc", "[", "'description'", "]", "=", "clean_description", "(", "py_doc_trim", "(", "doc", "[", "'description'", "]", ...
Return documentation about the argument that an endpoint accepts.
[ "Return", "documentation", "about", "the", "argument", "that", "an", "endpoint", "accepts", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/doc.py#L848-L858
train
Return documentation about the argument that an endpoint accepts.
Loudr/pale
pale/doc.py
format_endpoint_returns_doc
def format_endpoint_returns_doc(endpoint): """Return documentation about the resource that an endpoint returns.""" description = clean_description(py_doc_trim(endpoint._returns._description)) return { 'description': description, 'resource_name': endpoint._returns._value_type, 'resour...
python
def format_endpoint_returns_doc(endpoint): """Return documentation about the resource that an endpoint returns.""" description = clean_description(py_doc_trim(endpoint._returns._description)) return { 'description': description, 'resource_name': endpoint._returns._value_type, 'resour...
[ "def", "format_endpoint_returns_doc", "(", "endpoint", ")", ":", "description", "=", "clean_description", "(", "py_doc_trim", "(", "endpoint", ".", "_returns", ".", "_description", ")", ")", "return", "{", "'description'", ":", "description", ",", "'resource_name'",...
Return documentation about the resource that an endpoint returns.
[ "Return", "documentation", "about", "the", "resource", "that", "an", "endpoint", "returns", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/doc.py#L861-L868
train
Return documentation about the resource that an endpoint returns.
tBaxter/tango-contact-manager
build/lib/contact_manager/models.py
Contact.save
def save(self, *args, **kwargs): """ Create formatted version of body text. """ self.body_formatted = sanetize_text(self.body) super(Contact, self).save()
python
def save(self, *args, **kwargs): """ Create formatted version of body text. """ self.body_formatted = sanetize_text(self.body) super(Contact, self).save()
[ "def", "save", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "body_formatted", "=", "sanetize_text", "(", "self", ".", "body", ")", "super", "(", "Contact", ",", "self", ")", ".", "save", "(", ")" ]
Create formatted version of body text.
[ "Create", "formatted", "version", "of", "body", "text", "." ]
7bd5be326a8db8f438cdefff0fbd14849d0474a5
https://github.com/tBaxter/tango-contact-manager/blob/7bd5be326a8db8f438cdefff0fbd14849d0474a5/build/lib/contact_manager/models.py#L239-L244
train
Create formatted version of body text.
AASHE/python-membersuite-api-client
membersuite_api_client/memberships/services.py
MembershipService.get_current_membership_for_org
def get_current_membership_for_org(self, account_num, verbose=False): """Return a current membership for this org, or, None if there is none. """ all_memberships = self.get_memberships_for_org( account_num=account_num, verbose=verbose) # Look for first mem...
python
def get_current_membership_for_org(self, account_num, verbose=False): """Return a current membership for this org, or, None if there is none. """ all_memberships = self.get_memberships_for_org( account_num=account_num, verbose=verbose) # Look for first mem...
[ "def", "get_current_membership_for_org", "(", "self", ",", "account_num", ",", "verbose", "=", "False", ")", ":", "all_memberships", "=", "self", ".", "get_memberships_for_org", "(", "account_num", "=", "account_num", ",", "verbose", "=", "verbose", ")", "# Look f...
Return a current membership for this org, or, None if there is none.
[ "Return", "a", "current", "membership", "for", "this", "org", "or", "None", "if", "there", "is", "none", "." ]
221f5ed8bc7d4424237a4669c5af9edc11819ee9
https://github.com/AASHE/python-membersuite-api-client/blob/221f5ed8bc7d4424237a4669c5af9edc11819ee9/membersuite_api_client/memberships/services.py#L22-L34
train
Return the current membership for this org or None if there is none.
AASHE/python-membersuite-api-client
membersuite_api_client/memberships/services.py
MembershipService.get_memberships_for_org
def get_memberships_for_org(self, account_num, verbose=False): """ Retrieve all memberships associated with an organization, ordered by expiration date. """ if not self.client.session_id: self.client.request_session() query = "SELECT Objects() FROM Membership...
python
def get_memberships_for_org(self, account_num, verbose=False): """ Retrieve all memberships associated with an organization, ordered by expiration date. """ if not self.client.session_id: self.client.request_session() query = "SELECT Objects() FROM Membership...
[ "def", "get_memberships_for_org", "(", "self", ",", "account_num", ",", "verbose", "=", "False", ")", ":", "if", "not", "self", ".", "client", ".", "session_id", ":", "self", ".", "client", ".", "request_session", "(", ")", "query", "=", "\"SELECT Objects() ...
Retrieve all memberships associated with an organization, ordered by expiration date.
[ "Retrieve", "all", "memberships", "associated", "with", "an", "organization", "ordered", "by", "expiration", "date", "." ]
221f5ed8bc7d4424237a4669c5af9edc11819ee9
https://github.com/AASHE/python-membersuite-api-client/blob/221f5ed8bc7d4424237a4669c5af9edc11819ee9/membersuite_api_client/memberships/services.py#L36-L48
train
Retrieve all memberships associated with an organization.
AASHE/python-membersuite-api-client
membersuite_api_client/memberships/services.py
MembershipService.get_all_memberships
def get_all_memberships( self, limit_to=100, max_calls=None, parameters=None, since_when=None, start_record=0, verbose=False): """ Retrieve all memberships updated since "since_when" Loop over queries of size limit_to until either a non-full queryset is returned,...
python
def get_all_memberships( self, limit_to=100, max_calls=None, parameters=None, since_when=None, start_record=0, verbose=False): """ Retrieve all memberships updated since "since_when" Loop over queries of size limit_to until either a non-full queryset is returned,...
[ "def", "get_all_memberships", "(", "self", ",", "limit_to", "=", "100", ",", "max_calls", "=", "None", ",", "parameters", "=", "None", ",", "since_when", "=", "None", ",", "start_record", "=", "0", ",", "verbose", "=", "False", ")", ":", "if", "not", "...
Retrieve all memberships updated since "since_when" Loop over queries of size limit_to until either a non-full queryset is returned, or max_depth is reached (used in tests). Then the recursion collapses to return a single concatenated list.
[ "Retrieve", "all", "memberships", "updated", "since", "since_when" ]
221f5ed8bc7d4424237a4669c5af9edc11819ee9
https://github.com/AASHE/python-membersuite-api-client/blob/221f5ed8bc7d4424237a4669c5af9edc11819ee9/membersuite_api_client/memberships/services.py#L50-L92
train
Get all memberships updated since since_when
AASHE/python-membersuite-api-client
membersuite_api_client/memberships/services.py
MembershipProductService.get_all_membership_products
def get_all_membership_products(self, verbose=False): """ Retrieves membership product objects """ if not self.client.session_id: self.client.request_session() query = "SELECT Objects() FROM MembershipDuesProduct" membership_product_list = self.get_long_quer...
python
def get_all_membership_products(self, verbose=False): """ Retrieves membership product objects """ if not self.client.session_id: self.client.request_session() query = "SELECT Objects() FROM MembershipDuesProduct" membership_product_list = self.get_long_quer...
[ "def", "get_all_membership_products", "(", "self", ",", "verbose", "=", "False", ")", ":", "if", "not", "self", ".", "client", ".", "session_id", ":", "self", ".", "client", ".", "request_session", "(", ")", "query", "=", "\"SELECT Objects() FROM MembershipDuesP...
Retrieves membership product objects
[ "Retrieves", "membership", "product", "objects" ]
221f5ed8bc7d4424237a4669c5af9edc11819ee9
https://github.com/AASHE/python-membersuite-api-client/blob/221f5ed8bc7d4424237a4669c5af9edc11819ee9/membersuite_api_client/memberships/services.py#L109-L119
train
Retrieves all membership products
mangalam-research/selenic
selenic/builder.py
chromedriver_element_center_patch
def chromedriver_element_center_patch(): """ Patch move_to_element on ActionChains to work around a bug present in Chromedriver 2.14 to 2.20. Calling this function multiple times in the same process will install the patch once, and just once. """ patch_name = "_selenic_chromedriver_element...
python
def chromedriver_element_center_patch(): """ Patch move_to_element on ActionChains to work around a bug present in Chromedriver 2.14 to 2.20. Calling this function multiple times in the same process will install the patch once, and just once. """ patch_name = "_selenic_chromedriver_element...
[ "def", "chromedriver_element_center_patch", "(", ")", ":", "patch_name", "=", "\"_selenic_chromedriver_element_center_patched\"", "if", "getattr", "(", "ActionChains", ",", "patch_name", ",", "None", ")", ":", "return", "# We've patched ActionChains already!!", "# This is the...
Patch move_to_element on ActionChains to work around a bug present in Chromedriver 2.14 to 2.20. Calling this function multiple times in the same process will install the patch once, and just once.
[ "Patch", "move_to_element", "on", "ActionChains", "to", "work", "around", "a", "bug", "present", "in", "Chromedriver", "2", ".", "14", "to", "2", ".", "20", "." ]
2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad
https://github.com/mangalam-research/selenic/blob/2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad/selenic/builder.py#L260-L295
train
Patch ActionChains to move to the center of the element.
mangalam-research/selenic
selenic/builder.py
Builder.get_driver
def get_driver(self, desired_capabilities=None): """ Creates a Selenium driver on the basis of the configuration file upon which this object was created. :param desired_capabilities: Capabilities that the caller desires to override. This have priority over those ...
python
def get_driver(self, desired_capabilities=None): """ Creates a Selenium driver on the basis of the configuration file upon which this object was created. :param desired_capabilities: Capabilities that the caller desires to override. This have priority over those ...
[ "def", "get_driver", "(", "self", ",", "desired_capabilities", "=", "None", ")", ":", "override_caps", "=", "desired_capabilities", "or", "{", "}", "desired_capabilities", "=", "self", ".", "config", ".", "make_selenium_desired_capabilities", "(", ")", "desired_capa...
Creates a Selenium driver on the basis of the configuration file upon which this object was created. :param desired_capabilities: Capabilities that the caller desires to override. This have priority over those capabilities that are set by the configuration file passed ...
[ "Creates", "a", "Selenium", "driver", "on", "the", "basis", "of", "the", "configuration", "file", "upon", "which", "this", "object", "was", "created", "." ]
2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad
https://github.com/mangalam-research/selenic/blob/2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad/selenic/builder.py#L73-L171
train
Creates a Selenium driver based on the configuration file passed in.
mangalam-research/selenic
selenic/builder.py
Builder.update_ff_binary_env
def update_ff_binary_env(self, variable): """ If a ``FIREFOX_BINARY`` was specified, this method updates an environment variable used by the ``FirefoxBinary`` instance to the current value of the variable in the environment. This method is a no-op if ``FIREFOX_BINARY`` has not b...
python
def update_ff_binary_env(self, variable): """ If a ``FIREFOX_BINARY`` was specified, this method updates an environment variable used by the ``FirefoxBinary`` instance to the current value of the variable in the environment. This method is a no-op if ``FIREFOX_BINARY`` has not b...
[ "def", "update_ff_binary_env", "(", "self", ",", "variable", ")", ":", "if", "self", ".", "config", ".", "browser", "!=", "'FIREFOX'", ":", "return", "binary", "=", "self", ".", "local_conf", ".", "get", "(", "'FIREFOX_BINARY'", ")", "if", "binary", "is", ...
If a ``FIREFOX_BINARY`` was specified, this method updates an environment variable used by the ``FirefoxBinary`` instance to the current value of the variable in the environment. This method is a no-op if ``FIREFOX_BINARY`` has not been specified or if the configured browser is not Fire...
[ "If", "a", "FIREFOX_BINARY", "was", "specified", "this", "method", "updates", "an", "environment", "variable", "used", "by", "the", "FirefoxBinary", "instance", "to", "the", "current", "value", "of", "the", "variable", "in", "the", "environment", "." ]
2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad
https://github.com/mangalam-research/selenic/blob/2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad/selenic/builder.py#L173-L200
train
Updates the environment variable used by the Firefox binary instance.
projectshift/shift-schema
shiftschema/validators/choice.py
Choice.validate
def validate(self, value, model=None, context=None): """ Validate Perform value validation against validation settings and return error object. :param value: str, value to check :param model: parent model being validated :param context: ...
python
def validate(self, value, model=None, context=None): """ Validate Perform value validation against validation settings and return error object. :param value: str, value to check :param model: parent model being validated :param context: ...
[ "def", "validate", "(", "self", ",", "value", ",", "model", "=", "None", ",", "context", "=", "None", ")", ":", "if", "value", "not", "in", "self", ".", "choices", ":", "return", "Error", "(", "self", ".", "invalid_choice", ")", "# success otherwise", ...
Validate Perform value validation against validation settings and return error object. :param value: str, value to check :param model: parent model being validated :param context: object or None, validation context :return: shif...
[ "Validate", "Perform", "value", "validation", "against", "validation", "settings", "and", "return", "error", "object", "." ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/validators/choice.py#L35-L51
train
Validate the value of the key field against the choices and return a new error object.
a1ezzz/wasp-general
wasp_general/command/template_command.py
WTemplateResultCommand.result_template
def result_template(self, *command_tokens, **command_env): """ Generate template result. command_tokens and command_env arguments are used for template detailing :param command_tokens: same as command_tokens in :meth:`.WCommandProto.match` and \ :meth:`.WCommandProto.exec` methods (so as :meth:`.WCommand._exec...
python
def result_template(self, *command_tokens, **command_env): """ Generate template result. command_tokens and command_env arguments are used for template detailing :param command_tokens: same as command_tokens in :meth:`.WCommandProto.match` and \ :meth:`.WCommandProto.exec` methods (so as :meth:`.WCommand._exec...
[ "def", "result_template", "(", "self", ",", "*", "command_tokens", ",", "*", "*", "command_env", ")", ":", "result", "=", "WCommandResultTemplate", "(", "self", ".", "template", "(", ")", ")", "result", ".", "update_context", "(", "*", "*", "self", ".", ...
Generate template result. command_tokens and command_env arguments are used for template detailing :param command_tokens: same as command_tokens in :meth:`.WCommandProto.match` and \ :meth:`.WCommandProto.exec` methods (so as :meth:`.WCommand._exec`) :param command_env: same as command_env in :meth:`.WCommandP...
[ "Generate", "template", "result", ".", "command_tokens", "and", "command_env", "arguments", "are", "used", "for", "template", "detailing" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/command/template_command.py#L84-L97
train
Generate template result.
projectshift/shift-schema
shiftschema/validators/url.py
Url.validate
def validate(self, value, model=None, context=None): """ Validate Perform value validation and return result :param value: value to check :param model: parent model being validated :param context: object or None, validation context :re...
python
def validate(self, value, model=None, context=None): """ Validate Perform value validation and return result :param value: value to check :param model: parent model being validated :param context: object or None, validation context :re...
[ "def", "validate", "(", "self", ",", "value", ",", "model", "=", "None", ",", "context", "=", "None", ")", ":", "value", "=", "str", "(", "value", ")", "regex", "=", "self", ".", "regex", "(", "protocols", "=", "self", ".", "protocols", ",", "local...
Validate Perform value validation and return result :param value: value to check :param model: parent model being validated :param context: object or None, validation context :return: shiftschema.results.SimpleResult
[ "Validate", "Perform", "value", "validation", "and", "return", "result" ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/validators/url.py#L42-L66
train
Validate the value of a key - value pair.
projectshift/shift-schema
shiftschema/validators/url.py
Url.regex
def regex(self, protocols, localhost=True): """ URL Validation regex Based on regular expression by Diego Perini (@dperini) and provided under MIT License: https://gist.github.com/dperini/729294 :return: """ p = r"^" # protocol p += r"(?:(?:(?:{})...
python
def regex(self, protocols, localhost=True): """ URL Validation regex Based on regular expression by Diego Perini (@dperini) and provided under MIT License: https://gist.github.com/dperini/729294 :return: """ p = r"^" # protocol p += r"(?:(?:(?:{})...
[ "def", "regex", "(", "self", ",", "protocols", ",", "localhost", "=", "True", ")", ":", "p", "=", "r\"^\"", "# protocol", "p", "+=", "r\"(?:(?:(?:{}):)?//)\"", ".", "format", "(", "'|'", ".", "join", "(", "protocols", ")", ")", "# basic auth (optional)", "...
URL Validation regex Based on regular expression by Diego Perini (@dperini) and provided under MIT License: https://gist.github.com/dperini/729294 :return:
[ "URL", "Validation", "regex", "Based", "on", "regular", "expression", "by", "Diego", "Perini", "(" ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/validators/url.py#L68-L118
train
Regex for the URL validation regex.
a1ezzz/wasp-general
wasp_general/network/messenger/onion.py
WMessengerOnion.layers_names
def layers_names(self): """ :meth:`.WMessengerOnionProto.layer_names` method implementation. """ return list(self.__class__.__builtin_layers__.keys()) + list(self.__layers.keys())
python
def layers_names(self): """ :meth:`.WMessengerOnionProto.layer_names` method implementation. """ return list(self.__class__.__builtin_layers__.keys()) + list(self.__layers.keys())
[ "def", "layers_names", "(", "self", ")", ":", "return", "list", "(", "self", ".", "__class__", ".", "__builtin_layers__", ".", "keys", "(", ")", ")", "+", "list", "(", "self", ".", "__layers", ".", "keys", "(", ")", ")" ]
:meth:`.WMessengerOnionProto.layer_names` method implementation.
[ ":", "meth", ":", ".", "WMessengerOnionProto", ".", "layer_names", "method", "implementation", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/onion.py#L69-L72
train
Return a list of all layers names in this object.
a1ezzz/wasp-general
wasp_general/network/messenger/onion.py
WMessengerOnion.layer
def layer(self, layer_name): """ :meth:`.WMessengerOnionProto.layer` method implementation. """ if layer_name in self.__layers.keys(): return self.__layers[layer_name] elif layer_name in self.__class__.__builtin_layers__: return self.__class__.__builtin_layers__[layer_name] raise RuntimeError('Invalid ...
python
def layer(self, layer_name): """ :meth:`.WMessengerOnionProto.layer` method implementation. """ if layer_name in self.__layers.keys(): return self.__layers[layer_name] elif layer_name in self.__class__.__builtin_layers__: return self.__class__.__builtin_layers__[layer_name] raise RuntimeError('Invalid ...
[ "def", "layer", "(", "self", ",", "layer_name", ")", ":", "if", "layer_name", "in", "self", ".", "__layers", ".", "keys", "(", ")", ":", "return", "self", ".", "__layers", "[", "layer_name", "]", "elif", "layer_name", "in", "self", ".", "__class__", "....
:meth:`.WMessengerOnionProto.layer` method implementation.
[ ":", "meth", ":", ".", "WMessengerOnionProto", ".", "layer", "method", "implementation", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/onion.py#L75-L83
train
returns a layer object
a1ezzz/wasp-general
wasp_general/network/messenger/onion.py
WMessengerOnion.add_layers
def add_layers(self, *layers): """ Append given layers to this onion :param layers: layer to add :return: None """ for layer in layers: if layer.name() in self.__layers.keys(): raise ValueError('Layer "%s" already exists' % layer.name()) self.__layers[layer.name()] = layer
python
def add_layers(self, *layers): """ Append given layers to this onion :param layers: layer to add :return: None """ for layer in layers: if layer.name() in self.__layers.keys(): raise ValueError('Layer "%s" already exists' % layer.name()) self.__layers[layer.name()] = layer
[ "def", "add_layers", "(", "self", ",", "*", "layers", ")", ":", "for", "layer", "in", "layers", ":", "if", "layer", ".", "name", "(", ")", "in", "self", ".", "__layers", ".", "keys", "(", ")", ":", "raise", "ValueError", "(", "'Layer \"%s\" already exi...
Append given layers to this onion :param layers: layer to add :return: None
[ "Append", "given", "layers", "to", "this", "onion" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/onion.py#L86-L95
train
Append given layers to this onion
Pixelapse/pyunicode
pyunicode/api.py
safely_decode
def safely_decode(unicode_or_str, encoding='utf-8'): ''' Decodes byte <str> into <unicode>. Ignores any non-utf8 chars in <str>s ''' if isinstance(unicode_or_str, unicode): ustr = unicode_or_str elif isinstance(unicode_or_str, str): ustr = unicode_or_str.decode(encoding, 'ignore') else: raise Except...
python
def safely_decode(unicode_or_str, encoding='utf-8'): ''' Decodes byte <str> into <unicode>. Ignores any non-utf8 chars in <str>s ''' if isinstance(unicode_or_str, unicode): ustr = unicode_or_str elif isinstance(unicode_or_str, str): ustr = unicode_or_str.decode(encoding, 'ignore') else: raise Except...
[ "def", "safely_decode", "(", "unicode_or_str", ",", "encoding", "=", "'utf-8'", ")", ":", "if", "isinstance", "(", "unicode_or_str", ",", "unicode", ")", ":", "ustr", "=", "unicode_or_str", "elif", "isinstance", "(", "unicode_or_str", ",", "str", ")", ":", "...
Decodes byte <str> into <unicode>. Ignores any non-utf8 chars in <str>s
[ "Decodes", "byte", "<str", ">", "into", "<unicode", ">", ".", "Ignores", "any", "non", "-", "utf8", "chars", "in", "<str", ">", "s" ]
b7599eecd3566509cbdb180ee14b2997047b3698
https://github.com/Pixelapse/pyunicode/blob/b7599eecd3566509cbdb180ee14b2997047b3698/pyunicode/api.py#L13-L22
train
Decode a byte string into a unicode object.
Pixelapse/pyunicode
pyunicode/api.py
safely_encode
def safely_encode(unicode_or_str, encoding='utf-8'): ''' Encodes <unicode> into byte <str>. Replaces any non utf8 chars ''' if isinstance(unicode_or_str, unicode): rstr = unicode_or_str.encode(encoding, 'replace') elif isinstance(unicode_or_str, str): rstr = unicode_or_str else: raise Exception(u'No...
python
def safely_encode(unicode_or_str, encoding='utf-8'): ''' Encodes <unicode> into byte <str>. Replaces any non utf8 chars ''' if isinstance(unicode_or_str, unicode): rstr = unicode_or_str.encode(encoding, 'replace') elif isinstance(unicode_or_str, str): rstr = unicode_or_str else: raise Exception(u'No...
[ "def", "safely_encode", "(", "unicode_or_str", ",", "encoding", "=", "'utf-8'", ")", ":", "if", "isinstance", "(", "unicode_or_str", ",", "unicode", ")", ":", "rstr", "=", "unicode_or_str", ".", "encode", "(", "encoding", ",", "'replace'", ")", "elif", "isin...
Encodes <unicode> into byte <str>. Replaces any non utf8 chars
[ "Encodes", "<unicode", ">", "into", "byte", "<str", ">", ".", "Replaces", "any", "non", "utf8", "chars" ]
b7599eecd3566509cbdb180ee14b2997047b3698
https://github.com/Pixelapse/pyunicode/blob/b7599eecd3566509cbdb180ee14b2997047b3698/pyunicode/api.py#L25-L34
train
Encodes unicode into byte string.
mangalam-research/selenic
selenic/remote/saucelabs.py
get_unused_sauce_port
def get_unused_sauce_port(): """ This returns an unused port among those that Sauce Connect forwards. Note that this function does **not** lock the port! :returns: A presumably free port that Sauce Connect forwards. :rtype: int """ # # We exclude 80, 443, 888 from the list since they ar...
python
def get_unused_sauce_port(): """ This returns an unused port among those that Sauce Connect forwards. Note that this function does **not** lock the port! :returns: A presumably free port that Sauce Connect forwards. :rtype: int """ # # We exclude 80, 443, 888 from the list since they ar...
[ "def", "get_unused_sauce_port", "(", ")", ":", "#", "# We exclude 80, 443, 888 from the list since they are reserved.", "#", "sc_ports", "=", "[", "8000", ",", "8001", ",", "8003", ",", "8031", ",", "8080", ",", "8081", ",", "8765", ",", "8777", ",", "8888", "...
This returns an unused port among those that Sauce Connect forwards. Note that this function does **not** lock the port! :returns: A presumably free port that Sauce Connect forwards. :rtype: int
[ "This", "returns", "an", "unused", "port", "among", "those", "that", "Sauce", "Connect", "forwards", ".", "Note", "that", "this", "function", "does", "**", "not", "**", "lock", "the", "port!" ]
2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad
https://github.com/mangalam-research/selenic/blob/2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad/selenic/remote/saucelabs.py#L40-L98
train
This function returns an unused port among those that are not available on the Sauce Connect.
numberoverzero/declare
declare.py
index
def index(objects, attr): """ Generate a mapping of a list of objects indexed by the given attr. Parameters ---------- objects : :class:`list`, iterable attr : string The attribute to index the list of objects by Returns ------- dictionary : dict keys are the value ...
python
def index(objects, attr): """ Generate a mapping of a list of objects indexed by the given attr. Parameters ---------- objects : :class:`list`, iterable attr : string The attribute to index the list of objects by Returns ------- dictionary : dict keys are the value ...
[ "def", "index", "(", "objects", ",", "attr", ")", ":", "with", "warnings", ".", "catch_warnings", "(", ")", ":", "warnings", ".", "simplefilter", "(", "\"ignore\"", ")", "return", "{", "getattr", "(", "obj", ",", "attr", ")", ":", "obj", "for", "obj", ...
Generate a mapping of a list of objects indexed by the given attr. Parameters ---------- objects : :class:`list`, iterable attr : string The attribute to index the list of objects by Returns ------- dictionary : dict keys are the value of each object's attr, and values are ...
[ "Generate", "a", "mapping", "of", "a", "list", "of", "objects", "indexed", "by", "the", "given", "attr", "." ]
1b05ceca91fbdc3e8e770a376c2f070365c425ff
https://github.com/numberoverzero/declare/blob/1b05ceca91fbdc3e8e770a376c2f070365c425ff/declare.py#L428-L467
train
Generates a mapping of a list of objects indexed by the given attribute.
numberoverzero/declare
declare.py
TypeEngine.register
def register(self, typedef): """ Add the typedef to this engine if it is compatible. After registering a :class:`~TypeDefinition`, it will not be bound until :meth:`~TypeEngine.bind` is next called. Nothing will happen when register is called with a typedef that is pend...
python
def register(self, typedef): """ Add the typedef to this engine if it is compatible. After registering a :class:`~TypeDefinition`, it will not be bound until :meth:`~TypeEngine.bind` is next called. Nothing will happen when register is called with a typedef that is pend...
[ "def", "register", "(", "self", ",", "typedef", ")", ":", "if", "typedef", "in", "self", ".", "bound_types", ":", "return", "if", "not", "self", ".", "is_compatible", "(", "typedef", ")", ":", "raise", "ValueError", "(", "\"Incompatible type {} for engine {}\"...
Add the typedef to this engine if it is compatible. After registering a :class:`~TypeDefinition`, it will not be bound until :meth:`~TypeEngine.bind` is next called. Nothing will happen when register is called with a typedef that is pending binding or already bound. Otherwise, the eng...
[ "Add", "the", "typedef", "to", "this", "engine", "if", "it", "is", "compatible", "." ]
1b05ceca91fbdc3e8e770a376c2f070365c425ff
https://github.com/numberoverzero/declare/blob/1b05ceca91fbdc3e8e770a376c2f070365c425ff/declare.py#L73-L103
train
Register a typedef with this engine.
numberoverzero/declare
declare.py
TypeEngine.bind
def bind(self, **config): """ Bind all unbound types to the engine. Bind each unbound typedef to the engine, passing in the engine and :attr:`config`. The resulting ``load`` and ``dump`` functions can be found under ``self.bound_types[typedef]["load"]`` and ``self.bound...
python
def bind(self, **config): """ Bind all unbound types to the engine. Bind each unbound typedef to the engine, passing in the engine and :attr:`config`. The resulting ``load`` and ``dump`` functions can be found under ``self.bound_types[typedef]["load"]`` and ``self.bound...
[ "def", "bind", "(", "self", ",", "*", "*", "config", ")", ":", "while", "self", ".", "unbound_types", ":", "typedef", "=", "self", ".", "unbound_types", ".", "pop", "(", ")", "try", ":", "load", ",", "dump", "=", "typedef", ".", "bind", "(", "self"...
Bind all unbound types to the engine. Bind each unbound typedef to the engine, passing in the engine and :attr:`config`. The resulting ``load`` and ``dump`` functions can be found under ``self.bound_types[typedef]["load"]`` and ``self.bound_types[typedef]["dump"], respectively. ...
[ "Bind", "all", "unbound", "types", "to", "the", "engine", "." ]
1b05ceca91fbdc3e8e770a376c2f070365c425ff
https://github.com/numberoverzero/declare/blob/1b05ceca91fbdc3e8e770a376c2f070365c425ff/declare.py#L105-L132
train
Binds all unbound types to the engine and passes in the config dictionary.
numberoverzero/declare
declare.py
TypeEngine.load
def load(self, typedef, value, **kwargs): """ Return the result of the bound load method for a typedef Looks up the load function that was bound to the engine for a typedef, and return the result of passing the given `value` and any `context` to that function. Parameter...
python
def load(self, typedef, value, **kwargs): """ Return the result of the bound load method for a typedef Looks up the load function that was bound to the engine for a typedef, and return the result of passing the given `value` and any `context` to that function. Parameter...
[ "def", "load", "(", "self", ",", "typedef", ",", "value", ",", "*", "*", "kwargs", ")", ":", "try", ":", "bound_type", "=", "self", ".", "bound_types", "[", "typedef", "]", "except", "KeyError", ":", "raise", "DeclareException", "(", "\"Can't load unknown ...
Return the result of the bound load method for a typedef Looks up the load function that was bound to the engine for a typedef, and return the result of passing the given `value` and any `context` to that function. Parameters ---------- typedef : :class:`~TypeDefinition...
[ "Return", "the", "result", "of", "the", "bound", "load", "method", "for", "a", "typedef" ]
1b05ceca91fbdc3e8e770a376c2f070365c425ff
https://github.com/numberoverzero/declare/blob/1b05ceca91fbdc3e8e770a376c2f070365c425ff/declare.py#L134-L188
train
Loads the value of a typedef into the loaded value.
a1ezzz/wasp-general
wasp_general/crypto/random.py
random_bits
def random_bits(bits_count): """ Random generator (PyCrypto getrandbits wrapper). The result is a non-negative value. :param bits_count: random bits to generate :return: int """ bytes_count = int(math.ceil(bits_count / 8)) random_value = int.from_bytes(os.urandom(bytes_count), byteorder=sys.byteorder) result_bi...
python
def random_bits(bits_count): """ Random generator (PyCrypto getrandbits wrapper). The result is a non-negative value. :param bits_count: random bits to generate :return: int """ bytes_count = int(math.ceil(bits_count / 8)) random_value = int.from_bytes(os.urandom(bytes_count), byteorder=sys.byteorder) result_bi...
[ "def", "random_bits", "(", "bits_count", ")", ":", "bytes_count", "=", "int", "(", "math", ".", "ceil", "(", "bits_count", "/", "8", ")", ")", "random_value", "=", "int", ".", "from_bytes", "(", "os", ".", "urandom", "(", "bytes_count", ")", ",", "byte...
Random generator (PyCrypto getrandbits wrapper). The result is a non-negative value. :param bits_count: random bits to generate :return: int
[ "Random", "generator", "(", "PyCrypto", "getrandbits", "wrapper", ")", ".", "The", "result", "is", "a", "non", "-", "negative", "value", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/random.py#L36-L49
train
Random bits generator.
a1ezzz/wasp-general
wasp_general/crypto/random.py
random_int
def random_int(maximum_value): """ Random generator (PyCrypto getrandbits wrapper). The result is a non-negative value. :param maximum_value: maximum integer value :return: int """ if maximum_value == 0: return 0 elif maximum_value == 1: return random_bits(1) bits = math.floor(math.log2(maximum_value)) re...
python
def random_int(maximum_value): """ Random generator (PyCrypto getrandbits wrapper). The result is a non-negative value. :param maximum_value: maximum integer value :return: int """ if maximum_value == 0: return 0 elif maximum_value == 1: return random_bits(1) bits = math.floor(math.log2(maximum_value)) re...
[ "def", "random_int", "(", "maximum_value", ")", ":", "if", "maximum_value", "==", "0", ":", "return", "0", "elif", "maximum_value", "==", "1", ":", "return", "random_bits", "(", "1", ")", "bits", "=", "math", ".", "floor", "(", "math", ".", "log2", "("...
Random generator (PyCrypto getrandbits wrapper). The result is a non-negative value. :param maximum_value: maximum integer value :return: int
[ "Random", "generator", "(", "PyCrypto", "getrandbits", "wrapper", ")", ".", "The", "result", "is", "a", "non", "-", "negative", "value", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/random.py#L54-L67
train
Random integer generator.
Chilipp/model-organization
model_organization/config.py
get_configdir
def get_configdir(name): """ Return the string representing the configuration directory. The directory is chosen as follows: 1. If the ``name.upper() + CONFIGDIR`` environment variable is supplied, choose that. 2a. On Linux, choose `$HOME/.config`. 2b. On other platforms, choose `$HOM...
python
def get_configdir(name): """ Return the string representing the configuration directory. The directory is chosen as follows: 1. If the ``name.upper() + CONFIGDIR`` environment variable is supplied, choose that. 2a. On Linux, choose `$HOME/.config`. 2b. On other platforms, choose `$HOM...
[ "def", "get_configdir", "(", "name", ")", ":", "configdir", "=", "os", ".", "environ", ".", "get", "(", "'%sCONFIGDIR'", "%", "name", ".", "upper", "(", ")", ")", "if", "configdir", "is", "not", "None", ":", "return", "os", ".", "path", ".", "abspath...
Return the string representing the configuration directory. The directory is chosen as follows: 1. If the ``name.upper() + CONFIGDIR`` environment variable is supplied, choose that. 2a. On Linux, choose `$HOME/.config`. 2b. On other platforms, choose `$HOME/.matplotlib`. 3. If the chosen...
[ "Return", "the", "string", "representing", "the", "configuration", "directory", "." ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/config.py#L45-L83
train
Returns the string representing the configuration directory.
Chilipp/model-organization
model_organization/config.py
setup_logging
def setup_logging(default_path=None, default_level=logging.INFO, env_key=None): """ Setup logging configuration Parameters ---------- default_path: str Default path of the yaml logging configuration file. If None, it defaults to the 'logging.yaml' file in the confi...
python
def setup_logging(default_path=None, default_level=logging.INFO, env_key=None): """ Setup logging configuration Parameters ---------- default_path: str Default path of the yaml logging configuration file. If None, it defaults to the 'logging.yaml' file in the confi...
[ "def", "setup_logging", "(", "default_path", "=", "None", ",", "default_level", "=", "logging", ".", "INFO", ",", "env_key", "=", "None", ")", ":", "path", "=", "default_path", "or", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname...
Setup logging configuration Parameters ---------- default_path: str Default path of the yaml logging configuration file. If None, it defaults to the 'logging.yaml' file in the config directory default_level: int Default: :data:`logging.INFO`. Default level if default_path does n...
[ "Setup", "logging", "configuration" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/config.py#L86-L129
train
Setup logging configuration for the current application.
Chilipp/model-organization
model_organization/config.py
ordered_yaml_dump
def ordered_yaml_dump(data, stream=None, Dumper=None, **kwds): """Dumps the stream from an OrderedDict. Taken from http://stackoverflow.com/questions/5121931/in-python-how-can-you-load-yaml- mappings-as-ordereddicts""" Dumper = Dumper or yaml.Dumper class OrderedDumper(Dumper): pass ...
python
def ordered_yaml_dump(data, stream=None, Dumper=None, **kwds): """Dumps the stream from an OrderedDict. Taken from http://stackoverflow.com/questions/5121931/in-python-how-can-you-load-yaml- mappings-as-ordereddicts""" Dumper = Dumper or yaml.Dumper class OrderedDumper(Dumper): pass ...
[ "def", "ordered_yaml_dump", "(", "data", ",", "stream", "=", "None", ",", "Dumper", "=", "None", ",", "*", "*", "kwds", ")", ":", "Dumper", "=", "Dumper", "or", "yaml", ".", "Dumper", "class", "OrderedDumper", "(", "Dumper", ")", ":", "pass", "def", ...
Dumps the stream from an OrderedDict. Taken from http://stackoverflow.com/questions/5121931/in-python-how-can-you-load-yaml- mappings-as-ordereddicts
[ "Dumps", "the", "stream", "from", "an", "OrderedDict", ".", "Taken", "from" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/config.py#L152-L168
train
Dumps the stream from an OrderedDict.
Chilipp/model-organization
model_organization/config.py
safe_load
def safe_load(fname): """ Load the file fname and make sure it can be done in parallel Parameters ---------- fname: str The path name """ lock = fasteners.InterProcessLock(fname + '.lck') lock.acquire() try: with open(fname) as f: return ordered_yaml_load...
python
def safe_load(fname): """ Load the file fname and make sure it can be done in parallel Parameters ---------- fname: str The path name """ lock = fasteners.InterProcessLock(fname + '.lck') lock.acquire() try: with open(fname) as f: return ordered_yaml_load...
[ "def", "safe_load", "(", "fname", ")", ":", "lock", "=", "fasteners", ".", "InterProcessLock", "(", "fname", "+", "'.lck'", ")", "lock", ".", "acquire", "(", ")", "try", ":", "with", "open", "(", "fname", ")", "as", "f", ":", "return", "ordered_yaml_lo...
Load the file fname and make sure it can be done in parallel Parameters ---------- fname: str The path name
[ "Load", "the", "file", "fname", "and", "make", "sure", "it", "can", "be", "done", "in", "parallel" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/config.py#L171-L188
train
Load the file fname and make sure it can be done in parallel
Chilipp/model-organization
model_organization/config.py
safe_dump
def safe_dump(d, fname, *args, **kwargs): """ Savely dump `d` to `fname` using yaml This method creates a copy of `fname` called ``fname + '~'`` before saving `d` to `fname` using :func:`ordered_yaml_dump` Parameters ---------- d: object The object to dump fname: str Th...
python
def safe_dump(d, fname, *args, **kwargs): """ Savely dump `d` to `fname` using yaml This method creates a copy of `fname` called ``fname + '~'`` before saving `d` to `fname` using :func:`ordered_yaml_dump` Parameters ---------- d: object The object to dump fname: str Th...
[ "def", "safe_dump", "(", "d", ",", "fname", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "osp", ".", "exists", "(", "fname", ")", ":", "os", ".", "rename", "(", "fname", ",", "fname", "+", "'~'", ")", "lock", "=", "fasteners", "."...
Savely dump `d` to `fname` using yaml This method creates a copy of `fname` called ``fname + '~'`` before saving `d` to `fname` using :func:`ordered_yaml_dump` Parameters ---------- d: object The object to dump fname: str The path where to dump `d` Other Parameters ---...
[ "Savely", "dump", "d", "to", "fname", "using", "yaml" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/config.py#L191-L220
train
Savely dump d to fname using yaml_dump
Chilipp/model-organization
model_organization/config.py
ExperimentsConfig.project_map
def project_map(self): """A mapping from project name to experiments""" # first update with the experiments in the memory (the others should # already be loaded within the :attr:`exp_files` attribute) for key, val in self.items(): if isinstance(val, dict): l =...
python
def project_map(self): """A mapping from project name to experiments""" # first update with the experiments in the memory (the others should # already be loaded within the :attr:`exp_files` attribute) for key, val in self.items(): if isinstance(val, dict): l =...
[ "def", "project_map", "(", "self", ")", ":", "# first update with the experiments in the memory (the others should", "# already be loaded within the :attr:`exp_files` attribute)", "for", "key", ",", "val", "in", "self", ".", "items", "(", ")", ":", "if", "isinstance", "(", ...
A mapping from project name to experiments
[ "A", "mapping", "from", "project", "name", "to", "experiments" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/config.py#L260-L273
train
A mapping from project name to experiments
Chilipp/model-organization
model_organization/config.py
ExperimentsConfig.exp_files
def exp_files(self): """A mapping from experiment to experiment configuration file Note that this attribute only contains experiments whose configuration has already dumped to the file! """ ret = OrderedDict() # restore the order of the experiments exp_file = sel...
python
def exp_files(self): """A mapping from experiment to experiment configuration file Note that this attribute only contains experiments whose configuration has already dumped to the file! """ ret = OrderedDict() # restore the order of the experiments exp_file = sel...
[ "def", "exp_files", "(", "self", ")", ":", "ret", "=", "OrderedDict", "(", ")", "# restore the order of the experiments", "exp_file", "=", "self", ".", "exp_file", "if", "osp", ".", "exists", "(", "exp_file", ")", ":", "for", "key", ",", "val", "in", "safe...
A mapping from experiment to experiment configuration file Note that this attribute only contains experiments whose configuration has already dumped to the file!
[ "A", "mapping", "from", "experiment", "to", "experiment", "configuration", "file" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/config.py#L276-L301
train
A mapping from experiment to configuration file
Chilipp/model-organization
model_organization/config.py
ExperimentsConfig.save
def save(self): """Save the experiment configuration This method stores the configuration of each of the experiments in a file ``'<project-dir>/.project/<experiment>.yml'``, where ``'<project-dir>'`` corresponds to the project directory of the specific ``'<experiment>'``. Furthe...
python
def save(self): """Save the experiment configuration This method stores the configuration of each of the experiments in a file ``'<project-dir>/.project/<experiment>.yml'``, where ``'<project-dir>'`` corresponds to the project directory of the specific ``'<experiment>'``. Furthe...
[ "def", "save", "(", "self", ")", ":", "for", "exp", ",", "d", "in", "dict", "(", "self", ")", ".", "items", "(", ")", ":", "if", "isinstance", "(", "d", ",", "dict", ")", ":", "project_path", "=", "self", ".", "projects", "[", "d", "[", "'proje...
Save the experiment configuration This method stores the configuration of each of the experiments in a file ``'<project-dir>/.project/<experiment>.yml'``, where ``'<project-dir>'`` corresponds to the project directory of the specific ``'<experiment>'``. Furthermore it dumps all experime...
[ "Save", "the", "experiment", "configuration" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/config.py#L447-L471
train
Save the experiment configuration to the experiment configuration file.
Chilipp/model-organization
model_organization/config.py
ExperimentsConfig.as_ordereddict
def as_ordereddict(self): """Convenience method to convert this object into an OrderedDict""" if six.PY2: d = OrderedDict() copied = dict(self) for key in self: d[key] = copied[key] else: d = OrderedDict(self) return d
python
def as_ordereddict(self): """Convenience method to convert this object into an OrderedDict""" if six.PY2: d = OrderedDict() copied = dict(self) for key in self: d[key] = copied[key] else: d = OrderedDict(self) return d
[ "def", "as_ordereddict", "(", "self", ")", ":", "if", "six", ".", "PY2", ":", "d", "=", "OrderedDict", "(", ")", "copied", "=", "dict", "(", "self", ")", "for", "key", "in", "self", ":", "d", "[", "key", "]", "=", "copied", "[", "key", "]", "el...
Convenience method to convert this object into an OrderedDict
[ "Convenience", "method", "to", "convert", "this", "object", "into", "an", "OrderedDict" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/config.py#L480-L489
train
Convenience method to convert this object into an OrderedDict
Chilipp/model-organization
model_organization/config.py
ExperimentsConfig.remove
def remove(self, experiment): """Remove the configuration of an experiment""" try: project_path = self.projects[self[experiment]['project']]['root'] except KeyError: return config_path = osp.join(project_path, '.project', experiment + '.yml') for f in [con...
python
def remove(self, experiment): """Remove the configuration of an experiment""" try: project_path = self.projects[self[experiment]['project']]['root'] except KeyError: return config_path = osp.join(project_path, '.project', experiment + '.yml') for f in [con...
[ "def", "remove", "(", "self", ",", "experiment", ")", ":", "try", ":", "project_path", "=", "self", ".", "projects", "[", "self", "[", "experiment", "]", "[", "'project'", "]", "]", "[", "'root'", "]", "except", "KeyError", ":", "return", "config_path", ...
Remove the configuration of an experiment
[ "Remove", "the", "configuration", "of", "an", "experiment" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/config.py#L519-L529
train
Remove the configuration of an experiment
Chilipp/model-organization
model_organization/config.py
ProjectsConfig.fix_paths
def fix_paths(self, d, root=None, project=None): """ Fix the paths in the given dictionary to get absolute paths Parameters ---------- %(ExperimentsConfig.fix_paths.parameters)s Returns ------- %(ExperimentsConfig.fix_paths.returns)s Notes ...
python
def fix_paths(self, d, root=None, project=None): """ Fix the paths in the given dictionary to get absolute paths Parameters ---------- %(ExperimentsConfig.fix_paths.parameters)s Returns ------- %(ExperimentsConfig.fix_paths.returns)s Notes ...
[ "def", "fix_paths", "(", "self", ",", "d", ",", "root", "=", "None", ",", "project", "=", "None", ")", ":", "if", "root", "is", "None", "and", "project", "is", "None", ":", "project", "=", "d", ".", "get", "(", "'project'", ")", "if", "project", ...
Fix the paths in the given dictionary to get absolute paths Parameters ---------- %(ExperimentsConfig.fix_paths.parameters)s Returns ------- %(ExperimentsConfig.fix_paths.returns)s Notes ----- d is modified in place!
[ "Fix", "the", "paths", "in", "the", "given", "dictionary", "to", "get", "absolute", "paths" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/config.py#L610-L647
train
Fix the paths in the given dictionary to get absolute paths
Chilipp/model-organization
model_organization/config.py
ProjectsConfig.save
def save(self): """ Save the project configuration This method dumps the configuration for each project and the project paths (see the :attr:`all_projects` attribute) to the hard drive """ project_paths = OrderedDict() for project, d in OrderedDict(self).items():...
python
def save(self): """ Save the project configuration This method dumps the configuration for each project and the project paths (see the :attr:`all_projects` attribute) to the hard drive """ project_paths = OrderedDict() for project, d in OrderedDict(self).items():...
[ "def", "save", "(", "self", ")", ":", "project_paths", "=", "OrderedDict", "(", ")", "for", "project", ",", "d", "in", "OrderedDict", "(", "self", ")", ".", "items", "(", ")", ":", "if", "isinstance", "(", "d", ",", "dict", ")", ":", "project_path", ...
Save the project configuration This method dumps the configuration for each project and the project paths (see the :attr:`all_projects` attribute) to the hard drive
[ "Save", "the", "project", "configuration" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/config.py#L691-L713
train
Save the project configuration for each project and all the project paths that are in the hard drive.
Chilipp/model-organization
model_organization/config.py
Config.save
def save(self): """ Save the entire configuration files """ self.projects.save() self.experiments.save() safe_dump(self.global_config, self._globals_file, default_flow_style=False)
python
def save(self): """ Save the entire configuration files """ self.projects.save() self.experiments.save() safe_dump(self.global_config, self._globals_file, default_flow_style=False)
[ "def", "save", "(", "self", ")", ":", "self", ".", "projects", ".", "save", "(", ")", "self", ".", "experiments", ".", "save", "(", ")", "safe_dump", "(", "self", ".", "global_config", ",", "self", ".", "_globals_file", ",", "default_flow_style", "=", ...
Save the entire configuration files
[ "Save", "the", "entire", "configuration", "files" ]
694d1219c7ed7e1b2b17153afa11bdc21169bca2
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/config.py#L748-L755
train
Save the entire configuration files
olitheolix/qtmacs
qtmacs/extensions/qtmacsscintilla_widget.py
UndoRemoveSelectedText.reverseCommit
def reverseCommit(self): """ Reinsert the killed word. """ # Do nothing if no selection was available upon construction. if self.selectionPos is None: return # Insert the text at the specified position. line, col = self.selectionPos[:2] self....
python
def reverseCommit(self): """ Reinsert the killed word. """ # Do nothing if no selection was available upon construction. if self.selectionPos is None: return # Insert the text at the specified position. line, col = self.selectionPos[:2] self....
[ "def", "reverseCommit", "(", "self", ")", ":", "# Do nothing if no selection was available upon construction.", "if", "self", ".", "selectionPos", "is", "None", ":", "return", "# Insert the text at the specified position.", "line", ",", "col", "=", "self", ".", "selection...
Reinsert the killed word.
[ "Reinsert", "the", "killed", "word", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacsscintilla_widget.py#L125-L143
train
Reinsert the killed word.
olitheolix/qtmacs
qtmacs/extensions/qtmacsscintilla_widget.py
UndoReplaceSelectedText.reverseCommit
def reverseCommit(self): """ Reinsert the killed word. """ if self.selectionPosOld is None: return # Shorthand. wid = self.qteWidget # Select, backup, and delete the selection. wid.setSelection(*self.selectionPosNew) self.baseClass.re...
python
def reverseCommit(self): """ Reinsert the killed word. """ if self.selectionPosOld is None: return # Shorthand. wid = self.qteWidget # Select, backup, and delete the selection. wid.setSelection(*self.selectionPosNew) self.baseClass.re...
[ "def", "reverseCommit", "(", "self", ")", ":", "if", "self", ".", "selectionPosOld", "is", "None", ":", "return", "# Shorthand.", "wid", "=", "self", ".", "qteWidget", "# Select, backup, and delete the selection.", "wid", ".", "setSelection", "(", "*", "self", "...
Reinsert the killed word.
[ "Reinsert", "the", "killed", "word", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacsscintilla_widget.py#L201-L218
train
Reinsert the killed word.