repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
DataMedSci/mcpartools
setup.py
setup_versioneer
def setup_versioneer(): """ Generate (temporarily) versioneer.py file in project root directory :return: """ try: # assume versioneer.py was generated using "versioneer install" command import versioneer versioneer.get_version() except ImportError: # it looks vers...
python
def setup_versioneer(): """ Generate (temporarily) versioneer.py file in project root directory :return: """ try: # assume versioneer.py was generated using "versioneer install" command import versioneer versioneer.get_version() except ImportError: # it looks vers...
[ "def", "setup_versioneer", "(", ")", ":", "try", ":", "# assume versioneer.py was generated using \"versioneer install\" command", "import", "versioneer", "versioneer", ".", "get_version", "(", ")", "except", "ImportError", ":", "# it looks versioneer.py is missing", "# lets as...
Generate (temporarily) versioneer.py file in project root directory :return:
[ "Generate", "(", "temporarily", ")", "versioneer", ".", "py", "file", "in", "project", "root", "directory", ":", "return", ":" ]
84f869094d05bf70f09e8aaeca671ddaa1c56ec4
https://github.com/DataMedSci/mcpartools/blob/84f869094d05bf70f09e8aaeca671ddaa1c56ec4/setup.py#L25-L67
train
DataMedSci/mcpartools
setup.py
clean_cache
def clean_cache(): """ Python won't realise that new module has appeared in the runtime We need to clean the cache of module finders. Hacking again :return: """ import importlib try: # Python ver < 3.3 vermod = importlib.import_module("versioneer") globals()["versioneer"] = ...
python
def clean_cache(): """ Python won't realise that new module has appeared in the runtime We need to clean the cache of module finders. Hacking again :return: """ import importlib try: # Python ver < 3.3 vermod = importlib.import_module("versioneer") globals()["versioneer"] = ...
[ "def", "clean_cache", "(", ")", ":", "import", "importlib", "try", ":", "# Python ver < 3.3", "vermod", "=", "importlib", ".", "import_module", "(", "\"versioneer\"", ")", "globals", "(", ")", "[", "\"versioneer\"", "]", "=", "vermod", "except", "ImportError", ...
Python won't realise that new module has appeared in the runtime We need to clean the cache of module finders. Hacking again :return:
[ "Python", "won", "t", "realise", "that", "new", "module", "has", "appeared", "in", "the", "runtime", "We", "need", "to", "clean", "the", "cache", "of", "module", "finders", ".", "Hacking", "again", ":", "return", ":" ]
84f869094d05bf70f09e8aaeca671ddaa1c56ec4
https://github.com/DataMedSci/mcpartools/blob/84f869094d05bf70f09e8aaeca671ddaa1c56ec4/setup.py#L70-L81
train
DataMedSci/mcpartools
setup.py
get_version
def get_version(): """ Get project version (using versioneer) :return: string containing version """ setup_versioneer() clean_cache() import versioneer version = versioneer.get_version() parsed_version = parse_version(version) if '*@' in str(parsed_version): import time ...
python
def get_version(): """ Get project version (using versioneer) :return: string containing version """ setup_versioneer() clean_cache() import versioneer version = versioneer.get_version() parsed_version = parse_version(version) if '*@' in str(parsed_version): import time ...
[ "def", "get_version", "(", ")", ":", "setup_versioneer", "(", ")", "clean_cache", "(", ")", "import", "versioneer", "version", "=", "versioneer", ".", "get_version", "(", ")", "parsed_version", "=", "parse_version", "(", "version", ")", "if", "'*@'", "in", "...
Get project version (using versioneer) :return: string containing version
[ "Get", "project", "version", "(", "using", "versioneer", ")", ":", "return", ":", "string", "containing", "version" ]
84f869094d05bf70f09e8aaeca671ddaa1c56ec4
https://github.com/DataMedSci/mcpartools/blob/84f869094d05bf70f09e8aaeca671ddaa1c56ec4/setup.py#L84-L97
train
josiah-wolf-oberholtzer/uqbar
uqbar/io/__init__.py
find_common_prefix
def find_common_prefix( paths: Sequence[Union[str, pathlib.Path]] ) -> Optional[pathlib.Path]: """ Find the common prefix of two or more paths. :: >>> import pathlib >>> one = pathlib.Path('foo/bar/baz') >>> two = pathlib.Path('foo/quux/biz') >>> three = pathlib.Path('f...
python
def find_common_prefix( paths: Sequence[Union[str, pathlib.Path]] ) -> Optional[pathlib.Path]: """ Find the common prefix of two or more paths. :: >>> import pathlib >>> one = pathlib.Path('foo/bar/baz') >>> two = pathlib.Path('foo/quux/biz') >>> three = pathlib.Path('f...
[ "def", "find_common_prefix", "(", "paths", ":", "Sequence", "[", "Union", "[", "str", ",", "pathlib", ".", "Path", "]", "]", ")", "->", "Optional", "[", "pathlib", ".", "Path", "]", ":", "counter", ":", "collections", ".", "Counter", "=", "collections", ...
Find the common prefix of two or more paths. :: >>> import pathlib >>> one = pathlib.Path('foo/bar/baz') >>> two = pathlib.Path('foo/quux/biz') >>> three = pathlib.Path('foo/quux/wuux') :: >>> import uqbar.io >>> str(uqbar.io.find_common_prefix([one, two, thre...
[ "Find", "the", "common", "prefix", "of", "two", "or", "more", "paths", "." ]
eca7fefebbbee1e2ae13bf5d6baa838be66b1db6
https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/io/__init__.py#L16-L48
train
josiah-wolf-oberholtzer/uqbar
uqbar/io/__init__.py
find_executable
def find_executable(name: str, flags=os.X_OK) -> List[str]: r"""Finds executable `name`. Similar to Unix ``which`` command. Returns list of zero or more full paths to `name`. """ result = [] extensions = [x for x in os.environ.get("PATHEXT", "").split(os.pathsep) if x] path = os.environ.ge...
python
def find_executable(name: str, flags=os.X_OK) -> List[str]: r"""Finds executable `name`. Similar to Unix ``which`` command. Returns list of zero or more full paths to `name`. """ result = [] extensions = [x for x in os.environ.get("PATHEXT", "").split(os.pathsep) if x] path = os.environ.ge...
[ "def", "find_executable", "(", "name", ":", "str", ",", "flags", "=", "os", ".", "X_OK", ")", "->", "List", "[", "str", "]", ":", "result", "=", "[", "]", "extensions", "=", "[", "x", "for", "x", "in", "os", ".", "environ", ".", "get", "(", "\"...
r"""Finds executable `name`. Similar to Unix ``which`` command. Returns list of zero or more full paths to `name`.
[ "r", "Finds", "executable", "name", "." ]
eca7fefebbbee1e2ae13bf5d6baa838be66b1db6
https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/io/__init__.py#L51-L71
train
josiah-wolf-oberholtzer/uqbar
uqbar/io/__init__.py
relative_to
def relative_to( source_path: Union[str, pathlib.Path], target_path: Union[str, pathlib.Path] ) -> pathlib.Path: """ Generates relative path from ``source_path`` to ``target_path``. Handles the case of paths without a common prefix. :: >>> import pathlib >>> source = pathlib.Path(...
python
def relative_to( source_path: Union[str, pathlib.Path], target_path: Union[str, pathlib.Path] ) -> pathlib.Path: """ Generates relative path from ``source_path`` to ``target_path``. Handles the case of paths without a common prefix. :: >>> import pathlib >>> source = pathlib.Path(...
[ "def", "relative_to", "(", "source_path", ":", "Union", "[", "str", ",", "pathlib", ".", "Path", "]", ",", "target_path", ":", "Union", "[", "str", ",", "pathlib", ".", "Path", "]", ")", "->", "pathlib", ".", "Path", ":", "source_path", "=", "pathlib",...
Generates relative path from ``source_path`` to ``target_path``. Handles the case of paths without a common prefix. :: >>> import pathlib >>> source = pathlib.Path('foo/bar/baz') >>> target = pathlib.Path('foo/quux/biz') :: >>> target.relative_to(source) Tracebac...
[ "Generates", "relative", "path", "from", "source_path", "to", "target_path", "." ]
eca7fefebbbee1e2ae13bf5d6baa838be66b1db6
https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/io/__init__.py#L74-L114
train
josiah-wolf-oberholtzer/uqbar
uqbar/io/__init__.py
walk
def walk( root_path: Union[str, pathlib.Path], top_down: bool = True ) -> Generator[ Tuple[pathlib.Path, Sequence[pathlib.Path], Sequence[pathlib.Path]], None, None ]: """ Walks a directory tree. Like :py:func:`os.walk` but yielding instances of :py:class:`pathlib.Path` instead of strings. ...
python
def walk( root_path: Union[str, pathlib.Path], top_down: bool = True ) -> Generator[ Tuple[pathlib.Path, Sequence[pathlib.Path], Sequence[pathlib.Path]], None, None ]: """ Walks a directory tree. Like :py:func:`os.walk` but yielding instances of :py:class:`pathlib.Path` instead of strings. ...
[ "def", "walk", "(", "root_path", ":", "Union", "[", "str", ",", "pathlib", ".", "Path", "]", ",", "top_down", ":", "bool", "=", "True", ")", "->", "Generator", "[", "Tuple", "[", "pathlib", ".", "Path", ",", "Sequence", "[", "pathlib", ".", "Path", ...
Walks a directory tree. Like :py:func:`os.walk` but yielding instances of :py:class:`pathlib.Path` instead of strings. :param root_path: foo :param top_down: bar
[ "Walks", "a", "directory", "tree", "." ]
eca7fefebbbee1e2ae13bf5d6baa838be66b1db6
https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/io/__init__.py#L117-L143
train
josiah-wolf-oberholtzer/uqbar
uqbar/io/__init__.py
write
def write( contents: str, path: Union[str, pathlib.Path], verbose: bool = False, logger_func=None, ) -> bool: """ Writes ``contents`` to ``path``. Checks if ``path`` already exists and only write out new contents if the old contents do not match. Creates any intermediate missing di...
python
def write( contents: str, path: Union[str, pathlib.Path], verbose: bool = False, logger_func=None, ) -> bool: """ Writes ``contents`` to ``path``. Checks if ``path`` already exists and only write out new contents if the old contents do not match. Creates any intermediate missing di...
[ "def", "write", "(", "contents", ":", "str", ",", "path", ":", "Union", "[", "str", ",", "pathlib", ".", "Path", "]", ",", "verbose", ":", "bool", "=", "False", ",", "logger_func", "=", "None", ",", ")", "->", "bool", ":", "print_func", "=", "logge...
Writes ``contents`` to ``path``. Checks if ``path`` already exists and only write out new contents if the old contents do not match. Creates any intermediate missing directories. :param contents: the file contents to write :param path: the path to write to :param verbose: whether to print out...
[ "Writes", "contents", "to", "path", "." ]
eca7fefebbbee1e2ae13bf5d6baa838be66b1db6
https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/io/__init__.py#L146-L186
train
MatterMiners/cobald
cobald/daemon/debug.py
pretty_ref
def pretty_ref(obj: Any) -> str: """Pretty object reference using ``module.path:qual.name`` format""" try: return obj.__module__ + ':' + obj.__qualname__ except AttributeError: return pretty_ref(type(obj)) + '(...)'
python
def pretty_ref(obj: Any) -> str: """Pretty object reference using ``module.path:qual.name`` format""" try: return obj.__module__ + ':' + obj.__qualname__ except AttributeError: return pretty_ref(type(obj)) + '(...)'
[ "def", "pretty_ref", "(", "obj", ":", "Any", ")", "->", "str", ":", "try", ":", "return", "obj", ".", "__module__", "+", "':'", "+", "obj", ".", "__qualname__", "except", "AttributeError", ":", "return", "pretty_ref", "(", "type", "(", "obj", ")", ")",...
Pretty object reference using ``module.path:qual.name`` format
[ "Pretty", "object", "reference", "using", "module", ".", "path", ":", "qual", ".", "name", "format" ]
264138de4382d1c9b53fabcbc6660e10b33a914d
https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/debug.py#L8-L13
train
quantmind/agile-toolkit
agiletoolkit/github/remote.py
remote
def remote(ctx): """Display repo github path """ with command(): m = RepoManager(ctx.obj['agile']) click.echo(m.github_repo().repo_path)
python
def remote(ctx): """Display repo github path """ with command(): m = RepoManager(ctx.obj['agile']) click.echo(m.github_repo().repo_path)
[ "def", "remote", "(", "ctx", ")", ":", "with", "command", "(", ")", ":", "m", "=", "RepoManager", "(", "ctx", ".", "obj", "[", "'agile'", "]", ")", "click", ".", "echo", "(", "m", ".", "github_repo", "(", ")", ".", "repo_path", ")" ]
Display repo github path
[ "Display", "repo", "github", "path" ]
96028e36a842c57b171907c20583a60d1045fec1
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/github/remote.py#L9-L14
train
josiah-wolf-oberholtzer/uqbar
uqbar/containers/UniqueTreeNode.py
UniqueTreeNode.graph_order
def graph_order(self): """ Get graph-order tuple for node. :: >>> from uqbar.containers import UniqueTreeContainer, UniqueTreeNode >>> root_container = UniqueTreeContainer(name="root") >>> outer_container = UniqueTreeContainer(name="outer") >>> i...
python
def graph_order(self): """ Get graph-order tuple for node. :: >>> from uqbar.containers import UniqueTreeContainer, UniqueTreeNode >>> root_container = UniqueTreeContainer(name="root") >>> outer_container = UniqueTreeContainer(name="outer") >>> i...
[ "def", "graph_order", "(", "self", ")", ":", "parentage", "=", "tuple", "(", "reversed", "(", "self", ".", "parentage", ")", ")", "graph_order", "=", "[", "]", "for", "i", "in", "range", "(", "len", "(", "parentage", ")", "-", "1", ")", ":", "paren...
Get graph-order tuple for node. :: >>> from uqbar.containers import UniqueTreeContainer, UniqueTreeNode >>> root_container = UniqueTreeContainer(name="root") >>> outer_container = UniqueTreeContainer(name="outer") >>> inner_container = UniqueTreeContainer(name="...
[ "Get", "graph", "-", "order", "tuple", "for", "node", "." ]
eca7fefebbbee1e2ae13bf5d6baa838be66b1db6
https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/containers/UniqueTreeNode.py#L118-L154
train
xenadevel/PyXenaManager
xenamanager/api/XenaSocket.py
XenaSocket.sendQuery
def sendQuery(self, cmd, multilines=False): """ Send command, wait for response (single or multi lines), test for errors and return the returned code. :param cmd: command to send :param multilines: True - multiline response, False - single line response. :return: command return value. ...
python
def sendQuery(self, cmd, multilines=False): """ Send command, wait for response (single or multi lines), test for errors and return the returned code. :param cmd: command to send :param multilines: True - multiline response, False - single line response. :return: command return value. ...
[ "def", "sendQuery", "(", "self", ",", "cmd", ",", "multilines", "=", "False", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"sendQuery(%s)\"", ",", "cmd", ")", "if", "not", "self", ".", "is_connected", "(", ")", ":", "raise", "socket", ".", "...
Send command, wait for response (single or multi lines), test for errors and return the returned code. :param cmd: command to send :param multilines: True - multiline response, False - single line response. :return: command return value.
[ "Send", "command", "wait", "for", "response", "(", "single", "or", "multi", "lines", ")", "test", "for", "errors", "and", "return", "the", "returned", "code", "." ]
384ca265f73044b8a8b471f5dd7a6103fc54f4df
https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/api/XenaSocket.py#L97-L123
train
xenadevel/PyXenaManager
xenamanager/api/XenaSocket.py
XenaSocket.sendQueryVerify
def sendQueryVerify(self, cmd): """ Send command without return value, wait for completion, verify success. :param cmd: command to send """ cmd = cmd.strip() self.logger.debug("sendQueryVerify(%s)", cmd) if not self.is_connected(): raise socket.error("sendQue...
python
def sendQueryVerify(self, cmd): """ Send command without return value, wait for completion, verify success. :param cmd: command to send """ cmd = cmd.strip() self.logger.debug("sendQueryVerify(%s)", cmd) if not self.is_connected(): raise socket.error("sendQue...
[ "def", "sendQueryVerify", "(", "self", ",", "cmd", ")", ":", "cmd", "=", "cmd", ".", "strip", "(", ")", "self", ".", "logger", ".", "debug", "(", "\"sendQueryVerify(%s)\"", ",", "cmd", ")", "if", "not", "self", ".", "is_connected", "(", ")", ":", "ra...
Send command without return value, wait for completion, verify success. :param cmd: command to send
[ "Send", "command", "without", "return", "value", "wait", "for", "completion", "verify", "success", "." ]
384ca265f73044b8a8b471f5dd7a6103fc54f4df
https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/api/XenaSocket.py#L125-L138
train
DataMedSci/mcpartools
mcpartools/mcengine/shieldhit.py
ShieldHit.find_external_files
def find_external_files(self, run_input_dir): """ Scan all SHIELDHIT12A config files to find external files used and return them. Also change paths in config files to match convention that all resources are symlinked in job_xxxx/symlink """ beam_file, geo_file, mat_file, ...
python
def find_external_files(self, run_input_dir): """ Scan all SHIELDHIT12A config files to find external files used and return them. Also change paths in config files to match convention that all resources are symlinked in job_xxxx/symlink """ beam_file, geo_file, mat_file, ...
[ "def", "find_external_files", "(", "self", ",", "run_input_dir", ")", ":", "beam_file", ",", "geo_file", ",", "mat_file", ",", "_", "=", "self", ".", "input_files", "# check for external files in BEAM input file", "external_beam_files", "=", "self", ".", "_parse_beam_...
Scan all SHIELDHIT12A config files to find external files used and return them. Also change paths in config files to match convention that all resources are symlinked in job_xxxx/symlink
[ "Scan", "all", "SHIELDHIT12A", "config", "files", "to", "find", "external", "files", "used", "and", "return", "them", ".", "Also", "change", "paths", "in", "config", "files", "to", "match", "convention", "that", "all", "resources", "are", "symlinked", "in", ...
84f869094d05bf70f09e8aaeca671ddaa1c56ec4
https://github.com/DataMedSci/mcpartools/blob/84f869094d05bf70f09e8aaeca671ddaa1c56ec4/mcpartools/mcengine/shieldhit.py#L75-L109
train
DataMedSci/mcpartools
mcpartools/mcengine/shieldhit.py
ShieldHit._parse_beam_file
def _parse_beam_file(self, file_path, run_input_dir): """Scan SH12A BEAM file for references to external files and return them""" external_files = [] paths_to_replace = [] with open(file_path, 'r') as beam_f: for line in beam_f.readlines(): split_line = line.s...
python
def _parse_beam_file(self, file_path, run_input_dir): """Scan SH12A BEAM file for references to external files and return them""" external_files = [] paths_to_replace = [] with open(file_path, 'r') as beam_f: for line in beam_f.readlines(): split_line = line.s...
[ "def", "_parse_beam_file", "(", "self", ",", "file_path", ",", "run_input_dir", ")", ":", "external_files", "=", "[", "]", "paths_to_replace", "=", "[", "]", "with", "open", "(", "file_path", ",", "'r'", ")", "as", "beam_f", ":", "for", "line", "in", "be...
Scan SH12A BEAM file for references to external files and return them
[ "Scan", "SH12A", "BEAM", "file", "for", "references", "to", "external", "files", "and", "return", "them" ]
84f869094d05bf70f09e8aaeca671ddaa1c56ec4
https://github.com/DataMedSci/mcpartools/blob/84f869094d05bf70f09e8aaeca671ddaa1c56ec4/mcpartools/mcengine/shieldhit.py#L111-L133
train
DataMedSci/mcpartools
mcpartools/mcengine/shieldhit.py
ShieldHit._parse_geo_file
def _parse_geo_file(self, file_path, run_input_dir): """Scan SH12A GEO file for references to external files (like voxelised geometry) and return them""" external_files = [] paths_to_replace = [] with open(file_path, 'r') as geo_f: for line in geo_f.readlines(): ...
python
def _parse_geo_file(self, file_path, run_input_dir): """Scan SH12A GEO file for references to external files (like voxelised geometry) and return them""" external_files = [] paths_to_replace = [] with open(file_path, 'r') as geo_f: for line in geo_f.readlines(): ...
[ "def", "_parse_geo_file", "(", "self", ",", "file_path", ",", "run_input_dir", ")", ":", "external_files", "=", "[", "]", "paths_to_replace", "=", "[", "]", "with", "open", "(", "file_path", ",", "'r'", ")", "as", "geo_f", ":", "for", "line", "in", "geo_...
Scan SH12A GEO file for references to external files (like voxelised geometry) and return them
[ "Scan", "SH12A", "GEO", "file", "for", "references", "to", "external", "files", "(", "like", "voxelised", "geometry", ")", "and", "return", "them" ]
84f869094d05bf70f09e8aaeca671ddaa1c56ec4
https://github.com/DataMedSci/mcpartools/blob/84f869094d05bf70f09e8aaeca671ddaa1c56ec4/mcpartools/mcengine/shieldhit.py#L135-L158
train
DataMedSci/mcpartools
mcpartools/mcengine/shieldhit.py
ShieldHit._parse_mat_file
def _parse_mat_file(self, file_path): """Scan SH12A MAT file for ICRU+LOADEX pairs and return found ICRU numbers""" mat_file_sections = self._extract_mat_sections(file_path) return self._analyse_mat_sections(mat_file_sections)
python
def _parse_mat_file(self, file_path): """Scan SH12A MAT file for ICRU+LOADEX pairs and return found ICRU numbers""" mat_file_sections = self._extract_mat_sections(file_path) return self._analyse_mat_sections(mat_file_sections)
[ "def", "_parse_mat_file", "(", "self", ",", "file_path", ")", ":", "mat_file_sections", "=", "self", ".", "_extract_mat_sections", "(", "file_path", ")", "return", "self", ".", "_analyse_mat_sections", "(", "mat_file_sections", ")" ]
Scan SH12A MAT file for ICRU+LOADEX pairs and return found ICRU numbers
[ "Scan", "SH12A", "MAT", "file", "for", "ICRU", "+", "LOADEX", "pairs", "and", "return", "found", "ICRU", "numbers" ]
84f869094d05bf70f09e8aaeca671ddaa1c56ec4
https://github.com/DataMedSci/mcpartools/blob/84f869094d05bf70f09e8aaeca671ddaa1c56ec4/mcpartools/mcengine/shieldhit.py#L160-L163
train
DataMedSci/mcpartools
mcpartools/mcengine/shieldhit.py
ShieldHit._analyse_mat_sections
def _analyse_mat_sections(sections): """ Cases: - ICRU flag present, LOADDEDX flag missing -> data loaded from some data hardcoded in SH12A binary, no need to load external files - ICRU flag present, LOADDEDX flag present -> data loaded from external files. ICRU number read from ...
python
def _analyse_mat_sections(sections): """ Cases: - ICRU flag present, LOADDEDX flag missing -> data loaded from some data hardcoded in SH12A binary, no need to load external files - ICRU flag present, LOADDEDX flag present -> data loaded from external files. ICRU number read from ...
[ "def", "_analyse_mat_sections", "(", "sections", ")", ":", "icru_numbers", "=", "[", "]", "for", "section", "in", "sections", ":", "load_present", "=", "False", "load_value", "=", "False", "icru_value", "=", "False", "for", "e", "in", "section", ":", "split_...
Cases: - ICRU flag present, LOADDEDX flag missing -> data loaded from some data hardcoded in SH12A binary, no need to load external files - ICRU flag present, LOADDEDX flag present -> data loaded from external files. ICRU number read from ICRU flag, any number following LOADDEDX flag is ...
[ "Cases", ":", "-", "ICRU", "flag", "present", "LOADDEDX", "flag", "missing", "-", ">", "data", "loaded", "from", "some", "data", "hardcoded", "in", "SH12A", "binary", "no", "need", "to", "load", "external", "files", "-", "ICRU", "flag", "present", "LOADDED...
84f869094d05bf70f09e8aaeca671ddaa1c56ec4
https://github.com/DataMedSci/mcpartools/blob/84f869094d05bf70f09e8aaeca671ddaa1c56ec4/mcpartools/mcengine/shieldhit.py#L182-L210
train
DataMedSci/mcpartools
mcpartools/mcengine/shieldhit.py
ShieldHit._decrypt_icru_files
def _decrypt_icru_files(numbers): """Find matching file names for given ICRU numbers""" import json icru_file = resource_string(__name__, os.path.join('data', 'SH12A_ICRU_table.json')) ref_dict = json.loads(icru_file.decode('ascii')) try: return [ref_dict[e] for e in ...
python
def _decrypt_icru_files(numbers): """Find matching file names for given ICRU numbers""" import json icru_file = resource_string(__name__, os.path.join('data', 'SH12A_ICRU_table.json')) ref_dict = json.loads(icru_file.decode('ascii')) try: return [ref_dict[e] for e in ...
[ "def", "_decrypt_icru_files", "(", "numbers", ")", ":", "import", "json", "icru_file", "=", "resource_string", "(", "__name__", ",", "os", ".", "path", ".", "join", "(", "'data'", ",", "'SH12A_ICRU_table.json'", ")", ")", "ref_dict", "=", "json", ".", "loads...
Find matching file names for given ICRU numbers
[ "Find", "matching", "file", "names", "for", "given", "ICRU", "numbers" ]
84f869094d05bf70f09e8aaeca671ddaa1c56ec4
https://github.com/DataMedSci/mcpartools/blob/84f869094d05bf70f09e8aaeca671ddaa1c56ec4/mcpartools/mcengine/shieldhit.py#L213-L222
train
DataMedSci/mcpartools
mcpartools/mcengine/shieldhit.py
ShieldHit._rewrite_paths_in_file
def _rewrite_paths_in_file(config_file, paths_to_replace): """ Rewrite paths in config files to match convention job_xxxx/symlink Requires path to run_xxxx/input/config_file and a list of paths_to_replace """ lines = [] # make a copy of config import shutil ...
python
def _rewrite_paths_in_file(config_file, paths_to_replace): """ Rewrite paths in config files to match convention job_xxxx/symlink Requires path to run_xxxx/input/config_file and a list of paths_to_replace """ lines = [] # make a copy of config import shutil ...
[ "def", "_rewrite_paths_in_file", "(", "config_file", ",", "paths_to_replace", ")", ":", "lines", "=", "[", "]", "# make a copy of config", "import", "shutil", "shutil", ".", "copyfile", "(", "config_file", ",", "str", "(", "config_file", "+", "'_original'", ")", ...
Rewrite paths in config files to match convention job_xxxx/symlink Requires path to run_xxxx/input/config_file and a list of paths_to_replace
[ "Rewrite", "paths", "in", "config", "files", "to", "match", "convention", "job_xxxx", "/", "symlink", "Requires", "path", "to", "run_xxxx", "/", "input", "/", "config_file", "and", "a", "list", "of", "paths_to_replace" ]
84f869094d05bf70f09e8aaeca671ddaa1c56ec4
https://github.com/DataMedSci/mcpartools/blob/84f869094d05bf70f09e8aaeca671ddaa1c56ec4/mcpartools/mcengine/shieldhit.py#L225-L244
train
Karaage-Cluster/python-tldap
tldap/django/helpers.py
_check_exists
def _check_exists(database: Database, table: LdapObjectClass, key: str, value: str): """ Check if a given LDAP object exists. """ try: get_one(table, Q(**{key: value}), database=database) return True except ObjectDoesNotExist: return False
python
def _check_exists(database: Database, table: LdapObjectClass, key: str, value: str): """ Check if a given LDAP object exists. """ try: get_one(table, Q(**{key: value}), database=database) return True except ObjectDoesNotExist: return False
[ "def", "_check_exists", "(", "database", ":", "Database", ",", "table", ":", "LdapObjectClass", ",", "key", ":", "str", ",", "value", ":", "str", ")", ":", "try", ":", "get_one", "(", "table", ",", "Q", "(", "*", "*", "{", "key", ":", "value", "}",...
Check if a given LDAP object exists.
[ "Check", "if", "a", "given", "LDAP", "object", "exists", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/django/helpers.py#L26-L32
train
Karaage-Cluster/python-tldap
tldap/django/helpers.py
save_account
def save_account(changes: Changeset, table: LdapObjectClass, database: Database) -> Changeset: """ Modify a changes to add an automatically generated uidNumber. """ d = {} settings = database.settings uid_number = changes.get_value_as_single('uidNumber') if uid_number is None: scheme = sett...
python
def save_account(changes: Changeset, table: LdapObjectClass, database: Database) -> Changeset: """ Modify a changes to add an automatically generated uidNumber. """ d = {} settings = database.settings uid_number = changes.get_value_as_single('uidNumber') if uid_number is None: scheme = sett...
[ "def", "save_account", "(", "changes", ":", "Changeset", ",", "table", ":", "LdapObjectClass", ",", "database", ":", "Database", ")", "->", "Changeset", ":", "d", "=", "{", "}", "settings", "=", "database", ".", "settings", "uid_number", "=", "changes", "....
Modify a changes to add an automatically generated uidNumber.
[ "Modify", "a", "changes", "to", "add", "an", "automatically", "generated", "uidNumber", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/django/helpers.py#L35-L50
train
aroberge/experimental
experimental/transformers/switch_statement.py
transform_source
def transform_source(text): '''Replaces instances of switch expression: by for __case in _Switch(n): and replaces case expression: by if __case(expression): and default: by if __case(): ''' toks = tokenize.generate_tokens(StringIO...
python
def transform_source(text): '''Replaces instances of switch expression: by for __case in _Switch(n): and replaces case expression: by if __case(expression): and default: by if __case(): ''' toks = tokenize.generate_tokens(StringIO...
[ "def", "transform_source", "(", "text", ")", ":", "toks", "=", "tokenize", ".", "generate_tokens", "(", "StringIO", "(", "text", ")", ".", "readline", ")", "result", "=", "[", "]", "replacing_keyword", "=", "False", "for", "toktype", ",", "tokvalue", ",", ...
Replaces instances of switch expression: by for __case in _Switch(n): and replaces case expression: by if __case(expression): and default: by if __case():
[ "Replaces", "instances", "of" ]
031a9be10698b429998436da748b8fdb86f18b47
https://github.com/aroberge/experimental/blob/031a9be10698b429998436da748b8fdb86f18b47/experimental/transformers/switch_statement.py#L73-L125
train
Karaage-Cluster/python-tldap
tldap/backend/base.py
LdapBase.search
def search(self, base, scope, filterstr='(objectClass=*)', attrlist=None, limit=None) -> Generator[Tuple[str, dict], None, None]: """ Search for entries in LDAP database. """ _debug("search", base, scope, filterstr, attrlist, limit) # first results if att...
python
def search(self, base, scope, filterstr='(objectClass=*)', attrlist=None, limit=None) -> Generator[Tuple[str, dict], None, None]: """ Search for entries in LDAP database. """ _debug("search", base, scope, filterstr, attrlist, limit) # first results if att...
[ "def", "search", "(", "self", ",", "base", ",", "scope", ",", "filterstr", "=", "'(objectClass=*)'", ",", "attrlist", "=", "None", ",", "limit", "=", "None", ")", "->", "Generator", "[", "Tuple", "[", "str", ",", "dict", "]", ",", "None", ",", "None"...
Search for entries in LDAP database.
[ "Search", "for", "entries", "in", "LDAP", "database", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/base.py#L155-L192
train
Karaage-Cluster/python-tldap
tldap/backend/base.py
LdapBase.rename
def rename(self, dn: str, new_rdn: str, new_base_dn: Optional[str] = None) -> None: """ rename a dn in the ldap database; see ldap module. doesn't return a result if transactions enabled. """ raise NotImplementedError()
python
def rename(self, dn: str, new_rdn: str, new_base_dn: Optional[str] = None) -> None: """ rename a dn in the ldap database; see ldap module. doesn't return a result if transactions enabled. """ raise NotImplementedError()
[ "def", "rename", "(", "self", ",", "dn", ":", "str", ",", "new_rdn", ":", "str", ",", "new_base_dn", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "None", ":", "raise", "NotImplementedError", "(", ")" ]
rename a dn in the ldap database; see ldap module. doesn't return a result if transactions enabled.
[ "rename", "a", "dn", "in", "the", "ldap", "database", ";", "see", "ldap", "module", ".", "doesn", "t", "return", "a", "result", "if", "transactions", "enabled", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/base.py#L277-L282
train
qubell/contrib-python-qubell-client
example-hier-petclinic.py
prepare_env
def prepare_env(org): """ Example shows how to configure environment from scratch """ # Add services key_service = org.service(type='builtin:cobalt_secure_store', name='Keystore') wf_service = org.service(type='builtin:workflow_service', name='Workflow', parameters='{}') # Add services to environm...
python
def prepare_env(org): """ Example shows how to configure environment from scratch """ # Add services key_service = org.service(type='builtin:cobalt_secure_store', name='Keystore') wf_service = org.service(type='builtin:workflow_service', name='Workflow', parameters='{}') # Add services to environm...
[ "def", "prepare_env", "(", "org", ")", ":", "# Add services", "key_service", "=", "org", ".", "service", "(", "type", "=", "'builtin:cobalt_secure_store'", ",", "name", "=", "'Keystore'", ")", "wf_service", "=", "org", ".", "service", "(", "type", "=", "'bui...
Example shows how to configure environment from scratch
[ "Example", "shows", "how", "to", "configure", "environment", "from", "scratch" ]
4586ea11d5103c2ff9607d3ed922b5a0991b8845
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/example-hier-petclinic.py#L40-L70
train
quantmind/agile-toolkit
agiletoolkit/commands.py
start
def start(ctx, debug, version, config): """Commands for devops operations""" ctx.obj = {} ctx.DEBUG = debug if os.path.isfile(config): with open(config) as fp: agile = json.load(fp) else: agile = {} ctx.obj['agile'] = agile if version: click.echo(__version...
python
def start(ctx, debug, version, config): """Commands for devops operations""" ctx.obj = {} ctx.DEBUG = debug if os.path.isfile(config): with open(config) as fp: agile = json.load(fp) else: agile = {} ctx.obj['agile'] = agile if version: click.echo(__version...
[ "def", "start", "(", "ctx", ",", "debug", ",", "version", ",", "config", ")", ":", "ctx", ".", "obj", "=", "{", "}", "ctx", ".", "DEBUG", "=", "debug", "if", "os", ".", "path", ".", "isfile", "(", "config", ")", ":", "with", "open", "(", "confi...
Commands for devops operations
[ "Commands", "for", "devops", "operations" ]
96028e36a842c57b171907c20583a60d1045fec1
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/commands.py#L36-L50
train
developersociety/django-glitter
glitter/utils.py
duplicate
def duplicate(obj, value=None, field=None, duplicate_order=None): """ Duplicate all related objects of obj setting field to value. If one of the duplicate objects has an FK to another duplicate object update that as well. Return the duplicate copy of obj. duplicate_order is a list of models...
python
def duplicate(obj, value=None, field=None, duplicate_order=None): """ Duplicate all related objects of obj setting field to value. If one of the duplicate objects has an FK to another duplicate object update that as well. Return the duplicate copy of obj. duplicate_order is a list of models...
[ "def", "duplicate", "(", "obj", ",", "value", "=", "None", ",", "field", "=", "None", ",", "duplicate_order", "=", "None", ")", ":", "using", "=", "router", ".", "db_for_write", "(", "obj", ".", "_meta", ".", "model", ")", "collector", "=", "CloneColle...
Duplicate all related objects of obj setting field to value. If one of the duplicate objects has an FK to another duplicate object update that as well. Return the duplicate copy of obj. duplicate_order is a list of models which specify how the duplicate objects are saved. For complex objects ...
[ "Duplicate", "all", "related", "objects", "of", "obj", "setting", "field", "to", "value", ".", "If", "one", "of", "the", "duplicate", "objects", "has", "an", "FK", "to", "another", "duplicate", "object", "update", "that", "as", "well", ".", "Return", "the"...
2c0280ec83afee80deee94ee3934fc54239c2e87
https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/utils.py#L42-L98
train
davidblaisonneau-orange/foreman
foreman/subItemPuppetClasses.py
SubItemPuppetClasses.getPayloadStruct
def getPayloadStruct(self, attributes, objType): """ Function getPayloadStruct Get the payload structure to do a creation or a modification @param attribute: The data @param objType: SubItem type (e.g: hostgroup for hostgroup_class) @return RETURN: the payload """ ...
python
def getPayloadStruct(self, attributes, objType): """ Function getPayloadStruct Get the payload structure to do a creation or a modification @param attribute: The data @param objType: SubItem type (e.g: hostgroup for hostgroup_class) @return RETURN: the payload """ ...
[ "def", "getPayloadStruct", "(", "self", ",", "attributes", ",", "objType", ")", ":", "payload", "=", "{", "self", ".", "payloadObj", ":", "attributes", ",", "objType", "+", "\"_class\"", ":", "{", "self", ".", "payloadObj", ":", "attributes", "}", "}", "...
Function getPayloadStruct Get the payload structure to do a creation or a modification @param attribute: The data @param objType: SubItem type (e.g: hostgroup for hostgroup_class) @return RETURN: the payload
[ "Function", "getPayloadStruct", "Get", "the", "payload", "structure", "to", "do", "a", "creation", "or", "a", "modification" ]
acb8fd8d74657cfac3b25c82e9c6028b93eb6c92
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/subItemPuppetClasses.py#L34-L45
train
developersociety/django-glitter
glitter/blocks/video/validators.py
validate_url
def validate_url(value): """ Validate url. """ if not re.match(VIMEO_URL_RE, value) and not re.match(YOUTUBE_URL_RE, value): raise ValidationError('Invalid URL - only Youtube, Vimeo can be used.')
python
def validate_url(value): """ Validate url. """ if not re.match(VIMEO_URL_RE, value) and not re.match(YOUTUBE_URL_RE, value): raise ValidationError('Invalid URL - only Youtube, Vimeo can be used.')
[ "def", "validate_url", "(", "value", ")", ":", "if", "not", "re", ".", "match", "(", "VIMEO_URL_RE", ",", "value", ")", "and", "not", "re", ".", "match", "(", "YOUTUBE_URL_RE", ",", "value", ")", ":", "raise", "ValidationError", "(", "'Invalid URL - only Y...
Validate url.
[ "Validate", "url", "." ]
2c0280ec83afee80deee94ee3934fc54239c2e87
https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/blocks/video/validators.py#L45-L48
train
Karaage-Cluster/python-tldap
tldap/transaction.py
enter_transaction_management
def enter_transaction_management(using=None): """ Enters transaction management for a running thread. It must be balanced with the appropriate leave_transaction_management call, since the actual state is managed as a stack. The state and dirty flag are carried over from the surrounding block or ...
python
def enter_transaction_management(using=None): """ Enters transaction management for a running thread. It must be balanced with the appropriate leave_transaction_management call, since the actual state is managed as a stack. The state and dirty flag are carried over from the surrounding block or ...
[ "def", "enter_transaction_management", "(", "using", "=", "None", ")", ":", "if", "using", "is", "None", ":", "for", "using", "in", "tldap", ".", "backend", ".", "connections", ":", "connection", "=", "tldap", ".", "backend", ".", "connections", "[", "usin...
Enters transaction management for a running thread. It must be balanced with the appropriate leave_transaction_management call, since the actual state is managed as a stack. The state and dirty flag are carried over from the surrounding block or from the settings, if there is no surrounding block (dirt...
[ "Enters", "transaction", "management", "for", "a", "running", "thread", ".", "It", "must", "be", "balanced", "with", "the", "appropriate", "leave_transaction_management", "call", "since", "the", "actual", "state", "is", "managed", "as", "a", "stack", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/transaction.py#L45-L61
train
Karaage-Cluster/python-tldap
tldap/transaction.py
leave_transaction_management
def leave_transaction_management(using=None): """ Leaves transaction management for a running thread. A dirty flag is carried over to the surrounding block, as a commit will commit all changes, even those from outside. (Commits are on connection level.) """ if using is None: for using in...
python
def leave_transaction_management(using=None): """ Leaves transaction management for a running thread. A dirty flag is carried over to the surrounding block, as a commit will commit all changes, even those from outside. (Commits are on connection level.) """ if using is None: for using in...
[ "def", "leave_transaction_management", "(", "using", "=", "None", ")", ":", "if", "using", "is", "None", ":", "for", "using", "in", "tldap", ".", "backend", ".", "connections", ":", "connection", "=", "tldap", ".", "backend", ".", "connections", "[", "usin...
Leaves transaction management for a running thread. A dirty flag is carried over to the surrounding block, as a commit will commit all changes, even those from outside. (Commits are on connection level.)
[ "Leaves", "transaction", "management", "for", "a", "running", "thread", ".", "A", "dirty", "flag", "is", "carried", "over", "to", "the", "surrounding", "block", "as", "a", "commit", "will", "commit", "all", "changes", "even", "those", "from", "outside", ".",...
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/transaction.py#L64-L76
train
Karaage-Cluster/python-tldap
tldap/transaction.py
is_dirty
def is_dirty(using=None): """ Returns True if the current transaction requires a commit for changes to happen. """ if using is None: dirty = False for using in tldap.backend.connections: connection = tldap.backend.connections[using] if connection.is_dirty(): ...
python
def is_dirty(using=None): """ Returns True if the current transaction requires a commit for changes to happen. """ if using is None: dirty = False for using in tldap.backend.connections: connection = tldap.backend.connections[using] if connection.is_dirty(): ...
[ "def", "is_dirty", "(", "using", "=", "None", ")", ":", "if", "using", "is", "None", ":", "dirty", "=", "False", "for", "using", "in", "tldap", ".", "backend", ".", "connections", ":", "connection", "=", "tldap", ".", "backend", ".", "connections", "["...
Returns True if the current transaction requires a commit for changes to happen.
[ "Returns", "True", "if", "the", "current", "transaction", "requires", "a", "commit", "for", "changes", "to", "happen", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/transaction.py#L79-L92
train
Karaage-Cluster/python-tldap
tldap/transaction.py
is_managed
def is_managed(using=None): """ Checks whether the transaction manager is in manual or in auto state. """ if using is None: managed = False for using in tldap.backend.connections: connection = tldap.backend.connections[using] if connection.is_managed(): ...
python
def is_managed(using=None): """ Checks whether the transaction manager is in manual or in auto state. """ if using is None: managed = False for using in tldap.backend.connections: connection = tldap.backend.connections[using] if connection.is_managed(): ...
[ "def", "is_managed", "(", "using", "=", "None", ")", ":", "if", "using", "is", "None", ":", "managed", "=", "False", "for", "using", "in", "tldap", ".", "backend", ".", "connections", ":", "connection", "=", "tldap", ".", "backend", ".", "connections", ...
Checks whether the transaction manager is in manual or in auto state.
[ "Checks", "whether", "the", "transaction", "manager", "is", "in", "manual", "or", "in", "auto", "state", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/transaction.py#L95-L107
train
Karaage-Cluster/python-tldap
tldap/transaction.py
commit
def commit(using=None): """ Does the commit itself and resets the dirty flag. """ if using is None: for using in tldap.backend.connections: connection = tldap.backend.connections[using] connection.commit() return connection = tldap.backend.connections[using] ...
python
def commit(using=None): """ Does the commit itself and resets the dirty flag. """ if using is None: for using in tldap.backend.connections: connection = tldap.backend.connections[using] connection.commit() return connection = tldap.backend.connections[using] ...
[ "def", "commit", "(", "using", "=", "None", ")", ":", "if", "using", "is", "None", ":", "for", "using", "in", "tldap", ".", "backend", ".", "connections", ":", "connection", "=", "tldap", ".", "backend", ".", "connections", "[", "using", "]", "connecti...
Does the commit itself and resets the dirty flag.
[ "Does", "the", "commit", "itself", "and", "resets", "the", "dirty", "flag", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/transaction.py#L110-L120
train
Karaage-Cluster/python-tldap
tldap/transaction.py
rollback
def rollback(using=None): """ This function does the rollback itself and resets the dirty flag. """ if using is None: for using in tldap.backend.connections: connection = tldap.backend.connections[using] connection.rollback() return connection = tldap.backend....
python
def rollback(using=None): """ This function does the rollback itself and resets the dirty flag. """ if using is None: for using in tldap.backend.connections: connection = tldap.backend.connections[using] connection.rollback() return connection = tldap.backend....
[ "def", "rollback", "(", "using", "=", "None", ")", ":", "if", "using", "is", "None", ":", "for", "using", "in", "tldap", ".", "backend", ".", "connections", ":", "connection", "=", "tldap", ".", "backend", ".", "connections", "[", "using", "]", "connec...
This function does the rollback itself and resets the dirty flag.
[ "This", "function", "does", "the", "rollback", "itself", "and", "resets", "the", "dirty", "flag", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/transaction.py#L123-L133
train
Karaage-Cluster/python-tldap
tldap/transaction.py
_transaction_func
def _transaction_func(entering, exiting, using): """ Takes 3 things, an entering function (what to do to start this block of transaction management), an exiting function (what to do to end it, on both success and failure, and using which can be: None, indiciating transaction should occur on all defi...
python
def _transaction_func(entering, exiting, using): """ Takes 3 things, an entering function (what to do to start this block of transaction management), an exiting function (what to do to end it, on both success and failure, and using which can be: None, indiciating transaction should occur on all defi...
[ "def", "_transaction_func", "(", "entering", ",", "exiting", ",", "using", ")", ":", "# Note that although the first argument is *called* `using`, it", "# may actually be a function; @autocommit and @autocommit('foo')", "# are both allowed forms.", "if", "callable", "(", "using", "...
Takes 3 things, an entering function (what to do to start this block of transaction management), an exiting function (what to do to end it, on both success and failure, and using which can be: None, indiciating transaction should occur on all defined servers, or a callable, indicating that using is None...
[ "Takes", "3", "things", "an", "entering", "function", "(", "what", "to", "do", "to", "start", "this", "block", "of", "transaction", "management", ")", "an", "exiting", "function", "(", "what", "to", "do", "to", "end", "it", "on", "both", "success", "and"...
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/transaction.py#L179-L195
train
Karaage-Cluster/python-tldap
tldap/transaction.py
commit_on_success
def commit_on_success(using=None): """ This decorator activates commit on response. This way, if the view function runs successfully, a commit is made; if the viewfunc produces an exception, a rollback is made. This is one of the most common ways to do transaction control in Web apps. """ de...
python
def commit_on_success(using=None): """ This decorator activates commit on response. This way, if the view function runs successfully, a commit is made; if the viewfunc produces an exception, a rollback is made. This is one of the most common ways to do transaction control in Web apps. """ de...
[ "def", "commit_on_success", "(", "using", "=", "None", ")", ":", "def", "entering", "(", "using", ")", ":", "enter_transaction_management", "(", "using", "=", "using", ")", "def", "exiting", "(", "exc_value", ",", "using", ")", ":", "try", ":", "if", "ex...
This decorator activates commit on response. This way, if the view function runs successfully, a commit is made; if the viewfunc produces an exception, a rollback is made. This is one of the most common ways to do transaction control in Web apps.
[ "This", "decorator", "activates", "commit", "on", "response", ".", "This", "way", "if", "the", "view", "function", "runs", "successfully", "a", "commit", "is", "made", ";", "if", "the", "viewfunc", "produces", "an", "exception", "a", "rollback", "is", "made"...
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/transaction.py#L198-L218
train
Karaage-Cluster/python-tldap
tldap/transaction.py
commit_manually
def commit_manually(using=None): """ Decorator that activates manual transaction control. It just disables automatic transaction control and doesn't do any commit/rollback of its own -- it's up to the user to call the commit and rollback functions themselves. """ def entering(using): ...
python
def commit_manually(using=None): """ Decorator that activates manual transaction control. It just disables automatic transaction control and doesn't do any commit/rollback of its own -- it's up to the user to call the commit and rollback functions themselves. """ def entering(using): ...
[ "def", "commit_manually", "(", "using", "=", "None", ")", ":", "def", "entering", "(", "using", ")", ":", "enter_transaction_management", "(", "using", "=", "using", ")", "def", "exiting", "(", "exc_value", ",", "using", ")", ":", "leave_transaction_management...
Decorator that activates manual transaction control. It just disables automatic transaction control and doesn't do any commit/rollback of its own -- it's up to the user to call the commit and rollback functions themselves.
[ "Decorator", "that", "activates", "manual", "transaction", "control", ".", "It", "just", "disables", "automatic", "transaction", "control", "and", "doesn", "t", "do", "any", "commit", "/", "rollback", "of", "its", "own", "--", "it", "s", "up", "to", "the", ...
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/transaction.py#L221-L234
train
jamescooke/flake8-aaa
src/flake8_aaa/checker.py
Checker.run
def run(self) -> Generator[Tuple[int, int, str, type], None, None]: """ Yields: tuple (line_number: int, offset: int, text: str, check: type) """ if is_test_file(self.filename): self.load() for func in self.all_funcs(): try: ...
python
def run(self) -> Generator[Tuple[int, int, str, type], None, None]: """ Yields: tuple (line_number: int, offset: int, text: str, check: type) """ if is_test_file(self.filename): self.load() for func in self.all_funcs(): try: ...
[ "def", "run", "(", "self", ")", "->", "Generator", "[", "Tuple", "[", "int", ",", "int", ",", "str", ",", "type", "]", ",", "None", ",", "None", "]", ":", "if", "is_test_file", "(", "self", ".", "filename", ")", ":", "self", ".", "load", "(", "...
Yields: tuple (line_number: int, offset: int, text: str, check: type)
[ "Yields", ":", "tuple", "(", "line_number", ":", "int", "offset", ":", "int", "text", ":", "str", "check", ":", "type", ")" ]
29938b96845fe32ced4358ba66af3b3be2a37794
https://github.com/jamescooke/flake8-aaa/blob/29938b96845fe32ced4358ba66af3b3be2a37794/src/flake8_aaa/checker.py#L42-L54
train
developersociety/django-glitter
glitter/pages/middleware.py
GlitterUrlConfMiddleware.process_request
def process_request(self, request): """ Reloads glitter URL patterns if page URLs change. Avoids having to restart the server to recreate the glitter URLs being used by Django. """ global _urlconf_pages page_list = list( Page.objects.exclude(glitter_app_name...
python
def process_request(self, request): """ Reloads glitter URL patterns if page URLs change. Avoids having to restart the server to recreate the glitter URLs being used by Django. """ global _urlconf_pages page_list = list( Page.objects.exclude(glitter_app_name...
[ "def", "process_request", "(", "self", ",", "request", ")", ":", "global", "_urlconf_pages", "page_list", "=", "list", "(", "Page", ".", "objects", ".", "exclude", "(", "glitter_app_name", "=", "''", ")", ".", "values_list", "(", "'id'", ",", "'url'", ")",...
Reloads glitter URL patterns if page URLs change. Avoids having to restart the server to recreate the glitter URLs being used by Django.
[ "Reloads", "glitter", "URL", "patterns", "if", "page", "URLs", "change", "." ]
2c0280ec83afee80deee94ee3934fc54239c2e87
https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/pages/middleware.py#L38-L55
train
MatterMiners/cobald
cobald/daemon/runners/base_runner.py
BaseRunner.run
def run(self): """ Execute all current and future payloads Blocks and executes payloads until :py:meth:`stop` is called. It is an error for any orphaned payload to return or raise. """ self._logger.info('runner started: %s', self) try: with self._lock...
python
def run(self): """ Execute all current and future payloads Blocks and executes payloads until :py:meth:`stop` is called. It is an error for any orphaned payload to return or raise. """ self._logger.info('runner started: %s', self) try: with self._lock...
[ "def", "run", "(", "self", ")", ":", "self", ".", "_logger", ".", "info", "(", "'runner started: %s'", ",", "self", ")", "try", ":", "with", "self", ".", "_lock", ":", "assert", "not", "self", ".", "running", ".", "is_set", "(", ")", "and", "self", ...
Execute all current and future payloads Blocks and executes payloads until :py:meth:`stop` is called. It is an error for any orphaned payload to return or raise.
[ "Execute", "all", "current", "and", "future", "payloads" ]
264138de4382d1c9b53fabcbc6660e10b33a914d
https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/runners/base_runner.py#L45-L67
train
MatterMiners/cobald
cobald/daemon/runners/base_runner.py
BaseRunner.stop
def stop(self): """Stop execution of all current and future payloads""" if not self.running.wait(0.2): return self._logger.debug('runner disabled: %s', self) with self._lock: self.running.clear() self._stopped.wait()
python
def stop(self): """Stop execution of all current and future payloads""" if not self.running.wait(0.2): return self._logger.debug('runner disabled: %s', self) with self._lock: self.running.clear() self._stopped.wait()
[ "def", "stop", "(", "self", ")", ":", "if", "not", "self", ".", "running", ".", "wait", "(", "0.2", ")", ":", "return", "self", ".", "_logger", ".", "debug", "(", "'runner disabled: %s'", ",", "self", ")", "with", "self", ".", "_lock", ":", "self", ...
Stop execution of all current and future payloads
[ "Stop", "execution", "of", "all", "current", "and", "future", "payloads" ]
264138de4382d1c9b53fabcbc6660e10b33a914d
https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/runners/base_runner.py#L72-L79
train
josiah-wolf-oberholtzer/uqbar
uqbar/strings.py
delimit_words
def delimit_words(string: str) -> Generator[str, None, None]: """ Delimit a string at word boundaries. :: >>> import uqbar.strings >>> list(uqbar.strings.delimit_words("i want to believe")) ['i', 'want', 'to', 'believe'] :: >>> list(uqbar.strings.delimit_words("S3Buck...
python
def delimit_words(string: str) -> Generator[str, None, None]: """ Delimit a string at word boundaries. :: >>> import uqbar.strings >>> list(uqbar.strings.delimit_words("i want to believe")) ['i', 'want', 'to', 'believe'] :: >>> list(uqbar.strings.delimit_words("S3Buck...
[ "def", "delimit_words", "(", "string", ":", "str", ")", "->", "Generator", "[", "str", ",", "None", ",", "None", "]", ":", "# TODO: Reimplement this", "wordlike_characters", "=", "(", "\"<\"", ",", "\">\"", ",", "\"!\"", ")", "current_word", "=", "\"\"", "...
Delimit a string at word boundaries. :: >>> import uqbar.strings >>> list(uqbar.strings.delimit_words("i want to believe")) ['i', 'want', 'to', 'believe'] :: >>> list(uqbar.strings.delimit_words("S3Bucket")) ['S3', 'Bucket'] :: >>> list(uqbar.strings.del...
[ "Delimit", "a", "string", "at", "word", "boundaries", "." ]
eca7fefebbbee1e2ae13bf5d6baa838be66b1db6
https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/strings.py#L18-L78
train
josiah-wolf-oberholtzer/uqbar
uqbar/strings.py
normalize
def normalize(string: str) -> str: """ Normalizes whitespace. Strips leading and trailing blank lines, dedents, and removes trailing whitespace from the result. """ string = string.replace("\t", " ") lines = string.split("\n") while lines and (not lines[0] or lines[0].isspace()): ...
python
def normalize(string: str) -> str: """ Normalizes whitespace. Strips leading and trailing blank lines, dedents, and removes trailing whitespace from the result. """ string = string.replace("\t", " ") lines = string.split("\n") while lines and (not lines[0] or lines[0].isspace()): ...
[ "def", "normalize", "(", "string", ":", "str", ")", "->", "str", ":", "string", "=", "string", ".", "replace", "(", "\"\\t\"", ",", "\" \"", ")", "lines", "=", "string", ".", "split", "(", "\"\\n\"", ")", "while", "lines", "and", "(", "not", "line...
Normalizes whitespace. Strips leading and trailing blank lines, dedents, and removes trailing whitespace from the result.
[ "Normalizes", "whitespace", "." ]
eca7fefebbbee1e2ae13bf5d6baa838be66b1db6
https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/strings.py#L81-L98
train
josiah-wolf-oberholtzer/uqbar
uqbar/strings.py
to_dash_case
def to_dash_case(string: str) -> str: """ Convert a string to dash-delimited words. :: >>> import uqbar.strings >>> string = 'Tô Đặc Biệt Xe Lửa' >>> print(uqbar.strings.to_dash_case(string)) to-dac-biet-xe-lua :: >>> string = 'alpha.beta.gamma' >>> pr...
python
def to_dash_case(string: str) -> str: """ Convert a string to dash-delimited words. :: >>> import uqbar.strings >>> string = 'Tô Đặc Biệt Xe Lửa' >>> print(uqbar.strings.to_dash_case(string)) to-dac-biet-xe-lua :: >>> string = 'alpha.beta.gamma' >>> pr...
[ "def", "to_dash_case", "(", "string", ":", "str", ")", "->", "str", ":", "string", "=", "unidecode", ".", "unidecode", "(", "string", ")", "words", "=", "(", "_", ".", "lower", "(", ")", "for", "_", "in", "delimit_words", "(", "string", ")", ")", "...
Convert a string to dash-delimited words. :: >>> import uqbar.strings >>> string = 'Tô Đặc Biệt Xe Lửa' >>> print(uqbar.strings.to_dash_case(string)) to-dac-biet-xe-lua :: >>> string = 'alpha.beta.gamma' >>> print(uqbar.strings.to_dash_case(string)) al...
[ "Convert", "a", "string", "to", "dash", "-", "delimited", "words", "." ]
eca7fefebbbee1e2ae13bf5d6baa838be66b1db6
https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/strings.py#L101-L122
train
aroberge/experimental
experimental/transformers/utils/simple2to3.py
get_lib2to3_fixers
def get_lib2to3_fixers(): '''returns a list of all fixers found in the lib2to3 library''' fixers = [] fixer_dirname = fixer_dir.__path__[0] for name in sorted(os.listdir(fixer_dirname)): if name.startswith("fix_") and name.endswith(".py"): fixers.append("lib2to3.fixes." + name[:-3]) ...
python
def get_lib2to3_fixers(): '''returns a list of all fixers found in the lib2to3 library''' fixers = [] fixer_dirname = fixer_dir.__path__[0] for name in sorted(os.listdir(fixer_dirname)): if name.startswith("fix_") and name.endswith(".py"): fixers.append("lib2to3.fixes." + name[:-3]) ...
[ "def", "get_lib2to3_fixers", "(", ")", ":", "fixers", "=", "[", "]", "fixer_dirname", "=", "fixer_dir", ".", "__path__", "[", "0", "]", "for", "name", "in", "sorted", "(", "os", ".", "listdir", "(", "fixer_dirname", ")", ")", ":", "if", "name", ".", ...
returns a list of all fixers found in the lib2to3 library
[ "returns", "a", "list", "of", "all", "fixers", "found", "in", "the", "lib2to3", "library" ]
031a9be10698b429998436da748b8fdb86f18b47
https://github.com/aroberge/experimental/blob/031a9be10698b429998436da748b8fdb86f18b47/experimental/transformers/utils/simple2to3.py#L10-L17
train
aroberge/experimental
experimental/transformers/utils/simple2to3.py
get_single_fixer
def get_single_fixer(fixname): '''return a single fixer found in the lib2to3 library''' fixer_dirname = fixer_dir.__path__[0] for name in sorted(os.listdir(fixer_dirname)): if (name.startswith("fix_") and name.endswith(".py") and fixname == name[4:-3]): return "lib2to3.fixes...
python
def get_single_fixer(fixname): '''return a single fixer found in the lib2to3 library''' fixer_dirname = fixer_dir.__path__[0] for name in sorted(os.listdir(fixer_dirname)): if (name.startswith("fix_") and name.endswith(".py") and fixname == name[4:-3]): return "lib2to3.fixes...
[ "def", "get_single_fixer", "(", "fixname", ")", ":", "fixer_dirname", "=", "fixer_dir", ".", "__path__", "[", "0", "]", "for", "name", "in", "sorted", "(", "os", ".", "listdir", "(", "fixer_dirname", ")", ")", ":", "if", "(", "name", ".", "startswith", ...
return a single fixer found in the lib2to3 library
[ "return", "a", "single", "fixer", "found", "in", "the", "lib2to3", "library" ]
031a9be10698b429998436da748b8fdb86f18b47
https://github.com/aroberge/experimental/blob/031a9be10698b429998436da748b8fdb86f18b47/experimental/transformers/utils/simple2to3.py#L20-L26
train
Karaage-Cluster/python-tldap
tldap/fields.py
Field.to_db
def to_db(self, value): """ Returns field's single value prepared for saving into a database. """ # ensure value is valid self.validate(value) assert isinstance(value, list) value = list(value) for i, v in enumerate(value): value[i] = self.value_to_db(v) ...
python
def to_db(self, value): """ Returns field's single value prepared for saving into a database. """ # ensure value is valid self.validate(value) assert isinstance(value, list) value = list(value) for i, v in enumerate(value): value[i] = self.value_to_db(v) ...
[ "def", "to_db", "(", "self", ",", "value", ")", ":", "# ensure value is valid", "self", ".", "validate", "(", "value", ")", "assert", "isinstance", "(", "value", ",", "list", ")", "value", "=", "list", "(", "value", ")", "for", "i", ",", "v", "in", "...
Returns field's single value prepared for saving into a database.
[ "Returns", "field", "s", "single", "value", "prepared", "for", "saving", "into", "a", "database", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/fields.py#L42-L55
train
Karaage-Cluster/python-tldap
tldap/fields.py
Field.to_python
def to_python(self, value): """ Converts the input value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this. """ assert isinstance(value, list) ...
python
def to_python(self, value): """ Converts the input value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this. """ assert isinstance(value, list) ...
[ "def", "to_python", "(", "self", ",", "value", ")", ":", "assert", "isinstance", "(", "value", ",", "list", ")", "# convert every value in list", "value", "=", "list", "(", "value", ")", "for", "i", ",", "v", "in", "enumerate", "(", "value", ")", ":", ...
Converts the input value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this.
[ "Converts", "the", "input", "value", "into", "the", "expected", "Python", "data", "type", "raising", "django", ".", "core", ".", "exceptions", ".", "ValidationError", "if", "the", "data", "can", "t", "be", "converted", ".", "Returns", "the", "converted", "va...
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/fields.py#L57-L71
train
Karaage-Cluster/python-tldap
tldap/fields.py
Field.validate
def validate(self, value): """ Validates value and throws ValidationError. Subclasses should override this to provide validation logic. """ # check object type if not isinstance(value, list): raise tldap.exceptions.ValidationError( "is not a li...
python
def validate(self, value): """ Validates value and throws ValidationError. Subclasses should override this to provide validation logic. """ # check object type if not isinstance(value, list): raise tldap.exceptions.ValidationError( "is not a li...
[ "def", "validate", "(", "self", ",", "value", ")", ":", "# check object type", "if", "not", "isinstance", "(", "value", ",", "list", ")", ":", "raise", "tldap", ".", "exceptions", ".", "ValidationError", "(", "\"is not a list and max_instances is %s\"", "%", "se...
Validates value and throws ValidationError. Subclasses should override this to provide validation logic.
[ "Validates", "value", "and", "throws", "ValidationError", ".", "Subclasses", "should", "override", "this", "to", "provide", "validation", "logic", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/fields.py#L73-L96
train
Karaage-Cluster/python-tldap
tldap/fields.py
Field.clean
def clean(self, value): """ Convert the value's type and run validation. Validation errors from to_python and validate are propagated. The correct value is returned if no error is raised. """ value = self.to_python(value) self.validate(value) return value
python
def clean(self, value): """ Convert the value's type and run validation. Validation errors from to_python and validate are propagated. The correct value is returned if no error is raised. """ value = self.to_python(value) self.validate(value) return value
[ "def", "clean", "(", "self", ",", "value", ")", ":", "value", "=", "self", ".", "to_python", "(", "value", ")", "self", ".", "validate", "(", "value", ")", "return", "value" ]
Convert the value's type and run validation. Validation errors from to_python and validate are propagated. The correct value is returned if no error is raised.
[ "Convert", "the", "value", "s", "type", "and", "run", "validation", ".", "Validation", "errors", "from", "to_python", "and", "validate", "are", "propagated", ".", "The", "correct", "value", "is", "returned", "if", "no", "error", "is", "raised", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/fields.py#L98-L106
train
Karaage-Cluster/python-tldap
tldap/fields.py
CharField.value_to_db
def value_to_db(self, value): """ Returns field's single value prepared for saving into a database. """ if isinstance(value, six.string_types): value = value.encode("utf_8") return value
python
def value_to_db(self, value): """ Returns field's single value prepared for saving into a database. """ if isinstance(value, six.string_types): value = value.encode("utf_8") return value
[ "def", "value_to_db", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "six", ".", "string_types", ")", ":", "value", "=", "value", ".", "encode", "(", "\"utf_8\"", ")", "return", "value" ]
Returns field's single value prepared for saving into a database.
[ "Returns", "field", "s", "single", "value", "prepared", "for", "saving", "into", "a", "database", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/fields.py#L195-L199
train
Karaage-Cluster/python-tldap
tldap/fields.py
CharField.value_to_python
def value_to_python(self, value): """ Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this. """ if not isins...
python
def value_to_python(self, value): """ Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this. """ if not isins...
[ "def", "value_to_python", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "bytes", ")", ":", "raise", "tldap", ".", "exceptions", ".", "ValidationError", "(", "\"should be a bytes\"", ")", "value", "=", "value", ".", "dec...
Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this.
[ "Converts", "the", "input", "single", "value", "into", "the", "expected", "Python", "data", "type", "raising", "django", ".", "core", ".", "exceptions", ".", "ValidationError", "if", "the", "data", "can", "t", "be", "converted", ".", "Returns", "the", "conve...
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/fields.py#L201-L211
train
Karaage-Cluster/python-tldap
tldap/fields.py
CharField.value_validate
def value_validate(self, value): """ Validates value and throws ValidationError. Subclasses should override this to provide validation logic. """ if not isinstance(value, six.string_types): raise tldap.exceptions.ValidationError("should be a string")
python
def value_validate(self, value): """ Validates value and throws ValidationError. Subclasses should override this to provide validation logic. """ if not isinstance(value, six.string_types): raise tldap.exceptions.ValidationError("should be a string")
[ "def", "value_validate", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "six", ".", "string_types", ")", ":", "raise", "tldap", ".", "exceptions", ".", "ValidationError", "(", "\"should be a string\"", ")" ]
Validates value and throws ValidationError. Subclasses should override this to provide validation logic.
[ "Validates", "value", "and", "throws", "ValidationError", ".", "Subclasses", "should", "override", "this", "to", "provide", "validation", "logic", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/fields.py#L213-L219
train
Karaage-Cluster/python-tldap
tldap/fields.py
IntegerField.value_to_python
def value_to_python(self, value): """ Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this. """ if not isins...
python
def value_to_python(self, value): """ Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this. """ if not isins...
[ "def", "value_to_python", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "bytes", ")", ":", "raise", "tldap", ".", "exceptions", ".", "ValidationError", "(", "\"should be bytes\"", ")", "if", "value", "is", "None", ":", ...
Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this.
[ "Converts", "the", "input", "single", "value", "into", "the", "expected", "Python", "data", "type", "raising", "django", ".", "core", ".", "exceptions", ".", "ValidationError", "if", "the", "data", "can", "t", "be", "converted", ".", "Returns", "the", "conve...
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/fields.py#L254-L268
train
Karaage-Cluster/python-tldap
tldap/fields.py
IntegerField.value_to_db
def value_to_db(self, value): """ Returns field's single value prepared for saving into a database. """ assert isinstance(value, six.integer_types) return str(value).encode("utf_8")
python
def value_to_db(self, value): """ Returns field's single value prepared for saving into a database. """ assert isinstance(value, six.integer_types) return str(value).encode("utf_8")
[ "def", "value_to_db", "(", "self", ",", "value", ")", ":", "assert", "isinstance", "(", "value", ",", "six", ".", "integer_types", ")", "return", "str", "(", "value", ")", ".", "encode", "(", "\"utf_8\"", ")" ]
Returns field's single value prepared for saving into a database.
[ "Returns", "field", "s", "single", "value", "prepared", "for", "saving", "into", "a", "database", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/fields.py#L270-L273
train
Karaage-Cluster/python-tldap
tldap/fields.py
IntegerField.value_validate
def value_validate(self, value): """ Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this. """ if not isinst...
python
def value_validate(self, value): """ Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this. """ if not isinst...
[ "def", "value_validate", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "six", ".", "integer_types", ")", ":", "raise", "tldap", ".", "exceptions", ".", "ValidationError", "(", "\"should be a integer\"", ")", "try", ":", ...
Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this.
[ "Converts", "the", "input", "single", "value", "into", "the", "expected", "Python", "data", "type", "raising", "django", ".", "core", ".", "exceptions", ".", "ValidationError", "if", "the", "data", "can", "t", "be", "converted", ".", "Returns", "the", "conve...
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/fields.py#L275-L288
train
Karaage-Cluster/python-tldap
tldap/fields.py
DaysSinceEpochField.value_to_python
def value_to_python(self, value): """ Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this. """ if not isins...
python
def value_to_python(self, value): """ Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this. """ if not isins...
[ "def", "value_to_python", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "bytes", ")", ":", "raise", "tldap", ".", "exceptions", ".", "ValidationError", "(", "\"should be a bytes\"", ")", "try", ":", "value", "=", "int",...
Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this.
[ "Converts", "the", "input", "single", "value", "into", "the", "expected", "Python", "data", "type", "raising", "django", ".", "core", ".", "exceptions", ".", "ValidationError", "if", "the", "data", "can", "t", "be", "converted", ".", "Returns", "the", "conve...
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/fields.py#L294-L314
train
Karaage-Cluster/python-tldap
tldap/fields.py
DaysSinceEpochField.value_to_db
def value_to_db(self, value): """ Returns field's single value prepared for saving into a database. """ assert isinstance(value, datetime.date) assert not isinstance(value, datetime.datetime) try: value = value - datetime.date(year=1970, month=1, day=1) except Overfl...
python
def value_to_db(self, value): """ Returns field's single value prepared for saving into a database. """ assert isinstance(value, datetime.date) assert not isinstance(value, datetime.datetime) try: value = value - datetime.date(year=1970, month=1, day=1) except Overfl...
[ "def", "value_to_db", "(", "self", ",", "value", ")", ":", "assert", "isinstance", "(", "value", ",", "datetime", ".", "date", ")", "assert", "not", "isinstance", "(", "value", ",", "datetime", ".", "datetime", ")", "try", ":", "value", "=", "value", "...
Returns field's single value prepared for saving into a database.
[ "Returns", "field", "s", "single", "value", "prepared", "for", "saving", "into", "a", "database", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/fields.py#L316-L326
train
Karaage-Cluster/python-tldap
tldap/fields.py
DaysSinceEpochField.value_validate
def value_validate(self, value): """ Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this. """ if not isinst...
python
def value_validate(self, value): """ Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this. """ if not isinst...
[ "def", "value_validate", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "datetime", ".", "date", ")", ":", "raise", "tldap", ".", "exceptions", ".", "ValidationError", "(", "\"is invalid date\"", ")", "# a datetime is also a...
Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this.
[ "Converts", "the", "input", "single", "value", "into", "the", "expected", "Python", "data", "type", "raising", "django", ".", "core", ".", "exceptions", ".", "ValidationError", "if", "the", "data", "can", "t", "be", "converted", ".", "Returns", "the", "conve...
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/fields.py#L328-L339
train
Karaage-Cluster/python-tldap
tldap/fields.py
SecondsSinceEpochField.value_to_db
def value_to_db(self, value): """ Returns field's single value prepared for saving into a database. """ assert isinstance(value, datetime.datetime) try: value = value - datetime.datetime(1970, 1, 1) except OverflowError: raise tldap.exceptions.ValidationError("is...
python
def value_to_db(self, value): """ Returns field's single value prepared for saving into a database. """ assert isinstance(value, datetime.datetime) try: value = value - datetime.datetime(1970, 1, 1) except OverflowError: raise tldap.exceptions.ValidationError("is...
[ "def", "value_to_db", "(", "self", ",", "value", ")", ":", "assert", "isinstance", "(", "value", ",", "datetime", ".", "datetime", ")", "try", ":", "value", "=", "value", "-", "datetime", ".", "datetime", "(", "1970", ",", "1", ",", "1", ")", "except...
Returns field's single value prepared for saving into a database.
[ "Returns", "field", "s", "single", "value", "prepared", "for", "saving", "into", "a", "database", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/fields.py#L367-L379
train
Karaage-Cluster/python-tldap
tldap/fields.py
SecondsSinceEpochField.value_validate
def value_validate(self, value): """ Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this. """ if not isinst...
python
def value_validate(self, value): """ Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this. """ if not isinst...
[ "def", "value_validate", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "datetime", ".", "datetime", ")", ":", "raise", "tldap", ".", "exceptions", ".", "ValidationError", "(", "\"is invalid date time\"", ")" ]
Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this.
[ "Converts", "the", "input", "single", "value", "into", "the", "expected", "Python", "data", "type", "raising", "django", ".", "core", ".", "exceptions", ".", "ValidationError", "if", "the", "data", "can", "t", "be", "converted", ".", "Returns", "the", "conve...
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/fields.py#L381-L389
train
Karaage-Cluster/python-tldap
tldap/fields.py
SidField.value_to_python
def value_to_python(self, value): """ Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this. """ if not isins...
python
def value_to_python(self, value): """ Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this. """ if not isins...
[ "def", "value_to_python", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "bytes", ")", ":", "raise", "tldap", ".", "exceptions", ".", "ValidationError", "(", "\"should be a bytes\"", ")", "length", "=", "len", "(", "valu...
Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this.
[ "Converts", "the", "input", "single", "value", "into", "the", "expected", "Python", "data", "type", "raising", "django", ".", "core", ".", "exceptions", ".", "ValidationError", "if", "the", "data", "can", "t", "be", "converted", ".", "Returns", "the", "conve...
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/fields.py#L395-L420
train
Karaage-Cluster/python-tldap
tldap/fields.py
SidField.value_to_db
def value_to_db(self, value): """ Returns field's single value prepared for saving into a database. """ assert isinstance(value, str) array = value.split("-") length = len(array) - 3 assert length >= 0 assert array[0] == 'S' array = array[1:2] + [length, 0, 0,...
python
def value_to_db(self, value): """ Returns field's single value prepared for saving into a database. """ assert isinstance(value, str) array = value.split("-") length = len(array) - 3 assert length >= 0 assert array[0] == 'S' array = array[1:2] + [length, 0, 0,...
[ "def", "value_to_db", "(", "self", ",", "value", ")", ":", "assert", "isinstance", "(", "value", ",", "str", ")", "array", "=", "value", ".", "split", "(", "\"-\"", ")", "length", "=", "len", "(", "array", ")", "-", "3", "assert", "length", ">=", "...
Returns field's single value prepared for saving into a database.
[ "Returns", "field", "s", "single", "value", "prepared", "for", "saving", "into", "a", "database", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/fields.py#L422-L436
train
Karaage-Cluster/python-tldap
tldap/fields.py
SidField.value_validate
def value_validate(self, value): """ Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this. """ if not isinst...
python
def value_validate(self, value): """ Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this. """ if not isinst...
[ "def", "value_validate", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "str", ")", ":", "raise", "tldap", ".", "exceptions", ".", "ValidationError", "(", "\"Invalid sid\"", ")", "array", "=", "value", ".", "split", "(...
Converts the input single value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this.
[ "Converts", "the", "input", "single", "value", "into", "the", "expected", "Python", "data", "type", "raising", "django", ".", "core", ".", "exceptions", ".", "ValidationError", "if", "the", "data", "can", "t", "be", "converted", ".", "Returns", "the", "conve...
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/fields.py#L438-L460
train
quantmind/agile-toolkit
agiletoolkit/api/components.py
RepoComponents.get
def get(self, id): """Get data for this component """ id = self.as_id(id) url = '%s/%s' % (self, id) response = self.http.get(url, auth=self.auth) response.raise_for_status() return response.json()
python
def get(self, id): """Get data for this component """ id = self.as_id(id) url = '%s/%s' % (self, id) response = self.http.get(url, auth=self.auth) response.raise_for_status() return response.json()
[ "def", "get", "(", "self", ",", "id", ")", ":", "id", "=", "self", ".", "as_id", "(", "id", ")", "url", "=", "'%s/%s'", "%", "(", "self", ",", "id", ")", "response", "=", "self", ".", "http", ".", "get", "(", "url", ",", "auth", "=", "self", ...
Get data for this component
[ "Get", "data", "for", "this", "component" ]
96028e36a842c57b171907c20583a60d1045fec1
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/api/components.py#L38-L45
train
quantmind/agile-toolkit
agiletoolkit/api/components.py
RepoComponents.create
def create(self, data): """Create a new component """ response = self.http.post(str(self), json=data, auth=self.auth) response.raise_for_status() return response.json()
python
def create(self, data): """Create a new component """ response = self.http.post(str(self), json=data, auth=self.auth) response.raise_for_status() return response.json()
[ "def", "create", "(", "self", ",", "data", ")", ":", "response", "=", "self", ".", "http", ".", "post", "(", "str", "(", "self", ")", ",", "json", "=", "data", ",", "auth", "=", "self", ".", "auth", ")", "response", ".", "raise_for_status", "(", ...
Create a new component
[ "Create", "a", "new", "component" ]
96028e36a842c57b171907c20583a60d1045fec1
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/api/components.py#L47-L52
train
quantmind/agile-toolkit
agiletoolkit/api/components.py
RepoComponents.update
def update(self, id, data): """Update a component """ id = self.as_id(id) response = self.http.patch( '%s/%s' % (self, id), json=data, auth=self.auth ) response.raise_for_status() return response.json()
python
def update(self, id, data): """Update a component """ id = self.as_id(id) response = self.http.patch( '%s/%s' % (self, id), json=data, auth=self.auth ) response.raise_for_status() return response.json()
[ "def", "update", "(", "self", ",", "id", ",", "data", ")", ":", "id", "=", "self", ".", "as_id", "(", "id", ")", "response", "=", "self", ".", "http", ".", "patch", "(", "'%s/%s'", "%", "(", "self", ",", "id", ")", ",", "json", "=", "data", "...
Update a component
[ "Update", "a", "component" ]
96028e36a842c57b171907c20583a60d1045fec1
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/api/components.py#L54-L62
train
quantmind/agile-toolkit
agiletoolkit/api/components.py
RepoComponents.delete
def delete(self, id): """Delete a component by id """ id = self.as_id(id) response = self.http.delete( '%s/%s' % (self.api_url, id), auth=self.auth) response.raise_for_status()
python
def delete(self, id): """Delete a component by id """ id = self.as_id(id) response = self.http.delete( '%s/%s' % (self.api_url, id), auth=self.auth) response.raise_for_status()
[ "def", "delete", "(", "self", ",", "id", ")", ":", "id", "=", "self", ".", "as_id", "(", "id", ")", "response", "=", "self", ".", "http", ".", "delete", "(", "'%s/%s'", "%", "(", "self", ".", "api_url", ",", "id", ")", ",", "auth", "=", "self",...
Delete a component by id
[ "Delete", "a", "component", "by", "id" ]
96028e36a842c57b171907c20583a60d1045fec1
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/api/components.py#L64-L71
train
quantmind/agile-toolkit
agiletoolkit/api/components.py
RepoComponents.get_list
def get_list(self, url=None, callback=None, limit=100, **data): """Get a list of this github component :param url: full url :param Comp: a :class:`.Component` class :param callback: Optional callback :param limit: Optional number of items to retrieve :param data: addition...
python
def get_list(self, url=None, callback=None, limit=100, **data): """Get a list of this github component :param url: full url :param Comp: a :class:`.Component` class :param callback: Optional callback :param limit: Optional number of items to retrieve :param data: addition...
[ "def", "get_list", "(", "self", ",", "url", "=", "None", ",", "callback", "=", "None", ",", "limit", "=", "100", ",", "*", "*", "data", ")", ":", "url", "=", "url", "or", "str", "(", "self", ")", "data", "=", "dict", "(", "(", "(", "k", ",", ...
Get a list of this github component :param url: full url :param Comp: a :class:`.Component` class :param callback: Optional callback :param limit: Optional number of items to retrieve :param data: additional query data :return: a list of ``Comp`` objects with data
[ "Get", "a", "list", "of", "this", "github", "component", ":", "param", "url", ":", "full", "url", ":", "param", "Comp", ":", "a", ":", "class", ":", ".", "Component", "class", ":", "param", "callback", ":", "Optional", "callback", ":", "param", "limit"...
96028e36a842c57b171907c20583a60d1045fec1
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/api/components.py#L73-L105
train
quantmind/agile-toolkit
agiletoolkit/api/components.py
Issues.comments
def comments(self, issue): """Return all comments for this issue/pull request """ commit = self.as_id(issue) return self.get_list(url='%s/%s/comments' % (self, commit))
python
def comments(self, issue): """Return all comments for this issue/pull request """ commit = self.as_id(issue) return self.get_list(url='%s/%s/comments' % (self, commit))
[ "def", "comments", "(", "self", ",", "issue", ")", ":", "commit", "=", "self", ".", "as_id", "(", "issue", ")", "return", "self", ".", "get_list", "(", "url", "=", "'%s/%s/comments'", "%", "(", "self", ",", "commit", ")", ")" ]
Return all comments for this issue/pull request
[ "Return", "all", "comments", "for", "this", "issue", "/", "pull", "request" ]
96028e36a842c57b171907c20583a60d1045fec1
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/api/components.py#L139-L143
train
developersociety/django-glitter
glitter/admin.py
GlitterAdminMixin.has_edit_permission
def has_edit_permission(self, request, obj=None, version=None): """ Returns a boolean if the user in the request has edit permission for the object. Can also be passed a version object to check if the user has permission to edit a version of the object (if they own it). """ ...
python
def has_edit_permission(self, request, obj=None, version=None): """ Returns a boolean if the user in the request has edit permission for the object. Can also be passed a version object to check if the user has permission to edit a version of the object (if they own it). """ ...
[ "def", "has_edit_permission", "(", "self", ",", "request", ",", "obj", "=", "None", ",", "version", "=", "None", ")", ":", "# Has the edit permission for this object type", "permission_name", "=", "'{}.edit_{}'", ".", "format", "(", "self", ".", "opts", ".", "ap...
Returns a boolean if the user in the request has edit permission for the object. Can also be passed a version object to check if the user has permission to edit a version of the object (if they own it).
[ "Returns", "a", "boolean", "if", "the", "user", "in", "the", "request", "has", "edit", "permission", "for", "the", "object", "." ]
2c0280ec83afee80deee94ee3934fc54239c2e87
https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/admin.py#L120-L139
train
developersociety/django-glitter
glitter/admin.py
GlitterAdminMixin.has_publish_permission
def has_publish_permission(self, request, obj=None): """ Returns a boolean if the user in the request has publish permission for the object. """ permission_name = '{}.publish_{}'.format(self.opts.app_label, self.opts.model_name) has_permission = request.user.has_perm(permission_n...
python
def has_publish_permission(self, request, obj=None): """ Returns a boolean if the user in the request has publish permission for the object. """ permission_name = '{}.publish_{}'.format(self.opts.app_label, self.opts.model_name) has_permission = request.user.has_perm(permission_n...
[ "def", "has_publish_permission", "(", "self", ",", "request", ",", "obj", "=", "None", ")", ":", "permission_name", "=", "'{}.publish_{}'", ".", "format", "(", "self", ".", "opts", ".", "app_label", ",", "self", ".", "opts", ".", "model_name", ")", "has_pe...
Returns a boolean if the user in the request has publish permission for the object.
[ "Returns", "a", "boolean", "if", "the", "user", "in", "the", "request", "has", "publish", "permission", "for", "the", "object", "." ]
2c0280ec83afee80deee94ee3934fc54239c2e87
https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/admin.py#L141-L151
train
quantmind/agile-toolkit
agiletoolkit/utils.py
semantic_version
def semantic_version(tag): """Get a valid semantic version for tag """ try: version = list(map(int, tag.split('.'))) assert len(version) == 3 return tuple(version) except Exception as exc: raise CommandError( 'Could not parse "%s", please use ' 'MA...
python
def semantic_version(tag): """Get a valid semantic version for tag """ try: version = list(map(int, tag.split('.'))) assert len(version) == 3 return tuple(version) except Exception as exc: raise CommandError( 'Could not parse "%s", please use ' 'MA...
[ "def", "semantic_version", "(", "tag", ")", ":", "try", ":", "version", "=", "list", "(", "map", "(", "int", ",", "tag", ".", "split", "(", "'.'", ")", ")", ")", "assert", "len", "(", "version", ")", "==", "3", "return", "tuple", "(", "version", ...
Get a valid semantic version for tag
[ "Get", "a", "valid", "semantic", "version", "for", "tag" ]
96028e36a842c57b171907c20583a60d1045fec1
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/utils.py#L99-L110
train
davidblaisonneau-orange/foreman
foreman/item.py
ForemanItem.load
def load(self, data): """ Function load Store the object data """ self.clear() self.update(data) self.enhance()
python
def load(self, data): """ Function load Store the object data """ self.clear() self.update(data) self.enhance()
[ "def", "load", "(", "self", ",", "data", ")", ":", "self", ".", "clear", "(", ")", "self", ".", "update", "(", "data", ")", "self", ".", "enhance", "(", ")" ]
Function load Store the object data
[ "Function", "load", "Store", "the", "object", "data" ]
acb8fd8d74657cfac3b25c82e9c6028b93eb6c92
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/item.py#L53-L59
train
davidblaisonneau-orange/foreman
foreman/item.py
ForemanItem.enhance
def enhance(self): """ Function enhance Enhance the object with new item or enhanced items """ if self.objName in ['hosts', 'hostgroups', 'puppet_classes']: from foreman.itemSmartClassParameter\ import ItemSmartClassParameter ...
python
def enhance(self): """ Function enhance Enhance the object with new item or enhanced items """ if self.objName in ['hosts', 'hostgroups', 'puppet_classes']: from foreman.itemSmartClassParameter\ import ItemSmartClassParameter ...
[ "def", "enhance", "(", "self", ")", ":", "if", "self", ".", "objName", "in", "[", "'hosts'", ",", "'hostgroups'", ",", "'puppet_classes'", "]", ":", "from", "foreman", ".", "itemSmartClassParameter", "import", "ItemSmartClassParameter", "self", ".", "update", ...
Function enhance Enhance the object with new item or enhanced items
[ "Function", "enhance", "Enhance", "the", "object", "with", "new", "item", "or", "enhanced", "items" ]
acb8fd8d74657cfac3b25c82e9c6028b93eb6c92
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/item.py#L61-L72
train
davidblaisonneau-orange/foreman
foreman/item.py
ForemanItem.reload
def reload(self): """ Function reload Sync the full object """ self.load(self.api.get(self.objName, self.key))
python
def reload(self): """ Function reload Sync the full object """ self.load(self.api.get(self.objName, self.key))
[ "def", "reload", "(", "self", ")", ":", "self", ".", "load", "(", "self", ".", "api", ".", "get", "(", "self", ".", "objName", ",", "self", ".", "key", ")", ")" ]
Function reload Sync the full object
[ "Function", "reload", "Sync", "the", "full", "object" ]
acb8fd8d74657cfac3b25c82e9c6028b93eb6c92
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/item.py#L74-L78
train
davidblaisonneau-orange/foreman
foreman/item.py
ForemanItem.getParam
def getParam(self, name=None): """ Function getParam Return a dict of parameters or a parameter value @param key: The parameter name @return RETURN: dict of parameters or a parameter value """ if 'parameters' in self.keys(): l = {x['name']: x['value'] for x i...
python
def getParam(self, name=None): """ Function getParam Return a dict of parameters or a parameter value @param key: The parameter name @return RETURN: dict of parameters or a parameter value """ if 'parameters' in self.keys(): l = {x['name']: x['value'] for x i...
[ "def", "getParam", "(", "self", ",", "name", "=", "None", ")", ":", "if", "'parameters'", "in", "self", ".", "keys", "(", ")", ":", "l", "=", "{", "x", "[", "'name'", "]", ":", "x", "[", "'value'", "]", "for", "x", "in", "self", "[", "'paramete...
Function getParam Return a dict of parameters or a parameter value @param key: The parameter name @return RETURN: dict of parameters or a parameter value
[ "Function", "getParam", "Return", "a", "dict", "of", "parameters", "or", "a", "parameter", "value" ]
acb8fd8d74657cfac3b25c82e9c6028b93eb6c92
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/item.py#L91-L106
train
davidblaisonneau-orange/foreman
foreman/item.py
ForemanItem.checkAndCreateClasses
def checkAndCreateClasses(self, classes): """ Function checkAndCreateClasses Check and add puppet class @param classes: The classes ids list @return RETURN: boolean """ actual_classes = self['puppetclasses'].keys() for i in classes: if i not in actual...
python
def checkAndCreateClasses(self, classes): """ Function checkAndCreateClasses Check and add puppet class @param classes: The classes ids list @return RETURN: boolean """ actual_classes = self['puppetclasses'].keys() for i in classes: if i not in actual...
[ "def", "checkAndCreateClasses", "(", "self", ",", "classes", ")", ":", "actual_classes", "=", "self", "[", "'puppetclasses'", "]", ".", "keys", "(", ")", "for", "i", "in", "classes", ":", "if", "i", "not", "in", "actual_classes", ":", "self", "[", "'pupp...
Function checkAndCreateClasses Check and add puppet class @param classes: The classes ids list @return RETURN: boolean
[ "Function", "checkAndCreateClasses", "Check", "and", "add", "puppet", "class" ]
acb8fd8d74657cfac3b25c82e9c6028b93eb6c92
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/item.py#L108-L120
train
davidblaisonneau-orange/foreman
foreman/item.py
ForemanItem.checkAndCreateParams
def checkAndCreateParams(self, params): """ Function checkAndCreateParams Check and add global parameters @param key: The parameter name @param params: The params dict @return RETURN: boolean """ actual_params = self['parameters'].keys() for k, v in param...
python
def checkAndCreateParams(self, params): """ Function checkAndCreateParams Check and add global parameters @param key: The parameter name @param params: The params dict @return RETURN: boolean """ actual_params = self['parameters'].keys() for k, v in param...
[ "def", "checkAndCreateParams", "(", "self", ",", "params", ")", ":", "actual_params", "=", "self", "[", "'parameters'", "]", ".", "keys", "(", ")", "for", "k", ",", "v", "in", "params", ".", "items", "(", ")", ":", "if", "k", "not", "in", "actual_par...
Function checkAndCreateParams Check and add global parameters @param key: The parameter name @param params: The params dict @return RETURN: boolean
[ "Function", "checkAndCreateParams", "Check", "and", "add", "global", "parameters" ]
acb8fd8d74657cfac3b25c82e9c6028b93eb6c92
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/item.py#L122-L135
train
mozilla-services/amo2kinto
amo2kinto/compare.py
version_dict
def version_dict(version): """Turn a version string into a dict with major/minor/... info.""" match = version_re.match(str(version) or '') letters = 'alpha pre'.split() numbers = 'major minor1 minor2 minor3 alpha_ver pre_ver'.split() if match: d = match.groupdict() for letter in lett...
python
def version_dict(version): """Turn a version string into a dict with major/minor/... info.""" match = version_re.match(str(version) or '') letters = 'alpha pre'.split() numbers = 'major minor1 minor2 minor3 alpha_ver pre_ver'.split() if match: d = match.groupdict() for letter in lett...
[ "def", "version_dict", "(", "version", ")", ":", "match", "=", "version_re", ".", "match", "(", "str", "(", "version", ")", "or", "''", ")", "letters", "=", "'alpha pre'", ".", "split", "(", ")", "numbers", "=", "'major minor1 minor2 minor3 alpha_ver pre_ver'"...
Turn a version string into a dict with major/minor/... info.
[ "Turn", "a", "version", "string", "into", "a", "dict", "with", "major", "/", "minor", "/", "...", "info", "." ]
1ec40647e77cf89badbea4a58d328243daed49a9
https://github.com/mozilla-services/amo2kinto/blob/1ec40647e77cf89badbea4a58d328243daed49a9/amo2kinto/compare.py#L21-L38
train
mozilla-services/amo2kinto
amo2kinto/synchronize.py
get_diff
def get_diff(source, dest): """Get the diff between two records list in this order: - to_create - to_delete """ # First build a dict from the lists, with the ID as the key. source_dict = {record['id']: record for record in source} dest_dict = {record['id']: record for record in dest}...
python
def get_diff(source, dest): """Get the diff between two records list in this order: - to_create - to_delete """ # First build a dict from the lists, with the ID as the key. source_dict = {record['id']: record for record in source} dest_dict = {record['id']: record for record in dest}...
[ "def", "get_diff", "(", "source", ",", "dest", ")", ":", "# First build a dict from the lists, with the ID as the key.", "source_dict", "=", "{", "record", "[", "'id'", "]", ":", "record", "for", "record", "in", "source", "}", "dest_dict", "=", "{", "record", "[...
Get the diff between two records list in this order: - to_create - to_delete
[ "Get", "the", "diff", "between", "two", "records", "list", "in", "this", "order", ":", "-", "to_create", "-", "to_delete" ]
1ec40647e77cf89badbea4a58d328243daed49a9
https://github.com/mozilla-services/amo2kinto/blob/1ec40647e77cf89badbea4a58d328243daed49a9/amo2kinto/synchronize.py#L16-L45
train
developersociety/django-glitter
glitter/publisher/forms.py
object_version_choices
def object_version_choices(obj): """ Return a list of form choices for versions of this object which can be published. """ choices = BLANK_CHOICE_DASH + [(PublishAction.UNPUBLISH_CHOICE, 'Unpublish current version')] # When creating a new object in the Django admin - obj will be None if obj is ...
python
def object_version_choices(obj): """ Return a list of form choices for versions of this object which can be published. """ choices = BLANK_CHOICE_DASH + [(PublishAction.UNPUBLISH_CHOICE, 'Unpublish current version')] # When creating a new object in the Django admin - obj will be None if obj is ...
[ "def", "object_version_choices", "(", "obj", ")", ":", "choices", "=", "BLANK_CHOICE_DASH", "+", "[", "(", "PublishAction", ".", "UNPUBLISH_CHOICE", ",", "'Unpublish current version'", ")", "]", "# When creating a new object in the Django admin - obj will be None", "if", "o...
Return a list of form choices for versions of this object which can be published.
[ "Return", "a", "list", "of", "form", "choices", "for", "versions", "of", "this", "object", "which", "can", "be", "published", "." ]
2c0280ec83afee80deee94ee3934fc54239c2e87
https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/publisher/forms.py#L9-L27
train
quantmind/agile-toolkit
agiletoolkit/manager.py
Manager.manifest
def manifest(self, values, *paths, filename: str = None) -> Dict: """Load a manifest file and apply template values """ filename = filename or self.filename(*paths) with open(filename, 'r') as fp: template = Template(fp.read()) return yaml.load(template.render(values)...
python
def manifest(self, values, *paths, filename: str = None) -> Dict: """Load a manifest file and apply template values """ filename = filename or self.filename(*paths) with open(filename, 'r') as fp: template = Template(fp.read()) return yaml.load(template.render(values)...
[ "def", "manifest", "(", "self", ",", "values", ",", "*", "paths", ",", "filename", ":", "str", "=", "None", ")", "->", "Dict", ":", "filename", "=", "filename", "or", "self", ".", "filename", "(", "*", "paths", ")", "with", "open", "(", "filename", ...
Load a manifest file and apply template values
[ "Load", "a", "manifest", "file", "and", "apply", "template", "values" ]
96028e36a842c57b171907c20583a60d1045fec1
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/manager.py#L48-L54
train
xenadevel/PyXenaManager
xenamanager/xena_stream.py
XenaStream.set_packet_headers
def set_packet_headers(self, headers): """ Set packet header. The method will try to set ps_headerprotocol to inform the Xena GUI and tester how to interpret the packet header byte sequence specified with PS_PACKETHEADER. This is mainly for information purposes, and the stream will tran...
python
def set_packet_headers(self, headers): """ Set packet header. The method will try to set ps_headerprotocol to inform the Xena GUI and tester how to interpret the packet header byte sequence specified with PS_PACKETHEADER. This is mainly for information purposes, and the stream will tran...
[ "def", "set_packet_headers", "(", "self", ",", "headers", ")", ":", "bin_headers", "=", "'0x'", "+", "binascii", ".", "hexlify", "(", "headers", ".", "bin", "(", ")", ")", ".", "decode", "(", "'utf-8'", ")", "self", ".", "set_attributes", "(", "ps_packet...
Set packet header. The method will try to set ps_headerprotocol to inform the Xena GUI and tester how to interpret the packet header byte sequence specified with PS_PACKETHEADER. This is mainly for information purposes, and the stream will transmit the packet header bytes even if no pro...
[ "Set", "packet", "header", "." ]
384ca265f73044b8a8b471f5dd7a6103fc54f4df
https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_stream.py#L80-L107
train
xenadevel/PyXenaManager
xenamanager/xena_stream.py
XenaStream.add_modifier
def add_modifier(self, m_type=XenaModifierType.standard, **kwargs): """ Add modifier. :param m_type: modifier type - standard or extended. :type: xenamanager.xena_stram.ModifierType :return: newly created modifier. :rtype: xenamanager.xena_stream.XenaModifier """ ...
python
def add_modifier(self, m_type=XenaModifierType.standard, **kwargs): """ Add modifier. :param m_type: modifier type - standard or extended. :type: xenamanager.xena_stram.ModifierType :return: newly created modifier. :rtype: xenamanager.xena_stream.XenaModifier """ ...
[ "def", "add_modifier", "(", "self", ",", "m_type", "=", "XenaModifierType", ".", "standard", ",", "*", "*", "kwargs", ")", ":", "if", "m_type", "==", "XenaModifierType", ".", "standard", ":", "modifier", "=", "XenaModifier", "(", "self", ",", "index", "=",...
Add modifier. :param m_type: modifier type - standard or extended. :type: xenamanager.xena_stram.ModifierType :return: newly created modifier. :rtype: xenamanager.xena_stream.XenaModifier
[ "Add", "modifier", "." ]
384ca265f73044b8a8b471f5dd7a6103fc54f4df
https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_stream.py#L113-L129
train
xenadevel/PyXenaManager
xenamanager/xena_stream.py
XenaStream.remove_modifier
def remove_modifier(self, index, m_type=XenaModifierType.standard): """ Remove modifier. :param m_type: modifier type - standard or extended. :param index: index of modifier to remove. """ if m_type == XenaModifierType.standard: current_modifiers = OrderedDict(self....
python
def remove_modifier(self, index, m_type=XenaModifierType.standard): """ Remove modifier. :param m_type: modifier type - standard or extended. :param index: index of modifier to remove. """ if m_type == XenaModifierType.standard: current_modifiers = OrderedDict(self....
[ "def", "remove_modifier", "(", "self", ",", "index", ",", "m_type", "=", "XenaModifierType", ".", "standard", ")", ":", "if", "m_type", "==", "XenaModifierType", ".", "standard", ":", "current_modifiers", "=", "OrderedDict", "(", "self", ".", "modifiers", ")",...
Remove modifier. :param m_type: modifier type - standard or extended. :param index: index of modifier to remove.
[ "Remove", "modifier", "." ]
384ca265f73044b8a8b471f5dd7a6103fc54f4df
https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_stream.py#L131-L155
train
xenadevel/PyXenaManager
xenamanager/xena_stream.py
XenaStream.modifiers
def modifiers(self): """ :return: dictionary {index: object} of standard modifiers. """ if not self.get_objects_by_type('modifier'): for index in range(int(self.get_attribute('ps_modifiercount'))): XenaModifier(self, index='{}/{}'.format(self.index, index)).ge...
python
def modifiers(self): """ :return: dictionary {index: object} of standard modifiers. """ if not self.get_objects_by_type('modifier'): for index in range(int(self.get_attribute('ps_modifiercount'))): XenaModifier(self, index='{}/{}'.format(self.index, index)).ge...
[ "def", "modifiers", "(", "self", ")", ":", "if", "not", "self", ".", "get_objects_by_type", "(", "'modifier'", ")", ":", "for", "index", "in", "range", "(", "int", "(", "self", ".", "get_attribute", "(", "'ps_modifiercount'", ")", ")", ")", ":", "XenaMod...
:return: dictionary {index: object} of standard modifiers.
[ ":", "return", ":", "dictionary", "{", "index", ":", "object", "}", "of", "standard", "modifiers", "." ]
384ca265f73044b8a8b471f5dd7a6103fc54f4df
https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_stream.py#L162-L169
train
xenadevel/PyXenaManager
xenamanager/xena_stream.py
XenaStream.xmodifiers
def xmodifiers(self): """ :return: dictionary {index: object} of extended modifiers. """ if not self.get_objects_by_type('xmodifier'): try: for index in range(int(self.get_attribute('ps_modifierextcount'))): XenaXModifier(self, index='{}/{}...
python
def xmodifiers(self): """ :return: dictionary {index: object} of extended modifiers. """ if not self.get_objects_by_type('xmodifier'): try: for index in range(int(self.get_attribute('ps_modifierextcount'))): XenaXModifier(self, index='{}/{}...
[ "def", "xmodifiers", "(", "self", ")", ":", "if", "not", "self", ".", "get_objects_by_type", "(", "'xmodifier'", ")", ":", "try", ":", "for", "index", "in", "range", "(", "int", "(", "self", ".", "get_attribute", "(", "'ps_modifierextcount'", ")", ")", "...
:return: dictionary {index: object} of extended modifiers.
[ ":", "return", ":", "dictionary", "{", "index", ":", "object", "}", "of", "extended", "modifiers", "." ]
384ca265f73044b8a8b471f5dd7a6103fc54f4df
https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_stream.py#L172-L182
train
astroduff/commah
commah/cosmology_list.py
DRAGONS
def DRAGONS(flat=False, extras=True): """DRAGONS cosmology assumes WMAP7 + BAO + H_0 mean from Komatsu et al. (2011) ApJS 192 18K (arxiv:1001.4538v1) Parameters ---------- flat: boolean If True, sets omega_lambda_0 = 1 - omega_M_0 to ensure omega_k_0 = 0 exactly. Also sets omega_k_0 =...
python
def DRAGONS(flat=False, extras=True): """DRAGONS cosmology assumes WMAP7 + BAO + H_0 mean from Komatsu et al. (2011) ApJS 192 18K (arxiv:1001.4538v1) Parameters ---------- flat: boolean If True, sets omega_lambda_0 = 1 - omega_M_0 to ensure omega_k_0 = 0 exactly. Also sets omega_k_0 =...
[ "def", "DRAGONS", "(", "flat", "=", "False", ",", "extras", "=", "True", ")", ":", "omega_c_0", "=", "0.2292", "omega_b_0", "=", "0.0458", "cosmo", "=", "{", "'omega_b_0'", ":", "omega_b_0", ",", "'omega_M_0'", ":", "omega_b_0", "+", "omega_c_0", ",", "'...
DRAGONS cosmology assumes WMAP7 + BAO + H_0 mean from Komatsu et al. (2011) ApJS 192 18K (arxiv:1001.4538v1) Parameters ---------- flat: boolean If True, sets omega_lambda_0 = 1 - omega_M_0 to ensure omega_k_0 = 0 exactly. Also sets omega_k_0 = 0 explicitly. extras: boolean If...
[ "DRAGONS", "cosmology", "assumes", "WMAP7", "+", "BAO", "+", "H_0", "mean", "from", "Komatsu", "et", "al", ".", "(", "2011", ")", "ApJS", "192", "18K", "(", "arxiv", ":", "1001", ".", "4538v1", ")" ]
3ec70338c5123a053c79ddcf2cb3beac26bc9137
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/cosmology_list.py#L20-L55
train
astroduff/commah
commah/cosmology_list.py
Planck_2015
def Planck_2015(flat=False, extras=True): """Planck 2015 XII: Cosmological parameters Table 4 column Planck TT, TE, EE + lowP + lensing + ext from Ade et al. (2015) A&A in press (arxiv:1502.01589v1) Parameters ---------- flat: boolean If True, sets omega_lambda_0 = 1 - omega_M_0 to ensu...
python
def Planck_2015(flat=False, extras=True): """Planck 2015 XII: Cosmological parameters Table 4 column Planck TT, TE, EE + lowP + lensing + ext from Ade et al. (2015) A&A in press (arxiv:1502.01589v1) Parameters ---------- flat: boolean If True, sets omega_lambda_0 = 1 - omega_M_0 to ensu...
[ "def", "Planck_2015", "(", "flat", "=", "False", ",", "extras", "=", "True", ")", ":", "omega_b_0", "=", "0.02230", "/", "(", "0.6774", "**", "2", ")", "cosmo", "=", "{", "'omega_b_0'", ":", "omega_b_0", ",", "'omega_M_0'", ":", "0.3089", ",", "'omega_...
Planck 2015 XII: Cosmological parameters Table 4 column Planck TT, TE, EE + lowP + lensing + ext from Ade et al. (2015) A&A in press (arxiv:1502.01589v1) Parameters ---------- flat: boolean If True, sets omega_lambda_0 = 1 - omega_M_0 to ensure omega_k_0 = 0 exactly. Also sets omega_k...
[ "Planck", "2015", "XII", ":", "Cosmological", "parameters", "Table", "4", "column", "Planck", "TT", "TE", "EE", "+", "lowP", "+", "lensing", "+", "ext", "from", "Ade", "et", "al", ".", "(", "2015", ")", "A&A", "in", "press", "(", "arxiv", ":", "1502"...
3ec70338c5123a053c79ddcf2cb3beac26bc9137
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/cosmology_list.py#L512-L547
train
Karaage-Cluster/python-tldap
tldap/backend/no_transactions.py
LDAPwrapper.add
def add(self, dn: str, mod_list: dict) -> None: """ Add a DN to the LDAP database; See ldap module. Doesn't return a result if transactions enabled. """ return self._do_with_retry(lambda obj: obj.add_s(dn, mod_list))
python
def add(self, dn: str, mod_list: dict) -> None: """ Add a DN to the LDAP database; See ldap module. Doesn't return a result if transactions enabled. """ return self._do_with_retry(lambda obj: obj.add_s(dn, mod_list))
[ "def", "add", "(", "self", ",", "dn", ":", "str", ",", "mod_list", ":", "dict", ")", "->", "None", ":", "return", "self", ".", "_do_with_retry", "(", "lambda", "obj", ":", "obj", ".", "add_s", "(", "dn", ",", "mod_list", ")", ")" ]
Add a DN to the LDAP database; See ldap module. Doesn't return a result if transactions enabled.
[ "Add", "a", "DN", "to", "the", "LDAP", "database", ";", "See", "ldap", "module", ".", "Doesn", "t", "return", "a", "result", "if", "transactions", "enabled", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/no_transactions.py#L85-L91
train
Karaage-Cluster/python-tldap
tldap/backend/no_transactions.py
LDAPwrapper.modify
def modify(self, dn: str, mod_list: dict) -> None: """ Modify a DN in the LDAP database; See ldap module. Doesn't return a result if transactions enabled. """ return self._do_with_retry(lambda obj: obj.modify_s(dn, mod_list))
python
def modify(self, dn: str, mod_list: dict) -> None: """ Modify a DN in the LDAP database; See ldap module. Doesn't return a result if transactions enabled. """ return self._do_with_retry(lambda obj: obj.modify_s(dn, mod_list))
[ "def", "modify", "(", "self", ",", "dn", ":", "str", ",", "mod_list", ":", "dict", ")", "->", "None", ":", "return", "self", ".", "_do_with_retry", "(", "lambda", "obj", ":", "obj", ".", "modify_s", "(", "dn", ",", "mod_list", ")", ")" ]
Modify a DN in the LDAP database; See ldap module. Doesn't return a result if transactions enabled.
[ "Modify", "a", "DN", "in", "the", "LDAP", "database", ";", "See", "ldap", "module", ".", "Doesn", "t", "return", "a", "result", "if", "transactions", "enabled", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/no_transactions.py#L93-L99
train
Karaage-Cluster/python-tldap
tldap/backend/no_transactions.py
LDAPwrapper.delete
def delete(self, dn: str) -> None: """ delete a dn in the ldap database; see ldap module. doesn't return a result if transactions enabled. """ return self._do_with_retry(lambda obj: obj.delete_s(dn))
python
def delete(self, dn: str) -> None: """ delete a dn in the ldap database; see ldap module. doesn't return a result if transactions enabled. """ return self._do_with_retry(lambda obj: obj.delete_s(dn))
[ "def", "delete", "(", "self", ",", "dn", ":", "str", ")", "->", "None", ":", "return", "self", ".", "_do_with_retry", "(", "lambda", "obj", ":", "obj", ".", "delete_s", "(", "dn", ")", ")" ]
delete a dn in the ldap database; see ldap module. doesn't return a result if transactions enabled.
[ "delete", "a", "dn", "in", "the", "ldap", "database", ";", "see", "ldap", "module", ".", "doesn", "t", "return", "a", "result", "if", "transactions", "enabled", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/no_transactions.py#L109-L115
train
Karaage-Cluster/python-tldap
tldap/backend/no_transactions.py
LDAPwrapper.rename
def rename(self, dn: str, new_rdn: str, new_base_dn: Optional[str] = None) -> None: """ rename a dn in the ldap database; see ldap module. doesn't return a result if transactions enabled. """ return self._do_with_retry( lambda obj: obj.rename_s(dn, new_rdn, new_base_...
python
def rename(self, dn: str, new_rdn: str, new_base_dn: Optional[str] = None) -> None: """ rename a dn in the ldap database; see ldap module. doesn't return a result if transactions enabled. """ return self._do_with_retry( lambda obj: obj.rename_s(dn, new_rdn, new_base_...
[ "def", "rename", "(", "self", ",", "dn", ":", "str", ",", "new_rdn", ":", "str", ",", "new_base_dn", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "None", ":", "return", "self", ".", "_do_with_retry", "(", "lambda", "obj", ":", "obj", "...
rename a dn in the ldap database; see ldap module. doesn't return a result if transactions enabled.
[ "rename", "a", "dn", "in", "the", "ldap", "database", ";", "see", "ldap", "module", ".", "doesn", "t", "return", "a", "result", "if", "transactions", "enabled", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/no_transactions.py#L117-L124
train
developersociety/django-glitter
glitter/layouts.py
PageLayoutBase.get_column_name
def get_column_name(self, column_name): """ Get a column for given column name from META api. """ name = pretty_name(column_name) if column_name in self._meta.columns: column_cls = self._meta.columns[column_name] if column_cls.verbose_name: name = column_c...
python
def get_column_name(self, column_name): """ Get a column for given column name from META api. """ name = pretty_name(column_name) if column_name in self._meta.columns: column_cls = self._meta.columns[column_name] if column_cls.verbose_name: name = column_c...
[ "def", "get_column_name", "(", "self", ",", "column_name", ")", ":", "name", "=", "pretty_name", "(", "column_name", ")", "if", "column_name", "in", "self", ".", "_meta", ".", "columns", ":", "column_cls", "=", "self", ".", "_meta", ".", "columns", "[", ...
Get a column for given column name from META api.
[ "Get", "a", "column", "for", "given", "column", "name", "from", "META", "api", "." ]
2c0280ec83afee80deee94ee3934fc54239c2e87
https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/layouts.py#L86-L93
train
quantmind/agile-toolkit
agiletoolkit/repo.py
RepoManager.version
def version(self): """Software version of the current repository """ branches = self.branches() if self.info['branch'] == branches.sandbox: try: return self.software_version() except Exception as exc: raise utils.CommandError( ...
python
def version(self): """Software version of the current repository """ branches = self.branches() if self.info['branch'] == branches.sandbox: try: return self.software_version() except Exception as exc: raise utils.CommandError( ...
[ "def", "version", "(", "self", ")", ":", "branches", "=", "self", ".", "branches", "(", ")", "if", "self", ".", "info", "[", "'branch'", "]", "==", "branches", ".", "sandbox", ":", "try", ":", "return", "self", ".", "software_version", "(", ")", "exc...
Software version of the current repository
[ "Software", "version", "of", "the", "current", "repository" ]
96028e36a842c57b171907c20583a60d1045fec1
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/repo.py#L34-L49
train
quantmind/agile-toolkit
agiletoolkit/repo.py
RepoManager.validate_version
def validate_version(self, prefix='v'): """Validate version by checking if it is a valid semantic version and its value is higher than latest github tag """ version = self.software_version() repo = self.github_repo() repo.releases.validate_tag(version, prefix) ret...
python
def validate_version(self, prefix='v'): """Validate version by checking if it is a valid semantic version and its value is higher than latest github tag """ version = self.software_version() repo = self.github_repo() repo.releases.validate_tag(version, prefix) ret...
[ "def", "validate_version", "(", "self", ",", "prefix", "=", "'v'", ")", ":", "version", "=", "self", ".", "software_version", "(", ")", "repo", "=", "self", ".", "github_repo", "(", ")", "repo", ".", "releases", ".", "validate_tag", "(", "version", ",", ...
Validate version by checking if it is a valid semantic version and its value is higher than latest github tag
[ "Validate", "version", "by", "checking", "if", "it", "is", "a", "valid", "semantic", "version", "and", "its", "value", "is", "higher", "than", "latest", "github", "tag" ]
96028e36a842c57b171907c20583a60d1045fec1
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/repo.py#L51-L58
train
quantmind/agile-toolkit
agiletoolkit/repo.py
RepoManager.skip_build
def skip_build(self): """Check if build should be skipped """ skip_msg = self.config.get('skip', '[ci skip]') return ( os.environ.get('CODEBUILD_BUILD_SUCCEEDING') == '0' or self.info['current_tag'] or skip_msg in self.info['head']['message'] )
python
def skip_build(self): """Check if build should be skipped """ skip_msg = self.config.get('skip', '[ci skip]') return ( os.environ.get('CODEBUILD_BUILD_SUCCEEDING') == '0' or self.info['current_tag'] or skip_msg in self.info['head']['message'] )
[ "def", "skip_build", "(", "self", ")", ":", "skip_msg", "=", "self", ".", "config", ".", "get", "(", "'skip'", ",", "'[ci skip]'", ")", "return", "(", "os", ".", "environ", ".", "get", "(", "'CODEBUILD_BUILD_SUCCEEDING'", ")", "==", "'0'", "or", "self", ...
Check if build should be skipped
[ "Check", "if", "build", "should", "be", "skipped" ]
96028e36a842c57b171907c20583a60d1045fec1
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/repo.py#L60-L68
train