repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
quasipedia/swaggery
swaggery/checker.py
Checker.checks
def checks(self): '''Return the list of all check methods.''' condition = lambda a: a.startswith('check_') return (getattr(self, a) for a in dir(self) if condition(a))
python
def checks(self): '''Return the list of all check methods.''' condition = lambda a: a.startswith('check_') return (getattr(self, a) for a in dir(self) if condition(a))
[ "def", "checks", "(", "self", ")", ":", "condition", "=", "lambda", "a", ":", "a", ".", "startswith", "(", "'check_'", ")", "return", "(", "getattr", "(", "self", ",", "a", ")", "for", "a", "in", "dir", "(", "self", ")", "if", "condition", "(", "...
Return the list of all check methods.
[ "Return", "the", "list", "of", "all", "check", "methods", "." ]
train
https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/checker.py#L43-L46
quasipedia/swaggery
swaggery/checker.py
ApiChecker.check_has_docstring
def check_has_docstring(self, api): '''An API class must have a docstring.''' if not api.__doc__: msg = 'The Api class "{}" lacks a docstring.' return [msg.format(api.__name__)]
python
def check_has_docstring(self, api): '''An API class must have a docstring.''' if not api.__doc__: msg = 'The Api class "{}" lacks a docstring.' return [msg.format(api.__name__)]
[ "def", "check_has_docstring", "(", "self", ",", "api", ")", ":", "if", "not", "api", ".", "__doc__", ":", "msg", "=", "'The Api class \"{}\" lacks a docstring.'", "return", "[", "msg", ".", "format", "(", "api", ".", "__name__", ")", "]" ]
An API class must have a docstring.
[ "An", "API", "class", "must", "have", "a", "docstring", "." ]
train
https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/checker.py#L64-L68
quasipedia/swaggery
swaggery/checker.py
ApiChecker.check_has_version
def check_has_version(self, api): '''An API class must have a `version` attribute.''' if not hasattr(api, 'version'): msg = 'The Api class "{}" lacks a `version` attribute.' return [msg.format(api.__name__)]
python
def check_has_version(self, api): '''An API class must have a `version` attribute.''' if not hasattr(api, 'version'): msg = 'The Api class "{}" lacks a `version` attribute.' return [msg.format(api.__name__)]
[ "def", "check_has_version", "(", "self", ",", "api", ")", ":", "if", "not", "hasattr", "(", "api", ",", "'version'", ")", ":", "msg", "=", "'The Api class \"{}\" lacks a `version` attribute.'", "return", "[", "msg", ".", "format", "(", "api", ".", "__name__", ...
An API class must have a `version` attribute.
[ "An", "API", "class", "must", "have", "a", "version", "attribute", "." ]
train
https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/checker.py#L70-L74
quasipedia/swaggery
swaggery/checker.py
ApiChecker.check_has_path
def check_has_path(self, api): '''An API class must have a `path` attribute.''' if not hasattr(api, 'path'): msg = 'The Api class "{}" lacks a `path` attribute.' return [msg.format(api.__name__)]
python
def check_has_path(self, api): '''An API class must have a `path` attribute.''' if not hasattr(api, 'path'): msg = 'The Api class "{}" lacks a `path` attribute.' return [msg.format(api.__name__)]
[ "def", "check_has_path", "(", "self", ",", "api", ")", ":", "if", "not", "hasattr", "(", "api", ",", "'path'", ")", ":", "msg", "=", "'The Api class \"{}\" lacks a `path` attribute.'", "return", "[", "msg", ".", "format", "(", "api", ".", "__name__", ")", ...
An API class must have a `path` attribute.
[ "An", "API", "class", "must", "have", "a", "path", "attribute", "." ]
train
https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/checker.py#L76-L80
quasipedia/swaggery
swaggery/checker.py
ResourceMethodChecker.check_docstring
def check_docstring(self, method): '''All methods should have a docstring.''' mn = method.__name__ if method.__doc__ is None: return ['Missing docstring for method "{}"'.format(mn)]
python
def check_docstring(self, method): '''All methods should have a docstring.''' mn = method.__name__ if method.__doc__ is None: return ['Missing docstring for method "{}"'.format(mn)]
[ "def", "check_docstring", "(", "self", ",", "method", ")", ":", "mn", "=", "method", ".", "__name__", "if", "method", ".", "__doc__", "is", "None", ":", "return", "[", "'Missing docstring for method \"{}\"'", ".", "format", "(", "mn", ")", "]" ]
All methods should have a docstring.
[ "All", "methods", "should", "have", "a", "docstring", "." ]
train
https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/checker.py#L87-L91
quasipedia/swaggery
swaggery/checker.py
ResourceMethodChecker.check_return_types
def check_return_types(self, method): '''Return types must be correct, their codes must match actual use.''' mn = method.__name__ retanno = method.__annotations__.get('return', None) # Take a look at the syntax if not retanno: return ['Missing return types for method ...
python
def check_return_types(self, method): '''Return types must be correct, their codes must match actual use.''' mn = method.__name__ retanno = method.__annotations__.get('return', None) # Take a look at the syntax if not retanno: return ['Missing return types for method ...
[ "def", "check_return_types", "(", "self", ",", "method", ")", ":", "mn", "=", "method", ".", "__name__", "retanno", "=", "method", ".", "__annotations__", ".", "get", "(", "'return'", ",", "None", ")", "# Take a look at the syntax", "if", "not", "retanno", "...
Return types must be correct, their codes must match actual use.
[ "Return", "types", "must", "be", "correct", "their", "codes", "must", "match", "actual", "use", "." ]
train
https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/checker.py#L93-L133
quasipedia/swaggery
swaggery/checker.py
ResourceMethodChecker.check_params_types
def check_params_types(self, method): '''Types in argument annotations must be instances, not classes.''' mn = method.__name__ annos = dict(method.__annotations__) errors = [] # Take a look at the syntax msg_tuple = 'Parameter {} in method {} is not annotated with a tuple...
python
def check_params_types(self, method): '''Types in argument annotations must be instances, not classes.''' mn = method.__name__ annos = dict(method.__annotations__) errors = [] # Take a look at the syntax msg_tuple = 'Parameter {} in method {} is not annotated with a tuple...
[ "def", "check_params_types", "(", "self", ",", "method", ")", ":", "mn", "=", "method", ".", "__name__", "annos", "=", "dict", "(", "method", ".", "__annotations__", ")", "errors", "=", "[", "]", "# Take a look at the syntax", "msg_tuple", "=", "'Parameter {} ...
Types in argument annotations must be instances, not classes.
[ "Types", "in", "argument", "annotations", "must", "be", "instances", "not", "classes", "." ]
train
https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/checker.py#L135-L172
quasipedia/swaggery
swaggery/checker.py
ResourceChecker.check_path_consistency
def check_path_consistency(self, resource): '''Path arguments must be consistent for all methods.''' msg = ('Method "{}" path variables {}) do not conform with the ' 'resource subpath declaration ({}).') errors = [] # If subpath is not set, it will be detected by another c...
python
def check_path_consistency(self, resource): '''Path arguments must be consistent for all methods.''' msg = ('Method "{}" path variables {}) do not conform with the ' 'resource subpath declaration ({}).') errors = [] # If subpath is not set, it will be detected by another c...
[ "def", "check_path_consistency", "(", "self", ",", "resource", ")", ":", "msg", "=", "(", "'Method \"{}\" path variables {}) do not conform with the '", "'resource subpath declaration ({}).'", ")", "errors", "=", "[", "]", "# If subpath is not set, it will be detected by another ...
Path arguments must be consistent for all methods.
[ "Path", "arguments", "must", "be", "consistent", "for", "all", "methods", "." ]
train
https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/checker.py#L181-L198
quasipedia/swaggery
swaggery/checker.py
ResourceChecker.check_no_multiple_handlers
def check_no_multiple_handlers(self, resource): '''The same verb cannot be repeated on several endpoints.''' seen = [] errors = [] msg = 'HTTP verb "{}" associated to more than one endpoint in "{}".' for method in resource.callbacks: for op in getattr(method, 'swagger...
python
def check_no_multiple_handlers(self, resource): '''The same verb cannot be repeated on several endpoints.''' seen = [] errors = [] msg = 'HTTP verb "{}" associated to more than one endpoint in "{}".' for method in resource.callbacks: for op in getattr(method, 'swagger...
[ "def", "check_no_multiple_handlers", "(", "self", ",", "resource", ")", ":", "seen", "=", "[", "]", "errors", "=", "[", "]", "msg", "=", "'HTTP verb \"{}\" associated to more than one endpoint in \"{}\".'", "for", "method", "in", "resource", ".", "callbacks", ":", ...
The same verb cannot be repeated on several endpoints.
[ "The", "same", "verb", "cannot", "be", "repeated", "on", "several", "endpoints", "." ]
train
https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/checker.py#L200-L211
quasipedia/swaggery
swaggery/checker.py
ResourceChecker.check_methods
def check_methods(self, resource): '''Iteratively check all methods (endpoints) in the Resource.''' checker = ResourceMethodChecker() errors = [] for callback in resource.callbacks: new_errors = checker(callback) if new_errors: errors.extend(new_er...
python
def check_methods(self, resource): '''Iteratively check all methods (endpoints) in the Resource.''' checker = ResourceMethodChecker() errors = [] for callback in resource.callbacks: new_errors = checker(callback) if new_errors: errors.extend(new_er...
[ "def", "check_methods", "(", "self", ",", "resource", ")", ":", "checker", "=", "ResourceMethodChecker", "(", ")", "errors", "=", "[", "]", "for", "callback", "in", "resource", ".", "callbacks", ":", "new_errors", "=", "checker", "(", "callback", ")", "if"...
Iteratively check all methods (endpoints) in the Resource.
[ "Iteratively", "check", "all", "methods", "(", "endpoints", ")", "in", "the", "Resource", "." ]
train
https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/checker.py#L213-L221
sassoo/goldman
goldman/queryparams/include.py
init
def init(req, model): """ Return an array of fields to include. """ rels = model.relationships params = req.get_param_as_list('include') or [] params = [param.lower() for param in params] for param in params: _validate_no_nesting(param) _validate_rels(param, rels) return param...
python
def init(req, model): """ Return an array of fields to include. """ rels = model.relationships params = req.get_param_as_list('include') or [] params = [param.lower() for param in params] for param in params: _validate_no_nesting(param) _validate_rels(param, rels) return param...
[ "def", "init", "(", "req", ",", "model", ")", ":", "rels", "=", "model", ".", "relationships", "params", "=", "req", ".", "get_param_as_list", "(", "'include'", ")", "or", "[", "]", "params", "=", "[", "param", ".", "lower", "(", ")", "for", "param",...
Return an array of fields to include.
[ "Return", "an", "array", "of", "fields", "to", "include", "." ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/queryparams/include.py#L46-L57
maxfischer2781/include
include/inhibit.py
DisabledIncludeTypes.disable
def disable(self, identifier, children_only=False): """ Disable an include type :param identifier: module or name of the include type :param children_only: disable the include type only for child processes, not the current process The ``identifier`` can be specified in multiple...
python
def disable(self, identifier, children_only=False): """ Disable an include type :param identifier: module or name of the include type :param children_only: disable the include type only for child processes, not the current process The ``identifier`` can be specified in multiple...
[ "def", "disable", "(", "self", ",", "identifier", ",", "children_only", "=", "False", ")", ":", "import_path", "=", "self", ".", "_identifier2import_path", "(", "identifier", "=", "identifier", ")", "if", "not", "children_only", "and", "import_path", "not", "i...
Disable an include type :param identifier: module or name of the include type :param children_only: disable the include type only for child processes, not the current process The ``identifier`` can be specified in multiple ways to disable an include type: **module** (``include.files``...
[ "Disable", "an", "include", "type" ]
train
https://github.com/maxfischer2781/include/blob/d8b0404f4996b6abcd39fdebf282b31fad8bb6f5/include/inhibit.py#L66-L94
maxfischer2781/include
include/inhibit.py
DisabledIncludeTypes.enable
def enable(self, identifier, exclude_children=False): """ Enable a previously disabled include type :param identifier: module or name of the include type :param exclude_children: disable the include type only for child processes, not the current process The ``identifier`` can b...
python
def enable(self, identifier, exclude_children=False): """ Enable a previously disabled include type :param identifier: module or name of the include type :param exclude_children: disable the include type only for child processes, not the current process The ``identifier`` can b...
[ "def", "enable", "(", "self", ",", "identifier", ",", "exclude_children", "=", "False", ")", ":", "import_path", "=", "self", ".", "_identifier2import_path", "(", "identifier", "=", "identifier", ")", "if", "import_path", "in", "self", ".", "_disabled", ":", ...
Enable a previously disabled include type :param identifier: module or name of the include type :param exclude_children: disable the include type only for child processes, not the current process The ``identifier`` can be specified in multiple ways to disable an include type. See :py:m...
[ "Enable", "a", "previously", "disabled", "include", "type" ]
train
https://github.com/maxfischer2781/include/blob/d8b0404f4996b6abcd39fdebf282b31fad8bb6f5/include/inhibit.py#L96-L112
maxfischer2781/include
include/inhibit.py
DisabledTypeLoader.load_module
def load_module(self, name): """ Load and return a module If the module is already loaded, the existing module is returned. Otherwise, raises :py:exc:`DisabledIncludeError`. """ # allow reload noop if name in sys.modules: return sys.modules[name] ...
python
def load_module(self, name): """ Load and return a module If the module is already loaded, the existing module is returned. Otherwise, raises :py:exc:`DisabledIncludeError`. """ # allow reload noop if name in sys.modules: return sys.modules[name] ...
[ "def", "load_module", "(", "self", ",", "name", ")", ":", "# allow reload noop", "if", "name", "in", "sys", ".", "modules", ":", "return", "sys", ".", "modules", "[", "name", "]", "raise", "DisabledIncludeError", "(", "'Include type %r disabled, cannot import modu...
Load and return a module If the module is already loaded, the existing module is returned. Otherwise, raises :py:exc:`DisabledIncludeError`.
[ "Load", "and", "return", "a", "module" ]
train
https://github.com/maxfischer2781/include/blob/d8b0404f4996b6abcd39fdebf282b31fad8bb6f5/include/inhibit.py#L184-L194
lambdalisue/maidenhair
src/maidenhair/filters/relative.py
relative
def relative(dataset, ori=0, column=1, fail_silently=True): """ Convert dataset to relative value from the value of :attr:`ori` Parameters ---------- dataset : list of numpy array list A list of numpy array list ori : integer or numpy array, optional A relative original data ind...
python
def relative(dataset, ori=0, column=1, fail_silently=True): """ Convert dataset to relative value from the value of :attr:`ori` Parameters ---------- dataset : list of numpy array list A list of numpy array list ori : integer or numpy array, optional A relative original data ind...
[ "def", "relative", "(", "dataset", ",", "ori", "=", "0", ",", "column", "=", "1", ",", "fail_silently", "=", "True", ")", ":", "try", ":", "if", "isinstance", "(", "ori", ",", "int", ")", ":", "# relative from the [ori]th array", "ori", "=", "dataset", ...
Convert dataset to relative value from the value of :attr:`ori` Parameters ---------- dataset : list of numpy array list A list of numpy array list ori : integer or numpy array, optional A relative original data index or numpy array column : integer, optional An index of bas...
[ "Convert", "dataset", "to", "relative", "value", "from", "the", "value", "of", ":", "attr", ":", "ori" ]
train
https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/filters/relative.py#L10-L79
matthewdeanmartin/jiggle_version
build_utils.py
execute_get_text
def execute_get_text(command): # type: (str) ->str """ Execute shell command and return stdout txt :param command: :return: """ try: _ = subprocess.run try: completed = subprocess.run( command, check=True, shell=True, ...
python
def execute_get_text(command): # type: (str) ->str """ Execute shell command and return stdout txt :param command: :return: """ try: _ = subprocess.run try: completed = subprocess.run( command, check=True, shell=True, ...
[ "def", "execute_get_text", "(", "command", ")", ":", "# type: (str) ->str", "try", ":", "_", "=", "subprocess", ".", "run", "try", ":", "completed", "=", "subprocess", ".", "run", "(", "command", ",", "check", "=", "True", ",", "shell", "=", "True", ",",...
Execute shell command and return stdout txt :param command: :return:
[ "Execute", "shell", "command", "and", "return", "stdout", "txt", ":", "param", "command", ":", ":", "return", ":" ]
train
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/build_utils.py#L143-L170
jgoodlet/punter
punter/helpers.py
get_query_type
def get_query_type(query): """Gets the type of query in use (email or url). In order to provide a proper API endpoint it is necessary to first determine the type of query the client is using. There are only two options currently: 1) domain or 2) email. :param query: Search query provided by client...
python
def get_query_type(query): """Gets the type of query in use (email or url). In order to provide a proper API endpoint it is necessary to first determine the type of query the client is using. There are only two options currently: 1) domain or 2) email. :param query: Search query provided by client...
[ "def", "get_query_type", "(", "query", ")", ":", "if", "URL_RE", ".", "match", "(", "query", ")", ":", "query_type", "=", "'domain'", "elif", "EMAIL_RE", ".", "match", "(", "query", ")", ":", "query_type", "=", "'email'", "else", ":", "query_type", "=", ...
Gets the type of query in use (email or url). In order to provide a proper API endpoint it is necessary to first determine the type of query the client is using. There are only two options currently: 1) domain or 2) email. :param query: Search query provided by client.
[ "Gets", "the", "type", "of", "query", "in", "use", "(", "email", "or", "url", ")", "." ]
train
https://github.com/jgoodlet/punter/blob/605ee52a1e5019b360dd643f4bf6861aefa93812/punter/helpers.py#L38-L56
jgoodlet/punter
punter/helpers.py
get_endpoint
def get_endpoint(api_key, query, offset, type): """Return endpoint URL for the relevant search type. The base API endpoint only varies by type of search requested, of which there are two: 1) domain search and 2) email search. Each search type requires different parameters, though api_key is common ...
python
def get_endpoint(api_key, query, offset, type): """Return endpoint URL for the relevant search type. The base API endpoint only varies by type of search requested, of which there are two: 1) domain search and 2) email search. Each search type requires different parameters, though api_key is common ...
[ "def", "get_endpoint", "(", "api_key", ",", "query", ",", "offset", ",", "type", ")", ":", "query_type", "=", "get_query_type", "(", "query", ")", "if", "query_type", "not", "in", "(", "'domain'", ",", "'email'", ")", ":", "raise", "ex", ".", "InvalidQue...
Return endpoint URL for the relevant search type. The base API endpoint only varies by type of search requested, of which there are two: 1) domain search and 2) email search. Each search type requires different parameters, though api_key is common between them. Note: if both a url and email addres...
[ "Return", "endpoint", "URL", "for", "the", "relevant", "search", "type", "." ]
train
https://github.com/jgoodlet/punter/blob/605ee52a1e5019b360dd643f4bf6861aefa93812/punter/helpers.py#L59-L86
pydsigner/pygu
pygu/common.py
center_blit
def center_blit(target, source, dest = (0, 0), area=None, special_flags=0): ''' Blits surface @source to the center of surface @target. Takes the normal Surface.blit() flags; however, @dest is used as an offset. ''' loc = lambda d, s: _vec(d.get_size()) / 2 - _vec(s.get_size()) / 2 _blitter(loc...
python
def center_blit(target, source, dest = (0, 0), area=None, special_flags=0): ''' Blits surface @source to the center of surface @target. Takes the normal Surface.blit() flags; however, @dest is used as an offset. ''' loc = lambda d, s: _vec(d.get_size()) / 2 - _vec(s.get_size()) / 2 _blitter(loc...
[ "def", "center_blit", "(", "target", ",", "source", ",", "dest", "=", "(", "0", ",", "0", ")", ",", "area", "=", "None", ",", "special_flags", "=", "0", ")", ":", "loc", "=", "lambda", "d", ",", "s", ":", "_vec", "(", "d", ".", "get_size", "(",...
Blits surface @source to the center of surface @target. Takes the normal Surface.blit() flags; however, @dest is used as an offset.
[ "Blits", "surface" ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/common.py#L17-L23
pydsigner/pygu
pygu/common.py
vcenter_blit
def vcenter_blit(target, source, dest = (0, 0), area=None, special_flags=0): ''' The same as center_blit(), but only centers vertically. ''' loc = lambda d, s: (_vec(0, d.get_height() / 2) - _vec(0, s.get_height() / 2)) _blitter(loc, target, source, dest, area, special_flags)
python
def vcenter_blit(target, source, dest = (0, 0), area=None, special_flags=0): ''' The same as center_blit(), but only centers vertically. ''' loc = lambda d, s: (_vec(0, d.get_height() / 2) - _vec(0, s.get_height() / 2)) _blitter(loc, target, source, dest, area, special_flags)
[ "def", "vcenter_blit", "(", "target", ",", "source", ",", "dest", "=", "(", "0", ",", "0", ")", ",", "area", "=", "None", ",", "special_flags", "=", "0", ")", ":", "loc", "=", "lambda", "d", ",", "s", ":", "(", "_vec", "(", "0", ",", "d", "."...
The same as center_blit(), but only centers vertically.
[ "The", "same", "as", "center_blit", "()", "but", "only", "centers", "vertically", "." ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/common.py#L26-L32
pydsigner/pygu
pygu/common.py
hcenter_blit
def hcenter_blit(target, source, dest = (0, 0), area=None, special_flags=0): ''' The same as center_blit(), but only centers horizontally. ''' loc = lambda d, s: (_vec(d.get_width() / 2, 0) - _vec(s.get_width() / 2, 0)) _blitter(loc, target, source, dest, area, special_flags)
python
def hcenter_blit(target, source, dest = (0, 0), area=None, special_flags=0): ''' The same as center_blit(), but only centers horizontally. ''' loc = lambda d, s: (_vec(d.get_width() / 2, 0) - _vec(s.get_width() / 2, 0)) _blitter(loc, target, source, dest, area, special_flags)
[ "def", "hcenter_blit", "(", "target", ",", "source", ",", "dest", "=", "(", "0", ",", "0", ")", ",", "area", "=", "None", ",", "special_flags", "=", "0", ")", ":", "loc", "=", "lambda", "d", ",", "s", ":", "(", "_vec", "(", "d", ".", "get_width...
The same as center_blit(), but only centers horizontally.
[ "The", "same", "as", "center_blit", "()", "but", "only", "centers", "horizontally", "." ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/common.py#L35-L41
radjkarl/fancyTools
fancytools/utils/incrementName.py
incrementName
def incrementName(nameList, name): """ return a name that is unique in a given nameList through attaching a number to it >>> l = [] now we will add 3xfoo 2xbar and one klaus to our list: >>> l.append( incrementName(l,'foo') ) >>> l.append( incrementName(l,'bar') ) >>> l.append( increm...
python
def incrementName(nameList, name): """ return a name that is unique in a given nameList through attaching a number to it >>> l = [] now we will add 3xfoo 2xbar and one klaus to our list: >>> l.append( incrementName(l,'foo') ) >>> l.append( incrementName(l,'bar') ) >>> l.append( increm...
[ "def", "incrementName", "(", "nameList", ",", "name", ")", ":", "if", "name", "not", "in", "nameList", ":", "return", "name", "newName", "=", "name", "+", "str", "(", "1", ")", "for", "n", "in", "range", "(", "1", ",", "len", "(", "nameList", ")", ...
return a name that is unique in a given nameList through attaching a number to it >>> l = [] now we will add 3xfoo 2xbar and one klaus to our list: >>> l.append( incrementName(l,'foo') ) >>> l.append( incrementName(l,'bar') ) >>> l.append( incrementName(l,'foo') ) >>> l.append( incrementN...
[ "return", "a", "name", "that", "is", "unique", "in", "a", "given", "nameList", "through", "attaching", "a", "number", "to", "it" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/utils/incrementName.py#L3-L33
akatrevorjay/mainline
mainline/provider.py
provider_factory
def provider_factory(factory=_sentinel, scope=NoneScope): ''' Decorator to create a provider using the given factory, and scope. Can also be used in a non-decorator manner. :param scope: Scope key, factory, or instance :type scope: object or callable :return: decorator :rtype: decorator ...
python
def provider_factory(factory=_sentinel, scope=NoneScope): ''' Decorator to create a provider using the given factory, and scope. Can also be used in a non-decorator manner. :param scope: Scope key, factory, or instance :type scope: object or callable :return: decorator :rtype: decorator ...
[ "def", "provider_factory", "(", "factory", "=", "_sentinel", ",", "scope", "=", "NoneScope", ")", ":", "if", "factory", "is", "_sentinel", ":", "return", "functools", ".", "partial", "(", "provider_factory", ",", "scope", "=", "scope", ")", "provider", "=", ...
Decorator to create a provider using the given factory, and scope. Can also be used in a non-decorator manner. :param scope: Scope key, factory, or instance :type scope: object or callable :return: decorator :rtype: decorator
[ "Decorator", "to", "create", "a", "provider", "using", "the", "given", "factory", "and", "scope", ".", "Can", "also", "be", "used", "in", "a", "non", "-", "decorator", "manner", "." ]
train
https://github.com/akatrevorjay/mainline/blob/8aa7f6ef6cad4051fcd5f8d43d2ba8cdad681986/mainline/provider.py#L79-L92
radjkarl/fancyTools
fancytools/geometry/quad.py
scaleToBoxParam
def scaleToBoxParam(quad, shape): ''' so, you have a [quad] ((x0,y0),,,) inside a box [shape](width,height) this function gives you center [x,y], and scale factor [x,y] you would need to apply to [quad] in order to scale it to the same shape as the box !quad corners needs to be sorted...
python
def scaleToBoxParam(quad, shape): ''' so, you have a [quad] ((x0,y0),,,) inside a box [shape](width,height) this function gives you center [x,y], and scale factor [x,y] you would need to apply to [quad] in order to scale it to the same shape as the box !quad corners needs to be sorted...
[ "def", "scaleToBoxParam", "(", "quad", ",", "shape", ")", ":", "#get edge middle points", "x0", "=", "0.5", "*", "(", "quad", "[", "0", "]", "[", "0", "]", "+", "quad", "[", "1", "]", "[", "0", "]", ")", "x1", "=", "0.5", "*", "(", "quad", "[",...
so, you have a [quad] ((x0,y0),,,) inside a box [shape](width,height) this function gives you center [x,y], and scale factor [x,y] you would need to apply to [quad] in order to scale it to the same shape as the box !quad corners needs to be sorted like in example
[ "so", "you", "have", "a", "[", "quad", "]", "((", "x0", "y0", ")", ")", "inside", "a", "box", "[", "shape", "]", "(", "width", "height", ")", "this", "function", "gives", "you", "center", "[", "x", "y", "]", "and", "scale", "factor", "[", "x", ...
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/geometry/quad.py#L7-L31
ppo/django-guitar
guitar/utils/choices.py
Choices.get_from_human_key
def get_from_human_key(self, key): """Return the key (aka database value) of a human key (aka Python identifier).""" if key in self._identifier_map: return self._identifier_map[key] raise KeyError(key)
python
def get_from_human_key(self, key): """Return the key (aka database value) of a human key (aka Python identifier).""" if key in self._identifier_map: return self._identifier_map[key] raise KeyError(key)
[ "def", "get_from_human_key", "(", "self", ",", "key", ")", ":", "if", "key", "in", "self", ".", "_identifier_map", ":", "return", "self", ".", "_identifier_map", "[", "key", "]", "raise", "KeyError", "(", "key", ")" ]
Return the key (aka database value) of a human key (aka Python identifier).
[ "Return", "the", "key", "(", "aka", "database", "value", ")", "of", "a", "human", "key", "(", "aka", "Python", "identifier", ")", "." ]
train
https://github.com/ppo/django-guitar/blob/857282219c0c4ff5907c3ad04ef012281d245348/guitar/utils/choices.py#L60-L64
ppo/django-guitar
guitar/utils/choices.py
Choices.get_human_key
def get_human_key(self, key): """Return the human key (aka Python identifier) of a key (aka database value).""" for human_key, k in self._identifier_map.items(): if k == key: return human_key raise KeyError(key)
python
def get_human_key(self, key): """Return the human key (aka Python identifier) of a key (aka database value).""" for human_key, k in self._identifier_map.items(): if k == key: return human_key raise KeyError(key)
[ "def", "get_human_key", "(", "self", ",", "key", ")", ":", "for", "human_key", ",", "k", "in", "self", ".", "_identifier_map", ".", "items", "(", ")", ":", "if", "k", "==", "key", ":", "return", "human_key", "raise", "KeyError", "(", "key", ")" ]
Return the human key (aka Python identifier) of a key (aka database value).
[ "Return", "the", "human", "key", "(", "aka", "Python", "identifier", ")", "of", "a", "key", "(", "aka", "database", "value", ")", "." ]
train
https://github.com/ppo/django-guitar/blob/857282219c0c4ff5907c3ad04ef012281d245348/guitar/utils/choices.py#L66-L71
sassoo/goldman
goldman/types/to_many.py
ToMany.load
def load(self): """ Return the model from the store """ filters = [Filter(self.field, 'eq', self.rid)] store = goldman.sess.store self._is_loaded = True self.models = store.search(self.rtype, filters=filters) return self.models
python
def load(self): """ Return the model from the store """ filters = [Filter(self.field, 'eq', self.rid)] store = goldman.sess.store self._is_loaded = True self.models = store.search(self.rtype, filters=filters) return self.models
[ "def", "load", "(", "self", ")", ":", "filters", "=", "[", "Filter", "(", "self", ".", "field", ",", "'eq'", ",", "self", ".", "rid", ")", "]", "store", "=", "goldman", ".", "sess", ".", "store", "self", ".", "_is_loaded", "=", "True", "self", "....
Return the model from the store
[ "Return", "the", "model", "from", "the", "store" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/types/to_many.py#L59-L68
sassoo/goldman
goldman/types/to_many.py
Type.to_native
def to_native(self, value, context=None): """ Schematics deserializer override :return: ToMany instance """ if isinstance(value, ToMany): return value else: return ToMany(self.rtype, self.field, value)
python
def to_native(self, value, context=None): """ Schematics deserializer override :return: ToMany instance """ if isinstance(value, ToMany): return value else: return ToMany(self.rtype, self.field, value)
[ "def", "to_native", "(", "self", ",", "value", ",", "context", "=", "None", ")", ":", "if", "isinstance", "(", "value", ",", "ToMany", ")", ":", "return", "value", "else", ":", "return", "ToMany", "(", "self", ".", "rtype", ",", "self", ".", "field",...
Schematics deserializer override :return: ToMany instance
[ "Schematics", "deserializer", "override" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/types/to_many.py#L88-L97
sassoo/goldman
goldman/types/to_many.py
Type.to_primitive
def to_primitive(self, value, context=None): """ Schematics serializer override The return values vary to indicate whether or not the relationships is loaded with values (list with members), loaded but no values (empty list), or never loaded & unknown if values exist or not. ...
python
def to_primitive(self, value, context=None): """ Schematics serializer override The return values vary to indicate whether or not the relationships is loaded with values (list with members), loaded but no values (empty list), or never loaded & unknown if values exist or not. ...
[ "def", "to_primitive", "(", "self", ",", "value", ",", "context", "=", "None", ")", ":", "data", "=", "[", "]", "if", "not", "value", ".", "is_loaded", ":", "return", "None", "for", "model", "in", "value", ".", "models", ":", "if", "context", "and", ...
Schematics serializer override The return values vary to indicate whether or not the relationships is loaded with values (list with members), loaded but no values (empty list), or never loaded & unknown if values exist or not.
[ "Schematics", "serializer", "override" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/types/to_many.py#L99-L119
bwesterb/tkbd
src/sqlite3History.py
Sqlite3History._id_for_pc
def _id_for_pc(self, name): """ Given the name of the PC, return the database identifier. """ if not name in self.pc2id_lut: self.c.execute("INSERT INTO pcs (name) VALUES ( ? )", (name,)) self.pc2id_lut[name] = self.c.lastrowid self.id2pc_lut[self.c.lastrowid] = name ...
python
def _id_for_pc(self, name): """ Given the name of the PC, return the database identifier. """ if not name in self.pc2id_lut: self.c.execute("INSERT INTO pcs (name) VALUES ( ? )", (name,)) self.pc2id_lut[name] = self.c.lastrowid self.id2pc_lut[self.c.lastrowid] = name ...
[ "def", "_id_for_pc", "(", "self", ",", "name", ")", ":", "if", "not", "name", "in", "self", ".", "pc2id_lut", ":", "self", ".", "c", ".", "execute", "(", "\"INSERT INTO pcs (name) VALUES ( ? )\"", ",", "(", "name", ",", ")", ")", "self", ".", "pc2id_lut"...
Given the name of the PC, return the database identifier.
[ "Given", "the", "name", "of", "the", "PC", "return", "the", "database", "identifier", "." ]
train
https://github.com/bwesterb/tkbd/blob/fcf16977d38a93fe9b7fa198513007ab9921b650/src/sqlite3History.py#L60-L66
bwesterb/tkbd
src/sqlite3History.py
Sqlite3History._id_for_source
def _id_for_source(self, name): """ Given the name of the source, return the database identifier. """ if not name in self.source2id_lut: self.c.execute("INSERT INTO sources (name) VALUES ( ? )", (name,)) self.source2id_lut[name] = self.c.lastrowid self.id2source_lut[s...
python
def _id_for_source(self, name): """ Given the name of the source, return the database identifier. """ if not name in self.source2id_lut: self.c.execute("INSERT INTO sources (name) VALUES ( ? )", (name,)) self.source2id_lut[name] = self.c.lastrowid self.id2source_lut[s...
[ "def", "_id_for_source", "(", "self", ",", "name", ")", ":", "if", "not", "name", "in", "self", ".", "source2id_lut", ":", "self", ".", "c", ".", "execute", "(", "\"INSERT INTO sources (name) VALUES ( ? )\"", ",", "(", "name", ",", ")", ")", "self", ".", ...
Given the name of the source, return the database identifier.
[ "Given", "the", "name", "of", "the", "source", "return", "the", "database", "identifier", "." ]
train
https://github.com/bwesterb/tkbd/blob/fcf16977d38a93fe9b7fa198513007ab9921b650/src/sqlite3History.py#L67-L73
bwesterb/tkbd
src/sqlite3History.py
Sqlite3History.get_occupation
def get_occupation(self): """ Returns the occupation as was last recorded. """ ret = {} self.l.info("Reading occupation from database...") with self.lock: for pc_name, pc_id in self.pc2id_lut.iteritems(): self.c.execute(""" SELECT occupation FROM occupationUpd...
python
def get_occupation(self): """ Returns the occupation as was last recorded. """ ret = {} self.l.info("Reading occupation from database...") with self.lock: for pc_name, pc_id in self.pc2id_lut.iteritems(): self.c.execute(""" SELECT occupation FROM occupationUpd...
[ "def", "get_occupation", "(", "self", ")", ":", "ret", "=", "{", "}", "self", ".", "l", ".", "info", "(", "\"Reading occupation from database...\"", ")", "with", "self", ".", "lock", ":", "for", "pc_name", ",", "pc_id", "in", "self", ".", "pc2id_lut", "....
Returns the occupation as was last recorded.
[ "Returns", "the", "occupation", "as", "was", "last", "recorded", "." ]
train
https://github.com/bwesterb/tkbd/blob/fcf16977d38a93fe9b7fa198513007ab9921b650/src/sqlite3History.py#L75-L89
bwesterb/tkbd
src/sqlite3History.py
Sqlite3History.record_occupation_updates
def record_occupation_updates(self, updates, source, version): """ Records an occupation update """ now = int(time.time()) # Put it on the recordQueue and notify the worker thread. with self.recordCond: self.recordQueue.append((now, updates, source)) self.recordCo...
python
def record_occupation_updates(self, updates, source, version): """ Records an occupation update """ now = int(time.time()) # Put it on the recordQueue and notify the worker thread. with self.recordCond: self.recordQueue.append((now, updates, source)) self.recordCo...
[ "def", "record_occupation_updates", "(", "self", ",", "updates", ",", "source", ",", "version", ")", ":", "now", "=", "int", "(", "time", ".", "time", "(", ")", ")", "# Put it on the recordQueue and notify the worker thread.", "with", "self", ".", "recordCond", ...
Records an occupation update
[ "Records", "an", "occupation", "update" ]
train
https://github.com/bwesterb/tkbd/blob/fcf16977d38a93fe9b7fa198513007ab9921b650/src/sqlite3History.py#L91-L97
bwesterb/tkbd
src/sqlite3History.py
Sqlite3History.get_occupation_updates
def get_occupation_updates(self, offset=0, count=1000): """ Returns <count> occupation updates from <offset>. An occupation update is a quadrupel (pc, source, timestamp, occupation) """ ret = [] c = self.conn.cursor() for pc_id, source_id, datetime, ...
python
def get_occupation_updates(self, offset=0, count=1000): """ Returns <count> occupation updates from <offset>. An occupation update is a quadrupel (pc, source, timestamp, occupation) """ ret = [] c = self.conn.cursor() for pc_id, source_id, datetime, ...
[ "def", "get_occupation_updates", "(", "self", ",", "offset", "=", "0", ",", "count", "=", "1000", ")", ":", "ret", "=", "[", "]", "c", "=", "self", ".", "conn", ".", "cursor", "(", ")", "for", "pc_id", ",", "source_id", ",", "datetime", ",", "occup...
Returns <count> occupation updates from <offset>. An occupation update is a quadrupel (pc, source, timestamp, occupation)
[ "Returns", "<count", ">", "occupation", "updates", "from", "<offset", ">", ".", "An", "occupation", "update", "is", "a", "quadrupel" ]
train
https://github.com/bwesterb/tkbd/blob/fcf16977d38a93fe9b7fa198513007ab9921b650/src/sqlite3History.py#L99-L115
bwesterb/tkbd
src/sqlite3History.py
Sqlite3History.run
def run(self): """ Runs the worker thread that records occupation updates to the database. """ # TODO is a separate thread necessary? Wouldn't a threadPool.execute # suffice? self.running = True self.recordCond.acquire() while self.running or self.record...
python
def run(self): """ Runs the worker thread that records occupation updates to the database. """ # TODO is a separate thread necessary? Wouldn't a threadPool.execute # suffice? self.running = True self.recordCond.acquire() while self.running or self.record...
[ "def", "run", "(", "self", ")", ":", "# TODO is a separate thread necessary? Wouldn't a threadPool.execute", "# suffice?", "self", ".", "running", "=", "True", "self", ".", "recordCond", ".", "acquire", "(", ")", "while", "self", ".", "running", "or", "self", ...
Runs the worker thread that records occupation updates to the database.
[ "Runs", "the", "worker", "thread", "that", "records", "occupation", "updates", "to", "the", "database", "." ]
train
https://github.com/bwesterb/tkbd/blob/fcf16977d38a93fe9b7fa198513007ab9921b650/src/sqlite3History.py#L122-L148
dossier/dossier.models
dossier/models/features/basic.py
phones
def phones(text): '''Returns list of phone numbers without punctuation.''' return imap(lambda m: m.group(0).replace('-', ''), REGEX_PHONE.finditer(text))
python
def phones(text): '''Returns list of phone numbers without punctuation.''' return imap(lambda m: m.group(0).replace('-', ''), REGEX_PHONE.finditer(text))
[ "def", "phones", "(", "text", ")", ":", "return", "imap", "(", "lambda", "m", ":", "m", ".", "group", "(", "0", ")", ".", "replace", "(", "'-'", ",", "''", ")", ",", "REGEX_PHONE", ".", "finditer", "(", "text", ")", ")" ]
Returns list of phone numbers without punctuation.
[ "Returns", "list", "of", "phone", "numbers", "without", "punctuation", "." ]
train
https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/features/basic.py#L41-L44
dossier/dossier.models
dossier/models/features/basic.py
emails
def emails(text): '''Returns list of phone numbers without punctuation.''' return imap(lambda m: m.group(0).lower(), REGEX_EMAIL.finditer(text))
python
def emails(text): '''Returns list of phone numbers without punctuation.''' return imap(lambda m: m.group(0).lower(), REGEX_EMAIL.finditer(text))
[ "def", "emails", "(", "text", ")", ":", "return", "imap", "(", "lambda", "m", ":", "m", ".", "group", "(", "0", ")", ".", "lower", "(", ")", ",", "REGEX_EMAIL", ".", "finditer", "(", "text", ")", ")" ]
Returns list of phone numbers without punctuation.
[ "Returns", "list", "of", "phone", "numbers", "without", "punctuation", "." ]
train
https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/features/basic.py#L47-L49
dossier/dossier.models
dossier/models/features/basic.py
a_urls
def a_urls(html): ''' return normalized urls found in the 'a' tag ''' soup = BeautifulSoup(html, 'lxml') for node in soup.find_all('a'): try: href = node['href'] except KeyError: continue yield norm_url(href)
python
def a_urls(html): ''' return normalized urls found in the 'a' tag ''' soup = BeautifulSoup(html, 'lxml') for node in soup.find_all('a'): try: href = node['href'] except KeyError: continue yield norm_url(href)
[ "def", "a_urls", "(", "html", ")", ":", "soup", "=", "BeautifulSoup", "(", "html", ",", "'lxml'", ")", "for", "node", "in", "soup", ".", "find_all", "(", "'a'", ")", ":", "try", ":", "href", "=", "node", "[", "'href'", "]", "except", "KeyError", ":...
return normalized urls found in the 'a' tag
[ "return", "normalized", "urls", "found", "in", "the", "a", "tag" ]
train
https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/features/basic.py#L65-L75
dossier/dossier.models
dossier/models/features/basic.py
host_names
def host_names(urls): ''' Takes a StringCounter of normalized URL and parses their hostnames N.B. this assumes that absolute URLs will begin with http:// in order to accurately resolve the host name. Relative URLs will not have host names. ''' host_names = StringCounter() for url ...
python
def host_names(urls): ''' Takes a StringCounter of normalized URL and parses their hostnames N.B. this assumes that absolute URLs will begin with http:// in order to accurately resolve the host name. Relative URLs will not have host names. ''' host_names = StringCounter() for url ...
[ "def", "host_names", "(", "urls", ")", ":", "host_names", "=", "StringCounter", "(", ")", "for", "url", "in", "urls", ":", "host_names", "[", "urlparse", "(", "url", ")", ".", "netloc", "]", "+=", "urls", "[", "url", "]", "return", "host_names" ]
Takes a StringCounter of normalized URL and parses their hostnames N.B. this assumes that absolute URLs will begin with http:// in order to accurately resolve the host name. Relative URLs will not have host names.
[ "Takes", "a", "StringCounter", "of", "normalized", "URL", "and", "parses", "their", "hostnames" ]
train
https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/features/basic.py#L78-L92
dossier/dossier.models
dossier/models/features/basic.py
path_dirs
def path_dirs(urls): ''' Takes a StringCounter of normalized URL and parses them into a list of path directories. The file name is included in the path directory list. ''' path_dirs = StringCounter() for url in urls: for path_dir in filter(None, urlparse(url).path.split('/')): ...
python
def path_dirs(urls): ''' Takes a StringCounter of normalized URL and parses them into a list of path directories. The file name is included in the path directory list. ''' path_dirs = StringCounter() for url in urls: for path_dir in filter(None, urlparse(url).path.split('/')): ...
[ "def", "path_dirs", "(", "urls", ")", ":", "path_dirs", "=", "StringCounter", "(", ")", "for", "url", "in", "urls", ":", "for", "path_dir", "in", "filter", "(", "None", ",", "urlparse", "(", "url", ")", ".", "path", ".", "split", "(", "'/'", ")", "...
Takes a StringCounter of normalized URL and parses them into a list of path directories. The file name is included in the path directory list.
[ "Takes", "a", "StringCounter", "of", "normalized", "URL", "and", "parses", "them", "into", "a", "list", "of", "path", "directories", ".", "The", "file", "name", "is", "included", "in", "the", "path", "directory", "list", "." ]
train
https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/features/basic.py#L95-L105
mbanton/nose-mongoengine
nose_mongoengine/__init__.py
scan_path
def scan_path(executable="mongod"): """Scan the path for a binary. """ for path in os.environ.get("PATH", "").split(":"): path = os.path.abspath(path) executable_path = os.path.join(path, executable) if os.path.exists(executable_path): return executable_path
python
def scan_path(executable="mongod"): """Scan the path for a binary. """ for path in os.environ.get("PATH", "").split(":"): path = os.path.abspath(path) executable_path = os.path.join(path, executable) if os.path.exists(executable_path): return executable_path
[ "def", "scan_path", "(", "executable", "=", "\"mongod\"", ")", ":", "for", "path", "in", "os", ".", "environ", ".", "get", "(", "\"PATH\"", ",", "\"\"", ")", ".", "split", "(", "\":\"", ")", ":", "path", "=", "os", ".", "path", ".", "abspath", "(",...
Scan the path for a binary.
[ "Scan", "the", "path", "for", "a", "binary", "." ]
train
https://github.com/mbanton/nose-mongoengine/blob/3a06f52cd32f217b512af4a76d8ed4174185df59/nose_mongoengine/__init__.py#L34-L41
mbanton/nose-mongoengine
nose_mongoengine/__init__.py
get_open_port
def get_open_port(host="localhost"): """Get an open port on the machine. """ temp_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) temp_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) temp_sock.bind((host, 0)) port = temp_sock.getsockname()[1] temp_sock.close() del tem...
python
def get_open_port(host="localhost"): """Get an open port on the machine. """ temp_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) temp_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) temp_sock.bind((host, 0)) port = temp_sock.getsockname()[1] temp_sock.close() del tem...
[ "def", "get_open_port", "(", "host", "=", "\"localhost\"", ")", ":", "temp_sock", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "temp_sock", ".", "setsockopt", "(", "socket", ".", "SOL_SOCKET", ",", "s...
Get an open port on the machine.
[ "Get", "an", "open", "port", "on", "the", "machine", "." ]
train
https://github.com/mbanton/nose-mongoengine/blob/3a06f52cd32f217b512af4a76d8ed4174185df59/nose_mongoengine/__init__.py#L44-L53
mbanton/nose-mongoengine
nose_mongoengine/__init__.py
MongoEnginePlugin.configure
def configure(self, options, conf): """Parse the command line options and start an instance of mongodb """ # This option has to be specified on the command line, to enable the # plugin. if not options.mongoengine or options.mongodb_bin: return if not options....
python
def configure(self, options, conf): """Parse the command line options and start an instance of mongodb """ # This option has to be specified on the command line, to enable the # plugin. if not options.mongoengine or options.mongodb_bin: return if not options....
[ "def", "configure", "(", "self", ",", "options", ",", "conf", ")", ":", "# This option has to be specified on the command line, to enable the", "# plugin.", "if", "not", "options", ".", "mongoengine", "or", "options", ".", "mongodb_bin", ":", "return", "if", "not", ...
Parse the command line options and start an instance of mongodb
[ "Parse", "the", "command", "line", "options", "and", "start", "an", "instance", "of", "mongodb" ]
train
https://github.com/mbanton/nose-mongoengine/blob/3a06f52cd32f217b512af4a76d8ed4174185df59/nose_mongoengine/__init__.py#L125-L227
mbanton/nose-mongoengine
nose_mongoengine/__init__.py
MongoEnginePlugin.stopContext
def stopContext(self, context): """Clear the database if so configured for this """ # Use pymongo directly to drop all collections of created db if ((self.clear_context['module'] and inspect.ismodule(context)) or (self.clear_context['class'] and inspect.isclass(context))): ...
python
def stopContext(self, context): """Clear the database if so configured for this """ # Use pymongo directly to drop all collections of created db if ((self.clear_context['module'] and inspect.ismodule(context)) or (self.clear_context['class'] and inspect.isclass(context))): ...
[ "def", "stopContext", "(", "self", ",", "context", ")", ":", "# Use pymongo directly to drop all collections of created db", "if", "(", "(", "self", ".", "clear_context", "[", "'module'", "]", "and", "inspect", ".", "ismodule", "(", "context", ")", ")", "or", "(...
Clear the database if so configured for this
[ "Clear", "the", "database", "if", "so", "configured", "for", "this" ]
train
https://github.com/mbanton/nose-mongoengine/blob/3a06f52cd32f217b512af4a76d8ed4174185df59/nose_mongoengine/__init__.py#L229-L236
mbanton/nose-mongoengine
nose_mongoengine/__init__.py
MongoEnginePlugin.finalize
def finalize(self, result): """Stop the mongodb instance. """ if not self._running: return # Clear out the env variable. del os.environ["TEST_MONGODB"] del os.environ["TEST_MONGODB_DATABASE"] # Kill the mongod process if sys.platform == 'dar...
python
def finalize(self, result): """Stop the mongodb instance. """ if not self._running: return # Clear out the env variable. del os.environ["TEST_MONGODB"] del os.environ["TEST_MONGODB_DATABASE"] # Kill the mongod process if sys.platform == 'dar...
[ "def", "finalize", "(", "self", ",", "result", ")", ":", "if", "not", "self", ".", "_running", ":", "return", "# Clear out the env variable.", "del", "os", ".", "environ", "[", "\"TEST_MONGODB\"", "]", "del", "os", ".", "environ", "[", "\"TEST_MONGODB_DATABASE...
Stop the mongodb instance.
[ "Stop", "the", "mongodb", "instance", "." ]
train
https://github.com/mbanton/nose-mongoengine/blob/3a06f52cd32f217b512af4a76d8ed4174185df59/nose_mongoengine/__init__.py#L238-L258
samastur/pyimagediet
pyimagediet/cli.py
diet
def diet(file, configuration, check): """Simple program that either print config customisations for your environment or compresses file FILE.""" config = process.read_yaml_configuration(configuration) process.diet(file, config)
python
def diet(file, configuration, check): """Simple program that either print config customisations for your environment or compresses file FILE.""" config = process.read_yaml_configuration(configuration) process.diet(file, config)
[ "def", "diet", "(", "file", ",", "configuration", ",", "check", ")", ":", "config", "=", "process", ".", "read_yaml_configuration", "(", "configuration", ")", "process", ".", "diet", "(", "file", ",", "config", ")" ]
Simple program that either print config customisations for your environment or compresses file FILE.
[ "Simple", "program", "that", "either", "print", "config", "customisations", "for", "your", "environment", "or", "compresses", "file", "FILE", "." ]
train
https://github.com/samastur/pyimagediet/blob/480c6e171577df36e166590b031bc8891b3c9e7b/pyimagediet/cli.py#L22-L26
radjkarl/fancyTools
fancytools/math/linspace2.py
linspace2
def linspace2(a, b, n, dtype=None): """similar to numpy.linspace but excluding the boundaries this is the normal numpy.linspace: >>> print linspace(0,1,5) [ 0. 0.25 0.5 0.75 1. ] and this gives excludes the boundaries: >>> print linspace2(0,1,5) [ 0.1 0.3 0.5 0.7 0.9] """...
python
def linspace2(a, b, n, dtype=None): """similar to numpy.linspace but excluding the boundaries this is the normal numpy.linspace: >>> print linspace(0,1,5) [ 0. 0.25 0.5 0.75 1. ] and this gives excludes the boundaries: >>> print linspace2(0,1,5) [ 0.1 0.3 0.5 0.7 0.9] """...
[ "def", "linspace2", "(", "a", ",", "b", ",", "n", ",", "dtype", "=", "None", ")", ":", "a", "=", "linspace", "(", "a", ",", "b", ",", "n", "+", "1", ",", "dtype", "=", "dtype", ")", "[", ":", "-", "1", "]", "if", "len", "(", "a", ")", "...
similar to numpy.linspace but excluding the boundaries this is the normal numpy.linspace: >>> print linspace(0,1,5) [ 0. 0.25 0.5 0.75 1. ] and this gives excludes the boundaries: >>> print linspace2(0,1,5) [ 0.1 0.3 0.5 0.7 0.9]
[ "similar", "to", "numpy", ".", "linspace", "but", "excluding", "the", "boundaries" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/linspace2.py#L7-L24
20tab/twentytab-utils
twentytab/mail.py
send_mail
def send_mail(subject, text_content, from_email, to, html_content=None, attachments=[], cc=[], bcc=[]): """ This function sends mail using EmailMultiAlternatives and attachs all attachments passed as parameters """ msg = EmailMultiAlternatives(subject, text_content, from_email, to, cc=cc, bcc=bcc) ...
python
def send_mail(subject, text_content, from_email, to, html_content=None, attachments=[], cc=[], bcc=[]): """ This function sends mail using EmailMultiAlternatives and attachs all attachments passed as parameters """ msg = EmailMultiAlternatives(subject, text_content, from_email, to, cc=cc, bcc=bcc) ...
[ "def", "send_mail", "(", "subject", ",", "text_content", ",", "from_email", ",", "to", ",", "html_content", "=", "None", ",", "attachments", "=", "[", "]", ",", "cc", "=", "[", "]", ",", "bcc", "=", "[", "]", ")", ":", "msg", "=", "EmailMultiAlternat...
This function sends mail using EmailMultiAlternatives and attachs all attachments passed as parameters
[ "This", "function", "sends", "mail", "using", "EmailMultiAlternatives", "and", "attachs", "all", "attachments", "passed", "as", "parameters" ]
train
https://github.com/20tab/twentytab-utils/blob/e02d55b1fd848c8e11ca9b7e97a5916780544d34/twentytab/mail.py#L7-L28
20tab/twentytab-utils
twentytab/mail.py
send_rendered_mail
def send_rendered_mail(subject, template_name, context_dict, from_email, to, attachments=[], cc=[], bcc=[]): """ It sends mail after rendering html content and normal text using two different template (.html, .txt) with the same name. :param subject: :param template_name: without file extension ...
python
def send_rendered_mail(subject, template_name, context_dict, from_email, to, attachments=[], cc=[], bcc=[]): """ It sends mail after rendering html content and normal text using two different template (.html, .txt) with the same name. :param subject: :param template_name: without file extension ...
[ "def", "send_rendered_mail", "(", "subject", ",", "template_name", ",", "context_dict", ",", "from_email", ",", "to", ",", "attachments", "=", "[", "]", ",", "cc", "=", "[", "]", ",", "bcc", "=", "[", "]", ")", ":", "rendered", "=", "render_to_string", ...
It sends mail after rendering html content and normal text using two different template (.html, .txt) with the same name. :param subject: :param template_name: without file extension :param context_dict: :param from_email: :param to: :param attachments:
[ "It", "sends", "mail", "after", "rendering", "html", "content", "and", "normal", "text", "using", "two", "different", "template", "(", ".", "html", ".", "txt", ")", "with", "the", "same", "name", "." ]
train
https://github.com/20tab/twentytab-utils/blob/e02d55b1fd848c8e11ca9b7e97a5916780544d34/twentytab/mail.py#L31-L45
20tab/twentytab-utils
twentytab/mail.py
email_embed_image
def email_embed_image(email, img_content_id, img_data): """ email is a django.core.mail.EmailMessage object """ img = MIMEImage(img_data) img.add_header('Content-ID', '<%s>' % img_content_id) img.add_header('Content-Disposition', 'inline') email.attach(img)
python
def email_embed_image(email, img_content_id, img_data): """ email is a django.core.mail.EmailMessage object """ img = MIMEImage(img_data) img.add_header('Content-ID', '<%s>' % img_content_id) img.add_header('Content-Disposition', 'inline') email.attach(img)
[ "def", "email_embed_image", "(", "email", ",", "img_content_id", ",", "img_data", ")", ":", "img", "=", "MIMEImage", "(", "img_data", ")", "img", ".", "add_header", "(", "'Content-ID'", ",", "'<%s>'", "%", "img_content_id", ")", "img", ".", "add_header", "("...
email is a django.core.mail.EmailMessage object
[ "email", "is", "a", "django", ".", "core", ".", "mail", ".", "EmailMessage", "object" ]
train
https://github.com/20tab/twentytab-utils/blob/e02d55b1fd848c8e11ca9b7e97a5916780544d34/twentytab/mail.py#L48-L55
laurenceputra/mongo_notebook_manager
mongo_notebook_manager/mongodb_proxy.py
safe_mongocall
def safe_mongocall(call): """ Decorator for automatic handling of AutoReconnect-exceptions. """ def _safe_mongocall(*args, **kwargs): for i in range(4): try: return call(*args, **kwargs) except pymongo.errors.AutoReconnect: print ('AutoReconne...
python
def safe_mongocall(call): """ Decorator for automatic handling of AutoReconnect-exceptions. """ def _safe_mongocall(*args, **kwargs): for i in range(4): try: return call(*args, **kwargs) except pymongo.errors.AutoReconnect: print ('AutoReconne...
[ "def", "safe_mongocall", "(", "call", ")", ":", "def", "_safe_mongocall", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "i", "in", "range", "(", "4", ")", ":", "try", ":", "return", "call", "(", "*", "args", ",", "*", "*", "kwargs",...
Decorator for automatic handling of AutoReconnect-exceptions.
[ "Decorator", "for", "automatic", "handling", "of", "AutoReconnect", "-", "exceptions", "." ]
train
https://github.com/laurenceputra/mongo_notebook_manager/blob/d7f4031e236ff19b8f0658f8ad1fcd1b51815251/mongo_notebook_manager/mongodb_proxy.py#L18-L32
pip-services3-python/pip-services3-components-python
pip_services3_components/auth/CredentialParams.py
CredentialParams.get_username
def get_username(self): """ Gets the user name. The value can be stored in parameters "username" or "user". :return: the user name. """ username = self.get_as_nullable_string("username") username = username if username != None else self.get_as_nullable_string("user") ...
python
def get_username(self): """ Gets the user name. The value can be stored in parameters "username" or "user". :return: the user name. """ username = self.get_as_nullable_string("username") username = username if username != None else self.get_as_nullable_string("user") ...
[ "def", "get_username", "(", "self", ")", ":", "username", "=", "self", ".", "get_as_nullable_string", "(", "\"username\"", ")", "username", "=", "username", "if", "username", "!=", "None", "else", "self", ".", "get_as_nullable_string", "(", "\"user\"", ")", "r...
Gets the user name. The value can be stored in parameters "username" or "user". :return: the user name.
[ "Gets", "the", "user", "name", ".", "The", "value", "can", "be", "stored", "in", "parameters", "username", "or", "user", "." ]
train
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/auth/CredentialParams.py#L82-L90
pip-services3-python/pip-services3-components-python
pip_services3_components/auth/CredentialParams.py
CredentialParams.get_password
def get_password(self): """ Get the user password. The value can be stored in parameters "password" or "pass". :return: the user password. """ password = self.get_as_nullable_string("password") password = password if password != None else self.get_as_nullable_string("pas...
python
def get_password(self): """ Get the user password. The value can be stored in parameters "password" or "pass". :return: the user password. """ password = self.get_as_nullable_string("password") password = password if password != None else self.get_as_nullable_string("pas...
[ "def", "get_password", "(", "self", ")", ":", "password", "=", "self", ".", "get_as_nullable_string", "(", "\"password\"", ")", "password", "=", "password", "if", "password", "!=", "None", "else", "self", ".", "get_as_nullable_string", "(", "\"pass\"", ")", "r...
Get the user password. The value can be stored in parameters "password" or "pass". :return: the user password.
[ "Get", "the", "user", "password", ".", "The", "value", "can", "be", "stored", "in", "parameters", "password", "or", "pass", "." ]
train
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/auth/CredentialParams.py#L100-L108
pip-services3-python/pip-services3-components-python
pip_services3_components/auth/CredentialParams.py
CredentialParams.get_access_id
def get_access_id(self): """ Gets the application access id. The value can be stored in parameters "access_id" pr "client_id" :return: the application access id. """ access_id = self.get_as_nullable_string("access_id") access_id = access_id if access_id != None else self...
python
def get_access_id(self): """ Gets the application access id. The value can be stored in parameters "access_id" pr "client_id" :return: the application access id. """ access_id = self.get_as_nullable_string("access_id") access_id = access_id if access_id != None else self...
[ "def", "get_access_id", "(", "self", ")", ":", "access_id", "=", "self", ".", "get_as_nullable_string", "(", "\"access_id\"", ")", "access_id", "=", "access_id", "if", "access_id", "!=", "None", "else", "self", ".", "get_as_nullable_string", "(", "\"client_id\"", ...
Gets the application access id. The value can be stored in parameters "access_id" pr "client_id" :return: the application access id.
[ "Gets", "the", "application", "access", "id", ".", "The", "value", "can", "be", "stored", "in", "parameters", "access_id", "pr", "client_id" ]
train
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/auth/CredentialParams.py#L118-L126
pip-services3-python/pip-services3-components-python
pip_services3_components/auth/CredentialParams.py
CredentialParams.get_access_key
def get_access_key(self): """ Gets the application secret key. The value can be stored in parameters "access_key", "client_key" or "secret_key". :return: the application secret key. """ access_key = self.get_as_nullable_string("access_key") access_key = access_ke...
python
def get_access_key(self): """ Gets the application secret key. The value can be stored in parameters "access_key", "client_key" or "secret_key". :return: the application secret key. """ access_key = self.get_as_nullable_string("access_key") access_key = access_ke...
[ "def", "get_access_key", "(", "self", ")", ":", "access_key", "=", "self", ".", "get_as_nullable_string", "(", "\"access_key\"", ")", "access_key", "=", "access_key", "if", "access_key", "!=", "None", "else", "self", ".", "get_as_nullable_string", "(", "\"access_k...
Gets the application secret key. The value can be stored in parameters "access_key", "client_key" or "secret_key". :return: the application secret key.
[ "Gets", "the", "application", "secret", "key", ".", "The", "value", "can", "be", "stored", "in", "parameters", "access_key", "client_key", "or", "secret_key", "." ]
train
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/auth/CredentialParams.py#L136-L145
pip-services3-python/pip-services3-components-python
pip_services3_components/auth/CredentialParams.py
CredentialParams.many_from_config
def many_from_config(config): """ Retrieves all CredentialParams from configuration parameters from "credentials" section. If "credential" section is present instead, than it returns a list with only one CredentialParams. :param config: a configuration parameters to retrieve cre...
python
def many_from_config(config): """ Retrieves all CredentialParams from configuration parameters from "credentials" section. If "credential" section is present instead, than it returns a list with only one CredentialParams. :param config: a configuration parameters to retrieve cre...
[ "def", "many_from_config", "(", "config", ")", ":", "result", "=", "[", "]", "# Try to get multiple credentials first", "credentials", "=", "config", ".", "get_section", "(", "\"credentials\"", ")", "if", "len", "(", "credentials", ")", ">", "0", ":", "sections_...
Retrieves all CredentialParams from configuration parameters from "credentials" section. If "credential" section is present instead, than it returns a list with only one CredentialParams. :param config: a configuration parameters to retrieve credentials :return: a list of retrieved Cre...
[ "Retrieves", "all", "CredentialParams", "from", "configuration", "parameters", "from", "credentials", "section", ".", "If", "credential", "section", "is", "present", "instead", "than", "it", "returns", "a", "list", "with", "only", "one", "CredentialParams", "." ]
train
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/auth/CredentialParams.py#L182-L206
voidpp/python-tools
voidpp_tools/colors.py
ColorFactory.is_output_supports_color
def is_output_supports_color(): """ Returns True if the running system's terminal supports color, and False otherwise. """ plat = sys.platform supported_platform = plat != 'Pocket PC' and (plat != 'win32' or 'ANSICON' in os.environ) is_a_tty = hasattr(sys.stdout,...
python
def is_output_supports_color(): """ Returns True if the running system's terminal supports color, and False otherwise. """ plat = sys.platform supported_platform = plat != 'Pocket PC' and (plat != 'win32' or 'ANSICON' in os.environ) is_a_tty = hasattr(sys.stdout,...
[ "def", "is_output_supports_color", "(", ")", ":", "plat", "=", "sys", ".", "platform", "supported_platform", "=", "plat", "!=", "'Pocket PC'", "and", "(", "plat", "!=", "'win32'", "or", "'ANSICON'", "in", "os", ".", "environ", ")", "is_a_tty", "=", "hasattr"...
Returns True if the running system's terminal supports color, and False otherwise.
[ "Returns", "True", "if", "the", "running", "system", "s", "terminal", "supports", "color", "and", "False", "otherwise", "." ]
train
https://github.com/voidpp/python-tools/blob/0fc7460c827b02d8914411cedddadc23ccb3cc73/voidpp_tools/colors.py#L17-L28
mehmetg/streak_client
streak_client/streak_objects.py
StreakBaseObject.show
def show(self, displayAll = False): '''Prints relevant attributes of an object Args: displayAll if True displays ALL class attributes. ''' from pprint import pprint if displayAll: pprint(self.attributes) else: disp_attr = {} for key in self.disp_attr_keys: try: disp_attr[key] = self.at...
python
def show(self, displayAll = False): '''Prints relevant attributes of an object Args: displayAll if True displays ALL class attributes. ''' from pprint import pprint if displayAll: pprint(self.attributes) else: disp_attr = {} for key in self.disp_attr_keys: try: disp_attr[key] = self.at...
[ "def", "show", "(", "self", ",", "displayAll", "=", "False", ")", ":", "from", "pprint", "import", "pprint", "if", "displayAll", ":", "pprint", "(", "self", ".", "attributes", ")", "else", ":", "disp_attr", "=", "{", "}", "for", "key", "in", "self", ...
Prints relevant attributes of an object Args: displayAll if True displays ALL class attributes.
[ "Prints", "relevant", "attributes", "of", "an", "object", "Args", ":", "displayAll", "if", "True", "displays", "ALL", "class", "attributes", "." ]
train
https://github.com/mehmetg/streak_client/blob/46575510b4e4163a4a3cc06f7283a1ae377cdce6/streak_client/streak_objects.py#L19-L38
mehmetg/streak_client
streak_client/streak_objects.py
StreakBaseObject.to_dict
def to_dict(self, rw = False): '''Returns relevant attributes as a dict. Args: rw if True only returns the read/write enabled object attributes ''' return {k:v for (k,v) in self.attributes.items() if (v is not None and (not rw or (k in self.rw_attr_keys)))}
python
def to_dict(self, rw = False): '''Returns relevant attributes as a dict. Args: rw if True only returns the read/write enabled object attributes ''' return {k:v for (k,v) in self.attributes.items() if (v is not None and (not rw or (k in self.rw_attr_keys)))}
[ "def", "to_dict", "(", "self", ",", "rw", "=", "False", ")", ":", "return", "{", "k", ":", "v", "for", "(", "k", ",", "v", ")", "in", "self", ".", "attributes", ".", "items", "(", ")", "if", "(", "v", "is", "not", "None", "and", "(", "not", ...
Returns relevant attributes as a dict. Args: rw if True only returns the read/write enabled object attributes
[ "Returns", "relevant", "attributes", "as", "a", "dict", ".", "Args", ":", "rw", "if", "True", "only", "returns", "the", "read", "/", "write", "enabled", "object", "attributes" ]
train
https://github.com/mehmetg/streak_client/blob/46575510b4e4163a4a3cc06f7283a1ae377cdce6/streak_client/streak_objects.py#L40-L46
CS207-Final-Project-Group-10/cs207-FinalProject
solar_system/eight_planets.py
configuration
def configuration(t0: date, t1: Optional[date] = None, steps_per_day: int = None) -> Tuple[np.ndarray, np.ndarray]: """ Get the positions and velocities of the sun and eight planets Returned as a tuple q, v q: Nx3 array of positions (x, y, z) in the J2000.0 coordinate frame. """ ...
python
def configuration(t0: date, t1: Optional[date] = None, steps_per_day: int = None) -> Tuple[np.ndarray, np.ndarray]: """ Get the positions and velocities of the sun and eight planets Returned as a tuple q, v q: Nx3 array of positions (x, y, z) in the J2000.0 coordinate frame. """ ...
[ "def", "configuration", "(", "t0", ":", "date", ",", "t1", ":", "Optional", "[", "date", "]", "=", "None", ",", "steps_per_day", ":", "int", "=", "None", ")", "->", "Tuple", "[", "np", ".", "ndarray", ",", "np", ".", "ndarray", "]", ":", "# Default...
Get the positions and velocities of the sun and eight planets Returned as a tuple q, v q: Nx3 array of positions (x, y, z) in the J2000.0 coordinate frame.
[ "Get", "the", "positions", "and", "velocities", "of", "the", "sun", "and", "eight", "planets", "Returned", "as", "a", "tuple", "q", "v", "q", ":", "Nx3", "array", "of", "positions", "(", "x", "y", "z", ")", "in", "the", "J2000", ".", "0", "coordinate...
train
https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/eight_planets.py#L41-L95
CS207-Final-Project-Group-10/cs207-FinalProject
solar_system/eight_planets.py
plot
def plot(q: np.ndarray, bodies: List[str], plot_colors: Dict[str, str], sim_name: str, fname: Optional[str] = None): """ Plot the planetary orbits. Plot size limited to box of 10 AU around the sun. q is a Nx3B array. t indexes time points. 3B columns are (x, y, z) for the bodies in order. ""...
python
def plot(q: np.ndarray, bodies: List[str], plot_colors: Dict[str, str], sim_name: str, fname: Optional[str] = None): """ Plot the planetary orbits. Plot size limited to box of 10 AU around the sun. q is a Nx3B array. t indexes time points. 3B columns are (x, y, z) for the bodies in order. ""...
[ "def", "plot", "(", "q", ":", "np", ".", "ndarray", ",", "bodies", ":", "List", "[", "str", "]", ",", "plot_colors", ":", "Dict", "[", "str", ",", "str", "]", ",", "sim_name", ":", "str", ",", "fname", ":", "Optional", "[", "str", "]", "=", "No...
Plot the planetary orbits. Plot size limited to box of 10 AU around the sun. q is a Nx3B array. t indexes time points. 3B columns are (x, y, z) for the bodies in order.
[ "Plot", "the", "planetary", "orbits", ".", "Plot", "size", "limited", "to", "box", "of", "10", "AU", "around", "the", "sun", ".", "q", "is", "a", "Nx3B", "array", ".", "t", "indexes", "time", "points", ".", "3B", "columns", "are", "(", "x", "y", "z...
train
https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/eight_planets.py#L99-L150
CS207-Final-Project-Group-10/cs207-FinalProject
solar_system/eight_planets.py
make_frame
def make_frame(fig, ax, plot_x: np.ndarray, plot_y: np.ndarray, frame_num: int, bodies: List[str], plot_colors: Dict[str, str], markersize_tbl: Dict[str, float], fname: str): """ Make a series of frames of the planetary orbits that can be assembled into a movie. q is a Nx3B ar...
python
def make_frame(fig, ax, plot_x: np.ndarray, plot_y: np.ndarray, frame_num: int, bodies: List[str], plot_colors: Dict[str, str], markersize_tbl: Dict[str, float], fname: str): """ Make a series of frames of the planetary orbits that can be assembled into a movie. q is a Nx3B ar...
[ "def", "make_frame", "(", "fig", ",", "ax", ",", "plot_x", ":", "np", ".", "ndarray", ",", "plot_y", ":", "np", ".", "ndarray", ",", "frame_num", ":", "int", ",", "bodies", ":", "List", "[", "str", "]", ",", "plot_colors", ":", "Dict", "[", "str", ...
Make a series of frames of the planetary orbits that can be assembled into a movie. q is a Nx3B array. t indexes time points. 3B columns are (x, y, z) for the bodies in order.
[ "Make", "a", "series", "of", "frames", "of", "the", "planetary", "orbits", "that", "can", "be", "assembled", "into", "a", "movie", ".", "q", "is", "a", "Nx3B", "array", ".", "t", "indexes", "time", "points", ".", "3B", "columns", "are", "(", "x", "y"...
train
https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/eight_planets.py#L154-L186
CS207-Final-Project-Group-10/cs207-FinalProject
solar_system/eight_planets.py
make_movie
def make_movie(q: np.ndarray, step: int, bodies: List[str], plot_colors: Dict[str, str], fname: str): """ Make a series of frames of the planetary orbits that can be assembled into a movie. q is a Nx3B array. t indexes time points. 3B columns are (x, y, z) for the bodies in order. """ # Get N and ...
python
def make_movie(q: np.ndarray, step: int, bodies: List[str], plot_colors: Dict[str, str], fname: str): """ Make a series of frames of the planetary orbits that can be assembled into a movie. q is a Nx3B array. t indexes time points. 3B columns are (x, y, z) for the bodies in order. """ # Get N and ...
[ "def", "make_movie", "(", "q", ":", "np", ".", "ndarray", ",", "step", ":", "int", ",", "bodies", ":", "List", "[", "str", "]", ",", "plot_colors", ":", "Dict", "[", "str", ",", "str", "]", ",", "fname", ":", "str", ")", ":", "# Get N and number of...
Make a series of frames of the planetary orbits that can be assembled into a movie. q is a Nx3B array. t indexes time points. 3B columns are (x, y, z) for the bodies in order.
[ "Make", "a", "series", "of", "frames", "of", "the", "planetary", "orbits", "that", "can", "be", "assembled", "into", "a", "movie", ".", "q", "is", "a", "Nx3B", "array", ".", "t", "indexes", "time", "points", ".", "3B", "columns", "are", "(", "x", "y"...
train
https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/eight_planets.py#L189-L231
CS207-Final-Project-Group-10/cs207-FinalProject
solar_system/eight_planets.py
accel
def accel(q: np.ndarray): """ Compute the gravitational accelerations in the system q in row vector of 6 elements: sun (x, y, z), earth (x, y, z) """ # Infer number of dimensions from q dims: int = len(q) # Initialize acceleration as dimsx1 array a: np.ndarray = np.zeros(dims) ...
python
def accel(q: np.ndarray): """ Compute the gravitational accelerations in the system q in row vector of 6 elements: sun (x, y, z), earth (x, y, z) """ # Infer number of dimensions from q dims: int = len(q) # Initialize acceleration as dimsx1 array a: np.ndarray = np.zeros(dims) ...
[ "def", "accel", "(", "q", ":", "np", ".", "ndarray", ")", ":", "# Infer number of dimensions from q", "dims", ":", "int", "=", "len", "(", "q", ")", "# Initialize acceleration as dimsx1 array", "a", ":", "np", ".", "ndarray", "=", "np", ".", "zeros", "(", ...
Compute the gravitational accelerations in the system q in row vector of 6 elements: sun (x, y, z), earth (x, y, z)
[ "Compute", "the", "gravitational", "accelerations", "in", "the", "system", "q", "in", "row", "vector", "of", "6", "elements", ":", "sun", "(", "x", "y", "z", ")", "earth", "(", "x", "y", "z", ")" ]
train
https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/eight_planets.py#L234-L275
CS207-Final-Project-Group-10/cs207-FinalProject
solar_system/eight_planets.py
energy
def energy(q, v): """Compute the kinetic and potential energy of the planetary system""" # Number of points N: int = len(q) # Initialize arrays to zero of the correct size T: np.ndarray = np.zeros(N) U: np.ndarray = np.zeros(N) # Add up kinetic energy of each body for ...
python
def energy(q, v): """Compute the kinetic and potential energy of the planetary system""" # Number of points N: int = len(q) # Initialize arrays to zero of the correct size T: np.ndarray = np.zeros(N) U: np.ndarray = np.zeros(N) # Add up kinetic energy of each body for ...
[ "def", "energy", "(", "q", ",", "v", ")", ":", "# Number of points", "N", ":", "int", "=", "len", "(", "q", ")", "# Initialize arrays to zero of the correct size", "T", ":", "np", ".", "ndarray", "=", "np", ".", "zeros", "(", "N", ")", "U", ":", "np", ...
Compute the kinetic and potential energy of the planetary system
[ "Compute", "the", "kinetic", "and", "potential", "energy", "of", "the", "planetary", "system" ]
train
https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/eight_planets.py#L279-L315
CS207-Final-Project-Group-10/cs207-FinalProject
solar_system/eight_planets.py
make_force
def make_force(q_vars, mass): """Fluxion with the potential energy of the eight planets sytem""" # Number of bodies B: int = len(mass) # Build the potential energy fluxion by iterating over distinct pairs of bodies U = fl.Const(0.0) for i in range(B): for j in range(i+1, B): ...
python
def make_force(q_vars, mass): """Fluxion with the potential energy of the eight planets sytem""" # Number of bodies B: int = len(mass) # Build the potential energy fluxion by iterating over distinct pairs of bodies U = fl.Const(0.0) for i in range(B): for j in range(i+1, B): ...
[ "def", "make_force", "(", "q_vars", ",", "mass", ")", ":", "# Number of bodies", "B", ":", "int", "=", "len", "(", "mass", ")", "# Build the potential energy fluxion by iterating over distinct pairs of bodies", "U", "=", "fl", ".", "Const", "(", "0.0", ")", "for",...
Fluxion with the potential energy of the eight planets sytem
[ "Fluxion", "with", "the", "potential", "energy", "of", "the", "eight", "planets", "sytem" ]
train
https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/eight_planets.py#L342-L362
CS207-Final-Project-Group-10/cs207-FinalProject
solar_system/eight_planets.py
accel_fl
def accel_fl(q: np.ndarray): """Accelaration in the earth-sun system using Fluxion potential energy""" # Infer number of dimensions from q dims: int = len(q) # Number of celestial bodies B: int = dims // 3 # The force given the positions q of the bodies f = force(q) # The accelerations...
python
def accel_fl(q: np.ndarray): """Accelaration in the earth-sun system using Fluxion potential energy""" # Infer number of dimensions from q dims: int = len(q) # Number of celestial bodies B: int = dims // 3 # The force given the positions q of the bodies f = force(q) # The accelerations...
[ "def", "accel_fl", "(", "q", ":", "np", ".", "ndarray", ")", ":", "# Infer number of dimensions from q", "dims", ":", "int", "=", "len", "(", "q", ")", "# Number of celestial bodies", "B", ":", "int", "=", "dims", "//", "3", "# The force given the positions q of...
Accelaration in the earth-sun system using Fluxion potential energy
[ "Accelaration", "in", "the", "earth", "-", "sun", "system", "using", "Fluxion", "potential", "energy" ]
train
https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/eight_planets.py#L365-L380
csvsoundsystem/pytreasuryio
treasuryio/tweetbot.py
tweet
def tweet(tweet_text_func): ''' A decorator to make a function Tweet Parameters - `tweet_text_func` is a function that takes no parameters and returns a tweetable string For example:: @tweet def total_deposits_this_week(): # ... @tweet def not_an_inte...
python
def tweet(tweet_text_func): ''' A decorator to make a function Tweet Parameters - `tweet_text_func` is a function that takes no parameters and returns a tweetable string For example:: @tweet def total_deposits_this_week(): # ... @tweet def not_an_inte...
[ "def", "tweet", "(", "tweet_text_func", ")", ":", "def", "tweet_func", "(", ")", ":", "api", "=", "_connect_to_twitter", "(", ")", "tweet", "=", "tweet_text_func", "(", ")", "print", "\"Tweeting: %s\"", "%", "tweet", "api", ".", "update_status", "(", "tweet"...
A decorator to make a function Tweet Parameters - `tweet_text_func` is a function that takes no parameters and returns a tweetable string For example:: @tweet def total_deposits_this_week(): # ... @tweet def not_an_interesting_tweet(): return 'Thi...
[ "A", "decorator", "to", "make", "a", "function", "Tweet" ]
train
https://github.com/csvsoundsystem/pytreasuryio/blob/728caf815d16cd2f3548d8b67c84313de76f9be7/treasuryio/tweetbot.py#L16-L41
ppo/django-guitar
guitar/utils/__init__.py
get_perm_name
def get_perm_name(cls, action, full=True): """ Return the name of the permission for a given model and action. By default it returns the full permission name `app_label.perm_codename`. If `full=False`, it returns only the `perm_codename`. """ codename = "{}_{}".format(action, cls.__name__.lower...
python
def get_perm_name(cls, action, full=True): """ Return the name of the permission for a given model and action. By default it returns the full permission name `app_label.perm_codename`. If `full=False`, it returns only the `perm_codename`. """ codename = "{}_{}".format(action, cls.__name__.lower...
[ "def", "get_perm_name", "(", "cls", ",", "action", ",", "full", "=", "True", ")", ":", "codename", "=", "\"{}_{}\"", ".", "format", "(", "action", ",", "cls", ".", "__name__", ".", "lower", "(", ")", ")", "if", "full", ":", "return", "\"{}.{}\"", "."...
Return the name of the permission for a given model and action. By default it returns the full permission name `app_label.perm_codename`. If `full=False`, it returns only the `perm_codename`.
[ "Return", "the", "name", "of", "the", "permission", "for", "a", "given", "model", "and", "action", "." ]
train
https://github.com/ppo/django-guitar/blob/857282219c0c4ff5907c3ad04ef012281d245348/guitar/utils/__init__.py#L9-L19
pip-services3-python/pip-services3-components-python
pip_services3_components/connect/ConnectionResolver.py
ConnectionResolver.configure
def configure(self, config): """ Configures component by passing configuration parameters. :param config: configuration parameters to be set. """ connections = ConnectionParams.many_from_config(config) for connection in connections: self._connections.append(c...
python
def configure(self, config): """ Configures component by passing configuration parameters. :param config: configuration parameters to be set. """ connections = ConnectionParams.many_from_config(config) for connection in connections: self._connections.append(c...
[ "def", "configure", "(", "self", ",", "config", ")", ":", "connections", "=", "ConnectionParams", ".", "many_from_config", "(", "config", ")", "for", "connection", "in", "connections", ":", "self", ".", "_connections", ".", "append", "(", "connection", ")" ]
Configures component by passing configuration parameters. :param config: configuration parameters to be set.
[ "Configures", "component", "by", "passing", "configuration", "parameters", "." ]
train
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/connect/ConnectionResolver.py#L76-L84
pip-services3-python/pip-services3-components-python
pip_services3_components/connect/ConnectionResolver.py
ConnectionResolver.register
def register(self, correlation_id, connection): """ Registers the given connection in all referenced discovery services. This method can be used for dynamic service discovery. :param correlation_id: (optional) transaction id to trace execution through call chain. :param connect...
python
def register(self, correlation_id, connection): """ Registers the given connection in all referenced discovery services. This method can be used for dynamic service discovery. :param correlation_id: (optional) transaction id to trace execution through call chain. :param connect...
[ "def", "register", "(", "self", ",", "correlation_id", ",", "connection", ")", ":", "result", "=", "self", ".", "_register_in_discovery", "(", "correlation_id", ",", "connection", ")", "if", "result", ":", "self", ".", "_connections", ".", "append", "(", "co...
Registers the given connection in all referenced discovery services. This method can be used for dynamic service discovery. :param correlation_id: (optional) transaction id to trace execution through call chain. :param connection: a connection to register.
[ "Registers", "the", "given", "connection", "in", "all", "referenced", "discovery", "services", ".", "This", "method", "can", "be", "used", "for", "dynamic", "service", "discovery", "." ]
train
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/connect/ConnectionResolver.py#L122-L134
pip-services3-python/pip-services3-components-python
pip_services3_components/connect/ConnectionResolver.py
ConnectionResolver.resolve
def resolve(self, correlation_id): """ Resolves a single component connection. If connections are configured to be retrieved from Discovery service it finds a [[IDiscovery]] and resolves the connection there. :param correlation_id: (optional) transaction id to trace execution through ca...
python
def resolve(self, correlation_id): """ Resolves a single component connection. If connections are configured to be retrieved from Discovery service it finds a [[IDiscovery]] and resolves the connection there. :param correlation_id: (optional) transaction id to trace execution through ca...
[ "def", "resolve", "(", "self", ",", "correlation_id", ")", ":", "if", "len", "(", "self", ".", "_connections", ")", "==", "0", ":", "return", "None", "# Return connection that doesn't require discovery", "for", "connection", "in", "self", ".", "_connections", ":...
Resolves a single component connection. If connections are configured to be retrieved from Discovery service it finds a [[IDiscovery]] and resolves the connection there. :param correlation_id: (optional) transaction id to trace execution through call chain. :return: resolved connection paramet...
[ "Resolves", "a", "single", "component", "connection", ".", "If", "connections", "are", "configured", "to", "be", "retrieved", "from", "Discovery", "service", "it", "finds", "a", "[[", "IDiscovery", "]]", "and", "resolves", "the", "connection", "there", "." ]
train
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/connect/ConnectionResolver.py#L153-L178
pip-services3-python/pip-services3-components-python
pip_services3_components/connect/ConnectionResolver.py
ConnectionResolver.resolve_all
def resolve_all(self, correlation_id): """ Resolves all component connection. If connections are configured to be retrieved from Discovery service it finds a [[IDiscovery]] and resolves the connection there. :param correlation_id: (optional) transaction id to trace execution through cal...
python
def resolve_all(self, correlation_id): """ Resolves all component connection. If connections are configured to be retrieved from Discovery service it finds a [[IDiscovery]] and resolves the connection there. :param correlation_id: (optional) transaction id to trace execution through cal...
[ "def", "resolve_all", "(", "self", ",", "correlation_id", ")", ":", "resolved", "=", "[", "]", "to_resolve", "=", "[", "]", "# Sort connections", "for", "connection", "in", "self", ".", "_connections", ":", "if", "connection", ".", "use_discovery", "(", ")",...
Resolves all component connection. If connections are configured to be retrieved from Discovery service it finds a [[IDiscovery]] and resolves the connection there. :param correlation_id: (optional) transaction id to trace execution through call chain. :return: a list of resolved connections.
[ "Resolves", "all", "component", "connection", ".", "If", "connections", "are", "configured", "to", "be", "retrieved", "from", "Discovery", "service", "it", "finds", "a", "[[", "IDiscovery", "]]", "and", "resolves", "the", "connection", "there", "." ]
train
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/connect/ConnectionResolver.py#L200-L228
django-py/django-doberman
doberman/decorators.py
watch_login
def watch_login(func): """ Decorator @watch_login :param func: :return: """ @wraps(func) def decorated_login(request, *args, **kwargs): response = func(request, *args, **kwargs) lockout = AccessAttempt(request, response) user_access = lockout.check_failed_login() ...
python
def watch_login(func): """ Decorator @watch_login :param func: :return: """ @wraps(func) def decorated_login(request, *args, **kwargs): response = func(request, *args, **kwargs) lockout = AccessAttempt(request, response) user_access = lockout.check_failed_login() ...
[ "def", "watch_login", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "decorated_login", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "response", "=", "func", "(", "request", ",", "*", "args", ",", "*", "*", ...
Decorator @watch_login :param func: :return:
[ "Decorator" ]
train
https://github.com/django-py/django-doberman/blob/2e5959737a1b64234ed5a179c93f96a0de1c3e5c/doberman/decorators.py#L10-L29
django-py/django-doberman
doberman/decorators.py
protect_login_with_captcha
def protect_login_with_captcha(func): """ Protect the login with a captcha after of N failed access attempts :param func: :return: """ @wraps(func) def decorated_login(request, *args, **kwargs): response = func(request, *args, **kwargs) access_attempt = AccessAttempt(request...
python
def protect_login_with_captcha(func): """ Protect the login with a captcha after of N failed access attempts :param func: :return: """ @wraps(func) def decorated_login(request, *args, **kwargs): response = func(request, *args, **kwargs) access_attempt = AccessAttempt(request...
[ "def", "protect_login_with_captcha", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "decorated_login", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "response", "=", "func", "(", "request", ",", "*", "args", ",", ...
Protect the login with a captcha after of N failed access attempts :param func: :return:
[ "Protect", "the", "login", "with", "a", "captcha", "after", "of", "N", "failed", "access", "attempts", ":", "param", "func", ":", ":", "return", ":" ]
train
https://github.com/django-py/django-doberman/blob/2e5959737a1b64234ed5a179c93f96a0de1c3e5c/doberman/decorators.py#L32-L47
toastdriven/alligator
alligator/backends/sqs_backend.py
Client.push
def push(self, queue_name, task_id, data): """ Pushes a task onto the queue. :param queue_name: The name of the queue. Usually handled by the ``Gator`` instance. :type queue_name: string :param task_id: The identifier of the task. :type task_id: string ...
python
def push(self, queue_name, task_id, data): """ Pushes a task onto the queue. :param queue_name: The name of the queue. Usually handled by the ``Gator`` instance. :type queue_name: string :param task_id: The identifier of the task. :type task_id: string ...
[ "def", "push", "(", "self", ",", "queue_name", ",", "task_id", ",", "data", ")", ":", "# SQS doesn't let you specify a task id.", "queue", "=", "self", ".", "_get_queue", "(", "queue_name", ")", "message", "=", "queue", ".", "new_message", "(", "body", "=", ...
Pushes a task onto the queue. :param queue_name: The name of the queue. Usually handled by the ``Gator`` instance. :type queue_name: string :param task_id: The identifier of the task. :type task_id: string :param data: The relevant data for the task. :type ...
[ "Pushes", "a", "task", "onto", "the", "queue", "." ]
train
https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/backends/sqs_backend.py#L61-L79
toastdriven/alligator
alligator/backends/sqs_backend.py
Client.pop
def pop(self, queue_name): """ Pops a task off the queue. :param queue_name: The name of the queue. Usually handled by the ``Gator`` instance. :type queue_name: string :returns: The data for the task. :rtype: string """ queue = self._get_queu...
python
def pop(self, queue_name): """ Pops a task off the queue. :param queue_name: The name of the queue. Usually handled by the ``Gator`` instance. :type queue_name: string :returns: The data for the task. :rtype: string """ queue = self._get_queu...
[ "def", "pop", "(", "self", ",", "queue_name", ")", ":", "queue", "=", "self", ".", "_get_queue", "(", "queue_name", ")", "message", "=", "queue", ".", "read", "(", ")", "if", "message", ":", "data", "=", "message", ".", "get_body", "(", ")", "return"...
Pops a task off the queue. :param queue_name: The name of the queue. Usually handled by the ``Gator`` instance. :type queue_name: string :returns: The data for the task. :rtype: string
[ "Pops", "a", "task", "off", "the", "queue", "." ]
train
https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/backends/sqs_backend.py#L81-L97
Nixiware/viper
nx/viper/controller.py
Controller.sendPartialResponse
def sendPartialResponse(self): """ Send a partial response without closing the connection. :return: <void> """ self.requestProtocol.requestResponse["code"] = ( self.responseCode ) self.requestProtocol.requestResponse["content"] = ( self.re...
python
def sendPartialResponse(self): """ Send a partial response without closing the connection. :return: <void> """ self.requestProtocol.requestResponse["code"] = ( self.responseCode ) self.requestProtocol.requestResponse["content"] = ( self.re...
[ "def", "sendPartialResponse", "(", "self", ")", ":", "self", ".", "requestProtocol", ".", "requestResponse", "[", "\"code\"", "]", "=", "(", "self", ".", "responseCode", ")", "self", ".", "requestProtocol", ".", "requestResponse", "[", "\"content\"", "]", "=",...
Send a partial response without closing the connection. :return: <void>
[ "Send", "a", "partial", "response", "without", "closing", "the", "connection", "." ]
train
https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/controller.py#L34-L49
Nixiware/viper
nx/viper/controller.py
Controller.sendFinalResponse
def sendFinalResponse(self): """ Send the final response and close the connection. :return: <void> """ self.requestProtocol.requestResponse["code"] = ( self.responseCode ) self.requestProtocol.requestResponse["content"] = ( self.responseCo...
python
def sendFinalResponse(self): """ Send the final response and close the connection. :return: <void> """ self.requestProtocol.requestResponse["code"] = ( self.responseCode ) self.requestProtocol.requestResponse["content"] = ( self.responseCo...
[ "def", "sendFinalResponse", "(", "self", ")", ":", "self", ".", "requestProtocol", ".", "requestResponse", "[", "\"code\"", "]", "=", "(", "self", ".", "responseCode", ")", "self", ".", "requestProtocol", ".", "requestResponse", "[", "\"content\"", "]", "=", ...
Send the final response and close the connection. :return: <void>
[ "Send", "the", "final", "response", "and", "close", "the", "connection", "." ]
train
https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/controller.py#L51-L66
matthewdeanmartin/jiggle_version
jiggle_version/file_makers.py
FileMaker.create_init
def create_init(self, path): # type: (str) -> None """ Create a minimal __init__ file with enough boiler plate to not add to lint messages :param path: :return: """ source = """# coding=utf-8 \"\"\" Version \"\"\" __version__ = \"0.0.0\" """ with io.open(path, "w...
python
def create_init(self, path): # type: (str) -> None """ Create a minimal __init__ file with enough boiler plate to not add to lint messages :param path: :return: """ source = """# coding=utf-8 \"\"\" Version \"\"\" __version__ = \"0.0.0\" """ with io.open(path, "w...
[ "def", "create_init", "(", "self", ",", "path", ")", ":", "# type: (str) -> None", "source", "=", "\"\"\"# coding=utf-8\n\\\"\\\"\\\"\nVersion\n\\\"\\\"\\\"\n__version__ = \\\"0.0.0\\\"\n\"\"\"", "with", "io", ".", "open", "(", "path", ",", "\"w\"", ",", "encoding", "=", ...
Create a minimal __init__ file with enough boiler plate to not add to lint messages :param path: :return:
[ "Create", "a", "minimal", "__init__", "file", "with", "enough", "boiler", "plate", "to", "not", "add", "to", "lint", "messages", ":", "param", "path", ":", ":", "return", ":" ]
train
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/file_makers.py#L32-L45
matthewdeanmartin/jiggle_version
jiggle_version/file_makers.py
FileMaker.create_setup_cfg
def create_setup_cfg(self, path): # type: (str) -> None """ Just setup.cfg :param path: :return: """ source = """[metadata] name = {0} version=0.0.1 """.format( self.project ) with io.open(path, "w", encoding="utf-8") as outfile: ...
python
def create_setup_cfg(self, path): # type: (str) -> None """ Just setup.cfg :param path: :return: """ source = """[metadata] name = {0} version=0.0.1 """.format( self.project ) with io.open(path, "w", encoding="utf-8") as outfile: ...
[ "def", "create_setup_cfg", "(", "self", ",", "path", ")", ":", "# type: (str) -> None", "source", "=", "\"\"\"[metadata]\nname = {0}\nversion=0.0.1 \n\"\"\"", ".", "format", "(", "self", ".", "project", ")", "with", "io", ".", "open", "(", "path", ",", "\"w\"", ...
Just setup.cfg :param path: :return:
[ "Just", "setup", ".", "cfg", ":", "param", "path", ":", ":", "return", ":" ]
train
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/file_makers.py#L62-L75
sassoo/goldman
goldman/middleware/security/__init__.py
Middleware.process_request
def process_request(self, req, resp): """ Process the request before routing it. We always enforce the use of SSL. """ if goldman.config.TLS_REQUIRED and req.protocol != 'https': abort(TLSRequired)
python
def process_request(self, req, resp): """ Process the request before routing it. We always enforce the use of SSL. """ if goldman.config.TLS_REQUIRED and req.protocol != 'https': abort(TLSRequired)
[ "def", "process_request", "(", "self", ",", "req", ",", "resp", ")", ":", "if", "goldman", ".", "config", ".", "TLS_REQUIRED", "and", "req", ".", "protocol", "!=", "'https'", ":", "abort", "(", "TLSRequired", ")" ]
Process the request before routing it. We always enforce the use of SSL.
[ "Process", "the", "request", "before", "routing", "it", "." ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/middleware/security/__init__.py#L21-L28
sassoo/goldman
goldman/middleware/security/__init__.py
Middleware.process_response
def process_response(self, req, resp, resource): """ Post-processing of the response (after routing). We attempt to follow many of the 'hardening reponse headers' best practices. These include things like: HPKP: HTTP Public Key Pinning HSTS: HTTP Srict Transport Securit...
python
def process_response(self, req, resp, resource): """ Post-processing of the response (after routing). We attempt to follow many of the 'hardening reponse headers' best practices. These include things like: HPKP: HTTP Public Key Pinning HSTS: HTTP Srict Transport Securit...
[ "def", "process_response", "(", "self", ",", "req", ",", "resp", ",", "resource", ")", ":", "hpkp", "=", "goldman", ".", "config", ".", "HPKP", "if", "hpkp", ":", "resp", ".", "set_header", "(", "'Public-Key-Pins'", ",", "'{}; includeSubdomains; max-age=315360...
Post-processing of the response (after routing). We attempt to follow many of the 'hardening reponse headers' best practices. These include things like: HPKP: HTTP Public Key Pinning HSTS: HTTP Srict Transport Security X-Content-Type-Options: prevent...
[ "Post", "-", "processing", "of", "the", "response", "(", "after", "routing", ")", "." ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/middleware/security/__init__.py#L30-L65
radjkarl/fancyTools
fancytools/fcollections/FIFObuffer.py
FIFObuffer.add
def add(self, value): """ Add a value to the buffer. """ ind = int(self._ind % self.shape) self._pos = self._ind % self.shape self._values[ind] = value if self._ind < self.shape: self._ind += 1 # fast fill else: self._ind += self._...
python
def add(self, value): """ Add a value to the buffer. """ ind = int(self._ind % self.shape) self._pos = self._ind % self.shape self._values[ind] = value if self._ind < self.shape: self._ind += 1 # fast fill else: self._ind += self._...
[ "def", "add", "(", "self", ",", "value", ")", ":", "ind", "=", "int", "(", "self", ".", "_ind", "%", "self", ".", "shape", ")", "self", ".", "_pos", "=", "self", ".", "_ind", "%", "self", ".", "shape", "self", ".", "_values", "[", "ind", "]", ...
Add a value to the buffer.
[ "Add", "a", "value", "to", "the", "buffer", "." ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/fcollections/FIFObuffer.py#L45-L57
radjkarl/fancyTools
fancytools/fcollections/FIFObuffer.py
FIFObuffer.array
def array(self): """ Returns a numpy array containing the last stored values. """ if self._ind < self.shape: return self._values[:self._ind] if not self._cached: ind = int(self._ind % self.shape) self._cache[:self.shape - ind] = self._values[in...
python
def array(self): """ Returns a numpy array containing the last stored values. """ if self._ind < self.shape: return self._values[:self._ind] if not self._cached: ind = int(self._ind % self.shape) self._cache[:self.shape - ind] = self._values[in...
[ "def", "array", "(", "self", ")", ":", "if", "self", ".", "_ind", "<", "self", ".", "shape", ":", "return", "self", ".", "_values", "[", ":", "self", ".", "_ind", "]", "if", "not", "self", ".", "_cached", ":", "ind", "=", "int", "(", "self", "....
Returns a numpy array containing the last stored values.
[ "Returns", "a", "numpy", "array", "containing", "the", "last", "stored", "values", "." ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/fcollections/FIFObuffer.py#L59-L70
radjkarl/fancyTools
fancytools/fcollections/FIFObuffer.py
FIFObuffer.splitPos
def splitPos(self): """return the position of where to split the array to get the values in the right order""" if self._ind < self.shape: return 0 v = int(self._splitPos) if v >= 1: self._splitPos = 0 return v
python
def splitPos(self): """return the position of where to split the array to get the values in the right order""" if self._ind < self.shape: return 0 v = int(self._splitPos) if v >= 1: self._splitPos = 0 return v
[ "def", "splitPos", "(", "self", ")", ":", "if", "self", ".", "_ind", "<", "self", ".", "shape", ":", "return", "0", "v", "=", "int", "(", "self", ".", "_splitPos", ")", "if", "v", ">=", "1", ":", "self", ".", "_splitPos", "=", "0", "return", "v...
return the position of where to split the array to get the values in the right order
[ "return", "the", "position", "of", "where", "to", "split", "the", "array", "to", "get", "the", "values", "in", "the", "right", "order" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/fcollections/FIFObuffer.py#L79-L87
radjkarl/fancyTools
fancytools/geometry/polylines.py
sort
def sort(polylines): """ sort points within polyline p0-p1-p2... """ for n, c in enumerate(polylines): l = len(c) if l > 2: # DEFINE FIRST AND LAST INDEX A THOSE TWO POINTS THAT # HAVE THE BIGGEST DIFFERENCE FROM A MIDDLE: mid = c.mean(axis=0) ...
python
def sort(polylines): """ sort points within polyline p0-p1-p2... """ for n, c in enumerate(polylines): l = len(c) if l > 2: # DEFINE FIRST AND LAST INDEX A THOSE TWO POINTS THAT # HAVE THE BIGGEST DIFFERENCE FROM A MIDDLE: mid = c.mean(axis=0) ...
[ "def", "sort", "(", "polylines", ")", ":", "for", "n", ",", "c", "in", "enumerate", "(", "polylines", ")", ":", "l", "=", "len", "(", "c", ")", "if", "l", ">", "2", ":", "# DEFINE FIRST AND LAST INDEX A THOSE TWO POINTS THAT", "# HAVE THE BIGGEST DIFFERENCE FR...
sort points within polyline p0-p1-p2...
[ "sort", "points", "within", "polyline", "p0", "-", "p1", "-", "p2", "..." ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/geometry/polylines.py#L54-L80
radjkarl/fancyTools
fancytools/geometry/polylines.py
filter
def filter(polylines, min_len=20): """ filter polylines shorter than given min length """ filtered = [] for n in range(len(polylines) - 1, -1, -1): if lengths(polylines[n]).sum() < min_len: filtered.append(polylines.pop(n)) return filtered
python
def filter(polylines, min_len=20): """ filter polylines shorter than given min length """ filtered = [] for n in range(len(polylines) - 1, -1, -1): if lengths(polylines[n]).sum() < min_len: filtered.append(polylines.pop(n)) return filtered
[ "def", "filter", "(", "polylines", ",", "min_len", "=", "20", ")", ":", "filtered", "=", "[", "]", "for", "n", "in", "range", "(", "len", "(", "polylines", ")", "-", "1", ",", "-", "1", ",", "-", "1", ")", ":", "if", "lengths", "(", "polylines"...
filter polylines shorter than given min length
[ "filter", "polylines", "shorter", "than", "given", "min", "length" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/geometry/polylines.py#L83-L91
radjkarl/fancyTools
fancytools/geometry/polylines.py
separate
def separate(polylines, f_mx_dist=2, mn_group_len=4): """ split polylines wherever crinkles are found """ s = [] for n in range(len(polylines) - 1, -1, -1): c = polylines[n] separated = False start = 0 for m in range(mn_group_len, len(c) - 1): if m - sta...
python
def separate(polylines, f_mx_dist=2, mn_group_len=4): """ split polylines wherever crinkles are found """ s = [] for n in range(len(polylines) - 1, -1, -1): c = polylines[n] separated = False start = 0 for m in range(mn_group_len, len(c) - 1): if m - sta...
[ "def", "separate", "(", "polylines", ",", "f_mx_dist", "=", "2", ",", "mn_group_len", "=", "4", ")", ":", "s", "=", "[", "]", "for", "n", "in", "range", "(", "len", "(", "polylines", ")", "-", "1", ",", "-", "1", ",", "-", "1", ")", ":", "c",...
split polylines wherever crinkles are found
[ "split", "polylines", "wherever", "crinkles", "are", "found" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/geometry/polylines.py#L94-L133
radjkarl/fancyTools
fancytools/geometry/polylines.py
merge
def merge(polylines, mx_dist=4): """ point by line segment comparison merge polylines if points are close """ l = len(polylines) to_remove = set() for n in range(l - 1, -1, -1): if n not in to_remove: c = polylines[n] for p0, p1 in zip(c[:-1], c[1:]): ...
python
def merge(polylines, mx_dist=4): """ point by line segment comparison merge polylines if points are close """ l = len(polylines) to_remove = set() for n in range(l - 1, -1, -1): if n not in to_remove: c = polylines[n] for p0, p1 in zip(c[:-1], c[1:]): ...
[ "def", "merge", "(", "polylines", ",", "mx_dist", "=", "4", ")", ":", "l", "=", "len", "(", "polylines", ")", "to_remove", "=", "set", "(", ")", "for", "n", "in", "range", "(", "l", "-", "1", ",", "-", "1", ",", "-", "1", ")", ":", "if", "n...
point by line segment comparison merge polylines if points are close
[ "point", "by", "line", "segment", "comparison", "merge", "polylines", "if", "points", "are", "close" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/geometry/polylines.py#L136-L179
radjkarl/fancyTools
fancytools/geometry/polylines.py
connect
def connect(polylines, max_dist=10): """ connect polylines that are close and have a similar orientation o---o <-> o---o ==> o----o--o----o TODO: max_dist as function of cell size """ ll = len(polylines) remove = [] for n in range(ll - 1, -1, -1): c = polylines[n] if ...
python
def connect(polylines, max_dist=10): """ connect polylines that are close and have a similar orientation o---o <-> o---o ==> o----o--o----o TODO: max_dist as function of cell size """ ll = len(polylines) remove = [] for n in range(ll - 1, -1, -1): c = polylines[n] if ...
[ "def", "connect", "(", "polylines", ",", "max_dist", "=", "10", ")", ":", "ll", "=", "len", "(", "polylines", ")", "remove", "=", "[", "]", "for", "n", "in", "range", "(", "ll", "-", "1", ",", "-", "1", ",", "-", "1", ")", ":", "c", "=", "p...
connect polylines that are close and have a similar orientation o---o <-> o---o ==> o----o--o----o TODO: max_dist as function of cell size
[ "connect", "polylines", "that", "are", "close", "and", "have", "a", "similar", "orientation", "o", "---", "o", "<", "-", ">", "o", "---", "o", "==", ">", "o", "----", "o", "--", "o", "----", "o", "TODO", ":", "max_dist", "as", "function", "of", "ce...
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/geometry/polylines.py#L230-L263
radjkarl/fancyTools
fancytools/geometry/polylines.py
smooth
def smooth(polylines): """ smooth every polyline using spline interpolation """ for c in polylines: if len(c) < 9: # smoothing wouldn't make sense here continue x = c[:, 0] y = c[:, 1] t = np.arange(x.shape[0], dtype=float) t /= t[-1] ...
python
def smooth(polylines): """ smooth every polyline using spline interpolation """ for c in polylines: if len(c) < 9: # smoothing wouldn't make sense here continue x = c[:, 0] y = c[:, 1] t = np.arange(x.shape[0], dtype=float) t /= t[-1] ...
[ "def", "smooth", "(", "polylines", ")", ":", "for", "c", "in", "polylines", ":", "if", "len", "(", "c", ")", "<", "9", ":", "# smoothing wouldn't make sense here", "continue", "x", "=", "c", "[", ":", ",", "0", "]", "y", "=", "c", "[", ":", ",", ...
smooth every polyline using spline interpolation
[ "smooth", "every", "polyline", "using", "spline", "interpolation" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/geometry/polylines.py#L266-L282
rosenbrockc/acorn
acorn/subclass/_numpy.py
_get_acorn
def _get_acorn(self, method, *items): """Gets either a slice or an item from an array. Used for the __getitem__ and __getslice__ special methods of the sub-classed array. Args: method (str): on of ['slice', 'item']. """ #IMPORTANT!! I lost two hours because the ndarray becomes unstable if y...
python
def _get_acorn(self, method, *items): """Gets either a slice or an item from an array. Used for the __getitem__ and __getslice__ special methods of the sub-classed array. Args: method (str): on of ['slice', 'item']. """ #IMPORTANT!! I lost two hours because the ndarray becomes unstable if y...
[ "def", "_get_acorn", "(", "self", ",", "method", ",", "*", "items", ")", ":", "#IMPORTANT!! I lost two hours because the ndarray becomes unstable if you", "#don't call the original method first. Somehow passing the array instance to", "#other methods changed its internal representation and...
Gets either a slice or an item from an array. Used for the __getitem__ and __getslice__ special methods of the sub-classed array. Args: method (str): on of ['slice', 'item'].
[ "Gets", "either", "a", "slice", "or", "an", "item", "from", "an", "array", ".", "Used", "for", "the", "__getitem__", "and", "__getslice__", "special", "methods", "of", "the", "sub", "-", "classed", "array", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/subclass/_numpy.py#L9-L40
colab/colab-superarchives-plugin
src/colab_superarchives/managers.py
MostVotedManager.get_queryset
def get_queryset(self): """Query for the most voted messages sorting by the sum of voted and after by date.""" queryset = super(MostVotedManager, self).get_queryset() sql = """ SELECT count(sav.id) FROM colab_superarchives_vote AS...
python
def get_queryset(self): """Query for the most voted messages sorting by the sum of voted and after by date.""" queryset = super(MostVotedManager, self).get_queryset() sql = """ SELECT count(sav.id) FROM colab_superarchives_vote AS...
[ "def", "get_queryset", "(", "self", ")", ":", "queryset", "=", "super", "(", "MostVotedManager", ",", "self", ")", ".", "get_queryset", "(", ")", "sql", "=", "\"\"\"\n SELECT\n count(sav.id)\n FROM\n colab_superarchives_vote...
Query for the most voted messages sorting by the sum of voted and after by date.
[ "Query", "for", "the", "most", "voted", "messages", "sorting", "by", "the", "sum", "of", "voted", "and", "after", "by", "date", "." ]
train
https://github.com/colab/colab-superarchives-plugin/blob/fe588a1d4fac874ccad2063ee19a857028a22721/src/colab_superarchives/managers.py#L23-L43
rosenbrockc/acorn
acorn/acrn.py
_parser_options
def _parser_options(): """Parses the options and arguments from the command line.""" #We have two options: get some of the details from the config file, import argparse from acorn import base pdescr = "ACORN setup and custom configuration" parser = argparse.ArgumentParser(parents=[base.bparser],...
python
def _parser_options(): """Parses the options and arguments from the command line.""" #We have two options: get some of the details from the config file, import argparse from acorn import base pdescr = "ACORN setup and custom configuration" parser = argparse.ArgumentParser(parents=[base.bparser],...
[ "def", "_parser_options", "(", ")", ":", "#We have two options: get some of the details from the config file,", "import", "argparse", "from", "acorn", "import", "base", "pdescr", "=", "\"ACORN setup and custom configuration\"", "parser", "=", "argparse", ".", "ArgumentParser", ...
Parses the options and arguments from the command line.
[ "Parses", "the", "options", "and", "arguments", "from", "the", "command", "line", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/acrn.py#L35-L49
rosenbrockc/acorn
acorn/acrn.py
_conf_packages
def _conf_packages(args): """Runs custom configuration steps for the packages that ship with support in acorn. """ from acorn.config import config_dir from os import path from acorn.base import testmode target = config_dir(True) alternate = path.join(path.abspath(path.expanduser("~")), "...
python
def _conf_packages(args): """Runs custom configuration steps for the packages that ship with support in acorn. """ from acorn.config import config_dir from os import path from acorn.base import testmode target = config_dir(True) alternate = path.join(path.abspath(path.expanduser("~")), "...
[ "def", "_conf_packages", "(", "args", ")", ":", "from", "acorn", ".", "config", "import", "config_dir", "from", "os", "import", "path", "from", "acorn", ".", "base", "import", "testmode", "target", "=", "config_dir", "(", "True", ")", "alternate", "=", "pa...
Runs custom configuration steps for the packages that ship with support in acorn.
[ "Runs", "custom", "configuration", "steps", "for", "the", "packages", "that", "ship", "with", "support", "in", "acorn", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/acrn.py#L51-L86
rosenbrockc/acorn
acorn/acrn.py
_run_configure
def _run_configure(subcmd, args): """Runs the configuration step for the specified sub-command. """ maps = { "packages": _conf_packages } if subcmd in maps: maps[subcmd](args) else: msg.warn("'configure' sub-command {} is not supported.".format(subcmd))
python
def _run_configure(subcmd, args): """Runs the configuration step for the specified sub-command. """ maps = { "packages": _conf_packages } if subcmd in maps: maps[subcmd](args) else: msg.warn("'configure' sub-command {} is not supported.".format(subcmd))
[ "def", "_run_configure", "(", "subcmd", ",", "args", ")", ":", "maps", "=", "{", "\"packages\"", ":", "_conf_packages", "}", "if", "subcmd", "in", "maps", ":", "maps", "[", "subcmd", "]", "(", "args", ")", "else", ":", "msg", ".", "warn", "(", "\"'co...
Runs the configuration step for the specified sub-command.
[ "Runs", "the", "configuration", "step", "for", "the", "specified", "sub", "-", "command", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/acrn.py#L88-L97
rosenbrockc/acorn
acorn/acrn.py
run
def run(args): """Runs the acorn setup/configuration commands. """ if args is None: return cmd = args["commands"][0] if cmd == "configure": if len(args["commands"]) < 2:# pragma: no cover msg.err("'configure' command requires a second, sub-command " ...
python
def run(args): """Runs the acorn setup/configuration commands. """ if args is None: return cmd = args["commands"][0] if cmd == "configure": if len(args["commands"]) < 2:# pragma: no cover msg.err("'configure' command requires a second, sub-command " ...
[ "def", "run", "(", "args", ")", ":", "if", "args", "is", "None", ":", "return", "cmd", "=", "args", "[", "\"commands\"", "]", "[", "0", "]", "if", "cmd", "==", "\"configure\"", ":", "if", "len", "(", "args", "[", "\"commands\"", "]", ")", "<", "2...
Runs the acorn setup/configuration commands.
[ "Runs", "the", "acorn", "setup", "/", "configuration", "commands", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/acrn.py#L99-L113
rameshg87/pyremotevbox
pyremotevbox/ZSI/parse.py
ParsedSoap._check_for_legal_children
def _check_for_legal_children(self, name, elt, mustqualify=1): '''Check if all children of this node are elements or whitespace-only text nodes. ''' inheader = name == "Header" for n in _children(elt): t = n.nodeType if t == _Node.COMMENT_NODE: continue ...
python
def _check_for_legal_children(self, name, elt, mustqualify=1): '''Check if all children of this node are elements or whitespace-only text nodes. ''' inheader = name == "Header" for n in _children(elt): t = n.nodeType if t == _Node.COMMENT_NODE: continue ...
[ "def", "_check_for_legal_children", "(", "self", ",", "name", ",", "elt", ",", "mustqualify", "=", "1", ")", ":", "inheader", "=", "name", "==", "\"Header\"", "for", "n", "in", "_children", "(", "elt", ")", ":", "t", "=", "n", ".", "nodeType", "if", ...
Check if all children of this node are elements or whitespace-only text nodes.
[ "Check", "if", "all", "children", "of", "this", "node", "are", "elements", "or", "whitespace", "-", "only", "text", "nodes", "." ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/parse.py#L202-L217
rameshg87/pyremotevbox
pyremotevbox/ZSI/parse.py
ParsedSoap._check_for_pi_nodes
def _check_for_pi_nodes(self, list, inheader): '''Raise an exception if any of the list descendants are PI nodes. ''' list = list[:] while list: elt = list.pop() t = elt.nodeType if t == _Node.PROCESSING_INSTRUCTION_NODE: raise ParseExc...
python
def _check_for_pi_nodes(self, list, inheader): '''Raise an exception if any of the list descendants are PI nodes. ''' list = list[:] while list: elt = list.pop() t = elt.nodeType if t == _Node.PROCESSING_INSTRUCTION_NODE: raise ParseExc...
[ "def", "_check_for_pi_nodes", "(", "self", ",", "list", ",", "inheader", ")", ":", "list", "=", "list", "[", ":", "]", "while", "list", ":", "elt", "=", "list", ".", "pop", "(", ")", "t", "=", "elt", ".", "nodeType", "if", "t", "==", "_Node", "."...
Raise an exception if any of the list descendants are PI nodes.
[ "Raise", "an", "exception", "if", "any", "of", "the", "list", "descendants", "are", "PI", "nodes", "." ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/parse.py#L219-L233