repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
helixyte/everest
everest/representers/mapping.py
Mapping.with_updated_configuration
def with_updated_configuration(self, options=None, attribute_options=None): """ Returns a context in which this mapping is updated with the given options and attribute options. """ new_cfg = self.__configurations[-1].copy() if not option...
python
def with_updated_configuration(self, options=None, attribute_options=None): """ Returns a context in which this mapping is updated with the given options and attribute options. """ new_cfg = self.__configurations[-1].copy() if not option...
[ "def", "with_updated_configuration", "(", "self", ",", "options", "=", "None", ",", "attribute_options", "=", "None", ")", ":", "new_cfg", "=", "self", ".", "__configurations", "[", "-", "1", "]", ".", "copy", "(", ")", "if", "not", "options", "is", "Non...
Returns a context in which this mapping is updated with the given options and attribute options.
[ "Returns", "a", "context", "in", "which", "this", "mapping", "is", "updated", "with", "the", "given", "options", "and", "attribute", "options", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/mapping.py#L312-L329
train
58,400
helixyte/everest
everest/representers/mapping.py
Mapping._attribute_iterator
def _attribute_iterator(self, mapped_class, key): """ Returns an iterator over the attributes in this mapping for the given mapped class and attribute key. If this is a pruning mapping, attributes that are ignored because of a custom configuration or because of the default ignor...
python
def _attribute_iterator(self, mapped_class, key): """ Returns an iterator over the attributes in this mapping for the given mapped class and attribute key. If this is a pruning mapping, attributes that are ignored because of a custom configuration or because of the default ignor...
[ "def", "_attribute_iterator", "(", "self", ",", "mapped_class", ",", "key", ")", ":", "for", "attr", "in", "itervalues_", "(", "self", ".", "__get_attribute_map", "(", "mapped_class", ",", "key", ",", "0", ")", ")", ":", "if", "self", ".", "is_pruning", ...
Returns an iterator over the attributes in this mapping for the given mapped class and attribute key. If this is a pruning mapping, attributes that are ignored because of a custom configuration or because of the default ignore rules are skipped.
[ "Returns", "an", "iterator", "over", "the", "attributes", "in", "this", "mapping", "for", "the", "given", "mapped", "class", "and", "attribute", "key", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/mapping.py#L343-L359
train
58,401
helixyte/everest
everest/representers/mapping.py
MappingRegistry.create_mapping
def create_mapping(self, mapped_class, configuration=None): """ Creates a new mapping for the given mapped class and representer configuration. :param configuration: configuration for the new data element class. :type configuration: :class:`RepresenterConfiguration` :ret...
python
def create_mapping(self, mapped_class, configuration=None): """ Creates a new mapping for the given mapped class and representer configuration. :param configuration: configuration for the new data element class. :type configuration: :class:`RepresenterConfiguration` :ret...
[ "def", "create_mapping", "(", "self", ",", "mapped_class", ",", "configuration", "=", "None", ")", ":", "cfg", "=", "self", ".", "__configuration", ".", "copy", "(", ")", "if", "not", "configuration", "is", "None", ":", "cfg", ".", "update", "(", "config...
Creates a new mapping for the given mapped class and representer configuration. :param configuration: configuration for the new data element class. :type configuration: :class:`RepresenterConfiguration` :returns: newly created instance of :class:`Mapping`
[ "Creates", "a", "new", "mapping", "for", "the", "given", "mapped", "class", "and", "representer", "configuration", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/mapping.py#L474-L503
train
58,402
helixyte/everest
everest/representers/mapping.py
MappingRegistry.find_mapping
def find_mapping(self, mapped_class): """ Returns the mapping registered for the given mapped class or any of its base classes. Returns `None` if no mapping can be found. :param mapped_class: mapped type :type mapped_class: type :returns: instance of :class:`Mapping` or ...
python
def find_mapping(self, mapped_class): """ Returns the mapping registered for the given mapped class or any of its base classes. Returns `None` if no mapping can be found. :param mapped_class: mapped type :type mapped_class: type :returns: instance of :class:`Mapping` or ...
[ "def", "find_mapping", "(", "self", ",", "mapped_class", ")", ":", "if", "not", "self", ".", "__is_initialized", ":", "self", ".", "__is_initialized", "=", "True", "self", ".", "_initialize", "(", ")", "mapping", "=", "None", "for", "base_cls", "in", "mapp...
Returns the mapping registered for the given mapped class or any of its base classes. Returns `None` if no mapping can be found. :param mapped_class: mapped type :type mapped_class: type :returns: instance of :class:`Mapping` or `None`
[ "Returns", "the", "mapping", "registered", "for", "the", "given", "mapped", "class", "or", "any", "of", "its", "base", "classes", ".", "Returns", "None", "if", "no", "mapping", "can", "be", "found", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/mapping.py#L514-L534
train
58,403
corydodt/Codado
codado/py.py
eachMethod
def eachMethod(decorator, methodFilter=lambda fName: True): """ Class decorator that wraps every single method in its own method decorator methodFilter: a function which accepts a function name and should return True if the method is one which we want to decorate, False if we want to leave this met...
python
def eachMethod(decorator, methodFilter=lambda fName: True): """ Class decorator that wraps every single method in its own method decorator methodFilter: a function which accepts a function name and should return True if the method is one which we want to decorate, False if we want to leave this met...
[ "def", "eachMethod", "(", "decorator", ",", "methodFilter", "=", "lambda", "fName", ":", "True", ")", ":", "if", "isinstance", "(", "methodFilter", ",", "basestring", ")", ":", "# Is it a string? If it is, change it into a function that takes a string.", "prefix", "=", ...
Class decorator that wraps every single method in its own method decorator methodFilter: a function which accepts a function name and should return True if the method is one which we want to decorate, False if we want to leave this method alone. methodFilter can also be simply a string prefix. If it i...
[ "Class", "decorator", "that", "wraps", "every", "single", "method", "in", "its", "own", "method", "decorator" ]
487d51ec6132c05aa88e2f128012c95ccbf6928e
https://github.com/corydodt/Codado/blob/487d51ec6132c05aa88e2f128012c95ccbf6928e/codado/py.py#L42-L74
train
58,404
corydodt/Codado
codado/py.py
_sibpath
def _sibpath(path, sibling): """ Return the path to a sibling of a file in the filesystem. This is useful in conjunction with the special C{__file__} attribute that Python provides for modules, so modules can load associated resource files. (Stolen from twisted.python.util) """ return ...
python
def _sibpath(path, sibling): """ Return the path to a sibling of a file in the filesystem. This is useful in conjunction with the special C{__file__} attribute that Python provides for modules, so modules can load associated resource files. (Stolen from twisted.python.util) """ return ...
[ "def", "_sibpath", "(", "path", ",", "sibling", ")", ":", "return", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "path", ")", ")", ",", "sibling", ")" ]
Return the path to a sibling of a file in the filesystem. This is useful in conjunction with the special C{__file__} attribute that Python provides for modules, so modules can load associated resource files. (Stolen from twisted.python.util)
[ "Return", "the", "path", "to", "a", "sibling", "of", "a", "file", "in", "the", "filesystem", "." ]
487d51ec6132c05aa88e2f128012c95ccbf6928e
https://github.com/corydodt/Codado/blob/487d51ec6132c05aa88e2f128012c95ccbf6928e/codado/py.py#L97-L107
train
58,405
jealous/cachez
cachez.py
Cache.cache
def cache(cls, func): """ Global cache decorator :param func: the function to be decorated :return: the decorator """ @functools.wraps(func) def func_wrapper(*args, **kwargs): func_key = cls.get_key(func) val_cache = cls.get_cache(func_key) ...
python
def cache(cls, func): """ Global cache decorator :param func: the function to be decorated :return: the decorator """ @functools.wraps(func) def func_wrapper(*args, **kwargs): func_key = cls.get_key(func) val_cache = cls.get_cache(func_key) ...
[ "def", "cache", "(", "cls", ",", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "func_wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "func_key", "=", "cls", ".", "get_key", "(", "func", ")", "val_cache", ...
Global cache decorator :param func: the function to be decorated :return: the decorator
[ "Global", "cache", "decorator" ]
4e928b0d796be47073290e631463a63f0d1e66b8
https://github.com/jealous/cachez/blob/4e928b0d796be47073290e631463a63f0d1e66b8/cachez.py#L113-L129
train
58,406
jealous/cachez
cachez.py
Cache.instance_cache
def instance_cache(cls, func): """ Save the cache to `self` This decorator take it for granted that the decorated function is a method. The first argument of the function is `self`. :param func: function to decorate :return: the decorator """ @functools.wraps(...
python
def instance_cache(cls, func): """ Save the cache to `self` This decorator take it for granted that the decorated function is a method. The first argument of the function is `self`. :param func: function to decorate :return: the decorator """ @functools.wraps(...
[ "def", "instance_cache", "(", "cls", ",", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "func_wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "args", ":", "raise", "ValueError", "(", "'`self` i...
Save the cache to `self` This decorator take it for granted that the decorated function is a method. The first argument of the function is `self`. :param func: function to decorate :return: the decorator
[ "Save", "the", "cache", "to", "self" ]
4e928b0d796be47073290e631463a63f0d1e66b8
https://github.com/jealous/cachez/blob/4e928b0d796be47073290e631463a63f0d1e66b8/cachez.py#L163-L186
train
58,407
jealous/cachez
cachez.py
Cache.clear_instance_cache
def clear_instance_cache(cls, func): """ clear the instance cache Decorate a method of a class, the first parameter is supposed to be `self`. It clear all items cached by the `instance_cache` decorator. :param func: function to decorate """ @functools.wraps(func...
python
def clear_instance_cache(cls, func): """ clear the instance cache Decorate a method of a class, the first parameter is supposed to be `self`. It clear all items cached by the `instance_cache` decorator. :param func: function to decorate """ @functools.wraps(func...
[ "def", "clear_instance_cache", "(", "cls", ",", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "func_wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "args", ":", "raise", "ValueError", "(", "'`s...
clear the instance cache Decorate a method of a class, the first parameter is supposed to be `self`. It clear all items cached by the `instance_cache` decorator. :param func: function to decorate
[ "clear", "the", "instance", "cache" ]
4e928b0d796be47073290e631463a63f0d1e66b8
https://github.com/jealous/cachez/blob/4e928b0d796be47073290e631463a63f0d1e66b8/cachez.py#L189-L208
train
58,408
jealous/cachez
cachez.py
Persisted.persisted
def persisted(cls, seconds=0, minutes=0, hours=0, days=0, weeks=0): """ Cache the return of the function for given time. Default to 1 day. :param weeks: as name :param seconds: as name :param minutes: as name :param hours: as name :param days: as name :re...
python
def persisted(cls, seconds=0, minutes=0, hours=0, days=0, weeks=0): """ Cache the return of the function for given time. Default to 1 day. :param weeks: as name :param seconds: as name :param minutes: as name :param hours: as name :param days: as name :re...
[ "def", "persisted", "(", "cls", ",", "seconds", "=", "0", ",", "minutes", "=", "0", ",", "hours", "=", "0", ",", "days", "=", "0", ",", "weeks", "=", "0", ")", ":", "days", "+=", "weeks", "*", "7", "hours", "+=", "days", "*", "24", "minutes", ...
Cache the return of the function for given time. Default to 1 day. :param weeks: as name :param seconds: as name :param minutes: as name :param hours: as name :param days: as name :return: return of the function decorated
[ "Cache", "the", "return", "of", "the", "function", "for", "given", "time", "." ]
4e928b0d796be47073290e631463a63f0d1e66b8
https://github.com/jealous/cachez/blob/4e928b0d796be47073290e631463a63f0d1e66b8/cachez.py#L234-L297
train
58,409
tomprince/txgithub
txgithub/api.py
ReposEndpoint.getEvents
def getEvents(self, repo_user, repo_name, until_id=None): """Get all repository events, following paging, until the end or until UNTIL_ID is seen. Returns a Deferred.""" done = False page = 0 events = [] while not done: new_events = yield self.api.makeRequest...
python
def getEvents(self, repo_user, repo_name, until_id=None): """Get all repository events, following paging, until the end or until UNTIL_ID is seen. Returns a Deferred.""" done = False page = 0 events = [] while not done: new_events = yield self.api.makeRequest...
[ "def", "getEvents", "(", "self", ",", "repo_user", ",", "repo_name", ",", "until_id", "=", "None", ")", ":", "done", "=", "False", "page", "=", "0", "events", "=", "[", "]", "while", "not", "done", ":", "new_events", "=", "yield", "self", ".", "api",...
Get all repository events, following paging, until the end or until UNTIL_ID is seen. Returns a Deferred.
[ "Get", "all", "repository", "events", "following", "paging", "until", "the", "end", "or", "until", "UNTIL_ID", "is", "seen", ".", "Returns", "a", "Deferred", "." ]
3bd5eebb25db013e2193e6a102a91049f356710d
https://github.com/tomprince/txgithub/blob/3bd5eebb25db013e2193e6a102a91049f356710d/txgithub/api.py#L157-L179
train
58,410
sarugaku/mork
src/mork/virtualenv.py
VirtualEnv.from_project_path
def from_project_path(cls, path): """Utility for finding a virtualenv location based on a project path""" path = vistir.compat.Path(path) if path.name == 'Pipfile': pipfile_path = path path = path.parent else: pipfile_path = path / 'Pipfile' pi...
python
def from_project_path(cls, path): """Utility for finding a virtualenv location based on a project path""" path = vistir.compat.Path(path) if path.name == 'Pipfile': pipfile_path = path path = path.parent else: pipfile_path = path / 'Pipfile' pi...
[ "def", "from_project_path", "(", "cls", ",", "path", ")", ":", "path", "=", "vistir", ".", "compat", ".", "Path", "(", "path", ")", "if", "path", ".", "name", "==", "'Pipfile'", ":", "pipfile_path", "=", "path", "path", "=", "path", ".", "parent", "e...
Utility for finding a virtualenv location based on a project path
[ "Utility", "for", "finding", "a", "virtualenv", "location", "based", "on", "a", "project", "path" ]
c1a7cd63c490ed7fbecb7714fd5590d2609366de
https://github.com/sarugaku/mork/blob/c1a7cd63c490ed7fbecb7714fd5590d2609366de/src/mork/virtualenv.py#L46-L69
train
58,411
sarugaku/mork
src/mork/virtualenv.py
VirtualEnv.get_setup_install_args
def get_setup_install_args(self, pkgname, setup_py, develop=False): """Get setup.py install args for installing the supplied package in the virtualenv :param str pkgname: The name of the package to install :param str setup_py: The path to the setup file of the package :param bool develo...
python
def get_setup_install_args(self, pkgname, setup_py, develop=False): """Get setup.py install args for installing the supplied package in the virtualenv :param str pkgname: The name of the package to install :param str setup_py: The path to the setup file of the package :param bool develo...
[ "def", "get_setup_install_args", "(", "self", ",", "pkgname", ",", "setup_py", ",", "develop", "=", "False", ")", ":", "headers", "=", "self", ".", "base_paths", "[", "\"headers\"", "]", "headers", "=", "headers", "/", "\"python{0}\"", ".", "format", "(", ...
Get setup.py install args for installing the supplied package in the virtualenv :param str pkgname: The name of the package to install :param str setup_py: The path to the setup file of the package :param bool develop: Whether the package is in development mode :return: The installation...
[ "Get", "setup", ".", "py", "install", "args", "for", "installing", "the", "supplied", "package", "in", "the", "virtualenv" ]
c1a7cd63c490ed7fbecb7714fd5590d2609366de
https://github.com/sarugaku/mork/blob/c1a7cd63c490ed7fbecb7714fd5590d2609366de/src/mork/virtualenv.py#L453-L474
train
58,412
sarugaku/mork
src/mork/virtualenv.py
VirtualEnv.setuptools_install
def setuptools_install(self, chdir_to, pkg_name, setup_py_path=None, editable=False): """Install an sdist or an editable package into the virtualenv :param str chdir_to: The location to change to :param str setup_py_path: The path to the setup.py, if applicable defaults to None :param ...
python
def setuptools_install(self, chdir_to, pkg_name, setup_py_path=None, editable=False): """Install an sdist or an editable package into the virtualenv :param str chdir_to: The location to change to :param str setup_py_path: The path to the setup.py, if applicable defaults to None :param ...
[ "def", "setuptools_install", "(", "self", ",", "chdir_to", ",", "pkg_name", ",", "setup_py_path", "=", "None", ",", "editable", "=", "False", ")", ":", "install_options", "=", "[", "\"--prefix={0}\"", ".", "format", "(", "self", ".", "prefix", ".", "as_posix...
Install an sdist or an editable package into the virtualenv :param str chdir_to: The location to change to :param str setup_py_path: The path to the setup.py, if applicable defaults to None :param bool editable: Whether the package is editable, defaults to False
[ "Install", "an", "sdist", "or", "an", "editable", "package", "into", "the", "virtualenv" ]
c1a7cd63c490ed7fbecb7714fd5590d2609366de
https://github.com/sarugaku/mork/blob/c1a7cd63c490ed7fbecb7714fd5590d2609366de/src/mork/virtualenv.py#L476-L490
train
58,413
sarugaku/mork
src/mork/virtualenv.py
VirtualEnv.install
def install(self, req, editable=False, sources=[]): """Install a package into the virtualenv :param req: A requirement to install :type req: :class:`requirementslib.models.requirement.Requirement` :param bool editable: Whether the requirement is editable, defaults to False :para...
python
def install(self, req, editable=False, sources=[]): """Install a package into the virtualenv :param req: A requirement to install :type req: :class:`requirementslib.models.requirement.Requirement` :param bool editable: Whether the requirement is editable, defaults to False :para...
[ "def", "install", "(", "self", ",", "req", ",", "editable", "=", "False", ",", "sources", "=", "[", "]", ")", ":", "try", ":", "packagebuilder", "=", "self", ".", "safe_import", "(", "\"packagebuilder\"", ")", "except", "ImportError", ":", "packagebuilder"...
Install a package into the virtualenv :param req: A requirement to install :type req: :class:`requirementslib.models.requirement.Requirement` :param bool editable: Whether the requirement is editable, defaults to False :param list sources: A list of pip sources to consult, defaults to [...
[ "Install", "a", "package", "into", "the", "virtualenv" ]
c1a7cd63c490ed7fbecb7714fd5590d2609366de
https://github.com/sarugaku/mork/blob/c1a7cd63c490ed7fbecb7714fd5590d2609366de/src/mork/virtualenv.py#L492-L530
train
58,414
sarugaku/mork
src/mork/virtualenv.py
VirtualEnv.activated
def activated(self, include_extras=True, extra_dists=[]): """A context manager which activates the virtualenv. :param list extra_dists: Paths added to the context after the virtualenv is activated. This context manager sets the following environment variables: * `PYTHONUSERBASE` ...
python
def activated(self, include_extras=True, extra_dists=[]): """A context manager which activates the virtualenv. :param list extra_dists: Paths added to the context after the virtualenv is activated. This context manager sets the following environment variables: * `PYTHONUSERBASE` ...
[ "def", "activated", "(", "self", ",", "include_extras", "=", "True", ",", "extra_dists", "=", "[", "]", ")", ":", "original_path", "=", "sys", ".", "path", "original_prefix", "=", "sys", ".", "prefix", "original_user_base", "=", "os", ".", "environ", ".", ...
A context manager which activates the virtualenv. :param list extra_dists: Paths added to the context after the virtualenv is activated. This context manager sets the following environment variables: * `PYTHONUSERBASE` * `VIRTUAL_ENV` * `PYTHONIOENCODING` ...
[ "A", "context", "manager", "which", "activates", "the", "virtualenv", "." ]
c1a7cd63c490ed7fbecb7714fd5590d2609366de
https://github.com/sarugaku/mork/blob/c1a7cd63c490ed7fbecb7714fd5590d2609366de/src/mork/virtualenv.py#L533-L585
train
58,415
sarugaku/mork
src/mork/virtualenv.py
VirtualEnv.get_monkeypatched_pathset
def get_monkeypatched_pathset(self): """Returns a monkeypatched `UninstallPathset` for using to uninstall packages from the virtualenv :return: A patched `UninstallPathset` which enables uninstallation of venv packages :rtype: :class:`pip._internal.req.req_uninstall.UninstallPathset` ""...
python
def get_monkeypatched_pathset(self): """Returns a monkeypatched `UninstallPathset` for using to uninstall packages from the virtualenv :return: A patched `UninstallPathset` which enables uninstallation of venv packages :rtype: :class:`pip._internal.req.req_uninstall.UninstallPathset` ""...
[ "def", "get_monkeypatched_pathset", "(", "self", ")", ":", "from", "pip_shims", ".", "shims", "import", "InstallRequirement", "# Determine the path to the uninstall module name based on the install module name", "uninstall_path", "=", "InstallRequirement", ".", "__module__", ".",...
Returns a monkeypatched `UninstallPathset` for using to uninstall packages from the virtualenv :return: A patched `UninstallPathset` which enables uninstallation of venv packages :rtype: :class:`pip._internal.req.req_uninstall.UninstallPathset`
[ "Returns", "a", "monkeypatched", "UninstallPathset", "for", "using", "to", "uninstall", "packages", "from", "the", "virtualenv" ]
c1a7cd63c490ed7fbecb7714fd5590d2609366de
https://github.com/sarugaku/mork/blob/c1a7cd63c490ed7fbecb7714fd5590d2609366de/src/mork/virtualenv.py#L632-L648
train
58,416
sarugaku/mork
src/mork/virtualenv.py
VirtualEnv.uninstall
def uninstall(self, pkgname, *args, **kwargs): """A context manager which allows uninstallation of packages from the virtualenv :param str pkgname: The name of a package to uninstall >>> venv = VirtualEnv("/path/to/venv/root") >>> with venv.uninstall("pytz", auto_confirm=True, verbose=...
python
def uninstall(self, pkgname, *args, **kwargs): """A context manager which allows uninstallation of packages from the virtualenv :param str pkgname: The name of a package to uninstall >>> venv = VirtualEnv("/path/to/venv/root") >>> with venv.uninstall("pytz", auto_confirm=True, verbose=...
[ "def", "uninstall", "(", "self", ",", "pkgname", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "auto_confirm", "=", "kwargs", ".", "pop", "(", "\"auto_confirm\"", ",", "True", ")", "verbose", "=", "kwargs", ".", "pop", "(", "\"verbose\"", ",", ...
A context manager which allows uninstallation of packages from the virtualenv :param str pkgname: The name of a package to uninstall >>> venv = VirtualEnv("/path/to/venv/root") >>> with venv.uninstall("pytz", auto_confirm=True, verbose=False) as uninstaller: cleaned = uninstall...
[ "A", "context", "manager", "which", "allows", "uninstallation", "of", "packages", "from", "the", "virtualenv" ]
c1a7cd63c490ed7fbecb7714fd5590d2609366de
https://github.com/sarugaku/mork/blob/c1a7cd63c490ed7fbecb7714fd5590d2609366de/src/mork/virtualenv.py#L651-L683
train
58,417
brmscheiner/ideogram
ideogram/polarfract/polarfract.py
getRootNode
def getRootNode(nodes): '''Return the node with the most children''' max = 0 root = None for i in nodes: if len(i.children) > max: max = len(i.children) root = i return root
python
def getRootNode(nodes): '''Return the node with the most children''' max = 0 root = None for i in nodes: if len(i.children) > max: max = len(i.children) root = i return root
[ "def", "getRootNode", "(", "nodes", ")", ":", "max", "=", "0", "root", "=", "None", "for", "i", "in", "nodes", ":", "if", "len", "(", "i", ".", "children", ")", ">", "max", ":", "max", "=", "len", "(", "i", ".", "children", ")", "root", "=", ...
Return the node with the most children
[ "Return", "the", "node", "with", "the", "most", "children" ]
422bf566c51fd56f7bbb6e75b16d18d52b4c7568
https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/polarfract/polarfract.py#L34-L42
train
58,418
brmscheiner/ideogram
ideogram/polarfract/polarfract.py
getNextNode
def getNextNode(nodes,usednodes,parent): '''Get next node in a breadth-first traversal of nodes that have not been used yet''' for e in edges: if e.source==parent: if e.target in usednodes: x = e.target break elif e.target==parent: if e.sou...
python
def getNextNode(nodes,usednodes,parent): '''Get next node in a breadth-first traversal of nodes that have not been used yet''' for e in edges: if e.source==parent: if e.target in usednodes: x = e.target break elif e.target==parent: if e.sou...
[ "def", "getNextNode", "(", "nodes", ",", "usednodes", ",", "parent", ")", ":", "for", "e", "in", "edges", ":", "if", "e", ".", "source", "==", "parent", ":", "if", "e", ".", "target", "in", "usednodes", ":", "x", "=", "e", ".", "target", "break", ...
Get next node in a breadth-first traversal of nodes that have not been used yet
[ "Get", "next", "node", "in", "a", "breadth", "-", "first", "traversal", "of", "nodes", "that", "have", "not", "been", "used", "yet" ]
422bf566c51fd56f7bbb6e75b16d18d52b4c7568
https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/polarfract/polarfract.py#L44-L55
train
58,419
brmscheiner/ideogram
ideogram/polarfract/polarfract.py
Circle.calcPosition
def calcPosition(self,parent_circle): ''' Position the circle tangent to the parent circle with the line connecting the centers of the two circles meeting the x axis at angle theta. ''' if r not in self: raise AttributeError("radius must be calculated before position.") if theta not ...
python
def calcPosition(self,parent_circle): ''' Position the circle tangent to the parent circle with the line connecting the centers of the two circles meeting the x axis at angle theta. ''' if r not in self: raise AttributeError("radius must be calculated before position.") if theta not ...
[ "def", "calcPosition", "(", "self", ",", "parent_circle", ")", ":", "if", "r", "not", "in", "self", ":", "raise", "AttributeError", "(", "\"radius must be calculated before position.\"", ")", "if", "theta", "not", "in", "self", ":", "raise", "AttributeError", "(...
Position the circle tangent to the parent circle with the line connecting the centers of the two circles meeting the x axis at angle theta.
[ "Position", "the", "circle", "tangent", "to", "the", "parent", "circle", "with", "the", "line", "connecting", "the", "centers", "of", "the", "two", "circles", "meeting", "the", "x", "axis", "at", "angle", "theta", "." ]
422bf566c51fd56f7bbb6e75b16d18d52b4c7568
https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/polarfract/polarfract.py#L23-L32
train
58,420
foobarbecue/afterflight
afterflight/progressbarupload/views.py
upload_progress
def upload_progress(request): """ Used by Ajax calls Return the upload progress and total length values """ if 'X-Progress-ID' in request.GET: progress_id = request.GET['X-Progress-ID'] elif 'X-Progress-ID' in request.META: progress_id = request.META['X-Progress-ID'] if prog...
python
def upload_progress(request): """ Used by Ajax calls Return the upload progress and total length values """ if 'X-Progress-ID' in request.GET: progress_id = request.GET['X-Progress-ID'] elif 'X-Progress-ID' in request.META: progress_id = request.META['X-Progress-ID'] if prog...
[ "def", "upload_progress", "(", "request", ")", ":", "if", "'X-Progress-ID'", "in", "request", ".", "GET", ":", "progress_id", "=", "request", ".", "GET", "[", "'X-Progress-ID'", "]", "elif", "'X-Progress-ID'", "in", "request", ".", "META", ":", "progress_id", ...
Used by Ajax calls Return the upload progress and total length values
[ "Used", "by", "Ajax", "calls" ]
7085f719593f88999dce93f35caec5f15d2991b6
https://github.com/foobarbecue/afterflight/blob/7085f719593f88999dce93f35caec5f15d2991b6/afterflight/progressbarupload/views.py#L8-L21
train
58,421
clinicedc/edc-model-fields
edc_model_fields/fields/userfield.py
UserField.pre_save
def pre_save(self, model_instance, add): """Updates username created on ADD only.""" value = super(UserField, self).pre_save(model_instance, add) if not value and not add: # fall back to OS user if not accessing through browser # better than nothing ... value ...
python
def pre_save(self, model_instance, add): """Updates username created on ADD only.""" value = super(UserField, self).pre_save(model_instance, add) if not value and not add: # fall back to OS user if not accessing through browser # better than nothing ... value ...
[ "def", "pre_save", "(", "self", ",", "model_instance", ",", "add", ")", ":", "value", "=", "super", "(", "UserField", ",", "self", ")", ".", "pre_save", "(", "model_instance", ",", "add", ")", "if", "not", "value", "and", "not", "add", ":", "# fall bac...
Updates username created on ADD only.
[ "Updates", "username", "created", "on", "ADD", "only", "." ]
fac30a71163760edd57329f26b48095eb0a0dd5b
https://github.com/clinicedc/edc-model-fields/blob/fac30a71163760edd57329f26b48095eb0a0dd5b/edc_model_fields/fields/userfield.py#L19-L28
train
58,422
envi-idl/envipyarclib
envipyarclib/system.py
sys_toolbox_dir
def sys_toolbox_dir(): """ Returns this site-package esri toolbox directory. """ return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'esri', 'toolboxes')
python
def sys_toolbox_dir(): """ Returns this site-package esri toolbox directory. """ return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'esri', 'toolboxes')
[ "def", "sys_toolbox_dir", "(", ")", ":", "return", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "__file__", ")", ")", ",", "'esri'", ",", "'toolboxes'", ")" ]
Returns this site-package esri toolbox directory.
[ "Returns", "this", "site", "-", "package", "esri", "toolbox", "directory", "." ]
90135652510c3d53c5f51177252c1fea2639bf22
https://github.com/envi-idl/envipyarclib/blob/90135652510c3d53c5f51177252c1fea2639bf22/envipyarclib/system.py#L10-L14
train
58,423
envi-idl/envipyarclib
envipyarclib/system.py
appdata_roaming_dir
def appdata_roaming_dir(): """Returns the roaming AppData directory for the installed ArcGIS Desktop.""" install = arcpy.GetInstallInfo('desktop') app_data = arcpy.GetSystemEnvironment("APPDATA") product_dir = ''.join((install['ProductName'], major_version())) return os.path.join(app_data, 'ESRI', p...
python
def appdata_roaming_dir(): """Returns the roaming AppData directory for the installed ArcGIS Desktop.""" install = arcpy.GetInstallInfo('desktop') app_data = arcpy.GetSystemEnvironment("APPDATA") product_dir = ''.join((install['ProductName'], major_version())) return os.path.join(app_data, 'ESRI', p...
[ "def", "appdata_roaming_dir", "(", ")", ":", "install", "=", "arcpy", ".", "GetInstallInfo", "(", "'desktop'", ")", "app_data", "=", "arcpy", ".", "GetSystemEnvironment", "(", "\"APPDATA\"", ")", "product_dir", "=", "''", ".", "join", "(", "(", "install", "[...
Returns the roaming AppData directory for the installed ArcGIS Desktop.
[ "Returns", "the", "roaming", "AppData", "directory", "for", "the", "installed", "ArcGIS", "Desktop", "." ]
90135652510c3d53c5f51177252c1fea2639bf22
https://github.com/envi-idl/envipyarclib/blob/90135652510c3d53c5f51177252c1fea2639bf22/envipyarclib/system.py#L20-L25
train
58,424
silver-castle/mach9
mach9/app.py
Mach9.add_route
def add_route(self, handler, uri, methods=frozenset({'GET'}), host=None, strict_slashes=False): '''A helper method to register class instance or functions as a handler to the application url routes. :param handler: function or class instance :param uri: path of...
python
def add_route(self, handler, uri, methods=frozenset({'GET'}), host=None, strict_slashes=False): '''A helper method to register class instance or functions as a handler to the application url routes. :param handler: function or class instance :param uri: path of...
[ "def", "add_route", "(", "self", ",", "handler", ",", "uri", ",", "methods", "=", "frozenset", "(", "{", "'GET'", "}", ")", ",", "host", "=", "None", ",", "strict_slashes", "=", "False", ")", ":", "stream", "=", "False", "# Handle HTTPMethodView differentl...
A helper method to register class instance or functions as a handler to the application url routes. :param handler: function or class instance :param uri: path of the URL :param methods: list or tuple of methods allowed, these are overridden if using a HT...
[ "A", "helper", "method", "to", "register", "class", "instance", "or", "functions", "as", "a", "handler", "to", "the", "application", "url", "routes", "." ]
7a623aab3c70d89d36ade6901b6307e115400c5e
https://github.com/silver-castle/mach9/blob/7a623aab3c70d89d36ade6901b6307e115400c5e/mach9/app.py#L159-L195
train
58,425
silver-castle/mach9
mach9/app.py
Mach9.middleware
def middleware(self, middleware_or_request): '''Decorate and register middleware to be called before a request. Can either be called as @app.middleware or @app.middleware('request') ''' def register_middleware(middleware, attach_to='request'): if attach_to == 'request': ...
python
def middleware(self, middleware_or_request): '''Decorate and register middleware to be called before a request. Can either be called as @app.middleware or @app.middleware('request') ''' def register_middleware(middleware, attach_to='request'): if attach_to == 'request': ...
[ "def", "middleware", "(", "self", ",", "middleware_or_request", ")", ":", "def", "register_middleware", "(", "middleware", ",", "attach_to", "=", "'request'", ")", ":", "if", "attach_to", "==", "'request'", ":", "self", ".", "request_middleware", ".", "append", ...
Decorate and register middleware to be called before a request. Can either be called as @app.middleware or @app.middleware('request')
[ "Decorate", "and", "register", "middleware", "to", "be", "called", "before", "a", "request", ".", "Can", "either", "be", "called", "as" ]
7a623aab3c70d89d36ade6901b6307e115400c5e
https://github.com/silver-castle/mach9/blob/7a623aab3c70d89d36ade6901b6307e115400c5e/mach9/app.py#L220-L237
train
58,426
silver-castle/mach9
mach9/app.py
Mach9.static
def static(self, uri, file_or_directory, pattern=r'/?.+', use_modified_since=True, use_content_range=False): '''Register a root to serve files from. The input can either be a file or a directory. See ''' static_register(self, uri, file_or_directory, pattern, ...
python
def static(self, uri, file_or_directory, pattern=r'/?.+', use_modified_since=True, use_content_range=False): '''Register a root to serve files from. The input can either be a file or a directory. See ''' static_register(self, uri, file_or_directory, pattern, ...
[ "def", "static", "(", "self", ",", "uri", ",", "file_or_directory", ",", "pattern", "=", "r'/?.+'", ",", "use_modified_since", "=", "True", ",", "use_content_range", "=", "False", ")", ":", "static_register", "(", "self", ",", "uri", ",", "file_or_directory", ...
Register a root to serve files from. The input can either be a file or a directory. See
[ "Register", "a", "root", "to", "serve", "files", "from", ".", "The", "input", "can", "either", "be", "a", "file", "or", "a", "directory", ".", "See" ]
7a623aab3c70d89d36ade6901b6307e115400c5e
https://github.com/silver-castle/mach9/blob/7a623aab3c70d89d36ade6901b6307e115400c5e/mach9/app.py#L240-L246
train
58,427
silver-castle/mach9
mach9/app.py
Mach9.url_for
def url_for(self, view_name: str, **kwargs): '''Build a URL based on a view name and the values provided. In order to build a URL, all request parameters must be supplied as keyword arguments, and each parameter must pass the test for the specified parameter type. If these conditions ar...
python
def url_for(self, view_name: str, **kwargs): '''Build a URL based on a view name and the values provided. In order to build a URL, all request parameters must be supplied as keyword arguments, and each parameter must pass the test for the specified parameter type. If these conditions ar...
[ "def", "url_for", "(", "self", ",", "view_name", ":", "str", ",", "*", "*", "kwargs", ")", ":", "# find the route by the supplied view name", "uri", ",", "route", "=", "self", ".", "router", ".", "find_route_by_view_name", "(", "view_name", ")", "if", "not", ...
Build a URL based on a view name and the values provided. In order to build a URL, all request parameters must be supplied as keyword arguments, and each parameter must pass the test for the specified parameter type. If these conditions are not met, a `URLBuildError` will be thrown. ...
[ "Build", "a", "URL", "based", "on", "a", "view", "name", "and", "the", "values", "provided", "." ]
7a623aab3c70d89d36ade6901b6307e115400c5e
https://github.com/silver-castle/mach9/blob/7a623aab3c70d89d36ade6901b6307e115400c5e/mach9/app.py#L265-L359
train
58,428
rajeevs1992/pyhealthvault
src/healthvaultlib/hvcrypto.py
HVCrypto.i2osp
def i2osp(self, long_integer, block_size): 'Convert a long integer into an octet string.' hex_string = '%X' % long_integer if len(hex_string) > 2 * block_size: raise ValueError('integer %i too large to encode in %i octets' % (long_integer, block_size)) return a2b_hex(hex_stri...
python
def i2osp(self, long_integer, block_size): 'Convert a long integer into an octet string.' hex_string = '%X' % long_integer if len(hex_string) > 2 * block_size: raise ValueError('integer %i too large to encode in %i octets' % (long_integer, block_size)) return a2b_hex(hex_stri...
[ "def", "i2osp", "(", "self", ",", "long_integer", ",", "block_size", ")", ":", "hex_string", "=", "'%X'", "%", "long_integer", "if", "len", "(", "hex_string", ")", ">", "2", "*", "block_size", ":", "raise", "ValueError", "(", "'integer %i too large to encode i...
Convert a long integer into an octet string.
[ "Convert", "a", "long", "integer", "into", "an", "octet", "string", "." ]
2b6fa7c1687300bcc2e501368883fbb13dc80495
https://github.com/rajeevs1992/pyhealthvault/blob/2b6fa7c1687300bcc2e501368883fbb13dc80495/src/healthvaultlib/hvcrypto.py#L44-L49
train
58,429
callowayproject/Calloway
calloway/apps/django_ext/markov.py
MarkovChain.random_output
def random_output(self, max=100): """ Generate a list of elements from the markov chain. The `max` value is in place in order to prevent excessive iteration. """ output = [] item1 = item2 = MarkovChain.START for i in range(max-3): item3 = self[(item1, item...
python
def random_output(self, max=100): """ Generate a list of elements from the markov chain. The `max` value is in place in order to prevent excessive iteration. """ output = [] item1 = item2 = MarkovChain.START for i in range(max-3): item3 = self[(item1, item...
[ "def", "random_output", "(", "self", ",", "max", "=", "100", ")", ":", "output", "=", "[", "]", "item1", "=", "item2", "=", "MarkovChain", ".", "START", "for", "i", "in", "range", "(", "max", "-", "3", ")", ":", "item3", "=", "self", "[", "(", ...
Generate a list of elements from the markov chain. The `max` value is in place in order to prevent excessive iteration.
[ "Generate", "a", "list", "of", "elements", "from", "the", "markov", "chain", ".", "The", "max", "value", "is", "in", "place", "in", "order", "to", "prevent", "excessive", "iteration", "." ]
d22e98d41fbd298ab6393ba7bd84a75528be9f81
https://github.com/callowayproject/Calloway/blob/d22e98d41fbd298ab6393ba7bd84a75528be9f81/calloway/apps/django_ext/markov.py#L51-L64
train
58,430
fredericklussier/TinyPeriodicTask
tinyPeriodicTask/TinyPeriodicTask.py
TinyPeriodicTask.start
def start(self): """ Start the periodic runner """ if self._isRunning: return if self._cease.is_set(): self._cease.clear() # restart class Runner(threading.Thread): @classmethod def run(cls): nextRunAt = c...
python
def start(self): """ Start the periodic runner """ if self._isRunning: return if self._cease.is_set(): self._cease.clear() # restart class Runner(threading.Thread): @classmethod def run(cls): nextRunAt = c...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "_isRunning", ":", "return", "if", "self", ".", "_cease", ".", "is_set", "(", ")", ":", "self", ".", "_cease", ".", "clear", "(", ")", "# restart", "class", "Runner", "(", "threading", ".", ...
Start the periodic runner
[ "Start", "the", "periodic", "runner" ]
be79e349bf6f73c1ba7576eb5acc6e812ffcfe36
https://github.com/fredericklussier/TinyPeriodicTask/blob/be79e349bf6f73c1ba7576eb5acc6e812ffcfe36/tinyPeriodicTask/TinyPeriodicTask.py#L139-L167
train
58,431
fredericklussier/TinyPeriodicTask
tinyPeriodicTask/TinyPeriodicTask.py
TinyPeriodicTask.useThis
def useThis(self, *args, **kwargs): """ Change parameter of the callback function. :param *args, **kwargs: parameter(s) to use when executing the callback function. """ self._callback = functools.partial(self._callback, *args, **kwargs)
python
def useThis(self, *args, **kwargs): """ Change parameter of the callback function. :param *args, **kwargs: parameter(s) to use when executing the callback function. """ self._callback = functools.partial(self._callback, *args, **kwargs)
[ "def", "useThis", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_callback", "=", "functools", ".", "partial", "(", "self", ".", "_callback", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Change parameter of the callback function. :param *args, **kwargs: parameter(s) to use when executing the callback function.
[ "Change", "parameter", "of", "the", "callback", "function", "." ]
be79e349bf6f73c1ba7576eb5acc6e812ffcfe36
https://github.com/fredericklussier/TinyPeriodicTask/blob/be79e349bf6f73c1ba7576eb5acc6e812ffcfe36/tinyPeriodicTask/TinyPeriodicTask.py#L172-L179
train
58,432
fredericklussier/TinyPeriodicTask
tinyPeriodicTask/TinyPeriodicTask.py
TinyPeriodicTask.stop
def stop(self): """ Stop the periodic runner """ self._cease.set() time.sleep(0.1) # let the thread closing correctly. self._isRunning = False
python
def stop(self): """ Stop the periodic runner """ self._cease.set() time.sleep(0.1) # let the thread closing correctly. self._isRunning = False
[ "def", "stop", "(", "self", ")", ":", "self", ".", "_cease", ".", "set", "(", ")", "time", ".", "sleep", "(", "0.1", ")", "# let the thread closing correctly.", "self", ".", "_isRunning", "=", "False" ]
Stop the periodic runner
[ "Stop", "the", "periodic", "runner" ]
be79e349bf6f73c1ba7576eb5acc6e812ffcfe36
https://github.com/fredericklussier/TinyPeriodicTask/blob/be79e349bf6f73c1ba7576eb5acc6e812ffcfe36/tinyPeriodicTask/TinyPeriodicTask.py#L181-L187
train
58,433
AtomHash/evernode
evernode/middleware/session_middleware.py
SessionMiddleware.condition
def condition(self) -> bool: """ check JWT, then check session for validity """ jwt = JWT() if jwt.verify_http_auth_token(): if not current_app.config['AUTH']['FAST_SESSIONS']: session = SessionModel.where_session_id( jwt.data['session_id']) ...
python
def condition(self) -> bool: """ check JWT, then check session for validity """ jwt = JWT() if jwt.verify_http_auth_token(): if not current_app.config['AUTH']['FAST_SESSIONS']: session = SessionModel.where_session_id( jwt.data['session_id']) ...
[ "def", "condition", "(", "self", ")", "->", "bool", ":", "jwt", "=", "JWT", "(", ")", "if", "jwt", ".", "verify_http_auth_token", "(", ")", ":", "if", "not", "current_app", ".", "config", "[", "'AUTH'", "]", "[", "'FAST_SESSIONS'", "]", ":", "session",...
check JWT, then check session for validity
[ "check", "JWT", "then", "check", "session", "for", "validity" ]
b2fb91555fb937a3f3eba41db56dee26f9b034be
https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/middleware/session_middleware.py#L13-L24
train
58,434
vicalloy/lbutils
lbutils/widgets.py
render_hidden
def render_hidden(name, value): """ render as hidden widget """ if isinstance(value, list): return MultipleHiddenInput().render(name, value) return HiddenInput().render(name, value)
python
def render_hidden(name, value): """ render as hidden widget """ if isinstance(value, list): return MultipleHiddenInput().render(name, value) return HiddenInput().render(name, value)
[ "def", "render_hidden", "(", "name", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "list", ")", ":", "return", "MultipleHiddenInput", "(", ")", ".", "render", "(", "name", ",", "value", ")", "return", "HiddenInput", "(", ")", ".", "ren...
render as hidden widget
[ "render", "as", "hidden", "widget" ]
66ae7e73bc939f073cdc1b91602a95e67caf4ba6
https://github.com/vicalloy/lbutils/blob/66ae7e73bc939f073cdc1b91602a95e67caf4ba6/lbutils/widgets.py#L71-L75
train
58,435
erikvw/django-collect-offline-files
django_collect_offline_files/file_queues/deserialize_transactions_file_queue.py
DeserializeTransactionsFileQueue.next_task
def next_task(self, item, raise_exceptions=None, **kwargs): """Deserializes all transactions for this batch and archives the file. """ filename = os.path.basename(item) batch = self.get_batch(filename) tx_deserializer = self.tx_deserializer_cls( allow_self=sel...
python
def next_task(self, item, raise_exceptions=None, **kwargs): """Deserializes all transactions for this batch and archives the file. """ filename = os.path.basename(item) batch = self.get_batch(filename) tx_deserializer = self.tx_deserializer_cls( allow_self=sel...
[ "def", "next_task", "(", "self", ",", "item", ",", "raise_exceptions", "=", "None", ",", "*", "*", "kwargs", ")", ":", "filename", "=", "os", ".", "path", ".", "basename", "(", "item", ")", "batch", "=", "self", ".", "get_batch", "(", "filename", ")"...
Deserializes all transactions for this batch and archives the file.
[ "Deserializes", "all", "transactions", "for", "this", "batch", "and", "archives", "the", "file", "." ]
78f61c823ea3926eb88206b019b5dca3c36017da
https://github.com/erikvw/django-collect-offline-files/blob/78f61c823ea3926eb88206b019b5dca3c36017da/django_collect_offline_files/file_queues/deserialize_transactions_file_queue.py#L25-L42
train
58,436
erikvw/django-collect-offline-files
django_collect_offline_files/file_queues/deserialize_transactions_file_queue.py
DeserializeTransactionsFileQueue.get_batch
def get_batch(self, filename=None): """Returns a batch instance given the filename. """ try: history = self.history_model.objects.get(filename=filename) except self.history_model.DoesNotExist as e: raise TransactionsFileQueueError( f"Batch history ...
python
def get_batch(self, filename=None): """Returns a batch instance given the filename. """ try: history = self.history_model.objects.get(filename=filename) except self.history_model.DoesNotExist as e: raise TransactionsFileQueueError( f"Batch history ...
[ "def", "get_batch", "(", "self", ",", "filename", "=", "None", ")", ":", "try", ":", "history", "=", "self", ".", "history_model", ".", "objects", ".", "get", "(", "filename", "=", "filename", ")", "except", "self", ".", "history_model", ".", "DoesNotExi...
Returns a batch instance given the filename.
[ "Returns", "a", "batch", "instance", "given", "the", "filename", "." ]
78f61c823ea3926eb88206b019b5dca3c36017da
https://github.com/erikvw/django-collect-offline-files/blob/78f61c823ea3926eb88206b019b5dca3c36017da/django_collect_offline_files/file_queues/deserialize_transactions_file_queue.py#L44-L60
train
58,437
MacHu-GWU/crawl_zillow-project
crawl_zillow/htmlparser.py
HTMLParser.get_items
def get_items(self, html): """ Get state, county, zipcode, address code from lists page. Example: target url: http://www.zillow.com/browse/homes/md/ <<<<<<< HEAD data: ``[(href, name), ...]`` ======= data: [(href, name)] >>>>>>> 4507a26c6cc47e0affe1f7000f912e...
python
def get_items(self, html): """ Get state, county, zipcode, address code from lists page. Example: target url: http://www.zillow.com/browse/homes/md/ <<<<<<< HEAD data: ``[(href, name), ...]`` ======= data: [(href, name)] >>>>>>> 4507a26c6cc47e0affe1f7000f912e...
[ "def", "get_items", "(", "self", ",", "html", ")", ":", "captcha_patterns", "=", "[", "\"https://www.google.com/recaptcha/api.js\"", ",", "\"I'm not a robot\"", "]", "for", "captcha_pattern", "in", "captcha_patterns", ":", "if", "captcha_pattern", "in", "html", ":", ...
Get state, county, zipcode, address code from lists page. Example: target url: http://www.zillow.com/browse/homes/md/ <<<<<<< HEAD data: ``[(href, name), ...]`` ======= data: [(href, name)] >>>>>>> 4507a26c6cc47e0affe1f7000f912e536c45212b
[ "Get", "state", "county", "zipcode", "address", "code", "from", "lists", "page", "." ]
c6d7ca8e4c80e7e7e963496433ef73df1413c16e
https://github.com/MacHu-GWU/crawl_zillow-project/blob/c6d7ca8e4c80e7e7e963496433ef73df1413c16e/crawl_zillow/htmlparser.py#L11-L39
train
58,438
asascience-open/paegan-transport
paegan/transport/models/behaviors/diel.py
Diel.get_time
def get_time(self, loc4d=None): """ Based on a Location4D object and this Diel object, calculate the time at which this Diel migration is actually happening """ if loc4d is None: raise ValueError("Location4D object can not be None") if self.pattern ==...
python
def get_time(self, loc4d=None): """ Based on a Location4D object and this Diel object, calculate the time at which this Diel migration is actually happening """ if loc4d is None: raise ValueError("Location4D object can not be None") if self.pattern ==...
[ "def", "get_time", "(", "self", ",", "loc4d", "=", "None", ")", ":", "if", "loc4d", "is", "None", ":", "raise", "ValueError", "(", "\"Location4D object can not be None\"", ")", "if", "self", ".", "pattern", "==", "self", ".", "PATTERN_CYCLE", ":", "c", "="...
Based on a Location4D object and this Diel object, calculate the time at which this Diel migration is actually happening
[ "Based", "on", "a", "Location4D", "object", "and", "this", "Diel", "object", "calculate", "the", "time", "at", "which", "this", "Diel", "migration", "is", "actually", "happening" ]
99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3
https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/models/behaviors/diel.py#L95-L116
train
58,439
asascience-open/paegan-transport
paegan/transport/models/behaviors/diel.py
Diel.move
def move(self, particle, u, v, w, modelTimestep, **kwargs): # If the particle is settled, don't move it anywhere if particle.settled: return { 'u': 0, 'v': 0, 'w': 0 } # If the particle is halted (but not settled), don't move it anywhere if particle.halted: retu...
python
def move(self, particle, u, v, w, modelTimestep, **kwargs): # If the particle is settled, don't move it anywhere if particle.settled: return { 'u': 0, 'v': 0, 'w': 0 } # If the particle is halted (but not settled), don't move it anywhere if particle.halted: retu...
[ "def", "move", "(", "self", ",", "particle", ",", "u", ",", "v", ",", "w", ",", "modelTimestep", ",", "*", "*", "kwargs", ")", ":", "# If the particle is settled, don't move it anywhere", "if", "particle", ".", "settled", ":", "return", "{", "'u'", ":", "0...
This only works if min is less than max. No checks are done here, so it should be done before calling this function.
[ "This", "only", "works", "if", "min", "is", "less", "than", "max", ".", "No", "checks", "are", "done", "here", "so", "it", "should", "be", "done", "before", "calling", "this", "function", "." ]
99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3
https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/models/behaviors/diel.py#L119-L186
train
58,440
helixyte/everest
everest/entities/base.py
RootAggregate.make_relationship_aggregate
def make_relationship_aggregate(self, relationship): """ Returns a new relationship aggregate for the given relationship. :param relationship: Instance of :class:`everest.entities.relationship.DomainRelationship`. """ if not self._session.IS_MANAGING_BACKREFERENCES: ...
python
def make_relationship_aggregate(self, relationship): """ Returns a new relationship aggregate for the given relationship. :param relationship: Instance of :class:`everest.entities.relationship.DomainRelationship`. """ if not self._session.IS_MANAGING_BACKREFERENCES: ...
[ "def", "make_relationship_aggregate", "(", "self", ",", "relationship", ")", ":", "if", "not", "self", ".", "_session", ".", "IS_MANAGING_BACKREFERENCES", ":", "relationship", ".", "direction", "&=", "~", "RELATIONSHIP_DIRECTIONS", ".", "REVERSE", "return", "Relatio...
Returns a new relationship aggregate for the given relationship. :param relationship: Instance of :class:`everest.entities.relationship.DomainRelationship`.
[ "Returns", "a", "new", "relationship", "aggregate", "for", "the", "given", "relationship", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/entities/base.py#L462-L471
train
58,441
helixyte/everest
everest/repositories/uow.py
UnitOfWork.register_new
def register_new(self, entity_class, entity): """ Registers the given entity for the given class as NEW. :raises ValueError: If the given entity already holds state that was created by another Unit Of Work. """ EntityState.manage(entity, self) EntityState.get_s...
python
def register_new(self, entity_class, entity): """ Registers the given entity for the given class as NEW. :raises ValueError: If the given entity already holds state that was created by another Unit Of Work. """ EntityState.manage(entity, self) EntityState.get_s...
[ "def", "register_new", "(", "self", ",", "entity_class", ",", "entity", ")", ":", "EntityState", ".", "manage", "(", "entity", ",", "self", ")", "EntityState", ".", "get_state", "(", "entity", ")", ".", "status", "=", "ENTITY_STATUS", ".", "NEW", "self", ...
Registers the given entity for the given class as NEW. :raises ValueError: If the given entity already holds state that was created by another Unit Of Work.
[ "Registers", "the", "given", "entity", "for", "the", "given", "class", "as", "NEW", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/uow.py#L31-L40
train
58,442
helixyte/everest
everest/repositories/uow.py
UnitOfWork.register_clean
def register_clean(self, entity_class, entity): """ Registers the given entity for the given class as CLEAN. :returns: Cloned entity. """ EntityState.manage(entity, self) EntityState.get_state(entity).status = ENTITY_STATUS.CLEAN self.__entity_set_map[entity_clas...
python
def register_clean(self, entity_class, entity): """ Registers the given entity for the given class as CLEAN. :returns: Cloned entity. """ EntityState.manage(entity, self) EntityState.get_state(entity).status = ENTITY_STATUS.CLEAN self.__entity_set_map[entity_clas...
[ "def", "register_clean", "(", "self", ",", "entity_class", ",", "entity", ")", ":", "EntityState", ".", "manage", "(", "entity", ",", "self", ")", "EntityState", ".", "get_state", "(", "entity", ")", ".", "status", "=", "ENTITY_STATUS", ".", "CLEAN", "self...
Registers the given entity for the given class as CLEAN. :returns: Cloned entity.
[ "Registers", "the", "given", "entity", "for", "the", "given", "class", "as", "CLEAN", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/uow.py#L42-L50
train
58,443
helixyte/everest
everest/repositories/uow.py
UnitOfWork.register_deleted
def register_deleted(self, entity_class, entity): """ Registers the given entity for the given class as DELETED. :raises ValueError: If the given entity already holds state that was created by another Unit Of Work. """ EntityState.manage(entity, self) EntitySta...
python
def register_deleted(self, entity_class, entity): """ Registers the given entity for the given class as DELETED. :raises ValueError: If the given entity already holds state that was created by another Unit Of Work. """ EntityState.manage(entity, self) EntitySta...
[ "def", "register_deleted", "(", "self", ",", "entity_class", ",", "entity", ")", ":", "EntityState", ".", "manage", "(", "entity", ",", "self", ")", "EntityState", ".", "get_state", "(", "entity", ")", ".", "status", "=", "ENTITY_STATUS", ".", "DELETED", "...
Registers the given entity for the given class as DELETED. :raises ValueError: If the given entity already holds state that was created by another Unit Of Work.
[ "Registers", "the", "given", "entity", "for", "the", "given", "class", "as", "DELETED", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/uow.py#L52-L61
train
58,444
helixyte/everest
everest/repositories/uow.py
UnitOfWork.unregister
def unregister(self, entity_class, entity): """ Unregisters the given entity for the given class and discards its state information. """ EntityState.release(entity, self) self.__entity_set_map[entity_class].remove(entity)
python
def unregister(self, entity_class, entity): """ Unregisters the given entity for the given class and discards its state information. """ EntityState.release(entity, self) self.__entity_set_map[entity_class].remove(entity)
[ "def", "unregister", "(", "self", ",", "entity_class", ",", "entity", ")", ":", "EntityState", ".", "release", "(", "entity", ",", "self", ")", "self", ".", "__entity_set_map", "[", "entity_class", "]", ".", "remove", "(", "entity", ")" ]
Unregisters the given entity for the given class and discards its state information.
[ "Unregisters", "the", "given", "entity", "for", "the", "given", "class", "and", "discards", "its", "state", "information", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/uow.py#L63-L69
train
58,445
helixyte/everest
everest/repositories/uow.py
UnitOfWork.is_marked_new
def is_marked_new(self, entity): """ Checks if the given entity is marked with status NEW. Returns `False` if the entity has no state information. """ try: result = EntityState.get_state(entity).status == ENTITY_STATUS.NEW except ValueError: result...
python
def is_marked_new(self, entity): """ Checks if the given entity is marked with status NEW. Returns `False` if the entity has no state information. """ try: result = EntityState.get_state(entity).status == ENTITY_STATUS.NEW except ValueError: result...
[ "def", "is_marked_new", "(", "self", ",", "entity", ")", ":", "try", ":", "result", "=", "EntityState", ".", "get_state", "(", "entity", ")", ".", "status", "==", "ENTITY_STATUS", ".", "NEW", "except", "ValueError", ":", "result", "=", "False", "return", ...
Checks if the given entity is marked with status NEW. Returns `False` if the entity has no state information.
[ "Checks", "if", "the", "given", "entity", "is", "marked", "with", "status", "NEW", ".", "Returns", "False", "if", "the", "entity", "has", "no", "state", "information", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/uow.py#L78-L87
train
58,446
helixyte/everest
everest/repositories/uow.py
UnitOfWork.is_marked_deleted
def is_marked_deleted(self, entity): """ Checks if the given entity is marked with status DELETED. Returns `False` if the entity has no state information. """ try: result = EntityState.get_state(entity).status \ == E...
python
def is_marked_deleted(self, entity): """ Checks if the given entity is marked with status DELETED. Returns `False` if the entity has no state information. """ try: result = EntityState.get_state(entity).status \ == E...
[ "def", "is_marked_deleted", "(", "self", ",", "entity", ")", ":", "try", ":", "result", "=", "EntityState", ".", "get_state", "(", "entity", ")", ".", "status", "==", "ENTITY_STATUS", ".", "DELETED", "except", "ValueError", ":", "result", "=", "False", "re...
Checks if the given entity is marked with status DELETED. Returns `False` if the entity has no state information.
[ "Checks", "if", "the", "given", "entity", "is", "marked", "with", "status", "DELETED", ".", "Returns", "False", "if", "the", "entity", "has", "no", "state", "information", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/uow.py#L89-L99
train
58,447
helixyte/everest
everest/repositories/uow.py
UnitOfWork.mark_clean
def mark_clean(self, entity): """ Marks the given entity as CLEAN. This is done when an entity is loaded fresh from the repository or after a commit. """ state = EntityState.get_state(entity) state.status = ENTITY_STATUS.CLEAN state.is_persisted = True
python
def mark_clean(self, entity): """ Marks the given entity as CLEAN. This is done when an entity is loaded fresh from the repository or after a commit. """ state = EntityState.get_state(entity) state.status = ENTITY_STATUS.CLEAN state.is_persisted = True
[ "def", "mark_clean", "(", "self", ",", "entity", ")", ":", "state", "=", "EntityState", ".", "get_state", "(", "entity", ")", "state", ".", "status", "=", "ENTITY_STATUS", ".", "CLEAN", "state", ".", "is_persisted", "=", "True" ]
Marks the given entity as CLEAN. This is done when an entity is loaded fresh from the repository or after a commit.
[ "Marks", "the", "given", "entity", "as", "CLEAN", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/uow.py#L130-L139
train
58,448
helixyte/everest
everest/repositories/uow.py
UnitOfWork.iterator
def iterator(self): """ Returns an iterator over all entity states held by this Unit Of Work. """ # FIXME: There is no dependency tracking; objects are iterated in # random order. for ent_cls in list(self.__entity_set_map.keys()): for ent in self.__enti...
python
def iterator(self): """ Returns an iterator over all entity states held by this Unit Of Work. """ # FIXME: There is no dependency tracking; objects are iterated in # random order. for ent_cls in list(self.__entity_set_map.keys()): for ent in self.__enti...
[ "def", "iterator", "(", "self", ")", ":", "# FIXME: There is no dependency tracking; objects are iterated in", "# random order.", "for", "ent_cls", "in", "list", "(", "self", ".", "__entity_set_map", ".", "keys", "(", ")", ")", ":", "for", "ent", "in", "self"...
Returns an iterator over all entity states held by this Unit Of Work.
[ "Returns", "an", "iterator", "over", "all", "entity", "states", "held", "by", "this", "Unit", "Of", "Work", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/uow.py#L203-L211
train
58,449
AtomHash/evernode
evernode/classes/form_data.py
FormData.file_save
def file_save(self, name, filename=None, folder="", keep_ext=True) -> bool: """ Easy save of a file """ if name in self.files: file_object = self.files[name] clean_filename = secure_filename(file_object.filename) if filename is not None and keep_ext: ...
python
def file_save(self, name, filename=None, folder="", keep_ext=True) -> bool: """ Easy save of a file """ if name in self.files: file_object = self.files[name] clean_filename = secure_filename(file_object.filename) if filename is not None and keep_ext: ...
[ "def", "file_save", "(", "self", ",", "name", ",", "filename", "=", "None", ",", "folder", "=", "\"\"", ",", "keep_ext", "=", "True", ")", "->", "bool", ":", "if", "name", "in", "self", ".", "files", ":", "file_object", "=", "self", ".", "files", "...
Easy save of a file
[ "Easy", "save", "of", "a", "file" ]
b2fb91555fb937a3f3eba41db56dee26f9b034be
https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/form_data.py#L48-L61
train
58,450
AtomHash/evernode
evernode/classes/form_data.py
FormData.parse
def parse(self, fail_callback=None): """ Parse text fields and file fields for values and files """ # get text fields for field in self.field_arguments: self.values[field['name']] = self.__get_value(field['name']) if self.values[field['name']] is None and field['requ...
python
def parse(self, fail_callback=None): """ Parse text fields and file fields for values and files """ # get text fields for field in self.field_arguments: self.values[field['name']] = self.__get_value(field['name']) if self.values[field['name']] is None and field['requ...
[ "def", "parse", "(", "self", ",", "fail_callback", "=", "None", ")", ":", "# get text fields\r", "for", "field", "in", "self", ".", "field_arguments", ":", "self", ".", "values", "[", "field", "[", "'name'", "]", "]", "=", "self", ".", "__get_value", "("...
Parse text fields and file fields for values and files
[ "Parse", "text", "fields", "and", "file", "fields", "for", "values", "and", "files" ]
b2fb91555fb937a3f3eba41db56dee26f9b034be
https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/form_data.py#L63-L78
train
58,451
AtomHash/evernode
evernode/classes/form_data.py
FormData.__get_value
def __get_value(self, field_name): """ Get request Json value by field name """ value = request.values.get(field_name) if value is None: if self.json_form_data is None: value = None elif field_name in self.json_form_data: value = sel...
python
def __get_value(self, field_name): """ Get request Json value by field name """ value = request.values.get(field_name) if value is None: if self.json_form_data is None: value = None elif field_name in self.json_form_data: value = sel...
[ "def", "__get_value", "(", "self", ",", "field_name", ")", ":", "value", "=", "request", ".", "values", ".", "get", "(", "field_name", ")", "if", "value", "is", "None", ":", "if", "self", ".", "json_form_data", "is", "None", ":", "value", "=", "None", ...
Get request Json value by field name
[ "Get", "request", "Json", "value", "by", "field", "name" ]
b2fb91555fb937a3f3eba41db56dee26f9b034be
https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/form_data.py#L80-L88
train
58,452
AtomHash/evernode
evernode/classes/form_data.py
FormData.__get_file
def __get_file(self, file): """ Get request file and do a security check """ file_object = None if file['name'] in request.files: file_object = request.files[file['name']] clean_filename = secure_filename(file_object.filename) if clean_filename == '': ...
python
def __get_file(self, file): """ Get request file and do a security check """ file_object = None if file['name'] in request.files: file_object = request.files[file['name']] clean_filename = secure_filename(file_object.filename) if clean_filename == '': ...
[ "def", "__get_file", "(", "self", ",", "file", ")", ":", "file_object", "=", "None", "if", "file", "[", "'name'", "]", "in", "request", ".", "files", ":", "file_object", "=", "request", ".", "files", "[", "file", "[", "'name'", "]", "]", "clean_filenam...
Get request file and do a security check
[ "Get", "request", "file", "and", "do", "a", "security", "check" ]
b2fb91555fb937a3f3eba41db56dee26f9b034be
https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/form_data.py#L90-L103
train
58,453
AtomHash/evernode
evernode/classes/form_data.py
FormData.__allowed_extension
def __allowed_extension(self, filename, extensions): """ Check allowed file extensions """ allowed_extensions = current_app.config['UPLOADS']['EXTENSIONS'] if extensions is not None: allowed_extensions = extensions return '.' in filename and filename.rsplit('.', 1)[1].lo...
python
def __allowed_extension(self, filename, extensions): """ Check allowed file extensions """ allowed_extensions = current_app.config['UPLOADS']['EXTENSIONS'] if extensions is not None: allowed_extensions = extensions return '.' in filename and filename.rsplit('.', 1)[1].lo...
[ "def", "__allowed_extension", "(", "self", ",", "filename", ",", "extensions", ")", ":", "allowed_extensions", "=", "current_app", ".", "config", "[", "'UPLOADS'", "]", "[", "'EXTENSIONS'", "]", "if", "extensions", "is", "not", "None", ":", "allowed_extensions",...
Check allowed file extensions
[ "Check", "allowed", "file", "extensions" ]
b2fb91555fb937a3f3eba41db56dee26f9b034be
https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/form_data.py#L105-L111
train
58,454
AtomHash/evernode
evernode/classes/form_data.py
FormData.__invalid_request
def __invalid_request(self, error): """ Error response on failure """ # TODO: make this modifiable error = { 'error': { 'message': error } } abort(JsonResponse(status_code=400, data=error))
python
def __invalid_request(self, error): """ Error response on failure """ # TODO: make this modifiable error = { 'error': { 'message': error } } abort(JsonResponse(status_code=400, data=error))
[ "def", "__invalid_request", "(", "self", ",", "error", ")", ":", "# TODO: make this modifiable\r", "error", "=", "{", "'error'", ":", "{", "'message'", ":", "error", "}", "}", "abort", "(", "JsonResponse", "(", "status_code", "=", "400", ",", "data", "=", ...
Error response on failure
[ "Error", "response", "on", "failure" ]
b2fb91555fb937a3f3eba41db56dee26f9b034be
https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/form_data.py#L113-L121
train
58,455
dariusbakunas/rawdisk
rawdisk/util/rawstruct.py
RawStruct.get_field
def get_field(self, offset, length, format): """Returns unpacked Python struct array. Args: offset (int): offset to byte array within structure length (int): how many bytes to unpack format (str): Python struct format string for unpacking See Also: ...
python
def get_field(self, offset, length, format): """Returns unpacked Python struct array. Args: offset (int): offset to byte array within structure length (int): how many bytes to unpack format (str): Python struct format string for unpacking See Also: ...
[ "def", "get_field", "(", "self", ",", "offset", ",", "length", ",", "format", ")", ":", "return", "struct", ".", "unpack", "(", "format", ",", "self", ".", "data", "[", "offset", ":", "offset", "+", "length", "]", ")", "[", "0", "]" ]
Returns unpacked Python struct array. Args: offset (int): offset to byte array within structure length (int): how many bytes to unpack format (str): Python struct format string for unpacking See Also: https://docs.python.org/2/library/struct.html#format-...
[ "Returns", "unpacked", "Python", "struct", "array", "." ]
1dc9d0b377fe5da3c406ccec4abc238c54167403
https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/util/rawstruct.py#L92-L103
train
58,456
dariusbakunas/rawdisk
rawdisk/util/rawstruct.py
RawStruct.export
def export(self, filename, offset=0, length=None): """Exports byte array to specified destination Args: filename (str): destination to output file offset (int): byte offset (default: 0) """ self.__validate_offset(filename=filename, offset=offset, length=length) ...
python
def export(self, filename, offset=0, length=None): """Exports byte array to specified destination Args: filename (str): destination to output file offset (int): byte offset (default: 0) """ self.__validate_offset(filename=filename, offset=offset, length=length) ...
[ "def", "export", "(", "self", ",", "filename", ",", "offset", "=", "0", ",", "length", "=", "None", ")", ":", "self", ".", "__validate_offset", "(", "filename", "=", "filename", ",", "offset", "=", "offset", ",", "length", "=", "length", ")", "with", ...
Exports byte array to specified destination Args: filename (str): destination to output file offset (int): byte offset (default: 0)
[ "Exports", "byte", "array", "to", "specified", "destination" ]
1dc9d0b377fe5da3c406ccec4abc238c54167403
https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/util/rawstruct.py#L206-L224
train
58,457
yougov/vr.common
vr/common/utils.py
tmpdir
def tmpdir(): """ Create a tempdir context for the cwd and remove it after. """ target = None try: with _tmpdir_extant() as target: yield target finally: if target is not None: shutil.rmtree(target, ignore_errors=True)
python
def tmpdir(): """ Create a tempdir context for the cwd and remove it after. """ target = None try: with _tmpdir_extant() as target: yield target finally: if target is not None: shutil.rmtree(target, ignore_errors=True)
[ "def", "tmpdir", "(", ")", ":", "target", "=", "None", "try", ":", "with", "_tmpdir_extant", "(", ")", "as", "target", ":", "yield", "target", "finally", ":", "if", "target", "is", "not", "None", ":", "shutil", ".", "rmtree", "(", "target", ",", "ign...
Create a tempdir context for the cwd and remove it after.
[ "Create", "a", "tempdir", "context", "for", "the", "cwd", "and", "remove", "it", "after", "." ]
ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4
https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/utils.py#L31-L41
train
58,458
yougov/vr.common
vr/common/utils.py
run
def run(command, verbose=False): """ Run a shell command. Capture the stdout and stderr as a single stream. Capture the status code. If verbose=True, then print command and the output to the terminal as it comes in. """ def do_nothing(*args, **kwargs): return None v_print = p...
python
def run(command, verbose=False): """ Run a shell command. Capture the stdout and stderr as a single stream. Capture the status code. If verbose=True, then print command and the output to the terminal as it comes in. """ def do_nothing(*args, **kwargs): return None v_print = p...
[ "def", "run", "(", "command", ",", "verbose", "=", "False", ")", ":", "def", "do_nothing", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "None", "v_print", "=", "print", "if", "verbose", "else", "do_nothing", "p", "=", "subprocess", ...
Run a shell command. Capture the stdout and stderr as a single stream. Capture the status code. If verbose=True, then print command and the output to the terminal as it comes in.
[ "Run", "a", "shell", "command", ".", "Capture", "the", "stdout", "and", "stderr", "as", "a", "single", "stream", ".", "Capture", "the", "status", "code", "." ]
ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4
https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/utils.py#L101-L136
train
58,459
yougov/vr.common
vr/common/utils.py
get_lxc_version
def get_lxc_version(): """ Asks the current host what version of LXC it has. Returns it as a string. If LXC is not installed, raises subprocess.CalledProcessError""" runner = functools.partial( subprocess.check_output, stderr=subprocess.STDOUT, universal_newlines=True, ) #...
python
def get_lxc_version(): """ Asks the current host what version of LXC it has. Returns it as a string. If LXC is not installed, raises subprocess.CalledProcessError""" runner = functools.partial( subprocess.check_output, stderr=subprocess.STDOUT, universal_newlines=True, ) #...
[ "def", "get_lxc_version", "(", ")", ":", "runner", "=", "functools", ".", "partial", "(", "subprocess", ".", "check_output", ",", "stderr", "=", "subprocess", ".", "STDOUT", ",", "universal_newlines", "=", "True", ",", ")", "# Old LXC had an lxc-version executable...
Asks the current host what version of LXC it has. Returns it as a string. If LXC is not installed, raises subprocess.CalledProcessError
[ "Asks", "the", "current", "host", "what", "version", "of", "LXC", "it", "has", ".", "Returns", "it", "as", "a", "string", ".", "If", "LXC", "is", "not", "installed", "raises", "subprocess", ".", "CalledProcessError" ]
ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4
https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/utils.py#L238-L257
train
58,460
RI-imaging/qpformat
qpformat/file_formats/single_hdf5_qpimage.py
SingleHdf5Qpimage.get_qpimage
def get_qpimage(self, idx=0): """Return background-corrected QPImage""" if self._bgdata: # The user has explicitly chosen different background data # using `get_qpimage_raw`. qpi = super(SingleHdf5Qpimage, self).get_qpimage() else: # We can use the...
python
def get_qpimage(self, idx=0): """Return background-corrected QPImage""" if self._bgdata: # The user has explicitly chosen different background data # using `get_qpimage_raw`. qpi = super(SingleHdf5Qpimage, self).get_qpimage() else: # We can use the...
[ "def", "get_qpimage", "(", "self", ",", "idx", "=", "0", ")", ":", "if", "self", ".", "_bgdata", ":", "# The user has explicitly chosen different background data", "# using `get_qpimage_raw`.", "qpi", "=", "super", "(", "SingleHdf5Qpimage", ",", "self", ")", ".", ...
Return background-corrected QPImage
[ "Return", "background", "-", "corrected", "QPImage" ]
364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb
https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/single_hdf5_qpimage.py#L25-L42
train
58,461
kmedian/ctmc
ctmc/simulate.py
simulate
def simulate(s0, transmat, steps=1): """Simulate the next state Parameters ---------- s0 : ndarray Vector with state variables at t=0 transmat : ndarray The estimated transition/stochastic matrix. steps : int (Default: 1) The number of steps to simulate model outputs a...
python
def simulate(s0, transmat, steps=1): """Simulate the next state Parameters ---------- s0 : ndarray Vector with state variables at t=0 transmat : ndarray The estimated transition/stochastic matrix. steps : int (Default: 1) The number of steps to simulate model outputs a...
[ "def", "simulate", "(", "s0", ",", "transmat", ",", "steps", "=", "1", ")", ":", "# Single-Step simulation", "if", "steps", "==", "1", ":", "return", "np", ".", "dot", "(", "s0", ",", "transmat", ")", "# Multi-Step simulation", "out", "=", "np", ".", "...
Simulate the next state Parameters ---------- s0 : ndarray Vector with state variables at t=0 transmat : ndarray The estimated transition/stochastic matrix. steps : int (Default: 1) The number of steps to simulate model outputs ahead. If steps>1 the a Mult-Step Sim...
[ "Simulate", "the", "next", "state" ]
e30747f797ce777fd2aaa1b7ee5a77e91d7db5e4
https://github.com/kmedian/ctmc/blob/e30747f797ce777fd2aaa1b7ee5a77e91d7db5e4/ctmc/simulate.py#L5-L40
train
58,462
RI-imaging/qpformat
qpformat/file_formats/single_npy_numpy.py
SingleNpyNumpy.verify
def verify(path): """Verify that `path` has a supported numpy file format""" path = pathlib.Path(path) valid = False if path.suffix == ".npy": try: nf = np.load(str(path), mmap_mode="r", allow_pickle=False) except (OSError, ValueError, IsADirectory...
python
def verify(path): """Verify that `path` has a supported numpy file format""" path = pathlib.Path(path) valid = False if path.suffix == ".npy": try: nf = np.load(str(path), mmap_mode="r", allow_pickle=False) except (OSError, ValueError, IsADirectory...
[ "def", "verify", "(", "path", ")", ":", "path", "=", "pathlib", ".", "Path", "(", "path", ")", "valid", "=", "False", "if", "path", ".", "suffix", "==", "\".npy\"", ":", "try", ":", "nf", "=", "np", ".", "load", "(", "str", "(", "path", ")", ",...
Verify that `path` has a supported numpy file format
[ "Verify", "that", "path", "has", "a", "supported", "numpy", "file", "format" ]
364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb
https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/single_npy_numpy.py#L46-L58
train
58,463
greenape/mktheapidocs
mktheapidocs/plugin.py
PyDocFile._get_stem
def _get_stem(self): """ Return the name of the file without it's extension. """ filename = os.path.basename(self.src_path) stem, ext = os.path.splitext(filename) return "index" if stem in ("index", "README", "__init__") else stem
python
def _get_stem(self): """ Return the name of the file without it's extension. """ filename = os.path.basename(self.src_path) stem, ext = os.path.splitext(filename) return "index" if stem in ("index", "README", "__init__") else stem
[ "def", "_get_stem", "(", "self", ")", ":", "filename", "=", "os", ".", "path", ".", "basename", "(", "self", ".", "src_path", ")", "stem", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "return", "\"index\"", "if", "stem",...
Return the name of the file without it's extension.
[ "Return", "the", "name", "of", "the", "file", "without", "it", "s", "extension", "." ]
a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7
https://github.com/greenape/mktheapidocs/blob/a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7/mktheapidocs/plugin.py#L21-L25
train
58,464
panyam/typecube
typecube/checkers.py
type_check
def type_check(thetype, data, bindings = None): """ Checks that a given bit of data conforms to the type provided """ if not bindings: bindings = Bindings() if isinstance(thetype, core.RecordType): for name,child in zip(thetype.child_names, thetype.child_types): value = data[name] ...
python
def type_check(thetype, data, bindings = None): """ Checks that a given bit of data conforms to the type provided """ if not bindings: bindings = Bindings() if isinstance(thetype, core.RecordType): for name,child in zip(thetype.child_names, thetype.child_types): value = data[name] ...
[ "def", "type_check", "(", "thetype", ",", "data", ",", "bindings", "=", "None", ")", ":", "if", "not", "bindings", ":", "bindings", "=", "Bindings", "(", ")", "if", "isinstance", "(", "thetype", ",", "core", ".", "RecordType", ")", ":", "for", "name", ...
Checks that a given bit of data conforms to the type provided
[ "Checks", "that", "a", "given", "bit", "of", "data", "conforms", "to", "the", "type", "provided" ]
e8fa235675b6497acd52c68286bb9e4aefc5c8d1
https://github.com/panyam/typecube/blob/e8fa235675b6497acd52c68286bb9e4aefc5c8d1/typecube/checkers.py#L41-L92
train
58,465
danbradham/scrim
scrim/utils.py
parse_setup
def parse_setup(filepath): '''Get the kwargs from the setup function in setup.py''' # TODO: Need to parse setup.cfg and merge with the data from below # Monkey patch setuptools.setup to capture keyword arguments setup_kwargs = {} def setup_interceptor(**kwargs): setup_kwargs.update(kwargs)...
python
def parse_setup(filepath): '''Get the kwargs from the setup function in setup.py''' # TODO: Need to parse setup.cfg and merge with the data from below # Monkey patch setuptools.setup to capture keyword arguments setup_kwargs = {} def setup_interceptor(**kwargs): setup_kwargs.update(kwargs)...
[ "def", "parse_setup", "(", "filepath", ")", ":", "# TODO: Need to parse setup.cfg and merge with the data from below", "# Monkey patch setuptools.setup to capture keyword arguments", "setup_kwargs", "=", "{", "}", "def", "setup_interceptor", "(", "*", "*", "kwargs", ")", ":", ...
Get the kwargs from the setup function in setup.py
[ "Get", "the", "kwargs", "from", "the", "setup", "function", "in", "setup", ".", "py" ]
982a5db1db6e4ef40267f15642af2c7ea0e803ae
https://github.com/danbradham/scrim/blob/982a5db1db6e4ef40267f15642af2c7ea0e803ae/scrim/utils.py#L79-L101
train
58,466
danbradham/scrim
scrim/utils.py
get_console_scripts
def get_console_scripts(setup_data): '''Parse and return a list of console_scripts from setup_data''' # TODO: support ini format of entry_points # TODO: support setup.cfg entry_points as available in pbr if 'entry_points' not in setup_data: return [] console_scripts = setup_data['entry_po...
python
def get_console_scripts(setup_data): '''Parse and return a list of console_scripts from setup_data''' # TODO: support ini format of entry_points # TODO: support setup.cfg entry_points as available in pbr if 'entry_points' not in setup_data: return [] console_scripts = setup_data['entry_po...
[ "def", "get_console_scripts", "(", "setup_data", ")", ":", "# TODO: support ini format of entry_points", "# TODO: support setup.cfg entry_points as available in pbr", "if", "'entry_points'", "not", "in", "setup_data", ":", "return", "[", "]", "console_scripts", "=", "setup_data...
Parse and return a list of console_scripts from setup_data
[ "Parse", "and", "return", "a", "list", "of", "console_scripts", "from", "setup_data" ]
982a5db1db6e4ef40267f15642af2c7ea0e803ae
https://github.com/danbradham/scrim/blob/982a5db1db6e4ef40267f15642af2c7ea0e803ae/scrim/utils.py#L104-L114
train
58,467
ponty/confduino
confduino/proginstall.py
install_programmer
def install_programmer(programmer_id, programmer_options, replace_existing=False): """install programmer in programmers.txt. :param programmer_id: string identifier :param programmer_options: dict like :param replace_existing: bool :rtype: None """ doaction = 0 if programmer_id in prog...
python
def install_programmer(programmer_id, programmer_options, replace_existing=False): """install programmer in programmers.txt. :param programmer_id: string identifier :param programmer_options: dict like :param replace_existing: bool :rtype: None """ doaction = 0 if programmer_id in prog...
[ "def", "install_programmer", "(", "programmer_id", ",", "programmer_options", ",", "replace_existing", "=", "False", ")", ":", "doaction", "=", "0", "if", "programmer_id", "in", "programmers", "(", ")", ".", "keys", "(", ")", ":", "log", ".", "debug", "(", ...
install programmer in programmers.txt. :param programmer_id: string identifier :param programmer_options: dict like :param replace_existing: bool :rtype: None
[ "install", "programmer", "in", "programmers", ".", "txt", "." ]
f4c261e5e84997f145a8bdd001f471db74c9054b
https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/proginstall.py#L11-L32
train
58,468
dps/simplescheduler
simplescheduler/scheduler.py
Scheduler.schedule
def schedule(self, job, when): """ Schedule job to run at when nanoseconds since the UNIX epoch.""" pjob = pickle.dumps(job) self._redis.zadd('ss:scheduled', when, pjob)
python
def schedule(self, job, when): """ Schedule job to run at when nanoseconds since the UNIX epoch.""" pjob = pickle.dumps(job) self._redis.zadd('ss:scheduled', when, pjob)
[ "def", "schedule", "(", "self", ",", "job", ",", "when", ")", ":", "pjob", "=", "pickle", ".", "dumps", "(", "job", ")", "self", ".", "_redis", ".", "zadd", "(", "'ss:scheduled'", ",", "when", ",", "pjob", ")" ]
Schedule job to run at when nanoseconds since the UNIX epoch.
[ "Schedule", "job", "to", "run", "at", "when", "nanoseconds", "since", "the", "UNIX", "epoch", "." ]
d633549a8b78d5c1ff37419f4970835f1c6a5947
https://github.com/dps/simplescheduler/blob/d633549a8b78d5c1ff37419f4970835f1c6a5947/simplescheduler/scheduler.py#L68-L71
train
58,469
dps/simplescheduler
simplescheduler/scheduler.py
Scheduler.schedule_in
def schedule_in(self, job, timedelta): """ Schedule job to run at datetime.timedelta from now.""" now = long(self._now() * 1e6) when = now + timedelta.total_seconds() * 1e6 self.schedule(job, when)
python
def schedule_in(self, job, timedelta): """ Schedule job to run at datetime.timedelta from now.""" now = long(self._now() * 1e6) when = now + timedelta.total_seconds() * 1e6 self.schedule(job, when)
[ "def", "schedule_in", "(", "self", ",", "job", ",", "timedelta", ")", ":", "now", "=", "long", "(", "self", ".", "_now", "(", ")", "*", "1e6", ")", "when", "=", "now", "+", "timedelta", ".", "total_seconds", "(", ")", "*", "1e6", "self", ".", "sc...
Schedule job to run at datetime.timedelta from now.
[ "Schedule", "job", "to", "run", "at", "datetime", ".", "timedelta", "from", "now", "." ]
d633549a8b78d5c1ff37419f4970835f1c6a5947
https://github.com/dps/simplescheduler/blob/d633549a8b78d5c1ff37419f4970835f1c6a5947/simplescheduler/scheduler.py#L73-L77
train
58,470
dps/simplescheduler
simplescheduler/scheduler.py
Scheduler.schedule_now
def schedule_now(self, job): """ Schedule job to run as soon as possible.""" now = long(self._now() * 1e6) self.schedule(job, now)
python
def schedule_now(self, job): """ Schedule job to run as soon as possible.""" now = long(self._now() * 1e6) self.schedule(job, now)
[ "def", "schedule_now", "(", "self", ",", "job", ")", ":", "now", "=", "long", "(", "self", ".", "_now", "(", ")", "*", "1e6", ")", "self", ".", "schedule", "(", "job", ",", "now", ")" ]
Schedule job to run as soon as possible.
[ "Schedule", "job", "to", "run", "as", "soon", "as", "possible", "." ]
d633549a8b78d5c1ff37419f4970835f1c6a5947
https://github.com/dps/simplescheduler/blob/d633549a8b78d5c1ff37419f4970835f1c6a5947/simplescheduler/scheduler.py#L79-L82
train
58,471
hatemile/hatemile-for-python
hatemile/implementation/form.py
AccessibleFormImplementation._get_aria_autocomplete
def _get_aria_autocomplete(self, field): """ Returns the appropriate value for attribute aria-autocomplete of field. :param field: The field. :type field: hatemile.util.html.htmldomelement.HTMLDOMElement :return: The ARIA value of field. :rtype: str """ ...
python
def _get_aria_autocomplete(self, field): """ Returns the appropriate value for attribute aria-autocomplete of field. :param field: The field. :type field: hatemile.util.html.htmldomelement.HTMLDOMElement :return: The ARIA value of field. :rtype: str """ ...
[ "def", "_get_aria_autocomplete", "(", "self", ",", "field", ")", ":", "tag_name", "=", "field", ".", "get_tag_name", "(", ")", "input_type", "=", "None", "if", "field", ".", "has_attribute", "(", "'type'", ")", ":", "input_type", "=", "field", ".", "get_at...
Returns the appropriate value for attribute aria-autocomplete of field. :param field: The field. :type field: hatemile.util.html.htmldomelement.HTMLDOMElement :return: The ARIA value of field. :rtype: str
[ "Returns", "the", "appropriate", "value", "for", "attribute", "aria", "-", "autocomplete", "of", "field", "." ]
1e914f9aa09f6f8d78282af131311546ecba9fb8
https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/implementation/form.py#L89-L143
train
58,472
hatemile/hatemile-for-python
hatemile/implementation/form.py
AccessibleFormImplementation._validate
def _validate(self, field, list_attribute): """ Validate the field when its value change. :param field: The field. :param list_attribute: The list attribute of field with validation. """ if not self.scripts_added: self._generate_validation_scripts() ...
python
def _validate(self, field, list_attribute): """ Validate the field when its value change. :param field: The field. :param list_attribute: The list attribute of field with validation. """ if not self.scripts_added: self._generate_validation_scripts() ...
[ "def", "_validate", "(", "self", ",", "field", ",", "list_attribute", ")", ":", "if", "not", "self", ".", "scripts_added", ":", "self", ".", "_generate_validation_scripts", "(", ")", "self", ".", "id_generator", ".", "generate_id", "(", "field", ")", "self",...
Validate the field when its value change. :param field: The field. :param list_attribute: The list attribute of field with validation.
[ "Validate", "the", "field", "when", "its", "value", "change", "." ]
1e914f9aa09f6f8d78282af131311546ecba9fb8
https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/implementation/form.py#L250-L267
train
58,473
yougov/vr.common
vr/common/slugignore.py
remove
def remove(item): """ Delete item, whether it's a file, a folder, or a folder full of other files and folders. """ if os.path.isdir(item): shutil.rmtree(item) else: # Assume it's a file. error if not. os.remove(item)
python
def remove(item): """ Delete item, whether it's a file, a folder, or a folder full of other files and folders. """ if os.path.isdir(item): shutil.rmtree(item) else: # Assume it's a file. error if not. os.remove(item)
[ "def", "remove", "(", "item", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "item", ")", ":", "shutil", ".", "rmtree", "(", "item", ")", "else", ":", "# Assume it's a file. error if not.", "os", ".", "remove", "(", "item", ")" ]
Delete item, whether it's a file, a folder, or a folder full of other files and folders.
[ "Delete", "item", "whether", "it", "s", "a", "file", "a", "folder", "or", "a", "folder", "full", "of", "other", "files", "and", "folders", "." ]
ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4
https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/slugignore.py#L32-L41
train
58,474
yougov/vr.common
vr/common/slugignore.py
get_slugignores
def get_slugignores(root, fname='.slugignore'): """ Given a root path, read any .slugignore file inside and return a list of patterns that should be removed prior to slug compilation. Return empty list if file does not exist. """ try: with open(os.path.join(root, fname)) as f: ...
python
def get_slugignores(root, fname='.slugignore'): """ Given a root path, read any .slugignore file inside and return a list of patterns that should be removed prior to slug compilation. Return empty list if file does not exist. """ try: with open(os.path.join(root, fname)) as f: ...
[ "def", "get_slugignores", "(", "root", ",", "fname", "=", "'.slugignore'", ")", ":", "try", ":", "with", "open", "(", "os", ".", "path", ".", "join", "(", "root", ",", "fname", ")", ")", "as", "f", ":", "return", "[", "l", ".", "rstrip", "(", "'\...
Given a root path, read any .slugignore file inside and return a list of patterns that should be removed prior to slug compilation. Return empty list if file does not exist.
[ "Given", "a", "root", "path", "read", "any", ".", "slugignore", "file", "inside", "and", "return", "a", "list", "of", "patterns", "that", "should", "be", "removed", "prior", "to", "slug", "compilation", "." ]
ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4
https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/slugignore.py#L64-L75
train
58,475
yougov/vr.common
vr/common/slugignore.py
clean_slug_dir
def clean_slug_dir(root): """ Given a path, delete anything specified in .slugignore. """ if not root.endswith('/'): root += '/' for pattern in get_slugignores(root): print("pattern", pattern) remove_pattern(root, pattern)
python
def clean_slug_dir(root): """ Given a path, delete anything specified in .slugignore. """ if not root.endswith('/'): root += '/' for pattern in get_slugignores(root): print("pattern", pattern) remove_pattern(root, pattern)
[ "def", "clean_slug_dir", "(", "root", ")", ":", "if", "not", "root", ".", "endswith", "(", "'/'", ")", ":", "root", "+=", "'/'", "for", "pattern", "in", "get_slugignores", "(", "root", ")", ":", "print", "(", "\"pattern\"", ",", "pattern", ")", "remove...
Given a path, delete anything specified in .slugignore.
[ "Given", "a", "path", "delete", "anything", "specified", "in", ".", "slugignore", "." ]
ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4
https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/slugignore.py#L78-L86
train
58,476
asascience-open/paegan-transport
paegan/transport/model_controller.py
ModelController.export
def export(self, folder_path, format=None): """ General purpose export method, gets file type from filepath extension Valid output formats currently are: Trackline: trackline or trkl or *.trkl Shapefile: shapefile or shape or shp or *.shp ...
python
def export(self, folder_path, format=None): """ General purpose export method, gets file type from filepath extension Valid output formats currently are: Trackline: trackline or trkl or *.trkl Shapefile: shapefile or shape or shp or *.shp ...
[ "def", "export", "(", "self", ",", "folder_path", ",", "format", "=", "None", ")", ":", "if", "format", "is", "None", ":", "raise", "ValueError", "(", "\"Must export to a specific format, no format specified.\"", ")", "format", "=", "format", ".", "lower", "(", ...
General purpose export method, gets file type from filepath extension Valid output formats currently are: Trackline: trackline or trkl or *.trkl Shapefile: shapefile or shape or shp or *.shp NetCDF: netcdf or nc or *.nc
[ "General", "purpose", "export", "method", "gets", "file", "type", "from", "filepath", "extension" ]
99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3
https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/model_controller.py#L562-L585
train
58,477
puhitaku/naam
naam/__init__.py
_parse
def _parse(args): """Parse passed arguments from shell.""" ordered = [] opt_full = dict() opt_abbrev = dict() args = args + [''] # Avoid out of range i = 0 while i < len(args) - 1: arg = args[i] arg_next = args[i+1] if arg.startswith('--'): if arg_next...
python
def _parse(args): """Parse passed arguments from shell.""" ordered = [] opt_full = dict() opt_abbrev = dict() args = args + [''] # Avoid out of range i = 0 while i < len(args) - 1: arg = args[i] arg_next = args[i+1] if arg.startswith('--'): if arg_next...
[ "def", "_parse", "(", "args", ")", ":", "ordered", "=", "[", "]", "opt_full", "=", "dict", "(", ")", "opt_abbrev", "=", "dict", "(", ")", "args", "=", "args", "+", "[", "''", "]", "# Avoid out of range", "i", "=", "0", "while", "i", "<", "len", "...
Parse passed arguments from shell.
[ "Parse", "passed", "arguments", "from", "shell", "." ]
20dd01af4d85c9c88963ea1b78a6f217cb015f27
https://github.com/puhitaku/naam/blob/20dd01af4d85c9c88963ea1b78a6f217cb015f27/naam/__init__.py#L9-L38
train
58,478
puhitaku/naam
naam/__init__.py
_construct_optional
def _construct_optional(params): """Construct optional args' key and abbreviated key from signature.""" args = [] filtered = {key: arg.default for key, arg in params.items() if arg.default != inspect._empty} for key, default in filtered.items(): arg = OptionalArg(full=key, abbrev=key[0].lower()...
python
def _construct_optional(params): """Construct optional args' key and abbreviated key from signature.""" args = [] filtered = {key: arg.default for key, arg in params.items() if arg.default != inspect._empty} for key, default in filtered.items(): arg = OptionalArg(full=key, abbrev=key[0].lower()...
[ "def", "_construct_optional", "(", "params", ")", ":", "args", "=", "[", "]", "filtered", "=", "{", "key", ":", "arg", ".", "default", "for", "key", ",", "arg", "in", "params", ".", "items", "(", ")", "if", "arg", ".", "default", "!=", "inspect", "...
Construct optional args' key and abbreviated key from signature.
[ "Construct", "optional", "args", "key", "and", "abbreviated", "key", "from", "signature", "." ]
20dd01af4d85c9c88963ea1b78a6f217cb015f27
https://github.com/puhitaku/naam/blob/20dd01af4d85c9c88963ea1b78a6f217cb015f27/naam/__init__.py#L46-L73
train
58,479
hatemile/hatemile-for-python
hatemile/implementation/event.py
AccessibleEventImplementation._keyboard_access
def _keyboard_access(self, element): """ Provide keyboard access for element, if it not has. :param element: The element. :type element: hatemile.util.html.htmldomelement.HTMLDOMElement """ # pylint: disable=no-self-use if not element.has_attribute('tabindex'): ...
python
def _keyboard_access(self, element): """ Provide keyboard access for element, if it not has. :param element: The element. :type element: hatemile.util.html.htmldomelement.HTMLDOMElement """ # pylint: disable=no-self-use if not element.has_attribute('tabindex'): ...
[ "def", "_keyboard_access", "(", "self", ",", "element", ")", ":", "# pylint: disable=no-self-use", "if", "not", "element", ".", "has_attribute", "(", "'tabindex'", ")", ":", "tag", "=", "element", ".", "get_tag_name", "(", ")", "if", "(", "tag", "==", "'A'",...
Provide keyboard access for element, if it not has. :param element: The element. :type element: hatemile.util.html.htmldomelement.HTMLDOMElement
[ "Provide", "keyboard", "access", "for", "element", "if", "it", "not", "has", "." ]
1e914f9aa09f6f8d78282af131311546ecba9fb8
https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/implementation/event.py#L61-L81
train
58,480
hatemile/hatemile-for-python
hatemile/implementation/event.py
AccessibleEventImplementation._add_event_in_element
def _add_event_in_element(self, element, event): """ Add a type of event in element. :param element: The element. :type element: hatemile.util.html.htmldomelement.HTMLDOMElement :param event: The type of event. :type event: str """ if not self.main_scrip...
python
def _add_event_in_element(self, element, event): """ Add a type of event in element. :param element: The element. :type element: hatemile.util.html.htmldomelement.HTMLDOMElement :param event: The type of event. :type event: str """ if not self.main_scrip...
[ "def", "_add_event_in_element", "(", "self", ",", "element", ",", "event", ")", ":", "if", "not", "self", ".", "main_script_added", ":", "self", ".", "_generate_main_scripts", "(", ")", "if", "self", ".", "script_list", "is", "not", "None", ":", "self", "....
Add a type of event in element. :param element: The element. :type element: hatemile.util.html.htmldomelement.HTMLDOMElement :param event: The type of event. :type event: str
[ "Add", "a", "type", "of", "event", "in", "element", "." ]
1e914f9aa09f6f8d78282af131311546ecba9fb8
https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/implementation/event.py#L191-L211
train
58,481
Jarn/jarn.mkrelease
jarn/mkrelease/tee.py
tee
def tee(process, filter): """Read lines from process.stdout and echo them to sys.stdout. Returns a list of lines read. Lines are not newline terminated. The 'filter' is a callable which is invoked for every line, receiving the line as argument. If the filter returns True, the line is echoed to sys...
python
def tee(process, filter): """Read lines from process.stdout and echo them to sys.stdout. Returns a list of lines read. Lines are not newline terminated. The 'filter' is a callable which is invoked for every line, receiving the line as argument. If the filter returns True, the line is echoed to sys...
[ "def", "tee", "(", "process", ",", "filter", ")", ":", "lines", "=", "[", "]", "while", "True", ":", "line", "=", "process", ".", "stdout", ".", "readline", "(", ")", "if", "line", ":", "if", "sys", ".", "version_info", "[", "0", "]", ">=", "3", ...
Read lines from process.stdout and echo them to sys.stdout. Returns a list of lines read. Lines are not newline terminated. The 'filter' is a callable which is invoked for every line, receiving the line as argument. If the filter returns True, the line is echoed to sys.stdout.
[ "Read", "lines", "from", "process", ".", "stdout", "and", "echo", "them", "to", "sys", ".", "stdout", "." ]
844377f37a3cdc0a154148790a926f991019ec4a
https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/tee.py#L19-L42
train
58,482
Jarn/jarn.mkrelease
jarn/mkrelease/tee.py
tee2
def tee2(process, filter): """Read lines from process.stderr and echo them to sys.stderr. The 'filter' is a callable which is invoked for every line, receiving the line as argument. If the filter returns True, the line is echoed to sys.stderr. """ while True: line = process.stderr.readl...
python
def tee2(process, filter): """Read lines from process.stderr and echo them to sys.stderr. The 'filter' is a callable which is invoked for every line, receiving the line as argument. If the filter returns True, the line is echoed to sys.stderr. """ while True: line = process.stderr.readl...
[ "def", "tee2", "(", "process", ",", "filter", ")", ":", "while", "True", ":", "line", "=", "process", ".", "stderr", ".", "readline", "(", ")", "if", "line", ":", "if", "sys", ".", "version_info", "[", "0", "]", ">=", "3", ":", "line", "=", "deco...
Read lines from process.stderr and echo them to sys.stderr. The 'filter' is a callable which is invoked for every line, receiving the line as argument. If the filter returns True, the line is echoed to sys.stderr.
[ "Read", "lines", "from", "process", ".", "stderr", "and", "echo", "them", "to", "sys", ".", "stderr", "." ]
844377f37a3cdc0a154148790a926f991019ec4a
https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/tee.py#L45-L62
train
58,483
Jarn/jarn.mkrelease
jarn/mkrelease/tee.py
run
def run(args, echo=True, echo2=True, shell=False, cwd=None, env=None): """Run 'args' and return a two-tuple of exit code and lines read. If 'echo' is True, the stdout stream is echoed to sys.stdout. If 'echo2' is True, the stderr stream is echoed to sys.stderr. The 'echo' and 'echo2' arguments may be ...
python
def run(args, echo=True, echo2=True, shell=False, cwd=None, env=None): """Run 'args' and return a two-tuple of exit code and lines read. If 'echo' is True, the stdout stream is echoed to sys.stdout. If 'echo2' is True, the stderr stream is echoed to sys.stderr. The 'echo' and 'echo2' arguments may be ...
[ "def", "run", "(", "args", ",", "echo", "=", "True", ",", "echo2", "=", "True", ",", "shell", "=", "False", ",", "cwd", "=", "None", ",", "env", "=", "None", ")", ":", "if", "not", "callable", "(", "echo", ")", ":", "echo", "=", "On", "(", ")...
Run 'args' and return a two-tuple of exit code and lines read. If 'echo' is True, the stdout stream is echoed to sys.stdout. If 'echo2' is True, the stderr stream is echoed to sys.stderr. The 'echo' and 'echo2' arguments may be callables, in which case they are used as tee filters. If 'shell' is ...
[ "Run", "args", "and", "return", "a", "two", "-", "tuple", "of", "exit", "code", "and", "lines", "read", "." ]
844377f37a3cdc0a154148790a926f991019ec4a
https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/tee.py#L81-L112
train
58,484
helixyte/everest
everest/representers/registry.py
RepresenterRegistry.register_representer_class
def register_representer_class(self, representer_class): """ Registers the given representer class with this registry, using its MIME content type as the key. """ if representer_class in self.__rpr_classes.values(): raise ValueError('The representer class "%s" has alr...
python
def register_representer_class(self, representer_class): """ Registers the given representer class with this registry, using its MIME content type as the key. """ if representer_class in self.__rpr_classes.values(): raise ValueError('The representer class "%s" has alr...
[ "def", "register_representer_class", "(", "self", ",", "representer_class", ")", ":", "if", "representer_class", "in", "self", ".", "__rpr_classes", ".", "values", "(", ")", ":", "raise", "ValueError", "(", "'The representer class \"%s\" has already been '", "'registere...
Registers the given representer class with this registry, using its MIME content type as the key.
[ "Registers", "the", "given", "representer", "class", "with", "this", "registry", "using", "its", "MIME", "content", "type", "as", "the", "key", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/registry.py#L28-L41
train
58,485
helixyte/everest
everest/representers/registry.py
RepresenterRegistry.register
def register(self, resource_class, content_type, configuration=None): """ Registers a representer factory for the given combination of resource class and content type. :param configuration: representer configuration. A default instance will be created if this is not given. ...
python
def register(self, resource_class, content_type, configuration=None): """ Registers a representer factory for the given combination of resource class and content type. :param configuration: representer configuration. A default instance will be created if this is not given. ...
[ "def", "register", "(", "self", ",", "resource_class", ",", "content_type", ",", "configuration", "=", "None", ")", ":", "if", "not", "issubclass", "(", "resource_class", ",", "Resource", ")", ":", "raise", "ValueError", "(", "'Representers can only be registered ...
Registers a representer factory for the given combination of resource class and content type. :param configuration: representer configuration. A default instance will be created if this is not given. :type configuration: :class:`everest.representers.config.RepresenterConfi...
[ "Registers", "a", "representer", "factory", "for", "the", "given", "combination", "of", "resource", "class", "and", "content", "type", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/registry.py#L62-L112
train
58,486
helixyte/everest
everest/representers/registry.py
RepresenterRegistry.create
def create(self, resource_class, content_type): """ Creates a representer for the given combination of resource and content type. This will also find representer factories that were registered for a base class of the given resource. """ rpr_fac = self.__find_representer_f...
python
def create(self, resource_class, content_type): """ Creates a representer for the given combination of resource and content type. This will also find representer factories that were registered for a base class of the given resource. """ rpr_fac = self.__find_representer_f...
[ "def", "create", "(", "self", ",", "resource_class", ",", "content_type", ")", ":", "rpr_fac", "=", "self", ".", "__find_representer_factory", "(", "resource_class", ",", "content_type", ")", "if", "rpr_fac", "is", "None", ":", "# Register a representer with default...
Creates a representer for the given combination of resource and content type. This will also find representer factories that were registered for a base class of the given resource.
[ "Creates", "a", "representer", "for", "the", "given", "combination", "of", "resource", "and", "content", "type", ".", "This", "will", "also", "find", "representer", "factories", "that", "were", "registered", "for", "a", "base", "class", "of", "the", "given", ...
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/registry.py#L114-L128
train
58,487
blockstack-packages/blockstack-gpg
blockstack_gpg/gpg.py
make_gpg_home
def make_gpg_home(appname, config_dir=None): """ Make GPG keyring dir for a particular application. Return the path. """ assert is_valid_appname(appname) config_dir = get_config_dir( config_dir ) path = os.path.join( config_dir, "gpgkeys", appname ) if not os.path.exists(path): ...
python
def make_gpg_home(appname, config_dir=None): """ Make GPG keyring dir for a particular application. Return the path. """ assert is_valid_appname(appname) config_dir = get_config_dir( config_dir ) path = os.path.join( config_dir, "gpgkeys", appname ) if not os.path.exists(path): ...
[ "def", "make_gpg_home", "(", "appname", ",", "config_dir", "=", "None", ")", ":", "assert", "is_valid_appname", "(", "appname", ")", "config_dir", "=", "get_config_dir", "(", "config_dir", ")", "path", "=", "os", ".", "path", ".", "join", "(", "config_dir", ...
Make GPG keyring dir for a particular application. Return the path.
[ "Make", "GPG", "keyring", "dir", "for", "a", "particular", "application", ".", "Return", "the", "path", "." ]
e4d51e4e51678d9b946596ca9dec53e2d78c8710
https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L87-L102
train
58,488
blockstack-packages/blockstack-gpg
blockstack_gpg/gpg.py
get_gpg_home
def get_gpg_home( appname, config_dir=None ): """ Get the GPG keyring directory for a particular application. Return the path. """ assert is_valid_appname(appname) config_dir = get_config_dir( config_dir ) path = os.path.join( config_dir, "gpgkeys", appname ) return path
python
def get_gpg_home( appname, config_dir=None ): """ Get the GPG keyring directory for a particular application. Return the path. """ assert is_valid_appname(appname) config_dir = get_config_dir( config_dir ) path = os.path.join( config_dir, "gpgkeys", appname ) return path
[ "def", "get_gpg_home", "(", "appname", ",", "config_dir", "=", "None", ")", ":", "assert", "is_valid_appname", "(", "appname", ")", "config_dir", "=", "get_config_dir", "(", "config_dir", ")", "path", "=", "os", ".", "path", ".", "join", "(", "config_dir", ...
Get the GPG keyring directory for a particular application. Return the path.
[ "Get", "the", "GPG", "keyring", "directory", "for", "a", "particular", "application", ".", "Return", "the", "path", "." ]
e4d51e4e51678d9b946596ca9dec53e2d78c8710
https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L105-L113
train
58,489
blockstack-packages/blockstack-gpg
blockstack_gpg/gpg.py
make_gpg_tmphome
def make_gpg_tmphome( prefix=None, config_dir=None ): """ Make a temporary directory to hold GPG keys that are not going to be stored to the application's keyring. """ if prefix is None: prefix = "tmp" config_dir = get_config_dir( config_dir ) tmppath = os.path.join( config_dir, "t...
python
def make_gpg_tmphome( prefix=None, config_dir=None ): """ Make a temporary directory to hold GPG keys that are not going to be stored to the application's keyring. """ if prefix is None: prefix = "tmp" config_dir = get_config_dir( config_dir ) tmppath = os.path.join( config_dir, "t...
[ "def", "make_gpg_tmphome", "(", "prefix", "=", "None", ",", "config_dir", "=", "None", ")", ":", "if", "prefix", "is", "None", ":", "prefix", "=", "\"tmp\"", "config_dir", "=", "get_config_dir", "(", "config_dir", ")", "tmppath", "=", "os", ".", "path", ...
Make a temporary directory to hold GPG keys that are not going to be stored to the application's keyring.
[ "Make", "a", "temporary", "directory", "to", "hold", "GPG", "keys", "that", "are", "not", "going", "to", "be", "stored", "to", "the", "application", "s", "keyring", "." ]
e4d51e4e51678d9b946596ca9dec53e2d78c8710
https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L125-L139
train
58,490
blockstack-packages/blockstack-gpg
blockstack_gpg/gpg.py
gpg_stash_key
def gpg_stash_key( appname, key_bin, config_dir=None, gpghome=None ): """ Store a key locally to our app keyring. Does NOT put it into a blockchain ID Return the key ID on success Return None on error """ assert is_valid_appname(appname) key_bin = str(key_bin) assert len(key_bin) > ...
python
def gpg_stash_key( appname, key_bin, config_dir=None, gpghome=None ): """ Store a key locally to our app keyring. Does NOT put it into a blockchain ID Return the key ID on success Return None on error """ assert is_valid_appname(appname) key_bin = str(key_bin) assert len(key_bin) > ...
[ "def", "gpg_stash_key", "(", "appname", ",", "key_bin", ",", "config_dir", "=", "None", ",", "gpghome", "=", "None", ")", ":", "assert", "is_valid_appname", "(", "appname", ")", "key_bin", "=", "str", "(", "key_bin", ")", "assert", "len", "(", "key_bin", ...
Store a key locally to our app keyring. Does NOT put it into a blockchain ID Return the key ID on success Return None on error
[ "Store", "a", "key", "locally", "to", "our", "app", "keyring", ".", "Does", "NOT", "put", "it", "into", "a", "blockchain", "ID", "Return", "the", "key", "ID", "on", "success", "Return", "None", "on", "error" ]
e4d51e4e51678d9b946596ca9dec53e2d78c8710
https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L142-L172
train
58,491
blockstack-packages/blockstack-gpg
blockstack_gpg/gpg.py
gpg_unstash_key
def gpg_unstash_key( appname, key_id, config_dir=None, gpghome=None ): """ Remove a public key locally from our local app keyring Return True on success Return False on error """ assert is_valid_appname(appname) if gpghome is None: config_dir = get_config_dir( config_dir ) k...
python
def gpg_unstash_key( appname, key_id, config_dir=None, gpghome=None ): """ Remove a public key locally from our local app keyring Return True on success Return False on error """ assert is_valid_appname(appname) if gpghome is None: config_dir = get_config_dir( config_dir ) k...
[ "def", "gpg_unstash_key", "(", "appname", ",", "key_id", ",", "config_dir", "=", "None", ",", "gpghome", "=", "None", ")", ":", "assert", "is_valid_appname", "(", "appname", ")", "if", "gpghome", "is", "None", ":", "config_dir", "=", "get_config_dir", "(", ...
Remove a public key locally from our local app keyring Return True on success Return False on error
[ "Remove", "a", "public", "key", "locally", "from", "our", "local", "app", "keyring", "Return", "True", "on", "success", "Return", "False", "on", "error" ]
e4d51e4e51678d9b946596ca9dec53e2d78c8710
https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L175-L203
train
58,492
blockstack-packages/blockstack-gpg
blockstack_gpg/gpg.py
gpg_download_key
def gpg_download_key( key_id, key_server, config_dir=None ): """ Download a GPG key from a key server. Do not import it into any keyrings. Return the ASCII-armored key """ config_dir = get_config_dir( config_dir ) tmpdir = make_gpg_tmphome( prefix="download", config_dir=config_dir ) gpg...
python
def gpg_download_key( key_id, key_server, config_dir=None ): """ Download a GPG key from a key server. Do not import it into any keyrings. Return the ASCII-armored key """ config_dir = get_config_dir( config_dir ) tmpdir = make_gpg_tmphome( prefix="download", config_dir=config_dir ) gpg...
[ "def", "gpg_download_key", "(", "key_id", ",", "key_server", ",", "config_dir", "=", "None", ")", ":", "config_dir", "=", "get_config_dir", "(", "config_dir", ")", "tmpdir", "=", "make_gpg_tmphome", "(", "prefix", "=", "\"download\"", ",", "config_dir", "=", "...
Download a GPG key from a key server. Do not import it into any keyrings. Return the ASCII-armored key
[ "Download", "a", "GPG", "key", "from", "a", "key", "server", ".", "Do", "not", "import", "it", "into", "any", "keyrings", ".", "Return", "the", "ASCII", "-", "armored", "key" ]
e4d51e4e51678d9b946596ca9dec53e2d78c8710
https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L206-L232
train
58,493
blockstack-packages/blockstack-gpg
blockstack_gpg/gpg.py
gpg_key_fingerprint
def gpg_key_fingerprint( key_data, config_dir=None ): """ Get the key ID of a given serialized key Return the fingerprint on success Return None on error """ key_data = str(key_data) config_dir = get_config_dir( config_dir ) tmpdir = make_gpg_tmphome( prefix="key_id-", config_dir=confi...
python
def gpg_key_fingerprint( key_data, config_dir=None ): """ Get the key ID of a given serialized key Return the fingerprint on success Return None on error """ key_data = str(key_data) config_dir = get_config_dir( config_dir ) tmpdir = make_gpg_tmphome( prefix="key_id-", config_dir=confi...
[ "def", "gpg_key_fingerprint", "(", "key_data", ",", "config_dir", "=", "None", ")", ":", "key_data", "=", "str", "(", "key_data", ")", "config_dir", "=", "get_config_dir", "(", "config_dir", ")", "tmpdir", "=", "make_gpg_tmphome", "(", "prefix", "=", "\"key_id...
Get the key ID of a given serialized key Return the fingerprint on success Return None on error
[ "Get", "the", "key", "ID", "of", "a", "given", "serialized", "key", "Return", "the", "fingerprint", "on", "success", "Return", "None", "on", "error" ]
e4d51e4e51678d9b946596ca9dec53e2d78c8710
https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L235-L258
train
58,494
blockstack-packages/blockstack-gpg
blockstack_gpg/gpg.py
gpg_verify_key
def gpg_verify_key( key_id, key_data, config_dir=None ): """ Verify that a given serialized key, when imported, has the given key ID. Return True on success Return False on error """ key_data = str(key_data) config_dir = get_config_dir( config_dir ) sanitized_key_id = "".join( key_id.u...
python
def gpg_verify_key( key_id, key_data, config_dir=None ): """ Verify that a given serialized key, when imported, has the given key ID. Return True on success Return False on error """ key_data = str(key_data) config_dir = get_config_dir( config_dir ) sanitized_key_id = "".join( key_id.u...
[ "def", "gpg_verify_key", "(", "key_id", ",", "key_data", ",", "config_dir", "=", "None", ")", ":", "key_data", "=", "str", "(", "key_data", ")", "config_dir", "=", "get_config_dir", "(", "config_dir", ")", "sanitized_key_id", "=", "\"\"", ".", "join", "(", ...
Verify that a given serialized key, when imported, has the given key ID. Return True on success Return False on error
[ "Verify", "that", "a", "given", "serialized", "key", "when", "imported", "has", "the", "given", "key", "ID", ".", "Return", "True", "on", "success", "Return", "False", "on", "error" ]
e4d51e4e51678d9b946596ca9dec53e2d78c8710
https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L261-L287
train
58,495
blockstack-packages/blockstack-gpg
blockstack_gpg/gpg.py
gpg_export_key
def gpg_export_key( appname, key_id, config_dir=None, include_private=False ): """ Get the ASCII-armored key, given the ID """ assert is_valid_appname(appname) config_dir = get_config_dir( config_dir ) keydir = get_gpg_home( appname, config_dir=config_dir ) gpg = gnupg.GPG( homedir=keydir )...
python
def gpg_export_key( appname, key_id, config_dir=None, include_private=False ): """ Get the ASCII-armored key, given the ID """ assert is_valid_appname(appname) config_dir = get_config_dir( config_dir ) keydir = get_gpg_home( appname, config_dir=config_dir ) gpg = gnupg.GPG( homedir=keydir )...
[ "def", "gpg_export_key", "(", "appname", ",", "key_id", ",", "config_dir", "=", "None", ",", "include_private", "=", "False", ")", ":", "assert", "is_valid_appname", "(", "appname", ")", "config_dir", "=", "get_config_dir", "(", "config_dir", ")", "keydir", "=...
Get the ASCII-armored key, given the ID
[ "Get", "the", "ASCII", "-", "armored", "key", "given", "the", "ID" ]
e4d51e4e51678d9b946596ca9dec53e2d78c8710
https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L290-L305
train
58,496
blockstack-packages/blockstack-gpg
blockstack_gpg/gpg.py
gpg_fetch_key
def gpg_fetch_key( key_url, key_id=None, config_dir=None ): """ Fetch a GPG public key from the given URL. Supports anything urllib2 supports. If the URL has no scheme, then assume it's a PGP key server, and use GPG to go get it. The key is not accepted into any keyrings. Return the key data on ...
python
def gpg_fetch_key( key_url, key_id=None, config_dir=None ): """ Fetch a GPG public key from the given URL. Supports anything urllib2 supports. If the URL has no scheme, then assume it's a PGP key server, and use GPG to go get it. The key is not accepted into any keyrings. Return the key data on ...
[ "def", "gpg_fetch_key", "(", "key_url", ",", "key_id", "=", "None", ",", "config_dir", "=", "None", ")", ":", "dat", "=", "None", "from_blockstack", "=", "False", "# make sure it's valid ", "try", ":", "urlparse", ".", "urlparse", "(", "key_url", ")", "excep...
Fetch a GPG public key from the given URL. Supports anything urllib2 supports. If the URL has no scheme, then assume it's a PGP key server, and use GPG to go get it. The key is not accepted into any keyrings. Return the key data on success. If key_id is given, verify the key matches. Return None on...
[ "Fetch", "a", "GPG", "public", "key", "from", "the", "given", "URL", ".", "Supports", "anything", "urllib2", "supports", ".", "If", "the", "URL", "has", "no", "scheme", "then", "assume", "it", "s", "a", "PGP", "key", "server", "and", "use", "GPG", "to"...
e4d51e4e51678d9b946596ca9dec53e2d78c8710
https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L399-L488
train
58,497
blockstack-packages/blockstack-gpg
blockstack_gpg/gpg.py
gpg_app_put_key
def gpg_app_put_key( blockchain_id, appname, keyname, key_data, txid=None, immutable=False, proxy=None, wallet_keys=None, config_dir=None ): """ Put an application GPG key. Stash the private key locally to an app-specific keyring. Return {'status': True, 'key_url': ..., 'key_data': ...} on success ...
python
def gpg_app_put_key( blockchain_id, appname, keyname, key_data, txid=None, immutable=False, proxy=None, wallet_keys=None, config_dir=None ): """ Put an application GPG key. Stash the private key locally to an app-specific keyring. Return {'status': True, 'key_url': ..., 'key_data': ...} on success ...
[ "def", "gpg_app_put_key", "(", "blockchain_id", ",", "appname", ",", "keyname", ",", "key_data", ",", "txid", "=", "None", ",", "immutable", "=", "False", ",", "proxy", "=", "None", ",", "wallet_keys", "=", "None", ",", "config_dir", "=", "None", ")", ":...
Put an application GPG key. Stash the private key locally to an app-specific keyring. Return {'status': True, 'key_url': ..., 'key_data': ...} on success Return {'error': ...} on error If immutable is True, then store the data as an immutable entry (e.g. update the zonefile with the key hash) ...
[ "Put", "an", "application", "GPG", "key", ".", "Stash", "the", "private", "key", "locally", "to", "an", "app", "-", "specific", "keyring", "." ]
e4d51e4e51678d9b946596ca9dec53e2d78c8710
https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L703-L759
train
58,498
blockstack-packages/blockstack-gpg
blockstack_gpg/gpg.py
gpg_app_delete_key
def gpg_app_delete_key( blockchain_id, appname, keyname, txid=None, immutable=False, proxy=None, wallet_keys=None, config_dir=None ): """ Remove an application GPG key. Unstash the local private key. Return {'status': True, ...} on success Return {'error': ...} on error If immutable is True, ...
python
def gpg_app_delete_key( blockchain_id, appname, keyname, txid=None, immutable=False, proxy=None, wallet_keys=None, config_dir=None ): """ Remove an application GPG key. Unstash the local private key. Return {'status': True, ...} on success Return {'error': ...} on error If immutable is True, ...
[ "def", "gpg_app_delete_key", "(", "blockchain_id", ",", "appname", ",", "keyname", ",", "txid", "=", "None", ",", "immutable", "=", "False", ",", "proxy", "=", "None", ",", "wallet_keys", "=", "None", ",", "config_dir", "=", "None", ")", ":", "assert", "...
Remove an application GPG key. Unstash the local private key. Return {'status': True, ...} on success Return {'error': ...} on error If immutable is True, then remove the data from the user's zonefile, not profile. The delete may take on the order of an hour to complete on the blockchain. A tra...
[ "Remove", "an", "application", "GPG", "key", ".", "Unstash", "the", "local", "private", "key", "." ]
e4d51e4e51678d9b946596ca9dec53e2d78c8710
https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L762-L824
train
58,499