hexsha
stringlengths
40
40
repo
stringlengths
7
114
path
stringlengths
4
124
license
listlengths
1
9
language
stringclasses
1 value
identifier
stringlengths
1
71
return_type
stringlengths
1
749
original_string
stringlengths
76
22.7k
original_docstring
stringlengths
16
7.61k
docstring
stringlengths
16
2.47k
docstring_tokens
listlengths
6
477
code
stringlengths
14
10.2k
code_tokens
listlengths
6
996
short_docstring
stringlengths
2
644
short_docstring_tokens
listlengths
1
116
comment
listlengths
1
89
parameters
listlengths
0
64
docstring_params
dict
aac009c76767a3e31fbcac772a688609c4cb2289
Azure-Samples/key-vault-python-storage-accounts
storage_account_sample.py
[ "MIT" ]
Python
add_storage_account
null
def add_storage_account(self): """ Creates a storage account then adds the storage account to the vault to manage its keys. """ from azure.mgmt.storage import StorageManagementClient from azure.mgmt.storage.models import StorageAccountCreateParameters, Sku, SkuName, Kind ...
Creates a storage account then adds the storage account to the vault to manage its keys.
Creates a storage account then adds the storage account to the vault to manage its keys.
[ "Creates", "a", "storage", "account", "then", "adds", "the", "storage", "account", "to", "the", "vault", "to", "manage", "its", "keys", "." ]
def add_storage_account(self): from azure.mgmt.storage import StorageManagementClient from azure.mgmt.storage.models import StorageAccountCreateParameters, Sku, SkuName, Kind from msrestazure.azure_active_directory import AADTokenCredentials from azure.mgmt.authorization.models import Ro...
[ "def", "add_storage_account", "(", "self", ")", ":", "from", "azure", ".", "mgmt", ".", "storage", "import", "StorageManagementClient", "from", "azure", ".", "mgmt", ".", "storage", ".", "models", "import", "StorageAccountCreateParameters", ",", "Sku", ",", "Sku...
Creates a storage account then adds the storage account to the vault to manage its keys.
[ "Creates", "a", "storage", "account", "then", "adds", "the", "storage", "account", "to", "the", "vault", "to", "manage", "its", "keys", "." ]
[ "\"\"\"\n Creates a storage account then adds the storage account to the vault to manage its keys.\n \"\"\"", "# only user accounts with access to the storage account keys can add a storage account to", "# a vault. For this reason this sample creates the storage account with a user account", "#...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
aac009c76767a3e31fbcac772a688609c4cb2289
Azure-Samples/key-vault-python-storage-accounts
storage_account_sample.py
[ "MIT" ]
Python
update_storage_account
null
def update_storage_account(self): """ Updates a storage account in the vault. """ # switch the active key for the storage account print('updating storage account active key') self.keyvault_sp_client.update_storage_account(vault_base_url=self.sample_vault_url, ...
Updates a storage account in the vault.
Updates a storage account in the vault.
[ "Updates", "a", "storage", "account", "in", "the", "vault", "." ]
def update_storage_account(self): print('updating storage account active key') self.keyvault_sp_client.update_storage_account(vault_base_url=self.sample_vault_url, storage_account_name=self.config.storage_account_name, ...
[ "def", "update_storage_account", "(", "self", ")", ":", "print", "(", "'updating storage account active key'", ")", "self", ".", "keyvault_sp_client", ".", "update_storage_account", "(", "vault_base_url", "=", "self", ".", "sample_vault_url", ",", "storage_account_name", ...
Updates a storage account in the vault.
[ "Updates", "a", "storage", "account", "in", "the", "vault", "." ]
[ "\"\"\"\n Updates a storage account in the vault.\n \"\"\"", "# switch the active key for the storage account", "# update the key regeneration period", "# self.keyvault_sp_client.update_storage_account(vault_base_url=self.sample_vault_url,", "# st...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
aac009c76767a3e31fbcac772a688609c4cb2289
Azure-Samples/key-vault-python-storage-accounts
storage_account_sample.py
[ "MIT" ]
Python
regenerate_storage_account_key
null
def regenerate_storage_account_key(self): """ Regenerates a key of a storage account managed by the vault. """ # regenerate storage account keys by calling the regenerate_storage_account_key # Note that the regenerate_storage_account_key method can only be called by a user accoun...
Regenerates a key of a storage account managed by the vault.
Regenerates a key of a storage account managed by the vault.
[ "Regenerates", "a", "key", "of", "a", "storage", "account", "managed", "by", "the", "vault", "." ]
def regenerate_storage_account_key(self): print('regenerating storage account key1') self.keyvault_user_client.regenerate_storage_account_key(vault_base_url=self.sample_vault_url, storage_account_name=self.config.storage_account_name, ...
[ "def", "regenerate_storage_account_key", "(", "self", ")", ":", "print", "(", "'regenerating storage account key1'", ")", "self", ".", "keyvault_user_client", ".", "regenerate_storage_account_key", "(", "vault_base_url", "=", "self", ".", "sample_vault_url", ",", "storage...
Regenerates a key of a storage account managed by the vault.
[ "Regenerates", "a", "key", "of", "a", "storage", "account", "managed", "by", "the", "vault", "." ]
[ "\"\"\"\n Regenerates a key of a storage account managed by the vault.\n \"\"\"", "# regenerate storage account keys by calling the regenerate_storage_account_key", "# Note that the regenerate_storage_account_key method can only be called by a user account", "# not a service principal so we use ...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
aac009c76767a3e31fbcac772a688609c4cb2289
Azure-Samples/key-vault-python-storage-accounts
storage_account_sample.py
[ "MIT" ]
Python
delete_storage_account
null
def delete_storage_account(self): """ Deletes a storage account from a vault. """ print('deleting storage account %s from the vault' % self.config.storage_account_name) self.keyvault_sp_client.delete_storage_account(vault_base_url=self.sample_vault_url, ...
Deletes a storage account from a vault.
Deletes a storage account from a vault.
[ "Deletes", "a", "storage", "account", "from", "a", "vault", "." ]
def delete_storage_account(self): print('deleting storage account %s from the vault' % self.config.storage_account_name) self.keyvault_sp_client.delete_storage_account(vault_base_url=self.sample_vault_url, storage_account_name=self.config.storage_ac...
[ "def", "delete_storage_account", "(", "self", ")", ":", "print", "(", "'deleting storage account %s from the vault'", "%", "self", ".", "config", ".", "storage_account_name", ")", "self", ".", "keyvault_sp_client", ".", "delete_storage_account", "(", "vault_base_url", "...
Deletes a storage account from a vault.
[ "Deletes", "a", "storage", "account", "from", "a", "vault", "." ]
[ "\"\"\"\n Deletes a storage account from a vault.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc8586ecfc08bd0f1086623585b11cfbd98bac5f
Apache-HB/aiorule34
aiorule34/aiorule34.py
[ "Apache-2.0" ]
Python
rule34get
List[Rule34Image]
async def rule34get(tags = None, limit: int = 50, pid: int = None) -> List[Rule34Image]: '''Fetch a certain amount of images asyncronously from rule34.xxx Parameters ---------- tags: Optional[:class:`str`,`list`] the tags to search for if passing a string the tags must be seperated by one whitespace each limi...
Fetch a certain amount of images asyncronously from rule34.xxx Parameters ---------- tags: Optional[:class:`str`,`list`] the tags to search for if passing a string the tags must be seperated by one whitespace each limit: Optional[:class:`int`] the amount of images to retrive from rule34 must be between 1 a...
Fetch a certain amount of images asyncronously from rule34.xxx Parameters Raises when both tags and pid are passed, neither tags or pid are passed or when limit is out of range of 1 and 100 as per api rules when nothing is found from the search Yields list [:class:`Rule34Image`] a list of image objects fetched f...
[ "Fetch", "a", "certain", "amount", "of", "images", "asyncronously", "from", "rule34", ".", "xxx", "Parameters", "Raises", "when", "both", "tags", "and", "pid", "are", "passed", "neither", "tags", "or", "pid", "are", "passed", "or", "when", "limit", "is", "...
async def rule34get(tags = None, limit: int = 50, pid: int = None) -> List[Rule34Image]: if tags is None and pid is None: raise AttributeError('either tags or pid must be used') elif tags is not None and pid is not None: raise AttributeError('only tags or pid can be specified, not both') elif not 1 <= limit <= 1...
[ "async", "def", "rule34get", "(", "tags", "=", "None", ",", "limit", ":", "int", "=", "50", ",", "pid", ":", "int", "=", "None", ")", "->", "List", "[", "Rule34Image", "]", ":", "if", "tags", "is", "None", "and", "pid", "is", "None", ":", "raise"...
Fetch a certain amount of images asyncronously from rule34.xxx Parameters
[ "Fetch", "a", "certain", "amount", "of", "images", "asyncronously", "from", "rule34", ".", "xxx", "Parameters" ]
[ "'''Fetch a certain amount of images asyncronously from rule34.xxx\n\n\tParameters\n\t----------\n\ttags: Optional[:class:`str`,`list`]\n\t\tthe tags to search for\n\t\tif passing a string the tags must be seperated by one whitespace each\n\tlimit: Optional[:class:`int`]\n\t\tthe amount of images to retrive from ru...
[ { "param": "tags", "type": null }, { "param": "limit", "type": "int" }, { "param": "pid", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tags", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "limit", "type": "int", "docstring": null, "docstring_tokens":...
0b02d32cd924ca05b92b4011cb5546c9c47f7066
neurosnap/wsa-cli
wsa.py
[ "MIT" ]
Python
mkwsa
null
def mkwsa(dir, name, js, css, config_version, template, manifest, force): """ Command line template for creating a basic web-standard-apps module """ module_dir = os.path.join(dir, name) parent_dir = os.path.abspath(os.path.join(module_dir, os.pardir)) static_dir = os.path.join(module_dir, "static") ...
Command line template for creating a basic web-standard-apps module
Command line template for creating a basic web-standard-apps module
[ "Command", "line", "template", "for", "creating", "a", "basic", "web", "-", "standard", "-", "apps", "module" ]
def mkwsa(dir, name, js, css, config_version, template, manifest, force): module_dir = os.path.join(dir, name) parent_dir = os.path.abspath(os.path.join(module_dir, os.pardir)) static_dir = os.path.join(module_dir, "static") css_dir = os.path.join(static_dir, "css") css_modules = "modules" css_m...
[ "def", "mkwsa", "(", "dir", ",", "name", ",", "js", ",", "css", ",", "config_version", ",", "template", ",", "manifest", ",", "force", ")", ":", "module_dir", "=", "os", ".", "path", ".", "join", "(", "dir", ",", "name", ")", "parent_dir", "=", "os...
Command line template for creating a basic web-standard-apps module
[ "Command", "line", "template", "for", "creating", "a", "basic", "web", "-", "standard", "-", "apps", "module" ]
[ "\"\"\" Command line template for creating a basic web-standard-apps module \"\"\"", "# create base module folder", "# setup python package", "# setup template folder structure and default template", "# setup static folder structure and config files", "# create js modules directory and templated js file",...
[ { "param": "dir", "type": null }, { "param": "name", "type": null }, { "param": "js", "type": null }, { "param": "css", "type": null }, { "param": "config_version", "type": null }, { "param": "template", "type": null }, { "param": "manifest...
{ "returns": [], "raises": [], "params": [ { "identifier": "dir", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "name", "type": null, "docstring": null, "docstring_tokens": []...
0b02d32cd924ca05b92b4011cb5546c9c47f7066
neurosnap/wsa-cli
wsa.py
[ "MIT" ]
Python
create_dir
null
def create_dir(directory): """ Create directory or display message if directory already exists :param director: The directory """ if os.path.isdir(directory): click.echo("Found {}, skipping folder creation".format(directory)) else: click.echo("Creating {} ...".format(directory)) ...
Create directory or display message if directory already exists :param director: The directory
Create directory or display message if directory already exists
[ "Create", "directory", "or", "display", "message", "if", "directory", "already", "exists" ]
def create_dir(directory): if os.path.isdir(directory): click.echo("Found {}, skipping folder creation".format(directory)) else: click.echo("Creating {} ...".format(directory)) os.mkdir(directory)
[ "def", "create_dir", "(", "directory", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "directory", ")", ":", "click", ".", "echo", "(", "\"Found {}, skipping folder creation\"", ".", "format", "(", "directory", ")", ")", "else", ":", "click", ".", ...
Create directory or display message if directory already exists
[ "Create", "directory", "or", "display", "message", "if", "directory", "already", "exists" ]
[ "\"\"\" Create directory or display message if directory already exists\n\n :param director: The directory \"\"\"" ]
[ { "param": "directory", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "directory", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [ { "identifier": "director", "type": null, "docstring"...
73785bb7598d0f5d5c03cd491e771bbc653ec3ab
newvicx/piwebasync
piwebasync/http/client.py
[ "MIT" ]
Python
_configure_hooks
Mapping[str, List[Callable]]
def _configure_hooks( self, safe_chars: str = None, event_hooks: Mapping[str, List[Callable]] = None, ) -> Mapping[str, List[Callable]]: """ Configure event hooks to support safe chars if specified Raises: - TypeError: safe chars are wrong type ...
Configure event hooks to support safe chars if specified Raises: - TypeError: safe chars are wrong type
Configure event hooks to support safe chars if specified
[ "Configure", "event", "hooks", "to", "support", "safe", "chars", "if", "specified" ]
def _configure_hooks( self, safe_chars: str = None, event_hooks: Mapping[str, List[Callable]] = None, ) -> Mapping[str, List[Callable]]: event_hooks = event_hooks or {} if safe_chars: if not isinstance(safe_chars, str): raise TypeError( ...
[ "def", "_configure_hooks", "(", "self", ",", "safe_chars", ":", "str", "=", "None", ",", "event_hooks", ":", "Mapping", "[", "str", ",", "List", "[", "Callable", "]", "]", "=", "None", ",", ")", "->", "Mapping", "[", "str", ",", "List", "[", "Callabl...
Configure event hooks to support safe chars if specified
[ "Configure", "event", "hooks", "to", "support", "safe", "chars", "if", "specified" ]
[ "\"\"\"\n Configure event hooks to support safe chars if specified\n \n Raises:\n - TypeError: safe chars are wrong type\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "safe_chars", "type": "str" }, { "param": "event_hooks", "type": "Mapping[str, List[Callable]]" } ]
{ "returns": [], "raises": [ { "docstring": "safe chars are wrong type", "docstring_tokens": [ "safe", "chars", "are", "wrong", "type" ], "type": "- TypeError" } ], "params": [ { "identifier": "self", "type": null, "do...
73785bb7598d0f5d5c03cd491e771bbc653ec3ab
newvicx/piwebasync
piwebasync/http/client.py
[ "MIT" ]
Python
_validate_protocol
None
def _validate_protocol(self, request: APIRequest) -> None: """ Validate request is an HTTP request Raises - TypeError: request is not an APIRequest - ValueError: invalid protocol for request """ if not isinstance(request, APIRequest): ...
Validate request is an HTTP request Raises - TypeError: request is not an APIRequest - ValueError: invalid protocol for request
Validate request is an HTTP request Raises TypeError: request is not an APIRequest ValueError: invalid protocol for request
[ "Validate", "request", "is", "an", "HTTP", "request", "Raises", "TypeError", ":", "request", "is", "not", "an", "APIRequest", "ValueError", ":", "invalid", "protocol", "for", "request" ]
def _validate_protocol(self, request: APIRequest) -> None: if not isinstance(request, APIRequest): raise TypeError(f"'request' must be instance of APIRequest. Got {type(request)}") if request.protocol != "HTTP": raise ValueError( f"Invalid protocol for {self.__cla...
[ "def", "_validate_protocol", "(", "self", ",", "request", ":", "APIRequest", ")", "->", "None", ":", "if", "not", "isinstance", "(", "request", ",", "APIRequest", ")", ":", "raise", "TypeError", "(", "f\"'request' must be instance of APIRequest. Got {type(request)}\""...
Validate request is an HTTP request Raises TypeError: request is not an APIRequest ValueError: invalid protocol for request
[ "Validate", "request", "is", "an", "HTTP", "request", "Raises", "TypeError", ":", "request", "is", "not", "an", "APIRequest", "ValueError", ":", "invalid", "protocol", "for", "request" ]
[ "\"\"\"\n Validate request is an HTTP request\n \n Raises\n - TypeError: request is not an APIRequest\n - ValueError: invalid protocol for request\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "request", "type": "APIRequest" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "request", "type": "APIRequest", "docstring": null, "docstring...
70e89c39b14116ec9cf7722d0105194ad564ffff
newvicx/piwebasync
tests/websockets/manual_test.py
[ "MIT" ]
Python
receiver
<not_specific>
async def receiver(channel: WebsocketClient): """Receive messages from channel in asyncio.Task""" responses = [] try: async for response in channel: responses.append(response) except ChannelClosedError: raise except ChannelClosedOK: return responses
Receive messages from channel in asyncio.Task
Receive messages from channel in asyncio.Task
[ "Receive", "messages", "from", "channel", "in", "asyncio", ".", "Task" ]
async def receiver(channel: WebsocketClient): responses = [] try: async for response in channel: responses.append(response) except ChannelClosedError: raise except ChannelClosedOK: return responses
[ "async", "def", "receiver", "(", "channel", ":", "WebsocketClient", ")", ":", "responses", "=", "[", "]", "try", ":", "async", "for", "response", "in", "channel", ":", "responses", ".", "append", "(", "response", ")", "except", "ChannelClosedError", ":", "...
Receive messages from channel in asyncio.Task
[ "Receive", "messages", "from", "channel", "in", "asyncio", ".", "Task" ]
[ "\"\"\"Receive messages from channel in asyncio.Task\"\"\"" ]
[ { "param": "channel", "type": "WebsocketClient" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "channel", "type": "WebsocketClient", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
694ffdb75175e16fec3fe5f1357212b94720077f
newvicx/piwebasync
piwebasync/api/util.py
[ "MIT" ]
Python
json_dump_content
str
def json_dump_content( content: JSONType, *, default: Optional[Callable[[Any], Any]] ) -> str: """ Helper to decode orjson.dumps which produces bytes """ return orjson.dumps(content, default=default).decode()
Helper to decode orjson.dumps which produces bytes
Helper to decode orjson.dumps which produces bytes
[ "Helper", "to", "decode", "orjson", ".", "dumps", "which", "produces", "bytes" ]
def json_dump_content( content: JSONType, *, default: Optional[Callable[[Any], Any]] ) -> str: return orjson.dumps(content, default=default).decode()
[ "def", "json_dump_content", "(", "content", ":", "JSONType", ",", "*", ",", "default", ":", "Optional", "[", "Callable", "[", "[", "Any", "]", ",", "Any", "]", "]", ")", "->", "str", ":", "return", "orjson", ".", "dumps", "(", "content", ",", "defaul...
Helper to decode orjson.dumps which produces bytes
[ "Helper", "to", "decode", "orjson", ".", "dumps", "which", "produces", "bytes" ]
[ "\"\"\"\n Helper to decode orjson.dumps which produces bytes\n \"\"\"" ]
[ { "param": "content", "type": "JSONType" }, { "param": "default", "type": "Optional[Callable[[Any], Any]]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "content", "type": "JSONType", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "default", "type": "Optional[Callable[[Any], Any]]", "docst...
694ffdb75175e16fec3fe5f1357212b94720077f
newvicx/piwebasync
piwebasync/api/util.py
[ "MIT" ]
Python
json_load_content
JSONType
def json_load_content(content: bytes) -> JSONType: """ Escapes paths returned by Pi Web API so they can loaded as JSON """ content.replace('\\', '\\\\') try: return orjson.loads(bytes(content, 'utf-8')) except json.JSONDecodeError: return {}
Escapes paths returned by Pi Web API so they can loaded as JSON
Escapes paths returned by Pi Web API so they can loaded as JSON
[ "Escapes", "paths", "returned", "by", "Pi", "Web", "API", "so", "they", "can", "loaded", "as", "JSON" ]
def json_load_content(content: bytes) -> JSONType: content.replace('\\', '\\\\') try: return orjson.loads(bytes(content, 'utf-8')) except json.JSONDecodeError: return {}
[ "def", "json_load_content", "(", "content", ":", "bytes", ")", "->", "JSONType", ":", "content", ".", "replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ")", "try", ":", "return", "orjson", ".", "loads", "(", "bytes", "(", "content", ",", "'utf-8'", ")", ")", ...
Escapes paths returned by Pi Web API so they can loaded as JSON
[ "Escapes", "paths", "returned", "by", "Pi", "Web", "API", "so", "they", "can", "loaded", "as", "JSON" ]
[ "\"\"\"\n Escapes paths returned by Pi Web API so they can loaded as JSON\n \"\"\"" ]
[ { "param": "content", "type": "bytes" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "content", "type": "bytes", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
694ffdb75175e16fec3fe5f1357212b94720077f
newvicx/piwebasync
piwebasync/api/util.py
[ "MIT" ]
Python
normalize_request_params
Dict[str, str]
def normalize_request_params(raw_params: Dict[str, StrType]) -> Dict[str, str]: """ Convert snake case keys to lower camel case and serialize params """ return { normalize_request_key(key): serialize_to_str(param) for key, param in raw_params.items() }
Convert snake case keys to lower camel case and serialize params
Convert snake case keys to lower camel case and serialize params
[ "Convert", "snake", "case", "keys", "to", "lower", "camel", "case", "and", "serialize", "params" ]
def normalize_request_params(raw_params: Dict[str, StrType]) -> Dict[str, str]: return { normalize_request_key(key): serialize_to_str(param) for key, param in raw_params.items() }
[ "def", "normalize_request_params", "(", "raw_params", ":", "Dict", "[", "str", ",", "StrType", "]", ")", "->", "Dict", "[", "str", ",", "str", "]", ":", "return", "{", "normalize_request_key", "(", "key", ")", ":", "serialize_to_str", "(", "param", ")", ...
Convert snake case keys to lower camel case and serialize params
[ "Convert", "snake", "case", "keys", "to", "lower", "camel", "case", "and", "serialize", "params" ]
[ "\"\"\"\n Convert snake case keys to lower camel case and serialize params\n \"\"\"" ]
[ { "param": "raw_params", "type": "Dict[str, StrType]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "raw_params", "type": "Dict[str, StrType]", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
694ffdb75175e16fec3fe5f1357212b94720077f
newvicx/piwebasync
piwebasync/api/util.py
[ "MIT" ]
Python
reuse_validator
Any
def reuse_validator(key: str, validate_func: Callable[[Any], Any]) -> Any: """ Helper function for pydantic reuse validator """ if isinstance(validate_func, partial): validate_func.__name__ = validate_func.func.__name__ return validator(key, allow_reuse=True, check_fields=False)(validate_fun...
Helper function for pydantic reuse validator
Helper function for pydantic reuse validator
[ "Helper", "function", "for", "pydantic", "reuse", "validator" ]
def reuse_validator(key: str, validate_func: Callable[[Any], Any]) -> Any: if isinstance(validate_func, partial): validate_func.__name__ = validate_func.func.__name__ return validator(key, allow_reuse=True, check_fields=False)(validate_func)
[ "def", "reuse_validator", "(", "key", ":", "str", ",", "validate_func", ":", "Callable", "[", "[", "Any", "]", ",", "Any", "]", ")", "->", "Any", ":", "if", "isinstance", "(", "validate_func", ",", "partial", ")", ":", "validate_func", ".", "__name__", ...
Helper function for pydantic reuse validator
[ "Helper", "function", "for", "pydantic", "reuse", "validator" ]
[ "\"\"\"\n Helper function for pydantic reuse validator\n \"\"\"" ]
[ { "param": "key", "type": "str" }, { "param": "validate_func", "type": "Callable[[Any], Any]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "key", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "validate_func", "type": "Callable[[Any], Any]", "docstring": null, ...
694ffdb75175e16fec3fe5f1357212b94720077f
newvicx/piwebasync
piwebasync/api/util.py
[ "MIT" ]
Python
search_response_content
List[JSONType]
def search_response_content(field: str, response: JSONType) -> List[JSONType]: """ Extract field values from nested JSON response. Fields should be specified according to hierarchy of the data using dot notation, ``Top.Nested.NestedNested``. This function groups fields in nested lists by the index i...
Extract field values from nested JSON response. Fields should be specified according to hierarchy of the data using dot notation, ``Top.Nested.NestedNested``. This function groups fields in nested lists by the index in the list and returns a list of lists. For example consider the json response bel...
Extract field values from nested JSON response. Fields should be specified according to hierarchy of the data using dot notation, ``Top.Nested.NestedNested``. This function groups fields in nested lists by the index in the list and returns a list of lists.
[ "Extract", "field", "values", "from", "nested", "JSON", "response", ".", "Fields", "should", "be", "specified", "according", "to", "hierarchy", "of", "the", "data", "using", "dot", "notation", "`", "`", "Top", ".", "Nested", ".", "NestedNested", "`", "`", ...
def search_response_content(field: str, response: JSONType) -> List[JSONType]: def extract_nested_fields_from_list( nested_fields: List[str], subset: List[JSONType], level: int = 0 ) -> List[JSONType]: items = [] for item in subset: if isinstance(item, dict): ...
[ "def", "search_response_content", "(", "field", ":", "str", ",", "response", ":", "JSONType", ")", "->", "List", "[", "JSONType", "]", ":", "def", "extract_nested_fields_from_list", "(", "nested_fields", ":", "List", "[", "str", "]", ",", "subset", ":", "Lis...
Extract field values from nested JSON response.
[ "Extract", "field", "values", "from", "nested", "JSON", "response", "." ]
[ "\"\"\"\n Extract field values from nested JSON response. Fields should be\n specified according to hierarchy of the data using dot notation,\n ``Top.Nested.NestedNested``.\n This function groups fields in nested lists by the index in the list\n and returns a list of lists. For example consider the j...
[ { "param": "field", "type": "str" }, { "param": "response", "type": "JSONType" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "field", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "response", "type": "JSONType", "docstring": null, "docstrin...
694ffdb75175e16fec3fe5f1357212b94720077f
newvicx/piwebasync
piwebasync/api/util.py
[ "MIT" ]
Python
serialize_arbitrary_to_str
str
def serialize_arbitrary_to_str(obj: ConvertsToStr) -> str: """ Serialize arbitrary objects with a __str__ method. datetime converts to isoformat """ if isinstance(obj, datetime): return obj.isoformat("T") elif hasattr(obj, "__str__"): return str(obj) else: raise Serializa...
Serialize arbitrary objects with a __str__ method. datetime converts to isoformat
Serialize arbitrary objects with a __str__ method. datetime converts to isoformat
[ "Serialize", "arbitrary", "objects", "with", "a", "__str__", "method", ".", "datetime", "converts", "to", "isoformat" ]
def serialize_arbitrary_to_str(obj: ConvertsToStr) -> str: if isinstance(obj, datetime): return obj.isoformat("T") elif hasattr(obj, "__str__"): return str(obj) else: raise SerializationError( f"Cannot serialize object of type {type(obj)} to str" )
[ "def", "serialize_arbitrary_to_str", "(", "obj", ":", "ConvertsToStr", ")", "->", "str", ":", "if", "isinstance", "(", "obj", ",", "datetime", ")", ":", "return", "obj", ".", "isoformat", "(", "\"T\"", ")", "elif", "hasattr", "(", "obj", ",", "\"__str__\""...
Serialize arbitrary objects with a __str__ method.
[ "Serialize", "arbitrary", "objects", "with", "a", "__str__", "method", "." ]
[ "\"\"\"\n Serialize arbitrary objects with a __str__ method. datetime converts to isoformat\n \"\"\"" ]
[ { "param": "obj", "type": "ConvertsToStr" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "obj", "type": "ConvertsToStr", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
694ffdb75175e16fec3fe5f1357212b94720077f
newvicx/piwebasync
piwebasync/api/util.py
[ "MIT" ]
Python
serialize_to_str
str
def serialize_to_str(obj: StrType) -> str: """ Serialize objects to be used as query params to str """ if not obj: return elif isinstance(obj, str): return obj elif isinstance(obj, bytes): return obj.decode() # tuples are converted to list elif isinstance(obj, (li...
Serialize objects to be used as query params to str
Serialize objects to be used as query params to str
[ "Serialize", "objects", "to", "be", "used", "as", "query", "params", "to", "str" ]
def serialize_to_str(obj: StrType) -> str: if not obj: return elif isinstance(obj, str): return obj elif isinstance(obj, bytes): return obj.decode() elif isinstance(obj, (list, tuple)): return [serialize_arbitrary_to_str(item) for item in obj] elif isinstance(obj, (da...
[ "def", "serialize_to_str", "(", "obj", ":", "StrType", ")", "->", "str", ":", "if", "not", "obj", ":", "return", "elif", "isinstance", "(", "obj", ",", "str", ")", ":", "return", "obj", "elif", "isinstance", "(", "obj", ",", "bytes", ")", ":", "retur...
Serialize objects to be used as query params to str
[ "Serialize", "objects", "to", "be", "used", "as", "query", "params", "to", "str" ]
[ "\"\"\"\n Serialize objects to be used as query params to str\n \"\"\"", "# tuples are converted to list" ]
[ { "param": "obj", "type": "StrType" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "obj", "type": "StrType", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
694ffdb75175e16fec3fe5f1357212b94720077f
newvicx/piwebasync
piwebasync/api/util.py
[ "MIT" ]
Python
serialize_multi_instance
str
def serialize_multi_instance( key: str, params: Union[ List[ConvertsToStr], Tuple[ConvertsToStr] ] ) -> str: """ Serializes Pi Web API parameters that can be specified multiple times such as 'webId' for StreamSetAdHoc controller """ assert isinstance(params, (list, tuple)...
Serializes Pi Web API parameters that can be specified multiple times such as 'webId' for StreamSetAdHoc controller
Serializes Pi Web API parameters that can be specified multiple times such as 'webId' for StreamSetAdHoc controller
[ "Serializes", "Pi", "Web", "API", "parameters", "that", "can", "be", "specified", "multiple", "times", "such", "as", "'", "webId", "'", "for", "StreamSetAdHoc", "controller" ]
def serialize_multi_instance( key: str, params: Union[ List[ConvertsToStr], Tuple[ConvertsToStr] ] ) -> str: assert isinstance(params, (list, tuple)) serialized: Union[List[str], Tuple[str]] = serialize_to_str(params) if len(serialized) > 1: return f"{serialized.pop(0)}&{...
[ "def", "serialize_multi_instance", "(", "key", ":", "str", ",", "params", ":", "Union", "[", "List", "[", "ConvertsToStr", "]", ",", "Tuple", "[", "ConvertsToStr", "]", "]", ")", "->", "str", ":", "assert", "isinstance", "(", "params", ",", "(", "list", ...
Serializes Pi Web API parameters that can be specified multiple times such as 'webId' for StreamSetAdHoc controller
[ "Serializes", "Pi", "Web", "API", "parameters", "that", "can", "be", "specified", "multiple", "times", "such", "as", "'", "webId", "'", "for", "StreamSetAdHoc", "controller" ]
[ "\"\"\"\n Serializes Pi Web API parameters that can be specified multiple times\n such as 'webId' for StreamSetAdHoc controller\n \"\"\"" ]
[ { "param": "key", "type": "str" }, { "param": "params", "type": "Union[\n List[ConvertsToStr],\n Tuple[ConvertsToStr]\n ]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "key", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "params", "type": "Union[\n List[ConvertsToStr],\n Tuple[Con...
694ffdb75175e16fec3fe5f1357212b94720077f
newvicx/piwebasync
piwebasync/api/util.py
[ "MIT" ]
Python
serialize_semi_colon_separated
str
def serialize_semi_colon_separated( params: Union[ List[ConvertsToStr], Tuple[ConvertsToStr] ] ) -> str: """ Serializes Pi Web API parameters that can have multiple values separated by semi colons such as 'selectedFields' for most controllers """ assert isinstance(params, (li...
Serializes Pi Web API parameters that can have multiple values separated by semi colons such as 'selectedFields' for most controllers
Serializes Pi Web API parameters that can have multiple values separated by semi colons such as 'selectedFields' for most controllers
[ "Serializes", "Pi", "Web", "API", "parameters", "that", "can", "have", "multiple", "values", "separated", "by", "semi", "colons", "such", "as", "'", "selectedFields", "'", "for", "most", "controllers" ]
def serialize_semi_colon_separated( params: Union[ List[ConvertsToStr], Tuple[ConvertsToStr] ] ) -> str: assert isinstance(params, (list, tuple)) return ";".join(serialize_to_str(params))
[ "def", "serialize_semi_colon_separated", "(", "params", ":", "Union", "[", "List", "[", "ConvertsToStr", "]", ",", "Tuple", "[", "ConvertsToStr", "]", "]", ")", "->", "str", ":", "assert", "isinstance", "(", "params", ",", "(", "list", ",", "tuple", ")", ...
Serializes Pi Web API parameters that can have multiple values separated by semi colons such as 'selectedFields' for most controllers
[ "Serializes", "Pi", "Web", "API", "parameters", "that", "can", "have", "multiple", "values", "separated", "by", "semi", "colons", "such", "as", "'", "selectedFields", "'", "for", "most", "controllers" ]
[ "\"\"\"\n Serializes Pi Web API parameters that can have multiple values\n separated by semi colons such as 'selectedFields' for most controllers\n \"\"\"" ]
[ { "param": "params", "type": "Union[\n List[ConvertsToStr],\n Tuple[ConvertsToStr]\n ]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "params", "type": "Union[\n List[ConvertsToStr],\n Tuple[ConvertsToStr]\n ]", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "ot...
55f26ec9dd35576ede412fa2abf41f0f27009ac3
newvicx/piwebasync
piwebasync/api/models.py
[ "MIT" ]
Python
_build_request
<not_specific>
def _build_request( self, method: str, protocol: str, controller: str, action: str = None, webid: str = None, add_path: List[str] = None, **params: Any ): """Serialize params and return APIRequest instance""" serialized_param...
Serialize params and return APIRequest instance
Serialize params and return APIRequest instance
[ "Serialize", "params", "and", "return", "APIRequest", "instance" ]
def _build_request( self, method: str, protocol: str, controller: str, action: str = None, webid: str = None, add_path: List[str] = None, **params: Any ): serialized_params = self._serialize_params(params) return APIRequest( ...
[ "def", "_build_request", "(", "self", ",", "method", ":", "str", ",", "protocol", ":", "str", ",", "controller", ":", "str", ",", "action", ":", "str", "=", "None", ",", "webid", ":", "str", "=", "None", ",", "add_path", ":", "List", "[", "str", "]...
Serialize params and return APIRequest instance
[ "Serialize", "params", "and", "return", "APIRequest", "instance" ]
[ "\"\"\"Serialize params and return APIRequest instance\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "method", "type": "str" }, { "param": "protocol", "type": "str" }, { "param": "controller", "type": "str" }, { "param": "action", "type": "str" }, { "param": "webid", "type": "str" }, { "param":...
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "method", "type": "str", "docstring": null, "docstring_tokens"...
55f26ec9dd35576ede412fa2abf41f0f27009ac3
newvicx/piwebasync
piwebasync/api/models.py
[ "MIT" ]
Python
_serialize_params
<not_specific>
def _serialize_params(self, params: Dict[str, Any]): """Serialize semi colon and multi instance params to URL safe strings""" # serialize semi colon params for validate in self.SEMI_COLON_PARAMS: param = params.get(validate) if param is not None: ser...
Serialize semi colon and multi instance params to URL safe strings
Serialize semi colon and multi instance params to URL safe strings
[ "Serialize", "semi", "colon", "and", "multi", "instance", "params", "to", "URL", "safe", "strings" ]
def _serialize_params(self, params: Dict[str, Any]): for validate in self.SEMI_COLON_PARAMS: param = params.get(validate) if param is not None: serialized = serialize_semi_colon_separated(param) params.update({validate: serialized}) for validate, k...
[ "def", "_serialize_params", "(", "self", ",", "params", ":", "Dict", "[", "str", ",", "Any", "]", ")", ":", "for", "validate", "in", "self", ".", "SEMI_COLON_PARAMS", ":", "param", "=", "params", ".", "get", "(", "validate", ")", "if", "param", "is", ...
Serialize semi colon and multi instance params to URL safe strings
[ "Serialize", "semi", "colon", "and", "multi", "instance", "params", "to", "URL", "safe", "strings" ]
[ "\"\"\"Serialize semi colon and multi instance params to URL safe strings\"\"\"", "# serialize semi colon params\r", "# validate multi instance params\r" ]
[ { "param": "self", "type": null }, { "param": "params", "type": "Dict[str, Any]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "params", "type": "Dict[str, Any]", "docstring": null, "docstr...
55f26ec9dd35576ede412fa2abf41f0f27009ac3
newvicx/piwebasync
piwebasync/api/models.py
[ "MIT" ]
Python
normalize_root
str
def normalize_root(cls, root: str) -> str: """Add leading and trailing slash to root""" try: if root[0] != "/": root = '/' + root if root[-1] != "/": root = root + '/' except IndexError: root = '/' return root
Add leading and trailing slash to root
Add leading and trailing slash to root
[ "Add", "leading", "and", "trailing", "slash", "to", "root" ]
def normalize_root(cls, root: str) -> str: try: if root[0] != "/": root = '/' + root if root[-1] != "/": root = root + '/' except IndexError: root = '/' return root
[ "def", "normalize_root", "(", "cls", ",", "root", ":", "str", ")", "->", "str", ":", "try", ":", "if", "root", "[", "0", "]", "!=", "\"/\"", ":", "root", "=", "'/'", "+", "root", "if", "root", "[", "-", "1", "]", "!=", "\"/\"", ":", "root", "...
Add leading and trailing slash to root
[ "Add", "leading", "and", "trailing", "slash", "to", "root" ]
[ "\"\"\"Add leading and trailing slash to root\"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "root", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "root", "type": "str", "docstring": null, "docstring_tokens": [...
55f26ec9dd35576ede412fa2abf41f0f27009ac3
newvicx/piwebasync
piwebasync/api/models.py
[ "MIT" ]
Python
validate_add_path
str
def validate_add_path(cls, add_path: Union[None, list]) -> str: """Converts add_path from None to [] if applicable""" if add_path is None: return [] return add_path
Converts add_path from None to [] if applicable
Converts add_path from None to [] if applicable
[ "Converts", "add_path", "from", "None", "to", "[]", "if", "applicable" ]
def validate_add_path(cls, add_path: Union[None, list]) -> str: if add_path is None: return [] return add_path
[ "def", "validate_add_path", "(", "cls", ",", "add_path", ":", "Union", "[", "None", ",", "list", "]", ")", "->", "str", ":", "if", "add_path", "is", "None", ":", "return", "[", "]", "return", "add_path" ]
Converts add_path from None to [] if applicable
[ "Converts", "add_path", "from", "None", "to", "[]", "if", "applicable" ]
[ "\"\"\"Converts add_path from None to [] if applicable\"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "add_path", "type": "Union[None, list]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "add_path", "type": "Union[None, list]", "docstring": null, "do...
55f26ec9dd35576ede412fa2abf41f0f27009ac3
newvicx/piwebasync
piwebasync/api/models.py
[ "MIT" ]
Python
query
str
def query(self) -> str: """Get normalized query params as str""" params = self.params joined = [f"{key}={param}" for key, param in params.items() if param is not None] return "&".join(joined)
Get normalized query params as str
Get normalized query params as str
[ "Get", "normalized", "query", "params", "as", "str" ]
def query(self) -> str: params = self.params joined = [f"{key}={param}" for key, param in params.items() if param is not None] return "&".join(joined)
[ "def", "query", "(", "self", ")", "->", "str", ":", "params", "=", "self", ".", "params", "joined", "=", "[", "f\"{key}={param}\"", "for", "key", ",", "param", "in", "params", ".", "items", "(", ")", "if", "param", "is", "not", "None", "]", "return",...
Get normalized query params as str
[ "Get", "normalized", "query", "params", "as", "str" ]
[ "\"\"\"Get normalized query params as str\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
55f26ec9dd35576ede412fa2abf41f0f27009ac3
newvicx/piwebasync
piwebasync/api/models.py
[ "MIT" ]
Python
handle_web_exception
Dict[str, JSONType]
def handle_web_exception(cls, values: Dict[str, JSONType]) -> Dict[str, JSONType]: """ Handles WebException property in response body (if present). See link for error handling and WebException property https://docs.osisoft.com/bundle/pi-web-api-reference/page/help/topics/error-handli...
Handles WebException property in response body (if present). See link for error handling and WebException property https://docs.osisoft.com/bundle/pi-web-api-reference/page/help/topics/error-handling.html
Handles WebException property in response body (if present).
[ "Handles", "WebException", "property", "in", "response", "body", "(", "if", "present", ")", "." ]
def handle_web_exception(cls, values: Dict[str, JSONType]) -> Dict[str, JSONType]: web_exception = values.get('WebException') if web_exception is not None: errors = values.get('Errors') if not errors: errors = web_exception["Errors"] else: ...
[ "def", "handle_web_exception", "(", "cls", ",", "values", ":", "Dict", "[", "str", ",", "JSONType", "]", ")", "->", "Dict", "[", "str", ",", "JSONType", "]", ":", "web_exception", "=", "values", ".", "get", "(", "'WebException'", ")", "if", "web_exceptio...
Handles WebException property in response body (if present).
[ "Handles", "WebException", "property", "in", "response", "body", "(", "if", "present", ")", "." ]
[ "\"\"\"\r\n Handles WebException property in response body (if present).\r\n See link for error handling and WebException property\r\n https://docs.osisoft.com/bundle/pi-web-api-reference/page/help/topics/error-handling.html\r\n \"\"\"", "# handle WebException property, update status_c...
[ { "param": "cls", "type": null }, { "param": "values", "type": "Dict[str, JSONType]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "values", "type": "Dict[str, JSONType]", "docstring": null, "do...
55f26ec9dd35576ede412fa2abf41f0f27009ac3
newvicx/piwebasync
piwebasync/api/models.py
[ "MIT" ]
Python
normalize_response
Dict[str, JSONType]
def normalize_response(cls, values: Dict[str, JSONType]) -> Dict[str, JSONType]: """ Normalize top level keys from response body to snake case """ return {normalize_response_key(key): val for key, val in values.items()}
Normalize top level keys from response body to snake case
Normalize top level keys from response body to snake case
[ "Normalize", "top", "level", "keys", "from", "response", "body", "to", "snake", "case" ]
def normalize_response(cls, values: Dict[str, JSONType]) -> Dict[str, JSONType]: return {normalize_response_key(key): val for key, val in values.items()}
[ "def", "normalize_response", "(", "cls", ",", "values", ":", "Dict", "[", "str", ",", "JSONType", "]", ")", "->", "Dict", "[", "str", ",", "JSONType", "]", ":", "return", "{", "normalize_response_key", "(", "key", ")", ":", "val", "for", "key", ",", ...
Normalize top level keys from response body to snake case
[ "Normalize", "top", "level", "keys", "from", "response", "body", "to", "snake", "case" ]
[ "\"\"\"\r\n Normalize top level keys from response body to snake case\r\n \"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "values", "type": "Dict[str, JSONType]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "values", "type": "Dict[str, JSONType]", "docstring": null, "do...
55f26ec9dd35576ede412fa2abf41f0f27009ac3
newvicx/piwebasync
piwebasync/api/models.py
[ "MIT" ]
Python
raw_response
bytes
def raw_response(self) -> bytes: """ Reproduce raw response body from PI Web API as bytes """ response = self.dict() return orjson.dumps(response)
Reproduce raw response body from PI Web API as bytes
Reproduce raw response body from PI Web API as bytes
[ "Reproduce", "raw", "response", "body", "from", "PI", "Web", "API", "as", "bytes" ]
def raw_response(self) -> bytes: response = self.dict() return orjson.dumps(response)
[ "def", "raw_response", "(", "self", ")", "->", "bytes", ":", "response", "=", "self", ".", "dict", "(", ")", "return", "orjson", ".", "dumps", "(", "response", ")" ]
Reproduce raw response body from PI Web API as bytes
[ "Reproduce", "raw", "response", "body", "from", "PI", "Web", "API", "as", "bytes" ]
[ "\"\"\"\r\n Reproduce raw response body from PI Web API as bytes\r\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
55f26ec9dd35576ede412fa2abf41f0f27009ac3
newvicx/piwebasync
piwebasync/api/models.py
[ "MIT" ]
Python
dict
Dict[str, Any]
def dict(self, *args, **kwargs) -> Dict[str, Any]: """ Restore camel case for top level response content """ response = super().dict(*args, **kwargs) return {normalize_camel_case(key): val for key, val in response.items()}
Restore camel case for top level response content
Restore camel case for top level response content
[ "Restore", "camel", "case", "for", "top", "level", "response", "content" ]
def dict(self, *args, **kwargs) -> Dict[str, Any]: response = super().dict(*args, **kwargs) return {normalize_camel_case(key): val for key, val in response.items()}
[ "def", "dict", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "response", "=", "super", "(", ")", ".", "dict", "(", "*", "args", ",", "**", "kwargs", ")", "return", "{", "normalize_camel_c...
Restore camel case for top level response content
[ "Restore", "camel", "case", "for", "top", "level", "response", "content" ]
[ "\"\"\"\r\n Restore camel case for top level response content\r\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
55f26ec9dd35576ede412fa2abf41f0f27009ac3
newvicx/piwebasync
piwebasync/api/models.py
[ "MIT" ]
Python
select
Dict[str, JSONType]
def select(self, *fields: str) -> Dict[str, JSONType]: """ Returns the values of the selected fields from the response content. 'fields' are defined using dot notation (Top.Nested.NestedNested) """ response = self.dict() return {field: search_response_content(field,...
Returns the values of the selected fields from the response content. 'fields' are defined using dot notation (Top.Nested.NestedNested)
Returns the values of the selected fields from the response content. 'fields' are defined using dot notation (Top.Nested.NestedNested)
[ "Returns", "the", "values", "of", "the", "selected", "fields", "from", "the", "response", "content", ".", "'", "fields", "'", "are", "defined", "using", "dot", "notation", "(", "Top", ".", "Nested", ".", "NestedNested", ")" ]
def select(self, *fields: str) -> Dict[str, JSONType]: response = self.dict() return {field: search_response_content(field, response) for field in fields}
[ "def", "select", "(", "self", ",", "*", "fields", ":", "str", ")", "->", "Dict", "[", "str", ",", "JSONType", "]", ":", "response", "=", "self", ".", "dict", "(", ")", "return", "{", "field", ":", "search_response_content", "(", "field", ",", "respon...
Returns the values of the selected fields from the response content.
[ "Returns", "the", "values", "of", "the", "selected", "fields", "from", "the", "response", "content", "." ]
[ "\"\"\"\r\n Returns the values of the selected fields from the response content.\r\n 'fields' are defined using dot notation (Top.Nested.NestedNested)\r\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "fields", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "fields", "type": "str", "docstring": null, "docstring_tokens"...
55f26ec9dd35576ede412fa2abf41f0f27009ac3
newvicx/piwebasync
piwebasync/api/models.py
[ "MIT" ]
Python
raise_for_status
null
def raise_for_status(self): """ Raise HTTPStatusErorr for non successful request or error parsing content """ status_code = self.status_code if not codes.is_success(status_code): reason_phrase = codes.get_reason_phrase(status_code) ...
Raise HTTPStatusErorr for non successful request or error parsing content
Raise HTTPStatusErorr for non successful request or error parsing content
[ "Raise", "HTTPStatusErorr", "for", "non", "successful", "request", "or", "error", "parsing", "content" ]
def raise_for_status(self): status_code = self.status_code if not codes.is_success(status_code): reason_phrase = codes.get_reason_phrase(status_code) errors = self.dict().get('Errors') message = f"{status_code}: {reason_phrase}. The following errors occurred {errors}"...
[ "def", "raise_for_status", "(", "self", ")", ":", "status_code", "=", "self", ".", "status_code", "if", "not", "codes", ".", "is_success", "(", "status_code", ")", ":", "reason_phrase", "=", "codes", ".", "get_reason_phrase", "(", "status_code", ")", "errors",...
Raise HTTPStatusErorr for non successful request or error parsing content
[ "Raise", "HTTPStatusErorr", "for", "non", "successful", "request", "or", "error", "parsing", "content" ]
[ "\"\"\"\r\n Raise HTTPStatusErorr for non successful request or error\r\n parsing content\r\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7bb33918db654105a7f1cc9c3bedbe5b8f5de126
newvicx/piwebasync
piwebasync/http/safeurl.py
[ "MIT" ]
Python
raw_path
bytes
def raw_path(self) -> bytes: """Unquote encoded URL and requote with safe chars""" raw: bytes = super().raw_path safe: str = urllib.parse.quote( urllib.parse.unquote(raw.decode("ascii"), encoding="ascii"), safe=self._safe ) return safe.encode("ascii")
Unquote encoded URL and requote with safe chars
Unquote encoded URL and requote with safe chars
[ "Unquote", "encoded", "URL", "and", "requote", "with", "safe", "chars" ]
def raw_path(self) -> bytes: raw: bytes = super().raw_path safe: str = urllib.parse.quote( urllib.parse.unquote(raw.decode("ascii"), encoding="ascii"), safe=self._safe ) return safe.encode("ascii")
[ "def", "raw_path", "(", "self", ")", "->", "bytes", ":", "raw", ":", "bytes", "=", "super", "(", ")", ".", "raw_path", "safe", ":", "str", "=", "urllib", ".", "parse", ".", "quote", "(", "urllib", ".", "parse", ".", "unquote", "(", "raw", ".", "d...
Unquote encoded URL and requote with safe chars
[ "Unquote", "encoded", "URL", "and", "requote", "with", "safe", "chars" ]
[ "\"\"\"Unquote encoded URL and requote with safe chars\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ade9482d5afb4854886891f57b6f9e0d4c27741f
newvicx/piwebasync
piwebasync/http/hooks.py
[ "MIT" ]
Python
use_safe_url_hook
null
async def use_safe_url_hook(safe: str, obj: Union[httpx.Request, httpx.Response]): """Request/Response hook for modifying percent encoding of urls""" safe_url = SafeURL(safe, obj.url) if isinstance(obj, httpx.Request): obj.url = safe_url else: obj.request.url = safe_url
Request/Response hook for modifying percent encoding of urls
Request/Response hook for modifying percent encoding of urls
[ "Request", "/", "Response", "hook", "for", "modifying", "percent", "encoding", "of", "urls" ]
async def use_safe_url_hook(safe: str, obj: Union[httpx.Request, httpx.Response]): safe_url = SafeURL(safe, obj.url) if isinstance(obj, httpx.Request): obj.url = safe_url else: obj.request.url = safe_url
[ "async", "def", "use_safe_url_hook", "(", "safe", ":", "str", ",", "obj", ":", "Union", "[", "httpx", ".", "Request", ",", "httpx", ".", "Response", "]", ")", ":", "safe_url", "=", "SafeURL", "(", "safe", ",", "obj", ".", "url", ")", "if", "isinstanc...
Request/Response hook for modifying percent encoding of urls
[ "Request", "/", "Response", "hook", "for", "modifying", "percent", "encoding", "of", "urls" ]
[ "\"\"\"Request/Response hook for modifying percent encoding of urls\"\"\"" ]
[ { "param": "safe", "type": "str" }, { "param": "obj", "type": "Union[httpx.Request, httpx.Response]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "safe", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "obj", "type": "Union[httpx.Request, httpx.Response]", "docstring":...
c0b06f0ddeae42e9894677a45f008a65f40bbba0
newvicx/piwebasync
piwebasync/websockets/client.py
[ "MIT" ]
Python
is_closing
<not_specific>
def is_closing(self): """ `True` when channel is closing; `False` otherwise The channel is closed when the _close_channel_waiter is done. The _run_channel_task is being awaited when the channel is closing """ if self._close_channel_waiter is not None: return ...
`True` when channel is closing; `False` otherwise The channel is closed when the _close_channel_waiter is done. The _run_channel_task is being awaited when the channel is closing
`True` when channel is closing; `False` otherwise The channel is closed when the _close_channel_waiter is done. The _run_channel_task is being awaited when the channel is closing
[ "`", "True", "`", "when", "channel", "is", "closing", ";", "`", "False", "`", "otherwise", "The", "channel", "is", "closed", "when", "the", "_close_channel_waiter", "is", "done", ".", "The", "_run_channel_task", "is", "being", "awaited", "when", "the", "chan...
def is_closing(self): if self._close_channel_waiter is not None: return self._close_channel_waiter.done() return True
[ "def", "is_closing", "(", "self", ")", ":", "if", "self", ".", "_close_channel_waiter", "is", "not", "None", ":", "return", "self", ".", "_close_channel_waiter", ".", "done", "(", ")", "return", "True" ]
`True` when channel is closing; `False` otherwise The channel is closed when the _close_channel_waiter is done.
[ "`", "True", "`", "when", "channel", "is", "closing", ";", "`", "False", "`", "otherwise", "The", "channel", "is", "closed", "when", "the", "_close_channel_waiter", "is", "done", "." ]
[ "\"\"\"\n `True` when channel is closing; `False` otherwise\n\n The channel is closed when the _close_channel_waiter is done.\n The _run_channel_task is being awaited when the channel is closing\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c0b06f0ddeae42e9894677a45f008a65f40bbba0
newvicx/piwebasync
piwebasync/websockets/client.py
[ "MIT" ]
Python
is_open
<not_specific>
def is_open(self): """ `True` when channel is open; `False` otherwise The channel is considered open when the underlying websocket protocol instance is open and can receive messages """ if self._run_channel_task is not None: return ( not self....
`True` when channel is open; `False` otherwise The channel is considered open when the underlying websocket protocol instance is open and can receive messages
`True` when channel is open; `False` otherwise The channel is considered open when the underlying websocket protocol instance is open and can receive messages
[ "`", "True", "`", "when", "channel", "is", "open", ";", "`", "False", "`", "otherwise", "The", "channel", "is", "considered", "open", "when", "the", "underlying", "websocket", "protocol", "instance", "is", "open", "and", "can", "receive", "messages" ]
def is_open(self): if self._run_channel_task is not None: return ( not self._run_channel_task.done() and not self._no_data_transfer_event.is_set() ) return False
[ "def", "is_open", "(", "self", ")", ":", "if", "self", ".", "_run_channel_task", "is", "not", "None", ":", "return", "(", "not", "self", ".", "_run_channel_task", ".", "done", "(", ")", "and", "not", "self", ".", "_no_data_transfer_event", ".", "is_set", ...
`True` when channel is open; `False` otherwise The channel is considered open when the underlying websocket protocol instance is open and can receive messages
[ "`", "True", "`", "when", "channel", "is", "open", ";", "`", "False", "`", "otherwise", "The", "channel", "is", "considered", "open", "when", "the", "underlying", "websocket", "protocol", "instance", "is", "open", "and", "can", "receive", "messages" ]
[ "\"\"\"\n `True` when channel is open; `False` otherwise\n\n The channel is considered open when the underlying websocket protocol\n instance is open and can receive messages\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c0b06f0ddeae42e9894677a45f008a65f40bbba0
newvicx/piwebasync
piwebasync/websockets/client.py
[ "MIT" ]
Python
is_reconnecting
<not_specific>
def is_reconnecting(self): """ `True` when channel is reconnecting; `False` otherwise The channel is considered reconnecting when the underlying websocket protocol instance is closed but the _run_channel_task is not done """ if self._run_channel_task is not None: ...
`True` when channel is reconnecting; `False` otherwise The channel is considered reconnecting when the underlying websocket protocol instance is closed but the _run_channel_task is not done
`True` when channel is reconnecting; `False` otherwise The channel is considered reconnecting when the underlying websocket protocol instance is closed but the _run_channel_task is not done
[ "`", "True", "`", "when", "channel", "is", "reconnecting", ";", "`", "False", "`", "otherwise", "The", "channel", "is", "considered", "reconnecting", "when", "the", "underlying", "websocket", "protocol", "instance", "is", "closed", "but", "the", "_run_channel_ta...
def is_reconnecting(self): if self._run_channel_task is not None: return ( not self._run_channel_task.done() and self._no_data_transfer_event.is_set() ) return False
[ "def", "is_reconnecting", "(", "self", ")", ":", "if", "self", ".", "_run_channel_task", "is", "not", "None", ":", "return", "(", "not", "self", ".", "_run_channel_task", ".", "done", "(", ")", "and", "self", ".", "_no_data_transfer_event", ".", "is_set", ...
`True` when channel is reconnecting; `False` otherwise The channel is considered reconnecting when the underlying websocket protocol instance is closed but the _run_channel_task is not done
[ "`", "True", "`", "when", "channel", "is", "reconnecting", ";", "`", "False", "`", "otherwise", "The", "channel", "is", "considered", "reconnecting", "when", "the", "underlying", "websocket", "protocol", "instance", "is", "closed", "but", "the", "_run_channel_ta...
[ "\"\"\"\n `True` when channel is reconnecting; `False` otherwise\n\n The channel is considered reconnecting when the underlying websocket protocol\n instance is closed but the _run_channel_task is not done\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c0b06f0ddeae42e9894677a45f008a65f40bbba0
newvicx/piwebasync
piwebasync/websockets/client.py
[ "MIT" ]
Python
update
None
async def update(self, request: APIRequest, rollback: bool = False) -> None: """ Update Channel endpoint This method does not interrupt `recv`. Any messages already in the client buffer will remain there. New messages will reflect the updated endpoint accordingly. If `up...
Update Channel endpoint This method does not interrupt `recv`. Any messages already in the client buffer will remain there. New messages will reflect the updated endpoint accordingly. If `update` fails with a *ChannelUpdateError*, the channel will remain in a CL...
Update Channel endpoint This method does not interrupt `recv`. Any messages already in the client buffer will remain there. New messages will reflect the updated endpoint accordingly. If `update` fails with a *ChannelUpdateError*, the channel will remain in a CLOSED state Parameters Raises
[ "Update", "Channel", "endpoint", "This", "method", "does", "not", "interrupt", "`", "recv", "`", ".", "Any", "messages", "already", "in", "the", "client", "buffer", "will", "remain", "there", ".", "New", "messages", "will", "reflect", "the", "updated", "endp...
async def update(self, request: APIRequest, rollback: bool = False) -> None: if self._waiting_update: raise RuntimeError( "Cannot call update while another coroutine " "is already waiting to update client" ) self._waiting_update = True try:...
[ "async", "def", "update", "(", "self", ",", "request", ":", "APIRequest", ",", "rollback", ":", "bool", "=", "False", ")", "->", "None", ":", "if", "self", ".", "_waiting_update", ":", "raise", "RuntimeError", "(", "\"Cannot call update while another coroutine \...
Update Channel endpoint This method does not interrupt `recv`.
[ "Update", "Channel", "endpoint", "This", "method", "does", "not", "interrupt", "`", "recv", "`", "." ]
[ "\"\"\"\n Update Channel endpoint\n \n This method does not interrupt `recv`. Any messages already\n in the client buffer will remain there. New messages will\n reflect the updated endpoint accordingly. If `update` fails\n with a *ChannelUpdateError*, the channel will remai...
[ { "param": "self", "type": null }, { "param": "request", "type": "APIRequest" }, { "param": "rollback", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "request", "type": "APIRequest", "docstring": null, "docstring...
c0b06f0ddeae42e9894677a45f008a65f40bbba0
newvicx/piwebasync
piwebasync/websockets/client.py
[ "MIT" ]
Python
close
None
async def close(self) -> None: """ Close the client Execute closing sequence. Calls to `recv` after the closing sequence has started will raise ChannelClosed """ try: logger.debug("closing channel") if not self.is_closed: i...
Close the client Execute closing sequence. Calls to `recv` after the closing sequence has started will raise ChannelClosed
Close the client Execute closing sequence. Calls to `recv` after the closing sequence has started will raise ChannelClosed
[ "Close", "the", "client", "Execute", "closing", "sequence", ".", "Calls", "to", "`", "recv", "`", "after", "the", "closing", "sequence", "has", "started", "will", "raise", "ChannelClosed" ]
async def close(self) -> None: try: logger.debug("closing channel") if not self.is_closed: if not self.is_closing: logger.debug("signaling close channel task") self._close_channel_waiter.set_result(None) await self._...
[ "async", "def", "close", "(", "self", ")", "->", "None", ":", "try", ":", "logger", ".", "debug", "(", "\"closing channel\"", ")", "if", "not", "self", ".", "is_closed", ":", "if", "not", "self", ".", "is_closing", ":", "logger", ".", "debug", "(", "...
Close the client Execute closing sequence.
[ "Close", "the", "client", "Execute", "closing", "sequence", "." ]
[ "\"\"\"\n Close the client\n \n Execute closing sequence. Calls to `recv` after the closing\n sequence has started will raise ChannelClosed\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c0b06f0ddeae42e9894677a45f008a65f40bbba0
newvicx/piwebasync
piwebasync/websockets/client.py
[ "MIT" ]
Python
_ensure_open
None
async def _ensure_open(self) -> None: """ Check if channel is open If `update` is called, the channel will appear to be closed. Calls to `recv` will wait to aquire the lock indicating the update process finished before assessing the state of the channel. If an error occ...
Check if channel is open If `update` is called, the channel will appear to be closed. Calls to `recv` will wait to aquire the lock indicating the update process finished before assessing the state of the channel. If an error occurred during channel operation, this method ...
Check if channel is open If `update` is called, the channel will appear to be closed. Calls to `recv` will wait to aquire the lock indicating the update process finished before assessing the state of the channel. If an error occurred during channel operation, this method will raise ~piwebasync.exceptions.ChannelClosed...
[ "Check", "if", "channel", "is", "open", "If", "`", "update", "`", "is", "called", "the", "channel", "will", "appear", "to", "be", "closed", ".", "Calls", "to", "`", "recv", "`", "will", "wait", "to", "aquire", "the", "lock", "indicating", "the", "updat...
async def _ensure_open(self) -> None: async with self._update_lock: if self.is_closed or self.is_closing: self._raise_channel_exc()
[ "async", "def", "_ensure_open", "(", "self", ")", "->", "None", ":", "async", "with", "self", ".", "_update_lock", ":", "if", "self", ".", "is_closed", "or", "self", ".", "is_closing", ":", "self", ".", "_raise_channel_exc", "(", ")" ]
Check if channel is open If `update` is called, the channel will appear to be closed.
[ "Check", "if", "channel", "is", "open", "If", "`", "update", "`", "is", "called", "the", "channel", "will", "appear", "to", "be", "closed", "." ]
[ "\"\"\"\n Check if channel is open\n\n If `update` is called, the channel will appear to be closed.\n Calls to `recv` will wait to aquire the lock indicating the\n update process finished before assessing the state of the channel.\n\n If an error occurred during channel operation,...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c0b06f0ddeae42e9894677a45f008a65f40bbba0
newvicx/piwebasync
piwebasync/websockets/client.py
[ "MIT" ]
Python
_start
None
async def _start(self) -> None: """ Establish channel connection Raises: - asyncio.TimeoutError: Operation timed out trying to establish connection - RuntimeError: Attempted to open channel that is not closed or `close` was not called """ ...
Establish channel connection Raises: - asyncio.TimeoutError: Operation timed out trying to establish connection - RuntimeError: Attempted to open channel that is not closed or `close` was not called
Establish channel connection Raises: asyncio.TimeoutError: Operation timed out trying to establish connection RuntimeError: Attempted to open channel that is not closed or `close` was not called
[ "Establish", "channel", "connection", "Raises", ":", "asyncio", ".", "TimeoutError", ":", "Operation", "timed", "out", "trying", "to", "establish", "connection", "RuntimeError", ":", "Attempted", "to", "open", "channel", "that", "is", "not", "closed", "or", "`",...
async def _start(self) -> None: if not self.is_closed: raise RuntimeError( "Cannot open new connection. Client is not closed" ) self._channel_exc = None run_channel_task = self._loop.create_task(self._run()) try: await asyncio.wait_for(...
[ "async", "def", "_start", "(", "self", ")", "->", "None", ":", "if", "not", "self", ".", "is_closed", ":", "raise", "RuntimeError", "(", "\"Cannot open new connection. Client is not closed\"", ")", "self", ".", "_channel_exc", "=", "None", "run_channel_task", "=",...
Establish channel connection Raises: asyncio.TimeoutError: Operation timed out trying to establish connection RuntimeError: Attempted to open channel that is not closed or `close` was not called
[ "Establish", "channel", "connection", "Raises", ":", "asyncio", ".", "TimeoutError", ":", "Operation", "timed", "out", "trying", "to", "establish", "connection", "RuntimeError", ":", "Attempted", "to", "open", "channel", "that", "is", "not", "closed", "or", "`",...
[ "\"\"\"\n Establish channel connection\n\n Raises:\n - asyncio.TimeoutError: Operation timed out trying to\n establish connection\n - RuntimeError: Attempted to open channel that is not\n closed or `close` was not called\n \"\"\"", "# connection est...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c0b06f0ddeae42e9894677a45f008a65f40bbba0
newvicx/piwebasync
piwebasync/websockets/client.py
[ "MIT" ]
Python
_run
None
async def _run(self) -> None: """ Run websocket protocol and data transfer in a loop This task will continuously attempt to establish a websocket connection to the channel endpoint. Once a connection is established it will begin a data transfer task to receive messages, process ...
Run websocket protocol and data transfer in a loop This task will continuously attempt to establish a websocket connection to the channel endpoint. Once a connection is established it will begin a data transfer task to receive messages, process them, and place them in a buffer....
Run websocket protocol and data transfer in a loop This task will continuously attempt to establish a websocket connection to the channel endpoint. Once a connection is established it will begin a data transfer task to receive messages, process them, and place them in a buffer. If the websocket connection is closed via...
[ "Run", "websocket", "protocol", "and", "data", "transfer", "in", "a", "loop", "This", "task", "will", "continuously", "attempt", "to", "establish", "a", "websocket", "connection", "to", "the", "channel", "endpoint", ".", "Once", "a", "connection", "is", "estab...
async def _run(self) -> None: try: async for protocol in websockets.connect(self.url, **self._ws_connect_params): logger.debug("channel opened") self._channel_open_event.set() try: await self._transfer_data(protocol) ...
[ "async", "def", "_run", "(", "self", ")", "->", "None", ":", "try", ":", "async", "for", "protocol", "in", "websockets", ".", "connect", "(", "self", ".", "url", ",", "**", "self", ".", "_ws_connect_params", ")", ":", "logger", ".", "debug", "(", "\"...
Run websocket protocol and data transfer in a loop This task will continuously attempt to establish a websocket connection to the channel endpoint.
[ "Run", "websocket", "protocol", "and", "data", "transfer", "in", "a", "loop", "This", "task", "will", "continuously", "attempt", "to", "establish", "a", "websocket", "connection", "to", "the", "channel", "endpoint", "." ]
[ "\"\"\"\n Run websocket protocol and data transfer in a loop\n\n This task will continuously attempt to establish a websocket\n connection to the channel endpoint. Once a connection is established\n it will begin a data transfer task to receive messages, process them,\n and place ...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c0b06f0ddeae42e9894677a45f008a65f40bbba0
newvicx/piwebasync
piwebasync/websockets/client.py
[ "MIT" ]
Python
_close_channel
None
async def _close_channel(self) -> None: """ Close the channel This task is started after the first connection to the channel endpoint is established. It ensures `run channel task` finishes """ close_channel_waiter = self._loop.create_future() self._close...
Close the channel This task is started after the first connection to the channel endpoint is established. It ensures `run channel task` finishes
Close the channel This task is started after the first connection to the channel endpoint is established. It ensures `run channel task` finishes
[ "Close", "the", "channel", "This", "task", "is", "started", "after", "the", "first", "connection", "to", "the", "channel", "endpoint", "is", "established", ".", "It", "ensures", "`", "run", "channel", "task", "`", "finishes" ]
async def _close_channel(self) -> None: close_channel_waiter = self._loop.create_future() self._close_channel_waiter = close_channel_waiter try: await asyncio.wait( [close_channel_waiter, self._run_channel_task], return_when=asyncio.FIRST_COMPLETED ...
[ "async", "def", "_close_channel", "(", "self", ")", "->", "None", ":", "close_channel_waiter", "=", "self", ".", "_loop", ".", "create_future", "(", ")", "self", ".", "_close_channel_waiter", "=", "close_channel_waiter", "try", ":", "await", "asyncio", ".", "w...
Close the channel This task is started after the first connection to the channel endpoint is established.
[ "Close", "the", "channel", "This", "task", "is", "started", "after", "the", "first", "connection", "to", "the", "channel", "endpoint", "is", "established", "." ]
[ "\"\"\"\n Close the channel\n\n This task is started after the first connection to the\n channel endpoint is established. It ensures `run channel task`\n finishes\n \"\"\"", "# if wait was cancelled or close_channel_waiter finished", "# first, cancel _run_channel_task" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c0b06f0ddeae42e9894677a45f008a65f40bbba0
newvicx/piwebasync
piwebasync/websockets/client.py
[ "MIT" ]
Python
_transfer_data
None
async def _transfer_data(self, protocol: WebsocketAuthProtocol) -> None: """ Receive and process messages from websocket connection. Place processed messages in buffer This method will continuously receive messages from an open websocket connection. It is always awaited on by th...
Receive and process messages from websocket connection. Place processed messages in buffer This method will continuously receive messages from an open websocket connection. It is always awaited on by the `run` method. Any that ocurrs will propagate to and be handled by the pare...
Receive and process messages from websocket connection. Place processed messages in buffer This method will continuously receive messages from an open websocket connection. It is always awaited on by the `run` method. Any that ocurrs will propagate to and be handled by the parent task. Flow control is handled at the p...
[ "Receive", "and", "process", "messages", "from", "websocket", "connection", ".", "Place", "processed", "messages", "in", "buffer", "This", "method", "will", "continuously", "receive", "messages", "from", "an", "open", "websocket", "connection", ".", "It", "is", ...
async def _transfer_data(self, protocol: WebsocketAuthProtocol) -> None: try: self._no_data_transfer_event.clear() async for message in protocol: websocket_message = self._process_message(message) logger.debug("message received for endpoint %s", websocket_...
[ "async", "def", "_transfer_data", "(", "self", ",", "protocol", ":", "WebsocketAuthProtocol", ")", "->", "None", ":", "try", ":", "self", ".", "_no_data_transfer_event", ".", "clear", "(", ")", "async", "for", "message", "in", "protocol", ":", "websocket_messa...
Receive and process messages from websocket connection.
[ "Receive", "and", "process", "messages", "from", "websocket", "connection", "." ]
[ "\"\"\"\n Receive and process messages from websocket connection. Place processed\n messages in buffer\n\n This method will continuously receive messages from an open websocket\n connection. It is always awaited on by the `run` method. Any that ocurrs\n will propagate to and be ha...
[ { "param": "self", "type": null }, { "param": "protocol", "type": "WebsocketAuthProtocol" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "protocol", "type": "WebsocketAuthProtocol", "docstring": null, ...
c0b06f0ddeae42e9894677a45f008a65f40bbba0
newvicx/piwebasync
piwebasync/websockets/client.py
[ "MIT" ]
Python
_process_message
WebsocketMessage
def _process_message(self, message: Union[bytes, str]) -> WebsocketMessage: """ Parse message from websocket to WebsocketMessage object Args: message (Union[str, bytes]): Raw message returned from websocket Returns: WebsocketMessage: Formatted PI Web API channel...
Parse message from websocket to WebsocketMessage object Args: message (Union[str, bytes]): Raw message returned from websocket Returns: WebsocketMessage: Formatted PI Web API channel message
Parse message from websocket to WebsocketMessage object
[ "Parse", "message", "from", "websocket", "to", "WebsocketMessage", "object" ]
def _process_message(self, message: Union[bytes, str]) -> WebsocketMessage: try: content = orjson.loads(message) if isinstance(message, bytes) else json.loads(message) except (json.JSONDecodeError, orjson.JSONDecodeError) as err: message = message.decode() if isinstance(message, ...
[ "def", "_process_message", "(", "self", ",", "message", ":", "Union", "[", "bytes", ",", "str", "]", ")", "->", "WebsocketMessage", ":", "try", ":", "content", "=", "orjson", ".", "loads", "(", "message", ")", "if", "isinstance", "(", "message", ",", "...
Parse message from websocket to WebsocketMessage object
[ "Parse", "message", "from", "websocket", "to", "WebsocketMessage", "object" ]
[ "\"\"\"\n Parse message from websocket to WebsocketMessage object\n\n Args:\n message (Union[str, bytes]): Raw message returned from websocket\n\n Returns:\n WebsocketMessage: Formatted PI Web API channel message\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "message", "type": "Union[bytes, str]" } ]
{ "returns": [ { "docstring": "Formatted PI Web API channel message", "docstring_tokens": [ "Formatted", "PI", "Web", "API", "channel", "message" ], "type": "WebsocketMessage" } ], "raises": [], "params": [ { "identifier":...
c0b06f0ddeae42e9894677a45f008a65f40bbba0
newvicx/piwebasync
piwebasync/websockets/client.py
[ "MIT" ]
Python
_watchdog
None
async def _watchdog(self) -> None: """ Oversee channel reconnects. Close the channel if unable to reconnect If the watchdog times out it will start the channel closing process and set the `channel_exc` property. Calls to `recv` will raise a `~piwebasync.exceptions.ChannelClosedE...
Oversee channel reconnects. Close the channel if unable to reconnect If the watchdog times out it will start the channel closing process and set the `channel_exc` property. Calls to `recv` will raise a `~piwebasync.exceptions.ChannelClosedError` resulting from `~piwebasync.exce...
Oversee channel reconnects. Close the channel if unable to reconnect If the watchdog times out it will start the channel closing process and set the `channel_exc` property.
[ "Oversee", "channel", "reconnects", ".", "Close", "the", "channel", "if", "unable", "to", "reconnect", "If", "the", "watchdog", "times", "out", "it", "will", "start", "the", "channel", "closing", "process", "and", "set", "the", "`", "channel_exc", "`", "prop...
async def _watchdog(self) -> None: if self._reconnect: logger.debug("watchdog active") drops = 0 while True: if self.is_closed or self.is_closing: break try: try: logger.debug("wai...
[ "async", "def", "_watchdog", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_reconnect", ":", "logger", ".", "debug", "(", "\"watchdog active\"", ")", "drops", "=", "0", "while", "True", ":", "if", "self", ".", "is_closed", "or", "self", ".",...
Oversee channel reconnects.
[ "Oversee", "channel", "reconnects", "." ]
[ "\"\"\"\n Oversee channel reconnects. Close the channel if unable to reconnect\n\n If the watchdog times out it will start the channel closing process\n and set the `channel_exc` property. Calls to `recv` will raise a\n `~piwebasync.exceptions.ChannelClosedError` resulting from\n ...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c0b06f0ddeae42e9894677a45f008a65f40bbba0
newvicx/piwebasync
piwebasync/websockets/client.py
[ "MIT" ]
Python
_verify_request
None
def _verify_request( self, request: APIRequest ) -> None: """ Validates request type and also validates client can handle request Raises: - TypeError: request is not an instance of APIRequest - ValueError: client does not support this request ...
Validates request type and also validates client can handle request Raises: - TypeError: request is not an instance of APIRequest - ValueError: client does not support this request
Validates request type and also validates client can handle request
[ "Validates", "request", "type", "and", "also", "validates", "client", "can", "handle", "request" ]
def _verify_request( self, request: APIRequest ) -> None: if not isinstance(request, APIRequest): raise TypeError(f"'request' must be instance of APIRequest. Got {type(request)}") if request.method != "GET": raise ValueError( f"Invalid method f...
[ "def", "_verify_request", "(", "self", ",", "request", ":", "APIRequest", ")", "->", "None", ":", "if", "not", "isinstance", "(", "request", ",", "APIRequest", ")", ":", "raise", "TypeError", "(", "f\"'request' must be instance of APIRequest. Got {type(request)}\"", ...
Validates request type and also validates client can handle request
[ "Validates", "request", "type", "and", "also", "validates", "client", "can", "handle", "request" ]
[ "\"\"\"\n Validates request type and also validates client can handle request\n\n Raises:\n - TypeError: request is not an instance of APIRequest\n - ValueError: client does not support this request\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "request", "type": "APIRequest" } ]
{ "returns": [], "raises": [ { "docstring": "request is not an instance of APIRequest", "docstring_tokens": [ "request", "is", "not", "an", "instance", "of", "APIRequest" ], "type": "- TypeError" }, { "docstring": "cli...
d2496fa4ade78110a4ea072b4e2f8fa20c2363ff
screamyao/bear_backup
bear_backup.py
[ "MIT" ]
Python
text_with_converted_asset_paths
<not_specific>
def text_with_converted_asset_paths(self): """Returns the note text, but with any asset paths changed to point to the textbundle location. In addition, the image/file prefixes to the image path are removed too, because in an exported bearnote file it's just [assets/filename.ext]...
Returns the note text, but with any asset paths changed to point to the textbundle location. In addition, the image/file prefixes to the image path are removed too, because in an exported bearnote file it's just [assets/filename.ext]
Returns the note text, but with any asset paths changed to point to the textbundle location. In addition, the image/file prefixes to the image path are removed too, because in an exported bearnote file it's just [assets/filename.ext]
[ "Returns", "the", "note", "text", "but", "with", "any", "asset", "paths", "changed", "to", "point", "to", "the", "textbundle", "location", ".", "In", "addition", "the", "image", "/", "file", "prefixes", "to", "the", "image", "path", "are", "removed", "too"...
def text_with_converted_asset_paths(self): return re.sub(asset_re, lambda m: "[%s]" % (self.convert_asset_path(m[2])), self.text())
[ "def", "text_with_converted_asset_paths", "(", "self", ")", ":", "return", "re", ".", "sub", "(", "asset_re", ",", "lambda", "m", ":", "\"[%s]\"", "%", "(", "self", ".", "convert_asset_path", "(", "m", "[", "2", "]", ")", ")", ",", "self", ".", "text",...
Returns the note text, but with any asset paths changed to point to the textbundle location.
[ "Returns", "the", "note", "text", "but", "with", "any", "asset", "paths", "changed", "to", "point", "to", "the", "textbundle", "location", "." ]
[ "\"\"\"Returns the note text, but with any asset paths changed to point to\n the textbundle location.\n\n In addition, the image/file prefixes to the image path are removed\n too, because in an exported bearnote file it's just\n [assets/filename.ext]\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d2496fa4ade78110a4ea072b4e2f8fa20c2363ff
screamyao/bear_backup
bear_backup.py
[ "MIT" ]
Python
filename
<not_specific>
def filename(self): """Generates a filename from the note title, without any file extension""" filename = self.title() # Strip anything that isn't alphanumeric or spaces filename = re.sub('[^\w\s]+', '_', filename) # Collapse spaces filename = re.sub('\s+', ' ', f...
Generates a filename from the note title, without any file extension
Generates a filename from the note title, without any file extension
[ "Generates", "a", "filename", "from", "the", "note", "title", "without", "any", "file", "extension" ]
def filename(self): filename = self.title() filename = re.sub('[^\w\s]+', '_', filename) filename = re.sub('\s+', ' ', filename) return filename
[ "def", "filename", "(", "self", ")", ":", "filename", "=", "self", ".", "title", "(", ")", "filename", "=", "re", ".", "sub", "(", "'[^\\w\\s]+'", ",", "'_'", ",", "filename", ")", "filename", "=", "re", ".", "sub", "(", "'\\s+'", ",", "' '", ",", ...
Generates a filename from the note title, without any file extension
[ "Generates", "a", "filename", "from", "the", "note", "title", "without", "any", "file", "extension" ]
[ "\"\"\"Generates a filename from the note title, without any file\n extension\"\"\"", "# Strip anything that isn't alphanumeric or spaces", "# Collapse spaces" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d2496fa4ade78110a4ea072b4e2f8fa20c2363ff
screamyao/bear_backup
bear_backup.py
[ "MIT" ]
Python
zip_note
null
def zip_note(self, filename=None): """Adds the note to a zipfile in bearnote format. The bearnote format is almost identical to the textbundle format, except that asset (image and pdf) links aren't markdown images, they're just `[path/to/file]` (without backticks) """ if...
Adds the note to a zipfile in bearnote format. The bearnote format is almost identical to the textbundle format, except that asset (image and pdf) links aren't markdown images, they're just `[path/to/file]` (without backticks)
Adds the note to a zipfile in bearnote format. The bearnote format is almost identical to the textbundle format, except that asset (image and pdf) links aren't markdown images, they're just `[path/to/file]` (without backticks)
[ "Adds", "the", "note", "to", "a", "zipfile", "in", "bearnote", "format", ".", "The", "bearnote", "format", "is", "almost", "identical", "to", "the", "textbundle", "format", "except", "that", "asset", "(", "image", "and", "pdf", ")", "links", "aren", "'", ...
def zip_note(self, filename=None): if filename is None: filename = self.filename() filename = pathlib.Path(filename).with_suffix(".bearnote") zip_file = zipfile.ZipFile(str(filename), "w", compression=zipfile.ZIP_DEFLATED) zip_file.writestr(os.p...
[ "def", "zip_note", "(", "self", ",", "filename", "=", "None", ")", ":", "if", "filename", "is", "None", ":", "filename", "=", "self", ".", "filename", "(", ")", "filename", "=", "pathlib", ".", "Path", "(", "filename", ")", ".", "with_suffix", "(", "...
Adds the note to a zipfile in bearnote format.
[ "Adds", "the", "note", "to", "a", "zipfile", "in", "bearnote", "format", "." ]
[ "\"\"\"Adds the note to a zipfile in bearnote format.\n\n The bearnote format is almost identical to the textbundle format,\n except that asset (image and pdf) links aren't markdown images,\n they're just `[path/to/file]` (without backticks)\n \"\"\"", "# Add info.json", "# Add text"...
[ { "param": "self", "type": null }, { "param": "filename", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "filename", "type": null, "docstring": null, "docstring_tokens...
e5659c7a84ae67cd181353882e7d5470014c14cb
rhbvkleef/SteamBird
steambird/teacher/views.py
[ "BSD-3-Clause" ]
Python
form_valid
HttpResponseRedirect
def form_valid(self, form: Form) -> HttpResponseRedirect: """ Makes sure the data is saved after submission. :param form: The form and its data. :return: a redirect to get_success_url. """ new_mspline = form.save(commit=False) new_mspline.created_by = self.reques...
Makes sure the data is saved after submission. :param form: The form and its data. :return: a redirect to get_success_url.
Makes sure the data is saved after submission.
[ "Makes", "sure", "the", "data", "is", "saved", "after", "submission", "." ]
def form_valid(self, form: Form) -> HttpResponseRedirect: new_mspline = form.save(commit=False) new_mspline.created_by = self.request.user new_mspline.created_by_side = "TEACHER" new_mspline.save() form.save_m2m() return super().form_valid(form)
[ "def", "form_valid", "(", "self", ",", "form", ":", "Form", ")", "->", "HttpResponseRedirect", ":", "new_mspline", "=", "form", ".", "save", "(", "commit", "=", "False", ")", "new_mspline", ".", "created_by", "=", "self", ".", "request", ".", "user", "ne...
Makes sure the data is saved after submission.
[ "Makes", "sure", "the", "data", "is", "saved", "after", "submission", "." ]
[ "\"\"\"\n Makes sure the data is saved after submission.\n\n :param form: The form and its data.\n :return: a redirect to get_success_url.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "form", "type": "Form" } ]
{ "returns": [ { "docstring": "a redirect to get_success_url.", "docstring_tokens": [ "a", "redirect", "to", "get_success_url", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "...
7aaa49f235259326cff64b8b12de347a53c66a16
rhbvkleef/SteamBird
steambird/boecie/forms.py
[ "BSD-3-Clause" ]
Python
StudyCourseForm
<not_specific>
def StudyCourseForm(has_course_field: bool = False): """ Function which returns a modelform for usage in a page. The function is used to create a form to link information between studies anc courses. E.g. form_class = StudyCourseForm(True) Will return a form with Course field and Study...
Function which returns a modelform for usage in a page. The function is used to create a form to link information between studies anc courses. E.g. form_class = StudyCourseForm(True) Will return a form with Course field and Study-year visible, study-field is hidden input. While: ...
Function which returns a modelform for usage in a page. The function is used to create a form to link information between studies anc courses. Will return a form with Course field and Study-year visible, study-field is hidden input. Will return a form with Study field and Study-year visible, Course-field is hidd...
[ "Function", "which", "returns", "a", "modelform", "for", "usage", "in", "a", "page", ".", "The", "function", "is", "used", "to", "create", "a", "form", "to", "link", "information", "between", "studies", "anc", "courses", ".", "Will", "return", "a", "form",...
def StudyCourseForm(has_course_field: bool = False): class _cls(forms.ModelForm): class Meta: model = CourseStudy fields = [ 'study_year', ] + (['course'] if has_course_field else ['study']) if has_course_field: widgets = { ...
[ "def", "StudyCourseForm", "(", "has_course_field", ":", "bool", "=", "False", ")", ":", "class", "_cls", "(", "forms", ".", "ModelForm", ")", ":", "class", "Meta", ":", "model", "=", "CourseStudy", "fields", "=", "[", "'study_year'", ",", "]", "+", "(", ...
Function which returns a modelform for usage in a page.
[ "Function", "which", "returns", "a", "modelform", "for", "usage", "in", "a", "page", "." ]
[ "\"\"\"\n Function which returns a modelform for usage in a page. The function is used to create a form to\n link information between studies anc courses.\n\n E.g.\n form_class = StudyCourseForm(True)\n\n Will return a form with Course field and Study-year visible, study-field is hidden input...
[ { "param": "has_course_field", "type": "bool" } ]
{ "returns": [ { "docstring": "ModelForm with either Study or Course field", "docstring_tokens": [ "ModelForm", "with", "either", "Study", "or", "Course", "field" ], "type": null } ], "raises": [], "params": [ { "i...
b5641e161ffe2c659e96d7da56821c7be01e7a93
rhbvkleef/SteamBird
steambird/material_management/tools.py
[ "BSD-3-Clause" ]
Python
isbn_lookup
<not_specific>
def isbn_lookup(isbn: str): """ Tool that uses isbnlib to look up information for the given ISBN. :param isbn: ISBN in string format, as ISBN can also have some letters and dashes :return: Dict with data, or None """ try: meta_info = isbnlib.meta(isbn) desc = isbnlib.desc(isbn) ...
Tool that uses isbnlib to look up information for the given ISBN. :param isbn: ISBN in string format, as ISBN can also have some letters and dashes :return: Dict with data, or None
Tool that uses isbnlib to look up information for the given ISBN.
[ "Tool", "that", "uses", "isbnlib", "to", "look", "up", "information", "for", "the", "given", "ISBN", "." ]
def isbn_lookup(isbn: str): try: meta_info = isbnlib.meta(isbn) desc = isbnlib.desc(isbn) cover = isbnlib.cover(isbn) try: meta_info['img'] = cover['thumbnail'] except (TypeError, KeyError): meta_info['img'] = None return { 'meta': ...
[ "def", "isbn_lookup", "(", "isbn", ":", "str", ")", ":", "try", ":", "meta_info", "=", "isbnlib", ".", "meta", "(", "isbn", ")", "desc", "=", "isbnlib", ".", "desc", "(", "isbn", ")", "cover", "=", "isbnlib", ".", "cover", "(", "isbn", ")", "try", ...
Tool that uses isbnlib to look up information for the given ISBN.
[ "Tool", "that", "uses", "isbnlib", "to", "look", "up", "information", "for", "the", "given", "ISBN", "." ]
[ "\"\"\"\n Tool that uses isbnlib to look up information for the given ISBN.\n\n :param isbn: ISBN in string format, as ISBN can also have some letters and dashes\n :return: Dict with data, or None\n \"\"\"" ]
[ { "param": "isbn", "type": "str" } ]
{ "returns": [ { "docstring": "Dict with data, or None", "docstring_tokens": [ "Dict", "with", "data", "or", "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "isbn", "type": "str", "docstring": "IS...
b5641e161ffe2c659e96d7da56821c7be01e7a93
rhbvkleef/SteamBird
steambird/material_management/tools.py
[ "BSD-3-Clause" ]
Python
doi_lookup
Optional[dict]
def doi_lookup(doi: str) -> Optional[dict]: """ Tool that uses crossref package to retrieve information based on DOI inputted :param doi: DOI of any kind :return: Dictionary containing (a lot of) info or None """ info = works.doi(doi) return info
Tool that uses crossref package to retrieve information based on DOI inputted :param doi: DOI of any kind :return: Dictionary containing (a lot of) info or None
Tool that uses crossref package to retrieve information based on DOI inputted
[ "Tool", "that", "uses", "crossref", "package", "to", "retrieve", "information", "based", "on", "DOI", "inputted" ]
def doi_lookup(doi: str) -> Optional[dict]: info = works.doi(doi) return info
[ "def", "doi_lookup", "(", "doi", ":", "str", ")", "->", "Optional", "[", "dict", "]", ":", "info", "=", "works", ".", "doi", "(", "doi", ")", "return", "info" ]
Tool that uses crossref package to retrieve information based on DOI inputted
[ "Tool", "that", "uses", "crossref", "package", "to", "retrieve", "information", "based", "on", "DOI", "inputted" ]
[ "\"\"\"\n Tool that uses crossref package to retrieve information based on DOI inputted\n\n :param doi: DOI of any kind\n :return: Dictionary containing (a lot of) info or None\n \"\"\"" ]
[ { "param": "doi", "type": "str" } ]
{ "returns": [ { "docstring": "Dictionary containing (a lot of) info or None", "docstring_tokens": [ "Dictionary", "containing", "(", "a", "lot", "of", ")", "info", "or", "None" ], "type": null } ], "ra...
ba53c9a0cf98666a8c982fde757d59407cabb697
rhbvkleef/SteamBird
steambird/util/multi_form_view.py
[ "BSD-3-Clause" ]
Python
form_valid
Optional[Any]
def form_valid(self, request: HttpRequest, form: Form, form_name: str) -> Optional[Any]: """ Callback for a post request that sent valid form data. :param request: The request that was received. :param form: The form that was valid. :param form_name: The name of the form that wa...
Callback for a post request that sent valid form data. :param request: The request that was received. :param form: The form that was valid. :param form_name: The name of the form that was filled out. :return: Nothing or a response
Callback for a post request that sent valid form data.
[ "Callback", "for", "a", "post", "request", "that", "sent", "valid", "form", "data", "." ]
def form_valid(self, request: HttpRequest, form: Form, form_name: str) -> Optional[Any]: return False
[ "def", "form_valid", "(", "self", ",", "request", ":", "HttpRequest", ",", "form", ":", "Form", ",", "form_name", ":", "str", ")", "->", "Optional", "[", "Any", "]", ":", "return", "False" ]
Callback for a post request that sent valid form data.
[ "Callback", "for", "a", "post", "request", "that", "sent", "valid", "form", "data", "." ]
[ "\"\"\"\n Callback for a post request that sent valid form data.\n\n :param request: The request that was received.\n :param form: The form that was valid.\n :param form_name: The name of the form that was filled out.\n :return: Nothing or a response\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "request", "type": "HttpRequest" }, { "param": "form", "type": "Form" }, { "param": "form_name", "type": "str" } ]
{ "returns": [ { "docstring": "Nothing or a response", "docstring_tokens": [ "Nothing", "or", "a", "response" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docst...
ba53c9a0cf98666a8c982fde757d59407cabb697
rhbvkleef/SteamBird
steambird/util/multi_form_view.py
[ "BSD-3-Clause" ]
Python
form_invalid
Optional[Any]
def form_invalid(self, request: HttpRequest, form: Form, form_name: str) -> Optional[Any]: """ Callback for a post request that sent invalid data. :param request: The request that was received. :param form: The form that was invalid. :param form_name: The name of the form that w...
Callback for a post request that sent invalid data. :param request: The request that was received. :param form: The form that was invalid. :param form_name: The name of the form that was filled out. :return: Nothing or a response
Callback for a post request that sent invalid data.
[ "Callback", "for", "a", "post", "request", "that", "sent", "invalid", "data", "." ]
def form_invalid(self, request: HttpRequest, form: Form, form_name: str) -> Optional[Any]: return False
[ "def", "form_invalid", "(", "self", ",", "request", ":", "HttpRequest", ",", "form", ":", "Form", ",", "form_name", ":", "str", ")", "->", "Optional", "[", "Any", "]", ":", "return", "False" ]
Callback for a post request that sent invalid data.
[ "Callback", "for", "a", "post", "request", "that", "sent", "invalid", "data", "." ]
[ "\"\"\"\n Callback for a post request that sent invalid data.\n\n :param request: The request that was received.\n :param form: The form that was invalid.\n :param form_name: The name of the form that was filled out.\n :return: Nothing or a response\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "request", "type": "HttpRequest" }, { "param": "form", "type": "Form" }, { "param": "form_name", "type": "str" } ]
{ "returns": [ { "docstring": "Nothing or a response", "docstring_tokens": [ "Nothing", "or", "a", "response" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docst...
ba53c9a0cf98666a8c982fde757d59407cabb697
rhbvkleef/SteamBird
steambird/util/multi_form_view.py
[ "BSD-3-Clause" ]
Python
handle_post_forms
Optional[Any]
def handle_post_forms(self, request, forms) -> Optional[Any]: """ Fork to the validation functions in case of form submissions. :param request: The POST request that was received with form data. :param forms: The forms that were shown on this page. :return: Nothing or a response...
Fork to the validation functions in case of form submissions. :param request: The POST request that was received with form data. :param forms: The forms that were shown on this page. :return: Nothing or a response
Fork to the validation functions in case of form submissions.
[ "Fork", "to", "the", "validation", "functions", "in", "case", "of", "form", "submissions", "." ]
def handle_post_forms(self, request, forms) -> Optional[Any]: if not request.POST: return None form_name = request.POST[self.__class__.form_name_field_name] form = forms[form_name] if not form: return None if form.is_valid(): return self.form_v...
[ "def", "handle_post_forms", "(", "self", ",", "request", ",", "forms", ")", "->", "Optional", "[", "Any", "]", ":", "if", "not", "request", ".", "POST", ":", "return", "None", "form_name", "=", "request", ".", "POST", "[", "self", ".", "__class__", "."...
Fork to the validation functions in case of form submissions.
[ "Fork", "to", "the", "validation", "functions", "in", "case", "of", "form", "submissions", "." ]
[ "\"\"\"\n Fork to the validation functions in case of form submissions.\n\n :param request: The POST request that was received with form data.\n :param forms: The forms that were shown on this page.\n :return: Nothing or a response\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "request", "type": null }, { "param": "forms", "type": null } ]
{ "returns": [ { "docstring": "Nothing or a response", "docstring_tokens": [ "Nothing", "or", "a", "response" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docst...
b2f8bb9e8254121a80944279788566a14ea4d0fc
rhbvkleef/SteamBird
steambird/templatetags/ut_url_mapper.py
[ "BSD-3-Clause" ]
Python
osiris_url
str
def osiris_url(course_code, calendar_year) -> str: """ A template tag which resolves the params into a Osiris URL. Calendar Year is understood as Academic year which started in that year E.g. 2018 is understood as September 2018/ July 2019 :param course_code: The course-code you are looking for. [...
A template tag which resolves the params into a Osiris URL. Calendar Year is understood as Academic year which started in that year E.g. 2018 is understood as September 2018/ July 2019 :param course_code: The course-code you are looking for. [0-9,a-z,A-Z] is possible :param calendar_year: int ...
A template tag which resolves the params into a Osiris URL. Calendar Year is understood as Academic year which started in that year
[ "A", "template", "tag", "which", "resolves", "the", "params", "into", "a", "Osiris", "URL", ".", "Calendar", "Year", "is", "understood", "as", "Academic", "year", "which", "started", "in", "that", "year" ]
def osiris_url(course_code, calendar_year) -> str: return "https://osiris.utwente.nl/student/OnderwijsCatalogusSelect.do" \ "?selectie=cursus&cursus={}&collegejaar={}" \ .format(course_code, calendar_year)
[ "def", "osiris_url", "(", "course_code", ",", "calendar_year", ")", "->", "str", ":", "return", "\"https://osiris.utwente.nl/student/OnderwijsCatalogusSelect.do\"", "\"?selectie=cursus&cursus={}&collegejaar={}\"", ".", "format", "(", "course_code", ",", "calendar_year", ")" ]
A template tag which resolves the params into a Osiris URL.
[ "A", "template", "tag", "which", "resolves", "the", "params", "into", "a", "Osiris", "URL", "." ]
[ "\"\"\"\n A template tag which resolves the params into a Osiris URL.\n Calendar Year is understood as Academic year which started in that year\n\n E.g. 2018 is understood as September 2018/ July 2019\n\n :param course_code: The course-code you are looking for. [0-9,a-z,A-Z] is possible\n :param cale...
[ { "param": "course_code", "type": null }, { "param": "calendar_year", "type": null } ]
{ "returns": [ { "docstring": "Osiris URL for course_code in calendar_year", "docstring_tokens": [ "Osiris", "URL", "for", "course_code", "in", "calendar_year" ], "type": null } ], "raises": [], "params": [ { "identifier":...
b2f8bb9e8254121a80944279788566a14ea4d0fc
rhbvkleef/SteamBird
steambird/templatetags/ut_url_mapper.py
[ "BSD-3-Clause" ]
Python
people_utwente
str
def people_utwente(initials, surname_prefix, surname) -> str: """ Template tag which resolves teacher names into a people.utwente.nl URL :param initials: string :param surname_prefix: string :param surname: string :return: people.utwente.nl URL for given teacher """ if surname_prefix is...
Template tag which resolves teacher names into a people.utwente.nl URL :param initials: string :param surname_prefix: string :param surname: string :return: people.utwente.nl URL for given teacher
Template tag which resolves teacher names into a people.utwente.nl URL
[ "Template", "tag", "which", "resolves", "teacher", "names", "into", "a", "people", ".", "utwente", ".", "nl", "URL" ]
def people_utwente(initials, surname_prefix, surname) -> str: if surname_prefix is None: surname_prefix = "" return "https://people.utwente.nl/{}{}{}" \ .format(initials, surname_prefix, surname).replace(' ', '')
[ "def", "people_utwente", "(", "initials", ",", "surname_prefix", ",", "surname", ")", "->", "str", ":", "if", "surname_prefix", "is", "None", ":", "surname_prefix", "=", "\"\"", "return", "\"https://people.utwente.nl/{}{}{}\"", ".", "format", "(", "initials", ",",...
Template tag which resolves teacher names into a people.utwente.nl URL
[ "Template", "tag", "which", "resolves", "teacher", "names", "into", "a", "people", ".", "utwente", ".", "nl", "URL" ]
[ "\"\"\"\n Template tag which resolves teacher names into a people.utwente.nl URL\n\n :param initials: string\n :param surname_prefix: string\n :param surname: string\n :return: people.utwente.nl URL for given teacher\n \"\"\"" ]
[ { "param": "initials", "type": null }, { "param": "surname_prefix", "type": null }, { "param": "surname", "type": null } ]
{ "returns": [ { "docstring": "people.utwente.nl URL for given teacher", "docstring_tokens": [ "people", ".", "utwente", ".", "nl", "URL", "for", "given", "teacher" ], "type": null } ], "raises": [], "params"...
66fb6d266213d7a59cbc2a84d611e2c319141f51
rhbvkleef/SteamBird
steambird/boecie/views.py
[ "BSD-3-Clause" ]
Python
form_valid
HttpResponseRedirect
def form_valid(self, form: Form) -> HttpResponseRedirect: """ If the form is valid, save to the associated model. Sets the hidden-field to a valid id before saving. :param form: form object :return: HttpResponRedirect defined by get_success_url """ form.instance...
If the form is valid, save to the associated model. Sets the hidden-field to a valid id before saving. :param form: form object :return: HttpResponRedirect defined by get_success_url
If the form is valid, save to the associated model. Sets the hidden-field to a valid id before saving.
[ "If", "the", "form", "is", "valid", "save", "to", "the", "associated", "model", ".", "Sets", "the", "hidden", "-", "field", "to", "a", "valid", "id", "before", "saving", "." ]
def form_valid(self, form: Form) -> HttpResponseRedirect: form.instance.study = Study.objects.get(pk=self.kwargs['pk']) form.save() return super(StudyDetailView, self).form_valid(form)
[ "def", "form_valid", "(", "self", ",", "form", ":", "Form", ")", "->", "HttpResponseRedirect", ":", "form", ".", "instance", ".", "study", "=", "Study", ".", "objects", ".", "get", "(", "pk", "=", "self", ".", "kwargs", "[", "'pk'", "]", ")", "form",...
If the form is valid, save to the associated model.
[ "If", "the", "form", "is", "valid", "save", "to", "the", "associated", "model", "." ]
[ "\"\"\"\n If the form is valid, save to the associated model. Sets the hidden-field\n to a valid id before saving.\n\n :param form: form object\n :return: HttpResponRedirect defined by get_success_url\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "form", "type": "Form" } ]
{ "returns": [ { "docstring": "HttpResponRedirect defined by get_success_url", "docstring_tokens": [ "HttpResponRedirect", "defined", "by", "get_success_url" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "ty...
66fb6d266213d7a59cbc2a84d611e2c319141f51
rhbvkleef/SteamBird
steambird/boecie/views.py
[ "BSD-3-Clause" ]
Python
form_valid
HttpResponseRedirect
def form_valid(self, request: HttpRequest, form: Form, form_name: str) -> HttpResponseRedirect: """ Method which checks if the form is valid. Has a bit more complexity than most form_valid due to the M2M fields like teachers and MSP's. We also need to check which form has been submitted....
Method which checks if the form is valid. Has a bit more complexity than most form_valid due to the M2M fields like teachers and MSP's. We also need to check which form has been submitted. Save's valid forms content and fills in any leftover hidden fields :param request: Django HtppReq...
Method which checks if the form is valid. Has a bit more complexity than most form_valid due to the M2M fields like teachers and MSP's. We also need to check which form has been submitted. Save's valid forms content and fills in any leftover hidden fields
[ "Method", "which", "checks", "if", "the", "form", "is", "valid", ".", "Has", "a", "bit", "more", "complexity", "than", "most", "form_valid", "due", "to", "the", "M2M", "fields", "like", "teachers", "and", "MSP", "'", "s", ".", "We", "also", "need", "to...
def form_valid(self, request: HttpRequest, form: Form, form_name: str) -> HttpResponseRedirect: if form_name == 'course_form': form.instance.id = self.kwargs['pk'] form.save() next_course = Course.objects.filter(studies__id=self.kwargs['study'], ...
[ "def", "form_valid", "(", "self", ",", "request", ":", "HttpRequest", ",", "form", ":", "Form", ",", "form_name", ":", "str", ")", "->", "HttpResponseRedirect", ":", "if", "form_name", "==", "'course_form'", ":", "form", ".", "instance", ".", "id", "=", ...
Method which checks if the form is valid.
[ "Method", "which", "checks", "if", "the", "form", "is", "valid", "." ]
[ "\"\"\"\n Method which checks if the form is valid. Has a bit more complexity than most form_valid\n due to the M2M fields like teachers and MSP's. We also need to check which form has been\n submitted. Save's valid forms content and fills in any leftover hidden fields\n\n :param request...
[ { "param": "self", "type": null }, { "param": "request", "type": "HttpRequest" }, { "param": "form", "type": "Form" }, { "param": "form_name", "type": "str" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
66fb6d266213d7a59cbc2a84d611e2c319141f51
rhbvkleef/SteamBird
steambird/boecie/views.py
[ "BSD-3-Clause" ]
Python
form_valid
HttpResponseRedirect
def form_valid(self, form: Form) -> HttpResponseRedirect: """ Handles logic of when form is valid. Handles the two submit buttons actions, also handles creating course-stuyd relation :param form: Django Form object :return: Django HttpResonseRedirect """ if '_ma...
Handles logic of when form is valid. Handles the two submit buttons actions, also handles creating course-stuyd relation :param form: Django Form object :return: Django HttpResonseRedirect
Handles logic of when form is valid. Handles the two submit buttons actions, also handles creating course-stuyd relation
[ "Handles", "logic", "of", "when", "form", "is", "valid", ".", "Handles", "the", "two", "submit", "buttons", "actions", "also", "handles", "creating", "course", "-", "stuyd", "relation" ]
def form_valid(self, form: Form) -> HttpResponseRedirect: if '_mark_updated' in self.request.POST: form.instance.updated_associations = True form.save(commit=True) study = Study.objects.get(pk=self.kwargs['pk']) course = Course.objects.get(course_code=form.cleaned_data['cours...
[ "def", "form_valid", "(", "self", ",", "form", ":", "Form", ")", "->", "HttpResponseRedirect", ":", "if", "'_mark_updated'", "in", "self", ".", "request", ".", "POST", ":", "form", ".", "instance", ".", "updated_associations", "=", "True", "form", ".", "sa...
Handles logic of when form is valid.
[ "Handles", "logic", "of", "when", "form", "is", "valid", "." ]
[ "\"\"\"\n Handles logic of when form is valid. Handles the two submit buttons actions, also handles\n creating course-stuyd relation\n\n :param form: Django Form object\n :return: Django HttpResonseRedirect\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "form", "type": "Form" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
66fb6d266213d7a59cbc2a84d611e2c319141f51
rhbvkleef/SteamBird
steambird/boecie/views.py
[ "BSD-3-Clause" ]
Python
form_valid
HttpResponseRedirect
def form_valid(self, form: Form) -> HttpResponseRedirect: """ Checks if the Form is valid. Redirects to the 'edit' page of the same teacher :param form: Django Form object :return: Django HttpResponseRedirect """ teacherinfo = form.save(commit=False) lastname = ...
Checks if the Form is valid. Redirects to the 'edit' page of the same teacher :param form: Django Form object :return: Django HttpResponseRedirect
Checks if the Form is valid. Redirects to the 'edit' page of the same teacher
[ "Checks", "if", "the", "Form", "is", "valid", ".", "Redirects", "to", "the", "'", "edit", "'", "page", "of", "the", "same", "teacher" ]
def form_valid(self, form: Form) -> HttpResponseRedirect: teacherinfo = form.save(commit=False) lastname = str() if teacherinfo.surname_prefix is not None: lastname += teacherinfo.surname_prefix lastname += teacherinfo.last_name user = User() user.first_name =...
[ "def", "form_valid", "(", "self", ",", "form", ":", "Form", ")", "->", "HttpResponseRedirect", ":", "teacherinfo", "=", "form", ".", "save", "(", "commit", "=", "False", ")", "lastname", "=", "str", "(", ")", "if", "teacherinfo", ".", "surname_prefix", "...
Checks if the Form is valid.
[ "Checks", "if", "the", "Form", "is", "valid", "." ]
[ "\"\"\"\n Checks if the Form is valid. Redirects to the 'edit' page of the same teacher\n\n :param form: Django Form object\n :return: Django HttpResponseRedirect\n \"\"\"", "# Create a Django User object, so we can then create a Authcode and Teacher object to", "# link it to.", "#...
[ { "param": "self", "type": null }, { "param": "form", "type": "Form" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
66fb6d266213d7a59cbc2a84d611e2c319141f51
rhbvkleef/SteamBird
steambird/boecie/views.py
[ "BSD-3-Clause" ]
Python
form_valid
HttpResponse
def form_valid(self, form: Form) -> HttpResponse: """ Validates if the form submitted contains valid options, returns a download for those options. :param form: Django Form object :return: Django HttpResponse object """ form = form.cleaned_data period =...
Validates if the form submitted contains valid options, returns a download for those options. :param form: Django Form object :return: Django HttpResponse object
Validates if the form submitted contains valid options, returns a download for those options.
[ "Validates", "if", "the", "form", "submitted", "contains", "valid", "options", "returns", "a", "download", "for", "those", "options", "." ]
def form_valid(self, form: Form) -> HttpResponse: form = form.cleaned_data period = Period[form.get('period')] result = io.StringIO() writer = csv.writer(result, delimiter=';', quotechar='"') writer.writerow('groep;vak;standaardvak;isbn;prognose;schoolBetaalt;verplicht;huurkoop;'...
[ "def", "form_valid", "(", "self", ",", "form", ":", "Form", ")", "->", "HttpResponse", ":", "form", "=", "form", ".", "cleaned_data", "period", "=", "Period", "[", "form", ".", "get", "(", "'period'", ")", "]", "result", "=", "io", ".", "StringIO", "...
Validates if the form submitted contains valid options, returns a download for those options.
[ "Validates", "if", "the", "form", "submitted", "contains", "valid", "options", "returns", "a", "download", "for", "those", "options", "." ]
[ "\"\"\"\n Validates if the form submitted contains valid options, returns a download for\n those options.\n\n :param form: Django Form object\n :return: Django HttpResponse object\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "form", "type": "Form" } ]
{ "returns": [ { "docstring": "Django HttpResponse object", "docstring_tokens": [ "Django", "HttpResponse", "object" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstr...
66fb6d266213d7a59cbc2a84d611e2c319141f51
rhbvkleef/SteamBird
steambird/boecie/views.py
[ "BSD-3-Clause" ]
Python
form_valid
HttpResponseRedirect
def form_valid(self, form: Form) -> HttpResponseRedirect: """ If the form is valid, this will be triggered. :param form: The submitted form :return: Django HttpResponseRedirect """ form.save() return redirect(reverse_lazy('boecie:config', kwargs={'pk': 1})) ...
If the form is valid, this will be triggered. :param form: The submitted form :return: Django HttpResponseRedirect
If the form is valid, this will be triggered.
[ "If", "the", "form", "is", "valid", "this", "will", "be", "triggered", "." ]
def form_valid(self, form: Form) -> HttpResponseRedirect: form.save() return redirect(reverse_lazy('boecie:config', kwargs={'pk': 1}))
[ "def", "form_valid", "(", "self", ",", "form", ":", "Form", ")", "->", "HttpResponseRedirect", ":", "form", ".", "save", "(", ")", "return", "redirect", "(", "reverse_lazy", "(", "'boecie:config'", ",", "kwargs", "=", "{", "'pk'", ":", "1", "}", ")", "...
If the form is valid, this will be triggered.
[ "If", "the", "form", "is", "valid", "this", "will", "be", "triggered", "." ]
[ "\"\"\"\n If the form is valid, this will be triggered.\n\n :param form: The submitted form\n :return: Django HttpResponseRedirect\n \"\"\"", "# TODO: make this universal for more associations instead of just us, then pk will", "# match something with them" ]
[ { "param": "self", "type": null }, { "param": "form", "type": "Form" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
66fb6d266213d7a59cbc2a84d611e2c319141f51
rhbvkleef/SteamBird
steambird/boecie/views.py
[ "BSD-3-Clause" ]
Python
form_valid
<not_specific>
def form_valid(self, form): """ Makes sure the data is saved after submission. :param form: The form and its data. :return: a redirect to get_success_url. """ new_mspline = form.save(commit=False) new_mspline.created_by = self.request.user new_mspline.cre...
Makes sure the data is saved after submission. :param form: The form and its data. :return: a redirect to get_success_url.
Makes sure the data is saved after submission.
[ "Makes", "sure", "the", "data", "is", "saved", "after", "submission", "." ]
def form_valid(self, form): new_mspline = form.save(commit=False) new_mspline.created_by = self.request.user new_mspline.created_by_side = "BOECIE" new_mspline.save() form.save_m2m() return super().form_valid(form)
[ "def", "form_valid", "(", "self", ",", "form", ")", ":", "new_mspline", "=", "form", ".", "save", "(", "commit", "=", "False", ")", "new_mspline", ".", "created_by", "=", "self", ".", "request", ".", "user", "new_mspline", ".", "created_by_side", "=", "\...
Makes sure the data is saved after submission.
[ "Makes", "sure", "the", "data", "is", "saved", "after", "submission", "." ]
[ "\"\"\"\n Makes sure the data is saved after submission.\n\n :param form: The form and its data.\n :return: a redirect to get_success_url.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "form", "type": null } ]
{ "returns": [ { "docstring": "a redirect to get_success_url.", "docstring_tokens": [ "a", "redirect", "to", "get_success_url", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "...
d69bd0d134ba4017e3e96609c18759ccb24e3b6d
rhbvkleef/SteamBird
steambird/models/coursetree.py
[ "BSD-3-Clause" ]
Python
is_quartile
bool
def is_quartile(self) -> bool: """ Simple method which returns true if a Period is a quartile :return: bool """ return self in [Period.Q1, Period.Q2, Period.Q3, Period.Q4, Period.Q5]
Simple method which returns true if a Period is a quartile :return: bool
Simple method which returns true if a Period is a quartile
[ "Simple", "method", "which", "returns", "true", "if", "a", "Period", "is", "a", "quartile" ]
def is_quartile(self) -> bool: return self in [Period.Q1, Period.Q2, Period.Q3, Period.Q4, Period.Q5]
[ "def", "is_quartile", "(", "self", ")", "->", "bool", ":", "return", "self", "in", "[", "Period", ".", "Q1", ",", "Period", ".", "Q2", ",", "Period", ".", "Q3", ",", "Period", ".", "Q4", ",", "Period", ".", "Q5", "]" ]
Simple method which returns true if a Period is a quartile
[ "Simple", "method", "which", "returns", "true", "if", "a", "Period", "is", "a", "quartile" ]
[ "\"\"\"\n Simple method which returns true if a Period is a quartile\n\n :return: bool\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
d69bd0d134ba4017e3e96609c18759ccb24e3b6d
rhbvkleef/SteamBird
steambird/models/coursetree.py
[ "BSD-3-Clause" ]
Python
parent
Optional['Period']
def parent(self) -> Optional['Period']: """ Method which returns the parents of a Period :return: Usually a Period, or None """ if self in [Period.Q1, Period.Q2]: return Period.S1 if self in [Period.Q3, Period.Q4]: return Period.S2 if sel...
Method which returns the parents of a Period :return: Usually a Period, or None
Method which returns the parents of a Period
[ "Method", "which", "returns", "the", "parents", "of", "a", "Period" ]
def parent(self) -> Optional['Period']: if self in [Period.Q1, Period.Q2]: return Period.S1 if self in [Period.Q3, Period.Q4]: return Period.S2 if self == Period.Q5: return Period.S3 if self in [Period.S1, Period.S2]: return Period.YEAR ...
[ "def", "parent", "(", "self", ")", "->", "Optional", "[", "'Period'", "]", ":", "if", "self", "in", "[", "Period", ".", "Q1", ",", "Period", ".", "Q2", "]", ":", "return", "Period", ".", "S1", "if", "self", "in", "[", "Period", ".", "Q3", ",", ...
Method which returns the parents of a Period
[ "Method", "which", "returns", "the", "parents", "of", "a", "Period" ]
[ "\"\"\"\n Method which returns the parents of a Period\n\n :return: Usually a Period, or None\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "Usually a Period, or None", "docstring_tokens": [ "Usually", "a", "Period", "or", "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": ...
d69bd0d134ba4017e3e96609c18759ccb24e3b6d
rhbvkleef/SteamBird
steambird/models/coursetree.py
[ "BSD-3-Clause" ]
Python
children
List['Period']
def children(self) -> List['Period']: """ Method which returns the children of a Period :return: List of Periods, List can be empty """ if self == Period.S1: return [Period.Q1, Period.Q2] if self == Period.S2: return [Period.Q3, Period.Q4] ...
Method which returns the children of a Period :return: List of Periods, List can be empty
Method which returns the children of a Period
[ "Method", "which", "returns", "the", "children", "of", "a", "Period" ]
def children(self) -> List['Period']: if self == Period.S1: return [Period.Q1, Period.Q2] if self == Period.S2: return [Period.Q3, Period.Q4] if self == Period.S3: return [Period.Q5] if self == Period.YEAR: return [Period.S1, Period.S2] ...
[ "def", "children", "(", "self", ")", "->", "List", "[", "'Period'", "]", ":", "if", "self", "==", "Period", ".", "S1", ":", "return", "[", "Period", ".", "Q1", ",", "Period", ".", "Q2", "]", "if", "self", "==", "Period", ".", "S2", ":", "return",...
Method which returns the children of a Period
[ "Method", "which", "returns", "the", "children", "of", "a", "Period" ]
[ "\"\"\"\n Method which returns the children of a Period\n\n :return: List of Periods, List can be empty\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "List of Periods, List can be empty", "docstring_tokens": [ "List", "of", "Periods", "List", "can", "be", "empty" ], "type": null } ], "raises": [], "params": [ { "identifier": "self",...
d69bd0d134ba4017e3e96609c18759ccb24e3b6d
rhbvkleef/SteamBird
steambird/models/coursetree.py
[ "BSD-3-Clause" ]
Python
all_children
List['Period']
def all_children(self) -> List['Period']: """ Method which returns all children of a Period. Recursively adds until there is no further child object to be found :return: List of Periods that are children of requested period """ result = [] for child in self.child...
Method which returns all children of a Period. Recursively adds until there is no further child object to be found :return: List of Periods that are children of requested period
Method which returns all children of a Period. Recursively adds until there is no further child object to be found
[ "Method", "which", "returns", "all", "children", "of", "a", "Period", ".", "Recursively", "adds", "until", "there", "is", "no", "further", "child", "object", "to", "be", "found" ]
def all_children(self) -> List['Period']: result = [] for child in self.children(): result += child.all_children() result.append(child) return sorted(result)
[ "def", "all_children", "(", "self", ")", "->", "List", "[", "'Period'", "]", ":", "result", "=", "[", "]", "for", "child", "in", "self", ".", "children", "(", ")", ":", "result", "+=", "child", ".", "all_children", "(", ")", "result", ".", "append", ...
Method which returns all children of a Period.
[ "Method", "which", "returns", "all", "children", "of", "a", "Period", "." ]
[ "\"\"\"\n Method which returns all children of a Period. Recursively adds until there is no further\n child object to be found\n\n :return: List of Periods that are children of requested period\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "List of Periods that are children of requested period", "docstring_tokens": [ "List", "of", "Periods", "that", "are", "children", "of", "requested", "period" ], "type": null } ], ...
d69bd0d134ba4017e3e96609c18759ccb24e3b6d
rhbvkleef/SteamBird
steambird/models/coursetree.py
[ "BSD-3-Clause" ]
Python
all_parents
List['Period']
def all_parents(self) -> List['Period']: """ Method which returns all parents of a Period. Recursively adds until there is no further child object to be found :return: List of Periods that are parents of requested period """ result = [] parent = self.parent() ...
Method which returns all parents of a Period. Recursively adds until there is no further child object to be found :return: List of Periods that are parents of requested period
Method which returns all parents of a Period. Recursively adds until there is no further child object to be found
[ "Method", "which", "returns", "all", "parents", "of", "a", "Period", ".", "Recursively", "adds", "until", "there", "is", "no", "further", "child", "object", "to", "be", "found" ]
def all_parents(self) -> List['Period']: result = [] parent = self.parent() if parent: result.append(parent) result += parent.all_parents() return result
[ "def", "all_parents", "(", "self", ")", "->", "List", "[", "'Period'", "]", ":", "result", "=", "[", "]", "parent", "=", "self", ".", "parent", "(", ")", "if", "parent", ":", "result", ".", "append", "(", "parent", ")", "result", "+=", "parent", "....
Method which returns all parents of a Period.
[ "Method", "which", "returns", "all", "parents", "of", "a", "Period", "." ]
[ "\"\"\"\n Method which returns all parents of a Period. Recursively adds until there is no further\n child object to be found\n\n :return: List of Periods that are parents of requested period\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "List of Periods that are parents of requested period", "docstring_tokens": [ "List", "of", "Periods", "that", "are", "parents", "of", "requested", "period" ], "type": null } ], "r...
d69bd0d134ba4017e3e96609c18759ccb24e3b6d
rhbvkleef/SteamBird
steambird/models/coursetree.py
[ "BSD-3-Clause" ]
Python
all_teachers
List[Teacher]
def all_teachers(self) -> List[Teacher]: """ Method which returns both the coordinator and teachers of a study in a list. Filled in with the information according to osiris :return: List of all teachers helping out with a course. """ return [ self.coordinator...
Method which returns both the coordinator and teachers of a study in a list. Filled in with the information according to osiris :return: List of all teachers helping out with a course.
Method which returns both the coordinator and teachers of a study in a list. Filled in with the information according to osiris
[ "Method", "which", "returns", "both", "the", "coordinator", "and", "teachers", "of", "a", "study", "in", "a", "list", ".", "Filled", "in", "with", "the", "information", "according", "to", "osiris" ]
def all_teachers(self) -> List[Teacher]: return [ self.coordinator, *self.teachers, *[ teacher for course in self.parent_courses for teacher in course.all_teachers ], *[ study.director ...
[ "def", "all_teachers", "(", "self", ")", "->", "List", "[", "Teacher", "]", ":", "return", "[", "self", ".", "coordinator", ",", "*", "self", ".", "teachers", ",", "*", "[", "teacher", "for", "course", "in", "self", ".", "parent_courses", "for", "teach...
Method which returns both the coordinator and teachers of a study in a list.
[ "Method", "which", "returns", "both", "the", "coordinator", "and", "teachers", "of", "a", "study", "in", "a", "list", "." ]
[ "\"\"\"\n Method which returns both the coordinator and teachers of a study in a list. Filled in with\n the information according to osiris\n\n :return: List of all teachers helping out with a course.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "List of all teachers helping out with a course.", "docstring_tokens": [ "List", "of", "all", "teachers", "helping", "out", "with", "a", "course", "." ], "type": null } ], ...
d69bd0d134ba4017e3e96609c18759ccb24e3b6d
rhbvkleef/SteamBird
steambird/models/coursetree.py
[ "BSD-3-Clause" ]
Python
coordinators
List[Teacher]
def coordinators(self) -> List[Teacher]: """ These coordinators are also to be autonotified in case of delayed MSP's. :return: A list of teachers that have the end-control over this course. """ return [ self.coordinator, *[ teacher ...
These coordinators are also to be autonotified in case of delayed MSP's. :return: A list of teachers that have the end-control over this course.
These coordinators are also to be autonotified in case of delayed MSP's.
[ "These", "coordinators", "are", "also", "to", "be", "autonotified", "in", "case", "of", "delayed", "MSP", "'", "s", "." ]
def coordinators(self) -> List[Teacher]: return [ self.coordinator, *[ teacher for course in self.parent_courses for teacher in course.coordinators ] ]
[ "def", "coordinators", "(", "self", ")", "->", "List", "[", "Teacher", "]", ":", "return", "[", "self", ".", "coordinator", ",", "*", "[", "teacher", "for", "course", "in", "self", ".", "parent_courses", "for", "teacher", "in", "course", ".", "coordinato...
These coordinators are also to be autonotified in case of delayed MSP's.
[ "These", "coordinators", "are", "also", "to", "be", "autonotified", "in", "case", "of", "delayed", "MSP", "'", "s", "." ]
[ "\"\"\"\n These coordinators are also to be autonotified in case of delayed MSP's.\n\n :return: A list of teachers that have the end-control over this course.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "A list of teachers that have the end-control over this course.", "docstring_tokens": [ "A", "list", "of", "teachers", "that", "have", "the", "end", "-", "control", "over", "th...
d69bd0d134ba4017e3e96609c18759ccb24e3b6d
rhbvkleef/SteamBird
steambird/models/coursetree.py
[ "BSD-3-Clause" ]
Python
directors
List[Teacher]
def directors(self) -> List[Teacher]: """ Method which returns the study directors (OLD/OLC) :return: List of directors, should generally not be empty """ return [ *[ director for course in self.parent_courses for direc...
Method which returns the study directors (OLD/OLC) :return: List of directors, should generally not be empty
Method which returns the study directors (OLD/OLC)
[ "Method", "which", "returns", "the", "study", "directors", "(", "OLD", "/", "OLC", ")" ]
def directors(self) -> List[Teacher]: return [ *[ director for course in self.parent_courses for director in course.directors ], *map(lambda study: study.director, self.studies.all()) ]
[ "def", "directors", "(", "self", ")", "->", "List", "[", "Teacher", "]", ":", "return", "[", "*", "[", "director", "for", "course", "in", "self", ".", "parent_courses", "for", "director", "in", "course", ".", "directors", "]", ",", "*", "map", "(", "...
Method which returns the study directors (OLD/OLC)
[ "Method", "which", "returns", "the", "study", "directors", "(", "OLD", "/", "OLC", ")" ]
[ "\"\"\"\n Method which returns the study directors (OLD/OLC)\n\n :return: List of directors, should generally not be empty\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "List of directors, should generally not be empty", "docstring_tokens": [ "List", "of", "directors", "should", "generally", "not", "be", "empty" ], "type": null } ], "raises": [], "param...
d69bd0d134ba4017e3e96609c18759ccb24e3b6d
rhbvkleef/SteamBird
steambird/models/coursetree.py
[ "BSD-3-Clause" ]
Python
associations
List[StudyAssociation]
def associations(self) -> List[StudyAssociation]: """ Method which returns all the associations related to a course. Basically retrieve who can edit the course from the backend :return: List of StudyAssociations """ return [ *[ association ...
Method which returns all the associations related to a course. Basically retrieve who can edit the course from the backend :return: List of StudyAssociations
Method which returns all the associations related to a course. Basically retrieve who can edit the course from the backend
[ "Method", "which", "returns", "all", "the", "associations", "related", "to", "a", "course", ".", "Basically", "retrieve", "who", "can", "edit", "the", "course", "from", "the", "backend" ]
def associations(self) -> List[StudyAssociation]: return [ *[ association for course in self.parent_courses for association in course.associations ], *map(lambda study: study.association, self.studies.all()) ]
[ "def", "associations", "(", "self", ")", "->", "List", "[", "StudyAssociation", "]", ":", "return", "[", "*", "[", "association", "for", "course", "in", "self", ".", "parent_courses", "for", "association", "in", "course", ".", "associations", "]", ",", "*"...
Method which returns all the associations related to a course.
[ "Method", "which", "returns", "all", "the", "associations", "related", "to", "a", "course", "." ]
[ "\"\"\"\n Method which returns all the associations related to a course. Basically retrieve who can\n edit the course from the backend\n\n :return: List of StudyAssociations\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "List of StudyAssociations", "docstring_tokens": [ "List", "of", "StudyAssociations" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstrin...
d69bd0d134ba4017e3e96609c18759ccb24e3b6d
rhbvkleef/SteamBird
steambird/models/coursetree.py
[ "BSD-3-Clause" ]
Python
teacher_can_edit
bool
def teacher_can_edit(self, teacher: Teacher) -> bool: """ Can a teacher suggest changes to a course, e.g. on MSP's? Returns true if teacher is either coordinator of course or study directors :param teacher: Teacher object of which we want to know if they can make suggestions :re...
Can a teacher suggest changes to a course, e.g. on MSP's? Returns true if teacher is either coordinator of course or study directors :param teacher: Teacher object of which we want to know if they can make suggestions :return: Boolean
Can a teacher suggest changes to a course, e.g. on MSP's. Returns true if teacher is either coordinator of course or study directors
[ "Can", "a", "teacher", "suggest", "changes", "to", "a", "course", "e", ".", "g", ".", "on", "MSP", "'", "s", ".", "Returns", "true", "if", "teacher", "is", "either", "coordinator", "of", "course", "or", "study", "directors" ]
def teacher_can_edit(self, teacher: Teacher) -> bool: return teacher in (self.coordinators + self.directors)
[ "def", "teacher_can_edit", "(", "self", ",", "teacher", ":", "Teacher", ")", "->", "bool", ":", "return", "teacher", "in", "(", "self", ".", "coordinators", "+", "self", ".", "directors", ")" ]
Can a teacher suggest changes to a course, e.g.
[ "Can", "a", "teacher", "suggest", "changes", "to", "a", "course", "e", ".", "g", "." ]
[ "\"\"\"\n Can a teacher suggest changes to a course, e.g. on MSP's? Returns true if teacher is either\n coordinator of course or study directors\n\n :param teacher: Teacher object of which we want to know if they can make suggestions\n :return: Boolean\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "teacher", "type": "Teacher" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
d69bd0d134ba4017e3e96609c18759ccb24e3b6d
rhbvkleef/SteamBird
steambird/models/coursetree.py
[ "BSD-3-Clause" ]
Python
association_can_edit
bool
def association_can_edit(self, association: StudyAssociation) -> bool: """ Returns if an association can edit a specific course. :param association: A studyassociation object :return: Boolean """ return association in self.associations
Returns if an association can edit a specific course. :param association: A studyassociation object :return: Boolean
Returns if an association can edit a specific course.
[ "Returns", "if", "an", "association", "can", "edit", "a", "specific", "course", "." ]
def association_can_edit(self, association: StudyAssociation) -> bool: return association in self.associations
[ "def", "association_can_edit", "(", "self", ",", "association", ":", "StudyAssociation", ")", "->", "bool", ":", "return", "association", "in", "self", ".", "associations" ]
Returns if an association can edit a specific course.
[ "Returns", "if", "an", "association", "can", "edit", "a", "specific", "course", "." ]
[ "\"\"\"\n Returns if an association can edit a specific course.\n\n :param association: A studyassociation object\n :return: Boolean\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "association", "type": "StudyAssociation" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
d69bd0d134ba4017e3e96609c18759ccb24e3b6d
rhbvkleef/SteamBird
steambird/models/coursetree.py
[ "BSD-3-Clause" ]
Python
teacher_can_manage_msp
bool
def teacher_can_manage_msp(self, teacher: Teacher) -> bool: """ Can a teacher in some way or form manage a course? Returns true for coordinators, directors and teachers. :param teacher: Teachers object for which you want to check if they can manage :return: boolean """ ...
Can a teacher in some way or form manage a course? Returns true for coordinators, directors and teachers. :param teacher: Teachers object for which you want to check if they can manage :return: boolean
Can a teacher in some way or form manage a course. Returns true for coordinators, directors and teachers.
[ "Can", "a", "teacher", "in", "some", "way", "or", "form", "manage", "a", "course", ".", "Returns", "true", "for", "coordinators", "directors", "and", "teachers", "." ]
def teacher_can_manage_msp(self, teacher: Teacher) -> bool: return teacher in (self.coordinators + self.directors + self.teachers)
[ "def", "teacher_can_manage_msp", "(", "self", ",", "teacher", ":", "Teacher", ")", "->", "bool", ":", "return", "teacher", "in", "(", "self", ".", "coordinators", "+", "self", ".", "directors", "+", "self", ".", "teachers", ")" ]
Can a teacher in some way or form manage a course?
[ "Can", "a", "teacher", "in", "some", "way", "or", "form", "manage", "a", "course?" ]
[ "\"\"\"\n Can a teacher in some way or form manage a course? Returns true for coordinators, directors\n and teachers.\n\n :param teacher: Teachers object for which you want to check if they can manage\n :return: boolean\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "teacher", "type": "Teacher" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
d69bd0d134ba4017e3e96609c18759ccb24e3b6d
rhbvkleef/SteamBird
steambird/models/coursetree.py
[ "BSD-3-Clause" ]
Python
falls_in
bool
def falls_in(self, period: Period) -> bool: """ Which periods does a period fall in? Returns true if self falls in given period :param period: Period you want to check against :return: Boolean """ return period.name in self.period_all
Which periods does a period fall in? Returns true if self falls in given period :param period: Period you want to check against :return: Boolean
Which periods does a period fall in. Returns true if self falls in given period
[ "Which", "periods", "does", "a", "period", "fall", "in", ".", "Returns", "true", "if", "self", "falls", "in", "given", "period" ]
def falls_in(self, period: Period) -> bool: return period.name in self.period_all
[ "def", "falls_in", "(", "self", ",", "period", ":", "Period", ")", "->", "bool", ":", "return", "period", ".", "name", "in", "self", ".", "period_all" ]
Which periods does a period fall in?
[ "Which", "periods", "does", "a", "period", "fall", "in?" ]
[ "\"\"\"\n Which periods does a period fall in? Returns true if self falls in given period\n\n :param period: Period you want to check against\n :return: Boolean\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "period", "type": "Period" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
fe5c98b24ef34d469cfb1a9bc0fe7fc0f0120f9f
rhbvkleef/SteamBird
steambird/templatetags/render_template_type.py
[ "BSD-3-Clause" ]
Python
render_template_type
<not_specific>
def render_template_type(_context, obj: StudyMaterialEdition, template_path: str): """ Fetches template based on the type of the material. Works based on the Polymorphic c_type :param _context: Context of the page it is loaded from :param obj: StudyMaterialEdition object. Is used to retrieve the :p...
Fetches template based on the type of the material. Works based on the Polymorphic c_type :param _context: Context of the page it is loaded from :param obj: StudyMaterialEdition object. Is used to retrieve the :param template_path: string to the relative path to find the template which should be rende...
Fetches template based on the type of the material. Works based on the Polymorphic c_type
[ "Fetches", "template", "based", "on", "the", "type", "of", "the", "material", ".", "Works", "based", "on", "the", "Polymorphic", "c_type" ]
def render_template_type(_context, obj: StudyMaterialEdition, template_path: str): material_object = obj.polymorphic_ctype.model return get_template( template_path.format(material_object) ).render({material_object: obj})
[ "def", "render_template_type", "(", "_context", ",", "obj", ":", "StudyMaterialEdition", ",", "template_path", ":", "str", ")", ":", "material_object", "=", "obj", ".", "polymorphic_ctype", ".", "model", "return", "get_template", "(", "template_path", ".", "format...
Fetches template based on the type of the material.
[ "Fetches", "template", "based", "on", "the", "type", "of", "the", "material", "." ]
[ "\"\"\"\n Fetches template based on the type of the material. Works based on the Polymorphic c_type\n\n :param _context: Context of the page it is loaded from\n :param obj: StudyMaterialEdition object. Is used to retrieve the\n :param template_path: string to the relative path to find the template which...
[ { "param": "_context", "type": null }, { "param": "obj", "type": "StudyMaterialEdition" }, { "param": "template_path", "type": "str" } ]
{ "returns": [ { "docstring": "template which is loaded", "docstring_tokens": [ "template", "which", "is", "loaded" ], "type": null } ], "raises": [], "params": [ { "identifier": "_context", "type": null, "docstring": "Context...
79c623e9bafc572eadd67747d16f22030aef09a1
rhbvkleef/SteamBird
steambird/mail/mailsender.py
[ "BSD-3-Clause" ]
Python
_create_mime_attachment
MIMEBase
def _create_mime_attachment(self, content, mimetype) -> MIMEBase: """ Ensures content is a valid MIMEBase. :param content: the content to be converted. :param mimetype: the mimetype of the unconverted content. :return: a MIMEBase """ if isinstance(content, MIMETe...
Ensures content is a valid MIMEBase. :param content: the content to be converted. :param mimetype: the mimetype of the unconverted content. :return: a MIMEBase
Ensures content is a valid MIMEBase.
[ "Ensures", "content", "is", "a", "valid", "MIMEBase", "." ]
def _create_mime_attachment(self, content, mimetype) -> MIMEBase: if isinstance(content, MIMEText): return content if isinstance(content, MIMEBase) and\ 'Content-Transfer-Encoding' in content and\ content['Content-Transfer-Encoding'] != 'base64': e...
[ "def", "_create_mime_attachment", "(", "self", ",", "content", ",", "mimetype", ")", "->", "MIMEBase", ":", "if", "isinstance", "(", "content", ",", "MIMEText", ")", ":", "return", "content", "if", "isinstance", "(", "content", ",", "MIMEBase", ")", "and", ...
Ensures content is a valid MIMEBase.
[ "Ensures", "content", "is", "a", "valid", "MIMEBase", "." ]
[ "\"\"\"\n Ensures content is a valid MIMEBase.\n\n :param content: the content to be converted.\n :param mimetype: the mimetype of the unconverted content.\n :return: a MIMEBase\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "content", "type": null }, { "param": "mimetype", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
79c623e9bafc572eadd67747d16f22030aef09a1
rhbvkleef/SteamBird
steambird/mail/mailsender.py
[ "BSD-3-Clause" ]
Python
create_multilingual_mail
EmailMessage
def create_multilingual_mail(template_name: str, subject: str, context: dict, **kwargs) -> EmailMessage: """ Creates an instance of EmailMessage. If multiple languages exist for the given template name, it will create an RFC8255_ compatible email, and if only one language ex...
Creates an instance of EmailMessage. If multiple languages exist for the given template name, it will create an RFC8255_ compatible email, and if only one language exists, it will simply send an email in that language, without bothering with any multilingual crap. As of implementing this method, v...
Creates an instance of EmailMessage. If multiple languages exist for the given template name, it will create an RFC8255_ compatible email, and if only one language exists, it will simply send an email in that language, without bothering with any multilingual crap. As of implementing this method, very few to no email c...
[ "Creates", "an", "instance", "of", "EmailMessage", ".", "If", "multiple", "languages", "exist", "for", "the", "given", "template", "name", "it", "will", "create", "an", "RFC8255_", "compatible", "email", "and", "if", "only", "one", "language", "exists", "it", ...
def create_multilingual_mail(template_name: str, subject: str, context: dict, **kwargs) -> EmailMessage: _ensure_setup() kwargs['headers'] = kwargs['headers'] if 'headers' in kwargs else {} kwargs['headers'] = {"X-Mailer": get_mailer_name(), **kwargs['headers']} langs = temp...
[ "def", "create_multilingual_mail", "(", "template_name", ":", "str", ",", "subject", ":", "str", ",", "context", ":", "dict", ",", "**", "kwargs", ")", "->", "EmailMessage", ":", "_ensure_setup", "(", ")", "kwargs", "[", "'headers'", "]", "=", "kwargs", "[...
Creates an instance of EmailMessage.
[ "Creates", "an", "instance", "of", "EmailMessage", "." ]
[ "\"\"\"\n Creates an instance of EmailMessage. If multiple languages exist for\n the given template name, it will create an RFC8255_ compatible email, and if\n only one language exists, it will simply send an email in that language,\n without bothering with any multilingual crap.\n\n As of implementi...
[ { "param": "template_name", "type": "str" }, { "param": "subject", "type": "str" }, { "param": "context", "type": "dict" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "template_name", "type": "str", "docstring": "The template that should be used for this email", "docstring_tokens": ...
79c623e9bafc572eadd67747d16f22030aef09a1
rhbvkleef/SteamBird
steambird/mail/mailsender.py
[ "BSD-3-Clause" ]
Python
create_email
EmailMessage
def create_email(template_name: str, subject: str, context: dict, **kwargs) -> EmailMessage: """ Attempts to create an email that only has a single language, which is pulled from the context using get_language. If it cannot send the email in the requested language, it will call cre...
Attempts to create an email that only has a single language, which is pulled from the context using get_language. If it cannot send the email in the requested language, it will call create_multilingual_email to send an email in all the languages that are available. :param template_name: The t...
Attempts to create an email that only has a single language, which is pulled from the context using get_language. If it cannot send the email in the requested language, it will call create_multilingual_email to send an email in all the languages that are available.
[ "Attempts", "to", "create", "an", "email", "that", "only", "has", "a", "single", "language", "which", "is", "pulled", "from", "the", "context", "using", "get_language", ".", "If", "it", "cannot", "send", "the", "email", "in", "the", "requested", "language", ...
def create_email(template_name: str, subject: str, context: dict, **kwargs) -> EmailMessage: _ensure_setup() lang = get_language() kwargs['headers'] = kwargs['headers'] if 'headers' in kwargs else {} kwargs['headers'] = { "X-Mailer": get_mailer_name(), "Content-Language"...
[ "def", "create_email", "(", "template_name", ":", "str", ",", "subject", ":", "str", ",", "context", ":", "dict", ",", "**", "kwargs", ")", "->", "EmailMessage", ":", "_ensure_setup", "(", ")", "lang", "=", "get_language", "(", ")", "kwargs", "[", "'head...
Attempts to create an email that only has a single language, which is pulled from the context using get_language.
[ "Attempts", "to", "create", "an", "email", "that", "only", "has", "a", "single", "language", "which", "is", "pulled", "from", "the", "context", "using", "get_language", "." ]
[ "\"\"\"\n Attempts to create an email that only has a single language, which is\n pulled from the context using get_language.\n\n If it cannot send the email in the requested language, it will call\n create_multilingual_email to send an email in all the languages that are\n available.\n\n :param t...
[ { "param": "template_name", "type": "str" }, { "param": "subject", "type": "str" }, { "param": "context", "type": "dict" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "template_name", "type": "str", "docstring": "The template that should be used for this email", "docstring_tokens": ...
79c623e9bafc572eadd67747d16f22030aef09a1
rhbvkleef/SteamBird
steambird/mail/mailsender.py
[ "BSD-3-Clause" ]
Python
send_mimemessages
None
def send_mimemessages(msgs: List[EmailMessage]) -> None: """ Sends a list of EmailMessage. :param msgs: list of messages to send :return: nothing """ conn = get_connection() conn.open() for msg in msgs: msg.send() conn.close()
Sends a list of EmailMessage. :param msgs: list of messages to send :return: nothing
Sends a list of EmailMessage.
[ "Sends", "a", "list", "of", "EmailMessage", "." ]
def send_mimemessages(msgs: List[EmailMessage]) -> None: conn = get_connection() conn.open() for msg in msgs: msg.send() conn.close()
[ "def", "send_mimemessages", "(", "msgs", ":", "List", "[", "EmailMessage", "]", ")", "->", "None", ":", "conn", "=", "get_connection", "(", ")", "conn", ".", "open", "(", ")", "for", "msg", "in", "msgs", ":", "msg", ".", "send", "(", ")", "conn", "...
Sends a list of EmailMessage.
[ "Sends", "a", "list", "of", "EmailMessage", "." ]
[ "\"\"\"\n Sends a list of EmailMessage.\n\n :param msgs: list of messages to send\n :return: nothing\n \"\"\"" ]
[ { "param": "msgs", "type": "List[EmailMessage]" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "msgs", "type": "List[EmailMessage]", "docstring": "list of messages to send", "docstring_tokens": [ "list",...
5729fae6673e3c3fd688cbc4f9b0c3d965e4b49c
rhbvkleef/SteamBird
steambird/templatetags/period_footer.py
[ "BSD-3-Clause" ]
Python
period_retrieval
str
def period_retrieval() -> str: """ Template tag for retrieving the period :return: string sentence for showing year and period """ result = Config.objects.first() return _("You are working in Year {}, {}").format(result.year, result.period)
Template tag for retrieving the period :return: string sentence for showing year and period
Template tag for retrieving the period
[ "Template", "tag", "for", "retrieving", "the", "period" ]
def period_retrieval() -> str: result = Config.objects.first() return _("You are working in Year {}, {}").format(result.year, result.period)
[ "def", "period_retrieval", "(", ")", "->", "str", ":", "result", "=", "Config", ".", "objects", ".", "first", "(", ")", "return", "_", "(", "\"You are working in Year {}, {}\"", ")", ".", "format", "(", "result", ".", "year", ",", "result", ".", "period", ...
Template tag for retrieving the period
[ "Template", "tag", "for", "retrieving", "the", "period" ]
[ "\"\"\"\n Template tag for retrieving the period\n\n :return: string sentence for showing year and period\n \"\"\"" ]
[]
{ "returns": [ { "docstring": "string sentence for showing year and period", "docstring_tokens": [ "string", "sentence", "for", "showing", "year", "and", "period" ], "type": null } ], "raises": [], "params": [], "outlier_p...
1b92c9dff8d4bacfa12007746808fff79be6e733
gao123qiang/FGVC
onnx/onnx_RAFT.py
[ "MIT" ]
Python
create_dir
null
def create_dir(dir): """Creates a directory if not exist. """ if not os.path.exists(dir): os.makedirs(dir)
Creates a directory if not exist.
Creates a directory if not exist.
[ "Creates", "a", "directory", "if", "not", "exist", "." ]
def create_dir(dir): if not os.path.exists(dir): os.makedirs(dir)
[ "def", "create_dir", "(", "dir", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "dir", ")", ":", "os", ".", "makedirs", "(", "dir", ")" ]
Creates a directory if not exist.
[ "Creates", "a", "directory", "if", "not", "exist", "." ]
[ "\"\"\"Creates a directory if not exist.\n \"\"\"" ]
[ { "param": "dir", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dir", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
37a1589cb463cc9f70701ec48b9ab34674417b39
gao123qiang/FGVC
tool/video_completion.py
[ "MIT" ]
Python
extrapolation
<not_specific>
def extrapolation(args, video_ori, corrFlowF_ori, corrFlowB_ori, corrFlowNLF_ori, corrFlowNLB_ori): """Prepares the data for video extrapolation. """ imgH, imgW, _, nFrame = video_ori.shape # Defines new FOV. imgH_extr = int(args.H_scale * imgH) imgW_extr = int(args.W_scale * imgW) H_start ...
Prepares the data for video extrapolation.
Prepares the data for video extrapolation.
[ "Prepares", "the", "data", "for", "video", "extrapolation", "." ]
def extrapolation(args, video_ori, corrFlowF_ori, corrFlowB_ori, corrFlowNLF_ori, corrFlowNLB_ori): imgH, imgW, _, nFrame = video_ori.shape imgH_extr = int(args.H_scale * imgH) imgW_extr = int(args.W_scale * imgW) H_start = int((imgH_extr - imgH) / 2) W_start = int((imgW_extr - imgW) / 2) flow_m...
[ "def", "extrapolation", "(", "args", ",", "video_ori", ",", "corrFlowF_ori", ",", "corrFlowB_ori", ",", "corrFlowNLF_ori", ",", "corrFlowNLB_ori", ")", ":", "imgH", ",", "imgW", ",", "_", ",", "nFrame", "=", "video_ori", ".", "shape", "imgH_extr", "=", "int"...
Prepares the data for video extrapolation.
[ "Prepares", "the", "data", "for", "video", "extrapolation", "." ]
[ "\"\"\"Prepares the data for video extrapolation.\n \"\"\"", "# Defines new FOV.", "# Generates the mask for missing region.", "# Extrapolates the FOV for video.", "# Extrapolates the FOV for flow." ]
[ { "param": "args", "type": null }, { "param": "video_ori", "type": null }, { "param": "corrFlowF_ori", "type": null }, { "param": "corrFlowB_ori", "type": null }, { "param": "corrFlowNLF_ori", "type": null }, { "param": "corrFlowNLB_ori", "type": n...
{ "returns": [], "raises": [], "params": [ { "identifier": "args", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "video_ori", "type": null, "docstring": null, "docstring_token...
37a1589cb463cc9f70701ec48b9ab34674417b39
gao123qiang/FGVC
tool/video_completion.py
[ "MIT" ]
Python
edge_completion
<not_specific>
def edge_completion(args, EdgeGenerator, corrFlow, flow_mask, mode): """Calculate flow edge and complete it. """ if mode not in ['forward', 'backward']: raise NotImplementedError imgH, imgW, _, nFrame = corrFlow.shape Edge = np.empty(((imgH, imgW, 0)), dtype=np.float32) for i in range...
Calculate flow edge and complete it.
Calculate flow edge and complete it.
[ "Calculate", "flow", "edge", "and", "complete", "it", "." ]
def edge_completion(args, EdgeGenerator, corrFlow, flow_mask, mode): if mode not in ['forward', 'backward']: raise NotImplementedError imgH, imgW, _, nFrame = corrFlow.shape Edge = np.empty(((imgH, imgW, 0)), dtype=np.float32) for i in range(nFrame): print("Completing {0} flow edge {1:2d...
[ "def", "edge_completion", "(", "args", ",", "EdgeGenerator", ",", "corrFlow", ",", "flow_mask", ",", "mode", ")", ":", "if", "mode", "not", "in", "[", "'forward'", ",", "'backward'", "]", ":", "raise", "NotImplementedError", "imgH", ",", "imgW", ",", "_", ...
Calculate flow edge and complete it.
[ "Calculate", "flow", "edge", "and", "complete", "it", "." ]
[ "\"\"\"Calculate flow edge and complete it.\n \"\"\"" ]
[ { "param": "args", "type": null }, { "param": "EdgeGenerator", "type": null }, { "param": "corrFlow", "type": null }, { "param": "flow_mask", "type": null }, { "param": "mode", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "args", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "EdgeGenerator", "type": null, "docstring": null, "docstring_t...
5b0c3f61281d3245876e53fcec78454254352123
chunga2/HW1
hw1.py
[ "MIT" ]
Python
caesar_cipher
null
def caesar_cipher(sentence, shifts): """ Given a sentence and the number of shifts, RETURN the resulting caesar cipher. >>> caesar_cipher('Test.', 15) 'it78.' >>> caesar_cipher('Encoded strings are difficult to read', 30) 'iH6I787 MNLCHAM 4L8 7C99C6OFN NI L847' >>> caesar_cipher('3Q JZf xLY...
Given a sentence and the number of shifts, RETURN the resulting caesar cipher. >>> caesar_cipher('Test.', 15) 'it78.' >>> caesar_cipher('Encoded strings are difficult to read', 30) 'iH6I787 MNLCHAM 4L8 7C99C6OFN NI L847' >>> caesar_cipher('3Q JZf xLY CPLO ESTd AWPLdP DPYO 2PWa!', 15) 'If Y...
Given a sentence and the number of shifts, RETURN the resulting caesar cipher.
[ "Given", "a", "sentence", "and", "the", "number", "of", "shifts", "RETURN", "the", "resulting", "caesar", "cipher", "." ]
def caesar_cipher(sentence, shifts): pass
[ "def", "caesar_cipher", "(", "sentence", ",", "shifts", ")", ":", "pass" ]
Given a sentence and the number of shifts, RETURN the resulting caesar cipher.
[ "Given", "a", "sentence", "and", "the", "number", "of", "shifts", "RETURN", "the", "resulting", "caesar", "cipher", "." ]
[ "\"\"\"\n Given a sentence and the number of shifts, RETURN the resulting caesar cipher.\n\n >>> caesar_cipher('Test.', 15)\n 'it78.'\n >>> caesar_cipher('Encoded strings are difficult to read', 30)\n 'iH6I787 MNLCHAM 4L8 7C99C6OFN NI L847'\n >>> caesar_cipher('3Q JZf xLY CPLO ESTd AWPLdP DPYO 2PW...
[ { "param": "sentence", "type": null }, { "param": "shifts", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sentence", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "shifts", "type": null, "docstring": null, "docstring_toke...
5b0c3f61281d3245876e53fcec78454254352123
chunga2/HW1
hw1.py
[ "MIT" ]
Python
mom_and_dad
null
def mom_and_dad(string): """ Given a string, RETURN True if the number of appearnces of 'mom' and 'dad' are the same. >>> mom_and_dad('momdad') True >>> mom_and_dad('momomdad') False >>> mom_and_dad('mom091213aiomomdadmomoomomomdadadfishsdadandwich') False >>> mom_and_dad('momomdada...
Given a string, RETURN True if the number of appearnces of 'mom' and 'dad' are the same. >>> mom_and_dad('momdad') True >>> mom_and_dad('momomdad') False >>> mom_and_dad('mom091213aiomomdadmomoomomomdadadfishsdadandwich') False >>> mom_and_dad('momomdadad') True
Given a string, RETURN True if the number of appearnces of 'mom' and 'dad' are the same.
[ "Given", "a", "string", "RETURN", "True", "if", "the", "number", "of", "appearnces", "of", "'", "mom", "'", "and", "'", "dad", "'", "are", "the", "same", "." ]
def mom_and_dad(string): pass
[ "def", "mom_and_dad", "(", "string", ")", ":", "pass" ]
Given a string, RETURN True if the number of appearnces of 'mom' and 'dad' are the same.
[ "Given", "a", "string", "RETURN", "True", "if", "the", "number", "of", "appearnces", "of", "'", "mom", "'", "and", "'", "dad", "'", "are", "the", "same", "." ]
[ "\"\"\"\n Given a string, RETURN True if the number of appearnces of 'mom' and 'dad' are the same.\n\n >>> mom_and_dad('momdad')\n True\n >>> mom_and_dad('momomdad')\n False\n >>> mom_and_dad('mom091213aiomomdadmomoomomomdadadfishsdadandwich')\n False\n >>> mom_and_dad('momomdadad')\n Tru...
[ { "param": "string", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "string", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
44cb067fd645586bc07624b311a24d2d5d50d93f
adosaa/Backend-django-app
project/apps/django_backend_template/controllers/core/controller_template.py
[ "MIT" ]
Python
create_object_with_params
<not_specific>
def create_object_with_params(self): """ Basic (Transactional) method for create a instance of the self.model. :@raises {APIException} ModelBadRequest - 400 malformed request :@returns {Model Instance} - instance of the model """ try: serializer = self.serial...
Basic (Transactional) method for create a instance of the self.model. :@raises {APIException} ModelBadRequest - 400 malformed request :@returns {Model Instance} - instance of the model
Basic (Transactional) method for create a instance of the self.model. :@raises {APIException} ModelBadRequest - 400 malformed request :@returns {Model Instance} - instance of the model
[ "Basic", "(", "Transactional", ")", "method", "for", "create", "a", "instance", "of", "the", "self", ".", "model", ".", ":", "@raises", "{", "APIException", "}", "ModelBadRequest", "-", "400", "malformed", "request", ":", "@returns", "{", "Model", "Instance"...
def create_object_with_params(self): try: serializer = self.serializer(data=self.params) if not serializer.is_valid(): exception_name = "%sBadRequest" % (self.model.__name__) raise getattr(import_module(self.exception_path), exception_name) ret...
[ "def", "create_object_with_params", "(", "self", ")", ":", "try", ":", "serializer", "=", "self", ".", "serializer", "(", "data", "=", "self", ".", "params", ")", "if", "not", "serializer", ".", "is_valid", "(", ")", ":", "exception_name", "=", "\"%sBadReq...
Basic (Transactional) method for create a instance of the self.model.
[ "Basic", "(", "Transactional", ")", "method", "for", "create", "a", "instance", "of", "the", "self", ".", "model", "." ]
[ "\"\"\"\n Basic (Transactional) method for create a instance of the self.model.\n\n :@raises {APIException} ModelBadRequest - 400 malformed request\n :@returns {Model Instance} - instance of the model\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
99abdb0fe43ff789cae8370df93345b1c0b8fcb2
SiTae9317/Depth-Estimation-PyTorch
ExampleServer.py
[ "MIT" ]
Python
_upsample_add
<not_specific>
def _upsample_add(self, x, y): '''Upsample and add two feature maps. Args: x: (Variable) top feature map to be upsampled. y: (Variable) lateral feature map. Returns: (Variable) added feature map. Note in PyTorch, when input size is odd, the upsampled feature...
Upsample and add two feature maps. Args: x: (Variable) top feature map to be upsampled. y: (Variable) lateral feature map. Returns: (Variable) added feature map. Note in PyTorch, when input size is odd, the upsampled feature map with `F.upsample(..., scale_f...
Upsample and add two feature maps.
[ "Upsample", "and", "add", "two", "feature", "maps", "." ]
def _upsample_add(self, x, y): _,_,H,W = y.size() return F.interpolate(x, size=(H,W), mode='bilinear', align_corners=False) + y
[ "def", "_upsample_add", "(", "self", ",", "x", ",", "y", ")", ":", "_", ",", "_", ",", "H", ",", "W", "=", "y", ".", "size", "(", ")", "return", "F", ".", "interpolate", "(", "x", ",", "size", "=", "(", "H", ",", "W", ")", ",", "mode", "=...
Upsample and add two feature maps.
[ "Upsample", "and", "add", "two", "feature", "maps", "." ]
[ "'''Upsample and add two feature maps.\n Args:\n x: (Variable) top feature map to be upsampled.\n y: (Variable) lateral feature map.\n Returns:\n (Variable) added feature map.\n Note in PyTorch, when input size is odd, the upsampled feature map\n with `F.upsamp...
[ { "param": "self", "type": null }, { "param": "x", "type": null }, { "param": "y", "type": null } ]
{ "returns": [ { "docstring": "(Variable) added feature map.", "docstring_tokens": [ "(", "Variable", ")", "added", "feature", "map", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "self", ...
93368109b33e31e95ca8f7b394854e50c14948ce
bogdanvuk/pygears-tools
pygears_tools/utils.py
[ "MIT" ]
Python
shell_source
null
def shell_source(script): """Sometime you want to emulate the action of "source" in bash, settings some environment variables. Here is a way to do it.""" pipe = subprocess.Popen(". %s; env" % script, stdout=subprocess.PIPE, shell=True, ...
Sometime you want to emulate the action of "source" in bash, settings some environment variables. Here is a way to do it.
Sometime you want to emulate the action of "source" in bash, settings some environment variables. Here is a way to do it.
[ "Sometime", "you", "want", "to", "emulate", "the", "action", "of", "\"", "source", "\"", "in", "bash", "settings", "some", "environment", "variables", ".", "Here", "is", "a", "way", "to", "do", "it", "." ]
def shell_source(script): pipe = subprocess.Popen(". %s; env" % script, stdout=subprocess.PIPE, shell=True, executable="/bin/bash" if os_name() == 'ubuntu' else None) output = pipe.communicate()[0].decode() env = {} for ...
[ "def", "shell_source", "(", "script", ")", ":", "pipe", "=", "subprocess", ".", "Popen", "(", "\". %s; env\"", "%", "script", ",", "stdout", "=", "subprocess", ".", "PIPE", ",", "shell", "=", "True", ",", "executable", "=", "\"/bin/bash\"", "if", "os_name"...
Sometime you want to emulate the action of "source" in bash, settings some environment variables.
[ "Sometime", "you", "want", "to", "emulate", "the", "action", "of", "\"", "source", "\"", "in", "bash", "settings", "some", "environment", "variables", "." ]
[ "\"\"\"Sometime you want to emulate the action of \"source\" in bash,\n settings some environment variables. Here is a way to do it.\"\"\"" ]
[ { "param": "script", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "script", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b7c108ece75ba8f15a00e6f205ce6ae47b3ad833
orbichord/orbichord
orbichord/generator.py
[ "MIT" ]
Python
_copy_fix_octaves
<not_specific>
def _copy_fix_octaves(pitches): """Make chord octive consistent with their location within the chord.""" octave = pitches[0].octave new_pitches = [] for pitch in pitches: new_pitch = copy.deepcopy(pitch) new_pitch.octave -= octave new_pitches.a...
Make chord octive consistent with their location within the chord.
Make chord octive consistent with their location within the chord.
[ "Make", "chord", "octive", "consistent", "with", "their", "location", "within", "the", "chord", "." ]
def _copy_fix_octaves(pitches): octave = pitches[0].octave new_pitches = [] for pitch in pitches: new_pitch = copy.deepcopy(pitch) new_pitch.octave -= octave new_pitches.append(new_pitch) pitches = new_pitches for index in range(1, len(pitches)...
[ "def", "_copy_fix_octaves", "(", "pitches", ")", ":", "octave", "=", "pitches", "[", "0", "]", ".", "octave", "new_pitches", "=", "[", "]", "for", "pitch", "in", "pitches", ":", "new_pitch", "=", "copy", ".", "deepcopy", "(", "pitch", ")", "new_pitch", ...
Make chord octive consistent with their location within the chord.
[ "Make", "chord", "octive", "consistent", "with", "their", "location", "within", "the", "chord", "." ]
[ "\"\"\"Make chord octive consistent with their\n location within the chord.\"\"\"" ]
[ { "param": "pitches", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pitches", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b7c108ece75ba8f15a00e6f205ce6ae47b3ad833
orbichord/orbichord
orbichord/generator.py
[ "MIT" ]
Python
run
Iterator[Chord]
def run(self) -> Iterator[Chord]: """Generate a sequence of chords. Yields ------ Iterator[Chord] An iterator to the chords in the space. """ # List of identified chords vetoed_chords = set() # Sample the chord space as combination wi...
Generate a sequence of chords. Yields ------ Iterator[Chord] An iterator to the chords in the space.
Generate a sequence of chords. Yields Iterator[Chord] An iterator to the chords in the space.
[ "Generate", "a", "sequence", "of", "chords", ".", "Yields", "Iterator", "[", "Chord", "]", "An", "iterator", "to", "the", "chords", "in", "the", "space", "." ]
def run(self) -> Iterator[Chord]: vetoed_chords = set() for ntuple in self._combinator( self._pitches, self._dimension ): chord = IdentifiedChord( identify = self._identify, notes = self._copy_fix_octaves(ntuple) ) i...
[ "def", "run", "(", "self", ")", "->", "Iterator", "[", "Chord", "]", ":", "vetoed_chords", "=", "set", "(", ")", "for", "ntuple", "in", "self", ".", "_combinator", "(", "self", ".", "_pitches", ",", "self", ".", "_dimension", ")", ":", "chord", "=", ...
Generate a sequence of chords.
[ "Generate", "a", "sequence", "of", "chords", "." ]
[ "\"\"\"Generate a sequence of chords.\n\n Yields\n ------\n Iterator[Chord]\n An iterator to the chords in the space.\n \"\"\"", "# List of identified chords", "# Sample the chord space as combination with", "# replacement of the scale pitches.", "# Generate th...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ae7bc495d54cedf10a6266be0676224771dfc1ca
orbichord/orbichord
orbichord/identify.py
[ "MIT" ]
Python
chordSymbolIndex
str
def chordSymbolIndex(chord : Chord) -> str: """Identify chords based on its chord symbol index. The chord symbol index is an index that is unique to each named chord. Parameters ---------- chord : Chord Chord to be identified. Return ------ str A string...
Identify chords based on its chord symbol index. The chord symbol index is an index that is unique to each named chord. Parameters ---------- chord : Chord Chord to be identified. Return ------ str A string with the pitch names.
Identify chords based on its chord symbol index. The chord symbol index is an index that is unique to each named chord. Parameters chord : Chord Chord to be identified. Return str A string with the pitch names.
[ "Identify", "chords", "based", "on", "its", "chord", "symbol", "index", ".", "The", "chord", "symbol", "index", "is", "an", "index", "that", "is", "unique", "to", "each", "named", "chord", ".", "Parameters", "chord", ":", "Chord", "Chord", "to", "be", "i...
def chordSymbolIndex(chord : Chord) -> str: pcs = [] veto = set() for pc in chord.pitchClasses: if pc in veto: continue pcs.append(pc) veto.add(pc) pcs = [pcs[0]] + sorted(pcs[1:]) return '<' + ''.join(map(base10toN, pcs)) + '>'
[ "def", "chordSymbolIndex", "(", "chord", ":", "Chord", ")", "->", "str", ":", "pcs", "=", "[", "]", "veto", "=", "set", "(", ")", "for", "pc", "in", "chord", ".", "pitchClasses", ":", "if", "pc", "in", "veto", ":", "continue", "pcs", ".", "append",...
Identify chords based on its chord symbol index.
[ "Identify", "chords", "based", "on", "its", "chord", "symbol", "index", "." ]
[ "\"\"\"Identify chords based on its chord symbol index.\n\n The chord symbol index is an index that is unique to each named chord.\n\n Parameters\n ----------\n chord : Chord\n Chord to be identified.\n\n Return\n ------\n str\n A string with the pitch names.\n ...
[ { "param": "chord", "type": "Chord" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "chord", "type": "Chord", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d16e144ad717e69e34e149119d282ed2e42e8f18
orbichord/orbichord
orbichord/chordinate.py
[ "MIT" ]
Python
scalePoint
list
def scalePoint( chord: Chord, scale: ConcreteScale ) -> list: """Compute chord coordinates using the degree for a given scale Parameters ---------- chrod : Chrod Chord to estimate normal order scale : ConcreteScale Scale use as metric step Return ---...
Compute chord coordinates using the degree for a given scale Parameters ---------- chrod : Chrod Chord to estimate normal order scale : ConcreteScale Scale use as metric step Return ------ list List with scalar normal order Examples ...
Compute chord coordinates using the degree for a given scale Parameters chrod : Chrod Chord to estimate normal order scale : ConcreteScale Scale use as metric step Return list List with scalar normal order Examples
[ "Compute", "chord", "coordinates", "using", "the", "degree", "for", "a", "given", "scale", "Parameters", "chrod", ":", "Chrod", "Chord", "to", "estimate", "normal", "order", "scale", ":", "ConcreteScale", "Scale", "use", "as", "metric", "step", "Return", "list...
def scalePoint( chord: Chord, scale: ConcreteScale ) -> list: point = [] for pitch in chord.pitches: point.append( scale.getScaleDegreeFromPitch( pitch, comparisonAttribute='pitchClass' ) - 1 ) return point
[ "def", "scalePoint", "(", "chord", ":", "Chord", ",", "scale", ":", "ConcreteScale", ")", "->", "list", ":", "point", "=", "[", "]", "for", "pitch", "in", "chord", ".", "pitches", ":", "point", ".", "append", "(", "scale", ".", "getScaleDegreeFromPitch",...
Compute chord coordinates using the degree for a given scale Parameters
[ "Compute", "chord", "coordinates", "using", "the", "degree", "for", "a", "given", "scale", "Parameters" ]
[ "\"\"\"Compute chord coordinates using the degree for a given scale\n\n Parameters\n ----------\n chrod : Chrod\n Chord to estimate normal order\n scale : ConcreteScale\n Scale use as metric step\n\n Return\n ------\n list\n List with scalar normal o...
[ { "param": "chord", "type": "Chord" }, { "param": "scale", "type": "ConcreteScale" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "chord", "type": "Chord", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "scale", "type": "ConcreteScale", "docstring": null, "docs...
d16e144ad717e69e34e149119d282ed2e42e8f18
orbichord/orbichord
orbichord/chordinate.py
[ "MIT" ]
Python
standardSimplex
list
def standardSimplex( chord: Chord, scale: ConcreteScale, normalize: bool = True ) -> list: """Compute chord scale point in the standard simplex Parameters ---------- chrod : Chrod Chord to estimate normal order scale : ConcreteScale Scale use as metric st...
Compute chord scale point in the standard simplex Parameters ---------- chrod : Chrod Chord to estimate normal order scale : ConcreteScale Scale use as metric step normalize : int, optional Normalize coordinates by the number of scale degrees Ret...
Compute chord scale point in the standard simplex Parameters chrod : Chrod Chord to estimate normal order scale : ConcreteScale Scale use as metric step normalize : int, optional Normalize coordinates by the number of scale degrees Return list List with scalar point within standard simplex Examples
[ "Compute", "chord", "scale", "point", "in", "the", "standard", "simplex", "Parameters", "chrod", ":", "Chrod", "Chord", "to", "estimate", "normal", "order", "scale", ":", "ConcreteScale", "Scale", "use", "as", "metric", "step", "normalize", ":", "int", "option...
def standardSimplex( chord: Chord, scale: ConcreteScale, normalize: bool = True ) -> list: max_scale_degree = scale.getDegreeMaxUnique() point = scalePoint(chord, scale) dimension = len(point) sumchord = sum(point) point.sort() while sumchord >= max_scale_degree: last = point...
[ "def", "standardSimplex", "(", "chord", ":", "Chord", ",", "scale", ":", "ConcreteScale", ",", "normalize", ":", "bool", "=", "True", ")", "->", "list", ":", "max_scale_degree", "=", "scale", ".", "getDegreeMaxUnique", "(", ")", "point", "=", "scalePoint", ...
Compute chord scale point in the standard simplex Parameters
[ "Compute", "chord", "scale", "point", "in", "the", "standard", "simplex", "Parameters" ]
[ "\"\"\"Compute chord scale point in the standard simplex\n\n Parameters\n ----------\n chrod : Chrod\n Chord to estimate normal order\n scale : ConcreteScale\n Scale use as metric step\n normalize : int, optional\n Normalize coordinates by the number of sc...
[ { "param": "chord", "type": "Chord" }, { "param": "scale", "type": "ConcreteScale" }, { "param": "normalize", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "chord", "type": "Chord", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "scale", "type": "ConcreteScale", "docstring": null, "docs...
d16e144ad717e69e34e149119d282ed2e42e8f18
orbichord/orbichord
orbichord/chordinate.py
[ "MIT" ]
Python
interscalarMatrix
list
def interscalarMatrix( chordA: Chord, chordB: Chord, scale: ConcreteScale, cardinality: bool = True, permutation: Permutation = Permutation.ANY ) -> list: """Compute the interscalar matrix between two chords Parameters ---------- chrodA : Chrod Voice leading start ch...
Compute the interscalar matrix between two chords Parameters ---------- chrodA : Chrod Voice leading start chord. chrodA : Chrod Voice leading end chord scale : ConcreteScale Scale use a metric. cardinality: bool, optional If true ...
Compute the interscalar matrix between two chords Parameters chrodA : Chrod Voice leading start chord. chrodA : Chrod Voice leading end chord scale : ConcreteScale Scale use a metric. cardinality: bool, optional If true chord cardinality is invariant. permutation : Permutation, optional Permutation invariance in the i...
[ "Compute", "the", "interscalar", "matrix", "between", "two", "chords", "Parameters", "chrodA", ":", "Chrod", "Voice", "leading", "start", "chord", ".", "chrodA", ":", "Chrod", "Voice", "leading", "end", "chord", "scale", ":", "ConcreteScale", "Scale", "use", "...
def interscalarMatrix( chordA: Chord, chordB: Chord, scale: ConcreteScale, cardinality: bool = True, permutation: Permutation = Permutation.ANY ) -> list: if chordA.multisetCardinality != chordB.multisetCardinality: raise ValueError('Chords are not of the same dimension!') if cardina...
[ "def", "interscalarMatrix", "(", "chordA", ":", "Chord", ",", "chordB", ":", "Chord", ",", "scale", ":", "ConcreteScale", ",", "cardinality", ":", "bool", "=", "True", ",", "permutation", ":", "Permutation", "=", "Permutation", ".", "ANY", ")", "->", "list...
Compute the interscalar matrix between two chords Parameters
[ "Compute", "the", "interscalar", "matrix", "between", "two", "chords", "Parameters" ]
[ "\"\"\"Compute the interscalar matrix between two chords\n\n Parameters\n ----------\n chrodA : Chrod\n Voice leading start chord.\n chrodA : Chrod\n Voice leading end chord\n scale : ConcreteScale\n Scale use a metric.\n cardinality: bool, optional...
[ { "param": "chordA", "type": "Chord" }, { "param": "chordB", "type": "Chord" }, { "param": "scale", "type": "ConcreteScale" }, { "param": "cardinality", "type": "bool" }, { "param": "permutation", "type": "Permutation" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "chordA", "type": "Chord", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "chordB", "type": "Chord", "docstring": null, "docstring_...
8f537a6ede0741e030811df7b00197e7343222d1
orbichord/orbichord
orbichord/symbol.py
[ "MIT" ]
Python
hasChordSymbolFigure
bool
def hasChordSymbolFigure(chord : Chord) -> bool: """Return true if the chord has figure. This only applies to chords commonly found on lead sheets. Parameters ---------- chord : Chord Chord to be identified. Return ------ bool: Return if symbol figure e...
Return true if the chord has figure. This only applies to chords commonly found on lead sheets. Parameters ---------- chord : Chord Chord to be identified. Return ------ bool: Return if symbol figure exist (named chord).
Return true if the chord has figure. This only applies to chords commonly found on lead sheets. Parameters chord : Chord Chord to be identified. Return Return if symbol figure exist (named chord).
[ "Return", "true", "if", "the", "chord", "has", "figure", ".", "This", "only", "applies", "to", "chords", "commonly", "found", "on", "lead", "sheets", ".", "Parameters", "chord", ":", "Chord", "Chord", "to", "be", "identified", ".", "Return", "Return", "if"...
def hasChordSymbolFigure(chord : Chord) -> bool: key = chordSymbolIndex(chord) return key in SYMBOL_INDEX_TO_FIGURE
[ "def", "hasChordSymbolFigure", "(", "chord", ":", "Chord", ")", "->", "bool", ":", "key", "=", "chordSymbolIndex", "(", "chord", ")", "return", "key", "in", "SYMBOL_INDEX_TO_FIGURE" ]
Return true if the chord has figure.
[ "Return", "true", "if", "the", "chord", "has", "figure", "." ]
[ "\"\"\"Return true if the chord has figure.\n\n This only applies to chords commonly found on lead sheets.\n\n Parameters\n ----------\n chord : Chord\n Chord to be identified.\n\n Return\n ------\n bool:\n Return if symbol figure exist (named chord).\n \"\"\"" ...
[ { "param": "chord", "type": "Chord" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "chord", "type": "Chord", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8f537a6ede0741e030811df7b00197e7343222d1
orbichord/orbichord
orbichord/symbol.py
[ "MIT" ]
Python
chordSymbolFigure
str
def chordSymbolFigure( chord : Chord, inversion : int = None, enharmonic : int = 0 ) -> str: """Identify chords based chord symbol figure. This only applies to chords commonly found on lead sheets. Parameters ---------- chord : Chord Chord to be identifi...
Identify chords based chord symbol figure. This only applies to chords commonly found on lead sheets. Parameters ---------- chord : Chord Chord to be identified. inversion : int, optional Inversion index. enharmonic : int, optional Enharmonic ind...
Identify chords based chord symbol figure. This only applies to chords commonly found on lead sheets. Parameters chord : Chord Chord to be identified. inversion : int, optional Inversion index. enharmonic : int, optional Enharmonic index Return str A string with with the chord symbol figure.
[ "Identify", "chords", "based", "chord", "symbol", "figure", ".", "This", "only", "applies", "to", "chords", "commonly", "found", "on", "lead", "sheets", ".", "Parameters", "chord", ":", "Chord", "Chord", "to", "be", "identified", ".", "inversion", ":", "int"...
def chordSymbolFigure( chord : Chord, inversion : int = None, enharmonic : int = 0 ) -> str: key = chordSymbolIndex(chord) if key not in SYMBOL_INDEX_TO_FIGURE: return chord.pitchClasses figure, inversions = SYMBOL_INDEX_TO_FIGURE[key] if inversion is None: re...
[ "def", "chordSymbolFigure", "(", "chord", ":", "Chord", ",", "inversion", ":", "int", "=", "None", ",", "enharmonic", ":", "int", "=", "0", ")", "->", "str", ":", "key", "=", "chordSymbolIndex", "(", "chord", ")", "if", "key", "not", "in", "SYMBOL_INDE...
Identify chords based chord symbol figure.
[ "Identify", "chords", "based", "chord", "symbol", "figure", "." ]
[ "\"\"\"Identify chords based chord symbol figure.\n\n This only applies to chords commonly found on lead sheets.\n\n Parameters\n ----------\n chord : Chord\n Chord to be identified.\n inversion : int, optional\n Inversion index.\n enharmonic : int, optional\n ...
[ { "param": "chord", "type": "Chord" }, { "param": "inversion", "type": "int" }, { "param": "enharmonic", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "chord", "type": "Chord", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "inversion", "type": "int", "docstring": null, "docstring_...
cf37f40ad42a31f7927d55a616af9a9d81b415d2
orbichord/orbichord
orbichord/utils.py
[ "MIT" ]
Python
showMusicXML
<not_specific>
def showMusicXML(xml): """Show music xml using javascript. References ---------- https://notebooks.azure.com/OUsefulInfo/projects/gettingstarted/html/4.1.0%20Music%20Notation.ipynb """ DIV_ID = "OSMD-div-"+str(random.randint(0,1000000)) msg='loading OpenSheetMusicDisplay' msg='' ...
Show music xml using javascript. References ---------- https://notebooks.azure.com/OUsefulInfo/projects/gettingstarted/html/4.1.0%20Music%20Notation.ipynb
Show music xml using javascript. References
[ "Show", "music", "xml", "using", "javascript", ".", "References" ]
def showMusicXML(xml): DIV_ID = "OSMD-div-"+str(random.randint(0,1000000)) msg='loading OpenSheetMusicDisplay' msg='' display(HTML('<div id="'+DIV_ID+'">{}</div>'.format(msg))) script = """ console.log("loadOSMD()"); function loadOSMD() { return new Promise(function(resolve, reject){...
[ "def", "showMusicXML", "(", "xml", ")", ":", "DIV_ID", "=", "\"OSMD-div-\"", "+", "str", "(", "random", ".", "randint", "(", "0", ",", "1000000", ")", ")", "msg", "=", "'loading OpenSheetMusicDisplay'", "msg", "=", "''", "display", "(", "HTML", "(", "'<d...
Show music xml using javascript.
[ "Show", "music", "xml", "using", "javascript", "." ]
[ "\"\"\"Show music xml using javascript.\n\n References\n ----------\n https://notebooks.azure.com/OUsefulInfo/projects/gettingstarted/html/4.1.0%20Music%20Notation.ipynb\n \"\"\"" ]
[ { "param": "xml", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "xml", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }