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
54,500
mushkevych/scheduler
workers/abstract_mongo_worker.py
AbstractMongoWorker._run_custom_data_engine
def _run_custom_data_engine(self, start_id_obj, end_id_obj, start_timeperiod, end_timeperiod): """ fine-tuned data engine. MongoDB legacy """ collection_name = context.process_context[self.process_name].source iteration = 0 while True: cursor = self.ds.cursor_fine(collection_...
python
def _run_custom_data_engine(self, start_id_obj, end_id_obj, start_timeperiod, end_timeperiod): """ fine-tuned data engine. MongoDB legacy """ collection_name = context.process_context[self.process_name].source iteration = 0 while True: cursor = self.ds.cursor_fine(collection_...
[ "def", "_run_custom_data_engine", "(", "self", ",", "start_id_obj", ",", "end_id_obj", ",", "start_timeperiod", ",", "end_timeperiod", ")", ":", "collection_name", "=", "context", ".", "process_context", "[", "self", ".", "process_name", "]", ".", "source", "itera...
fine-tuned data engine. MongoDB legacy
[ "fine", "-", "tuned", "data", "engine", ".", "MongoDB", "legacy" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/workers/abstract_mongo_worker.py#L81-L109
54,501
mushkevych/scheduler
workers/abstract_mongo_worker.py
AbstractMongoWorker._run_data_engine
def _run_data_engine(self, start_timeperiod, end_timeperiod): """ regular data engine """ collection_name = context.process_context[self.process_name].source cursor = self.ds.cursor_batch(collection_name, start_timeperiod, ...
python
def _run_data_engine(self, start_timeperiod, end_timeperiod): """ regular data engine """ collection_name = context.process_context[self.process_name].source cursor = self.ds.cursor_batch(collection_name, start_timeperiod, ...
[ "def", "_run_data_engine", "(", "self", ",", "start_timeperiod", ",", "end_timeperiod", ")", ":", "collection_name", "=", "context", ".", "process_context", "[", "self", ".", "process_name", "]", ".", "source", "cursor", "=", "self", ".", "ds", ".", "cursor_ba...
regular data engine
[ "regular", "data", "engine" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/workers/abstract_mongo_worker.py#L111-L123
54,502
epio/mantrid
mantrid/actions.py
Spin.handle
def handle(self, sock, read_data, path, headers): "Just waits, and checks for other actions to replace us" for i in range(self.timeout // self.check_interval): # Sleep first eventlet.sleep(self.check_interval) # Check for another action action = self.balan...
python
def handle(self, sock, read_data, path, headers): "Just waits, and checks for other actions to replace us" for i in range(self.timeout // self.check_interval): # Sleep first eventlet.sleep(self.check_interval) # Check for another action action = self.balan...
[ "def", "handle", "(", "self", ",", "sock", ",", "read_data", ",", "path", ",", "headers", ")", ":", "for", "i", "in", "range", "(", "self", ".", "timeout", "//", "self", ".", "check_interval", ")", ":", "# Sleep first", "eventlet", ".", "sleep", "(", ...
Just waits, and checks for other actions to replace us
[ "Just", "waits", "and", "checks", "for", "other", "actions", "to", "replace", "us" ]
1c699f1a4b33888b533c19cb6d025173f2160576
https://github.com/epio/mantrid/blob/1c699f1a4b33888b533c19cb6d025173f2160576/mantrid/actions.py#L178-L189
54,503
helium/helium-python
helium/util.py
build_request_body
def build_request_body(type, id, attributes=None, relationships=None): """Build a request body object. A body JSON object is used for any of the ``update`` or ``create`` methods on :class:`Resource` subclasses. In normal library use you should not have to use this function directly. Args: ...
python
def build_request_body(type, id, attributes=None, relationships=None): """Build a request body object. A body JSON object is used for any of the ``update`` or ``create`` methods on :class:`Resource` subclasses. In normal library use you should not have to use this function directly. Args: ...
[ "def", "build_request_body", "(", "type", ",", "id", ",", "attributes", "=", "None", ",", "relationships", "=", "None", ")", ":", "result", "=", "{", "\"data\"", ":", "{", "\"type\"", ":", "type", "}", "}", "data", "=", "result", "[", "'data'", "]", ...
Build a request body object. A body JSON object is used for any of the ``update`` or ``create`` methods on :class:`Resource` subclasses. In normal library use you should not have to use this function directly. Args: type(string): The resource type for the attribute id(uuid): The id o...
[ "Build", "a", "request", "body", "object", "." ]
db73480b143da4fc48e95c4414bd69c576a3a390
https://github.com/helium/helium-python/blob/db73480b143da4fc48e95c4414bd69c576a3a390/helium/util.py#L45-L80
54,504
helium/helium-python
helium/util.py
build_request_relationship
def build_request_relationship(type, ids): """Build a relationship list. A relationship list is used to update relationships between two resources. Setting sensors on a label, for example, uses this function to construct the list of sensor ids to pass to the Helium API. Args: type(str...
python
def build_request_relationship(type, ids): """Build a relationship list. A relationship list is used to update relationships between two resources. Setting sensors on a label, for example, uses this function to construct the list of sensor ids to pass to the Helium API. Args: type(str...
[ "def", "build_request_relationship", "(", "type", ",", "ids", ")", ":", "if", "ids", "is", "None", ":", "return", "{", "'data'", ":", "None", "}", "elif", "isinstance", "(", "ids", ",", "str", ")", ":", "return", "{", "'data'", ":", "{", "'id'", ":",...
Build a relationship list. A relationship list is used to update relationships between two resources. Setting sensors on a label, for example, uses this function to construct the list of sensor ids to pass to the Helium API. Args: type(string): The resource type for the ids in the relatio...
[ "Build", "a", "relationship", "list", "." ]
db73480b143da4fc48e95c4414bd69c576a3a390
https://github.com/helium/helium-python/blob/db73480b143da4fc48e95c4414bd69c576a3a390/helium/util.py#L83-L113
54,505
helium/helium-python
helium/util.py
build_request_include
def build_request_include(include, params): """Augment request parameters with includes. When one or all resources are requested an additional set of resources can be requested as part of the request. This function extends the given parameters for a request with a list of resource types passed in a...
python
def build_request_include(include, params): """Augment request parameters with includes. When one or all resources are requested an additional set of resources can be requested as part of the request. This function extends the given parameters for a request with a list of resource types passed in a...
[ "def", "build_request_include", "(", "include", ",", "params", ")", ":", "params", "=", "params", "or", "OrderedDict", "(", ")", "if", "include", "is", "not", "None", ":", "params", "[", "'include'", "]", "=", "','", ".", "join", "(", "[", "cls", ".", ...
Augment request parameters with includes. When one or all resources are requested an additional set of resources can be requested as part of the request. This function extends the given parameters for a request with a list of resource types passed in as a list of :class:`Resource` subclasses. Args...
[ "Augment", "request", "parameters", "with", "includes", "." ]
db73480b143da4fc48e95c4414bd69c576a3a390
https://github.com/helium/helium-python/blob/db73480b143da4fc48e95c4414bd69c576a3a390/helium/util.py#L116-L139
54,506
helium/helium-python
helium/resource.py
Resource.find
def find(cls, session, resource_id, include=None): """Retrieve a single resource. This should only be called from sub-classes. Args: session(Session): The session to find the resource in resource_id: The ``id`` for the resource to look up Keyword Args: ...
python
def find(cls, session, resource_id, include=None): """Retrieve a single resource. This should only be called from sub-classes. Args: session(Session): The session to find the resource in resource_id: The ``id`` for the resource to look up Keyword Args: ...
[ "def", "find", "(", "cls", ",", "session", ",", "resource_id", ",", "include", "=", "None", ")", ":", "url", "=", "session", ".", "_build_url", "(", "cls", ".", "_resource_path", "(", ")", ",", "resource_id", ")", "params", "=", "build_request_include", ...
Retrieve a single resource. This should only be called from sub-classes. Args: session(Session): The session to find the resource in resource_id: The ``id`` for the resource to look up Keyword Args: include: Resource classes to include Returns: ...
[ "Retrieve", "a", "single", "resource", "." ]
db73480b143da4fc48e95c4414bd69c576a3a390
https://github.com/helium/helium-python/blob/db73480b143da4fc48e95c4414bd69c576a3a390/helium/resource.py#L201-L225
54,507
helium/helium-python
helium/resource.py
Resource.where
def where(cls, session, include=None, metadata=None, filter=None): """Get filtered resources of the given resource class. This should be called on sub-classes only. The include argument allows relationship fetches to be optimized by including the target resources in the request of ...
python
def where(cls, session, include=None, metadata=None, filter=None): """Get filtered resources of the given resource class. This should be called on sub-classes only. The include argument allows relationship fetches to be optimized by including the target resources in the request of ...
[ "def", "where", "(", "cls", ",", "session", ",", "include", "=", "None", ",", "metadata", "=", "None", ",", "filter", "=", "None", ")", ":", "url", "=", "session", ".", "_build_url", "(", "cls", ".", "_resource_path", "(", ")", ")", "params", "=", ...
Get filtered resources of the given resource class. This should be called on sub-classes only. The include argument allows relationship fetches to be optimized by including the target resources in the request of the containing resource. For example:: .. code-block:: python ...
[ "Get", "filtered", "resources", "of", "the", "given", "resource", "class", "." ]
db73480b143da4fc48e95c4414bd69c576a3a390
https://github.com/helium/helium-python/blob/db73480b143da4fc48e95c4414bd69c576a3a390/helium/resource.py#L228-L289
54,508
helium/helium-python
helium/resource.py
Resource.create
def create(cls, session, attributes=None, relationships=None): """Create a resource of the resource. This should only be called from sub-classes Args: session(Session): The session to create the resource in. attributes(dict): Any attributes that are valid for the ...
python
def create(cls, session, attributes=None, relationships=None): """Create a resource of the resource. This should only be called from sub-classes Args: session(Session): The session to create the resource in. attributes(dict): Any attributes that are valid for the ...
[ "def", "create", "(", "cls", ",", "session", ",", "attributes", "=", "None", ",", "relationships", "=", "None", ")", ":", "resource_type", "=", "cls", ".", "_resource_type", "(", ")", "resource_path", "=", "cls", ".", "_resource_path", "(", ")", "url", "...
Create a resource of the resource. This should only be called from sub-classes Args: session(Session): The session to create the resource in. attributes(dict): Any attributes that are valid for the given resource type. relationships(dict): Any relationshi...
[ "Create", "a", "resource", "of", "the", "resource", "." ]
db73480b143da4fc48e95c4414bd69c576a3a390
https://github.com/helium/helium-python/blob/db73480b143da4fc48e95c4414bd69c576a3a390/helium/resource.py#L292-L319
54,509
helium/helium-python
helium/resource.py
Resource.singleton
def singleton(cls, session, include=None): """Get the a singleton API resource. Some Helium API resources are singletons. The authorized user and organization for a given API key are examples of this. .. code-block:: python authorized_user = User.singleton(session) ...
python
def singleton(cls, session, include=None): """Get the a singleton API resource. Some Helium API resources are singletons. The authorized user and organization for a given API key are examples of this. .. code-block:: python authorized_user = User.singleton(session) ...
[ "def", "singleton", "(", "cls", ",", "session", ",", "include", "=", "None", ")", ":", "params", "=", "build_request_include", "(", "include", ",", "None", ")", "url", "=", "session", ".", "_build_url", "(", "cls", ".", "_resource_path", "(", ")", ")", ...
Get the a singleton API resource. Some Helium API resources are singletons. The authorized user and organization for a given API key are examples of this. .. code-block:: python authorized_user = User.singleton(session) will retrieve the authorized user for the given ...
[ "Get", "the", "a", "singleton", "API", "resource", "." ]
db73480b143da4fc48e95c4414bd69c576a3a390
https://github.com/helium/helium-python/blob/db73480b143da4fc48e95c4414bd69c576a3a390/helium/resource.py#L322-L343
54,510
helium/helium-python
helium/resource.py
Resource.update
def update(self, attributes=None): """Update this resource. Not all aspects of a resource can be updated. If the server rejects updates an error will be thrown. Keyword Arguments: attributes(dict): Attributes that are to be updated Returns: Resource: A ne...
python
def update(self, attributes=None): """Update this resource. Not all aspects of a resource can be updated. If the server rejects updates an error will be thrown. Keyword Arguments: attributes(dict): Attributes that are to be updated Returns: Resource: A ne...
[ "def", "update", "(", "self", ",", "attributes", "=", "None", ")", ":", "resource_type", "=", "self", ".", "_resource_type", "(", ")", "resource_path", "=", "self", ".", "_resource_path", "(", ")", "session", "=", "self", ".", "_session", "singleton", "=",...
Update this resource. Not all aspects of a resource can be updated. If the server rejects updates an error will be thrown. Keyword Arguments: attributes(dict): Attributes that are to be updated Returns: Resource: A new instance of this type of resource with the ...
[ "Update", "this", "resource", "." ]
db73480b143da4fc48e95c4414bd69c576a3a390
https://github.com/helium/helium-python/blob/db73480b143da4fc48e95c4414bd69c576a3a390/helium/resource.py#L418-L443
54,511
helium/helium-python
helium/resource.py
Resource.delete
def delete(self): """Delete the resource. Returns: True if the delete is successful. Will throw an error if other errors occur """ session = self._session url = session._build_url(self._resource_path(), self.id) return session.delete(url, CB.boolean...
python
def delete(self): """Delete the resource. Returns: True if the delete is successful. Will throw an error if other errors occur """ session = self._session url = session._build_url(self._resource_path(), self.id) return session.delete(url, CB.boolean...
[ "def", "delete", "(", "self", ")", ":", "session", "=", "self", ".", "_session", "url", "=", "session", ".", "_build_url", "(", "self", ".", "_resource_path", "(", ")", ",", "self", ".", "id", ")", "return", "session", ".", "delete", "(", "url", ",",...
Delete the resource. Returns: True if the delete is successful. Will throw an error if other errors occur
[ "Delete", "the", "resource", "." ]
db73480b143da4fc48e95c4414bd69c576a3a390
https://github.com/helium/helium-python/blob/db73480b143da4fc48e95c4414bd69c576a3a390/helium/resource.py#L445-L456
54,512
silas/ops
ops.py
chmod
def chmod(path, mode=None, user=None, group=None, other=None, recursive=False): """Changes file mode permissions. >>> if chmod('/tmp/one', 0755): ... print('OK') OK NOTE: The precending ``0`` is required when using a numerical mode. """ successful = True mode = _ops_mode(mode...
python
def chmod(path, mode=None, user=None, group=None, other=None, recursive=False): """Changes file mode permissions. >>> if chmod('/tmp/one', 0755): ... print('OK') OK NOTE: The precending ``0`` is required when using a numerical mode. """ successful = True mode = _ops_mode(mode...
[ "def", "chmod", "(", "path", ",", "mode", "=", "None", ",", "user", "=", "None", ",", "group", "=", "None", ",", "other", "=", "None", ",", "recursive", "=", "False", ")", ":", "successful", "=", "True", "mode", "=", "_ops_mode", "(", "mode", ")", ...
Changes file mode permissions. >>> if chmod('/tmp/one', 0755): ... print('OK') OK NOTE: The precending ``0`` is required when using a numerical mode.
[ "Changes", "file", "mode", "permissions", "." ]
8a62686b4e410ac599c4c15dcc41548b0296aeb3
https://github.com/silas/ops/blob/8a62686b4e410ac599c4c15dcc41548b0296aeb3/ops.py#L69-L91
54,513
silas/ops
ops.py
cp
def cp(src_path, dst_path, follow_links=False, recursive=True): """Copy source to destination. >>> if cp('/tmp/one', '/tmp/two'): ... print('OK') OK """ successful = False try: if follow_links and os.path.islink(src_path): src_path = os.path.realpath(src_path) ...
python
def cp(src_path, dst_path, follow_links=False, recursive=True): """Copy source to destination. >>> if cp('/tmp/one', '/tmp/two'): ... print('OK') OK """ successful = False try: if follow_links and os.path.islink(src_path): src_path = os.path.realpath(src_path) ...
[ "def", "cp", "(", "src_path", ",", "dst_path", ",", "follow_links", "=", "False", ",", "recursive", "=", "True", ")", ":", "successful", "=", "False", "try", ":", "if", "follow_links", "and", "os", ".", "path", ".", "islink", "(", "src_path", ")", ":",...
Copy source to destination. >>> if cp('/tmp/one', '/tmp/two'): ... print('OK') OK
[ "Copy", "source", "to", "destination", "." ]
8a62686b4e410ac599c4c15dcc41548b0296aeb3
https://github.com/silas/ops/blob/8a62686b4e410ac599c4c15dcc41548b0296aeb3/ops.py#L160-L187
54,514
silas/ops
ops.py
mkdir
def mkdir(path, recursive=True): """Create a directory at the specified path. By default this function recursively creates the path. >>> if mkdir('/tmp/one/two'): ... print('OK') OK """ if os.path.exists(path): return True try: if recursive: os.make...
python
def mkdir(path, recursive=True): """Create a directory at the specified path. By default this function recursively creates the path. >>> if mkdir('/tmp/one/two'): ... print('OK') OK """ if os.path.exists(path): return True try: if recursive: os.make...
[ "def", "mkdir", "(", "path", ",", "recursive", "=", "True", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "return", "True", "try", ":", "if", "recursive", ":", "os", ".", "makedirs", "(", "path", ")", "else", ":", "os",...
Create a directory at the specified path. By default this function recursively creates the path. >>> if mkdir('/tmp/one/two'): ... print('OK') OK
[ "Create", "a", "directory", "at", "the", "specified", "path", ".", "By", "default", "this", "function", "recursively", "creates", "the", "path", "." ]
8a62686b4e410ac599c4c15dcc41548b0296aeb3
https://github.com/silas/ops/blob/8a62686b4e410ac599c4c15dcc41548b0296aeb3/ops.py#L523-L541
54,515
silas/ops
ops.py
normalize
def normalize(value, default=None, type=None, raise_exception=False): """Convert string variables to a specified type. >>> normalize('true', type='boolean') True >>> normalize('11', type='number') 11 >>> normalize('10.3', default=11.0) 10.3 """ NUMBER_RE = re.compile('^[...
python
def normalize(value, default=None, type=None, raise_exception=False): """Convert string variables to a specified type. >>> normalize('true', type='boolean') True >>> normalize('11', type='number') 11 >>> normalize('10.3', default=11.0) 10.3 """ NUMBER_RE = re.compile('^[...
[ "def", "normalize", "(", "value", ",", "default", "=", "None", ",", "type", "=", "None", ",", "raise_exception", "=", "False", ")", ":", "NUMBER_RE", "=", "re", ".", "compile", "(", "'^[-+]?(([0-9]+\\.?[0-9]*)|([0-9]*\\.?[0-9]+))$'", ")", "if", "type", "is", ...
Convert string variables to a specified type. >>> normalize('true', type='boolean') True >>> normalize('11', type='number') 11 >>> normalize('10.3', default=11.0) 10.3
[ "Convert", "string", "variables", "to", "a", "specified", "type", "." ]
8a62686b4e410ac599c4c15dcc41548b0296aeb3
https://github.com/silas/ops/blob/8a62686b4e410ac599c4c15dcc41548b0296aeb3/ops.py#L636-L705
54,516
silas/ops
ops.py
rm
def rm(path, recursive=False): """Delete a specified file or directory. This function does not recursively delete by default. >>> if rm('/tmp/build', recursive=True): ... print('OK') OK """ try: if recursive: if os.path.isfile(path): os.remove(p...
python
def rm(path, recursive=False): """Delete a specified file or directory. This function does not recursively delete by default. >>> if rm('/tmp/build', recursive=True): ... print('OK') OK """ try: if recursive: if os.path.isfile(path): os.remove(p...
[ "def", "rm", "(", "path", ",", "recursive", "=", "False", ")", ":", "try", ":", "if", "recursive", ":", "if", "os", ".", "path", ".", "isfile", "(", "path", ")", ":", "os", ".", "remove", "(", "path", ")", "else", ":", "shutil", ".", "rmtree", ...
Delete a specified file or directory. This function does not recursively delete by default. >>> if rm('/tmp/build', recursive=True): ... print('OK') OK
[ "Delete", "a", "specified", "file", "or", "directory", ".", "This", "function", "does", "not", "recursively", "delete", "by", "default", "." ]
8a62686b4e410ac599c4c15dcc41548b0296aeb3
https://github.com/silas/ops/blob/8a62686b4e410ac599c4c15dcc41548b0296aeb3/ops.py#L832-L854
54,517
videntity/django-djmongo
djmongo/console/views.py
simple_ensure_index
def simple_ensure_index(request, database_name, collection_name): """Ensure a MongoDB index on a particular field name""" name = "Ensure a MongoDB index on a particular field name" if request.method == 'POST': form = EnsureIndexForm(request.POST) if form.is_valid(): result = fo...
python
def simple_ensure_index(request, database_name, collection_name): """Ensure a MongoDB index on a particular field name""" name = "Ensure a MongoDB index on a particular field name" if request.method == 'POST': form = EnsureIndexForm(request.POST) if form.is_valid(): result = fo...
[ "def", "simple_ensure_index", "(", "request", ",", "database_name", ",", "collection_name", ")", ":", "name", "=", "\"Ensure a MongoDB index on a particular field name\"", "if", "request", ".", "method", "==", "'POST'", ":", "form", "=", "EnsureIndexForm", "(", "reque...
Ensure a MongoDB index on a particular field name
[ "Ensure", "a", "MongoDB", "index", "on", "a", "particular", "field", "name" ]
7534e0981a2bc12634cf3f1ed03353623dc57565
https://github.com/videntity/django-djmongo/blob/7534e0981a2bc12634cf3f1ed03353623dc57565/djmongo/console/views.py#L220-L248
54,518
videntity/django-djmongo
djmongo/console/views.py
create_new_database
def create_new_database(request): """Create a New Mongo Database by adding a single document.""" name = "Create a New MongoDB Database" if request.method == 'POST': form = CreateDatabaseForm(request.POST) if form.is_valid(): result = form.save() if "error" in result...
python
def create_new_database(request): """Create a New Mongo Database by adding a single document.""" name = "Create a New MongoDB Database" if request.method == 'POST': form = CreateDatabaseForm(request.POST) if form.is_valid(): result = form.save() if "error" in result...
[ "def", "create_new_database", "(", "request", ")", ":", "name", "=", "\"Create a New MongoDB Database\"", "if", "request", ".", "method", "==", "'POST'", ":", "form", "=", "CreateDatabaseForm", "(", "request", ".", "POST", ")", "if", "form", ".", "is_valid", "...
Create a New Mongo Database by adding a single document.
[ "Create", "a", "New", "Mongo", "Database", "by", "adding", "a", "single", "document", "." ]
7534e0981a2bc12634cf3f1ed03353623dc57565
https://github.com/videntity/django-djmongo/blob/7534e0981a2bc12634cf3f1ed03353623dc57565/djmongo/console/views.py#L251-L284
54,519
mushkevych/scheduler
synergy/mx/base_request_handler.py
valid_action_request
def valid_action_request(method): """ wraps method with verification for is_request_valid""" @functools.wraps(method) def _wrapper(self, *args, **kwargs): assert isinstance(self, BaseRequestHandler) if not self.is_request_valid: return self.reply_bad_request() try: ...
python
def valid_action_request(method): """ wraps method with verification for is_request_valid""" @functools.wraps(method) def _wrapper(self, *args, **kwargs): assert isinstance(self, BaseRequestHandler) if not self.is_request_valid: return self.reply_bad_request() try: ...
[ "def", "valid_action_request", "(", "method", ")", ":", "@", "functools", ".", "wraps", "(", "method", ")", "def", "_wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "assert", "isinstance", "(", "self", ",", "BaseRequestHandler...
wraps method with verification for is_request_valid
[ "wraps", "method", "with", "verification", "for", "is_request_valid" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/mx/base_request_handler.py#L9-L25
54,520
mushkevych/scheduler
synergy/mx/base_request_handler.py
safe_json_response
def safe_json_response(method): """ makes sure the response' document has all leaf-fields converted to string """ def _safe_document(document): """ function modifies the document in place it iterates over the json document and stringify all non-string types :return: modified doc...
python
def safe_json_response(method): """ makes sure the response' document has all leaf-fields converted to string """ def _safe_document(document): """ function modifies the document in place it iterates over the json document and stringify all non-string types :return: modified doc...
[ "def", "safe_json_response", "(", "method", ")", ":", "def", "_safe_document", "(", "document", ")", ":", "\"\"\" function modifies the document in place\n it iterates over the json document and stringify all non-string types\n :return: modified document \"\"\"", "ass...
makes sure the response' document has all leaf-fields converted to string
[ "makes", "sure", "the", "response", "document", "has", "all", "leaf", "-", "fields", "converted", "to", "string" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/mx/base_request_handler.py#L28-L55
54,521
nicolargo/sxxexx
sxxexx/t411.py
T411._auth
def _auth(self, username, password) : """ Authentificate user and store token """ self.user_credentials = self.call('auth', {'username': username, 'password': password}) if 'error' in self.user_credentials: raise T411Exception('Error while fetching authentication token: %s'\...
python
def _auth(self, username, password) : """ Authentificate user and store token """ self.user_credentials = self.call('auth', {'username': username, 'password': password}) if 'error' in self.user_credentials: raise T411Exception('Error while fetching authentication token: %s'\...
[ "def", "_auth", "(", "self", ",", "username", ",", "password", ")", ":", "self", ".", "user_credentials", "=", "self", ".", "call", "(", "'auth'", ",", "{", "'username'", ":", "username", ",", "'password'", ":", "password", "}", ")", "if", "'error'", "...
Authentificate user and store token
[ "Authentificate", "user", "and", "store", "token" ]
88a896658609f4d56620bfe919284fa74ef560ac
https://github.com/nicolargo/sxxexx/blob/88a896658609f4d56620bfe919284fa74ef560ac/sxxexx/t411.py#L70-L81
54,522
nicolargo/sxxexx
sxxexx/t411.py
T411.call
def call(self, method = '', params = None) : """ Call T411 API """ # authentification request if method == 'auth' : req = requests.post(API_URL % method, data=params) # download torrent request elif 'download' in method: torrentid = os.path.basen...
python
def call(self, method = '', params = None) : """ Call T411 API """ # authentification request if method == 'auth' : req = requests.post(API_URL % method, data=params) # download torrent request elif 'download' in method: torrentid = os.path.basen...
[ "def", "call", "(", "self", ",", "method", "=", "''", ",", "params", "=", "None", ")", ":", "# authentification request", "if", "method", "==", "'auth'", ":", "req", "=", "requests", ".", "post", "(", "API_URL", "%", "method", ",", "data", "=", "params...
Call T411 API
[ "Call", "T411", "API" ]
88a896658609f4d56620bfe919284fa74ef560ac
https://github.com/nicolargo/sxxexx/blob/88a896658609f4d56620bfe919284fa74ef560ac/sxxexx/t411.py#L83-L139
54,523
nicolargo/sxxexx
sxxexx/t411.py
T411.download
def download(self, torrent_id, directory, filename) : """ Download a torrent """ return self.call('torrents/download/%s' % torrent_id, params={'filename' : filename, 'directory' : directory})
python
def download(self, torrent_id, directory, filename) : """ Download a torrent """ return self.call('torrents/download/%s' % torrent_id, params={'filename' : filename, 'directory' : directory})
[ "def", "download", "(", "self", ",", "torrent_id", ",", "directory", ",", "filename", ")", ":", "return", "self", ".", "call", "(", "'torrents/download/%s'", "%", "torrent_id", ",", "params", "=", "{", "'filename'", ":", "filename", ",", "'directory'", ":", ...
Download a torrent
[ "Download", "a", "torrent" ]
88a896658609f4d56620bfe919284fa74ef560ac
https://github.com/nicolargo/sxxexx/blob/88a896658609f4d56620bfe919284fa74ef560ac/sxxexx/t411.py#L165-L167
54,524
mushkevych/scheduler
synergy/scheduler/garbage_collector.py
GarbageCollector.flush
def flush(self, ignore_priority=False): """ method iterates over each reprocessing queues and re-submits UOW whose waiting time has expired """ for process_name, q in self.reprocess_uows.items(): self._flush_queue(q, ignore_priority)
python
def flush(self, ignore_priority=False): """ method iterates over each reprocessing queues and re-submits UOW whose waiting time has expired """ for process_name, q in self.reprocess_uows.items(): self._flush_queue(q, ignore_priority)
[ "def", "flush", "(", "self", ",", "ignore_priority", "=", "False", ")", ":", "for", "process_name", ",", "q", "in", "self", ".", "reprocess_uows", ".", "items", "(", ")", ":", "self", ".", "_flush_queue", "(", "q", ",", "ignore_priority", ")" ]
method iterates over each reprocessing queues and re-submits UOW whose waiting time has expired
[ "method", "iterates", "over", "each", "reprocessing", "queues", "and", "re", "-", "submits", "UOW", "whose", "waiting", "time", "has", "expired" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/scheduler/garbage_collector.py#L101-L104
54,525
mushkevych/scheduler
synergy/scheduler/garbage_collector.py
GarbageCollector.validate
def validate(self): """ method iterates over the reprocessing queue and synchronizes state of every UOW with the DB should it change via the MX to STATE_CANCELED - remove the UOW from the queue """ for process_name, q in self.reprocess_uows.items(): if not q: cont...
python
def validate(self): """ method iterates over the reprocessing queue and synchronizes state of every UOW with the DB should it change via the MX to STATE_CANCELED - remove the UOW from the queue """ for process_name, q in self.reprocess_uows.items(): if not q: cont...
[ "def", "validate", "(", "self", ")", ":", "for", "process_name", ",", "q", "in", "self", ".", "reprocess_uows", ".", "items", "(", ")", ":", "if", "not", "q", ":", "continue", "invalid_entries", "=", "list", "(", ")", "for", "entry", "in", "q", ".", ...
method iterates over the reprocessing queue and synchronizes state of every UOW with the DB should it change via the MX to STATE_CANCELED - remove the UOW from the queue
[ "method", "iterates", "over", "the", "reprocessing", "queue", "and", "synchronizes", "state", "of", "every", "UOW", "with", "the", "DB", "should", "it", "change", "via", "the", "MX", "to", "STATE_CANCELED", "-", "remove", "the", "UOW", "from", "the", "queue"...
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/scheduler/garbage_collector.py#L107-L129
54,526
mushkevych/scheduler
synergy/scheduler/garbage_collector.py
GarbageCollector.flush_one
def flush_one(self, process_name, ignore_priority=False): """ method iterates over the reprocessing queue for the given process and re-submits UOW whose waiting time has expired """ q = self.reprocess_uows[process_name] self._flush_queue(q, ignore_priority)
python
def flush_one(self, process_name, ignore_priority=False): """ method iterates over the reprocessing queue for the given process and re-submits UOW whose waiting time has expired """ q = self.reprocess_uows[process_name] self._flush_queue(q, ignore_priority)
[ "def", "flush_one", "(", "self", ",", "process_name", ",", "ignore_priority", "=", "False", ")", ":", "q", "=", "self", ".", "reprocess_uows", "[", "process_name", "]", "self", ".", "_flush_queue", "(", "q", ",", "ignore_priority", ")" ]
method iterates over the reprocessing queue for the given process and re-submits UOW whose waiting time has expired
[ "method", "iterates", "over", "the", "reprocessing", "queue", "for", "the", "given", "process", "and", "re", "-", "submits", "UOW", "whose", "waiting", "time", "has", "expired" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/scheduler/garbage_collector.py#L132-L136
54,527
mushkevych/scheduler
synergy/mx/tree_details.py
TreeDetails.mx_page_trees
def mx_page_trees(self, mx_page): """ return trees assigned to given MX Page """ resp = dict() for tree_name, tree in self.scheduler.timetable.trees.items(): if tree.mx_page == mx_page: rest_tree = self._get_tree_details(tree_name) resp[tree.tree_name]...
python
def mx_page_trees(self, mx_page): """ return trees assigned to given MX Page """ resp = dict() for tree_name, tree in self.scheduler.timetable.trees.items(): if tree.mx_page == mx_page: rest_tree = self._get_tree_details(tree_name) resp[tree.tree_name]...
[ "def", "mx_page_trees", "(", "self", ",", "mx_page", ")", ":", "resp", "=", "dict", "(", ")", "for", "tree_name", ",", "tree", "in", "self", ".", "scheduler", ".", "timetable", ".", "trees", ".", "items", "(", ")", ":", "if", "tree", ".", "mx_page", ...
return trees assigned to given MX Page
[ "return", "trees", "assigned", "to", "given", "MX", "Page" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/mx/tree_details.py#L33-L40
54,528
mushkevych/scheduler
synergy/db/model/queue_context_entry.py
queue_context_entry
def queue_context_entry(exchange, queue_name, routing=None): """ forms queue's context entry """ if routing is None: routing = queue_name queue_entry = QueueContextEntry(mq_queue=queue_name, mq_exchange=exchange, ...
python
def queue_context_entry(exchange, queue_name, routing=None): """ forms queue's context entry """ if routing is None: routing = queue_name queue_entry = QueueContextEntry(mq_queue=queue_name, mq_exchange=exchange, ...
[ "def", "queue_context_entry", "(", "exchange", ",", "queue_name", ",", "routing", "=", "None", ")", ":", "if", "routing", "is", "None", ":", "routing", "=", "queue_name", "queue_entry", "=", "QueueContextEntry", "(", "mq_queue", "=", "queue_name", ",", "mq_exc...
forms queue's context entry
[ "forms", "queue", "s", "context", "entry" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/db/model/queue_context_entry.py#L28-L38
54,529
475Cumulus/TBone
tbone/resources/aiohttp.py
AioHttpResource.request_args
def request_args(self): ''' Returns the arguments passed with the request in a dictionary. Returns both URL resolved arguments and query string arguments. ''' kwargs = {} kwargs.update(self.request.match_info.items()) kwargs.update(self.request.query.items()) ...
python
def request_args(self): ''' Returns the arguments passed with the request in a dictionary. Returns both URL resolved arguments and query string arguments. ''' kwargs = {} kwargs.update(self.request.match_info.items()) kwargs.update(self.request.query.items()) ...
[ "def", "request_args", "(", "self", ")", ":", "kwargs", "=", "{", "}", "kwargs", ".", "update", "(", "self", ".", "request", ".", "match_info", ".", "items", "(", ")", ")", "kwargs", ".", "update", "(", "self", ".", "request", ".", "query", ".", "i...
Returns the arguments passed with the request in a dictionary. Returns both URL resolved arguments and query string arguments.
[ "Returns", "the", "arguments", "passed", "with", "the", "request", "in", "a", "dictionary", ".", "Returns", "both", "URL", "resolved", "arguments", "and", "query", "string", "arguments", "." ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/resources/aiohttp.py#L36-L44
54,530
kdeldycke/chessboard
chessboard/pieces.py
Piece.compute_coordinates
def compute_coordinates(self): """ Compute 2D coordinates of the piece. """ self._x, self._y = self.board.index_to_coordinates(self.index)
python
def compute_coordinates(self): """ Compute 2D coordinates of the piece. """ self._x, self._y = self.board.index_to_coordinates(self.index)
[ "def", "compute_coordinates", "(", "self", ")", ":", "self", ".", "_x", ",", "self", ".", "_y", "=", "self", ".", "board", ".", "index_to_coordinates", "(", "self", ".", "index", ")" ]
Compute 2D coordinates of the piece.
[ "Compute", "2D", "coordinates", "of", "the", "piece", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/pieces.py#L78-L80
54,531
kdeldycke/chessboard
chessboard/pieces.py
Piece.horizontals
def horizontals(self): """ All horizontal squares from the piece's point of view. Returns a list of relative movements up to the board's bound. """ horizontal_shifts = set(izip_longest(map( lambda i: i - self.x, range(self.board.length)), [], fillvalue=0)) horizontal...
python
def horizontals(self): """ All horizontal squares from the piece's point of view. Returns a list of relative movements up to the board's bound. """ horizontal_shifts = set(izip_longest(map( lambda i: i - self.x, range(self.board.length)), [], fillvalue=0)) horizontal...
[ "def", "horizontals", "(", "self", ")", ":", "horizontal_shifts", "=", "set", "(", "izip_longest", "(", "map", "(", "lambda", "i", ":", "i", "-", "self", ".", "x", ",", "range", "(", "self", ".", "board", ".", "length", ")", ")", ",", "[", "]", "...
All horizontal squares from the piece's point of view. Returns a list of relative movements up to the board's bound.
[ "All", "horizontal", "squares", "from", "the", "piece", "s", "point", "of", "view", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/pieces.py#L124-L132
54,532
kdeldycke/chessboard
chessboard/pieces.py
Piece.verticals
def verticals(self): """ All vertical squares from the piece's point of view. Returns a list of relative movements up to the board's bound. """ vertical_shifts = set(izip_longest([], map( lambda i: i - self.y, range(self.board.height)), fillvalue=0)) vertical_shifts....
python
def verticals(self): """ All vertical squares from the piece's point of view. Returns a list of relative movements up to the board's bound. """ vertical_shifts = set(izip_longest([], map( lambda i: i - self.y, range(self.board.height)), fillvalue=0)) vertical_shifts....
[ "def", "verticals", "(", "self", ")", ":", "vertical_shifts", "=", "set", "(", "izip_longest", "(", "[", "]", ",", "map", "(", "lambda", "i", ":", "i", "-", "self", ".", "y", ",", "range", "(", "self", ".", "board", ".", "height", ")", ")", ",", ...
All vertical squares from the piece's point of view. Returns a list of relative movements up to the board's bound.
[ "All", "vertical", "squares", "from", "the", "piece", "s", "point", "of", "view", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/pieces.py#L135-L143
54,533
kdeldycke/chessboard
chessboard/pieces.py
Piece.diagonals
def diagonals(self): """ All diagonal squares from the piece's point of view. Returns a list of relative movements up to the board's bound. """ left_top_shifts = map(lambda i: (-(i + 1), -(i + 1)), range(min( self.left_distance, self.top_distance))) left_bottom_shift...
python
def diagonals(self): """ All diagonal squares from the piece's point of view. Returns a list of relative movements up to the board's bound. """ left_top_shifts = map(lambda i: (-(i + 1), -(i + 1)), range(min( self.left_distance, self.top_distance))) left_bottom_shift...
[ "def", "diagonals", "(", "self", ")", ":", "left_top_shifts", "=", "map", "(", "lambda", "i", ":", "(", "-", "(", "i", "+", "1", ")", ",", "-", "(", "i", "+", "1", ")", ")", ",", "range", "(", "min", "(", "self", ".", "left_distance", ",", "s...
All diagonal squares from the piece's point of view. Returns a list of relative movements up to the board's bound.
[ "All", "diagonal", "squares", "from", "the", "piece", "s", "point", "of", "view", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/pieces.py#L146-L161
54,534
kdeldycke/chessboard
chessboard/pieces.py
Piece.territory
def territory(self): """ Return the cached territory occupied by the piece. """ cache_key = ( self.board.length, self.board.height, self.uid, self.index) if cache_key not in self.territory_cache: vector = self.compute_territory() self.territory_cache[cache_key...
python
def territory(self): """ Return the cached territory occupied by the piece. """ cache_key = ( self.board.length, self.board.height, self.uid, self.index) if cache_key not in self.territory_cache: vector = self.compute_territory() self.territory_cache[cache_key...
[ "def", "territory", "(", "self", ")", ":", "cache_key", "=", "(", "self", ".", "board", ".", "length", ",", "self", ".", "board", ".", "height", ",", "self", ".", "uid", ",", "self", ".", "index", ")", "if", "cache_key", "not", "in", "self", ".", ...
Return the cached territory occupied by the piece.
[ "Return", "the", "cached", "territory", "occupied", "by", "the", "piece", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/pieces.py#L169-L178
54,535
kdeldycke/chessboard
chessboard/pieces.py
Piece.compute_territory
def compute_territory(self): """ Compute territory reachable by the piece from its current position. Returns a list of boolean flags of squares indexed linearly, for which a True means the square is reachable. """ # Initialize the square occupancy vector of the board. ve...
python
def compute_territory(self): """ Compute territory reachable by the piece from its current position. Returns a list of boolean flags of squares indexed linearly, for which a True means the square is reachable. """ # Initialize the square occupancy vector of the board. ve...
[ "def", "compute_territory", "(", "self", ")", ":", "# Initialize the square occupancy vector of the board.", "vector", "=", "self", ".", "board", ".", "new_vector", "(", ")", "# Mark current position as reachable.", "vector", "[", "self", ".", "index", "]", "=", "True...
Compute territory reachable by the piece from its current position. Returns a list of boolean flags of squares indexed linearly, for which a True means the square is reachable.
[ "Compute", "territory", "reachable", "by", "the", "piece", "from", "its", "current", "position", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/pieces.py#L180-L202
54,536
475Cumulus/TBone
tbone/dispatch/signals.py
Signal.connect
def connect(self, receiver, sender): ''' Connects a signal to a receiver function :param receiver: The callback function which will be connected to this signal :param sender: Specifies a particular sender to receive signals from. Used to limit the re...
python
def connect(self, receiver, sender): ''' Connects a signal to a receiver function :param receiver: The callback function which will be connected to this signal :param sender: Specifies a particular sender to receive signals from. Used to limit the re...
[ "def", "connect", "(", "self", ",", "receiver", ",", "sender", ")", ":", "logger", ".", "info", "(", "'Signal connected: {}'", ".", "format", "(", "receiver", ")", ")", "''' connect a receiver to a sender for signaling '''", "assert", "callable", "(", "receiver", ...
Connects a signal to a receiver function :param receiver: The callback function which will be connected to this signal :param sender: Specifies a particular sender to receive signals from. Used to limit the receiver function to signal from particular sender types
[ "Connects", "a", "signal", "to", "a", "receiver", "function" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/dispatch/signals.py#L28-L50
54,537
475Cumulus/TBone
tbone/dispatch/signals.py
Signal.send
async def send(self, sender, **kwargs): ''' send a signal from the sender to all connected receivers ''' if not self.receivers: return [] responses = [] futures = [] for receiver in self._get_receivers(sender): method = receiver() if callable(m...
python
async def send(self, sender, **kwargs): ''' send a signal from the sender to all connected receivers ''' if not self.receivers: return [] responses = [] futures = [] for receiver in self._get_receivers(sender): method = receiver() if callable(m...
[ "async", "def", "send", "(", "self", ",", "sender", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "receivers", ":", "return", "[", "]", "responses", "=", "[", "]", "futures", "=", "[", "]", "for", "receiver", "in", "self", ".", "_g...
send a signal from the sender to all connected receivers
[ "send", "a", "signal", "from", "the", "sender", "to", "all", "connected", "receivers" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/dispatch/signals.py#L58-L70
54,538
475Cumulus/TBone
tbone/dispatch/signals.py
Signal._get_receivers
def _get_receivers(self, sender): ''' filter only receiver functions which correspond to the provided sender ''' key = _make_id(sender) receivers = [] for (receiver_key, sender_key), receiver in self.receivers.items(): if sender_key == key: receivers.append(re...
python
def _get_receivers(self, sender): ''' filter only receiver functions which correspond to the provided sender ''' key = _make_id(sender) receivers = [] for (receiver_key, sender_key), receiver in self.receivers.items(): if sender_key == key: receivers.append(re...
[ "def", "_get_receivers", "(", "self", ",", "sender", ")", ":", "key", "=", "_make_id", "(", "sender", ")", "receivers", "=", "[", "]", "for", "(", "receiver_key", ",", "sender_key", ")", ",", "receiver", "in", "self", ".", "receivers", ".", "items", "(...
filter only receiver functions which correspond to the provided sender
[ "filter", "only", "receiver", "functions", "which", "correspond", "to", "the", "provided", "sender" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/dispatch/signals.py#L72-L79
54,539
kdeldycke/chessboard
chessboard/board.py
Board.reset
def reset(self): """ Empty board, remove all pieces and reset internal states. """ # Store positionned pieces on the board. self.pieces = set() # Squares on the board already occupied by a piece. self.occupancy = self.new_vector() # Territory susceptible to attacke, i.e...
python
def reset(self): """ Empty board, remove all pieces and reset internal states. """ # Store positionned pieces on the board. self.pieces = set() # Squares on the board already occupied by a piece. self.occupancy = self.new_vector() # Territory susceptible to attacke, i.e...
[ "def", "reset", "(", "self", ")", ":", "# Store positionned pieces on the board.", "self", ".", "pieces", "=", "set", "(", ")", "# Squares on the board already occupied by a piece.", "self", ".", "occupancy", "=", "self", ".", "new_vector", "(", ")", "# Territory susc...
Empty board, remove all pieces and reset internal states.
[ "Empty", "board", "remove", "all", "pieces", "and", "reset", "internal", "states", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/board.py#L118-L128
54,540
kdeldycke/chessboard
chessboard/board.py
Board.positions
def positions(self): """ Generator producing all 2D positions of all squares. """ for y in range(self.height): for x in range(self.length): yield x, y
python
def positions(self): """ Generator producing all 2D positions of all squares. """ for y in range(self.height): for x in range(self.length): yield x, y
[ "def", "positions", "(", "self", ")", ":", "for", "y", "in", "range", "(", "self", ".", "height", ")", ":", "for", "x", "in", "range", "(", "self", ".", "length", ")", ":", "yield", "x", ",", "y" ]
Generator producing all 2D positions of all squares.
[ "Generator", "producing", "all", "2D", "positions", "of", "all", "squares", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/board.py#L131-L135
54,541
kdeldycke/chessboard
chessboard/board.py
Board.validate_index
def validate_index(self, index): """ Check that a linear index of a square is within board's bounds. """ if index < 0 or index >= self.size: raise ForbiddenIndex("Linear index {} not in {}x{} board.".format( index, self.length, self.height))
python
def validate_index(self, index): """ Check that a linear index of a square is within board's bounds. """ if index < 0 or index >= self.size: raise ForbiddenIndex("Linear index {} not in {}x{} board.".format( index, self.length, self.height))
[ "def", "validate_index", "(", "self", ",", "index", ")", ":", "if", "index", "<", "0", "or", "index", ">=", "self", ".", "size", ":", "raise", "ForbiddenIndex", "(", "\"Linear index {} not in {}x{} board.\"", ".", "format", "(", "index", ",", "self", ".", ...
Check that a linear index of a square is within board's bounds.
[ "Check", "that", "a", "linear", "index", "of", "a", "square", "is", "within", "board", "s", "bounds", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/board.py#L144-L148
54,542
kdeldycke/chessboard
chessboard/board.py
Board.validate_coordinates
def validate_coordinates(self, x, y): """ Check if the piece lie within the board. """ if not(0 <= x < self.length and 0 <= y < self.height): raise ForbiddenCoordinates( "x={}, y={} outside of {}x{} board.".format( x, y, self.length, self.height))
python
def validate_coordinates(self, x, y): """ Check if the piece lie within the board. """ if not(0 <= x < self.length and 0 <= y < self.height): raise ForbiddenCoordinates( "x={}, y={} outside of {}x{} board.".format( x, y, self.length, self.height))
[ "def", "validate_coordinates", "(", "self", ",", "x", ",", "y", ")", ":", "if", "not", "(", "0", "<=", "x", "<", "self", ".", "length", "and", "0", "<=", "y", "<", "self", ".", "height", ")", ":", "raise", "ForbiddenCoordinates", "(", "\"x={}, y={} o...
Check if the piece lie within the board.
[ "Check", "if", "the", "piece", "lie", "within", "the", "board", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/board.py#L150-L155
54,543
kdeldycke/chessboard
chessboard/board.py
Board.coordinates_to_index
def coordinates_to_index(self, x, y, x_shift=0, y_shift=0): """ Return a linear index from a set of 2D coordinates. Optionnal vertical and horizontal shifts might be applied. """ target_x = x + x_shift target_y = y + y_shift self.validate_coordinates(target_x, target_y) ...
python
def coordinates_to_index(self, x, y, x_shift=0, y_shift=0): """ Return a linear index from a set of 2D coordinates. Optionnal vertical and horizontal shifts might be applied. """ target_x = x + x_shift target_y = y + y_shift self.validate_coordinates(target_x, target_y) ...
[ "def", "coordinates_to_index", "(", "self", ",", "x", ",", "y", ",", "x_shift", "=", "0", ",", "y_shift", "=", "0", ")", ":", "target_x", "=", "x", "+", "x_shift", "target_y", "=", "y", "+", "y_shift", "self", ".", "validate_coordinates", "(", "target_...
Return a linear index from a set of 2D coordinates. Optionnal vertical and horizontal shifts might be applied.
[ "Return", "a", "linear", "index", "from", "a", "set", "of", "2D", "coordinates", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/board.py#L164-L173
54,544
kdeldycke/chessboard
chessboard/board.py
Board.add
def add(self, piece_uid, index): """ Add a piece to the board at the provided linear position. """ # Square already occupied by another piece. if self.occupancy[index]: raise OccupiedPosition # Square reachable by another piece. if self.exposed_territory[index]: ...
python
def add(self, piece_uid, index): """ Add a piece to the board at the provided linear position. """ # Square already occupied by another piece. if self.occupancy[index]: raise OccupiedPosition # Square reachable by another piece. if self.exposed_territory[index]: ...
[ "def", "add", "(", "self", ",", "piece_uid", ",", "index", ")", ":", "# Square already occupied by another piece.", "if", "self", ".", "occupancy", "[", "index", "]", ":", "raise", "OccupiedPosition", "# Square reachable by another piece.", "if", "self", ".", "expos...
Add a piece to the board at the provided linear position.
[ "Add", "a", "piece", "to", "the", "board", "at", "the", "provided", "linear", "position", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/board.py#L175-L200
54,545
kdeldycke/chessboard
chessboard/board.py
Board.get
def get(self, x, y): """ Return piece placed at the provided coordinates. """ for piece in self.pieces: if (piece.x, piece.y) == (x, y): return piece
python
def get(self, x, y): """ Return piece placed at the provided coordinates. """ for piece in self.pieces: if (piece.x, piece.y) == (x, y): return piece
[ "def", "get", "(", "self", ",", "x", ",", "y", ")", ":", "for", "piece", "in", "self", ".", "pieces", ":", "if", "(", "piece", ".", "x", ",", "piece", ".", "y", ")", "==", "(", "x", ",", "y", ")", ":", "return", "piece" ]
Return piece placed at the provided coordinates.
[ "Return", "piece", "placed", "at", "the", "provided", "coordinates", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/board.py#L202-L206
54,546
Min-ops/cruddy
cruddy/__init__.py
CRUD.describe
def describe(self, **kwargs): """ Returns descriptive information about this cruddy handler and the methods supported by it. """ response = self._new_response() description = { 'cruddy_version': __version__, 'table_name': self.table_name, ...
python
def describe(self, **kwargs): """ Returns descriptive information about this cruddy handler and the methods supported by it. """ response = self._new_response() description = { 'cruddy_version': __version__, 'table_name': self.table_name, ...
[ "def", "describe", "(", "self", ",", "*", "*", "kwargs", ")", ":", "response", "=", "self", ".", "_new_response", "(", ")", "description", "=", "{", "'cruddy_version'", ":", "__version__", ",", "'table_name'", ":", "self", ".", "table_name", ",", "'support...
Returns descriptive information about this cruddy handler and the methods supported by it.
[ "Returns", "descriptive", "information", "about", "this", "cruddy", "handler", "and", "the", "methods", "supported", "by", "it", "." ]
b9ba3dda1757e1075bc1c62a6f43473eea27de41
https://github.com/Min-ops/cruddy/blob/b9ba3dda1757e1075bc1c62a6f43473eea27de41/cruddy/__init__.py#L181-L212
54,547
Min-ops/cruddy
cruddy/__init__.py
CRUD.search
def search(self, query, **kwargs): """ Cruddy provides a limited but useful interface to search GSI indexes in DynamoDB with the following limitations (hopefully some of these will be expanded or eliminated in the future. * The GSI must be configured with a only HASH and not a R...
python
def search(self, query, **kwargs): """ Cruddy provides a limited but useful interface to search GSI indexes in DynamoDB with the following limitations (hopefully some of these will be expanded or eliminated in the future. * The GSI must be configured with a only HASH and not a R...
[ "def", "search", "(", "self", ",", "query", ",", "*", "*", "kwargs", ")", ":", "response", "=", "self", ".", "_new_response", "(", ")", "if", "self", ".", "_check_supported_op", "(", "'search'", ",", "response", ")", ":", "if", "'='", "not", "in", "q...
Cruddy provides a limited but useful interface to search GSI indexes in DynamoDB with the following limitations (hopefully some of these will be expanded or eliminated in the future. * The GSI must be configured with a only HASH and not a RANGE. * The only operation supported in the que...
[ "Cruddy", "provides", "a", "limited", "but", "useful", "interface", "to", "search", "GSI", "indexes", "in", "DynamoDB", "with", "the", "following", "limitations", "(", "hopefully", "some", "of", "these", "will", "be", "expanded", "or", "eliminated", "in", "the...
b9ba3dda1757e1075bc1c62a6f43473eea27de41
https://github.com/Min-ops/cruddy/blob/b9ba3dda1757e1075bc1c62a6f43473eea27de41/cruddy/__init__.py#L214-L266
54,548
Min-ops/cruddy
cruddy/__init__.py
CRUD.list
def list(self, **kwargs): """ Returns a list of items in the database. Encrypted attributes are not decrypted when listing items. """ response = self._new_response() if self._check_supported_op('list', response): self._call_ddb_method(self.table.scan, {}, res...
python
def list(self, **kwargs): """ Returns a list of items in the database. Encrypted attributes are not decrypted when listing items. """ response = self._new_response() if self._check_supported_op('list', response): self._call_ddb_method(self.table.scan, {}, res...
[ "def", "list", "(", "self", ",", "*", "*", "kwargs", ")", ":", "response", "=", "self", ".", "_new_response", "(", ")", "if", "self", ".", "_check_supported_op", "(", "'list'", ",", "response", ")", ":", "self", ".", "_call_ddb_method", "(", "self", "....
Returns a list of items in the database. Encrypted attributes are not decrypted when listing items.
[ "Returns", "a", "list", "of", "items", "in", "the", "database", ".", "Encrypted", "attributes", "are", "not", "decrypted", "when", "listing", "items", "." ]
b9ba3dda1757e1075bc1c62a6f43473eea27de41
https://github.com/Min-ops/cruddy/blob/b9ba3dda1757e1075bc1c62a6f43473eea27de41/cruddy/__init__.py#L268-L280
54,549
Min-ops/cruddy
cruddy/__init__.py
CRUD.create
def create(self, item, **kwargs): """ Creates a new item. You pass in an item containing initial values. Any attribute names defined in ``prototype`` that are missing from the item will be added using the default value defined in ``prototype``. """ response = self._new_r...
python
def create(self, item, **kwargs): """ Creates a new item. You pass in an item containing initial values. Any attribute names defined in ``prototype`` that are missing from the item will be added using the default value defined in ``prototype``. """ response = self._new_r...
[ "def", "create", "(", "self", ",", "item", ",", "*", "*", "kwargs", ")", ":", "response", "=", "self", ".", "_new_response", "(", ")", "if", "self", ".", "_prototype_handler", ".", "check", "(", "item", ",", "'create'", ",", "response", ")", ":", "se...
Creates a new item. You pass in an item containing initial values. Any attribute names defined in ``prototype`` that are missing from the item will be added using the default value defined in ``prototype``.
[ "Creates", "a", "new", "item", ".", "You", "pass", "in", "an", "item", "containing", "initial", "values", ".", "Any", "attribute", "names", "defined", "in", "prototype", "that", "are", "missing", "from", "the", "item", "will", "be", "added", "using", "the"...
b9ba3dda1757e1075bc1c62a6f43473eea27de41
https://github.com/Min-ops/cruddy/blob/b9ba3dda1757e1075bc1c62a6f43473eea27de41/cruddy/__init__.py#L315-L330
54,550
Min-ops/cruddy
cruddy/__init__.py
CRUD.update
def update(self, item, encrypt=True, **kwargs): """ Updates the item based on the current values of the dictionary passed in. """ response = self._new_response() if self._check_supported_op('update', response): if self._prototype_handler.check(item, 'update', ...
python
def update(self, item, encrypt=True, **kwargs): """ Updates the item based on the current values of the dictionary passed in. """ response = self._new_response() if self._check_supported_op('update', response): if self._prototype_handler.check(item, 'update', ...
[ "def", "update", "(", "self", ",", "item", ",", "encrypt", "=", "True", ",", "*", "*", "kwargs", ")", ":", "response", "=", "self", ".", "_new_response", "(", ")", "if", "self", ".", "_check_supported_op", "(", "'update'", ",", "response", ")", ":", ...
Updates the item based on the current values of the dictionary passed in.
[ "Updates", "the", "item", "based", "on", "the", "current", "values", "of", "the", "dictionary", "passed", "in", "." ]
b9ba3dda1757e1075bc1c62a6f43473eea27de41
https://github.com/Min-ops/cruddy/blob/b9ba3dda1757e1075bc1c62a6f43473eea27de41/cruddy/__init__.py#L332-L348
54,551
Min-ops/cruddy
cruddy/__init__.py
CRUD.increment_counter
def increment_counter(self, id, counter_name, increment=1, id_name='id', **kwargs): """ Atomically increments a counter attribute in the item identified by ``id``. You must specify the name of the attribute as ``counter_name`` and, optionally, the ``increment``...
python
def increment_counter(self, id, counter_name, increment=1, id_name='id', **kwargs): """ Atomically increments a counter attribute in the item identified by ``id``. You must specify the name of the attribute as ``counter_name`` and, optionally, the ``increment``...
[ "def", "increment_counter", "(", "self", ",", "id", ",", "counter_name", ",", "increment", "=", "1", ",", "id_name", "=", "'id'", ",", "*", "*", "kwargs", ")", ":", "response", "=", "self", ".", "_new_response", "(", ")", "if", "self", ".", "_check_sup...
Atomically increments a counter attribute in the item identified by ``id``. You must specify the name of the attribute as ``counter_name`` and, optionally, the ``increment`` which defaults to ``1``.
[ "Atomically", "increments", "a", "counter", "attribute", "in", "the", "item", "identified", "by", "id", ".", "You", "must", "specify", "the", "name", "of", "the", "attribute", "as", "counter_name", "and", "optionally", "the", "increment", "which", "defaults", ...
b9ba3dda1757e1075bc1c62a6f43473eea27de41
https://github.com/Min-ops/cruddy/blob/b9ba3dda1757e1075bc1c62a6f43473eea27de41/cruddy/__init__.py#L350-L374
54,552
Min-ops/cruddy
cruddy/__init__.py
CRUD.delete
def delete(self, id, id_name='id', **kwargs): """ Deletes the item corresponding to ``id``. """ response = self._new_response() if self._check_supported_op('delete', response): params = {'Key': {id_name: id}} self._call_ddb_method(self.table.delete_item, p...
python
def delete(self, id, id_name='id', **kwargs): """ Deletes the item corresponding to ``id``. """ response = self._new_response() if self._check_supported_op('delete', response): params = {'Key': {id_name: id}} self._call_ddb_method(self.table.delete_item, p...
[ "def", "delete", "(", "self", ",", "id", ",", "id_name", "=", "'id'", ",", "*", "*", "kwargs", ")", ":", "response", "=", "self", ".", "_new_response", "(", ")", "if", "self", ".", "_check_supported_op", "(", "'delete'", ",", "response", ")", ":", "p...
Deletes the item corresponding to ``id``.
[ "Deletes", "the", "item", "corresponding", "to", "id", "." ]
b9ba3dda1757e1075bc1c62a6f43473eea27de41
https://github.com/Min-ops/cruddy/blob/b9ba3dda1757e1075bc1c62a6f43473eea27de41/cruddy/__init__.py#L376-L386
54,553
Min-ops/cruddy
cruddy/__init__.py
CRUD.bulk_delete
def bulk_delete(self, query, **kwargs): """ Perform a search and delete all items that match. """ response = self._new_response() if self._check_supported_op('search', response): n = 0 pe = 'id' response = self.search(query, projection_expressi...
python
def bulk_delete(self, query, **kwargs): """ Perform a search and delete all items that match. """ response = self._new_response() if self._check_supported_op('search', response): n = 0 pe = 'id' response = self.search(query, projection_expressi...
[ "def", "bulk_delete", "(", "self", ",", "query", ",", "*", "*", "kwargs", ")", ":", "response", "=", "self", ".", "_new_response", "(", ")", "if", "self", ".", "_check_supported_op", "(", "'search'", ",", "response", ")", ":", "n", "=", "0", "pe", "=...
Perform a search and delete all items that match.
[ "Perform", "a", "search", "and", "delete", "all", "items", "that", "match", "." ]
b9ba3dda1757e1075bc1c62a6f43473eea27de41
https://github.com/Min-ops/cruddy/blob/b9ba3dda1757e1075bc1c62a6f43473eea27de41/cruddy/__init__.py#L388-L408
54,554
Min-ops/cruddy
cruddy/__init__.py
CRUD.handler
def handler(self, operation=None, **kwargs): """ In addition to the methods described above, cruddy also provides a generic handler interface. This is mainly useful when you want to wrap a cruddy handler in a Lambda function and then call that Lambda function to access the CRUD ...
python
def handler(self, operation=None, **kwargs): """ In addition to the methods described above, cruddy also provides a generic handler interface. This is mainly useful when you want to wrap a cruddy handler in a Lambda function and then call that Lambda function to access the CRUD ...
[ "def", "handler", "(", "self", ",", "operation", "=", "None", ",", "*", "*", "kwargs", ")", ":", "response", "=", "self", ".", "_new_response", "(", ")", "if", "operation", "is", "None", ":", "response", ".", "status", "=", "'error'", "response", ".", ...
In addition to the methods described above, cruddy also provides a generic handler interface. This is mainly useful when you want to wrap a cruddy handler in a Lambda function and then call that Lambda function to access the CRUD capabilities. To call the handler, you simply put all ne...
[ "In", "addition", "to", "the", "methods", "described", "above", "cruddy", "also", "provides", "a", "generic", "handler", "interface", ".", "This", "is", "mainly", "useful", "when", "you", "want", "to", "wrap", "a", "cruddy", "handler", "in", "a", "Lambda", ...
b9ba3dda1757e1075bc1c62a6f43473eea27de41
https://github.com/Min-ops/cruddy/blob/b9ba3dda1757e1075bc1c62a6f43473eea27de41/cruddy/__init__.py#L410-L445
54,555
brocade/pynos
pynos/versions/base/lldp.py
LLDP.get_lldp_neighbors_request
def get_lldp_neighbors_request(last_ifindex, rbridge_id): """ Creates a new Netconf request based on the last received or if rbridge_id is specifed ifindex when the hasMore flag is true """ request_lldp = ET.Element( 'get-lldp-neighbor-detail', xmlns="urn...
python
def get_lldp_neighbors_request(last_ifindex, rbridge_id): """ Creates a new Netconf request based on the last received or if rbridge_id is specifed ifindex when the hasMore flag is true """ request_lldp = ET.Element( 'get-lldp-neighbor-detail', xmlns="urn...
[ "def", "get_lldp_neighbors_request", "(", "last_ifindex", ",", "rbridge_id", ")", ":", "request_lldp", "=", "ET", ".", "Element", "(", "'get-lldp-neighbor-detail'", ",", "xmlns", "=", "\"urn:brocade.com:mgmt:brocade-lldp-ext\"", ")", "if", "rbridge_id", "is", "not", "...
Creates a new Netconf request based on the last received or if rbridge_id is specifed ifindex when the hasMore flag is true
[ "Creates", "a", "new", "Netconf", "request", "based", "on", "the", "last", "received", "or", "if", "rbridge_id", "is", "specifed", "ifindex", "when", "the", "hasMore", "flag", "is", "true" ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/lldp.py#L92-L110
54,556
viniciuschiele/flask-io
flask_io/io.py
FlaskIO.created
def created(self, data, schema=None, envelope=None): """ Gets a 201 response with the specified data. :param data: The content value. :param schema: The schema to serialize the data. :param envelope: The key used to envelope the data. :return: A Flask response object. ...
python
def created(self, data, schema=None, envelope=None): """ Gets a 201 response with the specified data. :param data: The content value. :param schema: The schema to serialize the data. :param envelope: The key used to envelope the data. :return: A Flask response object. ...
[ "def", "created", "(", "self", ",", "data", ",", "schema", "=", "None", ",", "envelope", "=", "None", ")", ":", "data", "=", "marshal", "(", "data", ",", "schema", ",", "envelope", ")", "return", "self", ".", "__make_response", "(", "(", "data", ",",...
Gets a 201 response with the specified data. :param data: The content value. :param schema: The schema to serialize the data. :param envelope: The key used to envelope the data. :return: A Flask response object.
[ "Gets", "a", "201", "response", "with", "the", "specified", "data", "." ]
4e559419b3d8e6859f83fa16557b00542d5f3aa7
https://github.com/viniciuschiele/flask-io/blob/4e559419b3d8e6859f83fa16557b00542d5f3aa7/flask_io/io.py#L78-L89
54,557
viniciuschiele/flask-io
flask_io/io.py
FlaskIO.ok
def ok(self, data, schema=None, envelope=None): """ Gets a 200 response with the specified data. :param data: The content value. :param schema: The schema to serialize the data. :param envelope: The key used to envelope the data. :return: A Flask response object. ...
python
def ok(self, data, schema=None, envelope=None): """ Gets a 200 response with the specified data. :param data: The content value. :param schema: The schema to serialize the data. :param envelope: The key used to envelope the data. :return: A Flask response object. ...
[ "def", "ok", "(", "self", ",", "data", ",", "schema", "=", "None", ",", "envelope", "=", "None", ")", ":", "data", "=", "marshal", "(", "data", ",", "schema", ",", "envelope", ")", "return", "self", ".", "__make_response", "(", "data", ")" ]
Gets a 200 response with the specified data. :param data: The content value. :param schema: The schema to serialize the data. :param envelope: The key used to envelope the data. :return: A Flask response object.
[ "Gets", "a", "200", "response", "with", "the", "specified", "data", "." ]
4e559419b3d8e6859f83fa16557b00542d5f3aa7
https://github.com/viniciuschiele/flask-io/blob/4e559419b3d8e6859f83fa16557b00542d5f3aa7/flask_io/io.py#L120-L131
54,558
viniciuschiele/flask-io
flask_io/io.py
FlaskIO.authenticators
def authenticators(self, auths): """ A decorator that sets a list of authenticators for a function. :param auths: The list of authenticator instances or classes. :return: A function """ if not isinstance(auths, (list, tuple)): auths = [auths] instan...
python
def authenticators(self, auths): """ A decorator that sets a list of authenticators for a function. :param auths: The list of authenticator instances or classes. :return: A function """ if not isinstance(auths, (list, tuple)): auths = [auths] instan...
[ "def", "authenticators", "(", "self", ",", "auths", ")", ":", "if", "not", "isinstance", "(", "auths", ",", "(", "list", ",", "tuple", ")", ")", ":", "auths", "=", "[", "auths", "]", "instances", "=", "[", "]", "for", "auth", "in", "auths", ":", ...
A decorator that sets a list of authenticators for a function. :param auths: The list of authenticator instances or classes. :return: A function
[ "A", "decorator", "that", "sets", "a", "list", "of", "authenticators", "for", "a", "function", "." ]
4e559419b3d8e6859f83fa16557b00542d5f3aa7
https://github.com/viniciuschiele/flask-io/blob/4e559419b3d8e6859f83fa16557b00542d5f3aa7/flask_io/io.py#L142-L164
54,559
viniciuschiele/flask-io
flask_io/io.py
FlaskIO.permissions
def permissions(self, perms): """ A decorator that sets a list of permissions for a function. :param perms: The list of permission instances or classes. :return: A function """ if not isinstance(perms, (list, tuple)): perms = [perms] instances = [] ...
python
def permissions(self, perms): """ A decorator that sets a list of permissions for a function. :param perms: The list of permission instances or classes. :return: A function """ if not isinstance(perms, (list, tuple)): perms = [perms] instances = [] ...
[ "def", "permissions", "(", "self", ",", "perms", ")", ":", "if", "not", "isinstance", "(", "perms", ",", "(", "list", ",", "tuple", ")", ")", ":", "perms", "=", "[", "perms", "]", "instances", "=", "[", "]", "for", "perm", "in", "perms", ":", "if...
A decorator that sets a list of permissions for a function. :param perms: The list of permission instances or classes. :return: A function
[ "A", "decorator", "that", "sets", "a", "list", "of", "permissions", "for", "a", "function", "." ]
4e559419b3d8e6859f83fa16557b00542d5f3aa7
https://github.com/viniciuschiele/flask-io/blob/4e559419b3d8e6859f83fa16557b00542d5f3aa7/flask_io/io.py#L166-L188
54,560
viniciuschiele/flask-io
flask_io/io.py
FlaskIO.from_body
def from_body(self, param_name, schema): """ A decorator that converts the request body into a function parameter based on the specified schema. :param param_name: The parameter which receives the argument. :param schema: The schema class or instance used to deserialize the request body...
python
def from_body(self, param_name, schema): """ A decorator that converts the request body into a function parameter based on the specified schema. :param param_name: The parameter which receives the argument. :param schema: The schema class or instance used to deserialize the request body...
[ "def", "from_body", "(", "self", ",", "param_name", ",", "schema", ")", ":", "schema", "=", "schema", "(", ")", "if", "isclass", "(", "schema", ")", "else", "schema", "def", "decorator", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "fu...
A decorator that converts the request body into a function parameter based on the specified schema. :param param_name: The parameter which receives the argument. :param schema: The schema class or instance used to deserialize the request body toa Python object. :return: A function
[ "A", "decorator", "that", "converts", "the", "request", "body", "into", "a", "function", "parameter", "based", "on", "the", "specified", "schema", "." ]
4e559419b3d8e6859f83fa16557b00542d5f3aa7
https://github.com/viniciuschiele/flask-io/blob/4e559419b3d8e6859f83fa16557b00542d5f3aa7/flask_io/io.py#L190-L207
54,561
viniciuschiele/flask-io
flask_io/io.py
FlaskIO.from_cookie
def from_cookie(self, param_name, field): """ A decorator that converts a request cookie into a function parameter based on the specified field. :param str param_name: The parameter which receives the argument. :param Field field: The field class or instance used to deserialize the requ...
python
def from_cookie(self, param_name, field): """ A decorator that converts a request cookie into a function parameter based on the specified field. :param str param_name: The parameter which receives the argument. :param Field field: The field class or instance used to deserialize the requ...
[ "def", "from_cookie", "(", "self", ",", "param_name", ",", "field", ")", ":", "return", "self", ".", "__from_source", "(", "param_name", ",", "field", ",", "lambda", ":", "request", ".", "cookies", ",", "'cookie'", ")" ]
A decorator that converts a request cookie into a function parameter based on the specified field. :param str param_name: The parameter which receives the argument. :param Field field: The field class or instance used to deserialize the request cookie to a Python object. :return: A function
[ "A", "decorator", "that", "converts", "a", "request", "cookie", "into", "a", "function", "parameter", "based", "on", "the", "specified", "field", "." ]
4e559419b3d8e6859f83fa16557b00542d5f3aa7
https://github.com/viniciuschiele/flask-io/blob/4e559419b3d8e6859f83fa16557b00542d5f3aa7/flask_io/io.py#L209-L218
54,562
viniciuschiele/flask-io
flask_io/io.py
FlaskIO.from_form
def from_form(self, param_name, field): """ A decorator that converts a request form into a function parameter based on the specified field. :param str param_name: The parameter which receives the argument. :param Field field: The field class or instance used to deserialize the request ...
python
def from_form(self, param_name, field): """ A decorator that converts a request form into a function parameter based on the specified field. :param str param_name: The parameter which receives the argument. :param Field field: The field class or instance used to deserialize the request ...
[ "def", "from_form", "(", "self", ",", "param_name", ",", "field", ")", ":", "return", "self", ".", "__from_source", "(", "param_name", ",", "field", ",", "lambda", ":", "request", ".", "form", ",", "'form'", ")" ]
A decorator that converts a request form into a function parameter based on the specified field. :param str param_name: The parameter which receives the argument. :param Field field: The field class or instance used to deserialize the request form to a Python object. :return: A function
[ "A", "decorator", "that", "converts", "a", "request", "form", "into", "a", "function", "parameter", "based", "on", "the", "specified", "field", "." ]
4e559419b3d8e6859f83fa16557b00542d5f3aa7
https://github.com/viniciuschiele/flask-io/blob/4e559419b3d8e6859f83fa16557b00542d5f3aa7/flask_io/io.py#L220-L228
54,563
viniciuschiele/flask-io
flask_io/io.py
FlaskIO.from_header
def from_header(self, param_name, field): """ A decorator that converts a request header into a function parameter based on the specified field. :param str param_name: The parameter which receives the argument. :param Field field: The field class or instance used to deserialize the requ...
python
def from_header(self, param_name, field): """ A decorator that converts a request header into a function parameter based on the specified field. :param str param_name: The parameter which receives the argument. :param Field field: The field class or instance used to deserialize the requ...
[ "def", "from_header", "(", "self", ",", "param_name", ",", "field", ")", ":", "return", "self", ".", "__from_source", "(", "param_name", ",", "field", ",", "lambda", ":", "request", ".", "headers", ",", "'header'", ")" ]
A decorator that converts a request header into a function parameter based on the specified field. :param str param_name: The parameter which receives the argument. :param Field field: The field class or instance used to deserialize the request header to a Python object. :return: A function
[ "A", "decorator", "that", "converts", "a", "request", "header", "into", "a", "function", "parameter", "based", "on", "the", "specified", "field", "." ]
4e559419b3d8e6859f83fa16557b00542d5f3aa7
https://github.com/viniciuschiele/flask-io/blob/4e559419b3d8e6859f83fa16557b00542d5f3aa7/flask_io/io.py#L230-L238
54,564
viniciuschiele/flask-io
flask_io/io.py
FlaskIO.from_query
def from_query(self, param_name, field): """ A decorator that converts a query string into a function parameter based on the specified field. :param param_name: The parameter which receives the argument. :param Field field: The field class or instance used to deserialize the request que...
python
def from_query(self, param_name, field): """ A decorator that converts a query string into a function parameter based on the specified field. :param param_name: The parameter which receives the argument. :param Field field: The field class or instance used to deserialize the request que...
[ "def", "from_query", "(", "self", ",", "param_name", ",", "field", ")", ":", "return", "self", ".", "__from_source", "(", "param_name", ",", "field", ",", "lambda", ":", "request", ".", "args", ",", "'query'", ")" ]
A decorator that converts a query string into a function parameter based on the specified field. :param param_name: The parameter which receives the argument. :param Field field: The field class or instance used to deserialize the request query string to a Python object. :return: A function
[ "A", "decorator", "that", "converts", "a", "query", "string", "into", "a", "function", "parameter", "based", "on", "the", "specified", "field", "." ]
4e559419b3d8e6859f83fa16557b00542d5f3aa7
https://github.com/viniciuschiele/flask-io/blob/4e559419b3d8e6859f83fa16557b00542d5f3aa7/flask_io/io.py#L240-L249
54,565
viniciuschiele/flask-io
flask_io/io.py
FlaskIO.marshal_with
def marshal_with(self, schema, envelope=None): """ A decorator that apply marshalling to the return values of your methods. :param schema: The schema class to be used to serialize the values. :param envelope: The key used to envelope the data. :return: A function. """ ...
python
def marshal_with(self, schema, envelope=None): """ A decorator that apply marshalling to the return values of your methods. :param schema: The schema class to be used to serialize the values. :param envelope: The key used to envelope the data. :return: A function. """ ...
[ "def", "marshal_with", "(", "self", ",", "schema", ",", "envelope", "=", "None", ")", ":", "# schema is pre instantiated to avoid instantiate it", "# on every request", "schema_is_class", "=", "isclass", "(", "schema", ")", "schema_cache", "=", "schema", "(", ")", "...
A decorator that apply marshalling to the return values of your methods. :param schema: The schema class to be used to serialize the values. :param envelope: The key used to envelope the data. :return: A function.
[ "A", "decorator", "that", "apply", "marshalling", "to", "the", "return", "values", "of", "your", "methods", "." ]
4e559419b3d8e6859f83fa16557b00542d5f3aa7
https://github.com/viniciuschiele/flask-io/blob/4e559419b3d8e6859f83fa16557b00542d5f3aa7/flask_io/io.py#L251-L285
54,566
viniciuschiele/flask-io
flask_io/io.py
FlaskIO.trace_emit
def trace_emit(self): """ A decorator that allows to change the trace emitter. By default Python logging is used to emit the trace data. """ def decorator(f): self.tracer.emitter = f return f return decorator
python
def trace_emit(self): """ A decorator that allows to change the trace emitter. By default Python logging is used to emit the trace data. """ def decorator(f): self.tracer.emitter = f return f return decorator
[ "def", "trace_emit", "(", "self", ")", ":", "def", "decorator", "(", "f", ")", ":", "self", ".", "tracer", ".", "emitter", "=", "f", "return", "f", "return", "decorator" ]
A decorator that allows to change the trace emitter. By default Python logging is used to emit the trace data.
[ "A", "decorator", "that", "allows", "to", "change", "the", "trace", "emitter", ".", "By", "default", "Python", "logging", "is", "used", "to", "emit", "the", "trace", "data", "." ]
4e559419b3d8e6859f83fa16557b00542d5f3aa7
https://github.com/viniciuschiele/flask-io/blob/4e559419b3d8e6859f83fa16557b00542d5f3aa7/flask_io/io.py#L296-L304
54,567
viniciuschiele/flask-io
flask_io/io.py
FlaskIO.__make_response
def __make_response(self, data, default_renderer=None): """ Creates a Flask response object from the specified data. The appropriated encoder is taken based on the request header Accept. If there is not data to be serialized the response status code is 204. :param data: The Pyth...
python
def __make_response(self, data, default_renderer=None): """ Creates a Flask response object from the specified data. The appropriated encoder is taken based on the request header Accept. If there is not data to be serialized the response status code is 204. :param data: The Pyth...
[ "def", "__make_response", "(", "self", ",", "data", ",", "default_renderer", "=", "None", ")", ":", "status", "=", "headers", "=", "None", "if", "isinstance", "(", "data", ",", "tuple", ")", ":", "data", ",", "status", ",", "headers", "=", "unpack", "(...
Creates a Flask response object from the specified data. The appropriated encoder is taken based on the request header Accept. If there is not data to be serialized the response status code is 204. :param data: The Python object to be serialized. :return: A Flask response object.
[ "Creates", "a", "Flask", "response", "object", "from", "the", "specified", "data", ".", "The", "appropriated", "encoder", "is", "taken", "based", "on", "the", "request", "header", "Accept", ".", "If", "there", "is", "not", "data", "to", "be", "serialized", ...
4e559419b3d8e6859f83fa16557b00542d5f3aa7
https://github.com/viniciuschiele/flask-io/blob/4e559419b3d8e6859f83fa16557b00542d5f3aa7/flask_io/io.py#L334-L369
54,568
lepture/terminal
examples/command.py
log
def log(verbose=False): """ print a log test :param verbose: show more logs """ terminal.log.config(verbose=verbose) terminal.log.info('this is a info message') terminal.log.verbose.info('this is a verbose message')
python
def log(verbose=False): """ print a log test :param verbose: show more logs """ terminal.log.config(verbose=verbose) terminal.log.info('this is a info message') terminal.log.verbose.info('this is a verbose message')
[ "def", "log", "(", "verbose", "=", "False", ")", ":", "terminal", ".", "log", ".", "config", "(", "verbose", "=", "verbose", ")", "terminal", ".", "log", ".", "info", "(", "'this is a info message'", ")", "terminal", ".", "log", ".", "verbose", ".", "i...
print a log test :param verbose: show more logs
[ "print", "a", "log", "test" ]
5226d1cac53077f12624aa51f64de7b5b05d9cb8
https://github.com/lepture/terminal/blob/5226d1cac53077f12624aa51f64de7b5b05d9cb8/examples/command.py#L25-L34
54,569
475Cumulus/TBone
tbone/resources/resources.py
Resource.wrap_handler
def wrap_handler(cls, handler, protocol, **kwargs): ''' Wrap a request handler with the matching protocol handler ''' def _wrapper(request, *args, **kwargs): instance = cls(request=request, **kwargs) if protocol == Resource.Protocol.http: return instance._wrap_htt...
python
def wrap_handler(cls, handler, protocol, **kwargs): ''' Wrap a request handler with the matching protocol handler ''' def _wrapper(request, *args, **kwargs): instance = cls(request=request, **kwargs) if protocol == Resource.Protocol.http: return instance._wrap_htt...
[ "def", "wrap_handler", "(", "cls", ",", "handler", ",", "protocol", ",", "*", "*", "kwargs", ")", ":", "def", "_wrapper", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "instance", "=", "cls", "(", "request", "=", "request", "...
Wrap a request handler with the matching protocol handler
[ "Wrap", "a", "request", "handler", "with", "the", "matching", "protocol", "handler" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/resources/resources.py#L201-L213
54,570
475Cumulus/TBone
tbone/resources/resources.py
Resource.as_view
def as_view(cls, endpoint, protocol, *init_args, **init_kwargs): ''' Used for hooking up the endpoints. Returns a wrapper function that creates a new instance of the resource class and calls the correct view method for it. ''' def _wrapper(request, *args, **kwargs): '...
python
def as_view(cls, endpoint, protocol, *init_args, **init_kwargs): ''' Used for hooking up the endpoints. Returns a wrapper function that creates a new instance of the resource class and calls the correct view method for it. ''' def _wrapper(request, *args, **kwargs): '...
[ "def", "as_view", "(", "cls", ",", "endpoint", ",", "protocol", ",", "*", "init_args", ",", "*", "*", "init_kwargs", ")", ":", "def", "_wrapper", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "''' Make a new instance of the resource ...
Used for hooking up the endpoints. Returns a wrapper function that creates a new instance of the resource class and calls the correct view method for it.
[ "Used", "for", "hooking", "up", "the", "endpoints", ".", "Returns", "a", "wrapper", "function", "that", "creates", "a", "new", "instance", "of", "the", "resource", "class", "and", "calls", "the", "correct", "view", "method", "for", "it", "." ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/resources/resources.py#L216-L233
54,571
475Cumulus/TBone
tbone/resources/resources.py
Resource.as_list
def as_list(cls, protocol=Protocol.http, *args, **kwargs): ''' returns list views ''' return cls.as_view('list', protocol, *args, **kwargs)
python
def as_list(cls, protocol=Protocol.http, *args, **kwargs): ''' returns list views ''' return cls.as_view('list', protocol, *args, **kwargs)
[ "def", "as_list", "(", "cls", ",", "protocol", "=", "Protocol", ".", "http", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "cls", ".", "as_view", "(", "'list'", ",", "protocol", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
returns list views
[ "returns", "list", "views" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/resources/resources.py#L236-L238
54,572
475Cumulus/TBone
tbone/resources/resources.py
Resource.as_detail
def as_detail(cls, protocol=Protocol.http, *args, **kwargs): ''' returns detail views ''' return cls.as_view('detail', protocol, *args, **kwargs)
python
def as_detail(cls, protocol=Protocol.http, *args, **kwargs): ''' returns detail views ''' return cls.as_view('detail', protocol, *args, **kwargs)
[ "def", "as_detail", "(", "cls", ",", "protocol", "=", "Protocol", ".", "http", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "cls", ".", "as_view", "(", "'detail'", ",", "protocol", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
returns detail views
[ "returns", "detail", "views" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/resources/resources.py#L241-L243
54,573
475Cumulus/TBone
tbone/resources/resources.py
Resource._wrap_http
async def _wrap_http(self, handler, *args, **kwargs): ''' wraps a handler with an HTTP request-response cycle''' try: method = self.request_method() # support preflight requests when CORS is enabled if method == 'OPTIONS': return self.build_http_respon...
python
async def _wrap_http(self, handler, *args, **kwargs): ''' wraps a handler with an HTTP request-response cycle''' try: method = self.request_method() # support preflight requests when CORS is enabled if method == 'OPTIONS': return self.build_http_respon...
[ "async", "def", "_wrap_http", "(", "self", ",", "handler", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "method", "=", "self", ".", "request_method", "(", ")", "# support preflight requests when CORS is enabled", "if", "method", "==", "'O...
wraps a handler with an HTTP request-response cycle
[ "wraps", "a", "handler", "with", "an", "HTTP", "request", "-", "response", "cycle" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/resources/resources.py#L245-L258
54,574
475Cumulus/TBone
tbone/resources/resources.py
Resource._wrap_ws
async def _wrap_ws(self, handler, *args, **kwargs): ''' wraps a handler by receiving a websocket request and returning a websocket response ''' try: method = self.request_method() # call the wrapped handler data = await handler(self, *args, **kwargs) statu...
python
async def _wrap_ws(self, handler, *args, **kwargs): ''' wraps a handler by receiving a websocket request and returning a websocket response ''' try: method = self.request_method() # call the wrapped handler data = await handler(self, *args, **kwargs) statu...
[ "async", "def", "_wrap_ws", "(", "self", ",", "handler", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "method", "=", "self", ".", "request_method", "(", ")", "# call the wrapped handler", "data", "=", "await", "handler", "(", "self", ...
wraps a handler by receiving a websocket request and returning a websocket response
[ "wraps", "a", "handler", "by", "receiving", "a", "websocket", "request", "and", "returning", "a", "websocket", "response" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/resources/resources.py#L260-L281
54,575
475Cumulus/TBone
tbone/resources/resources.py
Resource.dispatch
async def dispatch(self, *args, **kwargs): ''' This method handles the actual request to the resource. It performs all the neccesary checks and then executes the relevant member method which is mapped to the method name. Handles authentication and de-serialization before calling the requ...
python
async def dispatch(self, *args, **kwargs): ''' This method handles the actual request to the resource. It performs all the neccesary checks and then executes the relevant member method which is mapped to the method name. Handles authentication and de-serialization before calling the requ...
[ "async", "def", "dispatch", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "method", "=", "self", ".", "request_method", "(", ")", "# get the db object associated with the app and assign to resource", "if", "hasattr", "(", "self", ".", "reques...
This method handles the actual request to the resource. It performs all the neccesary checks and then executes the relevant member method which is mapped to the method name. Handles authentication and de-serialization before calling the required method. Handles the serialization of the response
[ "This", "method", "handles", "the", "actual", "request", "to", "the", "resource", ".", "It", "performs", "all", "the", "neccesary", "checks", "and", "then", "executes", "the", "relevant", "member", "method", "which", "is", "mapped", "to", "the", "method", "n...
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/resources/resources.py#L311-L352
54,576
475Cumulus/TBone
tbone/resources/resources.py
Resource.dispatch_error
def dispatch_error(self, err): ''' Handles the dispatch of errors ''' try: data = {'error': [l for l in err.args]} body = self._meta.formatter.format(data) except Exception as ex: data = {'error': str(err)} body = self._meta.formatt...
python
def dispatch_error(self, err): ''' Handles the dispatch of errors ''' try: data = {'error': [l for l in err.args]} body = self._meta.formatter.format(data) except Exception as ex: data = {'error': str(err)} body = self._meta.formatt...
[ "def", "dispatch_error", "(", "self", ",", "err", ")", ":", "try", ":", "data", "=", "{", "'error'", ":", "[", "l", "for", "l", "in", "err", ".", "args", "]", "}", "body", "=", "self", ".", "_meta", ".", "formatter", ".", "format", "(", "data", ...
Handles the dispatch of errors
[ "Handles", "the", "dispatch", "of", "errors" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/resources/resources.py#L354-L366
54,577
475Cumulus/TBone
tbone/resources/resources.py
Resource.parse
def parse(self, method, endpoint, body): ''' calls parse on list or detail ''' if isinstance(body, dict): # request body was already parsed return body if endpoint == 'list': return self.parse_list(body) return self.parse_detail(body)
python
def parse(self, method, endpoint, body): ''' calls parse on list or detail ''' if isinstance(body, dict): # request body was already parsed return body if endpoint == 'list': return self.parse_list(body) return self.parse_detail(body)
[ "def", "parse", "(", "self", ",", "method", ",", "endpoint", ",", "body", ")", ":", "if", "isinstance", "(", "body", ",", "dict", ")", ":", "# request body was already parsed", "return", "body", "if", "endpoint", "==", "'list'", ":", "return", "self", ".",...
calls parse on list or detail
[ "calls", "parse", "on", "list", "or", "detail" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/resources/resources.py#L406-L413
54,578
475Cumulus/TBone
tbone/resources/resources.py
Resource.add_hypermedia
def add_hypermedia(self, obj): ''' Adds HATEOAS links to the resource. Adds href link to self. Override in subclasses to include additional functionality ''' if hasattr(self, 'pk'): obj['_links'] = { 'self': { 'href': '{}{}/'.format...
python
def add_hypermedia(self, obj): ''' Adds HATEOAS links to the resource. Adds href link to self. Override in subclasses to include additional functionality ''' if hasattr(self, 'pk'): obj['_links'] = { 'self': { 'href': '{}{}/'.format...
[ "def", "add_hypermedia", "(", "self", ",", "obj", ")", ":", "if", "hasattr", "(", "self", ",", "'pk'", ")", ":", "obj", "[", "'_links'", "]", "=", "{", "'self'", ":", "{", "'href'", ":", "'{}{}/'", ".", "format", "(", "self", ".", "get_resource_uri",...
Adds HATEOAS links to the resource. Adds href link to self. Override in subclasses to include additional functionality
[ "Adds", "HATEOAS", "links", "to", "the", "resource", ".", "Adds", "href", "link", "to", "self", ".", "Override", "in", "subclasses", "to", "include", "additional", "functionality" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/resources/resources.py#L425-L435
54,579
475Cumulus/TBone
tbone/resources/resources.py
Resource.format
def format(self, method, data): ''' Calls format on list or detail ''' if data is None: if method == 'GET': raise NotFound() return '' return self._meta.formatter.format(data)
python
def format(self, method, data): ''' Calls format on list or detail ''' if data is None: if method == 'GET': raise NotFound() return '' return self._meta.formatter.format(data)
[ "def", "format", "(", "self", ",", "method", ",", "data", ")", ":", "if", "data", "is", "None", ":", "if", "method", "==", "'GET'", ":", "raise", "NotFound", "(", ")", "return", "''", "return", "self", ".", "_meta", ".", "formatter", ".", "format", ...
Calls format on list or detail
[ "Calls", "format", "on", "list", "or", "detail" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/resources/resources.py#L437-L444
54,580
Min-ops/cruddy
cruddy/scripts/cli.py
cli
def cli(ctx, profile, region, lambda_fn, config, debug): """ cruddy is a CLI interface to the cruddy handler. It can be used in one of two ways. First, you can pass in a ``--config`` option which is a JSON file containing all of your cruddy parameters and the CLI will create a cruddy handler t...
python
def cli(ctx, profile, region, lambda_fn, config, debug): """ cruddy is a CLI interface to the cruddy handler. It can be used in one of two ways. First, you can pass in a ``--config`` option which is a JSON file containing all of your cruddy parameters and the CLI will create a cruddy handler t...
[ "def", "cli", "(", "ctx", ",", "profile", ",", "region", ",", "lambda_fn", ",", "config", ",", "debug", ")", ":", "ctx", ".", "obj", "=", "CLIHandler", "(", "profile", ",", "region", ",", "lambda_fn", ",", "config", ",", "debug", ")" ]
cruddy is a CLI interface to the cruddy handler. It can be used in one of two ways. First, you can pass in a ``--config`` option which is a JSON file containing all of your cruddy parameters and the CLI will create a cruddy handler to manipulate the DynamoDB table directly. Alternatively, you can...
[ "cruddy", "is", "a", "CLI", "interface", "to", "the", "cruddy", "handler", ".", "It", "can", "be", "used", "in", "one", "of", "two", "ways", "." ]
b9ba3dda1757e1075bc1c62a6f43473eea27de41
https://github.com/Min-ops/cruddy/blob/b9ba3dda1757e1075bc1c62a6f43473eea27de41/cruddy/scripts/cli.py#L90-L104
54,581
Min-ops/cruddy
cruddy/scripts/cli.py
get
def get(handler, item_id, decrypt): """Get an item""" data = {'operation': 'get', 'decrypt': decrypt, 'id': item_id} handler.invoke(data)
python
def get(handler, item_id, decrypt): """Get an item""" data = {'operation': 'get', 'decrypt': decrypt, 'id': item_id} handler.invoke(data)
[ "def", "get", "(", "handler", ",", "item_id", ",", "decrypt", ")", ":", "data", "=", "{", "'operation'", ":", "'get'", ",", "'decrypt'", ":", "decrypt", ",", "'id'", ":", "item_id", "}", "handler", ".", "invoke", "(", "data", ")" ]
Get an item
[ "Get", "an", "item" ]
b9ba3dda1757e1075bc1c62a6f43473eea27de41
https://github.com/Min-ops/cruddy/blob/b9ba3dda1757e1075bc1c62a6f43473eea27de41/cruddy/scripts/cli.py#L130-L135
54,582
Min-ops/cruddy
cruddy/scripts/cli.py
increment
def increment(handler, increment, item_id, counter_name): """Increment a counter attribute atomically""" data = {'operation': 'increment_counter', 'id': item_id, 'counter_name': counter_name, 'increment': increment} handler.invoke(data)
python
def increment(handler, increment, item_id, counter_name): """Increment a counter attribute atomically""" data = {'operation': 'increment_counter', 'id': item_id, 'counter_name': counter_name, 'increment': increment} handler.invoke(data)
[ "def", "increment", "(", "handler", ",", "increment", ",", "item_id", ",", "counter_name", ")", ":", "data", "=", "{", "'operation'", ":", "'increment_counter'", ",", "'id'", ":", "item_id", ",", "'counter_name'", ":", "counter_name", ",", "'increment'", ":", ...
Increment a counter attribute atomically
[ "Increment", "a", "counter", "attribute", "atomically" ]
b9ba3dda1757e1075bc1c62a6f43473eea27de41
https://github.com/Min-ops/cruddy/blob/b9ba3dda1757e1075bc1c62a6f43473eea27de41/cruddy/scripts/cli.py#L175-L181
54,583
Min-ops/cruddy
cruddy/scripts/cli.py
create
def create(handler, item_document): """Create a new item from a JSON document""" data = {'operation': 'create', 'item': json.load(item_document)} handler.invoke(data)
python
def create(handler, item_document): """Create a new item from a JSON document""" data = {'operation': 'create', 'item': json.load(item_document)} handler.invoke(data)
[ "def", "create", "(", "handler", ",", "item_document", ")", ":", "data", "=", "{", "'operation'", ":", "'create'", ",", "'item'", ":", "json", ".", "load", "(", "item_document", ")", "}", "handler", ".", "invoke", "(", "data", ")" ]
Create a new item from a JSON document
[ "Create", "a", "new", "item", "from", "a", "JSON", "document" ]
b9ba3dda1757e1075bc1c62a6f43473eea27de41
https://github.com/Min-ops/cruddy/blob/b9ba3dda1757e1075bc1c62a6f43473eea27de41/cruddy/scripts/cli.py#L187-L191
54,584
Min-ops/cruddy
cruddy/scripts/cli.py
update
def update(handler, item_document): """Update an item from a JSON document""" data = {'operation': 'update', 'encrypt': encrypt, 'item': json.load(item_document)} handler.invoke(data)
python
def update(handler, item_document): """Update an item from a JSON document""" data = {'operation': 'update', 'encrypt': encrypt, 'item': json.load(item_document)} handler.invoke(data)
[ "def", "update", "(", "handler", ",", "item_document", ")", ":", "data", "=", "{", "'operation'", ":", "'update'", ",", "'encrypt'", ":", "encrypt", ",", "'item'", ":", "json", ".", "load", "(", "item_document", ")", "}", "handler", ".", "invoke", "(", ...
Update an item from a JSON document
[ "Update", "an", "item", "from", "a", "JSON", "document" ]
b9ba3dda1757e1075bc1c62a6f43473eea27de41
https://github.com/Min-ops/cruddy/blob/b9ba3dda1757e1075bc1c62a6f43473eea27de41/cruddy/scripts/cli.py#L201-L206
54,585
Min-ops/cruddy
cruddy/scripts/cli.py
help
def help(handler): """ Returns a Markdown document that describes this handler and it's operations. """ data = {'operation': 'describe'} response = handler.invoke(data, raw=True) description = response.data lines = [] lines.append('# {}'.format(handler.lambda_fn)) lines.append('#...
python
def help(handler): """ Returns a Markdown document that describes this handler and it's operations. """ data = {'operation': 'describe'} response = handler.invoke(data, raw=True) description = response.data lines = [] lines.append('# {}'.format(handler.lambda_fn)) lines.append('#...
[ "def", "help", "(", "handler", ")", ":", "data", "=", "{", "'operation'", ":", "'describe'", "}", "response", "=", "handler", ".", "invoke", "(", "data", ",", "raw", "=", "True", ")", "description", "=", "response", ".", "data", "lines", "=", "[", "]...
Returns a Markdown document that describes this handler and it's operations.
[ "Returns", "a", "Markdown", "document", "that", "describes", "this", "handler", "and", "it", "s", "operations", "." ]
b9ba3dda1757e1075bc1c62a6f43473eea27de41
https://github.com/Min-ops/cruddy/blob/b9ba3dda1757e1075bc1c62a6f43473eea27de41/cruddy/scripts/cli.py#L231-L271
54,586
475Cumulus/TBone
tbone/data/fields/base.py
BaseField._check_required
def _check_required(self, value): ''' Internal method to check if assigned value is None while it is required. Exception is thrown if ``True`` ''' if value is None and self._required: err_msg = self._errors['required'].format(self.__class__.__name__, self.name) ...
python
def _check_required(self, value): ''' Internal method to check if assigned value is None while it is required. Exception is thrown if ``True`` ''' if value is None and self._required: err_msg = self._errors['required'].format(self.__class__.__name__, self.name) ...
[ "def", "_check_required", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", "and", "self", ".", "_required", ":", "err_msg", "=", "self", ".", "_errors", "[", "'required'", "]", ".", "format", "(", "self", ".", "__class__", ".", "__name...
Internal method to check if assigned value is None while it is required. Exception is thrown if ``True``
[ "Internal", "method", "to", "check", "if", "assigned", "value", "is", "None", "while", "it", "is", "required", ".", "Exception", "is", "thrown", "if", "True" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/data/fields/base.py#L220-L229
54,587
475Cumulus/TBone
tbone/data/fields/base.py
BaseField.to_data
def to_data(self, value): ''' Coerce python data type to simple form for serialization. If default value was defined returns the default value if None was passed. Throw exception is value is ``None`` is ``required`` is set to ``True`` ''' try: if value is None...
python
def to_data(self, value): ''' Coerce python data type to simple form for serialization. If default value was defined returns the default value if None was passed. Throw exception is value is ``None`` is ``required`` is set to ``True`` ''' try: if value is None...
[ "def", "to_data", "(", "self", ",", "value", ")", ":", "try", ":", "if", "value", "is", "None", "and", "self", ".", "_default", "is", "not", "None", ":", "return", "self", ".", "_export", "(", "self", ".", "default", ")", "self", ".", "_check_require...
Coerce python data type to simple form for serialization. If default value was defined returns the default value if None was passed. Throw exception is value is ``None`` is ``required`` is set to ``True``
[ "Coerce", "python", "data", "type", "to", "simple", "form", "for", "serialization", ".", "If", "default", "value", "was", "defined", "returns", "the", "default", "value", "if", "None", "was", "passed", ".", "Throw", "exception", "is", "value", "is", "None", ...
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/data/fields/base.py#L231-L244
54,588
475Cumulus/TBone
tbone/data/fields/base.py
BaseField.serialize
async def serialize(self, value, native=False): ''' Calls the field's ``to_python`` method. Override in derived classes of fields which involve models, such as ``ModelField`` ''' if native: return self.to_python(value) return self.to_data(value)
python
async def serialize(self, value, native=False): ''' Calls the field's ``to_python`` method. Override in derived classes of fields which involve models, such as ``ModelField`` ''' if native: return self.to_python(value) return self.to_data(value)
[ "async", "def", "serialize", "(", "self", ",", "value", ",", "native", "=", "False", ")", ":", "if", "native", ":", "return", "self", ".", "to_python", "(", "value", ")", "return", "self", ".", "to_data", "(", "value", ")" ]
Calls the field's ``to_python`` method. Override in derived classes of fields which involve models, such as ``ModelField``
[ "Calls", "the", "field", "s", "to_python", "method", ".", "Override", "in", "derived", "classes", "of", "fields", "which", "involve", "models", "such", "as", "ModelField" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/data/fields/base.py#L262-L269
54,589
475Cumulus/TBone
tbone/data/fields/base.py
BaseField.add_to_class
def add_to_class(self, cls, name): ''' Hook that replaces the `Field` attribute on a class with a named ``FieldDescriptor``. Called by the metaclass during construction of the ``Model``. ''' self._name = name self._container_model_class = cls setattr(cls, ...
python
def add_to_class(self, cls, name): ''' Hook that replaces the `Field` attribute on a class with a named ``FieldDescriptor``. Called by the metaclass during construction of the ``Model``. ''' self._name = name self._container_model_class = cls setattr(cls, ...
[ "def", "add_to_class", "(", "self", ",", "cls", ",", "name", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_container_model_class", "=", "cls", "setattr", "(", "cls", ",", "name", ",", "FieldDescriptor", "(", "self", ")", ")", "self", ".",...
Hook that replaces the `Field` attribute on a class with a named ``FieldDescriptor``. Called by the metaclass during construction of the ``Model``.
[ "Hook", "that", "replaces", "the", "Field", "attribute", "on", "a", "class", "with", "a", "named", "FieldDescriptor", ".", "Called", "by", "the", "metaclass", "during", "construction", "of", "the", "Model", "." ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/data/fields/base.py#L286-L295
54,590
kratsg/ironman
ironman/utilities.py
byteswap
def byteswap(data, word_size=4): """ Swap the byte-ordering in a packet with N=4 bytes per word """ return reduce(lambda x,y: x+''.join(reversed(y)), chunks(data, word_size), '')
python
def byteswap(data, word_size=4): """ Swap the byte-ordering in a packet with N=4 bytes per word """ return reduce(lambda x,y: x+''.join(reversed(y)), chunks(data, word_size), '')
[ "def", "byteswap", "(", "data", ",", "word_size", "=", "4", ")", ":", "return", "reduce", "(", "lambda", "x", ",", "y", ":", "x", "+", "''", ".", "join", "(", "reversed", "(", "y", ")", ")", ",", "chunks", "(", "data", ",", "word_size", ")", ",...
Swap the byte-ordering in a packet with N=4 bytes per word
[ "Swap", "the", "byte", "-", "ordering", "in", "a", "packet", "with", "N", "=", "4", "bytes", "per", "word" ]
7d67b79970870e7e5520181d2afa3f423e46eb3a
https://github.com/kratsg/ironman/blob/7d67b79970870e7e5520181d2afa3f423e46eb3a/ironman/utilities.py#L7-L10
54,591
brocade/pynos
pynos/versions/base/vcs.py
VCS.vcs_vip
def vcs_vip(self, **kwargs): """Set VCS Virtual IP. Args: vip (str): IPv4/IPv6 Virtual IP Address. rbridge_id (str): rbridge-id for device. Only required when type is `ve`. delete (bool): Deletes the virtual ip if `delete` is ``True``. get...
python
def vcs_vip(self, **kwargs): """Set VCS Virtual IP. Args: vip (str): IPv4/IPv6 Virtual IP Address. rbridge_id (str): rbridge-id for device. Only required when type is `ve`. delete (bool): Deletes the virtual ip if `delete` is ``True``. get...
[ "def", "vcs_vip", "(", "self", ",", "*", "*", "kwargs", ")", ":", "get_config", "=", "kwargs", ".", "pop", "(", "'get'", ",", "False", ")", "delete", "=", "kwargs", ".", "pop", "(", "'delete'", ",", "False", ")", "callback", "=", "kwargs", ".", "po...
Set VCS Virtual IP. Args: vip (str): IPv4/IPv6 Virtual IP Address. rbridge_id (str): rbridge-id for device. Only required when type is `ve`. delete (bool): Deletes the virtual ip if `delete` is ``True``. get (bool): Get config instead of editing c...
[ "Set", "VCS", "Virtual", "IP", "." ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/vcs.py#L78-L164
54,592
brocade/pynos
pynos/versions/base/bgp.py
BGP.get_bgp_neighbors
def get_bgp_neighbors(self, **kwargs): """Get BGP neighbors configured on a device. Args: rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. vrf (str): The VRF for this BGP process. callback (function): A f...
python
def get_bgp_neighbors(self, **kwargs): """Get BGP neighbors configured on a device. Args: rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. vrf (str): The VRF for this BGP process. callback (function): A f...
[ "def", "get_bgp_neighbors", "(", "self", ",", "*", "*", "kwargs", ")", ":", "callback", "=", "kwargs", ".", "pop", "(", "'callback'", ",", "self", ".", "_callback", ")", "neighbor_args", "=", "dict", "(", "router_bgp_neighbor_address", "=", "''", ",", "rem...
Get BGP neighbors configured on a device. Args: rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. vrf (str): The VRF for this BGP process. callback (function): A function executed upon completion of the ...
[ "Get", "BGP", "neighbors", "configured", "on", "a", "device", "." ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/bgp.py#L268-L350
54,593
brocade/pynos
pynos/versions/base/bgp.py
BGP.multihop
def multihop(self, **kwargs): """Set BGP multihop property for a neighbor. Args: vrf (str): The VRF for this BGP process. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. neighbor (str): Address family to...
python
def multihop(self, **kwargs): """Set BGP multihop property for a neighbor. Args: vrf (str): The VRF for this BGP process. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. neighbor (str): Address family to...
[ "def", "multihop", "(", "self", ",", "*", "*", "kwargs", ")", ":", "callback", "=", "kwargs", ".", "pop", "(", "'callback'", ",", "self", ".", "_callback", ")", "ip_addr", "=", "ip_interface", "(", "unicode", "(", "kwargs", ".", "pop", "(", "'neighbor'...
Set BGP multihop property for a neighbor. Args: vrf (str): The VRF for this BGP process. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. neighbor (str): Address family to configure. (ipv4, ipv6) coun...
[ "Set", "BGP", "multihop", "property", "for", "a", "neighbor", "." ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/bgp.py#L637-L704
54,594
brocade/pynos
pynos/versions/base/bgp.py
BGP.update_source
def update_source(self, **kwargs): """Set BGP update source property for a neighbor. This method currently only supports loopback interfaces. Args: vrf (str): The VRF for this BGP process. rbridge_id (str): The rbridge ID of the device on which BGP will be ...
python
def update_source(self, **kwargs): """Set BGP update source property for a neighbor. This method currently only supports loopback interfaces. Args: vrf (str): The VRF for this BGP process. rbridge_id (str): The rbridge ID of the device on which BGP will be ...
[ "def", "update_source", "(", "self", ",", "*", "*", "kwargs", ")", ":", "callback", "=", "kwargs", ".", "pop", "(", "'callback'", ",", "self", ".", "_callback", ")", "ip_addr", "=", "ip_interface", "(", "unicode", "(", "kwargs", ".", "pop", "(", "'neig...
Set BGP update source property for a neighbor. This method currently only supports loopback interfaces. Args: vrf (str): The VRF for this BGP process. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. nei...
[ "Set", "BGP", "update", "source", "property", "for", "a", "neighbor", "." ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/bgp.py#L763-L848
54,595
audreyr/standardjson
standardjson/encoder_funcs.py
encode_datetime
def encode_datetime(o): """ Encodes a Python datetime.datetime object as an ECMA-262 compliant datetime string.""" r = o.isoformat() if o.microsecond: r = r[:23] + r[26:] if r.endswith('+00:00'): r = r[:-6] + 'Z' return r
python
def encode_datetime(o): """ Encodes a Python datetime.datetime object as an ECMA-262 compliant datetime string.""" r = o.isoformat() if o.microsecond: r = r[:23] + r[26:] if r.endswith('+00:00'): r = r[:-6] + 'Z' return r
[ "def", "encode_datetime", "(", "o", ")", ":", "r", "=", "o", ".", "isoformat", "(", ")", "if", "o", ".", "microsecond", ":", "r", "=", "r", "[", ":", "23", "]", "+", "r", "[", "26", ":", "]", "if", "r", ".", "endswith", "(", "'+00:00'", ")", ...
Encodes a Python datetime.datetime object as an ECMA-262 compliant datetime string.
[ "Encodes", "a", "Python", "datetime", ".", "datetime", "object", "as", "an", "ECMA", "-", "262", "compliant", "datetime", "string", "." ]
5b275bb8158703eb77114ce9b632716c4201b675
https://github.com/audreyr/standardjson/blob/5b275bb8158703eb77114ce9b632716c4201b675/standardjson/encoder_funcs.py#L3-L11
54,596
audreyr/standardjson
standardjson/encoder_funcs.py
encode_time
def encode_time(o): """ Encodes a Python datetime.time object as an ECMA-262 compliant time string.""" r = o.isoformat() if o.microsecond: r = r[:12] if r.endswith('+00:00'): r = r[:-6] + 'Z' return r
python
def encode_time(o): """ Encodes a Python datetime.time object as an ECMA-262 compliant time string.""" r = o.isoformat() if o.microsecond: r = r[:12] if r.endswith('+00:00'): r = r[:-6] + 'Z' return r
[ "def", "encode_time", "(", "o", ")", ":", "r", "=", "o", ".", "isoformat", "(", ")", "if", "o", ".", "microsecond", ":", "r", "=", "r", "[", ":", "12", "]", "if", "r", ".", "endswith", "(", "'+00:00'", ")", ":", "r", "=", "r", "[", ":", "-"...
Encodes a Python datetime.time object as an ECMA-262 compliant time string.
[ "Encodes", "a", "Python", "datetime", ".", "time", "object", "as", "an", "ECMA", "-", "262", "compliant", "time", "string", "." ]
5b275bb8158703eb77114ce9b632716c4201b675
https://github.com/audreyr/standardjson/blob/5b275bb8158703eb77114ce9b632716c4201b675/standardjson/encoder_funcs.py#L18-L26
54,597
lepture/terminal
terminal/color.py
is_color_supported
def is_color_supported(): "Find out if your terminal environment supports color." # shinx.util.console if not hasattr(sys.stdout, 'isatty'): return False if not sys.stdout.isatty() and 'TERMINAL-COLOR' not in os.environ: return False if sys.platform == 'win32': # pragma: no cover ...
python
def is_color_supported(): "Find out if your terminal environment supports color." # shinx.util.console if not hasattr(sys.stdout, 'isatty'): return False if not sys.stdout.isatty() and 'TERMINAL-COLOR' not in os.environ: return False if sys.platform == 'win32': # pragma: no cover ...
[ "def", "is_color_supported", "(", ")", ":", "# shinx.util.console", "if", "not", "hasattr", "(", "sys", ".", "stdout", ",", "'isatty'", ")", ":", "return", "False", "if", "not", "sys", ".", "stdout", ".", "isatty", "(", ")", "and", "'TERMINAL-COLOR'", "not...
Find out if your terminal environment supports color.
[ "Find", "out", "if", "your", "terminal", "environment", "supports", "color", "." ]
5226d1cac53077f12624aa51f64de7b5b05d9cb8
https://github.com/lepture/terminal/blob/5226d1cac53077f12624aa51f64de7b5b05d9cb8/terminal/color.py#L26-L47
54,598
lepture/terminal
terminal/color.py
rgb2ansi
def rgb2ansi(r, g, b): """ Convert an RGB color to 256 ansi graphics. """ # Thanks to # https://github.com/tehmaze/ansi/blob/master/ansi/colour/rgb.py grayscale = False poss = True step = 2.5 while poss: if min(r, g, b) < step: grayscale = max(r, g, b) < step ...
python
def rgb2ansi(r, g, b): """ Convert an RGB color to 256 ansi graphics. """ # Thanks to # https://github.com/tehmaze/ansi/blob/master/ansi/colour/rgb.py grayscale = False poss = True step = 2.5 while poss: if min(r, g, b) < step: grayscale = max(r, g, b) < step ...
[ "def", "rgb2ansi", "(", "r", ",", "g", ",", "b", ")", ":", "# Thanks to", "# https://github.com/tehmaze/ansi/blob/master/ansi/colour/rgb.py", "grayscale", "=", "False", "poss", "=", "True", "step", "=", "2.5", "while", "poss", ":", "if", "min", "(", "r", ",", ...
Convert an RGB color to 256 ansi graphics.
[ "Convert", "an", "RGB", "color", "to", "256", "ansi", "graphics", "." ]
5226d1cac53077f12624aa51f64de7b5b05d9cb8
https://github.com/lepture/terminal/blob/5226d1cac53077f12624aa51f64de7b5b05d9cb8/terminal/color.py#L58-L81
54,599
lepture/terminal
terminal/color.py
hex2ansi
def hex2ansi(code): """ Convert hex code to ansi. """ if code.startswith('#'): code = code[1:] if len(code) == 3: # efc -> eeffcc return rgb2ansi(*map(lambda o: int(o * 2, 16), code)) if len(code) != 6: raise ValueError('invalid color code') rgb = (code[:2...
python
def hex2ansi(code): """ Convert hex code to ansi. """ if code.startswith('#'): code = code[1:] if len(code) == 3: # efc -> eeffcc return rgb2ansi(*map(lambda o: int(o * 2, 16), code)) if len(code) != 6: raise ValueError('invalid color code') rgb = (code[:2...
[ "def", "hex2ansi", "(", "code", ")", ":", "if", "code", ".", "startswith", "(", "'#'", ")", ":", "code", "=", "code", "[", "1", ":", "]", "if", "len", "(", "code", ")", "==", "3", ":", "# efc -> eeffcc", "return", "rgb2ansi", "(", "*", "map", "("...
Convert hex code to ansi.
[ "Convert", "hex", "code", "to", "ansi", "." ]
5226d1cac53077f12624aa51f64de7b5b05d9cb8
https://github.com/lepture/terminal/blob/5226d1cac53077f12624aa51f64de7b5b05d9cb8/terminal/color.py#L84-L100