id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
40,000
wuher/devil
devil/resource.py
Resource._exec_method
def _exec_method(self, method, request, data, *args, **kw): """ Execute appropriate request handler. """ if self._is_data_method(request): return method(data, request, *args, **kw) else: return method(request, *args, **kw)
python
def _exec_method(self, method, request, data, *args, **kw): """ Execute appropriate request handler. """ if self._is_data_method(request): return method(data, request, *args, **kw) else: return method(request, *args, **kw)
[ "def", "_exec_method", "(", "self", ",", "method", ",", "request", ",", "data", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "if", "self", ".", "_is_data_method", "(", "request", ")", ":", "return", "method", "(", "data", ",", "request", ",", "...
Execute appropriate request handler.
[ "Execute", "appropriate", "request", "handler", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/resource.py#L128-L133
40,001
wuher/devil
devil/resource.py
Resource._format_response
def _format_response(self, request, response): """ Format response using appropriate datamapper. Take the devil response and turn it into django response, ready to be returned to the client. """ res = datamapper.format(request, response, self) # data is now formatted, l...
python
def _format_response(self, request, response): """ Format response using appropriate datamapper. Take the devil response and turn it into django response, ready to be returned to the client. """ res = datamapper.format(request, response, self) # data is now formatted, l...
[ "def", "_format_response", "(", "self", ",", "request", ",", "response", ")", ":", "res", "=", "datamapper", ".", "format", "(", "request", ",", "response", ",", "self", ")", "# data is now formatted, let's check if the status_code is set", "if", "res", ".", "stat...
Format response using appropriate datamapper. Take the devil response and turn it into django response, ready to be returned to the client.
[ "Format", "response", "using", "appropriate", "datamapper", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/resource.py#L173-L186
40,002
wuher/devil
devil/resource.py
Resource._add_resposne_headers
def _add_resposne_headers(self, django_response, devil_response): """ Add response headers. Add HTTP headers from devil's response to django's response. """ try: headers = devil_response.headers except AttributeError: # ok, there was no devil_response ...
python
def _add_resposne_headers(self, django_response, devil_response): """ Add response headers. Add HTTP headers from devil's response to django's response. """ try: headers = devil_response.headers except AttributeError: # ok, there was no devil_response ...
[ "def", "_add_resposne_headers", "(", "self", ",", "django_response", ",", "devil_response", ")", ":", "try", ":", "headers", "=", "devil_response", ".", "headers", "except", "AttributeError", ":", "# ok, there was no devil_response", "pass", "else", ":", "for", "k",...
Add response headers. Add HTTP headers from devil's response to django's response.
[ "Add", "response", "headers", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/resource.py#L188-L202
40,003
wuher/devil
devil/resource.py
Resource._get_input_data
def _get_input_data(self, request): """ If there is data, parse it, otherwise return None. """ # only PUT and POST should provide data if not self._is_data_method(request): return None content = [row for row in request.read()] content = ''.join(content) if content el...
python
def _get_input_data(self, request): """ If there is data, parse it, otherwise return None. """ # only PUT and POST should provide data if not self._is_data_method(request): return None content = [row for row in request.read()] content = ''.join(content) if content el...
[ "def", "_get_input_data", "(", "self", ",", "request", ")", ":", "# only PUT and POST should provide data", "if", "not", "self", ".", "_is_data_method", "(", "request", ")", ":", "return", "None", "content", "=", "[", "row", "for", "row", "in", "request", ".",...
If there is data, parse it, otherwise return None.
[ "If", "there", "is", "data", "parse", "it", "otherwise", "return", "None", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/resource.py#L204-L212
40,004
wuher/devil
devil/resource.py
Resource._clean_input_data
def _clean_input_data(self, data, request): """ Clean input data. """ # sanity check if not self._is_data_method(request): # this is not PUT or POST -> return return data # do cleaning try: if self.representation: # representa...
python
def _clean_input_data(self, data, request): """ Clean input data. """ # sanity check if not self._is_data_method(request): # this is not PUT or POST -> return return data # do cleaning try: if self.representation: # representa...
[ "def", "_clean_input_data", "(", "self", ",", "data", ",", "request", ")", ":", "# sanity check", "if", "not", "self", ".", "_is_data_method", "(", "request", ")", ":", "# this is not PUT or POST -> return", "return", "data", "# do cleaning", "try", ":", "if", "...
Clean input data.
[ "Clean", "input", "data", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/resource.py#L218-L238
40,005
wuher/devil
devil/resource.py
Resource._get_input_validator
def _get_input_validator(self, request): """ Return appropriate input validator. For POST requests, ``self.post_representation`` is returned if it is present, ``self.representation`` otherwise. """ method = request.method.upper() if method != 'POST': return ...
python
def _get_input_validator(self, request): """ Return appropriate input validator. For POST requests, ``self.post_representation`` is returned if it is present, ``self.representation`` otherwise. """ method = request.method.upper() if method != 'POST': return ...
[ "def", "_get_input_validator", "(", "self", ",", "request", ")", ":", "method", "=", "request", ".", "method", ".", "upper", "(", ")", "if", "method", "!=", "'POST'", ":", "return", "self", ".", "representation", "elif", "self", ".", "post_representation", ...
Return appropriate input validator. For POST requests, ``self.post_representation`` is returned if it is present, ``self.representation`` otherwise.
[ "Return", "appropriate", "input", "validator", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/resource.py#L240-L253
40,006
wuher/devil
devil/resource.py
Resource._validate_input_data
def _validate_input_data(self, data, request): """ Validate input data. :param request: the HTTP request :param data: the parsed data :return: if validation is performed and succeeds the data is converted into whatever format the validation uses (by default Django's ...
python
def _validate_input_data(self, data, request): """ Validate input data. :param request: the HTTP request :param data: the parsed data :return: if validation is performed and succeeds the data is converted into whatever format the validation uses (by default Django's ...
[ "def", "_validate_input_data", "(", "self", ",", "data", ",", "request", ")", ":", "validator", "=", "self", ".", "_get_input_validator", "(", "request", ")", "if", "isinstance", "(", "data", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "map"...
Validate input data. :param request: the HTTP request :param data: the parsed data :return: if validation is performed and succeeds the data is converted into whatever format the validation uses (by default Django's Forms) If not, the data is returned unchanged...
[ "Validate", "input", "data", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/resource.py#L255-L270
40,007
wuher/devil
devil/resource.py
Resource._validate_output_data
def _validate_output_data( self, original_res, serialized_res, formatted_res, request): """ Validate the response data. :param response: ``HttpResponse`` :param data: payload data. This implementation assumes dict or list of dicts. :raises: `HttpStatusCodeEr...
python
def _validate_output_data( self, original_res, serialized_res, formatted_res, request): """ Validate the response data. :param response: ``HttpResponse`` :param data: payload data. This implementation assumes dict or list of dicts. :raises: `HttpStatusCodeEr...
[ "def", "_validate_output_data", "(", "self", ",", "original_res", ",", "serialized_res", ",", "formatted_res", ",", "request", ")", ":", "validator", "=", "self", ".", "representation", "# when not to validate...", "if", "not", "validator", ":", "return", "try", "...
Validate the response data. :param response: ``HttpResponse`` :param data: payload data. This implementation assumes dict or list of dicts. :raises: `HttpStatusCodeError` if data is not valid
[ "Validate", "the", "response", "data", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/resource.py#L272-L294
40,008
wuher/devil
devil/resource.py
Resource._create_object
def _create_object(self, data, request): """ Create a python object from the given data. This will use ``self.factory`` object's ``create()`` function to create the data. If no factory is defined, this will simply return the same data that was given. """ if req...
python
def _create_object(self, data, request): """ Create a python object from the given data. This will use ``self.factory`` object's ``create()`` function to create the data. If no factory is defined, this will simply return the same data that was given. """ if req...
[ "def", "_create_object", "(", "self", ",", "data", ",", "request", ")", ":", "if", "request", ".", "method", ".", "upper", "(", ")", "==", "'POST'", "and", "self", ".", "post_factory", ":", "fac_func", "=", "self", ".", "post_factory", ".", "create", "...
Create a python object from the given data. This will use ``self.factory`` object's ``create()`` function to create the data. If no factory is defined, this will simply return the same data that was given.
[ "Create", "a", "python", "object", "from", "the", "given", "data", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/resource.py#L316-L334
40,009
wuher/devil
devil/resource.py
Resource._serialize_object
def _serialize_object(self, response_data, request): """ Create a python datatype from the given python object. This will use ``self.factory`` object's ``serialize()`` function to convert the object into dictionary. If no factory is defined, this will simply return the same data ...
python
def _serialize_object(self, response_data, request): """ Create a python datatype from the given python object. This will use ``self.factory`` object's ``serialize()`` function to convert the object into dictionary. If no factory is defined, this will simply return the same data ...
[ "def", "_serialize_object", "(", "self", ",", "response_data", ",", "request", ")", ":", "if", "not", "self", ".", "factory", ":", "return", "response_data", "if", "isinstance", "(", "response_data", ",", "(", "list", ",", "tuple", ")", ")", ":", "return",...
Create a python datatype from the given python object. This will use ``self.factory`` object's ``serialize()`` function to convert the object into dictionary. If no factory is defined, this will simply return the same data that was given. :param response_data: data returned by...
[ "Create", "a", "python", "datatype", "from", "the", "given", "python", "object", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/resource.py#L336-L355
40,010
wuher/devil
devil/resource.py
Resource._get_unknown_error_response
def _get_unknown_error_response(self, request, exc): """ Generate HttpResponse for unknown exceptions. todo: this should be more informative.. """ logging.getLogger('devil').error( 'while doing %s on %s with [%s], devil caught: %s' % ( request.method, reques...
python
def _get_unknown_error_response(self, request, exc): """ Generate HttpResponse for unknown exceptions. todo: this should be more informative.. """ logging.getLogger('devil').error( 'while doing %s on %s with [%s], devil caught: %s' % ( request.method, reques...
[ "def", "_get_unknown_error_response", "(", "self", ",", "request", ",", "exc", ")", ":", "logging", ".", "getLogger", "(", "'devil'", ")", ".", "error", "(", "'while doing %s on %s with [%s], devil caught: %s'", "%", "(", "request", ".", "method", ",", "request", ...
Generate HttpResponse for unknown exceptions. todo: this should be more informative..
[ "Generate", "HttpResponse", "for", "unknown", "exceptions", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/resource.py#L357-L370
40,011
wuher/devil
devil/resource.py
Resource._get_error_response
def _get_error_response(self, exc): """ Generate HttpResponse based on the HttpStatusCodeError. """ if exc.has_code(codes.UNAUTHORIZED): return self._get_auth_challenge(exc) else: if exc.has_code(codes.INTERNAL_SERVER_ERROR): logging.getLogger('devil').err...
python
def _get_error_response(self, exc): """ Generate HttpResponse based on the HttpStatusCodeError. """ if exc.has_code(codes.UNAUTHORIZED): return self._get_auth_challenge(exc) else: if exc.has_code(codes.INTERNAL_SERVER_ERROR): logging.getLogger('devil').err...
[ "def", "_get_error_response", "(", "self", ",", "exc", ")", ":", "if", "exc", ".", "has_code", "(", "codes", ".", "UNAUTHORIZED", ")", ":", "return", "self", ".", "_get_auth_challenge", "(", "exc", ")", "else", ":", "if", "exc", ".", "has_code", "(", "...
Generate HttpResponse based on the HttpStatusCodeError.
[ "Generate", "HttpResponse", "based", "on", "the", "HttpStatusCodeError", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/resource.py#L372-L382
40,012
wuher/devil
devil/resource.py
Resource._get_auth_challenge
def _get_auth_challenge(self, exc): """ Returns HttpResponse for the client. """ response = HttpResponse(content=exc.content, status=exc.get_code_num()) response['WWW-Authenticate'] = 'Basic realm="%s"' % REALM return response
python
def _get_auth_challenge(self, exc): """ Returns HttpResponse for the client. """ response = HttpResponse(content=exc.content, status=exc.get_code_num()) response['WWW-Authenticate'] = 'Basic realm="%s"' % REALM return response
[ "def", "_get_auth_challenge", "(", "self", ",", "exc", ")", ":", "response", "=", "HttpResponse", "(", "content", "=", "exc", ".", "content", ",", "status", "=", "exc", ".", "get_code_num", "(", ")", ")", "response", "[", "'WWW-Authenticate'", "]", "=", ...
Returns HttpResponse for the client.
[ "Returns", "HttpResponse", "for", "the", "client", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/resource.py#L384-L388
40,013
wuher/devil
devil/resource.py
Resource._get_method
def _get_method(self, request): """ Figure out the requested method and return the callable. """ methodname = request.method.lower() method = getattr(self, methodname, None) if not method or not callable(method): raise errors.MethodNotAllowed() return method
python
def _get_method(self, request): """ Figure out the requested method and return the callable. """ methodname = request.method.lower() method = getattr(self, methodname, None) if not method or not callable(method): raise errors.MethodNotAllowed() return method
[ "def", "_get_method", "(", "self", ",", "request", ")", ":", "methodname", "=", "request", ".", "method", ".", "lower", "(", ")", "method", "=", "getattr", "(", "self", ",", "methodname", ",", "None", ")", "if", "not", "method", "or", "not", "callable"...
Figure out the requested method and return the callable.
[ "Figure", "out", "the", "requested", "method", "and", "return", "the", "callable", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/resource.py#L390-L396
40,014
wuher/devil
devil/resource.py
Resource._authenticate
def _authenticate(self, request): """ Perform authentication. """ def ensure_user_obj(): """ Make sure that request object has user property. If `request.user` is not present or is `None`, it is created and initialized with `AnonymousUser`. """ ...
python
def _authenticate(self, request): """ Perform authentication. """ def ensure_user_obj(): """ Make sure that request object has user property. If `request.user` is not present or is `None`, it is created and initialized with `AnonymousUser`. """ ...
[ "def", "_authenticate", "(", "self", ",", "request", ")", ":", "def", "ensure_user_obj", "(", ")", ":", "\"\"\" Make sure that request object has user property.\n\n If `request.user` is not present or is `None`, it is\n created and initialized with `AnonymousUser`.\n ...
Perform authentication.
[ "Perform", "authentication", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/resource.py#L402-L449
40,015
kellerza/pyqwikswitch
example.py
print_item_callback
def print_item_callback(item): """Print an item callback, used by &listen.""" print('&listen [{}, {}={}]'.format( item.get('cmd', ''), item.get('id', ''), item.get('data', '')))
python
def print_item_callback(item): """Print an item callback, used by &listen.""" print('&listen [{}, {}={}]'.format( item.get('cmd', ''), item.get('id', ''), item.get('data', '')))
[ "def", "print_item_callback", "(", "item", ")", ":", "print", "(", "'&listen [{}, {}={}]'", ".", "format", "(", "item", ".", "get", "(", "'cmd'", ",", "''", ")", ",", "item", ".", "get", "(", "'id'", ",", "''", ")", ",", "item", ".", "get", "(", "'...
Print an item callback, used by &listen.
[ "Print", "an", "item", "callback", "used", "by", "&listen", "." ]
9d4f080048221eaee93e3eefcf641919ff1af586
https://github.com/kellerza/pyqwikswitch/blob/9d4f080048221eaee93e3eefcf641919ff1af586/example.py#L31-L36
40,016
kellerza/pyqwikswitch
example.py
main
def main(): """Quick test for QSUsb class.""" import argparse parser = argparse.ArgumentParser() parser.add_argument('--url', help='QSUSB URL [http://127.0.0.1:2020]', default='http://127.0.0.1:2020') parser.add_argument('--file', help='a test file from /&devices') parser...
python
def main(): """Quick test for QSUsb class.""" import argparse parser = argparse.ArgumentParser() parser.add_argument('--url', help='QSUSB URL [http://127.0.0.1:2020]', default='http://127.0.0.1:2020') parser.add_argument('--file', help='a test file from /&devices') parser...
[ "def", "main", "(", ")", ":", "import", "argparse", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'--url'", ",", "help", "=", "'QSUSB URL [http://127.0.0.1:2020]'", ",", "default", "=", "'http://127.0.0.1:2020'", ...
Quick test for QSUsb class.
[ "Quick", "test", "for", "QSUsb", "class", "." ]
9d4f080048221eaee93e3eefcf641919ff1af586
https://github.com/kellerza/pyqwikswitch/blob/9d4f080048221eaee93e3eefcf641919ff1af586/example.py#L54-L96
40,017
stevepeak/dictime
dictime/moment.py
moment.get
def get(self): """Called to get the asset values and if it is valid """ with self._lock: now = datetime.now() active = [] for i, vef in enumerate(self.futures): # has expired if (vef[1] or datetime.max) <= now: ...
python
def get(self): """Called to get the asset values and if it is valid """ with self._lock: now = datetime.now() active = [] for i, vef in enumerate(self.futures): # has expired if (vef[1] or datetime.max) <= now: ...
[ "def", "get", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "now", "=", "datetime", ".", "now", "(", ")", "active", "=", "[", "]", "for", "i", ",", "vef", "in", "enumerate", "(", "self", ".", "futures", ")", ":", "# has expired", "if"...
Called to get the asset values and if it is valid
[ "Called", "to", "get", "the", "asset", "values", "and", "if", "it", "is", "valid" ]
6d8724bed5a7844e47a9c16a233f8db494c98c61
https://github.com/stevepeak/dictime/blob/6d8724bed5a7844e47a9c16a233f8db494c98c61/dictime/moment.py#L14-L39
40,018
ThomasChiroux/attowiki
src/attowiki/rst_directives.py
add_node
def add_node(node, **kwds): """add_node from Sphinx """ nodes._add_node_class_names([node.__name__]) for key, val in kwds.iteritems(): try: visit, depart = val except ValueError: raise ValueError('Value for key %r must be a ' '(vis...
python
def add_node(node, **kwds): """add_node from Sphinx """ nodes._add_node_class_names([node.__name__]) for key, val in kwds.iteritems(): try: visit, depart = val except ValueError: raise ValueError('Value for key %r must be a ' '(vis...
[ "def", "add_node", "(", "node", ",", "*", "*", "kwds", ")", ":", "nodes", ".", "_add_node_class_names", "(", "[", "node", ".", "__name__", "]", ")", "for", "key", ",", "val", "in", "kwds", ".", "iteritems", "(", ")", ":", "try", ":", "visit", ",", ...
add_node from Sphinx
[ "add_node", "from", "Sphinx" ]
6c93c420305490d324fdc95a7b40b2283a222183
https://github.com/ThomasChiroux/attowiki/blob/6c93c420305490d324fdc95a7b40b2283a222183/src/attowiki/rst_directives.py#L30-L49
40,019
concordusapps/python-shield
shield/_registry.py
Registry.retrieve
def retrieve(self, *args, **kwargs): """Retrieve the permsission function for the provided things. """ lookup, key = self._lookup(*args, **kwargs) return lookup[key]
python
def retrieve(self, *args, **kwargs): """Retrieve the permsission function for the provided things. """ lookup, key = self._lookup(*args, **kwargs) return lookup[key]
[ "def", "retrieve", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "lookup", ",", "key", "=", "self", ".", "_lookup", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return", "lookup", "[", "key", "]" ]
Retrieve the permsission function for the provided things.
[ "Retrieve", "the", "permsission", "function", "for", "the", "provided", "things", "." ]
3c08d483eaec1ebaa814e31c7de5daf82234b8f7
https://github.com/concordusapps/python-shield/blob/3c08d483eaec1ebaa814e31c7de5daf82234b8f7/shield/_registry.py#L129-L135
40,020
evocell/rabifier
rabifier/rabmyfire.py
Gprotein.has_rabf_motif
def has_rabf_motif(self): """Checks if the sequence has enough RabF motifs within the G domain If there exists more than one G domain in the sequence enough RabF motifs is required in at least one of those domains to classify the sequence as a Rab. """ if self.rabf_motifs: ...
python
def has_rabf_motif(self): """Checks if the sequence has enough RabF motifs within the G domain If there exists more than one G domain in the sequence enough RabF motifs is required in at least one of those domains to classify the sequence as a Rab. """ if self.rabf_motifs: ...
[ "def", "has_rabf_motif", "(", "self", ")", ":", "if", "self", ".", "rabf_motifs", ":", "for", "gdomain", "in", "self", ".", "gdomain_regions", ":", "beg", ",", "end", "=", "map", "(", "int", ",", "gdomain", ".", "split", "(", "'-'", ")", ")", "motifs...
Checks if the sequence has enough RabF motifs within the G domain If there exists more than one G domain in the sequence enough RabF motifs is required in at least one of those domains to classify the sequence as a Rab.
[ "Checks", "if", "the", "sequence", "has", "enough", "RabF", "motifs", "within", "the", "G", "domain" ]
a5be3d516517e555bde463b94f06aeed106d19b8
https://github.com/evocell/rabifier/blob/a5be3d516517e555bde463b94f06aeed106d19b8/rabifier/rabmyfire.py#L73-L88
40,021
evocell/rabifier
rabifier/rabmyfire.py
Gprotein.summarize
def summarize(self): """ G protein annotation summary in a text format :return: A string summary of the annotation :rtype: str """ data = [ ['Sequence ID', self.seqrecord.id], ['G domain', ' '.join(self.gdomain_regions) if self.gdomain_regions else None],...
python
def summarize(self): """ G protein annotation summary in a text format :return: A string summary of the annotation :rtype: str """ data = [ ['Sequence ID', self.seqrecord.id], ['G domain', ' '.join(self.gdomain_regions) if self.gdomain_regions else None],...
[ "def", "summarize", "(", "self", ")", ":", "data", "=", "[", "[", "'Sequence ID'", ",", "self", ".", "seqrecord", ".", "id", "]", ",", "[", "'G domain'", ",", "' '", ".", "join", "(", "self", ".", "gdomain_regions", ")", "if", "self", ".", "gdomain_r...
G protein annotation summary in a text format :return: A string summary of the annotation :rtype: str
[ "G", "protein", "annotation", "summary", "in", "a", "text", "format" ]
a5be3d516517e555bde463b94f06aeed106d19b8
https://github.com/evocell/rabifier/blob/a5be3d516517e555bde463b94f06aeed106d19b8/rabifier/rabmyfire.py#L120-L141
40,022
evocell/rabifier
rabifier/rabmyfire.py
Phase1.write
def write(self): """Write sequences predicted to be Rabs as a fasta file. :return: Number of written sequences :rtype: int """ rabs = [x.seqrecord for x in self.gproteins.values() if x.is_rab()] return SeqIO.write(rabs, self.tmpfname + '.phase2', 'fasta')
python
def write(self): """Write sequences predicted to be Rabs as a fasta file. :return: Number of written sequences :rtype: int """ rabs = [x.seqrecord for x in self.gproteins.values() if x.is_rab()] return SeqIO.write(rabs, self.tmpfname + '.phase2', 'fasta')
[ "def", "write", "(", "self", ")", ":", "rabs", "=", "[", "x", ".", "seqrecord", "for", "x", "in", "self", ".", "gproteins", ".", "values", "(", ")", "if", "x", ".", "is_rab", "(", ")", "]", "return", "SeqIO", ".", "write", "(", "rabs", ",", "se...
Write sequences predicted to be Rabs as a fasta file. :return: Number of written sequences :rtype: int
[ "Write", "sequences", "predicted", "to", "be", "Rabs", "as", "a", "fasta", "file", "." ]
a5be3d516517e555bde463b94f06aeed106d19b8
https://github.com/evocell/rabifier/blob/a5be3d516517e555bde463b94f06aeed106d19b8/rabifier/rabmyfire.py#L300-L308
40,023
evocell/rabifier
rabifier/rabmyfire.py
Rabmyfire.check
def check(self): """ Check if data and third party tools, necessary to run the classification, are available :raises: RuntimeError """ pathfinder = Pathfinder(True) if pathfinder.add_path(pathfinder['superfamily']) is None: raise RuntimeError("'superfamily' data dir...
python
def check(self): """ Check if data and third party tools, necessary to run the classification, are available :raises: RuntimeError """ pathfinder = Pathfinder(True) if pathfinder.add_path(pathfinder['superfamily']) is None: raise RuntimeError("'superfamily' data dir...
[ "def", "check", "(", "self", ")", ":", "pathfinder", "=", "Pathfinder", "(", "True", ")", "if", "pathfinder", ".", "add_path", "(", "pathfinder", "[", "'superfamily'", "]", ")", "is", "None", ":", "raise", "RuntimeError", "(", "\"'superfamily' data directory i...
Check if data and third party tools, necessary to run the classification, are available :raises: RuntimeError
[ "Check", "if", "data", "and", "third", "party", "tools", "necessary", "to", "run", "the", "classification", "are", "available" ]
a5be3d516517e555bde463b94f06aeed106d19b8
https://github.com/evocell/rabifier/blob/a5be3d516517e555bde463b94f06aeed106d19b8/rabifier/rabmyfire.py#L474-L486
40,024
concordusapps/python-shield
shield/utils.py
filter_
def filter_(*permissions, **kwargs): """ Constructs a clause to filter all bearers or targets for a given berarer or target. """ bearer = kwargs['bearer'] target = kwargs.get('target') bearer_cls = type_for(bearer) # We need a query object. There are many ways to get one, Either we ca...
python
def filter_(*permissions, **kwargs): """ Constructs a clause to filter all bearers or targets for a given berarer or target. """ bearer = kwargs['bearer'] target = kwargs.get('target') bearer_cls = type_for(bearer) # We need a query object. There are many ways to get one, Either we ca...
[ "def", "filter_", "(", "*", "permissions", ",", "*", "*", "kwargs", ")", ":", "bearer", "=", "kwargs", "[", "'bearer'", "]", "target", "=", "kwargs", ".", "get", "(", "'target'", ")", "bearer_cls", "=", "type_for", "(", "bearer", ")", "# We need a query ...
Constructs a clause to filter all bearers or targets for a given berarer or target.
[ "Constructs", "a", "clause", "to", "filter", "all", "bearers", "or", "targets", "for", "a", "given", "berarer", "or", "target", "." ]
3c08d483eaec1ebaa814e31c7de5daf82234b8f7
https://github.com/concordusapps/python-shield/blob/3c08d483eaec1ebaa814e31c7de5daf82234b8f7/shield/utils.py#L15-L61
40,025
Julian/Minion
minion/wsgi.py
create_app
def create_app(application, request_class=Request): """ Create a WSGI application out of the given Minion app. Arguments: application (Application): a minion app request_class (callable): a class to use for constructing incoming requests out of the WSGI ...
python
def create_app(application, request_class=Request): """ Create a WSGI application out of the given Minion app. Arguments: application (Application): a minion app request_class (callable): a class to use for constructing incoming requests out of the WSGI ...
[ "def", "create_app", "(", "application", ",", "request_class", "=", "Request", ")", ":", "def", "wsgi", "(", "environ", ",", "start_response", ")", ":", "response", "=", "application", ".", "serve", "(", "request", "=", "request_class", "(", "environ", ")", ...
Create a WSGI application out of the given Minion app. Arguments: application (Application): a minion app request_class (callable): a class to use for constructing incoming requests out of the WSGI environment. It will be passed a single arg, the environ. ...
[ "Create", "a", "WSGI", "application", "out", "of", "the", "given", "Minion", "app", "." ]
518d06f9ffd38dcacc0de4d94e72d1f8452157a8
https://github.com/Julian/Minion/blob/518d06f9ffd38dcacc0de4d94e72d1f8452157a8/minion/wsgi.py#L59-L90
40,026
wuher/devil
devil/docs/resource.py
DocumentedResource.get_documentation
def get_documentation(self, request, *args, **kw): """ Generate the documentation. """ ret = dict() ret['resource'] = self.name() ret['urls'] = self._get_url_doc() ret['description'] = self.__doc__ ret['representation'] = self._get_representation_doc() ret['method...
python
def get_documentation(self, request, *args, **kw): """ Generate the documentation. """ ret = dict() ret['resource'] = self.name() ret['urls'] = self._get_url_doc() ret['description'] = self.__doc__ ret['representation'] = self._get_representation_doc() ret['method...
[ "def", "get_documentation", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "ret", "=", "dict", "(", ")", "ret", "[", "'resource'", "]", "=", "self", ".", "name", "(", ")", "ret", "[", "'urls'", "]", "=", "self", "...
Generate the documentation.
[ "Generate", "the", "documentation", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/docs/resource.py#L35-L43
40,027
wuher/devil
devil/docs/resource.py
DocumentedResource._serialize_object
def _serialize_object(self, response_data, request): """ Override to not serialize doc responses. """ if self._is_doc_request(request): return response_data else: return super(DocumentedResource, self)._serialize_object( response_data, request)
python
def _serialize_object(self, response_data, request): """ Override to not serialize doc responses. """ if self._is_doc_request(request): return response_data else: return super(DocumentedResource, self)._serialize_object( response_data, request)
[ "def", "_serialize_object", "(", "self", ",", "response_data", ",", "request", ")", ":", "if", "self", ".", "_is_doc_request", "(", "request", ")", ":", "return", "response_data", "else", ":", "return", "super", "(", "DocumentedResource", ",", "self", ")", "...
Override to not serialize doc responses.
[ "Override", "to", "not", "serialize", "doc", "responses", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/docs/resource.py#L45-L51
40,028
wuher/devil
devil/docs/resource.py
DocumentedResource._validate_output_data
def _validate_output_data( self, original_res, serialized_res, formatted_res, request): """ Override to not validate doc output. """ if self._is_doc_request(request): return else: return super(DocumentedResource, self)._validate_output_data( origin...
python
def _validate_output_data( self, original_res, serialized_res, formatted_res, request): """ Override to not validate doc output. """ if self._is_doc_request(request): return else: return super(DocumentedResource, self)._validate_output_data( origin...
[ "def", "_validate_output_data", "(", "self", ",", "original_res", ",", "serialized_res", ",", "formatted_res", ",", "request", ")", ":", "if", "self", ".", "_is_doc_request", "(", "request", ")", ":", "return", "else", ":", "return", "super", "(", "DocumentedR...
Override to not validate doc output.
[ "Override", "to", "not", "validate", "doc", "output", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/docs/resource.py#L53-L60
40,029
wuher/devil
devil/docs/resource.py
DocumentedResource._get_method
def _get_method(self, request): """ Override to check if this is a documentation request. """ if self._is_doc_request(request): return self.get_documentation else: return super(DocumentedResource, self)._get_method(request)
python
def _get_method(self, request): """ Override to check if this is a documentation request. """ if self._is_doc_request(request): return self.get_documentation else: return super(DocumentedResource, self)._get_method(request)
[ "def", "_get_method", "(", "self", ",", "request", ")", ":", "if", "self", ".", "_is_doc_request", "(", "request", ")", ":", "return", "self", ".", "get_documentation", "else", ":", "return", "super", "(", "DocumentedResource", ",", "self", ")", ".", "_get...
Override to check if this is a documentation request.
[ "Override", "to", "check", "if", "this", "is", "a", "documentation", "request", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/docs/resource.py#L62-L67
40,030
wuher/devil
devil/docs/resource.py
DocumentedResource._get_representation_doc
def _get_representation_doc(self): """ Return documentation for the representation of the resource. """ if not self.representation: return 'N/A' fields = {} for name, field in self.representation.fields.items(): fields[name] = self._get_field_doc(field) re...
python
def _get_representation_doc(self): """ Return documentation for the representation of the resource. """ if not self.representation: return 'N/A' fields = {} for name, field in self.representation.fields.items(): fields[name] = self._get_field_doc(field) re...
[ "def", "_get_representation_doc", "(", "self", ")", ":", "if", "not", "self", ".", "representation", ":", "return", "'N/A'", "fields", "=", "{", "}", "for", "name", ",", "field", "in", "self", ".", "representation", ".", "fields", ".", "items", "(", ")",...
Return documentation for the representation of the resource.
[ "Return", "documentation", "for", "the", "representation", "of", "the", "resource", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/docs/resource.py#L73-L80
40,031
wuher/devil
devil/docs/resource.py
DocumentedResource._get_field_doc
def _get_field_doc(self, field): """ Return documentation for a field in the representation. """ fieldspec = dict() fieldspec['type'] = field.__class__.__name__ fieldspec['required'] = field.required fieldspec['validators'] = [{validator.__class__.__name__: validator.__dict__} fo...
python
def _get_field_doc(self, field): """ Return documentation for a field in the representation. """ fieldspec = dict() fieldspec['type'] = field.__class__.__name__ fieldspec['required'] = field.required fieldspec['validators'] = [{validator.__class__.__name__: validator.__dict__} fo...
[ "def", "_get_field_doc", "(", "self", ",", "field", ")", ":", "fieldspec", "=", "dict", "(", ")", "fieldspec", "[", "'type'", "]", "=", "field", ".", "__class__", ".", "__name__", "fieldspec", "[", "'required'", "]", "=", "field", ".", "required", "field...
Return documentation for a field in the representation.
[ "Return", "documentation", "for", "a", "field", "in", "the", "representation", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/docs/resource.py#L82-L88
40,032
wuher/devil
devil/docs/resource.py
DocumentedResource._get_url_doc
def _get_url_doc(self): """ Return a list of URLs that map to this resource. """ resolver = get_resolver(None) possibilities = resolver.reverse_dict.getlist(self) urls = [possibility[0] for possibility in possibilities] return urls
python
def _get_url_doc(self): """ Return a list of URLs that map to this resource. """ resolver = get_resolver(None) possibilities = resolver.reverse_dict.getlist(self) urls = [possibility[0] for possibility in possibilities] return urls
[ "def", "_get_url_doc", "(", "self", ")", ":", "resolver", "=", "get_resolver", "(", "None", ")", "possibilities", "=", "resolver", ".", "reverse_dict", ".", "getlist", "(", "self", ")", "urls", "=", "[", "possibility", "[", "0", "]", "for", "possibility", ...
Return a list of URLs that map to this resource.
[ "Return", "a", "list", "of", "URLs", "that", "map", "to", "this", "resource", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/docs/resource.py#L90-L95
40,033
wuher/devil
devil/docs/resource.py
DocumentedResource._get_method_doc
def _get_method_doc(self): """ Return method documentations. """ ret = {} for method_name in self.methods: method = getattr(self, method_name, None) if method: ret[method_name] = method.__doc__ return ret
python
def _get_method_doc(self): """ Return method documentations. """ ret = {} for method_name in self.methods: method = getattr(self, method_name, None) if method: ret[method_name] = method.__doc__ return ret
[ "def", "_get_method_doc", "(", "self", ")", ":", "ret", "=", "{", "}", "for", "method_name", "in", "self", ".", "methods", ":", "method", "=", "getattr", "(", "self", ",", "method_name", ",", "None", ")", "if", "method", ":", "ret", "[", "method_name",...
Return method documentations.
[ "Return", "method", "documentations", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/docs/resource.py#L97-L104
40,034
ten10solutions/Geist
geist/backends/_x11_common.py
GeistXBase.create_process
def create_process(self, command, shell=True, stdout=None, stderr=None, env=None): """ Execute a process using subprocess.Popen, setting the backend's DISPLAY """ env = env if env is not None else dict(os.environ) env['DISPLAY'] = self.display retur...
python
def create_process(self, command, shell=True, stdout=None, stderr=None, env=None): """ Execute a process using subprocess.Popen, setting the backend's DISPLAY """ env = env if env is not None else dict(os.environ) env['DISPLAY'] = self.display retur...
[ "def", "create_process", "(", "self", ",", "command", ",", "shell", "=", "True", ",", "stdout", "=", "None", ",", "stderr", "=", "None", ",", "env", "=", "None", ")", ":", "env", "=", "env", "if", "env", "is", "not", "None", "else", "dict", "(", ...
Execute a process using subprocess.Popen, setting the backend's DISPLAY
[ "Execute", "a", "process", "using", "subprocess", ".", "Popen", "setting", "the", "backend", "s", "DISPLAY" ]
a1ef16d8b4c3777735008b671a50acfde3ce7bf1
https://github.com/ten10solutions/Geist/blob/a1ef16d8b4c3777735008b671a50acfde3ce7bf1/geist/backends/_x11_common.py#L54-L63
40,035
TissueMAPS/TmDeploy
elasticluster/elasticluster/providers/azure_provider.py
AzureVM.pause
def pause(self, instance_id, keep_provisioned=True): """shuts down the instance without destroying it. The AbstractCloudProvider class uses 'stop' to refer to destroying a VM, so use 'pause' to mean powering it down while leaving it allocated. :param str instance_id: instance i...
python
def pause(self, instance_id, keep_provisioned=True): """shuts down the instance without destroying it. The AbstractCloudProvider class uses 'stop' to refer to destroying a VM, so use 'pause' to mean powering it down while leaving it allocated. :param str instance_id: instance i...
[ "def", "pause", "(", "self", ",", "instance_id", ",", "keep_provisioned", "=", "True", ")", ":", "try", ":", "if", "self", ".", "_paused", ":", "log", ".", "debug", "(", "\"node %s is already paused\"", ",", "instance_id", ")", "return", "self", ".", "_pau...
shuts down the instance without destroying it. The AbstractCloudProvider class uses 'stop' to refer to destroying a VM, so use 'pause' to mean powering it down while leaving it allocated. :param str instance_id: instance identifier :return: None
[ "shuts", "down", "the", "instance", "without", "destroying", "it", "." ]
f891b4ffb21431988bc4a063ae871da3bf284a45
https://github.com/TissueMAPS/TmDeploy/blob/f891b4ffb21431988bc4a063ae871da3bf284a45/elasticluster/elasticluster/providers/azure_provider.py#L1198-L1225
40,036
TissueMAPS/TmDeploy
elasticluster/elasticluster/providers/azure_provider.py
AzureVM.restart
def restart(self, instance_id): """restarts a paused instance. :param str instance_id: instance identifier :return: None """ try: if not self._paused: log.debug("node %s is not paused, can't restart", instance_id) return s...
python
def restart(self, instance_id): """restarts a paused instance. :param str instance_id: instance identifier :return: None """ try: if not self._paused: log.debug("node %s is not paused, can't restart", instance_id) return s...
[ "def", "restart", "(", "self", ",", "instance_id", ")", ":", "try", ":", "if", "not", "self", ".", "_paused", ":", "log", ".", "debug", "(", "\"node %s is not paused, can't restart\"", ",", "instance_id", ")", "return", "self", ".", "_paused", "=", "False", ...
restarts a paused instance. :param str instance_id: instance identifier :return: None
[ "restarts", "a", "paused", "instance", "." ]
f891b4ffb21431988bc4a063ae871da3bf284a45
https://github.com/TissueMAPS/TmDeploy/blob/f891b4ffb21431988bc4a063ae871da3bf284a45/elasticluster/elasticluster/providers/azure_provider.py#L1227-L1247
40,037
TissueMAPS/TmDeploy
elasticluster/elasticluster/providers/azure_provider.py
AzureCloudProvider._save_or_update
def _save_or_update(self): """Save or update the private state needed by the cloud provider. """ with self._resource_lock: if not self._config or not self._config._storage_path: raise Exception("self._config._storage path is undefined") if not self._config...
python
def _save_or_update(self): """Save or update the private state needed by the cloud provider. """ with self._resource_lock: if not self._config or not self._config._storage_path: raise Exception("self._config._storage path is undefined") if not self._config...
[ "def", "_save_or_update", "(", "self", ")", ":", "with", "self", ".", "_resource_lock", ":", "if", "not", "self", ".", "_config", "or", "not", "self", ".", "_config", ".", "_storage_path", ":", "raise", "Exception", "(", "\"self._config._storage path is undefine...
Save or update the private state needed by the cloud provider.
[ "Save", "or", "update", "the", "private", "state", "needed", "by", "the", "cloud", "provider", "." ]
f891b4ffb21431988bc4a063ae871da3bf284a45
https://github.com/TissueMAPS/TmDeploy/blob/f891b4ffb21431988bc4a063ae871da3bf284a45/elasticluster/elasticluster/providers/azure_provider.py#L1711-L1725
40,038
flashashen/flange
flange/iterutils.py
get_path
def get_path(root, path, default=_UNSET): """Retrieve a value from a nested object via a tuple representing the lookup path. >>> root = {'a': {'b': {'c': [[1], [2], [3]]}}} >>> get_path(root, ('a', 'b', 'c', 2, 0)) 3 The path format is intentionally consistent with that of :func:`remap`. ...
python
def get_path(root, path, default=_UNSET): """Retrieve a value from a nested object via a tuple representing the lookup path. >>> root = {'a': {'b': {'c': [[1], [2], [3]]}}} >>> get_path(root, ('a', 'b', 'c', 2, 0)) 3 The path format is intentionally consistent with that of :func:`remap`. ...
[ "def", "get_path", "(", "root", ",", "path", ",", "default", "=", "_UNSET", ")", ":", "if", "isinstance", "(", "path", ",", "basestring", ")", ":", "path", "=", "path", ".", "split", "(", "'.'", ")", "cur", "=", "root", "try", ":", "for", "seg", ...
Retrieve a value from a nested object via a tuple representing the lookup path. >>> root = {'a': {'b': {'c': [[1], [2], [3]]}}} >>> get_path(root, ('a', 'b', 'c', 2, 0)) 3 The path format is intentionally consistent with that of :func:`remap`. One of get_path's chief aims is improved erro...
[ "Retrieve", "a", "value", "from", "a", "nested", "object", "via", "a", "tuple", "representing", "the", "lookup", "path", "." ]
67ebaf70e39887f65ce1163168d182a8e4c2774a
https://github.com/flashashen/flange/blob/67ebaf70e39887f65ce1163168d182a8e4c2774a/flange/iterutils.py#L967-L1024
40,039
flashashen/flange
flange/iterutils.py
__query
def __query(p, k, v, accepted_keys=None, required_values=None, path=None, exact=True): """ Query function given to visit method :param p: visited path in tuple form :param k: visited key :param v: visited value :param accepted_keys: list of keys where one must match k to satisfy query. :par...
python
def __query(p, k, v, accepted_keys=None, required_values=None, path=None, exact=True): """ Query function given to visit method :param p: visited path in tuple form :param k: visited key :param v: visited value :param accepted_keys: list of keys where one must match k to satisfy query. :par...
[ "def", "__query", "(", "p", ",", "k", ",", "v", ",", "accepted_keys", "=", "None", ",", "required_values", "=", "None", ",", "path", "=", "None", ",", "exact", "=", "True", ")", ":", "# if not k:", "# print '__query p k:', p, k", "# print p, k, accepted_ke...
Query function given to visit method :param p: visited path in tuple form :param k: visited key :param v: visited value :param accepted_keys: list of keys where one must match k to satisfy query. :param required_values: list of values where one must match v to satisfy query :param path: exact p...
[ "Query", "function", "given", "to", "visit", "method" ]
67ebaf70e39887f65ce1163168d182a8e4c2774a
https://github.com/flashashen/flange/blob/67ebaf70e39887f65ce1163168d182a8e4c2774a/flange/iterutils.py#L1298-L1341
40,040
TissueMAPS/TmDeploy
elasticluster/elasticluster/providers/gce.py
GoogleCloudProvider._get_image_url
def _get_image_url(self, image_id): """Gets the url for the specified image. Unfortunatly this only works for images uploaded by the user. The images provided by google will not be found. :param str image_id: image identifier :return: str - api url of the image """ ...
python
def _get_image_url(self, image_id): """Gets the url for the specified image. Unfortunatly this only works for images uploaded by the user. The images provided by google will not be found. :param str image_id: image identifier :return: str - api url of the image """ ...
[ "def", "_get_image_url", "(", "self", ",", "image_id", ")", ":", "gce", "=", "self", ".", "_connect", "(", ")", "filter", "=", "\"name eq %s\"", "%", "image_id", "request", "=", "gce", ".", "images", "(", ")", ".", "list", "(", "project", "=", "self", ...
Gets the url for the specified image. Unfortunatly this only works for images uploaded by the user. The images provided by google will not be found. :param str image_id: image identifier :return: str - api url of the image
[ "Gets", "the", "url", "for", "the", "specified", "image", ".", "Unfortunatly", "this", "only", "works", "for", "images", "uploaded", "by", "the", "user", ".", "The", "images", "provided", "by", "google", "will", "not", "be", "found", "." ]
f891b4ffb21431988bc4a063ae871da3bf284a45
https://github.com/TissueMAPS/TmDeploy/blob/f891b4ffb21431988bc4a063ae871da3bf284a45/elasticluster/elasticluster/providers/gce.py#L476-L497
40,041
TissueMAPS/TmDeploy
elasticluster/elasticluster/subcommands.py
GC3PieConfig.execute
def execute(self): """ Load the cluster and build a GC3Pie configuration snippet. """ creator = make_creator(self.params.config, storage_path=self.params.storage) cluster_name = self.params.cluster try: cluster = creator.load_clu...
python
def execute(self): """ Load the cluster and build a GC3Pie configuration snippet. """ creator = make_creator(self.params.config, storage_path=self.params.storage) cluster_name = self.params.cluster try: cluster = creator.load_clu...
[ "def", "execute", "(", "self", ")", ":", "creator", "=", "make_creator", "(", "self", ".", "params", ".", "config", ",", "storage_path", "=", "self", ".", "params", ".", "storage", ")", "cluster_name", "=", "self", ".", "params", ".", "cluster", "try", ...
Load the cluster and build a GC3Pie configuration snippet.
[ "Load", "the", "cluster", "and", "build", "a", "GC3Pie", "configuration", "snippet", "." ]
f891b4ffb21431988bc4a063ae871da3bf284a45
https://github.com/TissueMAPS/TmDeploy/blob/f891b4ffb21431988bc4a063ae871da3bf284a45/elasticluster/elasticluster/subcommands.py#L778-L804
40,042
wedi/PyMediaRSS2Gen
PyMediaRSS2Gen.py
MediaRSS2.write_xml
def write_xml(self, outfile, encoding="UTF-8"): """Write the Media RSS Feed's XML representation to the given file.""" # we add the media namespace if we see any media items if any([key for item in self.items for key in vars(item) if key.startswith('media_') and getattr(item, key...
python
def write_xml(self, outfile, encoding="UTF-8"): """Write the Media RSS Feed's XML representation to the given file.""" # we add the media namespace if we see any media items if any([key for item in self.items for key in vars(item) if key.startswith('media_') and getattr(item, key...
[ "def", "write_xml", "(", "self", ",", "outfile", ",", "encoding", "=", "\"UTF-8\"", ")", ":", "# we add the media namespace if we see any media items", "if", "any", "(", "[", "key", "for", "item", "in", "self", ".", "items", "for", "key", "in", "vars", "(", ...
Write the Media RSS Feed's XML representation to the given file.
[ "Write", "the", "Media", "RSS", "Feed", "s", "XML", "representation", "to", "the", "given", "file", "." ]
11c3d0f57386906394e303cb31f2e02be2c4fadf
https://github.com/wedi/PyMediaRSS2Gen/blob/11c3d0f57386906394e303cb31f2e02be2c4fadf/PyMediaRSS2Gen.py#L46-L53
40,043
wedi/PyMediaRSS2Gen
PyMediaRSS2Gen.py
MediaContent._add_attribute
def _add_attribute(self, name, value, allowed_values=None): """Add an attribute to the MediaContent element.""" if value and value != 'none': if isinstance(value, (int, bool)): value = str(value) if allowed_values and value not in allowed_values: ...
python
def _add_attribute(self, name, value, allowed_values=None): """Add an attribute to the MediaContent element.""" if value and value != 'none': if isinstance(value, (int, bool)): value = str(value) if allowed_values and value not in allowed_values: ...
[ "def", "_add_attribute", "(", "self", ",", "name", ",", "value", ",", "allowed_values", "=", "None", ")", ":", "if", "value", "and", "value", "!=", "'none'", ":", "if", "isinstance", "(", "value", ",", "(", "int", ",", "bool", ")", ")", ":", "value",...
Add an attribute to the MediaContent element.
[ "Add", "an", "attribute", "to", "the", "MediaContent", "element", "." ]
11c3d0f57386906394e303cb31f2e02be2c4fadf
https://github.com/wedi/PyMediaRSS2Gen/blob/11c3d0f57386906394e303cb31f2e02be2c4fadf/PyMediaRSS2Gen.py#L100-L112
40,044
wedi/PyMediaRSS2Gen
PyMediaRSS2Gen.py
MediaRSSItem.check_complicance
def check_complicance(self): """Check compliance with Media RSS Specification, Version 1.5.1. see http://www.rssboard.org/media-rss Raises AttributeError on error. """ # check Media RSS requirement: one of the following elements is # required: media_group | media_content...
python
def check_complicance(self): """Check compliance with Media RSS Specification, Version 1.5.1. see http://www.rssboard.org/media-rss Raises AttributeError on error. """ # check Media RSS requirement: one of the following elements is # required: media_group | media_content...
[ "def", "check_complicance", "(", "self", ")", ":", "# check Media RSS requirement: one of the following elements is", "# required: media_group | media_content | media_player | media_peerLink", "# | media_location. We do the check only if any media_... element is", "# set to allow non media feeds",...
Check compliance with Media RSS Specification, Version 1.5.1. see http://www.rssboard.org/media-rss Raises AttributeError on error.
[ "Check", "compliance", "with", "Media", "RSS", "Specification", "Version", "1", ".", "5", ".", "1", "." ]
11c3d0f57386906394e303cb31f2e02be2c4fadf
https://github.com/wedi/PyMediaRSS2Gen/blob/11c3d0f57386906394e303cb31f2e02be2c4fadf/PyMediaRSS2Gen.py#L185-L230
40,045
wedi/PyMediaRSS2Gen
PyMediaRSS2Gen.py
MediaRSSItem.publish_extensions
def publish_extensions(self, handler): """Publish the Media RSS Feed elements as XML.""" if isinstance(self.media_content, list): [PyRSS2Gen._opt_element(handler, "media:content", mc_element) for mc_element in self.media_content] else: PyRSS2Gen._opt_element(...
python
def publish_extensions(self, handler): """Publish the Media RSS Feed elements as XML.""" if isinstance(self.media_content, list): [PyRSS2Gen._opt_element(handler, "media:content", mc_element) for mc_element in self.media_content] else: PyRSS2Gen._opt_element(...
[ "def", "publish_extensions", "(", "self", ",", "handler", ")", ":", "if", "isinstance", "(", "self", ".", "media_content", ",", "list", ")", ":", "[", "PyRSS2Gen", ".", "_opt_element", "(", "handler", ",", "\"media:content\"", ",", "mc_element", ")", "for", ...
Publish the Media RSS Feed elements as XML.
[ "Publish", "the", "Media", "RSS", "Feed", "elements", "as", "XML", "." ]
11c3d0f57386906394e303cb31f2e02be2c4fadf
https://github.com/wedi/PyMediaRSS2Gen/blob/11c3d0f57386906394e303cb31f2e02be2c4fadf/PyMediaRSS2Gen.py#L232-L245
40,046
fantastic001/pyfb
pyfacebook/inbox.py
Inbox.get_conversations
def get_conversations(self): """ Returns list of Conversation objects """ cs = self.data["data"] res = [] for c in cs: res.append(Conversation(c)) return res
python
def get_conversations(self): """ Returns list of Conversation objects """ cs = self.data["data"] res = [] for c in cs: res.append(Conversation(c)) return res
[ "def", "get_conversations", "(", "self", ")", ":", "cs", "=", "self", ".", "data", "[", "\"data\"", "]", "res", "=", "[", "]", "for", "c", "in", "cs", ":", "res", ".", "append", "(", "Conversation", "(", "c", ")", ")", "return", "res" ]
Returns list of Conversation objects
[ "Returns", "list", "of", "Conversation", "objects" ]
385a620e8c825fea5c859aec8c309ea59ef06713
https://github.com/fantastic001/pyfb/blob/385a620e8c825fea5c859aec8c309ea59ef06713/pyfacebook/inbox.py#L35-L43
40,047
CodyKochmann/generators
generators/Generator.py
_accumulate
def _accumulate(iterable, func=(lambda a,b:a+b)): # this was from the itertools documentation 'Return running totals' # accumulate([1,2,3,4,5]) --> 1 3 6 10 15 # accumulate([1,2,3,4,5], operator.mul) --> 1 2 6 24 120 it = iter(iterable) try: total = next(it) except StopIteration: ...
python
def _accumulate(iterable, func=(lambda a,b:a+b)): # this was from the itertools documentation 'Return running totals' # accumulate([1,2,3,4,5]) --> 1 3 6 10 15 # accumulate([1,2,3,4,5], operator.mul) --> 1 2 6 24 120 it = iter(iterable) try: total = next(it) except StopIteration: ...
[ "def", "_accumulate", "(", "iterable", ",", "func", "=", "(", "lambda", "a", ",", "b", ":", "a", "+", "b", ")", ")", ":", "# this was from the itertools documentation", "# accumulate([1,2,3,4,5]) --> 1 3 6 10 15", "# accumulate([1,2,3,4,5], operator.mul) --> 1 2 6 24 120", ...
Return running totals
[ "Return", "running", "totals" ]
e4ca4dd25d5023a94b0349c69d6224070cc2526f
https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/Generator.py#L264-L276
40,048
CodyKochmann/generators
generators/Generator.py
Generator.add_methods
def add_methods(methods_to_add): ''' use this to bulk add new methods to Generator ''' for i in methods_to_add: try: Generator.add_method(*i) except Exception as ex: raise Exception('issue adding {} - {}'.format(repr(i), ex))
python
def add_methods(methods_to_add): ''' use this to bulk add new methods to Generator ''' for i in methods_to_add: try: Generator.add_method(*i) except Exception as ex: raise Exception('issue adding {} - {}'.format(repr(i), ex))
[ "def", "add_methods", "(", "methods_to_add", ")", ":", "for", "i", "in", "methods_to_add", ":", "try", ":", "Generator", ".", "add_method", "(", "*", "i", ")", "except", "Exception", "as", "ex", ":", "raise", "Exception", "(", "'issue adding {} - {}'", ".", ...
use this to bulk add new methods to Generator
[ "use", "this", "to", "bulk", "add", "new", "methods", "to", "Generator" ]
e4ca4dd25d5023a94b0349c69d6224070cc2526f
https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/Generator.py#L145-L151
40,049
FNNDSC/pftree
pftree/pftree.py
pftree.dirsize_get
def dirsize_get(l_filesWithoutPath, **kwargs): """ Sample callback that determines a directory size. """ str_path = "" for k,v in kwargs.items(): if k == 'path': str_path = v d_ret = {} l_size = [] size = 0 for f in l_filesWi...
python
def dirsize_get(l_filesWithoutPath, **kwargs): """ Sample callback that determines a directory size. """ str_path = "" for k,v in kwargs.items(): if k == 'path': str_path = v d_ret = {} l_size = [] size = 0 for f in l_filesWi...
[ "def", "dirsize_get", "(", "l_filesWithoutPath", ",", "*", "*", "kwargs", ")", ":", "str_path", "=", "\"\"", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")", ":", "if", "k", "==", "'path'", ":", "str_path", "=", "v", "d_ret", "=", "{",...
Sample callback that determines a directory size.
[ "Sample", "callback", "that", "determines", "a", "directory", "size", "." ]
b841e337c976bce151735f9d5dd95eded62aa094
https://github.com/FNNDSC/pftree/blob/b841e337c976bce151735f9d5dd95eded62aa094/pftree/pftree.py#L284-L309
40,050
FNNDSC/pftree
pftree/pftree.py
pftree.inputReadCallback
def inputReadCallback(self, *args, **kwargs): """ Test for inputReadCallback This method does not actually "read" the input files, but simply returns the passed file list back to caller """ b_status = True filesRead = 0 for k, v in kwargs.i...
python
def inputReadCallback(self, *args, **kwargs): """ Test for inputReadCallback This method does not actually "read" the input files, but simply returns the passed file list back to caller """ b_status = True filesRead = 0 for k, v in kwargs.i...
[ "def", "inputReadCallback", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "b_status", "=", "True", "filesRead", "=", "0", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")", ":", "if", "k", "==", "'l_file'", ":", "l_...
Test for inputReadCallback This method does not actually "read" the input files, but simply returns the passed file list back to caller
[ "Test", "for", "inputReadCallback" ]
b841e337c976bce151735f9d5dd95eded62aa094
https://github.com/FNNDSC/pftree/blob/b841e337c976bce151735f9d5dd95eded62aa094/pftree/pftree.py#L771-L804
40,051
FNNDSC/pftree
pftree/pftree.py
pftree.inputAnalyzeCallback
def inputAnalyzeCallback(self, *args, **kwargs): """ Test method for inputAnalzeCallback This method loops over the passed number of files, and optionally "delays" in each loop to simulate some analysis. The delay length is specified by the '--test <delay>' flag. ...
python
def inputAnalyzeCallback(self, *args, **kwargs): """ Test method for inputAnalzeCallback This method loops over the passed number of files, and optionally "delays" in each loop to simulate some analysis. The delay length is specified by the '--test <delay>' flag. ...
[ "def", "inputAnalyzeCallback", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "b_status", "=", "False", "filesRead", "=", "0", "filesAnalyzed", "=", "0", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")", ":", "if", "k...
Test method for inputAnalzeCallback This method loops over the passed number of files, and optionally "delays" in each loop to simulate some analysis. The delay length is specified by the '--test <delay>' flag.
[ "Test", "method", "for", "inputAnalzeCallback" ]
b841e337c976bce151735f9d5dd95eded62aa094
https://github.com/FNNDSC/pftree/blob/b841e337c976bce151735f9d5dd95eded62aa094/pftree/pftree.py#L806-L842
40,052
FNNDSC/pftree
pftree/pftree.py
pftree.outputSaveCallback
def outputSaveCallback(self, at_data, **kwargs): """ Test method for outputSaveCallback Simply writes a file in the output tree corresponding to the number of files in the input tree. """ path = at_data[0] d_outputInfo = at_data[1] o...
python
def outputSaveCallback(self, at_data, **kwargs): """ Test method for outputSaveCallback Simply writes a file in the output tree corresponding to the number of files in the input tree. """ path = at_data[0] d_outputInfo = at_data[1] o...
[ "def", "outputSaveCallback", "(", "self", ",", "at_data", ",", "*", "*", "kwargs", ")", ":", "path", "=", "at_data", "[", "0", "]", "d_outputInfo", "=", "at_data", "[", "1", "]", "other", ".", "mkdir", "(", "self", ".", "str_outputDir", ")", "filesSave...
Test method for outputSaveCallback Simply writes a file in the output tree corresponding to the number of files in the input tree.
[ "Test", "method", "for", "outputSaveCallback" ]
b841e337c976bce151735f9d5dd95eded62aa094
https://github.com/FNNDSC/pftree/blob/b841e337c976bce151735f9d5dd95eded62aa094/pftree/pftree.py#L844-L873
40,053
FNNDSC/pftree
pftree/pftree.py
pftree.run
def run(self, *args, **kwargs): """ Probe the input tree and print. """ b_status = True d_probe = {} d_tree = {} d_stats = {} str_error = '' b_timerStart = False d_test = {} for k, ...
python
def run(self, *args, **kwargs): """ Probe the input tree and print. """ b_status = True d_probe = {} d_tree = {} d_stats = {} str_error = '' b_timerStart = False d_test = {} for k, ...
[ "def", "run", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "b_status", "=", "True", "d_probe", "=", "{", "}", "d_tree", "=", "{", "}", "d_stats", "=", "{", "}", "str_error", "=", "''", "b_timerStart", "=", "False", "d_test", ...
Probe the input tree and print.
[ "Probe", "the", "input", "tree", "and", "print", "." ]
b841e337c976bce151735f9d5dd95eded62aa094
https://github.com/FNNDSC/pftree/blob/b841e337c976bce151735f9d5dd95eded62aa094/pftree/pftree.py#L891-L967
40,054
cdumay/kser
src/kser/sequencing/operation.py
Operation._set_status
def _set_status(self, status, result=None): """ update operation status :param str status: New status :param cdumay_result.Result result: Execution result """ logger.info( "{}.SetStatus: {}[{}] status update '{}' -> '{}'".format( self.__class__.__name...
python
def _set_status(self, status, result=None): """ update operation status :param str status: New status :param cdumay_result.Result result: Execution result """ logger.info( "{}.SetStatus: {}[{}] status update '{}' -> '{}'".format( self.__class__.__name...
[ "def", "_set_status", "(", "self", ",", "status", ",", "result", "=", "None", ")", ":", "logger", ".", "info", "(", "\"{}.SetStatus: {}[{}] status update '{}' -> '{}'\"", ".", "format", "(", "self", ".", "__class__", ".", "__name__", ",", "self", ".", "__class...
update operation status :param str status: New status :param cdumay_result.Result result: Execution result
[ "update", "operation", "status" ]
fbd6fe9ab34b8b89d9937e5ff727614304af48c1
https://github.com/cdumay/kser/blob/fbd6fe9ab34b8b89d9937e5ff727614304af48c1/src/kser/sequencing/operation.py#L56-L74
40,055
cdumay/kser
src/kser/sequencing/operation.py
Operation._prerun
def _prerun(self): """ To execute before running message """ self.check_required_params() self._set_status("RUNNING") logger.debug( "{}.PreRun: {}[{}]: running...".format( self.__class__.__name__, self.__class__.path, self.uuid ), ...
python
def _prerun(self): """ To execute before running message """ self.check_required_params() self._set_status("RUNNING") logger.debug( "{}.PreRun: {}[{}]: running...".format( self.__class__.__name__, self.__class__.path, self.uuid ), ...
[ "def", "_prerun", "(", "self", ")", ":", "self", ".", "check_required_params", "(", ")", "self", ".", "_set_status", "(", "\"RUNNING\"", ")", "logger", ".", "debug", "(", "\"{}.PreRun: {}[{}]: running...\"", ".", "format", "(", "self", ".", "__class__", ".", ...
To execute before running message
[ "To", "execute", "before", "running", "message" ]
fbd6fe9ab34b8b89d9937e5ff727614304af48c1
https://github.com/cdumay/kser/blob/fbd6fe9ab34b8b89d9937e5ff727614304af48c1/src/kser/sequencing/operation.py#L113-L129
40,056
cdumay/kser
src/kser/sequencing/operation.py
Operation.next
def next(self, task): """ Find the next task :param kser.sequencing.task.Task task: previous task :return: The next task :rtype: kser.sequencing.task.Task or None """ uuid = str(task.uuid) for idx, otask in enumerate(self.tasks[:-1]): if otask.uuid ==...
python
def next(self, task): """ Find the next task :param kser.sequencing.task.Task task: previous task :return: The next task :rtype: kser.sequencing.task.Task or None """ uuid = str(task.uuid) for idx, otask in enumerate(self.tasks[:-1]): if otask.uuid ==...
[ "def", "next", "(", "self", ",", "task", ")", ":", "uuid", "=", "str", "(", "task", ".", "uuid", ")", "for", "idx", ",", "otask", "in", "enumerate", "(", "self", ".", "tasks", "[", ":", "-", "1", "]", ")", ":", "if", "otask", ".", "uuid", "==...
Find the next task :param kser.sequencing.task.Task task: previous task :return: The next task :rtype: kser.sequencing.task.Task or None
[ "Find", "the", "next", "task" ]
fbd6fe9ab34b8b89d9937e5ff727614304af48c1
https://github.com/cdumay/kser/blob/fbd6fe9ab34b8b89d9937e5ff727614304af48c1/src/kser/sequencing/operation.py#L194-L207
40,057
cdumay/kser
src/kser/sequencing/operation.py
Operation.launch_next
def launch_next(self, task=None, result=None): """ Launch next task or finish operation :param kser.sequencing.task.Task task: previous task :param cdumay_result.Result result: previous task result :return: Execution result :rtype: cdumay_result.Result """ if ta...
python
def launch_next(self, task=None, result=None): """ Launch next task or finish operation :param kser.sequencing.task.Task task: previous task :param cdumay_result.Result result: previous task result :return: Execution result :rtype: cdumay_result.Result """ if ta...
[ "def", "launch_next", "(", "self", ",", "task", "=", "None", ",", "result", "=", "None", ")", ":", "if", "task", ":", "next_task", "=", "self", ".", "next", "(", "task", ")", "if", "next_task", ":", "return", "next_task", ".", "send", "(", "result", ...
Launch next task or finish operation :param kser.sequencing.task.Task task: previous task :param cdumay_result.Result result: previous task result :return: Execution result :rtype: cdumay_result.Result
[ "Launch", "next", "task", "or", "finish", "operation" ]
fbd6fe9ab34b8b89d9937e5ff727614304af48c1
https://github.com/cdumay/kser/blob/fbd6fe9ab34b8b89d9937e5ff727614304af48c1/src/kser/sequencing/operation.py#L209-L227
40,058
cdumay/kser
src/kser/sequencing/operation.py
Operation.compute_tasks
def compute_tasks(self, **kwargs): """ perfrom checks and build tasks :return: list of tasks :rtype: list(kser.sequencing.operation.Operation) """ params = self._prebuild(**kwargs) if not params: params = dict(kwargs) return self._build_tasks(**param...
python
def compute_tasks(self, **kwargs): """ perfrom checks and build tasks :return: list of tasks :rtype: list(kser.sequencing.operation.Operation) """ params = self._prebuild(**kwargs) if not params: params = dict(kwargs) return self._build_tasks(**param...
[ "def", "compute_tasks", "(", "self", ",", "*", "*", "kwargs", ")", ":", "params", "=", "self", ".", "_prebuild", "(", "*", "*", "kwargs", ")", "if", "not", "params", ":", "params", "=", "dict", "(", "kwargs", ")", "return", "self", ".", "_build_tasks...
perfrom checks and build tasks :return: list of tasks :rtype: list(kser.sequencing.operation.Operation)
[ "perfrom", "checks", "and", "build", "tasks" ]
fbd6fe9ab34b8b89d9937e5ff727614304af48c1
https://github.com/cdumay/kser/blob/fbd6fe9ab34b8b89d9937e5ff727614304af48c1/src/kser/sequencing/operation.py#L277-L287
40,059
cdumay/kser
src/kser/sequencing/operation.py
Operation.build
def build(self, **kwargs): """ create the operation and associate tasks :param dict kwargs: operation data :return: the controller :rtype: kser.sequencing.controller.OperationController """ self.tasks += self.compute_tasks(**kwargs) return self.finalize()
python
def build(self, **kwargs): """ create the operation and associate tasks :param dict kwargs: operation data :return: the controller :rtype: kser.sequencing.controller.OperationController """ self.tasks += self.compute_tasks(**kwargs) return self.finalize()
[ "def", "build", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "tasks", "+=", "self", ".", "compute_tasks", "(", "*", "*", "kwargs", ")", "return", "self", ".", "finalize", "(", ")" ]
create the operation and associate tasks :param dict kwargs: operation data :return: the controller :rtype: kser.sequencing.controller.OperationController
[ "create", "the", "operation", "and", "associate", "tasks" ]
fbd6fe9ab34b8b89d9937e5ff727614304af48c1
https://github.com/cdumay/kser/blob/fbd6fe9ab34b8b89d9937e5ff727614304af48c1/src/kser/sequencing/operation.py#L289-L297
40,060
jic-dtool/dtool-http
dtool_http/server.py
serve_dtool_directory
def serve_dtool_directory(directory, port): """Serve the datasets in a directory over HTTP.""" os.chdir(directory) server_address = ("localhost", port) httpd = DtoolHTTPServer(server_address, DtoolHTTPRequestHandler) httpd.serve_forever()
python
def serve_dtool_directory(directory, port): """Serve the datasets in a directory over HTTP.""" os.chdir(directory) server_address = ("localhost", port) httpd = DtoolHTTPServer(server_address, DtoolHTTPRequestHandler) httpd.serve_forever()
[ "def", "serve_dtool_directory", "(", "directory", ",", "port", ")", ":", "os", ".", "chdir", "(", "directory", ")", "server_address", "=", "(", "\"localhost\"", ",", "port", ")", "httpd", "=", "DtoolHTTPServer", "(", "server_address", ",", "DtoolHTTPRequestHandl...
Serve the datasets in a directory over HTTP.
[ "Serve", "the", "datasets", "in", "a", "directory", "over", "HTTP", "." ]
7572221b07d5294aa9ead5097a4f16478837e742
https://github.com/jic-dtool/dtool-http/blob/7572221b07d5294aa9ead5097a4f16478837e742/dtool_http/server.py#L90-L95
40,061
jic-dtool/dtool-http
dtool_http/server.py
cli
def cli(): """Command line utility for serving datasets in a directory over HTTP.""" parser = argparse.ArgumentParser(description=__doc__) parser.add_argument( "dataset_directory", help="Directory with datasets to be served" ) parser.add_argument( "-p", "--port", ...
python
def cli(): """Command line utility for serving datasets in a directory over HTTP.""" parser = argparse.ArgumentParser(description=__doc__) parser.add_argument( "dataset_directory", help="Directory with datasets to be served" ) parser.add_argument( "-p", "--port", ...
[ "def", "cli", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "__doc__", ")", "parser", ".", "add_argument", "(", "\"dataset_directory\"", ",", "help", "=", "\"Directory with datasets to be served\"", ")", "parser", ".", ...
Command line utility for serving datasets in a directory over HTTP.
[ "Command", "line", "utility", "for", "serving", "datasets", "in", "a", "directory", "over", "HTTP", "." ]
7572221b07d5294aa9ead5097a4f16478837e742
https://github.com/jic-dtool/dtool-http/blob/7572221b07d5294aa9ead5097a4f16478837e742/dtool_http/server.py#L98-L116
40,062
jic-dtool/dtool-http
dtool_http/server.py
DtoolHTTPRequestHandler.generate_url
def generate_url(self, suffix): """Return URL by combining server details with a path suffix.""" url_base_path = os.path.dirname(self.path) netloc = "{}:{}".format(*self.server.server_address) return urlunparse(( "http", netloc, url_base_path + "/" + s...
python
def generate_url(self, suffix): """Return URL by combining server details with a path suffix.""" url_base_path = os.path.dirname(self.path) netloc = "{}:{}".format(*self.server.server_address) return urlunparse(( "http", netloc, url_base_path + "/" + s...
[ "def", "generate_url", "(", "self", ",", "suffix", ")", ":", "url_base_path", "=", "os", ".", "path", ".", "dirname", "(", "self", ".", "path", ")", "netloc", "=", "\"{}:{}\"", ".", "format", "(", "*", "self", ".", "server", ".", "server_address", ")",...
Return URL by combining server details with a path suffix.
[ "Return", "URL", "by", "combining", "server", "details", "with", "a", "path", "suffix", "." ]
7572221b07d5294aa9ead5097a4f16478837e742
https://github.com/jic-dtool/dtool-http/blob/7572221b07d5294aa9ead5097a4f16478837e742/dtool_http/server.py#L16-L24
40,063
jic-dtool/dtool-http
dtool_http/server.py
DtoolHTTPRequestHandler.generate_http_manifest
def generate_http_manifest(self): """Return http manifest. The http manifest is the resource that defines a dataset as HTTP enabled (published). """ base_path = os.path.dirname(self.translate_path(self.path)) self.dataset = dtoolcore.DataSet.from_uri(base_path) ...
python
def generate_http_manifest(self): """Return http manifest. The http manifest is the resource that defines a dataset as HTTP enabled (published). """ base_path = os.path.dirname(self.translate_path(self.path)) self.dataset = dtoolcore.DataSet.from_uri(base_path) ...
[ "def", "generate_http_manifest", "(", "self", ")", ":", "base_path", "=", "os", ".", "path", ".", "dirname", "(", "self", ".", "translate_path", "(", "self", ".", "path", ")", ")", "self", ".", "dataset", "=", "dtoolcore", ".", "DataSet", ".", "from_uri"...
Return http manifest. The http manifest is the resource that defines a dataset as HTTP enabled (published).
[ "Return", "http", "manifest", "." ]
7572221b07d5294aa9ead5097a4f16478837e742
https://github.com/jic-dtool/dtool-http/blob/7572221b07d5294aa9ead5097a4f16478837e742/dtool_http/server.py#L43-L63
40,064
jic-dtool/dtool-http
dtool_http/server.py
DtoolHTTPRequestHandler.do_GET
def do_GET(self): """Override inherited do_GET method. Include logic for returning a http manifest when the URL ends with "http_manifest.json". """ if self.path.endswith("http_manifest.json"): try: manifest = self.generate_http_manifest() ...
python
def do_GET(self): """Override inherited do_GET method. Include logic for returning a http manifest when the URL ends with "http_manifest.json". """ if self.path.endswith("http_manifest.json"): try: manifest = self.generate_http_manifest() ...
[ "def", "do_GET", "(", "self", ")", ":", "if", "self", ".", "path", ".", "endswith", "(", "\"http_manifest.json\"", ")", ":", "try", ":", "manifest", "=", "self", ".", "generate_http_manifest", "(", ")", "self", ".", "send_response", "(", "200", ")", "sel...
Override inherited do_GET method. Include logic for returning a http manifest when the URL ends with "http_manifest.json".
[ "Override", "inherited", "do_GET", "method", "." ]
7572221b07d5294aa9ead5097a4f16478837e742
https://github.com/jic-dtool/dtool-http/blob/7572221b07d5294aa9ead5097a4f16478837e742/dtool_http/server.py#L65-L82
40,065
chaosim/dao
dao/compilebase.py
Compiler.indent
def indent(self, code, level=1): '''python's famous indent''' lines = code.split('\n') lines = tuple(self.indent_space*level + line for line in lines) return '\n'.join(lines)
python
def indent(self, code, level=1): '''python's famous indent''' lines = code.split('\n') lines = tuple(self.indent_space*level + line for line in lines) return '\n'.join(lines)
[ "def", "indent", "(", "self", ",", "code", ",", "level", "=", "1", ")", ":", "lines", "=", "code", ".", "split", "(", "'\\n'", ")", "lines", "=", "tuple", "(", "self", ".", "indent_space", "*", "level", "+", "line", "for", "line", "in", "lines", ...
python's famous indent
[ "python", "s", "famous", "indent" ]
d7ba65c98ee063aefd1ff4eabb192d1536fdbaaa
https://github.com/chaosim/dao/blob/d7ba65c98ee063aefd1ff4eabb192d1536fdbaaa/dao/compilebase.py#L100-L104
40,066
ymotongpoo/pyoauth2
pyoauth2/client.py
OAuth2AuthorizationFlow.retrieve_authorization_code
def retrieve_authorization_code(self, redirect_func=None): """ retrieve authorization code to get access token """ request_param = { "client_id": self.client_id, "redirect_uri": self.redirect_uri, } if self.scope: request_param['s...
python
def retrieve_authorization_code(self, redirect_func=None): """ retrieve authorization code to get access token """ request_param = { "client_id": self.client_id, "redirect_uri": self.redirect_uri, } if self.scope: request_param['s...
[ "def", "retrieve_authorization_code", "(", "self", ",", "redirect_func", "=", "None", ")", ":", "request_param", "=", "{", "\"client_id\"", ":", "self", ".", "client_id", ",", "\"redirect_uri\"", ":", "self", ".", "redirect_uri", ",", "}", "if", "self", ".", ...
retrieve authorization code to get access token
[ "retrieve", "authorization", "code", "to", "get", "access", "token" ]
7fddaf5fba190cfbc025961ce5948267d3d688ad
https://github.com/ymotongpoo/pyoauth2/blob/7fddaf5fba190cfbc025961ce5948267d3d688ad/pyoauth2/client.py#L121-L145
40,067
ymotongpoo/pyoauth2
pyoauth2/client.py
OAuth2AuthorizationFlow.retrieve_token
def retrieve_token(self): """ retrieve access token with code fetched via retrieve_authorization_code method. """ if self.authorization_code: request_param = { "client_id": self.client_id, "client_secret": self.client_secret, ...
python
def retrieve_token(self): """ retrieve access token with code fetched via retrieve_authorization_code method. """ if self.authorization_code: request_param = { "client_id": self.client_id, "client_secret": self.client_secret, ...
[ "def", "retrieve_token", "(", "self", ")", ":", "if", "self", ".", "authorization_code", ":", "request_param", "=", "{", "\"client_id\"", ":", "self", ".", "client_id", ",", "\"client_secret\"", ":", "self", ".", "client_secret", ",", "\"redirect_uri\"", ":", ...
retrieve access token with code fetched via retrieve_authorization_code method.
[ "retrieve", "access", "token", "with", "code", "fetched", "via", "retrieve_authorization_code", "method", "." ]
7fddaf5fba190cfbc025961ce5948267d3d688ad
https://github.com/ymotongpoo/pyoauth2/blob/7fddaf5fba190cfbc025961ce5948267d3d688ad/pyoauth2/client.py#L151-L181
40,068
TissueMAPS/TmDeploy
tmdeploy/config.py
_SetupSection.to_dict
def to_dict(self): '''Represents the setup section in form of key-value pairs. Returns ------- dict ''' mapping = dict() for attr in dir(self): if attr.startswith('_'): continue if not isinstance(getattr(self.__class__, att...
python
def to_dict(self): '''Represents the setup section in form of key-value pairs. Returns ------- dict ''' mapping = dict() for attr in dir(self): if attr.startswith('_'): continue if not isinstance(getattr(self.__class__, att...
[ "def", "to_dict", "(", "self", ")", ":", "mapping", "=", "dict", "(", ")", "for", "attr", "in", "dir", "(", "self", ")", ":", "if", "attr", ".", "startswith", "(", "'_'", ")", ":", "continue", "if", "not", "isinstance", "(", "getattr", "(", "self",...
Represents the setup section in form of key-value pairs. Returns ------- dict
[ "Represents", "the", "setup", "section", "in", "form", "of", "key", "-", "value", "pairs", "." ]
f891b4ffb21431988bc4a063ae871da3bf284a45
https://github.com/TissueMAPS/TmDeploy/blob/f891b4ffb21431988bc4a063ae871da3bf284a45/tmdeploy/config.py#L112-L138
40,069
hackedd/gw2api
gw2api/util.py
mtime
def mtime(path): """Get the modification time of a file, or -1 if the file does not exist. """ if not os.path.exists(path): return -1 stat = os.stat(path) return stat.st_mtime
python
def mtime(path): """Get the modification time of a file, or -1 if the file does not exist. """ if not os.path.exists(path): return -1 stat = os.stat(path) return stat.st_mtime
[ "def", "mtime", "(", "path", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "return", "-", "1", "stat", "=", "os", ".", "stat", "(", "path", ")", "return", "stat", ".", "st_mtime" ]
Get the modification time of a file, or -1 if the file does not exist.
[ "Get", "the", "modification", "time", "of", "a", "file", "or", "-", "1", "if", "the", "file", "does", "not", "exist", "." ]
5543a78e6e3ed0573b7e84c142c44004b4779eac
https://github.com/hackedd/gw2api/blob/5543a78e6e3ed0573b7e84c142c44004b4779eac/gw2api/util.py#L14-L20
40,070
hackedd/gw2api
gw2api/util.py
encode_coin_link
def encode_coin_link(copper, silver=0, gold=0): """Encode a chat link for an amount of coins. """ return encode_chat_link(gw2api.TYPE_COIN, copper=copper, silver=silver, gold=gold)
python
def encode_coin_link(copper, silver=0, gold=0): """Encode a chat link for an amount of coins. """ return encode_chat_link(gw2api.TYPE_COIN, copper=copper, silver=silver, gold=gold)
[ "def", "encode_coin_link", "(", "copper", ",", "silver", "=", "0", ",", "gold", "=", "0", ")", ":", "return", "encode_chat_link", "(", "gw2api", ".", "TYPE_COIN", ",", "copper", "=", "copper", ",", "silver", "=", "silver", ",", "gold", "=", "gold", ")"...
Encode a chat link for an amount of coins.
[ "Encode", "a", "chat", "link", "for", "an", "amount", "of", "coins", "." ]
5543a78e6e3ed0573b7e84c142c44004b4779eac
https://github.com/hackedd/gw2api/blob/5543a78e6e3ed0573b7e84c142c44004b4779eac/gw2api/util.py#L72-L76
40,071
tradenity/python-sdk
tradenity/resources/store_credit_payment.py
StoreCreditPayment.status
def status(self, status): """Sets the status of this StoreCreditPayment. :param status: The status of this StoreCreditPayment. :type: str """ allowed_values = ["pending", "awaitingRetry", "successful", "failed"] if status is not None and status not in allowed_values: ...
python
def status(self, status): """Sets the status of this StoreCreditPayment. :param status: The status of this StoreCreditPayment. :type: str """ allowed_values = ["pending", "awaitingRetry", "successful", "failed"] if status is not None and status not in allowed_values: ...
[ "def", "status", "(", "self", ",", "status", ")", ":", "allowed_values", "=", "[", "\"pending\"", ",", "\"awaitingRetry\"", ",", "\"successful\"", ",", "\"failed\"", "]", "if", "status", "is", "not", "None", "and", "status", "not", "in", "allowed_values", ":...
Sets the status of this StoreCreditPayment. :param status: The status of this StoreCreditPayment. :type: str
[ "Sets", "the", "status", "of", "this", "StoreCreditPayment", "." ]
d13fbe23f4d6ff22554c6d8d2deaf209371adaf1
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/store_credit_payment.py#L203-L217
40,072
inveniosoftware-attic/invenio-utils
invenio_utils/html.py
nmtoken_from_string
def nmtoken_from_string(text): """ Returns a Nmtoken from a string. It is useful to produce XHTML valid values for the 'name' attribute of an anchor. CAUTION: the function is surjective: 2 different texts might lead to the same result. This is improbable on a single page. Nmtoken is the ty...
python
def nmtoken_from_string(text): """ Returns a Nmtoken from a string. It is useful to produce XHTML valid values for the 'name' attribute of an anchor. CAUTION: the function is surjective: 2 different texts might lead to the same result. This is improbable on a single page. Nmtoken is the ty...
[ "def", "nmtoken_from_string", "(", "text", ")", ":", "text", "=", "text", ".", "replace", "(", "'-'", ",", "'--'", ")", "return", "''", ".", "join", "(", "[", "(", "(", "(", "not", "char", ".", "isalnum", "(", ")", "and", "char", "not", "in", "["...
Returns a Nmtoken from a string. It is useful to produce XHTML valid values for the 'name' attribute of an anchor. CAUTION: the function is surjective: 2 different texts might lead to the same result. This is improbable on a single page. Nmtoken is the type that is a mixture of characters supporte...
[ "Returns", "a", "Nmtoken", "from", "a", "string", ".", "It", "is", "useful", "to", "produce", "XHTML", "valid", "values", "for", "the", "name", "attribute", "of", "an", "anchor", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/html.py#L86-L108
40,073
inveniosoftware-attic/invenio-utils
invenio_utils/html.py
tidy_html
def tidy_html(html_buffer, cleaning_lib='utidylib'): """ Tidy up the input HTML using one of the installed cleaning libraries. @param html_buffer: the input HTML to clean up @type html_buffer: string @param cleaning_lib: chose the preferred library to clean the HTML. One of: ...
python
def tidy_html(html_buffer, cleaning_lib='utidylib'): """ Tidy up the input HTML using one of the installed cleaning libraries. @param html_buffer: the input HTML to clean up @type html_buffer: string @param cleaning_lib: chose the preferred library to clean the HTML. One of: ...
[ "def", "tidy_html", "(", "html_buffer", ",", "cleaning_lib", "=", "'utidylib'", ")", ":", "if", "CFG_TIDY_INSTALLED", "and", "cleaning_lib", "==", "'utidylib'", ":", "options", "=", "dict", "(", "output_xhtml", "=", "1", ",", "show_body_only", "=", "1", ",", ...
Tidy up the input HTML using one of the installed cleaning libraries. @param html_buffer: the input HTML to clean up @type html_buffer: string @param cleaning_lib: chose the preferred library to clean the HTML. One of: - utidylib - beautifulsoup @re...
[ "Tidy", "up", "the", "input", "HTML", "using", "one", "of", "the", "installed", "cleaning", "libraries", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/html.py#L413-L444
40,074
inveniosoftware-attic/invenio-utils
invenio_utils/html.py
remove_html_markup
def remove_html_markup(text, replacechar=' ', remove_escaped_chars_p=True): """ Remove HTML markup from text. @param text: Input text. @type text: string. @param replacechar: By which character should we replace HTML markup. Usually, a single space or an empty string are nice values. @t...
python
def remove_html_markup(text, replacechar=' ', remove_escaped_chars_p=True): """ Remove HTML markup from text. @param text: Input text. @type text: string. @param replacechar: By which character should we replace HTML markup. Usually, a single space or an empty string are nice values. @t...
[ "def", "remove_html_markup", "(", "text", ",", "replacechar", "=", "' '", ",", "remove_escaped_chars_p", "=", "True", ")", ":", "if", "not", "remove_escaped_chars_p", ":", "return", "RE_HTML_WITHOUT_ESCAPED_CHARS", ".", "sub", "(", "replacechar", ",", "text", ")",...
Remove HTML markup from text. @param text: Input text. @type text: string. @param replacechar: By which character should we replace HTML markup. Usually, a single space or an empty string are nice values. @type replacechar: string @param remove_escaped_chars_p: If True, also remove escaped ...
[ "Remove", "HTML", "markup", "from", "text", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/html.py#L661-L678
40,075
inveniosoftware-attic/invenio-utils
invenio_utils/html.py
create_html_select
def create_html_select( options, name=None, selected=None, disabled=None, multiple=False, attrs=None, **other_attrs): """ Create an HTML select box. >>> print create_html_select(["foo", "bar"], selected="bar", name="baz") <select name="baz...
python
def create_html_select( options, name=None, selected=None, disabled=None, multiple=False, attrs=None, **other_attrs): """ Create an HTML select box. >>> print create_html_select(["foo", "bar"], selected="bar", name="baz") <select name="baz...
[ "def", "create_html_select", "(", "options", ",", "name", "=", "None", ",", "selected", "=", "None", ",", "disabled", "=", "None", ",", "multiple", "=", "False", ",", "attrs", "=", "None", ",", "*", "*", "other_attrs", ")", ":", "body", "=", "[", "]"...
Create an HTML select box. >>> print create_html_select(["foo", "bar"], selected="bar", name="baz") <select name="baz"> <option selected="selected" value="bar"> bar </option> <option value="foo"> foo </option> </select> >>>...
[ "Create", "an", "HTML", "select", "box", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/html.py#L910-L1018
40,076
inveniosoftware-attic/invenio-utils
invenio_utils/html.py
HTMLWasher.wash
def wash( self, html_buffer, render_unallowed_tags=False, allowed_tag_whitelist=CFG_HTML_BUFFER_ALLOWED_TAG_WHITELIST, automatic_link_transformation=False, allowed_attribute_whitelist=CFG_HTML_BUFFER_ALLOWED_ATTRIBUTE_WHITELIST): """ ...
python
def wash( self, html_buffer, render_unallowed_tags=False, allowed_tag_whitelist=CFG_HTML_BUFFER_ALLOWED_TAG_WHITELIST, automatic_link_transformation=False, allowed_attribute_whitelist=CFG_HTML_BUFFER_ALLOWED_ATTRIBUTE_WHITELIST): """ ...
[ "def", "wash", "(", "self", ",", "html_buffer", ",", "render_unallowed_tags", "=", "False", ",", "allowed_tag_whitelist", "=", "CFG_HTML_BUFFER_ALLOWED_TAG_WHITELIST", ",", "automatic_link_transformation", "=", "False", ",", "allowed_attribute_whitelist", "=", "CFG_HTML_BUF...
Wash HTML buffer, escaping XSS attacks. @param html_buffer: text to escape @param render_unallowed_tags: if True, print unallowed tags escaping < and >. Else, only print content of unallowed tags. @param allowed_tag_whitelist: list of allowed tags @param allowed_attribute_wh...
[ "Wash", "HTML", "buffer", "escaping", "XSS", "attacks", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/html.py#L301-L329
40,077
Cecca/lydoc
lydoc/renderer.py
template_from_filename
def template_from_filename(filename): """Returns the appropriate template name based on the given file name.""" ext = filename.split(os.path.extsep)[-1] if not ext in TEMPLATES_MAP: raise ValueError("No template for file extension {}".format(ext)) return TEMPLATES_MAP[ext]
python
def template_from_filename(filename): """Returns the appropriate template name based on the given file name.""" ext = filename.split(os.path.extsep)[-1] if not ext in TEMPLATES_MAP: raise ValueError("No template for file extension {}".format(ext)) return TEMPLATES_MAP[ext]
[ "def", "template_from_filename", "(", "filename", ")", ":", "ext", "=", "filename", ".", "split", "(", "os", ".", "path", ".", "extsep", ")", "[", "-", "1", "]", "if", "not", "ext", "in", "TEMPLATES_MAP", ":", "raise", "ValueError", "(", "\"No template f...
Returns the appropriate template name based on the given file name.
[ "Returns", "the", "appropriate", "template", "name", "based", "on", "the", "given", "file", "name", "." ]
cd01dd5ed902b2574fb412c55bdc684276a88505
https://github.com/Cecca/lydoc/blob/cd01dd5ed902b2574fb412c55bdc684276a88505/lydoc/renderer.py#L41-L46
40,078
trevisanj/a99
a99/datetimefunc.py
dt2ts
def dt2ts(dt): """Converts to float representing number of seconds since 1970-01-01 GMT.""" # Note: no assertion to really keep this fast assert isinstance(dt, (datetime.datetime, datetime.date)) ret = time.mktime(dt.timetuple()) if isinstance(dt, datetime.datetime): ret += 1e-6 * dt.m...
python
def dt2ts(dt): """Converts to float representing number of seconds since 1970-01-01 GMT.""" # Note: no assertion to really keep this fast assert isinstance(dt, (datetime.datetime, datetime.date)) ret = time.mktime(dt.timetuple()) if isinstance(dt, datetime.datetime): ret += 1e-6 * dt.m...
[ "def", "dt2ts", "(", "dt", ")", ":", "# Note: no assertion to really keep this fast\r", "assert", "isinstance", "(", "dt", ",", "(", "datetime", ".", "datetime", ",", "datetime", ".", "date", ")", ")", "ret", "=", "time", ".", "mktime", "(", "dt", ".", "ti...
Converts to float representing number of seconds since 1970-01-01 GMT.
[ "Converts", "to", "float", "representing", "number", "of", "seconds", "since", "1970", "-", "01", "-", "01", "GMT", "." ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/datetimefunc.py#L24-L31
40,079
trevisanj/a99
a99/datetimefunc.py
dt2str
def dt2str(dt, flagSeconds=True): """Converts datetime object to str if not yet an str.""" if isinstance(dt, str): return dt return dt.strftime(_FMTS if flagSeconds else _FMT)
python
def dt2str(dt, flagSeconds=True): """Converts datetime object to str if not yet an str.""" if isinstance(dt, str): return dt return dt.strftime(_FMTS if flagSeconds else _FMT)
[ "def", "dt2str", "(", "dt", ",", "flagSeconds", "=", "True", ")", ":", "if", "isinstance", "(", "dt", ",", "str", ")", ":", "return", "dt", "return", "dt", ".", "strftime", "(", "_FMTS", "if", "flagSeconds", "else", "_FMT", ")" ]
Converts datetime object to str if not yet an str.
[ "Converts", "datetime", "object", "to", "str", "if", "not", "yet", "an", "str", "." ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/datetimefunc.py#L37-L41
40,080
trevisanj/a99
a99/datetimefunc.py
time2seconds
def time2seconds(t): """Returns seconds since 0h00.""" return t.hour * 3600 + t.minute * 60 + t.second + float(t.microsecond) / 1e6
python
def time2seconds(t): """Returns seconds since 0h00.""" return t.hour * 3600 + t.minute * 60 + t.second + float(t.microsecond) / 1e6
[ "def", "time2seconds", "(", "t", ")", ":", "return", "t", ".", "hour", "*", "3600", "+", "t", ".", "minute", "*", "60", "+", "t", ".", "second", "+", "float", "(", "t", ".", "microsecond", ")", "/", "1e6" ]
Returns seconds since 0h00.
[ "Returns", "seconds", "since", "0h00", "." ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/datetimefunc.py#L54-L56
40,081
nuSTORM/gnomon
gnomon/processors/Fitter.py
VlenfPolynomialFitter.Fit
def Fit(self, zxq): """Perform a 2D fit on 2D points then return parameters :param zxq: A list where each element is (z, transverse, charge) """ z, trans, Q = zip(*zxq) assert len(trans) == len(z) ndf = len(z) - 3 z = np.array(z) trans = np.array(trans) ...
python
def Fit(self, zxq): """Perform a 2D fit on 2D points then return parameters :param zxq: A list where each element is (z, transverse, charge) """ z, trans, Q = zip(*zxq) assert len(trans) == len(z) ndf = len(z) - 3 z = np.array(z) trans = np.array(trans) ...
[ "def", "Fit", "(", "self", ",", "zxq", ")", ":", "z", ",", "trans", ",", "Q", "=", "zip", "(", "*", "zxq", ")", "assert", "len", "(", "trans", ")", "==", "len", "(", "z", ")", "ndf", "=", "len", "(", "z", ")", "-", "3", "z", "=", "np", ...
Perform a 2D fit on 2D points then return parameters :param zxq: A list where each element is (z, transverse, charge)
[ "Perform", "a", "2D", "fit", "on", "2D", "points", "then", "return", "parameters" ]
7616486ecd6e26b76f677c380e62db1c0ade558a
https://github.com/nuSTORM/gnomon/blob/7616486ecd6e26b76f677c380e62db1c0ade558a/gnomon/processors/Fitter.py#L317-L353
40,082
nuSTORM/gnomon
gnomon/processors/Fitter.py
VlenfPolynomialFitter._get_last_transverse_over_list
def _get_last_transverse_over_list(self, zxq): """ Get transverse coord at highest z :param zx: A list where each element is (z, transverse, charge) """ z_max = None x_of_interest = None for z, x, q in zxq: if z == None or z > z_max: x_of_int...
python
def _get_last_transverse_over_list(self, zxq): """ Get transverse coord at highest z :param zx: A list where each element is (z, transverse, charge) """ z_max = None x_of_interest = None for z, x, q in zxq: if z == None or z > z_max: x_of_int...
[ "def", "_get_last_transverse_over_list", "(", "self", ",", "zxq", ")", ":", "z_max", "=", "None", "x_of_interest", "=", "None", "for", "z", ",", "x", ",", "q", "in", "zxq", ":", "if", "z", "==", "None", "or", "z", ">", "z_max", ":", "x_of_interest", ...
Get transverse coord at highest z :param zx: A list where each element is (z, transverse, charge)
[ "Get", "transverse", "coord", "at", "highest", "z" ]
7616486ecd6e26b76f677c380e62db1c0ade558a
https://github.com/nuSTORM/gnomon/blob/7616486ecd6e26b76f677c380e62db1c0ade558a/gnomon/processors/Fitter.py#L363-L375
40,083
hackedd/gw2api
gw2api/items.py
item_details
def item_details(item_id, lang="en"): """This resource returns a details about a single item. :param item_id: The item to query for. :param lang: The language to display the texts in. The response is an object with at least the following properties. Note that the availability of some properties de...
python
def item_details(item_id, lang="en"): """This resource returns a details about a single item. :param item_id: The item to query for. :param lang: The language to display the texts in. The response is an object with at least the following properties. Note that the availability of some properties de...
[ "def", "item_details", "(", "item_id", ",", "lang", "=", "\"en\"", ")", ":", "params", "=", "{", "\"item_id\"", ":", "item_id", ",", "\"lang\"", ":", "lang", "}", "cache_name", "=", "\"item_details.%(item_id)s.%(lang)s.json\"", "%", "params", "return", "get_cach...
This resource returns a details about a single item. :param item_id: The item to query for. :param lang: The language to display the texts in. The response is an object with at least the following properties. Note that the availability of some properties depends on the type of the item. item_id (...
[ "This", "resource", "returns", "a", "details", "about", "a", "single", "item", "." ]
5543a78e6e3ed0573b7e84c142c44004b4779eac
https://github.com/hackedd/gw2api/blob/5543a78e6e3ed0573b7e84c142c44004b4779eac/gw2api/items.py#L24-L85
40,084
hackedd/gw2api
gw2api/items.py
recipe_details
def recipe_details(recipe_id, lang="en"): """This resource returns a details about a single recipe. :param recipe_id: The recipe to query for. :param lang: The language to display the texts in. The response is an object with the following properties: recipe_id (number): The recipe id. ...
python
def recipe_details(recipe_id, lang="en"): """This resource returns a details about a single recipe. :param recipe_id: The recipe to query for. :param lang: The language to display the texts in. The response is an object with the following properties: recipe_id (number): The recipe id. ...
[ "def", "recipe_details", "(", "recipe_id", ",", "lang", "=", "\"en\"", ")", ":", "params", "=", "{", "\"recipe_id\"", ":", "recipe_id", ",", "\"lang\"", ":", "lang", "}", "cache_name", "=", "\"recipe_details.%(recipe_id)s.%(lang)s.json\"", "%", "params", "return",...
This resource returns a details about a single recipe. :param recipe_id: The recipe to query for. :param lang: The language to display the texts in. The response is an object with the following properties: recipe_id (number): The recipe id. type (string): The type of the produced...
[ "This", "resource", "returns", "a", "details", "about", "a", "single", "recipe", "." ]
5543a78e6e3ed0573b7e84c142c44004b4779eac
https://github.com/hackedd/gw2api/blob/5543a78e6e3ed0573b7e84c142c44004b4779eac/gw2api/items.py#L88-L139
40,085
martymcguire/Flask-IndieAuth
flask_indieauth.py
requires_indieauth
def requires_indieauth(f): """Wraps a Flask handler to require a valid IndieAuth access token. """ @wraps(f) def decorated(*args, **kwargs): access_token = get_access_token() resp = check_auth(access_token) if isinstance(resp, Response): return resp return f(*ar...
python
def requires_indieauth(f): """Wraps a Flask handler to require a valid IndieAuth access token. """ @wraps(f) def decorated(*args, **kwargs): access_token = get_access_token() resp = check_auth(access_token) if isinstance(resp, Response): return resp return f(*ar...
[ "def", "requires_indieauth", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "decorated", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "access_token", "=", "get_access_token", "(", ")", "resp", "=", "check_auth", "(", "access_token", ")...
Wraps a Flask handler to require a valid IndieAuth access token.
[ "Wraps", "a", "Flask", "handler", "to", "require", "a", "valid", "IndieAuth", "access", "token", "." ]
6b5a816dabaa243d1833ff23a9d21d91d35e7461
https://github.com/martymcguire/Flask-IndieAuth/blob/6b5a816dabaa243d1833ff23a9d21d91d35e7461/flask_indieauth.py#L58-L68
40,086
martymcguire/Flask-IndieAuth
flask_indieauth.py
check_auth
def check_auth(access_token): """This function contacts the configured IndieAuth Token Endpoint to see if the given token is a valid token and for whom. """ if not access_token: current_app.logger.error('No access token.') return deny('No access token found.') request = Request( cu...
python
def check_auth(access_token): """This function contacts the configured IndieAuth Token Endpoint to see if the given token is a valid token and for whom. """ if not access_token: current_app.logger.error('No access token.') return deny('No access token found.') request = Request( cu...
[ "def", "check_auth", "(", "access_token", ")", ":", "if", "not", "access_token", ":", "current_app", ".", "logger", ".", "error", "(", "'No access token.'", ")", "return", "deny", "(", "'No access token found.'", ")", "request", "=", "Request", "(", "current_app...
This function contacts the configured IndieAuth Token Endpoint to see if the given token is a valid token and for whom.
[ "This", "function", "contacts", "the", "configured", "IndieAuth", "Token", "Endpoint", "to", "see", "if", "the", "given", "token", "is", "a", "valid", "token", "and", "for", "whom", "." ]
6b5a816dabaa243d1833ff23a9d21d91d35e7461
https://github.com/martymcguire/Flask-IndieAuth/blob/6b5a816dabaa243d1833ff23a9d21d91d35e7461/flask_indieauth.py#L70-L110
40,087
Julian/Minion
examples/flaskr.py
connect_db
def connect_db(config): """Connects to the specific database.""" rv = sqlite3.connect(config["database"]["uri"]) rv.row_factory = sqlite3.Row return rv
python
def connect_db(config): """Connects to the specific database.""" rv = sqlite3.connect(config["database"]["uri"]) rv.row_factory = sqlite3.Row return rv
[ "def", "connect_db", "(", "config", ")", ":", "rv", "=", "sqlite3", ".", "connect", "(", "config", "[", "\"database\"", "]", "[", "\"uri\"", "]", ")", "rv", ".", "row_factory", "=", "sqlite3", ".", "Row", "return", "rv" ]
Connects to the specific database.
[ "Connects", "to", "the", "specific", "database", "." ]
518d06f9ffd38dcacc0de4d94e72d1f8452157a8
https://github.com/Julian/Minion/blob/518d06f9ffd38dcacc0de4d94e72d1f8452157a8/examples/flaskr.py#L92-L96
40,088
inveniosoftware-attic/invenio-utils
invenio_utils/vcs/git.py
harvest_repo
def harvest_repo(root_url, archive_path, tag=None, archive_format='tar.gz'): """ Archives a specific tag in a specific Git repository. :param root_url: The URL to the Git repo - Supported protocols: git, ssh, http[s]. :param archive_path: A temporary path to clone the repo to - Must end in .git...
python
def harvest_repo(root_url, archive_path, tag=None, archive_format='tar.gz'): """ Archives a specific tag in a specific Git repository. :param root_url: The URL to the Git repo - Supported protocols: git, ssh, http[s]. :param archive_path: A temporary path to clone the repo to - Must end in .git...
[ "def", "harvest_repo", "(", "root_url", ",", "archive_path", ",", "tag", "=", "None", ",", "archive_format", "=", "'tar.gz'", ")", ":", "if", "not", "git_exists", "(", ")", ":", "raise", "Exception", "(", "\"Git not found. It probably needs installing.\"", ")", ...
Archives a specific tag in a specific Git repository. :param root_url: The URL to the Git repo - Supported protocols: git, ssh, http[s]. :param archive_path: A temporary path to clone the repo to - Must end in .git :param tag: The path to which the .tar.gz will go to - Must end in the same as f...
[ "Archives", "a", "specific", "tag", "in", "a", "specific", "Git", "repository", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/vcs/git.py#L49-L85
40,089
hayalasalah/adhan.py
adhan/calculations.py
gregorian_to_julian
def gregorian_to_julian(day): """Convert a datetime.date object to its corresponding Julian day. :param day: The datetime.date to convert to a Julian day :returns: A Julian day, as an integer """ before_march = 1 if day.month < MARCH else 0 # # Number of months since March # month_...
python
def gregorian_to_julian(day): """Convert a datetime.date object to its corresponding Julian day. :param day: The datetime.date to convert to a Julian day :returns: A Julian day, as an integer """ before_march = 1 if day.month < MARCH else 0 # # Number of months since March # month_...
[ "def", "gregorian_to_julian", "(", "day", ")", ":", "before_march", "=", "1", "if", "day", ".", "month", "<", "MARCH", "else", "0", "#", "# Number of months since March", "#", "month_index", "=", "day", ".", "month", "+", "MONTHS_PER_YEAR", "*", "before_march"...
Convert a datetime.date object to its corresponding Julian day. :param day: The datetime.date to convert to a Julian day :returns: A Julian day, as an integer
[ "Convert", "a", "datetime", ".", "date", "object", "to", "its", "corresponding", "Julian", "day", "." ]
a7c080ba48f70be9801f048451d2c91a7d579602
https://github.com/hayalasalah/adhan.py/blob/a7c080ba48f70be9801f048451d2c91a7d579602/adhan/calculations.py#L46-L78
40,090
hayalasalah/adhan.py
adhan/calculations.py
sun_declination
def sun_declination(day): """Compute the declination angle of the sun for the given date. Uses the Spencer Formula (found at http://www.illustratingshadows.com/www-formulae-collection.pdf) :param day: The datetime.date to compute the declination angle for :returns: The angle, in degrees, of the an...
python
def sun_declination(day): """Compute the declination angle of the sun for the given date. Uses the Spencer Formula (found at http://www.illustratingshadows.com/www-formulae-collection.pdf) :param day: The datetime.date to compute the declination angle for :returns: The angle, in degrees, of the an...
[ "def", "sun_declination", "(", "day", ")", ":", "day_of_year", "=", "day", ".", "toordinal", "(", ")", "-", "date", "(", "day", ".", "year", ",", "1", ",", "1", ")", ".", "toordinal", "(", ")", "day_angle", "=", "2", "*", "pi", "*", "day_of_year", ...
Compute the declination angle of the sun for the given date. Uses the Spencer Formula (found at http://www.illustratingshadows.com/www-formulae-collection.pdf) :param day: The datetime.date to compute the declination angle for :returns: The angle, in degrees, of the angle of declination
[ "Compute", "the", "declination", "angle", "of", "the", "sun", "for", "the", "given", "date", "." ]
a7c080ba48f70be9801f048451d2c91a7d579602
https://github.com/hayalasalah/adhan.py/blob/a7c080ba48f70be9801f048451d2c91a7d579602/adhan/calculations.py#L81-L102
40,091
hayalasalah/adhan.py
adhan/calculations.py
equation_of_time
def equation_of_time(day): """Compute the equation of time for the given date. Uses formula described at https://en.wikipedia.org/wiki/Equation_of_time#Alternative_calculation :param day: The datetime.date to compute the equation of time for :returns: The angle, in radians, of the Equation of Time...
python
def equation_of_time(day): """Compute the equation of time for the given date. Uses formula described at https://en.wikipedia.org/wiki/Equation_of_time#Alternative_calculation :param day: The datetime.date to compute the equation of time for :returns: The angle, in radians, of the Equation of Time...
[ "def", "equation_of_time", "(", "day", ")", ":", "day_of_year", "=", "day", ".", "toordinal", "(", ")", "-", "date", "(", "day", ".", "year", ",", "1", ",", "1", ")", ".", "toordinal", "(", ")", "# pylint: disable=invalid-name", "#", "# Distance Earth move...
Compute the equation of time for the given date. Uses formula described at https://en.wikipedia.org/wiki/Equation_of_time#Alternative_calculation :param day: The datetime.date to compute the equation of time for :returns: The angle, in radians, of the Equation of Time
[ "Compute", "the", "equation", "of", "time", "for", "the", "given", "date", "." ]
a7c080ba48f70be9801f048451d2c91a7d579602
https://github.com/hayalasalah/adhan.py/blob/a7c080ba48f70be9801f048451d2c91a7d579602/adhan/calculations.py#L105-L145
40,092
hayalasalah/adhan.py
adhan/calculations.py
compute_zuhr_utc
def compute_zuhr_utc(day, longitude): """Compute the UTC floating point time for Zuhr given date and longitude. This function is necessary since all other prayer times are based on the time for Zuhr :param day: The day to compute Zuhr adhan for :param longitude: Longitude of the place of interest ...
python
def compute_zuhr_utc(day, longitude): """Compute the UTC floating point time for Zuhr given date and longitude. This function is necessary since all other prayer times are based on the time for Zuhr :param day: The day to compute Zuhr adhan for :param longitude: Longitude of the place of interest ...
[ "def", "compute_zuhr_utc", "(", "day", ",", "longitude", ")", ":", "eot", "=", "equation_of_time", "(", "day", ")", "#", "# Formula as described by PrayTime.org doesn't work in Eastern hemisphere", "# because it expects to be subtracting a negative longitude. +abs() should", "# do ...
Compute the UTC floating point time for Zuhr given date and longitude. This function is necessary since all other prayer times are based on the time for Zuhr :param day: The day to compute Zuhr adhan for :param longitude: Longitude of the place of interest :returns: The UTC time for Zuhr, as a flo...
[ "Compute", "the", "UTC", "floating", "point", "time", "for", "Zuhr", "given", "date", "and", "longitude", "." ]
a7c080ba48f70be9801f048451d2c91a7d579602
https://github.com/hayalasalah/adhan.py/blob/a7c080ba48f70be9801f048451d2c91a7d579602/adhan/calculations.py#L148-L167
40,093
hayalasalah/adhan.py
adhan/calculations.py
compute_time_at_sun_angle
def compute_time_at_sun_angle(day, latitude, angle): """Compute the floating point time difference between mid-day and an angle. All the prayers are defined as certain angles from mid-day (Zuhr). This formula is taken from praytimes.org/calculation :param day: The day to which to compute for :para...
python
def compute_time_at_sun_angle(day, latitude, angle): """Compute the floating point time difference between mid-day and an angle. All the prayers are defined as certain angles from mid-day (Zuhr). This formula is taken from praytimes.org/calculation :param day: The day to which to compute for :para...
[ "def", "compute_time_at_sun_angle", "(", "day", ",", "latitude", ",", "angle", ")", ":", "positive_angle_rad", "=", "radians", "(", "abs", "(", "angle", ")", ")", "angle_sign", "=", "abs", "(", "angle", ")", "/", "angle", "latitude_rad", "=", "radians", "(...
Compute the floating point time difference between mid-day and an angle. All the prayers are defined as certain angles from mid-day (Zuhr). This formula is taken from praytimes.org/calculation :param day: The day to which to compute for :param longitude: Longitude of the place of interest :angle: ...
[ "Compute", "the", "floating", "point", "time", "difference", "between", "mid", "-", "day", "and", "an", "angle", "." ]
a7c080ba48f70be9801f048451d2c91a7d579602
https://github.com/hayalasalah/adhan.py/blob/a7c080ba48f70be9801f048451d2c91a7d579602/adhan/calculations.py#L170-L195
40,094
hayalasalah/adhan.py
adhan/calculations.py
time_at_shadow_length
def time_at_shadow_length(day, latitude, multiplier): """Compute the time at which an object's shadow is a multiple of its length. Specifically, determine the time the length of the shadow is a multiple of the object's length + the length of the object's shadow at noon This is used in the calculation ...
python
def time_at_shadow_length(day, latitude, multiplier): """Compute the time at which an object's shadow is a multiple of its length. Specifically, determine the time the length of the shadow is a multiple of the object's length + the length of the object's shadow at noon This is used in the calculation ...
[ "def", "time_at_shadow_length", "(", "day", ",", "latitude", ",", "multiplier", ")", ":", "latitude_rad", "=", "radians", "(", "latitude", ")", "declination", "=", "radians", "(", "sun_declination", "(", "day", ")", ")", "angle", "=", "arccot", "(", "multipl...
Compute the time at which an object's shadow is a multiple of its length. Specifically, determine the time the length of the shadow is a multiple of the object's length + the length of the object's shadow at noon This is used in the calculation for Asr time. Hanafi uses a multiplier of 2, and everyone...
[ "Compute", "the", "time", "at", "which", "an", "object", "s", "shadow", "is", "a", "multiple", "of", "its", "length", "." ]
a7c080ba48f70be9801f048451d2c91a7d579602
https://github.com/hayalasalah/adhan.py/blob/a7c080ba48f70be9801f048451d2c91a7d579602/adhan/calculations.py#L198-L226
40,095
koenedaele/pyramid_skosprovider
pyramid_skosprovider/utils.py
parse_range_header
def parse_range_header(range): ''' Parse a range header as used by the dojo Json Rest store. :param str range: The content of the range header to be parsed. eg. `items=0-9` :returns: A dict with keys start, finish and number or `False` if the range is invalid. ''' match = re.mat...
python
def parse_range_header(range): ''' Parse a range header as used by the dojo Json Rest store. :param str range: The content of the range header to be parsed. eg. `items=0-9` :returns: A dict with keys start, finish and number or `False` if the range is invalid. ''' match = re.mat...
[ "def", "parse_range_header", "(", "range", ")", ":", "match", "=", "re", ".", "match", "(", "'^items=([0-9]+)-([0-9]+)$'", ",", "range", ")", "if", "match", ":", "start", "=", "int", "(", "match", ".", "group", "(", "1", ")", ")", "finish", "=", "int",...
Parse a range header as used by the dojo Json Rest store. :param str range: The content of the range header to be parsed. eg. `items=0-9` :returns: A dict with keys start, finish and number or `False` if the range is invalid.
[ "Parse", "a", "range", "header", "as", "used", "by", "the", "dojo", "Json", "Rest", "store", "." ]
3affdb53cac7ad01bf3656ecd4c4d7ad9b4948b6
https://github.com/koenedaele/pyramid_skosprovider/blob/3affdb53cac7ad01bf3656ecd4c4d7ad9b4948b6/pyramid_skosprovider/utils.py#L65-L86
40,096
numberoverzero/accordian
accordian.py
Dispatch.on
def on(self, event): """ Returns a wrapper for the given event. Usage: @dispatch.on("my_event") def handle_my_event(foo, bar, baz): ... """ handler = self._handlers.get(event, None) if not handler: raise ValueError("U...
python
def on(self, event): """ Returns a wrapper for the given event. Usage: @dispatch.on("my_event") def handle_my_event(foo, bar, baz): ... """ handler = self._handlers.get(event, None) if not handler: raise ValueError("U...
[ "def", "on", "(", "self", ",", "event", ")", ":", "handler", "=", "self", ".", "_handlers", ".", "get", "(", "event", ",", "None", ")", "if", "not", "handler", ":", "raise", "ValueError", "(", "\"Unknown event '{}'\"", ".", "format", "(", "event", ")",...
Returns a wrapper for the given event. Usage: @dispatch.on("my_event") def handle_my_event(foo, bar, baz): ...
[ "Returns", "a", "wrapper", "for", "the", "given", "event", "." ]
f1fe44dc9c646006418017bbf70f597b180c8b97
https://github.com/numberoverzero/accordian/blob/f1fe44dc9c646006418017bbf70f597b180c8b97/accordian.py#L85-L99
40,097
numberoverzero/accordian
accordian.py
Dispatch.register
def register(self, event, keys): """ Register a new event with available keys. Raises ValueError when the event has already been registered. Usage: dispatch.register("my_event", ["foo", "bar", "baz"]) """ if self.running: raise RuntimeError("Can...
python
def register(self, event, keys): """ Register a new event with available keys. Raises ValueError when the event has already been registered. Usage: dispatch.register("my_event", ["foo", "bar", "baz"]) """ if self.running: raise RuntimeError("Can...
[ "def", "register", "(", "self", ",", "event", ",", "keys", ")", ":", "if", "self", ".", "running", ":", "raise", "RuntimeError", "(", "\"Can't register while running\"", ")", "handler", "=", "self", ".", "_handlers", ".", "get", "(", "event", ",", "None", ...
Register a new event with available keys. Raises ValueError when the event has already been registered. Usage: dispatch.register("my_event", ["foo", "bar", "baz"])
[ "Register", "a", "new", "event", "with", "available", "keys", ".", "Raises", "ValueError", "when", "the", "event", "has", "already", "been", "registered", "." ]
f1fe44dc9c646006418017bbf70f597b180c8b97
https://github.com/numberoverzero/accordian/blob/f1fe44dc9c646006418017bbf70f597b180c8b97/accordian.py#L101-L116
40,098
numberoverzero/accordian
accordian.py
Dispatch.unregister
def unregister(self, event): """ Remove all registered handlers for an event. Silent return when event was not registered. Usage: dispatch.unregister("my_event") dispatch.unregister("my_event") # no-op """ if self.running: raise Run...
python
def unregister(self, event): """ Remove all registered handlers for an event. Silent return when event was not registered. Usage: dispatch.unregister("my_event") dispatch.unregister("my_event") # no-op """ if self.running: raise Run...
[ "def", "unregister", "(", "self", ",", "event", ")", ":", "if", "self", ".", "running", ":", "raise", "RuntimeError", "(", "\"Can't unregister while running\"", ")", "self", ".", "_handlers", ".", "pop", "(", "event", ",", "None", ")" ]
Remove all registered handlers for an event. Silent return when event was not registered. Usage: dispatch.unregister("my_event") dispatch.unregister("my_event") # no-op
[ "Remove", "all", "registered", "handlers", "for", "an", "event", ".", "Silent", "return", "when", "event", "was", "not", "registered", "." ]
f1fe44dc9c646006418017bbf70f597b180c8b97
https://github.com/numberoverzero/accordian/blob/f1fe44dc9c646006418017bbf70f597b180c8b97/accordian.py#L118-L131
40,099
numberoverzero/accordian
accordian.py
Dispatch.trigger
async def trigger(self, event, kwargs): """ Enqueue an event for processing """ await self._queue.put((event, kwargs)) self._resume_processing.set()
python
async def trigger(self, event, kwargs): """ Enqueue an event for processing """ await self._queue.put((event, kwargs)) self._resume_processing.set()
[ "async", "def", "trigger", "(", "self", ",", "event", ",", "kwargs", ")", ":", "await", "self", ".", "_queue", ".", "put", "(", "(", "event", ",", "kwargs", ")", ")", "self", ".", "_resume_processing", ".", "set", "(", ")" ]
Enqueue an event for processing
[ "Enqueue", "an", "event", "for", "processing" ]
f1fe44dc9c646006418017bbf70f597b180c8b97
https://github.com/numberoverzero/accordian/blob/f1fe44dc9c646006418017bbf70f597b180c8b97/accordian.py#L133-L136