repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
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 |
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 |
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 |
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",
"None... | 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 |
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",
"experiment",
... | 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 |
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 |
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 |
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 |
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",
",",
"**",
"kwargs",
... | 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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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",
")",
":",
"if",
"not",
"QtCore",
".",
"QFile",
"(",
"fileName",
")",
".",
"exists",
"(",
")",
":",
"msg",
"=",
"\"File <b>{}</b> does not exist\"",
".",
"format",
"(",
"self",
".",
"qteAppletID",
"(",
")",... | 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 |
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 |
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 |
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",
"''",
"lines",
"=",
"docstring",
".",
"expandtabs",
"(",
")",
".",
"splitlines",
"(",
")",
"indent",
"=",
"sys",
".",
"maxint",
"for",
"line",
"in",
"lines",
"["... | 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 |
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 |
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",
"(",
")",
"if",
"obj",
"is",
"None",
":",
"logging",
".",
"debug",
"(",
"\"_render_serializable passed a None obj, returning None\"",
")",
"return",
"None",... | 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 |
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 |
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 |
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 |
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 |
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",
")",
":",
"raml_built_in_types",
"=",
"{",
"\"any\"",
":",
"{",
"\"parent\"",
":",
"None",
",",
"}",
",",
"\"time-only\"",
":",
"{",
"\"parent\"",
":",
"\"any\"",
",",
"}",
",",
"\"date... | 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 |
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",
"(",
")",
"module_end... | 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 |
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 |
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 |
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",
"(",
")",
"doc",
"[",
"'description'",
"]",
"=",
"clean_description",
"(",
"py_doc_trim",
"(",
"doc",
"[",
"'description'",
"]",
")",
")",
"details",
"... | 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 |
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 |
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 |
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",
")",
"for",
... | 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 |
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 |
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 |
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 |
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 |
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 |
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\"^\"",
"p",
"+=",
"r\"(?:(?:(?:{}):)?//)\"",
".",
"format",
"(",
"'|'",
".",
"join",
"(",
"protocols",
")",
")",
"p",
"+=",
"r\"(?:\\S+(?::\\S*)?@)?\"",
... | 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 |
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 |
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 |
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 |
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 |
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 type {... | 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 |
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 |
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",
"_dict... | 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 |
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 |
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",
".",
"I... | 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 |
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",
")",
":",
"for",
"key",
",",
"val",
"in",
"self",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"dict",
")",
":",
"l",
"=",
"self",
".",
"_project_map",
"[",
"val",
"[",
"'project'",
"]",
"]"... | 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 |
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",
"(",
")",
"exp_file",
"=",
"self",
".",
"exp_file",
"if",
"osp",
".",
"exists",
"(",
"exp_file",
")",
":",
"for",
"key",
",",
"val",
"in",
"safe_load",
"(",
"exp_file",
")",
".",
... | 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 |
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 |
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 |
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 |
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 |
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 |
olitheolix/qtmacs | qtmacs/extensions/qtmacsscintilla_widget.py | UndoSetText.reverseCommit | def reverseCommit(self):
"""
Replace the current widget content with the original text.
Note that the original text has styling information available,
whereas the new text does not.
"""
self.baseClass.setText(self.oldText)
self.qteWidget.SCISetStylingEx(0, 0, self... | python | def reverseCommit(self):
"""
Replace the current widget content with the original text.
Note that the original text has styling information available,
whereas the new text does not.
"""
self.baseClass.setText(self.oldText)
self.qteWidget.SCISetStylingEx(0, 0, self... | [
"def",
"reverseCommit",
"(",
"self",
")",
":",
"self",
".",
"baseClass",
".",
"setText",
"(",
"self",
".",
"oldText",
")",
"self",
".",
"qteWidget",
".",
"SCISetStylingEx",
"(",
"0",
",",
"0",
",",
"self",
".",
"style",
")"
] | Replace the current widget content with the original text.
Note that the original text has styling information available,
whereas the new text does not. | [
"Replace",
"the",
"current",
"widget",
"content",
"with",
"the",
"original",
"text",
".",
"Note",
"that",
"the",
"original",
"text",
"has",
"styling",
"information",
"available",
"whereas",
"the",
"new",
"text",
"does",
"not",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacsscintilla_widget.py#L390-L397 | train |
olitheolix/qtmacs | qtmacs/extensions/qtmacsscintilla_widget.py | UndoGenericQtmacsScintilla.placeCursor | def placeCursor(self, line, col):
"""
Try to place the cursor in ``line`` at ``col`` if possible,
otherwise place it at the end.
"""
num_lines, num_col = self.qteWidget.getNumLinesAndColumns()
# Place the cursor at the specified position if possible.
if line >= n... | python | def placeCursor(self, line, col):
"""
Try to place the cursor in ``line`` at ``col`` if possible,
otherwise place it at the end.
"""
num_lines, num_col = self.qteWidget.getNumLinesAndColumns()
# Place the cursor at the specified position if possible.
if line >= n... | [
"def",
"placeCursor",
"(",
"self",
",",
"line",
",",
"col",
")",
":",
"num_lines",
",",
"num_col",
"=",
"self",
".",
"qteWidget",
".",
"getNumLinesAndColumns",
"(",
")",
"if",
"line",
">=",
"num_lines",
":",
"line",
",",
"col",
"=",
"num_lines",
",",
"... | Try to place the cursor in ``line`` at ``col`` if possible,
otherwise place it at the end. | [
"Try",
"to",
"place",
"the",
"cursor",
"in",
"line",
"at",
"col",
"if",
"possible",
"otherwise",
"place",
"it",
"at",
"the",
"end",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacsscintilla_widget.py#L441-L456 | train |
olitheolix/qtmacs | qtmacs/extensions/qtmacsscintilla_widget.py | UndoGenericQtmacsScintilla.reverseCommit | def reverseCommit(self):
"""
Put the document into the 'before' state.
"""
# Put the document into the 'before' state.
self.baseClass.setText(self.textBefore)
self.qteWidget.SCISetStylingEx(0, 0, self.styleBefore) | python | def reverseCommit(self):
"""
Put the document into the 'before' state.
"""
# Put the document into the 'before' state.
self.baseClass.setText(self.textBefore)
self.qteWidget.SCISetStylingEx(0, 0, self.styleBefore) | [
"def",
"reverseCommit",
"(",
"self",
")",
":",
"self",
".",
"baseClass",
".",
"setText",
"(",
"self",
".",
"textBefore",
")",
"self",
".",
"qteWidget",
".",
"SCISetStylingEx",
"(",
"0",
",",
"0",
",",
"self",
".",
"styleBefore",
")"
] | Put the document into the 'before' state. | [
"Put",
"the",
"document",
"into",
"the",
"before",
"state",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacsscintilla_widget.py#L476-L482 | train |
olitheolix/qtmacs | qtmacs/extensions/qtmacsscintilla_widget.py | QtmacsScintilla.fromMimeData | def fromMimeData(self, data):
"""
Paste the clipboard data at the current cursor position.
This method also adds another undo-object to the undo-stack.
..note: This method forcefully interrupts the ``QsciInternal``
pasting mechnism by returning an empty MIME data elemen... | python | def fromMimeData(self, data):
"""
Paste the clipboard data at the current cursor position.
This method also adds another undo-object to the undo-stack.
..note: This method forcefully interrupts the ``QsciInternal``
pasting mechnism by returning an empty MIME data elemen... | [
"def",
"fromMimeData",
"(",
"self",
",",
"data",
")",
":",
"if",
"data",
".",
"hasText",
"(",
")",
":",
"self",
".",
"insert",
"(",
"data",
".",
"text",
"(",
")",
")",
"return",
"(",
"QtCore",
".",
"QByteArray",
"(",
")",
",",
"False",
")"
] | Paste the clipboard data at the current cursor position.
This method also adds another undo-object to the undo-stack.
..note: This method forcefully interrupts the ``QsciInternal``
pasting mechnism by returning an empty MIME data element.
This is not an elegant implemen... | [
"Paste",
"the",
"clipboard",
"data",
"at",
"the",
"current",
"cursor",
"position",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacsscintilla_widget.py#L582-L600 | train |
olitheolix/qtmacs | qtmacs/extensions/qtmacsscintilla_widget.py | QtmacsScintilla.keyPressEvent | def keyPressEvent(self, keyEvent: QtGui.QKeyEvent):
"""
Undo safe wrapper for the native ``keyPressEvent`` method.
|Args|
* ``keyEvent`` (**QKeyEvent**): the key event to process.
|Returns|
**None**
|Raises|
* **QtmacsArgumentError** if at least one ... | python | def keyPressEvent(self, keyEvent: QtGui.QKeyEvent):
"""
Undo safe wrapper for the native ``keyPressEvent`` method.
|Args|
* ``keyEvent`` (**QKeyEvent**): the key event to process.
|Returns|
**None**
|Raises|
* **QtmacsArgumentError** if at least one ... | [
"def",
"keyPressEvent",
"(",
"self",
",",
"keyEvent",
":",
"QtGui",
".",
"QKeyEvent",
")",
":",
"undoObj",
"=",
"UndoInsert",
"(",
"self",
",",
"keyEvent",
".",
"text",
"(",
")",
")",
"self",
".",
"qteUndoStack",
".",
"push",
"(",
"undoObj",
")"
] | Undo safe wrapper for the native ``keyPressEvent`` method.
|Args|
* ``keyEvent`` (**QKeyEvent**): the key event to process.
|Returns|
**None**
|Raises|
* **QtmacsArgumentError** if at least one argument has an invalid type. | [
"Undo",
"safe",
"wrapper",
"for",
"the",
"native",
"keyPressEvent",
"method",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacsscintilla_widget.py#L695-L712 | train |
olitheolix/qtmacs | qtmacs/extensions/qtmacsscintilla_widget.py | QtmacsScintilla.replaceSelectedText | def replaceSelectedText(self, text: str):
"""
Undo safe wrapper for the native ``replaceSelectedText`` method.
|Args|
* ``text`` (**str**): text to replace the current selection.
|Returns|
**None**
|Raises|
* **QtmacsArgumentError** if at least one a... | python | def replaceSelectedText(self, text: str):
"""
Undo safe wrapper for the native ``replaceSelectedText`` method.
|Args|
* ``text`` (**str**): text to replace the current selection.
|Returns|
**None**
|Raises|
* **QtmacsArgumentError** if at least one a... | [
"def",
"replaceSelectedText",
"(",
"self",
",",
"text",
":",
"str",
")",
":",
"undoObj",
"=",
"UndoReplaceSelectedText",
"(",
"self",
",",
"text",
")",
"self",
".",
"qteUndoStack",
".",
"push",
"(",
"undoObj",
")"
] | Undo safe wrapper for the native ``replaceSelectedText`` method.
|Args|
* ``text`` (**str**): text to replace the current selection.
|Returns|
**None**
|Raises|
* **QtmacsArgumentError** if at least one argument has an invalid type. | [
"Undo",
"safe",
"wrapper",
"for",
"the",
"native",
"replaceSelectedText",
"method",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacsscintilla_widget.py#L735-L752 | train |
olitheolix/qtmacs | qtmacs/extensions/qtmacsscintilla_widget.py | QtmacsScintilla.insert | def insert(self, text: str):
"""
Undo safe wrapper for the native ``insert`` method.
|Args|
* ``text`` (**str**): text to insert at the current position.
|Returns|
**None**
|Raises|
* **QtmacsArgumentError** if at least one argument has an invalid ty... | python | def insert(self, text: str):
"""
Undo safe wrapper for the native ``insert`` method.
|Args|
* ``text`` (**str**): text to insert at the current position.
|Returns|
**None**
|Raises|
* **QtmacsArgumentError** if at least one argument has an invalid ty... | [
"def",
"insert",
"(",
"self",
",",
"text",
":",
"str",
")",
":",
"undoObj",
"=",
"UndoInsert",
"(",
"self",
",",
"text",
")",
"self",
".",
"qteUndoStack",
".",
"push",
"(",
"undoObj",
")"
] | Undo safe wrapper for the native ``insert`` method.
|Args|
* ``text`` (**str**): text to insert at the current position.
|Returns|
**None**
|Raises|
* **QtmacsArgumentError** if at least one argument has an invalid type. | [
"Undo",
"safe",
"wrapper",
"for",
"the",
"native",
"insert",
"method",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacsscintilla_widget.py#L755-L772 | train |
olitheolix/qtmacs | qtmacs/extensions/qtmacsscintilla_widget.py | QtmacsScintilla.insertAt | def insertAt(self, text: str, line: int, col: int):
"""
Undo safe wrapper for the native ``insertAt`` method.
|Args|
* ``text`` (**str**): text to insert at the specified position.
* ``line`` (**int**): line number.
* ``col`` (**int**): column number.
|Returns|... | python | def insertAt(self, text: str, line: int, col: int):
"""
Undo safe wrapper for the native ``insertAt`` method.
|Args|
* ``text`` (**str**): text to insert at the specified position.
* ``line`` (**int**): line number.
* ``col`` (**int**): column number.
|Returns|... | [
"def",
"insertAt",
"(",
"self",
",",
"text",
":",
"str",
",",
"line",
":",
"int",
",",
"col",
":",
"int",
")",
":",
"undoObj",
"=",
"UndoInsertAt",
"(",
"self",
",",
"text",
",",
"line",
",",
"col",
")",
"self",
".",
"qteUndoStack",
".",
"push",
... | Undo safe wrapper for the native ``insertAt`` method.
|Args|
* ``text`` (**str**): text to insert at the specified position.
* ``line`` (**int**): line number.
* ``col`` (**int**): column number.
|Returns|
**None**
|Raises|
* **QtmacsArgumentError** ... | [
"Undo",
"safe",
"wrapper",
"for",
"the",
"native",
"insertAt",
"method",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacsscintilla_widget.py#L775-L794 | train |
olitheolix/qtmacs | qtmacs/extensions/qtmacsscintilla_widget.py | QtmacsScintilla.append | def append(self, text: str):
"""
Undo safe wrapper for the native ``append`` method.
|Args|
* ``text`` (**str**): text to insert at the specified position.
|Returns|
**None**
|Raises|
* **QtmacsArgumentError** if at least one argument has an invalid ... | python | def append(self, text: str):
"""
Undo safe wrapper for the native ``append`` method.
|Args|
* ``text`` (**str**): text to insert at the specified position.
|Returns|
**None**
|Raises|
* **QtmacsArgumentError** if at least one argument has an invalid ... | [
"def",
"append",
"(",
"self",
",",
"text",
":",
"str",
")",
":",
"pos",
"=",
"self",
".",
"getCursorPosition",
"(",
")",
"line",
",",
"col",
"=",
"self",
".",
"getNumLinesAndColumns",
"(",
")",
"undoObj",
"=",
"UndoInsertAt",
"(",
"self",
",",
"text",
... | Undo safe wrapper for the native ``append`` method.
|Args|
* ``text`` (**str**): text to insert at the specified position.
|Returns|
**None**
|Raises|
* **QtmacsArgumentError** if at least one argument has an invalid type. | [
"Undo",
"safe",
"wrapper",
"for",
"the",
"native",
"append",
"method",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacsscintilla_widget.py#L797-L817 | train |
olitheolix/qtmacs | qtmacs/extensions/qtmacsscintilla_widget.py | QtmacsScintilla.setText | def setText(self, text: str):
"""
Undo safe wrapper for the native ``setText`` method.
|Args|
* ``text`` (**str**): text to insert at the specified position.
|Returns|
**None**
|Raises|
* **QtmacsArgumentError** if at least one argument has an invali... | python | def setText(self, text: str):
"""
Undo safe wrapper for the native ``setText`` method.
|Args|
* ``text`` (**str**): text to insert at the specified position.
|Returns|
**None**
|Raises|
* **QtmacsArgumentError** if at least one argument has an invali... | [
"def",
"setText",
"(",
"self",
",",
"text",
":",
"str",
")",
":",
"undoObj",
"=",
"UndoSetText",
"(",
"self",
",",
"text",
")",
"self",
".",
"qteUndoStack",
".",
"push",
"(",
"undoObj",
")"
] | Undo safe wrapper for the native ``setText`` method.
|Args|
* ``text`` (**str**): text to insert at the specified position.
|Returns|
**None**
|Raises|
* **QtmacsArgumentError** if at least one argument has an invalid type. | [
"Undo",
"safe",
"wrapper",
"for",
"the",
"native",
"setText",
"method",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacsscintilla_widget.py#L820-L837 | train |
olitheolix/qtmacs | qtmacs/extensions/qtmacsscintilla_widget.py | QtmacsScintilla.SCIGetStyledText | def SCIGetStyledText(self, selectionPos: tuple):
"""
Pythonic wrapper for the SCI_GETSTYLEDTEXT command.
For example, to get the raw text and styling bits
for the first five characters in the widget use::
text, style = SCIGetStyledText((0, 0, 0, 5))
print(text.d... | python | def SCIGetStyledText(self, selectionPos: tuple):
"""
Pythonic wrapper for the SCI_GETSTYLEDTEXT command.
For example, to get the raw text and styling bits
for the first five characters in the widget use::
text, style = SCIGetStyledText((0, 0, 0, 5))
print(text.d... | [
"def",
"SCIGetStyledText",
"(",
"self",
",",
"selectionPos",
":",
"tuple",
")",
":",
"if",
"not",
"self",
".",
"isSelectionPositionValid",
"(",
"selectionPos",
")",
":",
"return",
"None",
"start",
"=",
"self",
".",
"positionFromLineIndex",
"(",
"*",
"selection... | Pythonic wrapper for the SCI_GETSTYLEDTEXT command.
For example, to get the raw text and styling bits
for the first five characters in the widget use::
text, style = SCIGetStyledText((0, 0, 0, 5))
print(text.decode('utf-8'))
|Args|
* ``selectionPos`` (**tuple*... | [
"Pythonic",
"wrapper",
"for",
"the",
"SCI_GETSTYLEDTEXT",
"command",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacsscintilla_widget.py#L840-L895 | train |
olitheolix/qtmacs | qtmacs/extensions/qtmacsscintilla_widget.py | QtmacsScintilla.SCISetStyling | def SCISetStyling(self, line: int, col: int,
numChar: int, style: bytearray):
"""
Pythonic wrapper for the SCI_SETSTYLING command.
For example, the following code applies style #3
to the first five characters in the second line
of the widget:
S... | python | def SCISetStyling(self, line: int, col: int,
numChar: int, style: bytearray):
"""
Pythonic wrapper for the SCI_SETSTYLING command.
For example, the following code applies style #3
to the first five characters in the second line
of the widget:
S... | [
"def",
"SCISetStyling",
"(",
"self",
",",
"line",
":",
"int",
",",
"col",
":",
"int",
",",
"numChar",
":",
"int",
",",
"style",
":",
"bytearray",
")",
":",
"if",
"not",
"self",
".",
"isPositionValid",
"(",
"line",
",",
"col",
")",
":",
"return",
"p... | Pythonic wrapper for the SCI_SETSTYLING command.
For example, the following code applies style #3
to the first five characters in the second line
of the widget:
SCISetStyling((0, 1), 5, 3)
|Args|
* ``line`` (**int**): line number where to start styling.
* ... | [
"Pythonic",
"wrapper",
"for",
"the",
"SCI_SETSTYLING",
"command",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacsscintilla_widget.py#L898-L929 | train |
olitheolix/qtmacs | qtmacs/extensions/qtmacsscintilla_widget.py | QtmacsScintilla.SCISetStylingEx | def SCISetStylingEx(self, line: int, col: int, style: bytearray):
"""
Pythonic wrapper for the SCI_SETSTYLINGEX command.
For example, the following code will fetch the styling for the first
five characters applies it verbatim to the next five characters.
text, style = SCIGe... | python | def SCISetStylingEx(self, line: int, col: int, style: bytearray):
"""
Pythonic wrapper for the SCI_SETSTYLINGEX command.
For example, the following code will fetch the styling for the first
five characters applies it verbatim to the next five characters.
text, style = SCIGe... | [
"def",
"SCISetStylingEx",
"(",
"self",
",",
"line",
":",
"int",
",",
"col",
":",
"int",
",",
"style",
":",
"bytearray",
")",
":",
"if",
"not",
"self",
".",
"isPositionValid",
"(",
"line",
",",
"col",
")",
":",
"return",
"pos",
"=",
"self",
".",
"po... | Pythonic wrapper for the SCI_SETSTYLINGEX command.
For example, the following code will fetch the styling for the first
five characters applies it verbatim to the next five characters.
text, style = SCIGetStyledText((0, 0, 0, 5))
SCISetStylingEx((0, 5), style)
|Args|
... | [
"Pythonic",
"wrapper",
"for",
"the",
"SCI_SETSTYLINGEX",
"command",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacsscintilla_widget.py#L932-L961 | train |
olitheolix/qtmacs | qtmacs/extensions/qtmacsscintilla_widget.py | QtmacsScintilla.qteSetLexer | def qteSetLexer(self, lexer):
"""
Specify the lexer to use.
The only difference between this method and the native
``setLexer`` method is that expects ``lexer`` to be class, not
an instance. Another feature is that this method knows which
``lexer`` class was installed la... | python | def qteSetLexer(self, lexer):
"""
Specify the lexer to use.
The only difference between this method and the native
``setLexer`` method is that expects ``lexer`` to be class, not
an instance. Another feature is that this method knows which
``lexer`` class was installed la... | [
"def",
"qteSetLexer",
"(",
"self",
",",
"lexer",
")",
":",
"if",
"(",
"lexer",
"is",
"not",
"None",
")",
"and",
"(",
"not",
"issubclass",
"(",
"lexer",
",",
"Qsci",
".",
"QsciLexer",
")",
")",
":",
"QtmacsOtherError",
"(",
"'lexer must be a class object an... | Specify the lexer to use.
The only difference between this method and the native
``setLexer`` method is that expects ``lexer`` to be class, not
an instance. Another feature is that this method knows which
``lexer`` class was installed last, and this information can
be retrieved ... | [
"Specify",
"the",
"lexer",
"to",
"use",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacsscintilla_widget.py#L963-L998 | train |
olitheolix/qtmacs | qtmacs/extensions/qtmacsscintilla_widget.py | QtmacsScintilla.setMonospace | def setMonospace(self):
"""
Fix the fonts of the first 32 styles to a mono space one.
|Args|
* **None**
|Returns|
**None**
|Raises|
* **None**
"""
font = bytes('courier new', 'utf-8')
for ii in range(32):
self.Send... | python | def setMonospace(self):
"""
Fix the fonts of the first 32 styles to a mono space one.
|Args|
* **None**
|Returns|
**None**
|Raises|
* **None**
"""
font = bytes('courier new', 'utf-8')
for ii in range(32):
self.Send... | [
"def",
"setMonospace",
"(",
"self",
")",
":",
"font",
"=",
"bytes",
"(",
"'courier new'",
",",
"'utf-8'",
")",
"for",
"ii",
"in",
"range",
"(",
"32",
")",
":",
"self",
".",
"SendScintilla",
"(",
"self",
".",
"SCI_STYLESETFONT",
",",
"ii",
",",
"font",
... | Fix the fonts of the first 32 styles to a mono space one.
|Args|
* **None**
|Returns|
**None**
|Raises|
* **None** | [
"Fix",
"the",
"fonts",
"of",
"the",
"first",
"32",
"styles",
"to",
"a",
"mono",
"space",
"one",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacsscintilla_widget.py#L1022-L1040 | train |
olitheolix/qtmacs | qtmacs/extensions/qtmacsscintilla_widget.py | QtmacsScintilla.setModified | def setModified(self, isModified: bool):
"""
Set the modified state to ``isModified``.
From a programmer's perspective this method does the same as
the native ``QsciScintilla`` method but also ensures that the
undo framework knows when the document state was changed.
|A... | python | def setModified(self, isModified: bool):
"""
Set the modified state to ``isModified``.
From a programmer's perspective this method does the same as
the native ``QsciScintilla`` method but also ensures that the
undo framework knows when the document state was changed.
|A... | [
"def",
"setModified",
"(",
"self",
",",
"isModified",
":",
"bool",
")",
":",
"if",
"not",
"isModified",
":",
"self",
".",
"qteUndoStack",
".",
"saveState",
"(",
")",
"super",
"(",
")",
".",
"setModified",
"(",
"isModified",
")"
] | Set the modified state to ``isModified``.
From a programmer's perspective this method does the same as
the native ``QsciScintilla`` method but also ensures that the
undo framework knows when the document state was changed.
|Args|
* ``isModified`` (**bool**): whether or not the... | [
"Set",
"the",
"modified",
"state",
"to",
"isModified",
"."
] | 36253b082b82590f183fe154b053eb3a1e741be2 | https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacsscintilla_widget.py#L1043-L1066 | train |
vecnet/vecnet.openmalaria | vecnet/openmalaria/scenario/core.py | attribute | def attribute(func):
"""
Decorator used to declare that property is a tag attribute
"""
def inner(self):
name, attribute_type = func(self)
if not name:
name = func.__name__
try:
return attribute_type(self.et.attrib[name])
except KeyError:
... | python | def attribute(func):
"""
Decorator used to declare that property is a tag attribute
"""
def inner(self):
name, attribute_type = func(self)
if not name:
name = func.__name__
try:
return attribute_type(self.et.attrib[name])
except KeyError:
... | [
"def",
"attribute",
"(",
"func",
")",
":",
"def",
"inner",
"(",
"self",
")",
":",
"name",
",",
"attribute_type",
"=",
"func",
"(",
"self",
")",
"if",
"not",
"name",
":",
"name",
"=",
"func",
".",
"__name__",
"try",
":",
"return",
"attribute_type",
"(... | Decorator used to declare that property is a tag attribute | [
"Decorator",
"used",
"to",
"declare",
"that",
"property",
"is",
"a",
"tag",
"attribute"
] | 795bc9d1b81a6c664f14879edda7a7c41188e95a | https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/core.py#L14-L27 | train |
vecnet/vecnet.openmalaria | vecnet/openmalaria/scenario/core.py | section | def section(func):
"""
Decorator used to declare that the property is xml section
"""
def inner(self):
return func(self)(self.et.find(func.__name__))
return inner | python | def section(func):
"""
Decorator used to declare that the property is xml section
"""
def inner(self):
return func(self)(self.et.find(func.__name__))
return inner | [
"def",
"section",
"(",
"func",
")",
":",
"def",
"inner",
"(",
"self",
")",
":",
"return",
"func",
"(",
"self",
")",
"(",
"self",
".",
"et",
".",
"find",
"(",
"func",
".",
"__name__",
")",
")",
"return",
"inner"
] | Decorator used to declare that the property is xml section | [
"Decorator",
"used",
"to",
"declare",
"that",
"the",
"property",
"is",
"xml",
"section"
] | 795bc9d1b81a6c664f14879edda7a7c41188e95a | https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/core.py#L40-L46 | train |
vecnet/vecnet.openmalaria | vecnet/openmalaria/scenario/core.py | tag_value | def tag_value(func):
"""
Decorator used to declare that the property is attribute of embedded tag
"""
def inner(self):
tag, attrib, attrib_type = func(self)
tag_obj = self.et.find(tag)
if tag_obj is not None:
try:
return attrib_type(self.et.find(tag).... | python | def tag_value(func):
"""
Decorator used to declare that the property is attribute of embedded tag
"""
def inner(self):
tag, attrib, attrib_type = func(self)
tag_obj = self.et.find(tag)
if tag_obj is not None:
try:
return attrib_type(self.et.find(tag).... | [
"def",
"tag_value",
"(",
"func",
")",
":",
"def",
"inner",
"(",
"self",
")",
":",
"tag",
",",
"attrib",
",",
"attrib_type",
"=",
"func",
"(",
"self",
")",
"tag_obj",
"=",
"self",
".",
"et",
".",
"find",
"(",
"tag",
")",
"if",
"tag_obj",
"is",
"no... | Decorator used to declare that the property is attribute of embedded tag | [
"Decorator",
"used",
"to",
"declare",
"that",
"the",
"property",
"is",
"attribute",
"of",
"embedded",
"tag"
] | 795bc9d1b81a6c664f14879edda7a7c41188e95a | https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/core.py#L49-L63 | train |
vecnet/vecnet.openmalaria | vecnet/openmalaria/scenario/core.py | tag_value_setter | def tag_value_setter(tag, attrib):
"""
Decorator used to declare that the setter function is an attribute of embedded tag
"""
def outer(func):
def inner(self, value):
tag_elem = self.et.find(tag)
if tag_elem is None:
et = ElementTree.fromstring("<{}></{}>... | python | def tag_value_setter(tag, attrib):
"""
Decorator used to declare that the setter function is an attribute of embedded tag
"""
def outer(func):
def inner(self, value):
tag_elem = self.et.find(tag)
if tag_elem is None:
et = ElementTree.fromstring("<{}></{}>... | [
"def",
"tag_value_setter",
"(",
"tag",
",",
"attrib",
")",
":",
"def",
"outer",
"(",
"func",
")",
":",
"def",
"inner",
"(",
"self",
",",
"value",
")",
":",
"tag_elem",
"=",
"self",
".",
"et",
".",
"find",
"(",
"tag",
")",
"if",
"tag_elem",
"is",
... | Decorator used to declare that the setter function is an attribute of embedded tag | [
"Decorator",
"used",
"to",
"declare",
"that",
"the",
"setter",
"function",
"is",
"an",
"attribute",
"of",
"embedded",
"tag"
] | 795bc9d1b81a6c664f14879edda7a7c41188e95a | https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/core.py#L66-L81 | train |
projectshift/shift-schema | shiftschema/validators/abstract_validator.py | AbstractValidator.run | def run(self, value, model=None, context=None):
"""
Run validation
Wraps concrete implementation to ensure custom validators return
proper type of result.
:param value: a value to validate
:param model: parent model of the property
:pa... | python | def run(self, value, model=None, context=None):
"""
Run validation
Wraps concrete implementation to ensure custom validators return
proper type of result.
:param value: a value to validate
:param model: parent model of the property
:pa... | [
"def",
"run",
"(",
"self",
",",
"value",
",",
"model",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"res",
"=",
"self",
".",
"validate",
"(",
"value",
",",
"model",
",",
"context",
")",
"if",
"not",
"isinstance",
"(",
"res",
",",
"Error",
... | Run validation
Wraps concrete implementation to ensure custom validators return
proper type of result.
:param value: a value to validate
:param model: parent model of the property
:param context: parent model or custom context
:ret... | [
"Run",
"validation",
"Wraps",
"concrete",
"implementation",
"to",
"ensure",
"custom",
"validators",
"return",
"proper",
"type",
"of",
"result",
"."
] | 07787b540d3369bb37217ffbfbe629118edaf0eb | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/validators/abstract_validator.py#L29-L49 | train |
alextricity25/dwell_in_you_richly | diyr/sinks/base.py | BaseSinkClass._collect_data | def _collect_data(self):
"""
Returns a list of all the data gathered from the engine
iterable.
"""
all_data = []
for line in self.engine.run_engine():
logging.debug("Adding {} to all_data".format(line))
all_data.append(line.copy())
logg... | python | def _collect_data(self):
"""
Returns a list of all the data gathered from the engine
iterable.
"""
all_data = []
for line in self.engine.run_engine():
logging.debug("Adding {} to all_data".format(line))
all_data.append(line.copy())
logg... | [
"def",
"_collect_data",
"(",
"self",
")",
":",
"all_data",
"=",
"[",
"]",
"for",
"line",
"in",
"self",
".",
"engine",
".",
"run_engine",
"(",
")",
":",
"logging",
".",
"debug",
"(",
"\"Adding {} to all_data\"",
".",
"format",
"(",
"line",
")",
")",
"al... | Returns a list of all the data gathered from the engine
iterable. | [
"Returns",
"a",
"list",
"of",
"all",
"the",
"data",
"gathered",
"from",
"the",
"engine",
"iterable",
"."
] | e705e1bc4fc0b8d2aa25680dfc432762b361c783 | https://github.com/alextricity25/dwell_in_you_richly/blob/e705e1bc4fc0b8d2aa25680dfc432762b361c783/diyr/sinks/base.py#L23-L34 | train |
pmacosta/pexdoc | pexdoc/pinspect.py | _get_module_name_from_fname | def _get_module_name_from_fname(fname):
"""Get module name from module file name."""
fname = fname.replace(".pyc", ".py")
for mobj in sys.modules.values():
if (
hasattr(mobj, "__file__")
and mobj.__file__
and (mobj.__file__.replace(".pyc", ".py") == fname)
... | python | def _get_module_name_from_fname(fname):
"""Get module name from module file name."""
fname = fname.replace(".pyc", ".py")
for mobj in sys.modules.values():
if (
hasattr(mobj, "__file__")
and mobj.__file__
and (mobj.__file__.replace(".pyc", ".py") == fname)
... | [
"def",
"_get_module_name_from_fname",
"(",
"fname",
")",
":",
"fname",
"=",
"fname",
".",
"replace",
"(",
"\".pyc\"",
",",
"\".py\"",
")",
"for",
"mobj",
"in",
"sys",
".",
"modules",
".",
"values",
"(",
")",
":",
"if",
"(",
"hasattr",
"(",
"mobj",
",",... | Get module name from module file name. | [
"Get",
"module",
"name",
"from",
"module",
"file",
"name",
"."
] | 201ac243e5781347feb75896a4231429fe6da4b1 | https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pinspect.py#L40-L51 | train |
pmacosta/pexdoc | pexdoc/pinspect.py | get_function_args | def get_function_args(func, no_self=False, no_varargs=False):
"""
Return tuple of the function argument names in the order of the function signature.
:param func: Function
:type func: function object
:param no_self: Flag that indicates whether the function argument *self*,
if ... | python | def get_function_args(func, no_self=False, no_varargs=False):
"""
Return tuple of the function argument names in the order of the function signature.
:param func: Function
:type func: function object
:param no_self: Flag that indicates whether the function argument *self*,
if ... | [
"def",
"get_function_args",
"(",
"func",
",",
"no_self",
"=",
"False",
",",
"no_varargs",
"=",
"False",
")",
":",
"par_dict",
"=",
"signature",
"(",
"func",
")",
".",
"parameters",
"pos",
"=",
"lambda",
"x",
":",
"x",
".",
"kind",
"==",
"Parameter",
".... | Return tuple of the function argument names in the order of the function signature.
:param func: Function
:type func: function object
:param no_self: Flag that indicates whether the function argument *self*,
if present, is included in the output (False) or not (True)
:type no_sel... | [
"Return",
"tuple",
"of",
"the",
"function",
"argument",
"names",
"in",
"the",
"order",
"of",
"the",
"function",
"signature",
"."
] | 201ac243e5781347feb75896a4231429fe6da4b1 | https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pinspect.py#L66-L126 | train |
pmacosta/pexdoc | pexdoc/pinspect.py | get_module_name | def get_module_name(module_obj):
r"""
Retrieve the module name from a module object.
:param module_obj: Module object
:type module_obj: object
:rtype: string
:raises:
* RuntimeError (Argument \`module_obj\` is not valid)
* RuntimeError (Module object \`*[module_name]*\` could not ... | python | def get_module_name(module_obj):
r"""
Retrieve the module name from a module object.
:param module_obj: Module object
:type module_obj: object
:rtype: string
:raises:
* RuntimeError (Argument \`module_obj\` is not valid)
* RuntimeError (Module object \`*[module_name]*\` could not ... | [
"def",
"get_module_name",
"(",
"module_obj",
")",
":",
"r",
"if",
"not",
"is_object_module",
"(",
"module_obj",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Argument `module_obj` is not valid\"",
")",
"name",
"=",
"module_obj",
".",
"__name__",
"msg",
"=",
"\"Module... | r"""
Retrieve the module name from a module object.
:param module_obj: Module object
:type module_obj: object
:rtype: string
:raises:
* RuntimeError (Argument \`module_obj\` is not valid)
* RuntimeError (Module object \`*[module_name]*\` could not be found in
loaded modules)
... | [
"r",
"Retrieve",
"the",
"module",
"name",
"from",
"a",
"module",
"object",
"."
] | 201ac243e5781347feb75896a4231429fe6da4b1 | https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pinspect.py#L129-L156 | train |
pmacosta/pexdoc | pexdoc/pinspect.py | private_props | def private_props(obj):
"""
Yield private properties of an object.
A private property is defined as one that has a single underscore
(:code:`_`) before its name
:param obj: Object
:type obj: object
:returns: iterator
"""
# Get private properties but NOT magic methods
props = ... | python | def private_props(obj):
"""
Yield private properties of an object.
A private property is defined as one that has a single underscore
(:code:`_`) before its name
:param obj: Object
:type obj: object
:returns: iterator
"""
# Get private properties but NOT magic methods
props = ... | [
"def",
"private_props",
"(",
"obj",
")",
":",
"props",
"=",
"[",
"item",
"for",
"item",
"in",
"dir",
"(",
"obj",
")",
"]",
"priv_props",
"=",
"[",
"_PRIVATE_PROP_REGEXP",
".",
"match",
"(",
"item",
")",
"for",
"item",
"in",
"props",
"]",
"call_props",
... | Yield private properties of an object.
A private property is defined as one that has a single underscore
(:code:`_`) before its name
:param obj: Object
:type obj: object
:returns: iterator | [
"Yield",
"private",
"properties",
"of",
"an",
"object",
"."
] | 201ac243e5781347feb75896a4231429fe6da4b1 | https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pinspect.py#L183-L201 | train |
pmacosta/pexdoc | pexdoc/pinspect.py | Callables._check_intersection | def _check_intersection(self, other):
"""Check that intersection of two objects has the same information."""
# pylint: disable=C0123
props = ["_callables_db", "_reverse_callables_db", "_modules_dict"]
for prop in props:
self_dict = getattr(self, prop)
other_dict =... | python | def _check_intersection(self, other):
"""Check that intersection of two objects has the same information."""
# pylint: disable=C0123
props = ["_callables_db", "_reverse_callables_db", "_modules_dict"]
for prop in props:
self_dict = getattr(self, prop)
other_dict =... | [
"def",
"_check_intersection",
"(",
"self",
",",
"other",
")",
":",
"props",
"=",
"[",
"\"_callables_db\"",
",",
"\"_reverse_callables_db\"",
",",
"\"_modules_dict\"",
"]",
"for",
"prop",
"in",
"props",
":",
"self_dict",
"=",
"getattr",
"(",
"self",
",",
"prop"... | Check that intersection of two objects has the same information. | [
"Check",
"that",
"intersection",
"of",
"two",
"objects",
"has",
"the",
"same",
"information",
"."
] | 201ac243e5781347feb75896a4231429fe6da4b1 | https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pinspect.py#L484-L506 | train |
pmacosta/pexdoc | pexdoc/pinspect.py | Callables.get_callable_from_line | def get_callable_from_line(self, module_file, lineno):
"""Get the callable that the line number belongs to."""
module_name = _get_module_name_from_fname(module_file)
if module_name not in self._modules_dict:
self.trace([module_file])
ret = None
# Sort callables by sta... | python | def get_callable_from_line(self, module_file, lineno):
"""Get the callable that the line number belongs to."""
module_name = _get_module_name_from_fname(module_file)
if module_name not in self._modules_dict:
self.trace([module_file])
ret = None
# Sort callables by sta... | [
"def",
"get_callable_from_line",
"(",
"self",
",",
"module_file",
",",
"lineno",
")",
":",
"module_name",
"=",
"_get_module_name_from_fname",
"(",
"module_file",
")",
"if",
"module_name",
"not",
"in",
"self",
".",
"_modules_dict",
":",
"self",
".",
"trace",
"(",... | Get the callable that the line number belongs to. | [
"Get",
"the",
"callable",
"that",
"the",
"line",
"number",
"belongs",
"to",
"."
] | 201ac243e5781347feb75896a4231429fe6da4b1 | https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pinspect.py#L512-L525 | train |
pmacosta/pexdoc | pexdoc/pinspect.py | Callables.refresh | def refresh(self):
"""Re-traces modules modified since the time they were traced."""
self.trace(list(self._fnames.keys()), _refresh=True) | python | def refresh(self):
"""Re-traces modules modified since the time they were traced."""
self.trace(list(self._fnames.keys()), _refresh=True) | [
"def",
"refresh",
"(",
"self",
")",
":",
"self",
".",
"trace",
"(",
"list",
"(",
"self",
".",
"_fnames",
".",
"keys",
"(",
")",
")",
",",
"_refresh",
"=",
"True",
")"
] | Re-traces modules modified since the time they were traced. | [
"Re",
"-",
"traces",
"modules",
"modified",
"since",
"the",
"time",
"they",
"were",
"traced",
"."
] | 201ac243e5781347feb75896a4231429fe6da4b1 | https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pinspect.py#L578-L580 | train |
pmacosta/pexdoc | pexdoc/pinspect.py | Callables.save | def save(self, callables_fname):
r"""
Save traced modules information to a `JSON`_ file.
If the file exists it is overwritten
:param callables_fname: File name
:type callables_fname: :ref:`FileName`
:raises: RuntimeError (Argument \\`fname\\` is not valid)
"""... | python | def save(self, callables_fname):
r"""
Save traced modules information to a `JSON`_ file.
If the file exists it is overwritten
:param callables_fname: File name
:type callables_fname: :ref:`FileName`
:raises: RuntimeError (Argument \\`fname\\` is not valid)
"""... | [
"def",
"save",
"(",
"self",
",",
"callables_fname",
")",
":",
"r",
"_validate_fname",
"(",
"callables_fname",
")",
"items",
"=",
"self",
".",
"_reverse_callables_db",
".",
"items",
"(",
")",
"fdict",
"=",
"{",
"\"_callables_db\"",
":",
"self",
".",
"_callabl... | r"""
Save traced modules information to a `JSON`_ file.
If the file exists it is overwritten
:param callables_fname: File name
:type callables_fname: :ref:`FileName`
:raises: RuntimeError (Argument \\`fname\\` is not valid) | [
"r",
"Save",
"traced",
"modules",
"information",
"to",
"a",
"JSON",
"_",
"file",
"."
] | 201ac243e5781347feb75896a4231429fe6da4b1 | https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pinspect.py#L582-L609 | train |
pmacosta/pexdoc | pexdoc/pinspect.py | _AstTreeScanner._close_callable | def _close_callable(self, node, force=False):
"""Record last line number of callable."""
# Only nodes that have a line number can be considered for closing
# callables. Similarly, only nodes with lines greater than the one
# already processed can be considered for closing callables
... | python | def _close_callable(self, node, force=False):
"""Record last line number of callable."""
# Only nodes that have a line number can be considered for closing
# callables. Similarly, only nodes with lines greater than the one
# already processed can be considered for closing callables
... | [
"def",
"_close_callable",
"(",
"self",
",",
"node",
",",
"force",
"=",
"False",
")",
":",
"try",
":",
"lineno",
"=",
"node",
".",
"lineno",
"except",
"AttributeError",
":",
"return",
"if",
"lineno",
"<=",
"self",
".",
"_processed_line",
":",
"return",
"n... | Record last line number of callable. | [
"Record",
"last",
"line",
"number",
"of",
"callable",
"."
] | 201ac243e5781347feb75896a4231429fe6da4b1 | https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pinspect.py#L791-L903 | train |
pmacosta/pexdoc | pexdoc/pinspect.py | _AstTreeScanner._get_indent | def _get_indent(self, node):
"""Get node indentation level."""
lineno = node.lineno
if lineno > len(self._lines):
return -1
wsindent = self._wsregexp.match(self._lines[lineno - 1])
return len(wsindent.group(1)) | python | def _get_indent(self, node):
"""Get node indentation level."""
lineno = node.lineno
if lineno > len(self._lines):
return -1
wsindent = self._wsregexp.match(self._lines[lineno - 1])
return len(wsindent.group(1)) | [
"def",
"_get_indent",
"(",
"self",
",",
"node",
")",
":",
"lineno",
"=",
"node",
".",
"lineno",
"if",
"lineno",
">",
"len",
"(",
"self",
".",
"_lines",
")",
":",
"return",
"-",
"1",
"wsindent",
"=",
"self",
".",
"_wsregexp",
".",
"match",
"(",
"sel... | Get node indentation level. | [
"Get",
"node",
"indentation",
"level",
"."
] | 201ac243e5781347feb75896a4231429fe6da4b1 | https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pinspect.py#L905-L911 | train |
pmacosta/pexdoc | pexdoc/pinspect.py | _AstTreeScanner._in_class | def _in_class(self, node):
"""Find if callable is function or method."""
# Move left one indentation level and check if that callable is a class
indent = self._get_indent(node)
for indent_dict in reversed(self._indent_stack): # pragma: no branch
if (indent_dict["level"] < in... | python | def _in_class(self, node):
"""Find if callable is function or method."""
# Move left one indentation level and check if that callable is a class
indent = self._get_indent(node)
for indent_dict in reversed(self._indent_stack): # pragma: no branch
if (indent_dict["level"] < in... | [
"def",
"_in_class",
"(",
"self",
",",
"node",
")",
":",
"indent",
"=",
"self",
".",
"_get_indent",
"(",
"node",
")",
"for",
"indent_dict",
"in",
"reversed",
"(",
"self",
".",
"_indent_stack",
")",
":",
"if",
"(",
"indent_dict",
"[",
"\"level\"",
"]",
"... | Find if callable is function or method. | [
"Find",
"if",
"callable",
"is",
"function",
"or",
"method",
"."
] | 201ac243e5781347feb75896a4231429fe6da4b1 | https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pinspect.py#L913-L919 | train |
pmacosta/pexdoc | pexdoc/pinspect.py | _AstTreeScanner._pop_indent_stack | def _pop_indent_stack(self, node, node_type=None, action=None):
"""Get callable full name."""
indent = self._get_indent(node)
indent_stack = copy.deepcopy(self._indent_stack)
# Find enclosing scope
while (len(indent_stack) > 1) and (
(
(indent <= inden... | python | def _pop_indent_stack(self, node, node_type=None, action=None):
"""Get callable full name."""
indent = self._get_indent(node)
indent_stack = copy.deepcopy(self._indent_stack)
# Find enclosing scope
while (len(indent_stack) > 1) and (
(
(indent <= inden... | [
"def",
"_pop_indent_stack",
"(",
"self",
",",
"node",
",",
"node_type",
"=",
"None",
",",
"action",
"=",
"None",
")",
":",
"indent",
"=",
"self",
".",
"_get_indent",
"(",
"node",
")",
"indent_stack",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"_in... | Get callable full name. | [
"Get",
"callable",
"full",
"name",
"."
] | 201ac243e5781347feb75896a4231429fe6da4b1 | https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pinspect.py#L921-L965 | train |
pmacosta/pexdoc | pexdoc/pinspect.py | _AstTreeScanner.generic_visit | def generic_visit(self, node):
"""Implement generic node."""
# [[[cog
# cog.out("print(pcolor('Enter generic visitor', 'magenta'))")
# ]]]
# [[[end]]]
# A generic visitor that potentially closes callables is needed to
# close enclosed callables that are not at the... | python | def generic_visit(self, node):
"""Implement generic node."""
# [[[cog
# cog.out("print(pcolor('Enter generic visitor', 'magenta'))")
# ]]]
# [[[end]]]
# A generic visitor that potentially closes callables is needed to
# close enclosed callables that are not at the... | [
"def",
"generic_visit",
"(",
"self",
",",
"node",
")",
":",
"self",
".",
"_close_callable",
"(",
"node",
")",
"super",
"(",
"_AstTreeScanner",
",",
"self",
")",
".",
"generic_visit",
"(",
"node",
")"
] | Implement generic node. | [
"Implement",
"generic",
"node",
"."
] | 201ac243e5781347feb75896a4231429fe6da4b1 | https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pinspect.py#L967-L979 | train |
pmacosta/pexdoc | pexdoc/pinspect.py | _AstTreeScanner.visit_Assign | def visit_Assign(self, node):
"""
Implement assignment walker.
Parse class properties defined via the property() function
"""
# [[[cog
# cog.out("print(pcolor('Enter assign visitor', 'magenta'))")
# ]]]
# [[[end]]]
# ###
# Class-level assi... | python | def visit_Assign(self, node):
"""
Implement assignment walker.
Parse class properties defined via the property() function
"""
# [[[cog
# cog.out("print(pcolor('Enter assign visitor', 'magenta'))")
# ]]]
# [[[end]]]
# ###
# Class-level assi... | [
"def",
"visit_Assign",
"(",
"self",
",",
"node",
")",
":",
"if",
"self",
".",
"_in_class",
"(",
"node",
")",
":",
"element_full_name",
"=",
"self",
".",
"_pop_indent_stack",
"(",
"node",
",",
"\"prop\"",
")",
"code_id",
"=",
"(",
"self",
".",
"_fname",
... | Implement assignment walker.
Parse class properties defined via the property() function | [
"Implement",
"assignment",
"walker",
"."
] | 201ac243e5781347feb75896a4231429fe6da4b1 | https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pinspect.py#L989-L1029 | train |
pmacosta/pexdoc | pexdoc/pinspect.py | _AstTreeScanner.visit_ClassDef | def visit_ClassDef(self, node):
"""Implement class walker."""
# [[[cog
# cog.out("print(pcolor('Enter class visitor', 'magenta'))")
# ]]]
# [[[end]]]
# Get class information (name, line number, etc.)
element_full_name = self._pop_indent_stack(node, "class")
... | python | def visit_ClassDef(self, node):
"""Implement class walker."""
# [[[cog
# cog.out("print(pcolor('Enter class visitor', 'magenta'))")
# ]]]
# [[[end]]]
# Get class information (name, line number, etc.)
element_full_name = self._pop_indent_stack(node, "class")
... | [
"def",
"visit_ClassDef",
"(",
"self",
",",
"node",
")",
":",
"element_full_name",
"=",
"self",
".",
"_pop_indent_stack",
"(",
"node",
",",
"\"class\"",
")",
"code_id",
"=",
"(",
"self",
".",
"_fname",
",",
"node",
".",
"lineno",
")",
"self",
".",
"_proce... | Implement class walker. | [
"Implement",
"class",
"walker",
"."
] | 201ac243e5781347feb75896a4231429fe6da4b1 | https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pinspect.py#L1031-L1064 | train |
rbeagrie/wrapit | wrapit/api.py | run | def run(task_creators, args, task_selectors=[]):
"""run doit using task_creators
@param task_creators: module or dict containing task creators
"""
if args.reset_dep:
sys.exit(DoitMain(WrapitLoader(args, task_creators)).run(['reset-dep']))
else:
sys.exit(DoitMain(WrapitLoader(args, t... | python | def run(task_creators, args, task_selectors=[]):
"""run doit using task_creators
@param task_creators: module or dict containing task creators
"""
if args.reset_dep:
sys.exit(DoitMain(WrapitLoader(args, task_creators)).run(['reset-dep']))
else:
sys.exit(DoitMain(WrapitLoader(args, t... | [
"def",
"run",
"(",
"task_creators",
",",
"args",
",",
"task_selectors",
"=",
"[",
"]",
")",
":",
"if",
"args",
".",
"reset_dep",
":",
"sys",
".",
"exit",
"(",
"DoitMain",
"(",
"WrapitLoader",
"(",
"args",
",",
"task_creators",
")",
")",
".",
"run",
"... | run doit using task_creators
@param task_creators: module or dict containing task creators | [
"run",
"doit",
"using",
"task_creators"
] | ee01c20cca0a9e51c62fb73c894227e36d9abaaa | https://github.com/rbeagrie/wrapit/blob/ee01c20cca0a9e51c62fb73c894227e36d9abaaa/wrapit/api.py#L7-L15 | train |
a1ezzz/wasp-general | wasp_general/task/registry.py | WTaskRegistryStorage.tasks_by_tag | def tasks_by_tag(self, registry_tag):
""" Get tasks from registry by its tag
:param registry_tag: any hash-able object
:return: Return task (if :attr:`.WTaskRegistryStorage.__multiple_tasks_per_tag__` is not True) or \
list of tasks
"""
if registry_tag not in self.__registry.keys():
return None
tasks ... | python | def tasks_by_tag(self, registry_tag):
""" Get tasks from registry by its tag
:param registry_tag: any hash-able object
:return: Return task (if :attr:`.WTaskRegistryStorage.__multiple_tasks_per_tag__` is not True) or \
list of tasks
"""
if registry_tag not in self.__registry.keys():
return None
tasks ... | [
"def",
"tasks_by_tag",
"(",
"self",
",",
"registry_tag",
")",
":",
"if",
"registry_tag",
"not",
"in",
"self",
".",
"__registry",
".",
"keys",
"(",
")",
":",
"return",
"None",
"tasks",
"=",
"self",
".",
"__registry",
"[",
"registry_tag",
"]",
"return",
"t... | Get tasks from registry by its tag
:param registry_tag: any hash-able object
:return: Return task (if :attr:`.WTaskRegistryStorage.__multiple_tasks_per_tag__` is not True) or \
list of tasks | [
"Get",
"tasks",
"from",
"registry",
"by",
"its",
"tag"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/registry.py#L201-L211 | train |
a1ezzz/wasp-general | wasp_general/task/registry.py | WTaskRegistryStorage.count | def count(self):
""" Registered task count
:return: int
"""
result = 0
for tasks in self.__registry.values():
result += len(tasks)
return result | python | def count(self):
""" Registered task count
:return: int
"""
result = 0
for tasks in self.__registry.values():
result += len(tasks)
return result | [
"def",
"count",
"(",
"self",
")",
":",
"result",
"=",
"0",
"for",
"tasks",
"in",
"self",
".",
"__registry",
".",
"values",
"(",
")",
":",
"result",
"+=",
"len",
"(",
"tasks",
")",
"return",
"result"
] | Registered task count
:return: int | [
"Registered",
"task",
"count"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/registry.py#L230-L238 | train |
a1ezzz/wasp-general | wasp_general/task/registry.py | WTaskRegistry.add | def add(cls, task_cls):
""" Add task class to storage
:param task_cls: task to add
:return: None
"""
if task_cls.__registry_tag__ is None and cls.__skip_none_registry_tag__ is True:
return
cls.registry_storage().add(task_cls) | python | def add(cls, task_cls):
""" Add task class to storage
:param task_cls: task to add
:return: None
"""
if task_cls.__registry_tag__ is None and cls.__skip_none_registry_tag__ is True:
return
cls.registry_storage().add(task_cls) | [
"def",
"add",
"(",
"cls",
",",
"task_cls",
")",
":",
"if",
"task_cls",
".",
"__registry_tag__",
"is",
"None",
"and",
"cls",
".",
"__skip_none_registry_tag__",
"is",
"True",
":",
"return",
"cls",
".",
"registry_storage",
"(",
")",
".",
"add",
"(",
"task_cls... | Add task class to storage
:param task_cls: task to add
:return: None | [
"Add",
"task",
"class",
"to",
"storage"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/registry.py#L270-L280 | train |
pmacosta/pexdoc | docs/support/exh_example.py | my_func | def my_func(name):
"""Sample function."""
# Add exception
exobj = addex(TypeError, "Argument `name` is not valid")
# Conditionally raise exception
exobj(not isinstance(name, str))
print("My name is {0}".format(name)) | python | def my_func(name):
"""Sample function."""
# Add exception
exobj = addex(TypeError, "Argument `name` is not valid")
# Conditionally raise exception
exobj(not isinstance(name, str))
print("My name is {0}".format(name)) | [
"def",
"my_func",
"(",
"name",
")",
":",
"exobj",
"=",
"addex",
"(",
"TypeError",
",",
"\"Argument `name` is not valid\"",
")",
"exobj",
"(",
"not",
"isinstance",
"(",
"name",
",",
"str",
")",
")",
"print",
"(",
"\"My name is {0}\"",
".",
"format",
"(",
"n... | Sample function. | [
"Sample",
"function",
"."
] | 201ac243e5781347feb75896a4231429fe6da4b1 | https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/docs/support/exh_example.py#L10-L16 | train |
a1ezzz/wasp-general | wasp_general/command/command.py | WCommandPrioritizedSelector.add_prioritized | def add_prioritized(self, command_obj, priority):
""" Add command with the specified priority
:param command_obj: command to add
:param priority: command priority
:return: None
"""
if priority not in self.__priorities.keys():
self.__priorities[priority] = []
self.__priorities[priority].append(command... | python | def add_prioritized(self, command_obj, priority):
""" Add command with the specified priority
:param command_obj: command to add
:param priority: command priority
:return: None
"""
if priority not in self.__priorities.keys():
self.__priorities[priority] = []
self.__priorities[priority].append(command... | [
"def",
"add_prioritized",
"(",
"self",
",",
"command_obj",
",",
"priority",
")",
":",
"if",
"priority",
"not",
"in",
"self",
".",
"__priorities",
".",
"keys",
"(",
")",
":",
"self",
".",
"__priorities",
"[",
"priority",
"]",
"=",
"[",
"]",
"self",
".",... | Add command with the specified priority
:param command_obj: command to add
:param priority: command priority
:return: None | [
"Add",
"command",
"with",
"the",
"specified",
"priority"
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/command/command.py#L205-L215 | train |
a1ezzz/wasp-general | wasp_general/command/command.py | WCommandSet.__track_vars | def __track_vars(self, command_result):
""" Check if there are any tracked variable inside the result. And keep them for future use.
:param command_result: command result tot check
:return:
"""
command_env = command_result.environment()
for var_name in self.tracked_vars():
if var_name in command_env.ke... | python | def __track_vars(self, command_result):
""" Check if there are any tracked variable inside the result. And keep them for future use.
:param command_result: command result tot check
:return:
"""
command_env = command_result.environment()
for var_name in self.tracked_vars():
if var_name in command_env.ke... | [
"def",
"__track_vars",
"(",
"self",
",",
"command_result",
")",
":",
"command_env",
"=",
"command_result",
".",
"environment",
"(",
")",
"for",
"var_name",
"in",
"self",
".",
"tracked_vars",
"(",
")",
":",
"if",
"var_name",
"in",
"command_env",
".",
"keys",
... | Check if there are any tracked variable inside the result. And keep them for future use.
:param command_result: command result tot check
:return: | [
"Check",
"if",
"there",
"are",
"any",
"tracked",
"variable",
"inside",
"the",
"result",
".",
"And",
"keep",
"them",
"for",
"future",
"use",
"."
] | 1029839d33eb663f8dec76c1c46754d53c1de4a9 | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/command/command.py#L320-L330 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.