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
f28754953d1233f3b393c2025a7692c549b0bb19
mowangdk/huskar
huskar_api/models/instance/management.py
[ "MIT" ]
Python
resolve_cluster_name
<not_specific>
def resolve_cluster_name(self, cluster_name): """Resolves the cluster name and returns the name of physical cluster. See :class:`ClusterResolver` for details. :param cluster_name: The original cluster name, or the intent of route. :returns: The physical cluster name or ``None``. ...
Resolves the cluster name and returns the name of physical cluster. See :class:`ClusterResolver` for details. :param cluster_name: The original cluster name, or the intent of route. :returns: The physical cluster name or ``None``.
Resolves the cluster name and returns the name of physical cluster. See :class:`ClusterResolver` for details.
[ "Resolves", "the", "cluster", "name", "and", "returns", "the", "name", "of", "physical", "cluster", ".", "See", ":", "class", ":", "`", "ClusterResolver", "`", "for", "details", "." ]
def resolve_cluster_name(self, cluster_name): if self.type_name != SERVICE_SUBDOMAIN: return if (self.from_application_name and self.from_cluster_name and cluster_name in settings.ROUTE_INTENT_LIST): physical_name = self.cluster_resolver.resolve( c...
[ "def", "resolve_cluster_name", "(", "self", ",", "cluster_name", ")", ":", "if", "self", ".", "type_name", "!=", "SERVICE_SUBDOMAIN", ":", "return", "if", "(", "self", ".", "from_application_name", "and", "self", ".", "from_cluster_name", "and", "cluster_name", ...
Resolves the cluster name and returns the name of physical cluster.
[ "Resolves", "the", "cluster", "name", "and", "returns", "the", "name", "of", "physical", "cluster", "." ]
[ "\"\"\"Resolves the cluster name and returns the name of physical cluster.\n\n See :class:`ClusterResolver` for details.\n\n :param cluster_name: The original cluster name, or the intent of route.\n :returns: The physical cluster name or ``None``.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "cluster_name", "type": null } ]
{ "returns": [ { "docstring": "The physical cluster name or ``None``.", "docstring_tokens": [ "The", "physical", "cluster", "name", "or", "`", "`", "None", "`", "`", "." ], "type": null } ], "ra...
f28754953d1233f3b393c2025a7692c549b0bb19
mowangdk/huskar
huskar_api/models/instance/management.py
[ "MIT" ]
Python
delete_cluster
<not_specific>
def delete_cluster(self, cluster_name): """Deletes the cluster by its name. A cluster which could be deleted shall not include any instance or any using cluster info. :prama cluster_name: The name of cluster which will be deleted. :raises MalformedDataError: The data source is ...
Deletes the cluster by its name. A cluster which could be deleted shall not include any instance or any using cluster info. :prama cluster_name: The name of cluster which will be deleted. :raises MalformedDataError: The data source is malformed. :raises NotEmptyError: if the cl...
Deletes the cluster by its name. A cluster which could be deleted shall not include any instance or any using cluster info.
[ "Deletes", "the", "cluster", "by", "its", "name", ".", "A", "cluster", "which", "could", "be", "deleted", "shall", "not", "include", "any", "instance", "or", "any", "using", "cluster", "info", "." ]
def delete_cluster(self, cluster_name): service_info = self._make_service_info() service_info.load() cluster_info = self._make_cluster_info(cluster_name) cluster_info.load() if service_info.stat is None or cluster_info.stat is None: return outgoing_cluster_nam...
[ "def", "delete_cluster", "(", "self", ",", "cluster_name", ")", ":", "service_info", "=", "self", ".", "_make_service_info", "(", ")", "service_info", ".", "load", "(", ")", "cluster_info", "=", "self", ".", "_make_cluster_info", "(", "cluster_name", ")", "clu...
Deletes the cluster by its name.
[ "Deletes", "the", "cluster", "by", "its", "name", "." ]
[ "\"\"\"Deletes the cluster by its name.\n\n A cluster which could be deleted shall not include any instance or any\n using cluster info.\n\n :prama cluster_name: The name of cluster which will be deleted.\n :raises MalformedDataError: The data source is malformed.\n :raises NotEmp...
[ { "param": "self", "type": null }, { "param": "cluster_name", "type": null } ]
{ "returns": [ { "docstring": "``None`` if the cluster does not exist, an instance of\n:class:`ClusterInfo` if the cluster has been deleted.", "docstring_tokens": [ "`", "`", "None", "`", "`", "if", "the", "cluster", "does", ...
1c342deba119b31588f50bdd551a7d92b6156a77
mowangdk/huskar
huskar_api/api/webhook.py
[ "MIT" ]
Python
put
<not_specific>
def put(self, webhook_id): """To update subscription settings of an application Request body schema same to ``POST`` method. :param application_name: The name of application. :param webhook_id: The id of webhook. :param webhoo_type: default 0, set universal with 1 :stat...
To update subscription settings of an application Request body schema same to ``POST`` method. :param application_name: The name of application. :param webhook_id: The id of webhook. :param webhoo_type: default 0, set universal with 1 :status 200: thr request is successful. ...
To update subscription settings of an application Request body schema same to ``POST`` method.
[ "To", "update", "subscription", "settings", "of", "an", "application", "Request", "body", "schema", "same", "to", "`", "`", "POST", "`", "`", "method", "." ]
def put(self, webhook_id): webhook = self._get_webhook_or_404(webhook_id) self._check_authority(webhook) data = request.get_json() or {} validate_fields(webhook_schema, data, partial=False) if not webhook.is_normal: webhook.update_url(data['webhook_url']) ...
[ "def", "put", "(", "self", ",", "webhook_id", ")", ":", "webhook", "=", "self", ".", "_get_webhook_or_404", "(", "webhook_id", ")", "self", ".", "_check_authority", "(", "webhook", ")", "data", "=", "request", ".", "get_json", "(", ")", "or", "{", "}", ...
To update subscription settings of an application Request body schema same to ``POST`` method.
[ "To", "update", "subscription", "settings", "of", "an", "application", "Request", "body", "schema", "same", "to", "`", "`", "POST", "`", "`", "method", "." ]
[ "\"\"\"To update subscription settings of an application\n\n Request body schema same to ``POST`` method.\n\n :param application_name: The name of application.\n :param webhook_id: The id of webhook.\n :param webhoo_type: default 0, set universal with 1\n :status 200: thr request ...
[ { "param": "self", "type": null }, { "param": "webhook_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "webhook_id", "type": null, "docstring": "The id of webhook.", ...
eecac79ed76b459b07222f77f82abcd2316239b0
mowangdk/huskar
huskar_api/models/auth/application.py
[ "MIT" ]
Python
check_auth
<not_specific>
def check_auth(self, authority, user_id): """Checks the authority of user for this application. :param authority: ``AUTHORITY_READ``, ``AUTHORITY_WRITE`` or ``AUTHORITY_ADMIN``. :param user_id: The id of examined user. """ assert authority in Authority ...
Checks the authority of user for this application. :param authority: ``AUTHORITY_READ``, ``AUTHORITY_WRITE`` or ``AUTHORITY_ADMIN``. :param user_id: The id of examined user.
Checks the authority of user for this application.
[ "Checks", "the", "authority", "of", "user", "for", "this", "application", "." ]
def check_auth(self, authority, user_id): assert authority in Authority return self._check_authority_with_internal_auth(authority, user_id)
[ "def", "check_auth", "(", "self", ",", "authority", ",", "user_id", ")", ":", "assert", "authority", "in", "Authority", "return", "self", ".", "_check_authority_with_internal_auth", "(", "authority", ",", "user_id", ")" ]
Checks the authority of user for this application.
[ "Checks", "the", "authority", "of", "user", "for", "this", "application", "." ]
[ "\"\"\"Checks the authority of user for this application.\n\n :param authority: ``AUTHORITY_READ``, ``AUTHORITY_WRITE`` or\n ``AUTHORITY_ADMIN``.\n :param user_id: The id of examined user.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "authority", "type": null }, { "param": "user_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "authority", "type": null, "docstring": "``AUTHORITY_READ``, ``AUTHO...
eecac79ed76b459b07222f77f82abcd2316239b0
mowangdk/huskar
huskar_api/models/auth/application.py
[ "MIT" ]
Python
ensure_auth
null
def ensure_auth(self, authority, user_id): """Creates an application auth if it does not exist. :param authority: ``AUTHORITY_READ`` or ``AUTHORITY_WRITE`` :param user_id: The id of owner. """ ApplicationAuth.ensure(authority, user_id, self.id)
Creates an application auth if it does not exist. :param authority: ``AUTHORITY_READ`` or ``AUTHORITY_WRITE`` :param user_id: The id of owner.
Creates an application auth if it does not exist.
[ "Creates", "an", "application", "auth", "if", "it", "does", "not", "exist", "." ]
def ensure_auth(self, authority, user_id): ApplicationAuth.ensure(authority, user_id, self.id)
[ "def", "ensure_auth", "(", "self", ",", "authority", ",", "user_id", ")", ":", "ApplicationAuth", ".", "ensure", "(", "authority", ",", "user_id", ",", "self", ".", "id", ")" ]
Creates an application auth if it does not exist.
[ "Creates", "an", "application", "auth", "if", "it", "does", "not", "exist", "." ]
[ "\"\"\"Creates an application auth if it does not exist.\n\n :param authority: ``AUTHORITY_READ`` or ``AUTHORITY_WRITE``\n :param user_id: The id of owner.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "authority", "type": null }, { "param": "user_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "authority", "type": null, "docstring": "``AUTHORITY_READ`` or ``AUT...
eecac79ed76b459b07222f77f82abcd2316239b0
mowangdk/huskar
huskar_api/models/auth/application.py
[ "MIT" ]
Python
discard_auth
null
def discard_auth(self, authority, user_id): """Deletes an application auth if it does exist. :param authority: ``AUTHORITY_READ`` or ``AUTHORITY_WRITE`` :param user_id: The id of owner. """ ApplicationAuth.discard(authority, user_id, self.id)
Deletes an application auth if it does exist. :param authority: ``AUTHORITY_READ`` or ``AUTHORITY_WRITE`` :param user_id: The id of owner.
Deletes an application auth if it does exist.
[ "Deletes", "an", "application", "auth", "if", "it", "does", "exist", "." ]
def discard_auth(self, authority, user_id): ApplicationAuth.discard(authority, user_id, self.id)
[ "def", "discard_auth", "(", "self", ",", "authority", ",", "user_id", ")", ":", "ApplicationAuth", ".", "discard", "(", "authority", ",", "user_id", ",", "self", ".", "id", ")" ]
Deletes an application auth if it does exist.
[ "Deletes", "an", "application", "auth", "if", "it", "does", "exist", "." ]
[ "\"\"\"Deletes an application auth if it does exist.\n\n :param authority: ``AUTHORITY_READ`` or ``AUTHORITY_WRITE``\n :param user_id: The id of owner.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "authority", "type": null }, { "param": "user_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "authority", "type": null, "docstring": "``AUTHORITY_READ`` or ``AUT...
eecac79ed76b459b07222f77f82abcd2316239b0
mowangdk/huskar
huskar_api/models/auth/application.py
[ "MIT" ]
Python
find
<not_specific>
def find(cls, authority, user_id, application_id): """Find an application auth by a condition-tuple. :param authority: ``AUTHORITY_READ`` or ``AUTHORITY_WRITE`` :param user_id: The id of owner. :param application_id: The id of application. :returns: An :class:`ApplicationAuth` i...
Find an application auth by a condition-tuple. :param authority: ``AUTHORITY_READ`` or ``AUTHORITY_WRITE`` :param user_id: The id of owner. :param application_id: The id of application. :returns: An :class:`ApplicationAuth` instance or ``None``.
Find an application auth by a condition-tuple.
[ "Find", "an", "application", "auth", "by", "a", "condition", "-", "tuple", "." ]
def find(cls, authority, user_id, application_id): assert authority in Authority id_ = cls.find_id(authority, user_id, application_id) return None if id_ is None else cls.get(id_)
[ "def", "find", "(", "cls", ",", "authority", ",", "user_id", ",", "application_id", ")", ":", "assert", "authority", "in", "Authority", "id_", "=", "cls", ".", "find_id", "(", "authority", ",", "user_id", ",", "application_id", ")", "return", "None", "if",...
Find an application auth by a condition-tuple.
[ "Find", "an", "application", "auth", "by", "a", "condition", "-", "tuple", "." ]
[ "\"\"\"Find an application auth by a condition-tuple.\n\n :param authority: ``AUTHORITY_READ`` or ``AUTHORITY_WRITE``\n :param user_id: The id of owner.\n :param application_id: The id of application.\n :returns: An :class:`ApplicationAuth` instance or ``None``.\n \"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "authority", "type": null }, { "param": "user_id", "type": null }, { "param": "application_id", "type": null } ]
{ "returns": [ { "docstring": "An :class:`ApplicationAuth` instance or ``None``.", "docstring_tokens": [ "An", ":", "class", ":", "`", "ApplicationAuth", "`", "instance", "or", "`", "`", "None", "`"...
eecac79ed76b459b07222f77f82abcd2316239b0
mowangdk/huskar
huskar_api/models/auth/application.py
[ "MIT" ]
Python
search_by
<not_specific>
def search_by(cls, authority=None, user_id=None, application_id=None): """Searches application auth by conditions. This method is without cache. :param authority: ``Authority.READ`` or ``Authority.WRITE`` :param user_id: The id of owner. :param application_id: The id of applica...
Searches application auth by conditions. This method is without cache. :param authority: ``Authority.READ`` or ``Authority.WRITE`` :param user_id: The id of owner. :param application_id: The id of application. :returns: A list of :class:`ApplicationAuth`.
Searches application auth by conditions. This method is without cache.
[ "Searches", "application", "auth", "by", "conditions", ".", "This", "method", "is", "without", "cache", "." ]
def search_by(cls, authority=None, user_id=None, application_id=None): ids = cls.search_ids_by(authority, user_id, application_id) return cls.mget(ids)
[ "def", "search_by", "(", "cls", ",", "authority", "=", "None", ",", "user_id", "=", "None", ",", "application_id", "=", "None", ")", ":", "ids", "=", "cls", ".", "search_ids_by", "(", "authority", ",", "user_id", ",", "application_id", ")", "return", "cl...
Searches application auth by conditions.
[ "Searches", "application", "auth", "by", "conditions", "." ]
[ "\"\"\"Searches application auth by conditions.\n\n This method is without cache.\n\n :param authority: ``Authority.READ`` or ``Authority.WRITE``\n :param user_id: The id of owner.\n :param application_id: The id of application.\n :returns: A list of :class:`ApplicationAuth`.\n ...
[ { "param": "cls", "type": null }, { "param": "authority", "type": null }, { "param": "user_id", "type": null }, { "param": "application_id", "type": null } ]
{ "returns": [ { "docstring": "A list of :class:`ApplicationAuth`.", "docstring_tokens": [ "A", "list", "of", ":", "class", ":", "`", "ApplicationAuth", "`", "." ], "type": null } ], "raises": [], "pa...
eecac79ed76b459b07222f77f82abcd2316239b0
mowangdk/huskar
huskar_api/models/auth/application.py
[ "MIT" ]
Python
ensure
null
def ensure(cls, authority, user_id, application_id): """Creates an application auth if it does not exist. :param authority: ``AUTHORITY_READ`` or ``AUTHORITY_WRITE`` :param user_id: The id of owner. :param application_id: The id of application. """ assert authority in Au...
Creates an application auth if it does not exist. :param authority: ``AUTHORITY_READ`` or ``AUTHORITY_WRITE`` :param user_id: The id of owner. :param application_id: The id of application.
Creates an application auth if it does not exist.
[ "Creates", "an", "application", "auth", "if", "it", "does", "not", "exist", "." ]
def ensure(cls, authority, user_id, application_id): assert authority in Authority stmt = cls.upsert().values( authority=authority.value, user_id=user_id, application_id=application_id) with DBSession().close_on_exit(False) as db: db.execute(stmt) ...
[ "def", "ensure", "(", "cls", ",", "authority", ",", "user_id", ",", "application_id", ")", ":", "assert", "authority", "in", "Authority", "stmt", "=", "cls", ".", "upsert", "(", ")", ".", "values", "(", "authority", "=", "authority", ".", "value", ",", ...
Creates an application auth if it does not exist.
[ "Creates", "an", "application", "auth", "if", "it", "does", "not", "exist", "." ]
[ "\"\"\"Creates an application auth if it does not exist.\n\n :param authority: ``AUTHORITY_READ`` or ``AUTHORITY_WRITE``\n :param user_id: The id of owner.\n :param application_id: The id of application.\n \"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "authority", "type": null }, { "param": "user_id", "type": null }, { "param": "application_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "authority", "type": null, "docstring": "``AUTHORITY_READ`` or ``AUTH...
eecac79ed76b459b07222f77f82abcd2316239b0
mowangdk/huskar
huskar_api/models/auth/application.py
[ "MIT" ]
Python
discard
null
def discard(cls, authority, user_id, application_id): """Deletes an application auth if it does exist. :param authority: ``AUTHORITY_READ`` or ``AUTHORITY_WRITE`` :param user_id: The id of owner. :param application_id: The id of application. """ assert authority in Autho...
Deletes an application auth if it does exist. :param authority: ``AUTHORITY_READ`` or ``AUTHORITY_WRITE`` :param user_id: The id of owner. :param application_id: The id of application.
Deletes an application auth if it does exist.
[ "Deletes", "an", "application", "auth", "if", "it", "does", "exist", "." ]
def discard(cls, authority, user_id, application_id): assert authority in Authority stmt = cls.__table__.delete().where( (cls.authority == authority.value) & (cls.user_id == user_id) & (cls.application_id == application_id)) with DBSession().close_on_exit(False) as db: ...
[ "def", "discard", "(", "cls", ",", "authority", ",", "user_id", ",", "application_id", ")", ":", "assert", "authority", "in", "Authority", "stmt", "=", "cls", ".", "__table__", ".", "delete", "(", ")", ".", "where", "(", "(", "cls", ".", "authority", "...
Deletes an application auth if it does exist.
[ "Deletes", "an", "application", "auth", "if", "it", "does", "exist", "." ]
[ "\"\"\"Deletes an application auth if it does exist.\n\n :param authority: ``AUTHORITY_READ`` or ``AUTHORITY_WRITE``\n :param user_id: The id of owner.\n :param application_id: The id of application.\n \"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "authority", "type": null }, { "param": "user_id", "type": null }, { "param": "application_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "authority", "type": null, "docstring": "``AUTHORITY_READ`` or ``AUTH...
4a2503e61a636e8f8bcb04a5ab77cb9812bff9ca
mowangdk/huskar
huskar_api/models/auth/team.py
[ "MIT" ]
Python
list_admin
<not_specific>
def list_admin(self): """Get the list of admin users for this team. :returns: The list of :class:`User`. """ ids = TeamAdmin.get_user_ids(self.id) return User.mget(ids)
Get the list of admin users for this team. :returns: The list of :class:`User`.
Get the list of admin users for this team.
[ "Get", "the", "list", "of", "admin", "users", "for", "this", "team", "." ]
def list_admin(self): ids = TeamAdmin.get_user_ids(self.id) return User.mget(ids)
[ "def", "list_admin", "(", "self", ")", ":", "ids", "=", "TeamAdmin", ".", "get_user_ids", "(", "self", ".", "id", ")", "return", "User", ".", "mget", "(", "ids", ")" ]
Get the list of admin users for this team.
[ "Get", "the", "list", "of", "admin", "users", "for", "this", "team", "." ]
[ "\"\"\"Get the list of admin users for this team.\n\n :returns: The list of :class:`User`.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "The list of :class:`User`.", "docstring_tokens": [ "The", "list", "of", ":", "class", ":", "`", "User", "`", "." ], "type": null } ], "raises": [], "params": [ { ...
4a2503e61a636e8f8bcb04a5ab77cb9812bff9ca
mowangdk/huskar
huskar_api/models/auth/team.py
[ "MIT" ]
Python
grant_admin
null
def grant_admin(self, user_id): """Grants user as an admin for this team. :param user_id: The id of user. """ TeamAdmin.ensure(self.id, user_id)
Grants user as an admin for this team. :param user_id: The id of user.
Grants user as an admin for this team.
[ "Grants", "user", "as", "an", "admin", "for", "this", "team", "." ]
def grant_admin(self, user_id): TeamAdmin.ensure(self.id, user_id)
[ "def", "grant_admin", "(", "self", ",", "user_id", ")", ":", "TeamAdmin", ".", "ensure", "(", "self", ".", "id", ",", "user_id", ")" ]
Grants user as an admin for this team.
[ "Grants", "user", "as", "an", "admin", "for", "this", "team", "." ]
[ "\"\"\"Grants user as an admin for this team.\n\n :param user_id: The id of user.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "user_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "user_id", "type": null, "docstring": "The id of user.", "docs...
4a2503e61a636e8f8bcb04a5ab77cb9812bff9ca
mowangdk/huskar
huskar_api/models/auth/team.py
[ "MIT" ]
Python
dismiss_admin
null
def dismiss_admin(self, user_id): """Dismisses user's admin role for this team. :param user_id: The id of user. """ TeamAdmin.discard(self.id, user_id)
Dismisses user's admin role for this team. :param user_id: The id of user.
Dismisses user's admin role for this team.
[ "Dismisses", "user", "'", "s", "admin", "role", "for", "this", "team", "." ]
def dismiss_admin(self, user_id): TeamAdmin.discard(self.id, user_id)
[ "def", "dismiss_admin", "(", "self", ",", "user_id", ")", ":", "TeamAdmin", ".", "discard", "(", "self", ".", "id", ",", "user_id", ")" ]
Dismisses user's admin role for this team.
[ "Dismisses", "user", "'", "s", "admin", "role", "for", "this", "team", "." ]
[ "\"\"\"Dismisses user's admin role for this team.\n\n :param user_id: The id of user.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "user_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "user_id", "type": null, "docstring": "The id of user.", "docs...
6e4b68835ace37c487fc2cc1414315a6a32c1c01
mowangdk/huskar
huskar_api/models/cache/__init__.py
[ "MIT" ]
Python
pk_attribute
<not_specific>
def pk_attribute(cls): """Get object primary key attribute. :return: sqlalchemy ``Column`` object of the primary key """ if cls.__mapper__.primary_key: return getattr(cls, cls.__mapper__.primary_key[0].name)
Get object primary key attribute. :return: sqlalchemy ``Column`` object of the primary key
Get object primary key attribute.
[ "Get", "object", "primary", "key", "attribute", "." ]
def pk_attribute(cls): if cls.__mapper__.primary_key: return getattr(cls, cls.__mapper__.primary_key[0].name)
[ "def", "pk_attribute", "(", "cls", ")", ":", "if", "cls", ".", "__mapper__", ".", "primary_key", ":", "return", "getattr", "(", "cls", ",", "cls", ".", "__mapper__", ".", "primary_key", "[", "0", "]", ".", "name", ")" ]
Get object primary key attribute.
[ "Get", "object", "primary", "key", "attribute", "." ]
[ "\"\"\"Get object primary key attribute.\n\n :return: sqlalchemy ``Column`` object of the primary key\n \"\"\"" ]
[ { "param": "cls", "type": null } ]
{ "returns": [ { "docstring": "sqlalchemy ``Column`` object of the primary key", "docstring_tokens": [ "sqlalchemy", "`", "`", "Column", "`", "`", "object", "of", "the", "primary", "key" ], "type": null...
6e4b68835ace37c487fc2cc1414315a6a32c1c01
mowangdk/huskar
huskar_api/models/cache/__init__.py
[ "MIT" ]
Python
mget
<not_specific>
def mget(cls, _ids, force=False, as_dict=False): """Query a list of objects by pks. :func:`~mget` will always use db slave, values will be stored to cache if cache misses. Use ``force=True`` to force load from db. :param _ids: a list of pks :param force: whether force ...
Query a list of objects by pks. :func:`~mget` will always use db slave, values will be stored to cache if cache misses. Use ``force=True`` to force load from db. :param _ids: a list of pks :param force: whether force to load from db :param as_dict: return dict or list ...
Query a list of objects by pks.
[ "Query", "a", "list", "of", "objects", "by", "pks", "." ]
def mget(cls, _ids, force=False, as_dict=False): if not _ids: return {} if as_dict else [] objs = {} if not force: if cls._db_session.identity_map: for i in _ids: ident_key = identity_key(cls, i) if ident_key in cls....
[ "def", "mget", "(", "cls", ",", "_ids", ",", "force", "=", "False", ",", "as_dict", "=", "False", ")", ":", "if", "not", "_ids", ":", "return", "{", "}", "if", "as_dict", "else", "[", "]", "objs", "=", "{", "}", "if", "not", "force", ":", "if",...
Query a list of objects by pks.
[ "Query", "a", "list", "of", "objects", "by", "pks", "." ]
[ "\"\"\"Query a list of objects by pks.\n\n :func:`~mget` will always use db slave, values will be stored\n to cache if cache misses.\n\n Use ``force=True`` to force load from db.\n\n :param _ids: a list of pks\n :param force: whether force to load from db\n :param as_dict: ...
[ { "param": "cls", "type": null }, { "param": "_ids", "type": null }, { "param": "force", "type": null }, { "param": "as_dict", "type": null } ]
{ "returns": [ { "docstring": "dict or list of objects", "docstring_tokens": [ "dict", "or", "list", "of", "objects" ], "type": null } ], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null...
1e994b0ba77cef291816ca726002a9ea16709094
mowangdk/huskar
tests/utils.py
[ "MIT" ]
Python
assert_response_ok
null
def assert_response_ok(response): """Test whether the response is mean success :param response: Response instance from ``pytest_flask.fixtures.client`` :raise AssertionError: If test failed, will raise ``AssertionError`` """ assert response.status_code == 200, response.data assert response.json...
Test whether the response is mean success :param response: Response instance from ``pytest_flask.fixtures.client`` :raise AssertionError: If test failed, will raise ``AssertionError``
Test whether the response is mean success
[ "Test", "whether", "the", "response", "is", "mean", "success" ]
def assert_response_ok(response): assert response.status_code == 200, response.data assert response.json['status'] == 'SUCCESS' assert response.json['message'] == ''
[ "def", "assert_response_ok", "(", "response", ")", ":", "assert", "response", ".", "status_code", "==", "200", ",", "response", ".", "data", "assert", "response", ".", "json", "[", "'status'", "]", "==", "'SUCCESS'", "assert", "response", ".", "json", "[", ...
Test whether the response is mean success
[ "Test", "whether", "the", "response", "is", "mean", "success" ]
[ "\"\"\"Test whether the response is mean success\n\n :param response: Response instance from ``pytest_flask.fixtures.client``\n :raise AssertionError: If test failed, will raise ``AssertionError``\n \"\"\"" ]
[ { "param": "response", "type": null } ]
{ "returns": [], "raises": [ { "docstring": "If test failed, will raise ``AssertionError``", "docstring_tokens": [ "If", "test", "failed", "will", "raise", "`", "`", "AssertionError", "`", "`" ], "type": "Ass...
e36f7a5d2b41deae8e5418618acfc011116392a9
mowangdk/huskar
huskar_api/models/tree/holder.py
[ "MIT" ]
Python
start
null
def start(self): """Starts to synchronize the cache and subscribes events.""" self.throttle_semaphore.acquire() self.cache.listen(self.dispatch_signal) self.cache.listen_fault(self.record_errors) self.cache.start() self._started = True
Starts to synchronize the cache and subscribes events.
Starts to synchronize the cache and subscribes events.
[ "Starts", "to", "synchronize", "the", "cache", "and", "subscribes", "events", "." ]
def start(self): self.throttle_semaphore.acquire() self.cache.listen(self.dispatch_signal) self.cache.listen_fault(self.record_errors) self.cache.start() self._started = True
[ "def", "start", "(", "self", ")", ":", "self", ".", "throttle_semaphore", ".", "acquire", "(", ")", "self", ".", "cache", ".", "listen", "(", "self", ".", "dispatch_signal", ")", "self", ".", "cache", ".", "listen_fault", "(", "self", ".", "record_errors...
Starts to synchronize the cache and subscribes events.
[ "Starts", "to", "synchronize", "the", "cache", "and", "subscribes", "events", "." ]
[ "\"\"\"Starts to synchronize the cache and subscribes events.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e36f7a5d2b41deae8e5418618acfc011116392a9
mowangdk/huskar
huskar_api/models/tree/holder.py
[ "MIT" ]
Python
list_cluster_routes
<not_specific>
def list_cluster_routes(self, from_application_name=None, from_cluster_name=None): """Gets the route table between clusters. :param from_application_name: The name of caller application. :param from_cluster_name: The name of caller cluster. """ cluste...
Gets the route table between clusters. :param from_application_name: The name of caller application. :param from_cluster_name: The name of caller cluster.
Gets the route table between clusters.
[ "Gets", "the", "route", "table", "between", "clusters", "." ]
def list_cluster_routes(self, from_application_name=None, from_cluster_name=None): cluster_names = self.get_children( self.type_name, self.application_name) force_route_cluster_name = \ from_cluster_name if self.type_name == SERVICE_SUBDOMAIN else None...
[ "def", "list_cluster_routes", "(", "self", ",", "from_application_name", "=", "None", ",", "from_cluster_name", "=", "None", ")", ":", "cluster_names", "=", "self", ".", "get_children", "(", "self", ".", "type_name", ",", "self", ".", "application_name", ")", ...
Gets the route table between clusters.
[ "Gets", "the", "route", "table", "between", "clusters", "." ]
[ "\"\"\"Gets the route table between clusters.\n\n :param from_application_name: The name of caller application.\n :param from_cluster_name: The name of caller cluster.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "from_application_name", "type": null }, { "param": "from_cluster_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "from_application_name", "type": null, "docstring": "The name of cal...
cb14f7598c0d5c219ab08514498fdddef6553d43
mowangdk/huskar
huskar_api/api/instance.py
[ "MIT" ]
Python
post
<not_specific>
def post(self, application_name): """Creates an empty cluster. It is not necessary to create an empty cluster before placing content inside it. This API is intent on creating symbol clusters for linking. :form cluster: The name of creating cluster. :<header Authorization: Huska...
Creates an empty cluster. It is not necessary to create an empty cluster before placing content inside it. This API is intent on creating symbol clusters for linking. :form cluster: The name of creating cluster. :<header Authorization: Huskar Token (See :ref:`token`) :<header C...
Creates an empty cluster. It is not necessary to create an empty cluster before placing content inside it. This API is intent on creating symbol clusters for linking.
[ "Creates", "an", "empty", "cluster", ".", "It", "is", "not", "necessary", "to", "create", "an", "empty", "cluster", "before", "placing", "content", "inside", "it", ".", "This", "API", "is", "intent", "on", "creating", "symbol", "clusters", "for", "linking", ...
def post(self, application_name): check_application_auth(application_name, Authority.WRITE) cluster_name = request.values['cluster'].strip() validate_fields(instance_schema, { 'application': application_name, 'cluster': cluster_name }) check_cluster_name(c...
[ "def", "post", "(", "self", ",", "application_name", ")", ":", "check_application_auth", "(", "application_name", ",", "Authority", ".", "WRITE", ")", "cluster_name", "=", "request", ".", "values", "[", "'cluster'", "]", ".", "strip", "(", ")", "validate_field...
Creates an empty cluster.
[ "Creates", "an", "empty", "cluster", "." ]
[ "\"\"\"Creates an empty cluster.\n\n It is not necessary to create an empty cluster before placing content\n inside it. This API is intent on creating symbol clusters for linking.\n\n :form cluster: The name of creating cluster.\n :<header Authorization: Huskar Token (See :ref:`token`)\n...
[ { "param": "self", "type": null }, { "param": "application_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "application_name", "type": null, "docstring": null, "docstrin...
009ae421262c11390f2105a53342d21f8641b8e1
mowangdk/huskar
huskar_api/models/container/common.py
[ "MIT" ]
Python
is_container_id
<not_specific>
def is_container_id(key): """Checks an instance key is a container id or not. :param key: The instance key. :returns: ``True`` for possible container id. """ if re.match(container_regex, key): return True return False
Checks an instance key is a container id or not. :param key: The instance key. :returns: ``True`` for possible container id.
Checks an instance key is a container id or not.
[ "Checks", "an", "instance", "key", "is", "a", "container", "id", "or", "not", "." ]
def is_container_id(key): if re.match(container_regex, key): return True return False
[ "def", "is_container_id", "(", "key", ")", ":", "if", "re", ".", "match", "(", "container_regex", ",", "key", ")", ":", "return", "True", "return", "False" ]
Checks an instance key is a container id or not.
[ "Checks", "an", "instance", "key", "is", "a", "container", "id", "or", "not", "." ]
[ "\"\"\"Checks an instance key is a container id or not.\n\n :param key: The instance key.\n :returns: ``True`` for possible container id.\n \"\"\"" ]
[ { "param": "key", "type": null } ]
{ "returns": [ { "docstring": "``True`` for possible container id.", "docstring_tokens": [ "`", "`", "True", "`", "`", "for", "possible", "container", "id", "." ], "type": null } ], "raises": [], "par...
7bfea589954939f5850af121f70d1028cda0fb68
mowangdk/huskar
huskar_api/models/znode.py
[ "MIT" ]
Python
load
<not_specific>
def load(self): """Loads data from ZooKeeper and parses it. The :attr:`ZnodeModel.stat` will be ``None`` if the target node does not exist. :raises MalformedDataError: The data source is malformed. """ try: data, stat = self.client.get(self.path) exc...
Loads data from ZooKeeper and parses it. The :attr:`ZnodeModel.stat` will be ``None`` if the target node does not exist. :raises MalformedDataError: The data source is malformed.
Loads data from ZooKeeper and parses it.
[ "Loads", "data", "from", "ZooKeeper", "and", "parses", "it", "." ]
def load(self): try: data, stat = self.client.get(self.path) except NoNodeError: return self.stat = stat if data: try: self.data, _ = self.MARSHMALLOW_SCHEMA.loads(data) except self._MALFORMED_DATA_EXCEPTIONS as e: ...
[ "def", "load", "(", "self", ")", ":", "try", ":", "data", ",", "stat", "=", "self", ".", "client", ".", "get", "(", "self", ".", "path", ")", "except", "NoNodeError", ":", "return", "self", ".", "stat", "=", "stat", "if", "data", ":", "try", ":",...
Loads data from ZooKeeper and parses it.
[ "Loads", "data", "from", "ZooKeeper", "and", "parses", "it", "." ]
[ "\"\"\"Loads data from ZooKeeper and parses it.\n\n The :attr:`ZnodeModel.stat` will be ``None`` if the target node does\n not exist.\n\n :raises MalformedDataError: The data source is malformed.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [ { "docstring": "The data source is malformed.", "docstring_tokens": [ "The", "data", "source", "is", "malformed", "." ], "type": "MalformedDataError" } ], "params": [ { "identifier": "self", ...
7bfea589954939f5850af121f70d1028cda0fb68
mowangdk/huskar
huskar_api/models/znode.py
[ "MIT" ]
Python
save
null
def save(self, version=None): """Saves the data in this instance to ZooKeeper. It is concurrency-safe if you never break the :attr:`ZnodeModel.stat`. :param version: Optional. The alternative version instead of :attr:`ZnodeModel.stat`. :raises OutOfSyncError: Th...
Saves the data in this instance to ZooKeeper. It is concurrency-safe if you never break the :attr:`ZnodeModel.stat`. :param version: Optional. The alternative version instead of :attr:`ZnodeModel.stat`. :raises OutOfSyncError: The local data is outdated. :raises...
Saves the data in this instance to ZooKeeper. It is concurrency-safe if you never break the :attr:`ZnodeModel.stat`.
[ "Saves", "the", "data", "in", "this", "instance", "to", "ZooKeeper", ".", "It", "is", "concurrency", "-", "safe", "if", "you", "never", "break", "the", ":", "attr", ":", "`", "ZnodeModel", ".", "stat", "`", "." ]
def save(self, version=None): data, _ = self.MARSHMALLOW_SCHEMA.dumps(self.data) self.MARSHMALLOW_SCHEMA.loads(data) if self.stat is None: try: self.client.create(self.path, data, makepath=True) zk_payload(payload_data=data, payload_type='create') ...
[ "def", "save", "(", "self", ",", "version", "=", "None", ")", ":", "data", ",", "_", "=", "self", ".", "MARSHMALLOW_SCHEMA", ".", "dumps", "(", "self", ".", "data", ")", "self", ".", "MARSHMALLOW_SCHEMA", ".", "loads", "(", "data", ")", "if", "self",...
Saves the data in this instance to ZooKeeper.
[ "Saves", "the", "data", "in", "this", "instance", "to", "ZooKeeper", "." ]
[ "\"\"\"Saves the data in this instance to ZooKeeper.\n\n It is concurrency-safe if you never break the :attr:`ZnodeModel.stat`.\n\n :param version: Optional. The alternative version instead of\n :attr:`ZnodeModel.stat`.\n :raises OutOfSyncError: The local data is outdated...
[ { "param": "self", "type": null }, { "param": "version", "type": null } ]
{ "returns": [], "raises": [ { "docstring": "The local data is outdated.", "docstring_tokens": [ "The", "local", "data", "is", "outdated", "." ], "type": "OutOfSyncError" }, { "docstring": ":attr:`ZnodeModel.data` is invalid",...
7bfea589954939f5850af121f70d1028cda0fb68
mowangdk/huskar
huskar_api/models/znode.py
[ "MIT" ]
Python
delete
null
def delete(self, version=None): """Deletes this znode from ZooKeeper. It is concurrency-safe if you never break the :attr:`ZnodeModel.stat`. :param version: Optional. The alternative version instead of :attr:`ZnodeModel.stat`. :raises OutOfSyncError: The model i...
Deletes this znode from ZooKeeper. It is concurrency-safe if you never break the :attr:`ZnodeModel.stat`. :param version: Optional. The alternative version instead of :attr:`ZnodeModel.stat`. :raises OutOfSyncError: The model is not loaded yet, or the local data ...
Deletes this znode from ZooKeeper. It is concurrency-safe if you never break the :attr:`ZnodeModel.stat`.
[ "Deletes", "this", "znode", "from", "ZooKeeper", ".", "It", "is", "concurrency", "-", "safe", "if", "you", "never", "break", "the", ":", "attr", ":", "`", "ZnodeModel", ".", "stat", "`", "." ]
def delete(self, version=None): if self.stat is None: raise OutOfSyncError() if version is None: version = self.stat.version try: self.client.delete(self.path, version=version, recursive=False) except BadVersionError as e: raise OutOfSyncEr...
[ "def", "delete", "(", "self", ",", "version", "=", "None", ")", ":", "if", "self", ".", "stat", "is", "None", ":", "raise", "OutOfSyncError", "(", ")", "if", "version", "is", "None", ":", "version", "=", "self", ".", "stat", ".", "version", "try", ...
Deletes this znode from ZooKeeper.
[ "Deletes", "this", "znode", "from", "ZooKeeper", "." ]
[ "\"\"\"Deletes this znode from ZooKeeper.\n\n It is concurrency-safe if you never break the :attr:`ZnodeModel.stat`.\n\n :param version: Optional. The alternative version instead of\n :attr:`ZnodeModel.stat`.\n :raises OutOfSyncError: The model is not loaded yet, or the l...
[ { "param": "self", "type": null }, { "param": "version", "type": null } ]
{ "returns": [], "raises": [ { "docstring": "The model is not loaded yet, or the local data\nis outdated.", "docstring_tokens": [ "The", "model", "is", "not", "loaded", "yet", "or", "the", "local", "data", "is", ...
7bfea589954939f5850af121f70d1028cda0fb68
mowangdk/huskar
huskar_api/models/znode.py
[ "MIT" ]
Python
start
<not_specific>
def start(self): """Starts the synchronizing and fetches initial data.""" if self.started: return self.started = True client = self.client self.data_watch = client.DataWatch(self.parent_path, self._handle_data) self.children_watch = client.ChildrenWatch( ...
Starts the synchronizing and fetches initial data.
Starts the synchronizing and fetches initial data.
[ "Starts", "the", "synchronizing", "and", "fetches", "initial", "data", "." ]
def start(self): if self.started: return self.started = True client = self.client self.data_watch = client.DataWatch(self.parent_path, self._handle_data) self.children_watch = client.ChildrenWatch( self.parent_path, self._handle_children)
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "started", ":", "return", "self", ".", "started", "=", "True", "client", "=", "self", ".", "client", "self", ".", "data_watch", "=", "client", ".", "DataWatch", "(", "self", ".", "parent_path", ...
Starts the synchronizing and fetches initial data.
[ "Starts", "the", "synchronizing", "and", "fetches", "initial", "data", "." ]
[ "\"\"\"Starts the synchronizing and fetches initial data.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
633623f128450867fdacb265efaa56a921341cda
mowangdk/huskar
huskar_api/api/service_link.py
[ "MIT" ]
Python
post
<not_specific>
def post(self, application_name, cluster_name): """Links a cluster to another physical cluster. The ``write`` authority is required. See :ref:`application_auth` also. Once you configure a cluster A to link to B, the service instances of A will be hidden, the service instances of B will...
Links a cluster to another physical cluster. The ``write`` authority is required. See :ref:`application_auth` also. Once you configure a cluster A to link to B, the service instances of A will be hidden, the service instances of B will appear in cluster A. :param application_name: The...
Links a cluster to another physical cluster. The ``write`` authority is required. Once you configure a cluster A to link to B, the service instances of A will be hidden, the service instances of B will appear in cluster A.
[ "Links", "a", "cluster", "to", "another", "physical", "cluster", ".", "The", "`", "`", "write", "`", "`", "authority", "is", "required", ".", "Once", "you", "configure", "a", "cluster", "A", "to", "link", "to", "B", "the", "service", "instances", "of", ...
def post(self, application_name, cluster_name): check_application_auth(application_name, Authority.WRITE) check_cluster_name(cluster_name, application_name) link = request.form['link'].strip() if not link or link == cluster_name: abort(400, 'bad link parameter') with ...
[ "def", "post", "(", "self", ",", "application_name", ",", "cluster_name", ")", ":", "check_application_auth", "(", "application_name", ",", "Authority", ".", "WRITE", ")", "check_cluster_name", "(", "cluster_name", ",", "application_name", ")", "link", "=", "reque...
Links a cluster to another physical cluster.
[ "Links", "a", "cluster", "to", "another", "physical", "cluster", "." ]
[ "\"\"\"Links a cluster to another physical cluster.\n\n The ``write`` authority is required. See :ref:`application_auth` also.\n\n Once you configure a cluster A to link to B, the service instances of\n A will be hidden, the service instances of B will appear in cluster A.\n\n :param app...
[ { "param": "self", "type": null }, { "param": "application_name", "type": null }, { "param": "cluster_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "application_name", "type": null, "docstring": "The name of applicat...
633623f128450867fdacb265efaa56a921341cda
mowangdk/huskar
huskar_api/api/service_link.py
[ "MIT" ]
Python
delete
<not_specific>
def delete(self, application_name, cluster_name): """Unlinks a cluster from certain physical cluster. The ``write`` authority is required. See :ref:`application_auth` also. :param application_name: The name of application. :param cluster_name: The name of cluster. :form link: O...
Unlinks a cluster from certain physical cluster. The ``write`` authority is required. See :ref:`application_auth` also. :param application_name: The name of application. :param cluster_name: The name of cluster. :form link: Optional. If you pass this, the cluster will be unlinked ...
Unlinks a cluster from certain physical cluster. The ``write`` authority is required.
[ "Unlinks", "a", "cluster", "from", "certain", "physical", "cluster", ".", "The", "`", "`", "write", "`", "`", "authority", "is", "required", "." ]
def delete(self, application_name, cluster_name): check_application_auth(application_name, Authority.WRITE) check_cluster_name(cluster_name, application_name) now_link = ServiceLink.get_link(application_name, cluster_name) with audit_log(audit_log.types.DELETE_CLUSTER_LINK, ...
[ "def", "delete", "(", "self", ",", "application_name", ",", "cluster_name", ")", ":", "check_application_auth", "(", "application_name", ",", "Authority", ".", "WRITE", ")", "check_cluster_name", "(", "cluster_name", ",", "application_name", ")", "now_link", "=", ...
Unlinks a cluster from certain physical cluster.
[ "Unlinks", "a", "cluster", "from", "certain", "physical", "cluster", "." ]
[ "\"\"\"Unlinks a cluster from certain physical cluster.\n\n The ``write`` authority is required. See :ref:`application_auth` also.\n\n :param application_name: The name of application.\n :param cluster_name: The name of cluster.\n :form link: Optional. If you pass this, the cluster will ...
[ { "param": "self", "type": null }, { "param": "application_name", "type": null }, { "param": "cluster_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "application_name", "type": null, "docstring": "The name of applicat...
90b828fd218f1833118b32e65fd6c17d89a95b56
mowangdk/huskar
huskar_api/api/support.py
[ "MIT" ]
Python
delete
<not_specific>
def delete(self, container_id): """Reregisters all instances bound to this container. The site admin authority is required. See :ref:`site_admin` also. :param container_id: The container id (a.k.a CID, Task ID). :<header Authorization: Huskar Token (See :ref:`token`) :status 40...
Reregisters all instances bound to this container. The site admin authority is required. See :ref:`site_admin` also. :param container_id: The container id (a.k.a CID, Task ID). :<header Authorization: Huskar Token (See :ref:`token`) :status 409: The container is still using by another ...
Reregisters all instances bound to this container. The site admin authority is required.
[ "Reregisters", "all", "instances", "bound", "to", "this", "container", ".", "The", "site", "admin", "authority", "is", "required", "." ]
def delete(self, container_id): g.auth.require_admin() cm = ContainerManagement(huskar_client, container_id) cm.set_barrier() for application_name, cluster_name in cm.lookup(): old_data = service_facade.get_value( application_name, cluster_name, container_id) ...
[ "def", "delete", "(", "self", ",", "container_id", ")", ":", "g", ".", "auth", ".", "require_admin", "(", ")", "cm", "=", "ContainerManagement", "(", "huskar_client", ",", "container_id", ")", "cm", ".", "set_barrier", "(", ")", "for", "application_name", ...
Reregisters all instances bound to this container.
[ "Reregisters", "all", "instances", "bound", "to", "this", "container", "." ]
[ "\"\"\"Reregisters all instances bound to this container.\n\n The site admin authority is required. See :ref:`site_admin` also.\n\n :param container_id: The container id (a.k.a CID, Task ID).\n :<header Authorization: Huskar Token (See :ref:`token`)\n :status 409: The container is still ...
[ { "param": "self", "type": null }, { "param": "container_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "container_id", "type": null, "docstring": "The container id (a.k.a ...
90b828fd218f1833118b32e65fd6c17d89a95b56
mowangdk/huskar
huskar_api/api/support.py
[ "MIT" ]
Python
post
<not_specific>
def post(self): """Adds an IP address to blacklist. The site admin authority is required. See :ref:`application_auth` also. :<header Authorization: Huskar Token (See :ref:`token`) :form remote_addr: The adding IP address. :status 400: The IP address is invalid. :status ...
Adds an IP address to blacklist. The site admin authority is required. See :ref:`application_auth` also. :<header Authorization: Huskar Token (See :ref:`token`) :form remote_addr: The adding IP address. :status 400: The IP address is invalid. :status 409: The blacklist is modif...
Adds an IP address to blacklist. The site admin authority is required.
[ "Adds", "an", "IP", "address", "to", "blacklist", ".", "The", "site", "admin", "authority", "is", "required", "." ]
def post(self): g.auth.require_admin() remote_addr = request.form.get('remote_addr', type=ip_address) if not remote_addr: abort(400, 'remote_addr is invalid') with self._update_blacklist() as blacklist: blacklist.add(unicode(remote_addr)) return api_respon...
[ "def", "post", "(", "self", ")", ":", "g", ".", "auth", ".", "require_admin", "(", ")", "remote_addr", "=", "request", ".", "form", ".", "get", "(", "'remote_addr'", ",", "type", "=", "ip_address", ")", "if", "not", "remote_addr", ":", "abort", "(", ...
Adds an IP address to blacklist.
[ "Adds", "an", "IP", "address", "to", "blacklist", "." ]
[ "\"\"\"Adds an IP address to blacklist.\n\n The site admin authority is required. See :ref:`application_auth` also.\n\n :<header Authorization: Huskar Token (See :ref:`token`)\n :form remote_addr: The adding IP address.\n :status 400: The IP address is invalid.\n :status 409: The ...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [ { "identifier": "<header", "docstring": "Huskar ...
90b828fd218f1833118b32e65fd6c17d89a95b56
mowangdk/huskar
huskar_api/api/support.py
[ "MIT" ]
Python
delete
<not_specific>
def delete(self): """Deletes an IP address from blacklist. The site admin authority is required. See :ref:`application_auth` also. :<header Authorization: Huskar Token (See :ref:`token`) :form remote_addr: The deleting IP address. :status 400: The IP address is invalid. ...
Deletes an IP address from blacklist. The site admin authority is required. See :ref:`application_auth` also. :<header Authorization: Huskar Token (See :ref:`token`) :form remote_addr: The deleting IP address. :status 400: The IP address is invalid. :status 409: The blacklist i...
Deletes an IP address from blacklist. The site admin authority is required.
[ "Deletes", "an", "IP", "address", "from", "blacklist", ".", "The", "site", "admin", "authority", "is", "required", "." ]
def delete(self): g.auth.require_admin() remote_addr = request.form.get('remote_addr', type=ip_address) if not remote_addr: abort(400, 'remote_addr is invalid') with self._update_blacklist() as blacklist: blacklist.discard(unicode(remote_addr)) return api_...
[ "def", "delete", "(", "self", ")", ":", "g", ".", "auth", ".", "require_admin", "(", ")", "remote_addr", "=", "request", ".", "form", ".", "get", "(", "'remote_addr'", ",", "type", "=", "ip_address", ")", "if", "not", "remote_addr", ":", "abort", "(", ...
Deletes an IP address from blacklist.
[ "Deletes", "an", "IP", "address", "from", "blacklist", "." ]
[ "\"\"\"Deletes an IP address from blacklist.\n\n The site admin authority is required. See :ref:`application_auth` also.\n\n :<header Authorization: Huskar Token (See :ref:`token`)\n :form remote_addr: The deleting IP address.\n :status 400: The IP address is invalid.\n :status 40...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [ { "identifier": "<header", "docstring": "Huskar ...
90b828fd218f1833118b32e65fd6c17d89a95b56
mowangdk/huskar
huskar_api/api/support.py
[ "MIT" ]
Python
post
<not_specific>
def post(self): """Changes the stage of route program. The site admin authority is required. See :ref:`application_auth` also. :<header Authorization: Huskar Token (See :ref:`token`) :form application: The name of application :form stage: **D**isabled / **C**hecking / **E**nabl...
Changes the stage of route program. The site admin authority is required. See :ref:`application_auth` also. :<header Authorization: Huskar Token (See :ref:`token`) :form application: The name of application :form stage: **D**isabled / **C**hecking / **E**nabled / *...
Changes the stage of route program. The site admin authority is required.
[ "Changes", "the", "stage", "of", "route", "program", ".", "The", "site", "admin", "authority", "is", "required", "." ]
def post(self): name = request.form['application'] stage = request.form.get('stage', type=RouteHijack.Mode) cluster_name = request.form.get('cluster', OVERALL) cluster_list = {OVERALL}.union(self._make_im().list_cluster_names()) if stage is None: abort(400, 'stage is ...
[ "def", "post", "(", "self", ")", ":", "name", "=", "request", ".", "form", "[", "'application'", "]", "stage", "=", "request", ".", "form", ".", "get", "(", "'stage'", ",", "type", "=", "RouteHijack", ".", "Mode", ")", "cluster_name", "=", "request", ...
Changes the stage of route program.
[ "Changes", "the", "stage", "of", "route", "program", "." ]
[ "\"\"\"Changes the stage of route program.\n\n The site admin authority is required. See :ref:`application_auth` also.\n\n :<header Authorization: Huskar Token (See :ref:`token`)\n :form application: The name of application\n :form stage: **D**isabled / **C**hecking / **E**nabled /\n ...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [ { "identifier": "<header", "docstring": "Huskar ...
d0a9b25e8d2e1645545fa0433e6d01e02131baa0
NLGS2907/python-gamelib-plus
gamelib.py
[ "MIT" ]
Python
handle_event
None
def handle_event(self, tkevent: tk.Event) -> None: "Puts an event in the queue so it can be processed." if any(isinstance(tkevent.widget, class_check) for class_check in [Button]): tkevent.x = tkevent.x_root - self.canvas.winfo_rootx() tkevent.y = tkevent.y_root - self.canvas.wi...
Puts an event in the queue so it can be processed.
Puts an event in the queue so it can be processed.
[ "Puts", "an", "event", "in", "the", "queue", "so", "it", "can", "be", "processed", "." ]
def handle_event(self, tkevent: tk.Event) -> None: if any(isinstance(tkevent.widget, class_check) for class_check in [Button]): tkevent.x = tkevent.x_root - self.canvas.winfo_rootx() tkevent.y = tkevent.y_root - self.canvas.winfo_rooty() _GameThread.events.put(Event(tkevent))
[ "def", "handle_event", "(", "self", ",", "tkevent", ":", "tk", ".", "Event", ")", "->", "None", ":", "if", "any", "(", "isinstance", "(", "tkevent", ".", "widget", ",", "class_check", ")", "for", "class_check", "in", "[", "Button", "]", ")", ":", "tk...
Puts an event in the queue so it can be processed.
[ "Puts", "an", "event", "in", "the", "queue", "so", "it", "can", "be", "processed", "." ]
[ "\"Puts an event in the queue so it can be processed.\"" ]
[ { "param": "self", "type": null }, { "param": "tkevent", "type": "tk.Event" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "tkevent", "type": "tk.Event", "docstring": null, "docstring_t...
d0a9b25e8d2e1645545fa0433e6d01e02131baa0
NLGS2907/python-gamelib-plus
gamelib.py
[ "MIT" ]
Python
draw
None
def draw(self, type: str, args, kwargs) -> None: "Draws a figure in the canvas." options = {"fill": "white", "tag": "figure"} options.update(kwargs) getattr(self.canvas, f"create_{type}")(*args, **options)
Draws a figure in the canvas.
Draws a figure in the canvas.
[ "Draws", "a", "figure", "in", "the", "canvas", "." ]
def draw(self, type: str, args, kwargs) -> None: options = {"fill": "white", "tag": "figure"} options.update(kwargs) getattr(self.canvas, f"create_{type}")(*args, **options)
[ "def", "draw", "(", "self", ",", "type", ":", "str", ",", "args", ",", "kwargs", ")", "->", "None", ":", "options", "=", "{", "\"fill\"", ":", "\"white\"", ",", "\"tag\"", ":", "\"figure\"", "}", "options", ".", "update", "(", "kwargs", ")", "getattr...
Draws a figure in the canvas.
[ "Draws", "a", "figure", "in", "the", "canvas", "." ]
[ "\"Draws a figure in the canvas.\"" ]
[ { "param": "self", "type": null }, { "param": "type", "type": "str" }, { "param": "args", "type": null }, { "param": "kwargs", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "type", "type": "str", "docstring": null, "docstring_tokens": ...
d0a9b25e8d2e1645545fa0433e6d01e02131baa0
NLGS2907/python-gamelib-plus
gamelib.py
[ "MIT" ]
Python
draw_button
None
def draw_button(self, x: int, y: int, options) -> None: "Draws a button in the canvas." if "image" in options: options["image"] = self.get_image(options["image"]) button = Button(master=self, **options) if (x, y) not in self.buttons and button["text"] not in (btn["text"] fo...
Draws a button in the canvas.
Draws a button in the canvas.
[ "Draws", "a", "button", "in", "the", "canvas", "." ]
def draw_button(self, x: int, y: int, options) -> None: if "image" in options: options["image"] = self.get_image(options["image"]) button = Button(master=self, **options) if (x, y) not in self.buttons and button["text"] not in (btn["text"] for btn in self.buttons.values()): ...
[ "def", "draw_button", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ",", "options", ")", "->", "None", ":", "if", "\"image\"", "in", "options", ":", "options", "[", "\"image\"", "]", "=", "self", ".", "get_image", "(", "options", "[", "\...
Draws a button in the canvas.
[ "Draws", "a", "button", "in", "the", "canvas", "." ]
[ "\"Draws a button in the canvas.\"" ]
[ { "param": "self", "type": null }, { "param": "x", "type": "int" }, { "param": "y", "type": "int" }, { "param": "options", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": "int", "docstring": null, "docstring_tokens": [],...
d0a9b25e8d2e1645545fa0433e6d01e02131baa0
NLGS2907/python-gamelib-plus
gamelib.py
[ "MIT" ]
Python
draw_text
None
def draw_text(self, text: str, x: int, y: int, font: str, size: int, bold: True, italic: True, kwargs) -> None: "Draws text lines in the canvas." options = {"fill": "white"} options.update(kwargs) self.canvas.create_text(x, y, text=text, font=self.get_font(font, size, bold, italic), tag...
Draws text lines in the canvas.
Draws text lines in the canvas.
[ "Draws", "text", "lines", "in", "the", "canvas", "." ]
def draw_text(self, text: str, x: int, y: int, font: str, size: int, bold: True, italic: True, kwargs) -> None: options = {"fill": "white"} options.update(kwargs) self.canvas.create_text(x, y, text=text, font=self.get_font(font, size, bold, italic), tag="text", **options)
[ "def", "draw_text", "(", "self", ",", "text", ":", "str", ",", "x", ":", "int", ",", "y", ":", "int", ",", "font", ":", "str", ",", "size", ":", "int", ",", "bold", ":", "True", ",", "italic", ":", "True", ",", "kwargs", ")", "->", "None", ":...
Draws text lines in the canvas.
[ "Draws", "text", "lines", "in", "the", "canvas", "." ]
[ "\"Draws text lines in the canvas.\"" ]
[ { "param": "self", "type": null }, { "param": "text", "type": "str" }, { "param": "x", "type": "int" }, { "param": "y", "type": "int" }, { "param": "font", "type": "str" }, { "param": "size", "type": "int" }, { "param": "bold", "type": ...
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "text", "type": "str", "docstring": null, "docstring_tokens": ...
d0a9b25e8d2e1645545fa0433e6d01e02131baa0
NLGS2907/python-gamelib-plus
gamelib.py
[ "MIT" ]
Python
say
None
def say(self, message: str, msg_type: str, done: Queue) -> None: "Prompts a message box of a given type in the canvas." if isinstance(msg_type, MessageType): message_type = msg_type.value elif isinstance(msg_type, str) and msg_type.upper() in (msgtype.name for msgtype in MessageType...
Prompts a message box of a given type in the canvas.
Prompts a message box of a given type in the canvas.
[ "Prompts", "a", "message", "box", "of", "a", "given", "type", "in", "the", "canvas", "." ]
def say(self, message: str, msg_type: str, done: Queue) -> None: if isinstance(msg_type, MessageType): message_type = msg_type.value elif isinstance(msg_type, str) and msg_type.upper() in (msgtype.name for msgtype in MessageType): message_type = getattr(MessageType, msg_type.uppe...
[ "def", "say", "(", "self", ",", "message", ":", "str", ",", "msg_type", ":", "str", ",", "done", ":", "Queue", ")", "->", "None", ":", "if", "isinstance", "(", "msg_type", ",", "MessageType", ")", ":", "message_type", "=", "msg_type", ".", "value", "...
Prompts a message box of a given type in the canvas.
[ "Prompts", "a", "message", "box", "of", "a", "given", "type", "in", "the", "canvas", "." ]
[ "\"Prompts a message box of a given type in the canvas.\"" ]
[ { "param": "self", "type": null }, { "param": "message", "type": "str" }, { "param": "msg_type", "type": "str" }, { "param": "done", "type": "Queue" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "message", "type": "str", "docstring": null, "docstring_tokens...
d0a9b25e8d2e1645545fa0433e6d01e02131baa0
NLGS2907/python-gamelib-plus
gamelib.py
[ "MIT" ]
Python
check_image_format
None
def check_image_format(path: str) -> None: "Produce a warning message if the image format is not supported" ext = splitext(path)[1].lower() supported = (".gif", ".ppm", ".pgm", ".pbm") if ext not in supported: log.warning(f"{path}: image format {ext} is not supported and may not work properly o...
Produce a warning message if the image format is not supported
Produce a warning message if the image format is not supported
[ "Produce", "a", "warning", "message", "if", "the", "image", "format", "is", "not", "supported" ]
def check_image_format(path: str) -> None: ext = splitext(path)[1].lower() supported = (".gif", ".ppm", ".pgm", ".pbm") if ext not in supported: log.warning(f"{path}: image format {ext} is not supported and may not work properly on some platforms (Windows/Mac/Linux).\n" + f"Pleas...
[ "def", "check_image_format", "(", "path", ":", "str", ")", "->", "None", ":", "ext", "=", "splitext", "(", "path", ")", "[", "1", "]", ".", "lower", "(", ")", "supported", "=", "(", "\".gif\"", ",", "\".ppm\"", ",", "\".pgm\"", ",", "\".pbm\"", ")", ...
Produce a warning message if the image format is not supported
[ "Produce", "a", "warning", "message", "if", "the", "image", "format", "is", "not", "supported" ]
[ "\"Produce a warning message if the image format is not supported\"" ]
[ { "param": "path", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "path", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d0a9b25e8d2e1645545fa0433e6d01e02131baa0
NLGS2907/python-gamelib-plus
gamelib.py
[ "MIT" ]
Python
check_audio_format
None
def check_audio_format(path: str) -> None: "Produce a warning message if the audio format is not supported" ext = splitext(path)[1].lower() if ext != ".wav": log.warning(f"{path}: audio format {ext} is not supported and may not work properly on some platforms (Windows/Mac/Linux).\n" + ...
Produce a warning message if the audio format is not supported
Produce a warning message if the audio format is not supported
[ "Produce", "a", "warning", "message", "if", "the", "audio", "format", "is", "not", "supported" ]
def check_audio_format(path: str) -> None: ext = splitext(path)[1].lower() if ext != ".wav": log.warning(f"{path}: audio format {ext} is not supported and may not work properly on some platforms (Windows/Mac/Linux).\n" + f"Please use WAV.")
[ "def", "check_audio_format", "(", "path", ":", "str", ")", "->", "None", ":", "ext", "=", "splitext", "(", "path", ")", "[", "1", "]", ".", "lower", "(", ")", "if", "ext", "!=", "\".wav\"", ":", "log", ".", "warning", "(", "f\"{path}: audio format {ext...
Produce a warning message if the audio format is not supported
[ "Produce", "a", "warning", "message", "if", "the", "audio", "format", "is", "not", "supported" ]
[ "\"Produce a warning message if the audio format is not supported\"" ]
[ { "param": "path", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "path", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d0a9b25e8d2e1645545fa0433e6d01e02131baa0
NLGS2907/python-gamelib-plus
gamelib.py
[ "MIT" ]
Python
_playsoundWin
None
def _playsoundWin(sound: str) -> None: "Plays a sound for Windows." from ctypes import c_buffer, windll from random import random from sys import getfilesystemencoding def winCommand(*command: Tuple[str, ...]): "Executes a Windows Command." buf = c_buff...
Plays a sound for Windows.
Plays a sound for Windows.
[ "Plays", "a", "sound", "for", "Windows", "." ]
def _playsoundWin(sound: str) -> None: from ctypes import c_buffer, windll from random import random from sys import getfilesystemencoding def winCommand(*command: Tuple[str, ...]): buf = c_buffer(255) command = ' '.join(command).encode(getfilesystemencoding()) ...
[ "def", "_playsoundWin", "(", "sound", ":", "str", ")", "->", "None", ":", "from", "ctypes", "import", "c_buffer", ",", "windll", "from", "random", "import", "random", "from", "sys", "import", "getfilesystemencoding", "def", "winCommand", "(", "*", "command", ...
Plays a sound for Windows.
[ "Plays", "a", "sound", "for", "Windows", "." ]
[ "\"Plays a sound for Windows.\"", "\"Executes a Windows Command.\"" ]
[ { "param": "sound", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sound", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d0a9b25e8d2e1645545fa0433e6d01e02131baa0
NLGS2907/python-gamelib-plus
gamelib.py
[ "MIT" ]
Python
play_sound
None
def play_sound(sound: str) -> None: """ Play a sound located at the given path. Example: ``` gamelib.play_sound('sound/jump.wav') ``` Note: The only sound format that is supported accross all platforms (Windows/Mac/Linux) is W...
Play a sound located at the given path. Example: ``` gamelib.play_sound('sound/jump.wav') ``` Note: The only sound format that is supported accross all platforms (Windows/Mac/Linux) is WAV.
Play a sound located at the given path.
[ "Play", "a", "sound", "located", "at", "the", "given", "path", "." ]
def play_sound(sound: str) -> None: check_audio_format(sound) if system == 'Windows': _playsoundWin(sound) elif system == 'Darwin': _playsoundOSX(sound) else: _playsoundNix(sound)
[ "def", "play_sound", "(", "sound", ":", "str", ")", "->", "None", ":", "check_audio_format", "(", "sound", ")", "if", "system", "==", "'Windows'", ":", "_playsoundWin", "(", "sound", ")", "elif", "system", "==", "'Darwin'", ":", "_playsoundOSX", "(", "soun...
Play a sound located at the given path.
[ "Play", "a", "sound", "located", "at", "the", "given", "path", "." ]
[ "\"\"\"\n Play a sound located at the given path.\n\n Example:\n ```\n gamelib.play_sound('sound/jump.wav')\n ```\n\n Note:\n The only sound format that is supported accross all platforms (Windows/Mac/Linux)\n is WAV.\n \"\"\"" ]
[ { "param": "sound", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sound", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [ { "identifier": "examples", "docstring": "```\...
d0a9b25e8d2e1645545fa0433e6d01e02131baa0
NLGS2907/python-gamelib-plus
gamelib.py
[ "MIT" ]
Python
start
None
def start(self, game_main: Callable[..., None], args) -> None: "Starts and sets up the thread." self.game_main = game_main self.args = args super().start()
Starts and sets up the thread.
Starts and sets up the thread.
[ "Starts", "and", "sets", "up", "the", "thread", "." ]
def start(self, game_main: Callable[..., None], args) -> None: self.game_main = game_main self.args = args super().start()
[ "def", "start", "(", "self", ",", "game_main", ":", "Callable", "[", "...", ",", "None", "]", ",", "args", ")", "->", "None", ":", "self", ".", "game_main", "=", "game_main", "self", ".", "args", "=", "args", "super", "(", ")", ".", "start", "(", ...
Starts and sets up the thread.
[ "Starts", "and", "sets", "up", "the", "thread", "." ]
[ "\"Starts and sets up the thread.\"" ]
[ { "param": "self", "type": null }, { "param": "game_main", "type": "Callable[..., None]" }, { "param": "args", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "game_main", "type": "Callable[..., None]", "docstring": null, ...
d0a9b25e8d2e1645545fa0433e6d01e02131baa0
NLGS2907/python-gamelib-plus
gamelib.py
[ "MIT" ]
Python
notify_tk
None
def notify_tk(self) -> None: """ Waits for `_TkWindow` and notifies it so it generates the <notify> event. """ self.wait_for_tk() w = _TkWindow.instance if w: w.notify()
Waits for `_TkWindow` and notifies it so it generates the <notify> event.
Waits for `_TkWindow` and notifies it so it generates the event.
[ "Waits", "for", "`", "_TkWindow", "`", "and", "notifies", "it", "so", "it", "generates", "the", "event", "." ]
def notify_tk(self) -> None: self.wait_for_tk() w = _TkWindow.instance if w: w.notify()
[ "def", "notify_tk", "(", "self", ")", "->", "None", ":", "self", ".", "wait_for_tk", "(", ")", "w", "=", "_TkWindow", ".", "instance", "if", "w", ":", "w", ".", "notify", "(", ")" ]
Waits for `_TkWindow` and notifies it so it generates the <notify> event.
[ "Waits", "for", "`", "_TkWindow", "`", "and", "notifies", "it", "so", "it", "generates", "the", "<notify", ">", "event", "." ]
[ "\"\"\"\n Waits for `_TkWindow` and notifies it so it\n generates the <notify> event.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d0a9b25e8d2e1645545fa0433e6d01e02131baa0
NLGS2907/python-gamelib-plus
gamelib.py
[ "MIT" ]
Python
wait_for_tk
None
def wait_for_tk(self) -> None: """ Initializes the thread and waits until the window also is initialized. """ if not _TkWindow.initialized.is_set(): _GameThread.initialized.set() # block until Tk is initialized _TkWindow.initialized.wait()
Initializes the thread and waits until the window also is initialized.
Initializes the thread and waits until the window also is initialized.
[ "Initializes", "the", "thread", "and", "waits", "until", "the", "window", "also", "is", "initialized", "." ]
def wait_for_tk(self) -> None: if not _TkWindow.initialized.is_set(): _GameThread.initialized.set() _TkWindow.initialized.wait()
[ "def", "wait_for_tk", "(", "self", ")", "->", "None", ":", "if", "not", "_TkWindow", ".", "initialized", ".", "is_set", "(", ")", ":", "_GameThread", ".", "initialized", ".", "set", "(", ")", "_TkWindow", ".", "initialized", ".", "wait", "(", ")" ]
Initializes the thread and waits until the window also is initialized.
[ "Initializes", "the", "thread", "and", "waits", "until", "the", "window", "also", "is", "initialized", "." ]
[ "\"\"\"\n Initializes the thread and waits until the window\n also is initialized.\n \"\"\"", "# block until Tk is initialized" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d0a9b25e8d2e1645545fa0433e6d01e02131baa0
NLGS2907/python-gamelib-plus
gamelib.py
[ "MIT" ]
Python
send_command_to_tk
None
def send_command_to_tk(self, *args, notify: bool=False) -> None: "Enqueues a command to be processed later." _TkWindow.commands.put(args) if notify: self.notify_tk()
Enqueues a command to be processed later.
Enqueues a command to be processed later.
[ "Enqueues", "a", "command", "to", "be", "processed", "later", "." ]
def send_command_to_tk(self, *args, notify: bool=False) -> None: _TkWindow.commands.put(args) if notify: self.notify_tk()
[ "def", "send_command_to_tk", "(", "self", ",", "*", "args", ",", "notify", ":", "bool", "=", "False", ")", "->", "None", ":", "_TkWindow", ".", "commands", ".", "put", "(", "args", ")", "if", "notify", ":", "self", ".", "notify_tk", "(", ")" ]
Enqueues a command to be processed later.
[ "Enqueues", "a", "command", "to", "be", "processed", "later", "." ]
[ "\"Enqueues a command to be processed later.\"" ]
[ { "param": "self", "type": null }, { "param": "notify", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "notify", "type": "bool", "docstring": null, "docstring_tokens...
d0a9b25e8d2e1645545fa0433e6d01e02131baa0
NLGS2907/python-gamelib-plus
gamelib.py
[ "MIT" ]
Python
icon
None
def icon(self, path: str) -> None: """ Set the window icon to the image located at `path`. Example: ``` gamelib.icon('images/icon.gif') ``` Note: The only image formats that are supported accross all platforms (Windows/Mac/Linux) ...
Set the window icon to the image located at `path`. Example: ``` gamelib.icon('images/icon.gif') ``` Note: The only image formats that are supported accross all platforms (Windows/Mac/Linux) are GIF and PPM/PGM/PBM.
Set the window icon to the image located at `path`.
[ "Set", "the", "window", "icon", "to", "the", "image", "located", "at", "`", "path", "`", "." ]
def icon(self, path: str) -> None: self.send_command_to_tk('icon', path)
[ "def", "icon", "(", "self", ",", "path", ":", "str", ")", "->", "None", ":", "self", ".", "send_command_to_tk", "(", "'icon'", ",", "path", ")" ]
Set the window icon to the image located at `path`.
[ "Set", "the", "window", "icon", "to", "the", "image", "located", "at", "`", "path", "`", "." ]
[ "\"\"\"\n Set the window icon to the image located at `path`.\n\n Example:\n ```\n gamelib.icon('images/icon.gif')\n ```\n\n Note:\n The only image formats that are supported accross all platforms (Windows/Mac/Linux)\n are GIF and PPM/PGM/P...
[ { "param": "self", "type": null }, { "param": "path", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "path", "type": "str", "docstring": null, "docstring_tokens": ...
d0a9b25e8d2e1645545fa0433e6d01e02131baa0
NLGS2907/python-gamelib-plus
gamelib.py
[ "MIT" ]
Python
draw_polygon
None
def draw_polygon(self, points: List[int], **options) -> None: """ Draw a polygon with vertices in the given `points` coordinates list. The list must have an even amount of numbers; each pair determines a vertex. The last vertex is automatically joined with the first one with a segment. ...
Draw a polygon with vertices in the given `points` coordinates list. The list must have an even amount of numbers; each pair determines a vertex. The last vertex is automatically joined with the first one with a segment. To see all supported options, see the documentation for [...
Draw a polygon with vertices in the given `points` coordinates list. The list must have an even amount of numbers; each pair determines a vertex. The last vertex is automatically joined with the first one with a segment. To see all supported options, see the documentation for [`tkinter.Canvas.create_polygon`].
[ "Draw", "a", "polygon", "with", "vertices", "in", "the", "given", "`", "points", "`", "coordinates", "list", ".", "The", "list", "must", "have", "an", "even", "amount", "of", "numbers", ";", "each", "pair", "determines", "a", "vertex", ".", "The", "last"...
def draw_polygon(self, points: List[int], **options) -> None: self.send_command_to_tk('draw', 'polygon', points, options)
[ "def", "draw_polygon", "(", "self", ",", "points", ":", "List", "[", "int", "]", ",", "**", "options", ")", "->", "None", ":", "self", ".", "send_command_to_tk", "(", "'draw'", ",", "'polygon'", ",", "points", ",", "options", ")" ]
Draw a polygon with vertices in the given `points` coordinates list.
[ "Draw", "a", "polygon", "with", "vertices", "in", "the", "given", "`", "points", "`", "coordinates", "list", "." ]
[ "\"\"\"\n Draw a polygon with vertices in the given `points` coordinates list. The list must have\n an even amount of numbers; each pair determines a vertex. The last vertex is automatically\n joined with the first one with a segment.\n\n To see all supported options, see the documentati...
[ { "param": "self", "type": null }, { "param": "points", "type": "List[int]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "points", "type": "List[int]", "docstring": null, "docstring_t...
d0a9b25e8d2e1645545fa0433e6d01e02131baa0
NLGS2907/python-gamelib-plus
gamelib.py
[ "MIT" ]
Python
say
Optional[bool]
def say(self, message: str, msg_type: str='info') -> Optional[bool]: """ Present the user with the given `message` in a dialog box, depending on the type. Available types are `info`, `warning`, `error`, `question`, `okcancel`, `yesno`, `yesnocancel` or `retry`. The default is `in...
Present the user with the given `message` in a dialog box, depending on the type. Available types are `info`, `warning`, `error`, `question`, `okcancel`, `yesno`, `yesnocancel` or `retry`. The default is `info`.
Present the user with the given `message` in a dialog box, depending on the type.
[ "Present", "the", "user", "with", "the", "given", "`", "message", "`", "in", "a", "dialog", "box", "depending", "on", "the", "type", "." ]
def say(self, message: str, msg_type: str='info') -> Optional[bool]: done = Queue() self.send_command_to_tk('say', message, msg_type, done, notify=True) return done.get()
[ "def", "say", "(", "self", ",", "message", ":", "str", ",", "msg_type", ":", "str", "=", "'info'", ")", "->", "Optional", "[", "bool", "]", ":", "done", "=", "Queue", "(", ")", "self", ".", "send_command_to_tk", "(", "'say'", ",", "message", ",", "...
Present the user with the given `message` in a dialog box, depending on the type.
[ "Present", "the", "user", "with", "the", "given", "`", "message", "`", "in", "a", "dialog", "box", "depending", "on", "the", "type", "." ]
[ "\"\"\"\n Present the user with the given `message` in a dialog box, depending on the type.\n Available types are `info`, `warning`, `error`, `question`, `okcancel`, `yesno`,\n `yesnocancel` or `retry`.\n The default is `info`.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "message", "type": "str" }, { "param": "msg_type", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "message", "type": "str", "docstring": null, "docstring_tokens...
d0a9b25e8d2e1645545fa0433e6d01e02131baa0
NLGS2907/python-gamelib-plus
gamelib.py
[ "MIT" ]
Python
input
Optional[str]
def input(self, prompt: str) -> Optional[str]: """ Ask the user to enter a text value. Args: prompt: A message to display. Returns: A string containing the value that the user typed. `None` if the user clicked on Cancel instead of OK. """ ...
Ask the user to enter a text value. Args: prompt: A message to display. Returns: A string containing the value that the user typed. `None` if the user clicked on Cancel instead of OK.
Ask the user to enter a text value.
[ "Ask", "the", "user", "to", "enter", "a", "text", "value", "." ]
def input(self, prompt: str) -> Optional[str]: response = Queue() self.send_command_to_tk('input', prompt, response, notify=True) return response.get()
[ "def", "input", "(", "self", ",", "prompt", ":", "str", ")", "->", "Optional", "[", "str", "]", ":", "response", "=", "Queue", "(", ")", "self", ".", "send_command_to_tk", "(", "'input'", ",", "prompt", ",", "response", ",", "notify", "=", "True", ")...
Ask the user to enter a text value.
[ "Ask", "the", "user", "to", "enter", "a", "text", "value", "." ]
[ "\"\"\"\n Ask the user to enter a text value.\n\n Args:\n prompt: A message to display.\n\n Returns:\n A string containing the value that the user typed. `None` if the user\n clicked on Cancel instead of OK.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "prompt", "type": "str" } ]
{ "returns": [ { "docstring": "A string containing the value that the user typed. `None` if the user\nclicked on Cancel instead of OK.", "docstring_tokens": [ "A", "string", "containing", "the", "value", "that", "the", "user", "ty...
d0a9b25e8d2e1645545fa0433e6d01e02131baa0
NLGS2907/python-gamelib-plus
gamelib.py
[ "MIT" ]
Python
loop
bool
def loop(self, fps: int=30) -> bool: """ When used in a `while` loop, the body will be executed `fps` times per second. Returns: `True` if the game window is still open, `False` otherwise. Example: ``` while gamelib.loop(fps=30): # th...
When used in a `while` loop, the body will be executed `fps` times per second. Returns: `True` if the game window is still open, `False` otherwise. Example: ``` while gamelib.loop(fps=30): # this is executed 30 times per second ...
When used in a `while` loop, the body will be executed `fps` times per second.
[ "When", "used", "in", "a", "`", "while", "`", "loop", "the", "body", "will", "be", "executed", "`", "fps", "`", "times", "per", "second", "." ]
def loop(self, fps: int=30) -> bool: frame_duration = 1.0 / fps a = _GameThread._last_loop_time b = time() if a: sleep(max(0, frame_duration - (b - a))) _GameThread._last_loop_time = time() return self.is_alive()
[ "def", "loop", "(", "self", ",", "fps", ":", "int", "=", "30", ")", "->", "bool", ":", "frame_duration", "=", "1.0", "/", "fps", "a", "=", "_GameThread", ".", "_last_loop_time", "b", "=", "time", "(", ")", "if", "a", ":", "sleep", "(", "max", "("...
When used in a `while` loop, the body will be executed `fps` times per second.
[ "When", "used", "in", "a", "`", "while", "`", "loop", "the", "body", "will", "be", "executed", "`", "fps", "`", "times", "per", "second", "." ]
[ "\"\"\"\n When used in a `while` loop, the body will be executed `fps` times per second.\n\n Returns:\n `True` if the game window is still open, `False` otherwise.\n\n Example:\n ```\n while gamelib.loop(fps=30):\n # this is executed 30 times per ...
[ { "param": "self", "type": null }, { "param": "fps", "type": "int" } ]
{ "returns": [ { "docstring": "`True` if the game window is still open, `False` otherwise.", "docstring_tokens": [ "`", "True", "`", "if", "the", "game", "window", "is", "still", "open", "`", "False", ...
6bf62f0a8fcf6f922fe43bf58fb625b7352492f4
zbartl/flask
examples/tutorial/tests/conftest.py
[ "BSD-3-Clause" ]
Python
app
null
def app(): """Create and configure a new app instance for each test.""" # create a temporary file to isolate the database for each test db_fd, db_path = tempfile.mkstemp() # create the app with common test config app = create_app({"TESTING": True, "DATABASE": db_path}) # create the database and...
Create and configure a new app instance for each test.
Create and configure a new app instance for each test.
[ "Create", "and", "configure", "a", "new", "app", "instance", "for", "each", "test", "." ]
def app(): db_fd, db_path = tempfile.mkstemp() app = create_app({"TESTING": True, "DATABASE": db_path}) with app.app_context(): init_db() get_db().executescript(_data_sql) yield app os.close(db_fd) os.unlink(db_path)
[ "def", "app", "(", ")", ":", "db_fd", ",", "db_path", "=", "tempfile", ".", "mkstemp", "(", ")", "app", "=", "create_app", "(", "{", "\"TESTING\"", ":", "True", ",", "\"DATABASE\"", ":", "db_path", "}", ")", "with", "app", ".", "app_context", "(", ")...
Create and configure a new app instance for each test.
[ "Create", "and", "configure", "a", "new", "app", "instance", "for", "each", "test", "." ]
[ "\"\"\"Create and configure a new app instance for each test.\"\"\"", "# create a temporary file to isolate the database for each test", "# create the app with common test config", "# create the database and load test data", "# close and remove the temporary database" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
3704626b1c68f9e4a92e5b7ccbdd816871f8a6f6
zbartl/flask
examples/tutorial/flaskr/blog.py
[ "BSD-3-Clause" ]
Python
create
<not_specific>
def create(): """Create a new post for the current user.""" if request.method == "POST": title = request.form["title"] body = request.form["body"] error = None if not title: error = "Title is required." if error is not None: flash(error) ...
Create a new post for the current user.
Create a new post for the current user.
[ "Create", "a", "new", "post", "for", "the", "current", "user", "." ]
def create(): if request.method == "POST": title = request.form["title"] body = request.form["body"] error = None if not title: error = "Title is required." if error is not None: flash(error) else: db = get_db() db.execu...
[ "def", "create", "(", ")", ":", "if", "request", ".", "method", "==", "\"POST\"", ":", "title", "=", "request", ".", "form", "[", "\"title\"", "]", "body", "=", "request", ".", "form", "[", "\"body\"", "]", "error", "=", "None", "if", "not", "title",...
Create a new post for the current user.
[ "Create", "a", "new", "post", "for", "the", "current", "user", "." ]
[ "\"\"\"Create a new post for the current user.\"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
212f7d7ee8848aa6ef8c6469754c14ae8eb7c9d6
zbartl/flask
src/flask/debughelpers.py
[ "BSD-3-Clause" ]
Python
attach_enctype_error_multidict
<not_specific>
def attach_enctype_error_multidict(request): """Since Flask 0.8 we're monkeypatching the files object in case a request is detected that does not use multipart form data but the files object is accessed. """ oldcls = request.files.__class__ class newcls(oldcls): def __getitem__(self, ke...
Since Flask 0.8 we're monkeypatching the files object in case a request is detected that does not use multipart form data but the files object is accessed.
Since Flask 0.8 we're monkeypatching the files object in case a request is detected that does not use multipart form data but the files object is accessed.
[ "Since", "Flask", "0", ".", "8", "we", "'", "re", "monkeypatching", "the", "files", "object", "in", "case", "a", "request", "is", "detected", "that", "does", "not", "use", "multipart", "form", "data", "but", "the", "files", "object", "is", "accessed", "....
def attach_enctype_error_multidict(request): oldcls = request.files.__class__ class newcls(oldcls): def __getitem__(self, key): try: return oldcls.__getitem__(self, key) except KeyError as e: if key not in request.form: raise ...
[ "def", "attach_enctype_error_multidict", "(", "request", ")", ":", "oldcls", "=", "request", ".", "files", ".", "__class__", "class", "newcls", "(", "oldcls", ")", ":", "def", "__getitem__", "(", "self", ",", "key", ")", ":", "try", ":", "return", "oldcls"...
Since Flask 0.8 we're monkeypatching the files object in case a request is detected that does not use multipart form data but the files object is accessed.
[ "Since", "Flask", "0", ".", "8", "we", "'", "re", "monkeypatching", "the", "files", "object", "in", "case", "a", "request", "is", "detected", "that", "does", "not", "use", "multipart", "form", "data", "but", "the", "files", "object", "is", "accessed", "....
[ "\"\"\"Since Flask 0.8 we're monkeypatching the files object in case a\n request is detected that does not use multipart form data but the files\n object is accessed.\n \"\"\"" ]
[ { "param": "request", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "request", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
212f7d7ee8848aa6ef8c6469754c14ae8eb7c9d6
zbartl/flask
src/flask/debughelpers.py
[ "BSD-3-Clause" ]
Python
explain_template_loading_attempts
None
def explain_template_loading_attempts(app: Flask, template, attempts) -> None: """This should help developers understand what failed""" info = [f"Locating template {template!r}:"] total_found = 0 blueprint = None reqctx = _request_ctx_stack.top if reqctx is not None and reqctx.request.blueprint ...
This should help developers understand what failed
This should help developers understand what failed
[ "This", "should", "help", "developers", "understand", "what", "failed" ]
def explain_template_loading_attempts(app: Flask, template, attempts) -> None: info = [f"Locating template {template!r}:"] total_found = 0 blueprint = None reqctx = _request_ctx_stack.top if reqctx is not None and reqctx.request.blueprint is not None: blueprint = reqctx.request.blueprint ...
[ "def", "explain_template_loading_attempts", "(", "app", ":", "Flask", ",", "template", ",", "attempts", ")", "->", "None", ":", "info", "=", "[", "f\"Locating template {template!r}:\"", "]", "total_found", "=", "0", "blueprint", "=", "None", "reqctx", "=", "_req...
This should help developers understand what failed
[ "This", "should", "help", "developers", "understand", "what", "failed" ]
[ "\"\"\"This should help developers understand what failed\"\"\"" ]
[ { "param": "app", "type": "Flask" }, { "param": "template", "type": null }, { "param": "attempts", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "app", "type": "Flask", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "template", "type": null, "docstring": null, "docstring_toke...
1cf007e20ac7a20eda0428f7c197c87cd466fcea
zbartl/flask
src/flask/scaffold.py
[ "BSD-3-Clause" ]
Python
static_folder
t.Optional[str]
def static_folder(self) -> t.Optional[str]: """The absolute path to the configured static folder. ``None`` if no static folder is set. """ if self._static_folder is not None: return os.path.join(self.root_path, self._static_folder) else: return None
The absolute path to the configured static folder. ``None`` if no static folder is set.
The absolute path to the configured static folder. ``None`` if no static folder is set.
[ "The", "absolute", "path", "to", "the", "configured", "static", "folder", ".", "`", "`", "None", "`", "`", "if", "no", "static", "folder", "is", "set", "." ]
def static_folder(self) -> t.Optional[str]: if self._static_folder is not None: return os.path.join(self.root_path, self._static_folder) else: return None
[ "def", "static_folder", "(", "self", ")", "->", "t", ".", "Optional", "[", "str", "]", ":", "if", "self", ".", "_static_folder", "is", "not", "None", ":", "return", "os", ".", "path", ".", "join", "(", "self", ".", "root_path", ",", "self", ".", "_...
The absolute path to the configured static folder.
[ "The", "absolute", "path", "to", "the", "configured", "static", "folder", "." ]
[ "\"\"\"The absolute path to the configured static folder. ``None``\n if no static folder is set.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1cf007e20ac7a20eda0428f7c197c87cd466fcea
zbartl/flask
src/flask/scaffold.py
[ "BSD-3-Clause" ]
Python
static_url_path
t.Optional[str]
def static_url_path(self) -> t.Optional[str]: """The URL prefix that the static route will be accessible from. If it was not configured during init, it is derived from :attr:`static_folder`. """ if self._static_url_path is not None: return self._static_url_path ...
The URL prefix that the static route will be accessible from. If it was not configured during init, it is derived from :attr:`static_folder`.
The URL prefix that the static route will be accessible from. If it was not configured during init, it is derived from
[ "The", "URL", "prefix", "that", "the", "static", "route", "will", "be", "accessible", "from", ".", "If", "it", "was", "not", "configured", "during", "init", "it", "is", "derived", "from" ]
def static_url_path(self) -> t.Optional[str]: if self._static_url_path is not None: return self._static_url_path if self.static_folder is not None: basename = os.path.basename(self.static_folder) return f"/{basename}".rstrip("/") return None
[ "def", "static_url_path", "(", "self", ")", "->", "t", ".", "Optional", "[", "str", "]", ":", "if", "self", ".", "_static_url_path", "is", "not", "None", ":", "return", "self", ".", "_static_url_path", "if", "self", ".", "static_folder", "is", "not", "No...
The URL prefix that the static route will be accessible from.
[ "The", "URL", "prefix", "that", "the", "static", "route", "will", "be", "accessible", "from", "." ]
[ "\"\"\"The URL prefix that the static route will be accessible from.\n\n If it was not configured during init, it is derived from\n :attr:`static_folder`.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [ { "identifier": "attr", "docstring": null, ...
1cf007e20ac7a20eda0428f7c197c87cd466fcea
zbartl/flask
src/flask/scaffold.py
[ "BSD-3-Clause" ]
Python
jinja_loader
t.Optional[FileSystemLoader]
def jinja_loader(self) -> t.Optional[FileSystemLoader]: """The Jinja loader for this object's templates. By default this is a class :class:`jinja2.loaders.FileSystemLoader` to :attr:`template_folder` if it is set. .. versionadded:: 0.5 """ if self.template_folder is not ...
The Jinja loader for this object's templates. By default this is a class :class:`jinja2.loaders.FileSystemLoader` to :attr:`template_folder` if it is set. .. versionadded:: 0.5
The Jinja loader for this object's templates. By default this is a class :class:`jinja2.loaders.FileSystemLoader` to
[ "The", "Jinja", "loader", "for", "this", "object", "'", "s", "templates", ".", "By", "default", "this", "is", "a", "class", ":", "class", ":", "`", "jinja2", ".", "loaders", ".", "FileSystemLoader", "`", "to" ]
def jinja_loader(self) -> t.Optional[FileSystemLoader]: if self.template_folder is not None: return FileSystemLoader(os.path.join(self.root_path, self.template_folder)) else: return None
[ "def", "jinja_loader", "(", "self", ")", "->", "t", ".", "Optional", "[", "FileSystemLoader", "]", ":", "if", "self", ".", "template_folder", "is", "not", "None", ":", "return", "FileSystemLoader", "(", "os", ".", "path", ".", "join", "(", "self", ".", ...
The Jinja loader for this object's templates.
[ "The", "Jinja", "loader", "for", "this", "object", "'", "s", "templates", "." ]
[ "\"\"\"The Jinja loader for this object's templates. By default this\n is a class :class:`jinja2.loaders.FileSystemLoader` to\n :attr:`template_folder` if it is set.\n\n .. versionadded:: 0.5\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [ { "identifier": "attr", "docstring": "`template_...
1cf007e20ac7a20eda0428f7c197c87cd466fcea
zbartl/flask
src/flask/scaffold.py
[ "BSD-3-Clause" ]
Python
endpoint
t.Callable
def endpoint(self, endpoint: str) -> t.Callable: """Decorate a view function to register it for the given endpoint. Used if a rule is added without a ``view_func`` with :meth:`add_url_rule`. .. code-block:: python app.add_url_rule("/ex", endpoint="example") @ap...
Decorate a view function to register it for the given endpoint. Used if a rule is added without a ``view_func`` with :meth:`add_url_rule`. .. code-block:: python app.add_url_rule("/ex", endpoint="example") @app.endpoint("example") def example(): ...
Decorate a view function to register it for the given endpoint. Used if a rule is added without a ``view_func`` with
[ "Decorate", "a", "view", "function", "to", "register", "it", "for", "the", "given", "endpoint", ".", "Used", "if", "a", "rule", "is", "added", "without", "a", "`", "`", "view_func", "`", "`", "with" ]
def endpoint(self, endpoint: str) -> t.Callable: def decorator(f): self.view_functions[endpoint] = f return f return decorator
[ "def", "endpoint", "(", "self", ",", "endpoint", ":", "str", ")", "->", "t", ".", "Callable", ":", "def", "decorator", "(", "f", ")", ":", "self", ".", "view_functions", "[", "endpoint", "]", "=", "f", "return", "f", "return", "decorator" ]
Decorate a view function to register it for the given endpoint.
[ "Decorate", "a", "view", "function", "to", "register", "it", "for", "the", "given", "endpoint", "." ]
[ "\"\"\"Decorate a view function to register it for the given\n endpoint. Used if a rule is added without a ``view_func`` with\n :meth:`add_url_rule`.\n\n .. code-block:: python\n\n app.add_url_rule(\"/ex\", endpoint=\"example\")\n\n @app.endpoint(\"example\")\n ...
[ { "param": "self", "type": null }, { "param": "endpoint", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "endpoint", "type": "str", "docstring": "The endpoint name to associ...
1cf007e20ac7a20eda0428f7c197c87cd466fcea
zbartl/flask
src/flask/scaffold.py
[ "BSD-3-Clause" ]
Python
before_request
BeforeRequestCallable
def before_request(self, f: BeforeRequestCallable) -> BeforeRequestCallable: """Register a function to run before each request. For example, this can be used to open a database connection, or to load the logged in user from the session. .. code-block:: python @app.before_r...
Register a function to run before each request. For example, this can be used to open a database connection, or to load the logged in user from the session. .. code-block:: python @app.before_request def load_user(): if "user_id" in session: ...
Register a function to run before each request. For example, this can be used to open a database connection, or to load the logged in user from the session. code-block:: python The function will be called without any arguments. If it returns a non-``None`` value, the value is handled as if it was the return value f...
[ "Register", "a", "function", "to", "run", "before", "each", "request", ".", "For", "example", "this", "can", "be", "used", "to", "open", "a", "database", "connection", "or", "to", "load", "the", "logged", "in", "user", "from", "the", "session", ".", "cod...
def before_request(self, f: BeforeRequestCallable) -> BeforeRequestCallable: self.before_request_funcs.setdefault(None, []).append(f) return f
[ "def", "before_request", "(", "self", ",", "f", ":", "BeforeRequestCallable", ")", "->", "BeforeRequestCallable", ":", "self", ".", "before_request_funcs", ".", "setdefault", "(", "None", ",", "[", "]", ")", ".", "append", "(", "f", ")", "return", "f" ]
Register a function to run before each request.
[ "Register", "a", "function", "to", "run", "before", "each", "request", "." ]
[ "\"\"\"Register a function to run before each request.\n\n For example, this can be used to open a database connection, or\n to load the logged in user from the session.\n\n .. code-block:: python\n\n @app.before_request\n def load_user():\n if \"user_id\" i...
[ { "param": "self", "type": null }, { "param": "f", "type": "BeforeRequestCallable" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "f", "type": "BeforeRequestCallable", "docstring": null, "docs...
1cf007e20ac7a20eda0428f7c197c87cd466fcea
zbartl/flask
src/flask/scaffold.py
[ "BSD-3-Clause" ]
Python
after_request
AfterRequestCallable
def after_request(self, f: AfterRequestCallable) -> AfterRequestCallable: """Register a function to run after each request to this object. The function is called with the response object, and must return a response object. This allows the functions to modify or replace the response befo...
Register a function to run after each request to this object. The function is called with the response object, and must return a response object. This allows the functions to modify or replace the response before it is sent. If a function raises an exception, any remaining ``af...
Register a function to run after each request to this object. The function is called with the response object, and must return a response object. This allows the functions to modify or replace the response before it is sent. If a function raises an exception, any remaining ``after_request`` functions will not be calle...
[ "Register", "a", "function", "to", "run", "after", "each", "request", "to", "this", "object", ".", "The", "function", "is", "called", "with", "the", "response", "object", "and", "must", "return", "a", "response", "object", ".", "This", "allows", "the", "fu...
def after_request(self, f: AfterRequestCallable) -> AfterRequestCallable: self.after_request_funcs.setdefault(None, []).append(f) return f
[ "def", "after_request", "(", "self", ",", "f", ":", "AfterRequestCallable", ")", "->", "AfterRequestCallable", ":", "self", ".", "after_request_funcs", ".", "setdefault", "(", "None", ",", "[", "]", ")", ".", "append", "(", "f", ")", "return", "f" ]
Register a function to run after each request to this object.
[ "Register", "a", "function", "to", "run", "after", "each", "request", "to", "this", "object", "." ]
[ "\"\"\"Register a function to run after each request to this object.\n\n The function is called with the response object, and must return\n a response object. This allows the functions to modify or\n replace the response before it is sent.\n\n If a function raises an exception, any remai...
[ { "param": "self", "type": null }, { "param": "f", "type": "AfterRequestCallable" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "f", "type": "AfterRequestCallable", "docstring": null, "docst...
1cf007e20ac7a20eda0428f7c197c87cd466fcea
zbartl/flask
src/flask/scaffold.py
[ "BSD-3-Clause" ]
Python
teardown_request
TeardownCallable
def teardown_request(self, f: TeardownCallable) -> TeardownCallable: """Register a function to be run at the end of each request, regardless of whether there was an exception or not. These functions are executed when the request context is popped, even if not an actual request was perfo...
Register a function to be run at the end of each request, regardless of whether there was an exception or not. These functions are executed when the request context is popped, even if not an actual request was performed. Example:: ctx = app.test_request_context() ...
Register a function to be run at the end of each request, regardless of whether there was an exception or not. These functions are executed when the request context is popped, even if not an actual request was performed. When ``ctx.pop()`` is executed in the above example, the teardown functions are called just b...
[ "Register", "a", "function", "to", "be", "run", "at", "the", "end", "of", "each", "request", "regardless", "of", "whether", "there", "was", "an", "exception", "or", "not", ".", "These", "functions", "are", "executed", "when", "the", "request", "context", "...
def teardown_request(self, f: TeardownCallable) -> TeardownCallable: self.teardown_request_funcs.setdefault(None, []).append(f) return f
[ "def", "teardown_request", "(", "self", ",", "f", ":", "TeardownCallable", ")", "->", "TeardownCallable", ":", "self", ".", "teardown_request_funcs", ".", "setdefault", "(", "None", ",", "[", "]", ")", ".", "append", "(", "f", ")", "return", "f" ]
Register a function to be run at the end of each request, regardless of whether there was an exception or not.
[ "Register", "a", "function", "to", "be", "run", "at", "the", "end", "of", "each", "request", "regardless", "of", "whether", "there", "was", "an", "exception", "or", "not", "." ]
[ "\"\"\"Register a function to be run at the end of each request,\n regardless of whether there was an exception or not. These functions\n are executed when the request context is popped, even if not an\n actual request was performed.\n\n Example::\n\n ctx = app.test_request_c...
[ { "param": "self", "type": null }, { "param": "f", "type": "TeardownCallable" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "f", "type": "TeardownCallable", "docstring": null, "docstring...
1cf007e20ac7a20eda0428f7c197c87cd466fcea
zbartl/flask
src/flask/scaffold.py
[ "BSD-3-Clause" ]
Python
context_processor
TemplateContextProcessorCallable
def context_processor( self, f: TemplateContextProcessorCallable ) -> TemplateContextProcessorCallable: """Registers a template context processor function.""" self.template_context_processors[None].append(f) return f
Registers a template context processor function.
Registers a template context processor function.
[ "Registers", "a", "template", "context", "processor", "function", "." ]
def context_processor( self, f: TemplateContextProcessorCallable ) -> TemplateContextProcessorCallable: self.template_context_processors[None].append(f) return f
[ "def", "context_processor", "(", "self", ",", "f", ":", "TemplateContextProcessorCallable", ")", "->", "TemplateContextProcessorCallable", ":", "self", ".", "template_context_processors", "[", "None", "]", ".", "append", "(", "f", ")", "return", "f" ]
Registers a template context processor function.
[ "Registers", "a", "template", "context", "processor", "function", "." ]
[ "\"\"\"Registers a template context processor function.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "f", "type": "TemplateContextProcessorCallable" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "f", "type": "TemplateContextProcessorCallable", "docstring": null, ...
1cf007e20ac7a20eda0428f7c197c87cd466fcea
zbartl/flask
src/flask/scaffold.py
[ "BSD-3-Clause" ]
Python
url_value_preprocessor
URLValuePreprocessorCallable
def url_value_preprocessor( self, f: URLValuePreprocessorCallable ) -> URLValuePreprocessorCallable: """Register a URL value preprocessor function for all view functions in the application. These functions will be called before the :meth:`before_request` functions. The funct...
Register a URL value preprocessor function for all view functions in the application. These functions will be called before the :meth:`before_request` functions. The function can modify the values captured from the matched url before they are passed to the view. For example, this can be...
Register a URL value preprocessor function for all view functions in the application. These functions will be called before the
[ "Register", "a", "URL", "value", "preprocessor", "function", "for", "all", "view", "functions", "in", "the", "application", ".", "These", "functions", "will", "be", "called", "before", "the" ]
def url_value_preprocessor( self, f: URLValuePreprocessorCallable ) -> URLValuePreprocessorCallable: self.url_value_preprocessors[None].append(f) return f
[ "def", "url_value_preprocessor", "(", "self", ",", "f", ":", "URLValuePreprocessorCallable", ")", "->", "URLValuePreprocessorCallable", ":", "self", ".", "url_value_preprocessors", "[", "None", "]", ".", "append", "(", "f", ")", "return", "f" ]
Register a URL value preprocessor function for all view functions in the application.
[ "Register", "a", "URL", "value", "preprocessor", "function", "for", "all", "view", "functions", "in", "the", "application", "." ]
[ "\"\"\"Register a URL value preprocessor function for all view\n functions in the application. These functions will be called before the\n :meth:`before_request` functions.\n\n The function can modify the values captured from the matched url before\n they are passed to the view. For exam...
[ { "param": "self", "type": null }, { "param": "f", "type": "URLValuePreprocessorCallable" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "f", "type": "URLValuePreprocessorCallable", "docstring": null, ...
1cf007e20ac7a20eda0428f7c197c87cd466fcea
zbartl/flask
src/flask/scaffold.py
[ "BSD-3-Clause" ]
Python
url_defaults
URLDefaultCallable
def url_defaults(self, f: URLDefaultCallable) -> URLDefaultCallable: """Callback function for URL defaults for all view functions of the application. It's called with the endpoint and values and should update the values passed in place. """ self.url_default_functions[None].appen...
Callback function for URL defaults for all view functions of the application. It's called with the endpoint and values and should update the values passed in place.
Callback function for URL defaults for all view functions of the application. It's called with the endpoint and values and should update the values passed in place.
[ "Callback", "function", "for", "URL", "defaults", "for", "all", "view", "functions", "of", "the", "application", ".", "It", "'", "s", "called", "with", "the", "endpoint", "and", "values", "and", "should", "update", "the", "values", "passed", "in", "place", ...
def url_defaults(self, f: URLDefaultCallable) -> URLDefaultCallable: self.url_default_functions[None].append(f) return f
[ "def", "url_defaults", "(", "self", ",", "f", ":", "URLDefaultCallable", ")", "->", "URLDefaultCallable", ":", "self", ".", "url_default_functions", "[", "None", "]", ".", "append", "(", "f", ")", "return", "f" ]
Callback function for URL defaults for all view functions of the application.
[ "Callback", "function", "for", "URL", "defaults", "for", "all", "view", "functions", "of", "the", "application", "." ]
[ "\"\"\"Callback function for URL defaults for all view functions of the\n application. It's called with the endpoint and values and should\n update the values passed in place.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "f", "type": "URLDefaultCallable" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "f", "type": "URLDefaultCallable", "docstring": null, "docstri...
1cf007e20ac7a20eda0428f7c197c87cd466fcea
zbartl/flask
src/flask/scaffold.py
[ "BSD-3-Clause" ]
Python
register_error_handler
None
def register_error_handler( self, code_or_exception: t.Union[t.Type[GenericException], int], f: "ErrorHandlerCallable[GenericException]", ) -> None: """Alternative error attach function to the :meth:`errorhandler` decorator that is more straightforward to use for non decorato...
Alternative error attach function to the :meth:`errorhandler` decorator that is more straightforward to use for non decorator usage. .. versionadded:: 0.7
Alternative error attach function to the :meth:`errorhandler` decorator that is more straightforward to use for non decorator usage.
[ "Alternative", "error", "attach", "function", "to", "the", ":", "meth", ":", "`", "errorhandler", "`", "decorator", "that", "is", "more", "straightforward", "to", "use", "for", "non", "decorator", "usage", "." ]
def register_error_handler( self, code_or_exception: t.Union[t.Type[GenericException], int], f: "ErrorHandlerCallable[GenericException]", ) -> None: if isinstance(code_or_exception, HTTPException): raise ValueError( "Tried to register a handler for an ex...
[ "def", "register_error_handler", "(", "self", ",", "code_or_exception", ":", "t", ".", "Union", "[", "t", ".", "Type", "[", "GenericException", "]", ",", "int", "]", ",", "f", ":", "\"ErrorHandlerCallable[GenericException]\"", ",", ")", "->", "None", ":", "i...
Alternative error attach function to the :meth:`errorhandler` decorator that is more straightforward to use for non decorator usage.
[ "Alternative", "error", "attach", "function", "to", "the", ":", "meth", ":", "`", "errorhandler", "`", "decorator", "that", "is", "more", "straightforward", "to", "use", "for", "non", "decorator", "usage", "." ]
[ "\"\"\"Alternative error attach function to the :meth:`errorhandler`\n decorator that is more straightforward to use for non decorator\n usage.\n\n .. versionadded:: 0.7\n \"\"\"", "# old broken behavior" ]
[ { "param": "self", "type": null }, { "param": "code_or_exception", "type": "t.Union[t.Type[GenericException], int]" }, { "param": "f", "type": "\"ErrorHandlerCallable[GenericException]\"" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "code_or_exception", "type": "t.Union[t.Type[GenericException], int]", ...
1cf007e20ac7a20eda0428f7c197c87cd466fcea
zbartl/flask
src/flask/scaffold.py
[ "BSD-3-Clause" ]
Python
_get_exc_class_and_code
t.Tuple[t.Type[Exception], t.Optional[int]]
def _get_exc_class_and_code( exc_class_or_code: t.Union[t.Type[Exception], int] ) -> t.Tuple[t.Type[Exception], t.Optional[int]]: """Get the exception class being handled. For HTTP status codes or ``HTTPException`` subclasses, return both the exception and status code. :para...
Get the exception class being handled. For HTTP status codes or ``HTTPException`` subclasses, return both the exception and status code. :param exc_class_or_code: Any exception class, or an HTTP status code as an integer.
Get the exception class being handled. For HTTP status codes or ``HTTPException`` subclasses, return both the exception and status code.
[ "Get", "the", "exception", "class", "being", "handled", ".", "For", "HTTP", "status", "codes", "or", "`", "`", "HTTPException", "`", "`", "subclasses", "return", "both", "the", "exception", "and", "status", "code", "." ]
def _get_exc_class_and_code( exc_class_or_code: t.Union[t.Type[Exception], int] ) -> t.Tuple[t.Type[Exception], t.Optional[int]]: exc_class: t.Type[Exception] if isinstance(exc_class_or_code, int): exc_class = default_exceptions[exc_class_or_code] else: exc_cl...
[ "def", "_get_exc_class_and_code", "(", "exc_class_or_code", ":", "t", ".", "Union", "[", "t", ".", "Type", "[", "Exception", "]", ",", "int", "]", ")", "->", "t", ".", "Tuple", "[", "t", ".", "Type", "[", "Exception", "]", ",", "t", ".", "Optional", ...
Get the exception class being handled.
[ "Get", "the", "exception", "class", "being", "handled", "." ]
[ "\"\"\"Get the exception class being handled. For HTTP status codes\n or ``HTTPException`` subclasses, return both the exception and\n status code.\n\n :param exc_class_or_code: Any exception class, or an HTTP status\n code as an integer.\n \"\"\"" ]
[ { "param": "exc_class_or_code", "type": "t.Union[t.Type[Exception], int]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "exc_class_or_code", "type": "t.Union[t.Type[Exception], int]", "docstring": "Any exception class, or an HTTP status\ncode as an integer.", "docstring_tokens": [ "Any", "exception", "class", "or"...
1cf007e20ac7a20eda0428f7c197c87cd466fcea
zbartl/flask
src/flask/scaffold.py
[ "BSD-3-Clause" ]
Python
_endpoint_from_view_func
str
def _endpoint_from_view_func(view_func: t.Callable) -> str: """Internal helper that returns the default endpoint for a given function. This always is the function name. """ assert view_func is not None, "expected view func if endpoint is not provided." return view_func.__name__
Internal helper that returns the default endpoint for a given function. This always is the function name.
Internal helper that returns the default endpoint for a given function. This always is the function name.
[ "Internal", "helper", "that", "returns", "the", "default", "endpoint", "for", "a", "given", "function", ".", "This", "always", "is", "the", "function", "name", "." ]
def _endpoint_from_view_func(view_func: t.Callable) -> str: assert view_func is not None, "expected view func if endpoint is not provided." return view_func.__name__
[ "def", "_endpoint_from_view_func", "(", "view_func", ":", "t", ".", "Callable", ")", "->", "str", ":", "assert", "view_func", "is", "not", "None", ",", "\"expected view func if endpoint is not provided.\"", "return", "view_func", ".", "__name__" ]
Internal helper that returns the default endpoint for a given function.
[ "Internal", "helper", "that", "returns", "the", "default", "endpoint", "for", "a", "given", "function", "." ]
[ "\"\"\"Internal helper that returns the default endpoint for a given\n function. This always is the function name.\n \"\"\"" ]
[ { "param": "view_func", "type": "t.Callable" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "view_func", "type": "t.Callable", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1cf007e20ac7a20eda0428f7c197c87cd466fcea
zbartl/flask
src/flask/scaffold.py
[ "BSD-3-Clause" ]
Python
_matching_loader_thinks_module_is_package
<not_specific>
def _matching_loader_thinks_module_is_package(loader, mod_name): """Attempt to figure out if the given name is a package or a module. :param: loader: The loader that handled the name. :param mod_name: The name of the package or module. """ # Use loader.is_package if it's available. if hasattr(l...
Attempt to figure out if the given name is a package or a module. :param: loader: The loader that handled the name. :param mod_name: The name of the package or module.
Attempt to figure out if the given name is a package or a module. :param: loader: The loader that handled the name. :param mod_name: The name of the package or module.
[ "Attempt", "to", "figure", "out", "if", "the", "given", "name", "is", "a", "package", "or", "a", "module", ".", ":", "param", ":", "loader", ":", "The", "loader", "that", "handled", "the", "name", ".", ":", "param", "mod_name", ":", "The", "name", "o...
def _matching_loader_thinks_module_is_package(loader, mod_name): if hasattr(loader, "is_package"): return loader.is_package(mod_name) cls = type(loader) if cls.__module__ == "_frozen_importlib" and cls.__name__ == "NamespaceLoader": return True raise AttributeError( f"'{cls.__nam...
[ "def", "_matching_loader_thinks_module_is_package", "(", "loader", ",", "mod_name", ")", ":", "if", "hasattr", "(", "loader", ",", "\"is_package\"", ")", ":", "return", "loader", ".", "is_package", "(", "mod_name", ")", "cls", "=", "type", "(", "loader", ")", ...
Attempt to figure out if the given name is a package or a module.
[ "Attempt", "to", "figure", "out", "if", "the", "given", "name", "is", "a", "package", "or", "a", "module", "." ]
[ "\"\"\"Attempt to figure out if the given name is a package or a module.\n\n :param: loader: The loader that handled the name.\n :param mod_name: The name of the package or module.\n \"\"\"", "# Use loader.is_package if it's available.", "# NamespaceLoader doesn't implement is_package, but all names it...
[ { "param": "loader", "type": null }, { "param": "mod_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "loader", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mod_name", "type": null, "docstring": null, "docstring_toke...
1cf007e20ac7a20eda0428f7c197c87cd466fcea
zbartl/flask
src/flask/scaffold.py
[ "BSD-3-Clause" ]
Python
_find_package_path
<not_specific>
def _find_package_path(root_mod_name): """Find the path that contains the package or module.""" try: spec = importlib.util.find_spec(root_mod_name) if spec is None: raise ValueError("not found") # ImportError: the machinery told us it does not exist # ValueError: # - ...
Find the path that contains the package or module.
Find the path that contains the package or module.
[ "Find", "the", "path", "that", "contains", "the", "package", "or", "module", "." ]
def _find_package_path(root_mod_name): try: spec = importlib.util.find_spec(root_mod_name) if spec is None: raise ValueError("not found") except (ImportError, ValueError): pass else: if spec.origin in {"namespace", None}: return os.path.dirname(next(...
[ "def", "_find_package_path", "(", "root_mod_name", ")", ":", "try", ":", "spec", "=", "importlib", ".", "util", ".", "find_spec", "(", "root_mod_name", ")", "if", "spec", "is", "None", ":", "raise", "ValueError", "(", "\"not found\"", ")", "except", "(", "...
Find the path that contains the package or module.
[ "Find", "the", "path", "that", "contains", "the", "package", "or", "module", "." ]
[ "\"\"\"Find the path that contains the package or module.\"\"\"", "# ImportError: the machinery told us it does not exist", "# ValueError:", "# - the module name was invalid", "# - the module name is __main__", "# - *we* raised `ValueError` due to `spec` being `None`", "# handled below", "# n...
[ { "param": "root_mod_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "root_mod_name", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1cf007e20ac7a20eda0428f7c197c87cd466fcea
zbartl/flask
src/flask/scaffold.py
[ "BSD-3-Clause" ]
Python
find_package
<not_specific>
def find_package(import_name: str): """Find the prefix that a package is installed under, and the path that it would be imported from. The prefix is the directory containing the standard directory hierarchy (lib, bin, etc.). If the package is not installed to the system (:attr:`sys.prefix`) or a vi...
Find the prefix that a package is installed under, and the path that it would be imported from. The prefix is the directory containing the standard directory hierarchy (lib, bin, etc.). If the package is not installed to the system (:attr:`sys.prefix`) or a virtualenv (``site-packages``), ``None`` ...
Find the prefix that a package is installed under, and the path that it would be imported from. The prefix is the directory containing the standard directory hierarchy (lib, bin, etc.). The path is the entry in :attr:`sys.path` that contains the package for import. If the package is not installed, it's assumed that t...
[ "Find", "the", "prefix", "that", "a", "package", "is", "installed", "under", "and", "the", "path", "that", "it", "would", "be", "imported", "from", ".", "The", "prefix", "is", "the", "directory", "containing", "the", "standard", "directory", "hierarchy", "("...
def find_package(import_name: str): root_mod_name, _, _ = import_name.partition(".") package_path = _find_package_path(root_mod_name) py_prefix = os.path.abspath(sys.prefix) if package_path.startswith(py_prefix): return py_prefix, package_path site_parent, site_folder = os.path.split(package...
[ "def", "find_package", "(", "import_name", ":", "str", ")", ":", "root_mod_name", ",", "_", ",", "_", "=", "import_name", ".", "partition", "(", "\".\"", ")", "package_path", "=", "_find_package_path", "(", "root_mod_name", ")", "py_prefix", "=", "os", ".", ...
Find the prefix that a package is installed under, and the path that it would be imported from.
[ "Find", "the", "prefix", "that", "a", "package", "is", "installed", "under", "and", "the", "path", "that", "it", "would", "be", "imported", "from", "." ]
[ "\"\"\"Find the prefix that a package is installed under, and the path\n that it would be imported from.\n\n The prefix is the directory containing the standard directory\n hierarchy (lib, bin, etc.). If the package is not installed to the\n system (:attr:`sys.prefix`) or a virtualenv (``site-packages``...
[ { "param": "import_name", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "import_name", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b423e6ae4a729f53c893a7a4705121d26b316d23
zbartl/flask
examples/tutorial/flaskr/auth.py
[ "BSD-3-Clause" ]
Python
register
<not_specific>
def register(): """Register a new user. Validates that the username is not already taken. Hashes the password for security. """ if request.method == "POST": username = request.form["username"] password = request.form["password"] db = get_db() error = None if...
Register a new user. Validates that the username is not already taken. Hashes the password for security.
Register a new user. Validates that the username is not already taken. Hashes the password for security.
[ "Register", "a", "new", "user", ".", "Validates", "that", "the", "username", "is", "not", "already", "taken", ".", "Hashes", "the", "password", "for", "security", "." ]
def register(): if request.method == "POST": username = request.form["username"] password = request.form["password"] db = get_db() error = None if not username: error = "Username is required." elif not password: error = "Password is required." ...
[ "def", "register", "(", ")", ":", "if", "request", ".", "method", "==", "\"POST\"", ":", "username", "=", "request", ".", "form", "[", "\"username\"", "]", "password", "=", "request", ".", "form", "[", "\"password\"", "]", "db", "=", "get_db", "(", ")"...
Register a new user.
[ "Register", "a", "new", "user", "." ]
[ "\"\"\"Register a new user.\n\n Validates that the username is not already taken. Hashes the\n password for security.\n \"\"\"", "# The username was already taken, which caused the", "# commit to fail. Show a validation error.", "# Success, go to the login page." ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
86dacfdfe7bc61d4e5dc5eaefda152a1c857c284
vincentBenet/casing
casing/casing.py
[ "MIT" ]
Python
detect
<not_specific>
def detect(var): """ Function that will detect the casing of the input variable. :param var: Variable to detect the casing :type var: :py:class:`str` :returns: **case**: (:py:class:`str`) - Names of avalaible cases of this module :Example: Import the module and run the function wi...
Function that will detect the casing of the input variable. :param var: Variable to detect the casing :type var: :py:class:`str` :returns: **case**: (:py:class:`str`) - Names of avalaible cases of this module :Example: Import the module and run the function with the variable to detec...
Function that will detect the casing of the input variable.
[ "Function", "that", "will", "detect", "the", "casing", "of", "the", "input", "variable", "." ]
def detect(var): var_list = analyze(var) for fct in getcases(): case = fct[:-len("case")] result = transform(var, case) if result == var: break else: case = "unknow" return case
[ "def", "detect", "(", "var", ")", ":", "var_list", "=", "analyze", "(", "var", ")", "for", "fct", "in", "getcases", "(", ")", ":", "case", "=", "fct", "[", ":", "-", "len", "(", "\"case\"", ")", "]", "result", "=", "transform", "(", "var", ",", ...
Function that will detect the casing of the input variable.
[ "Function", "that", "will", "detect", "the", "casing", "of", "the", "input", "variable", "." ]
[ "\"\"\"\n Function that will detect the casing of the input variable.\n \n :param var: Variable to detect the casing\n :type var: :py:class:`str`\n \n :returns: **case**: (:py:class:`str`) - Names of avalaible cases of this module\n \n :Example: Import the module and run the function with th...
[ { "param": "var", "type": null } ]
{ "returns": [ { "docstring": "case**: (:py:class:`str`) - Names of avalaible cases of this module", "docstring_tokens": [ "case", "**", ":", "(", ":", "py", ":", "class", ":", "`", "str", "`", ")",...
86dacfdfe7bc61d4e5dc5eaefda152a1c857c284
vincentBenet/casing
casing/casing.py
[ "MIT" ]
Python
analyze
<not_specific>
def analyze(var): """ Split the input `var` in each elements. :param str var: Variable to analyze :type var: :py:class:`str` :returns: **case**: (:py:class:`list`: **1-D list of string**) - Analyze input `var` splited in lowercase :Example: Import the module and run the function w...
Split the input `var` in each elements. :param str var: Variable to analyze :type var: :py:class:`str` :returns: **case**: (:py:class:`list`: **1-D list of string**) - Analyze input `var` splited in lowercase :Example: Import the module and run the function with the variable to analy...
Split the input `var` in each elements.
[ "Split", "the", "input", "`", "var", "`", "in", "each", "elements", "." ]
def analyze(var): var_list = [] buffer = "" for i, charact in enumerate(var): if charact in separators: var_list.append(buffer) buffer = "" elif charact in alphabet.upper(): if i > 0 and var[i - 1].isupper(): buffer += charact.lower() ...
[ "def", "analyze", "(", "var", ")", ":", "var_list", "=", "[", "]", "buffer", "=", "\"\"", "for", "i", ",", "charact", "in", "enumerate", "(", "var", ")", ":", "if", "charact", "in", "separators", ":", "var_list", ".", "append", "(", "buffer", ")", ...
Split the input `var` in each elements.
[ "Split", "the", "input", "`", "var", "`", "in", "each", "elements", "." ]
[ "\"\"\"\n Split the input `var` in each elements.\n \n :param str var: Variable to analyze\n :type var: :py:class:`str`\n \n :returns: **case**: (:py:class:`list`: **1-D list of string**) - Analyze input `var` splited in lowercase\n \n :Example: Import the module and run the function with th...
[ { "param": "var", "type": null } ]
{ "returns": [ { "docstring": "case**: (:py:class:`list`: **1-D list of string**) - Analyze input `var` splited in lowercase", "docstring_tokens": [ "case", "**", ":", "(", ":", "py", ":", "class", ":", "`", "list"...
86dacfdfe7bc61d4e5dc5eaefda152a1c857c284
vincentBenet/casing
casing/casing.py
[ "MIT" ]
Python
transform
<not_specific>
def transform(var, case="snake"): """ Transform the input into the indicated case. :param var: Variable to transform :param case: Case convention. Can be any available case. :type var: :py:class:`str` / :py:class:`list` :type case: :py:class:`str` :returns: **transformed**: (...
Transform the input into the indicated case. :param var: Variable to transform :param case: Case convention. Can be any available case. :type var: :py:class:`str` / :py:class:`list` :type case: :py:class:`str` :returns: **transformed**: (:py:class:`str`) - Transformed input `var...
Transform the input into the indicated case.
[ "Transform", "the", "input", "into", "the", "indicated", "case", "." ]
def transform(var, case="snake"): if case.endswith("case"): case = case[:-len("case")] for fct in getcases(): if "{0}case".format(case) == fct: function = globals()[fct] if type(var) is str: return function(analyze(var)) elif type(var) is list:...
[ "def", "transform", "(", "var", ",", "case", "=", "\"snake\"", ")", ":", "if", "case", ".", "endswith", "(", "\"case\"", ")", ":", "case", "=", "case", "[", ":", "-", "len", "(", "\"case\"", ")", "]", "for", "fct", "in", "getcases", "(", ")", ":"...
Transform the input into the indicated case.
[ "Transform", "the", "input", "into", "the", "indicated", "case", "." ]
[ "\"\"\"\n Transform the input into the indicated case.\n \n :param var: Variable to transform\n :param case: Case convention. Can be any available case. \n \n :type var: :py:class:`str` / :py:class:`list`\n :type case: :py:class:`str`\n \n :returns: **transformed**: (:py:class:`str`) - Tr...
[ { "param": "var", "type": null }, { "param": "case", "type": null } ]
{ "returns": [ { "docstring": "transformed**: (:py:class:`str`) - Transformed input `var` in `case` convention\ncode-block:: python\n:linenos.\n\nimport casing\nprint(casing.transform(\"stringToTransform\", \"snakeuppercase\"))\n>>> \"STRING_TO_TRANSFORM\"\nprint(casing.transform(['string', 'to', 'transform...
86dacfdfe7bc61d4e5dc5eaefda152a1c857c284
vincentBenet/casing
casing/casing.py
[ "MIT" ]
Python
snakeuppercase
<not_specific>
def snakeuppercase(var): # SOME_VARIABLE """ Snake uppercase convention. Include '_' between each element and transform in uppercase. :param var: Variable to transform :type var: :py:class:`list` :returns: **transformed**: (:py:class:`str`) - Transformed input in ``SNAKE_UPPERCASE`` conve...
Snake uppercase convention. Include '_' between each element and transform in uppercase. :param var: Variable to transform :type var: :py:class:`list` :returns: **transformed**: (:py:class:`str`) - Transformed input in ``SNAKE_UPPERCASE`` convention.
Snake uppercase convention. Include '_' between each element and transform in uppercase.
[ "Snake", "uppercase", "convention", ".", "Include", "'", "_", "'", "between", "each", "element", "and", "transform", "in", "uppercase", "." ]
def snakeuppercase(var): return "_".join(var).upper()
[ "def", "snakeuppercase", "(", "var", ")", ":", "return", "\"_\"", ".", "join", "(", "var", ")", ".", "upper", "(", ")" ]
Snake uppercase convention.
[ "Snake", "uppercase", "convention", "." ]
[ "# SOME_VARIABLE", "\"\"\"\n Snake uppercase convention. Include '_' between each element and transform in uppercase.\n \n :param var: Variable to transform\n :type var: :py:class:`list`\n \n :returns: **transformed**: (:py:class:`str`) - Transformed input in ``SNAKE_UPPERCASE`` convention.\n ...
[ { "param": "var", "type": null } ]
{ "returns": [ { "docstring": "transformed**: (:py:class:`str`) - Transformed input in ``SNAKE_UPPERCASE`` convention.", "docstring_tokens": [ "transformed", "**", ":", "(", ":", "py", ":", "class", ":", "`", "str"...
86dacfdfe7bc61d4e5dc5eaefda152a1c857c284
vincentBenet/casing
casing/casing.py
[ "MIT" ]
Python
dashuppercase
<not_specific>
def dashuppercase(var): # SOME-VARIABLE """ Dash uppercase convention. Include '-' between each element and transform in uppercase. :param var: Variable to transform :type var: :py:class:`list` :returns: **transformed**: (:py:class:`str`) - Transformed input in ``DASH-UPPERCASE`` conventi...
Dash uppercase convention. Include '-' between each element and transform in uppercase. :param var: Variable to transform :type var: :py:class:`list` :returns: **transformed**: (:py:class:`str`) - Transformed input in ``DASH-UPPERCASE`` convention.
Dash uppercase convention. Include '-' between each element and transform in uppercase.
[ "Dash", "uppercase", "convention", ".", "Include", "'", "-", "'", "between", "each", "element", "and", "transform", "in", "uppercase", "." ]
def dashuppercase(var): return "-".join(var).upper()
[ "def", "dashuppercase", "(", "var", ")", ":", "return", "\"-\"", ".", "join", "(", "var", ")", ".", "upper", "(", ")" ]
Dash uppercase convention.
[ "Dash", "uppercase", "convention", "." ]
[ "# SOME-VARIABLE", "\"\"\"\n Dash uppercase convention. Include '-' between each element and transform in uppercase.\n \n :param var: Variable to transform\n :type var: :py:class:`list`\n \n :returns: **transformed**: (:py:class:`str`) - Transformed input in ``DASH-UPPERCASE`` convention.\n \...
[ { "param": "var", "type": null } ]
{ "returns": [ { "docstring": "transformed**: (:py:class:`str`) - Transformed input in ``DASH-UPPERCASE`` convention.", "docstring_tokens": [ "transformed", "**", ":", "(", ":", "py", ":", "class", ":", "`", "str",...
86dacfdfe7bc61d4e5dc5eaefda152a1c857c284
vincentBenet/casing
casing/casing.py
[ "MIT" ]
Python
pascalcase
<not_specific>
def pascalcase(var): # SomeVariable """ Pascal case convention. Include an uppercase at every first element. :param var: Variable to transform :type var: :py:class:`list` :returns: **transformed**: (:py:class:`str`) - Transformed input in ``PascalCase`` convention. """ result = ""...
Pascal case convention. Include an uppercase at every first element. :param var: Variable to transform :type var: :py:class:`list` :returns: **transformed**: (:py:class:`str`) - Transformed input in ``PascalCase`` convention.
Pascal case convention. Include an uppercase at every first element.
[ "Pascal", "case", "convention", ".", "Include", "an", "uppercase", "at", "every", "first", "element", "." ]
def pascalcase(var): result = "" for element in var: element = list(element) element[0] = element[0].upper() result += "".join(element) return result
[ "def", "pascalcase", "(", "var", ")", ":", "result", "=", "\"\"", "for", "element", "in", "var", ":", "element", "=", "list", "(", "element", ")", "element", "[", "0", "]", "=", "element", "[", "0", "]", ".", "upper", "(", ")", "result", "+=", "\...
Pascal case convention.
[ "Pascal", "case", "convention", "." ]
[ "# SomeVariable", "\"\"\"\n Pascal case convention. Include an uppercase at every first element.\n \n :param var: Variable to transform\n :type var: :py:class:`list`\n \n :returns: **transformed**: (:py:class:`str`) - Transformed input in ``PascalCase`` convention.\n \"\"\"" ]
[ { "param": "var", "type": null } ]
{ "returns": [ { "docstring": "transformed**: (:py:class:`str`) - Transformed input in ``PascalCase`` convention.", "docstring_tokens": [ "transformed", "**", ":", "(", ":", "py", ":", "class", ":", "`", "str", ...
86dacfdfe7bc61d4e5dc5eaefda152a1c857c284
vincentBenet/casing
casing/casing.py
[ "MIT" ]
Python
camelcase
<not_specific>
def camelcase(var): # someVariable """ Camel case convention. Include an uppercase at every first element except the first. :param var: Variable to transform :type var: :py:class:`list` :returns: **transformed**: (:py:class:`str`) - Transformed input in ``camelCase`` convention. """ ...
Camel case convention. Include an uppercase at every first element except the first. :param var: Variable to transform :type var: :py:class:`list` :returns: **transformed**: (:py:class:`str`) - Transformed input in ``camelCase`` convention.
Camel case convention. Include an uppercase at every first element except the first.
[ "Camel", "case", "convention", ".", "Include", "an", "uppercase", "at", "every", "first", "element", "except", "the", "first", "." ]
def camelcase(var): result = "" for i, element in enumerate(var): element = list(element) if i > 0: element[0] = element[0].upper() result += "".join(element) return result
[ "def", "camelcase", "(", "var", ")", ":", "result", "=", "\"\"", "for", "i", ",", "element", "in", "enumerate", "(", "var", ")", ":", "element", "=", "list", "(", "element", ")", "if", "i", ">", "0", ":", "element", "[", "0", "]", "=", "element",...
Camel case convention.
[ "Camel", "case", "convention", "." ]
[ "# someVariable", "\"\"\"\n Camel case convention. Include an uppercase at every first element except the first.\n \n :param var: Variable to transform\n :type var: :py:class:`list`\n \n :returns: **transformed**: (:py:class:`str`) - Transformed input in ``camelCase`` convention.\n \"\"\"" ]
[ { "param": "var", "type": null } ]
{ "returns": [ { "docstring": "transformed**: (:py:class:`str`) - Transformed input in ``camelCase`` convention.", "docstring_tokens": [ "transformed", "**", ":", "(", ":", "py", ":", "class", ":", "`", "str", ...
86dacfdfe7bc61d4e5dc5eaefda152a1c857c284
vincentBenet/casing
casing/casing.py
[ "MIT" ]
Python
normalcase
<not_specific>
def normalcase(var): # some variable """ Normal case convention. Include space between each element. :param var: Variable to transform :type var: :py:class:`list` :returns: **transformed**: (:py:class:`str`) - Transformed input in ``normal case`` convention. """ return " ".join(va...
Normal case convention. Include space between each element. :param var: Variable to transform :type var: :py:class:`list` :returns: **transformed**: (:py:class:`str`) - Transformed input in ``normal case`` convention.
Normal case convention. Include space between each element.
[ "Normal", "case", "convention", ".", "Include", "space", "between", "each", "element", "." ]
def normalcase(var): return " ".join(var)
[ "def", "normalcase", "(", "var", ")", ":", "return", "\" \"", ".", "join", "(", "var", ")" ]
Normal case convention.
[ "Normal", "case", "convention", "." ]
[ "# some variable", "\"\"\"\n Normal case convention. Include space between each element.\n \n :param var: Variable to transform\n :type var: :py:class:`list`\n \n :returns: **transformed**: (:py:class:`str`) - Transformed input in ``normal case`` convention.\n \"\"\"" ]
[ { "param": "var", "type": null } ]
{ "returns": [ { "docstring": "transformed**: (:py:class:`str`) - Transformed input in ``normal case`` convention.", "docstring_tokens": [ "transformed", "**", ":", "(", ":", "py", ":", "class", ":", "`", "str", ...
86dacfdfe7bc61d4e5dc5eaefda152a1c857c284
vincentBenet/casing
casing/casing.py
[ "MIT" ]
Python
prettycase
<not_specific>
def prettycase(var): # Some Variable """ Pretty case convention. Include space between each element and uppercase the first letter of element. :param var: Variable to transform :type var: :py:class:`list` :returns: **transformed**: (:py:class:`str`) - Transformed input in ``Pretty Case`` ...
Pretty case convention. Include space between each element and uppercase the first letter of element. :param var: Variable to transform :type var: :py:class:`list` :returns: **transformed**: (:py:class:`str`) - Transformed input in ``Pretty Case`` convention.
Pretty case convention. Include space between each element and uppercase the first letter of element.
[ "Pretty", "case", "convention", ".", "Include", "space", "between", "each", "element", "and", "uppercase", "the", "first", "letter", "of", "element", "." ]
def prettycase(var): result = "" for i, element in enumerate(var): element = list(element) element[0] = element[0].upper() result += "".join(element) + " " return result[:-1]
[ "def", "prettycase", "(", "var", ")", ":", "result", "=", "\"\"", "for", "i", ",", "element", "in", "enumerate", "(", "var", ")", ":", "element", "=", "list", "(", "element", ")", "element", "[", "0", "]", "=", "element", "[", "0", "]", ".", "upp...
Pretty case convention.
[ "Pretty", "case", "convention", "." ]
[ "# Some Variable", "\"\"\"\n Pretty case convention. Include space between each element and uppercase the first letter of element.\n \n :param var: Variable to transform\n :type var: :py:class:`list`\n \n :returns: **transformed**: (:py:class:`str`) - Transformed input in ``Pretty Case`` convent...
[ { "param": "var", "type": null } ]
{ "returns": [ { "docstring": "transformed**: (:py:class:`str`) - Transformed input in ``Pretty Case`` convention.", "docstring_tokens": [ "transformed", "**", ":", "(", ":", "py", ":", "class", ":", "`", "str", ...
86dacfdfe7bc61d4e5dc5eaefda152a1c857c284
vincentBenet/casing
casing/casing.py
[ "MIT" ]
Python
sentencecase
<not_specific>
def sentencecase(var): # Some variable """ Sentence case convention. Include space between each element and uppercase the first letter of first element. :param var: Variable to transform :type var: :py:class:`list` :returns: **transformed**: (:py:class:`str`) - Transformed input in ``Sent...
Sentence case convention. Include space between each element and uppercase the first letter of first element. :param var: Variable to transform :type var: :py:class:`list` :returns: **transformed**: (:py:class:`str`) - Transformed input in ``Sentence case`` convention.
Sentence case convention. Include space between each element and uppercase the first letter of first element.
[ "Sentence", "case", "convention", ".", "Include", "space", "between", "each", "element", "and", "uppercase", "the", "first", "letter", "of", "first", "element", "." ]
def sentencecase(var): result = "" for i, element in enumerate(var): element = list(element) if i == 0: element[0] = element[0].upper() result += "".join(element) + " " return result[:-1]
[ "def", "sentencecase", "(", "var", ")", ":", "result", "=", "\"\"", "for", "i", ",", "element", "in", "enumerate", "(", "var", ")", ":", "element", "=", "list", "(", "element", ")", "if", "i", "==", "0", ":", "element", "[", "0", "]", "=", "eleme...
Sentence case convention.
[ "Sentence", "case", "convention", "." ]
[ "# Some variable", "\"\"\"\n Sentence case convention. Include space between each element and uppercase the first letter of first element.\n \n :param var: Variable to transform\n :type var: :py:class:`list`\n \n :returns: **transformed**: (:py:class:`str`) - Transformed input in ``Sentence case...
[ { "param": "var", "type": null } ]
{ "returns": [ { "docstring": "transformed**: (:py:class:`str`) - Transformed input in ``Sentence case`` convention.", "docstring_tokens": [ "transformed", "**", ":", "(", ":", "py", ":", "class", ":", "`", "str", ...
86dacfdfe7bc61d4e5dc5eaefda152a1c857c284
vincentBenet/casing
casing/casing.py
[ "MIT" ]
Python
normaluppercase
<not_specific>
def normaluppercase(var): # SOME VARIABLE """ Normal uppercase convention. Include space between each element and transform in uppercase. :param var: Variable to transform :type var: :py:class:`list` :returns: **transformed**: (:py:class:`str`) - Transformed input in ``NORMAL UPPERCASE`` ...
Normal uppercase convention. Include space between each element and transform in uppercase. :param var: Variable to transform :type var: :py:class:`list` :returns: **transformed**: (:py:class:`str`) - Transformed input in ``NORMAL UPPERCASE`` convention.
Normal uppercase convention. Include space between each element and transform in uppercase.
[ "Normal", "uppercase", "convention", ".", "Include", "space", "between", "each", "element", "and", "transform", "in", "uppercase", "." ]
def normaluppercase(var): return " ".join(var).upper()
[ "def", "normaluppercase", "(", "var", ")", ":", "return", "\" \"", ".", "join", "(", "var", ")", ".", "upper", "(", ")" ]
Normal uppercase convention.
[ "Normal", "uppercase", "convention", "." ]
[ "# SOME VARIABLE", "\"\"\"\n Normal uppercase convention. Include space between each element and transform in uppercase.\n \n :param var: Variable to transform\n :type var: :py:class:`list`\n \n :returns: **transformed**: (:py:class:`str`) - Transformed input in ``NORMAL UPPERCASE`` convention.\...
[ { "param": "var", "type": null } ]
{ "returns": [ { "docstring": "transformed**: (:py:class:`str`) - Transformed input in ``NORMAL UPPERCASE`` convention.", "docstring_tokens": [ "transformed", "**", ":", "(", ":", "py", ":", "class", ":", "`", "str...
86dacfdfe7bc61d4e5dc5eaefda152a1c857c284
vincentBenet/casing
casing/casing.py
[ "MIT" ]
Python
attachedcase
<not_specific>
def attachedcase(var): # samevariable """ Attached case convention. Join all elements together. :param var: Variable to transform :type var: :py:class:`list` :returns: **transformed**: (:py:class:`str`) - Transformed input in ``attachedcase`` convention. .. warning:: It will lost...
Attached case convention. Join all elements together. :param var: Variable to transform :type var: :py:class:`list` :returns: **transformed**: (:py:class:`str`) - Transformed input in ``attachedcase`` convention. .. warning:: It will lost the possibility to analyse or transform the o...
Attached case convention. Join all elements together.
[ "Attached", "case", "convention", ".", "Join", "all", "elements", "together", "." ]
def attachedcase(var): return "".join(var)
[ "def", "attachedcase", "(", "var", ")", ":", "return", "\"\"", ".", "join", "(", "var", ")" ]
Attached case convention.
[ "Attached", "case", "convention", "." ]
[ "# samevariable", "\"\"\"\n Attached case convention. Join all elements together.\n \n :param var: Variable to transform\n :type var: :py:class:`list`\n \n :returns: **transformed**: (:py:class:`str`) - Transformed input in ``attachedcase`` convention.\n \n .. warning:: It will lost the po...
[ { "param": "var", "type": null } ]
{ "returns": [ { "docstring": "transformed**: (:py:class:`str`) - Transformed input in ``attachedcase`` convention.\nwarning:: It will lost the possibility to analyse or transform the output.", "docstring_tokens": [ "transformed", "**", ":", "(", ":", "p...
86dacfdfe7bc61d4e5dc5eaefda152a1c857c284
vincentBenet/casing
casing/casing.py
[ "MIT" ]
Python
attacheduppercase
<not_specific>
def attacheduppercase(var): # SOMEVARIABLE """ Attached uppercase convention. Join all elements together and transform in uppercase. :param var: Variable to transform :type var: :py:class:`list` :returns: **transformed**: (:py:class:`str`) - Transformed input in ``ATTACHEDCASE`` conventio...
Attached uppercase convention. Join all elements together and transform in uppercase. :param var: Variable to transform :type var: :py:class:`list` :returns: **transformed**: (:py:class:`str`) - Transformed input in ``ATTACHEDCASE`` convention. .. warning:: It will lost the possibili...
Attached uppercase convention. Join all elements together and transform in uppercase.
[ "Attached", "uppercase", "convention", ".", "Join", "all", "elements", "together", "and", "transform", "in", "uppercase", "." ]
def attacheduppercase(var): return "".join(var).upper()
[ "def", "attacheduppercase", "(", "var", ")", ":", "return", "\"\"", ".", "join", "(", "var", ")", ".", "upper", "(", ")" ]
Attached uppercase convention.
[ "Attached", "uppercase", "convention", "." ]
[ "# SOMEVARIABLE", "\"\"\"\n Attached uppercase convention. Join all elements together and transform in uppercase.\n \n :param var: Variable to transform\n :type var: :py:class:`list`\n \n :returns: **transformed**: (:py:class:`str`) - Transformed input in ``ATTACHEDCASE`` convention.\n \n ...
[ { "param": "var", "type": null } ]
{ "returns": [ { "docstring": "transformed**: (:py:class:`str`) - Transformed input in ``ATTACHEDCASE`` convention.\nwarning:: It will lost the possibility to analyse or transform the output.", "docstring_tokens": [ "transformed", "**", ":", "(", ":", "p...
86dacfdfe7bc61d4e5dc5eaefda152a1c857c284
vincentBenet/casing
casing/casing.py
[ "MIT" ]
Python
reversedcase
<not_specific>
def reversedcase(var): # some Variable """ Reverse uppercase convention. Join all elements and uppercase first letter of alls except the first. :param var: Variable to transform :type var: :py:class:`list` :returns: **transformed**: (:py:class:`str`) - Transformed input in ``reverseCase``...
Reverse uppercase convention. Join all elements and uppercase first letter of alls except the first. :param var: Variable to transform :type var: :py:class:`list` :returns: **transformed**: (:py:class:`str`) - Transformed input in ``reverseCase`` convention. .. note:: Different from ...
Reverse uppercase convention. Join all elements and uppercase first letter of alls except the first.
[ "Reverse", "uppercase", "convention", ".", "Join", "all", "elements", "and", "uppercase", "first", "letter", "of", "alls", "except", "the", "first", "." ]
def reversedcase(var): result = list(prettycase(var)) result[0] = result[0].lower() return "".join(result)
[ "def", "reversedcase", "(", "var", ")", ":", "result", "=", "list", "(", "prettycase", "(", "var", ")", ")", "result", "[", "0", "]", "=", "result", "[", "0", "]", ".", "lower", "(", ")", "return", "\"\"", ".", "join", "(", "result", ")" ]
Reverse uppercase convention.
[ "Reverse", "uppercase", "convention", "." ]
[ "# some Variable", "\"\"\"\n Reverse uppercase convention. Join all elements and uppercase first letter of alls except the first.\n \n :param var: Variable to transform\n :type var: :py:class:`list`\n \n :returns: **transformed**: (:py:class:`str`) - Transformed input in ``reverseCase`` conventi...
[ { "param": "var", "type": null } ]
{ "returns": [ { "docstring": "transformed**: (:py:class:`str`) - Transformed input in ``reverseCase`` convention.\nnote:: Different from camelcase except on 2 or less elements input.", "docstring_tokens": [ "transformed", "**", ":", "(", ":", "py", ...
b7a818c195719ffd5cc53ff0fa137be77212548f
haoruisun/CS254FinalProject
p300_detector.py
[ "MIT" ]
Python
preprocess
<not_specific>
def preprocess(data_dict, ch_indices, fs, epoch_period=667): ''' This function loads the data struct and extracts machine learning features from raw dataset. Parameters ---------- data_dict : dict DESCRIPTION. The EEG data dictionary ch_indices : int list/array DESCRIPTION....
This function loads the data struct and extracts machine learning features from raw dataset. Parameters ---------- data_dict : dict DESCRIPTION. The EEG data dictionary ch_indices : int list/array DESCRIPTION. The list/array of the integer of desired channel fs : int ...
This function loads the data struct and extracts machine learning features from raw dataset. Parameters data_dict : dict DESCRIPTION. The EEG data dictionary ch_indices : int list/array DESCRIPTION. The list/array of the integer of desired channel fs : int DESCRIPTION. Sampling frequency in Hz epoch_period : int, opt...
[ "This", "function", "loads", "the", "data", "struct", "and", "extracts", "machine", "learning", "features", "from", "raw", "dataset", ".", "Parameters", "data_dict", ":", "dict", "DESCRIPTION", ".", "The", "EEG", "data", "dictionary", "ch_indices", ":", "int", ...
def preprocess(data_dict, ch_indices, fs, epoch_period=667): flashing = data_dict['Flashing'] types= data_dict['StimulusType'] event_time = np.where(np.diff([flashing])[0][0] > 0)[0] + 1 event_time = np.insert(event_time, 0, 0) label = types[:, event_time].flatten() epoch_len = round(epoch_pe...
[ "def", "preprocess", "(", "data_dict", ",", "ch_indices", ",", "fs", ",", "epoch_period", "=", "667", ")", ":", "flashing", "=", "data_dict", "[", "'Flashing'", "]", "types", "=", "data_dict", "[", "'StimulusType'", "]", "event_time", "=", "np", ".", "wher...
This function loads the data struct and extracts machine learning features from raw dataset.
[ "This", "function", "loads", "the", "data", "struct", "and", "extracts", "machine", "learning", "features", "from", "raw", "dataset", "." ]
[ "'''\n This function loads the data struct and extracts machine learning features\n from raw dataset. \n\n Parameters\n ----------\n data_dict : dict\n DESCRIPTION. The EEG data dictionary\n ch_indices : int list/array\n DESCRIPTION. The list/array of the integer of desired channel\n...
[ { "param": "data_dict", "type": null }, { "param": "ch_indices", "type": null }, { "param": "fs", "type": null }, { "param": "epoch_period", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "data_dict", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ch_indices", "type": null, "docstring": null, "docstring...
b7a818c195719ffd5cc53ff0fa137be77212548f
haoruisun/CS254FinalProject
p300_detector.py
[ "MIT" ]
Python
preprocess1
<not_specific>
def preprocess1(data_dict, ch_indices, fs, epoch_period=667): ''' This function loads the data struct and extracts machine learning features for EEGNet only from raw dataset. Parameters ---------- data_dict : dict DESCRIPTION. The EEG data dictionary ch_indices : int list/array ...
This function loads the data struct and extracts machine learning features for EEGNet only from raw dataset. Parameters ---------- data_dict : dict DESCRIPTION. The EEG data dictionary ch_indices : int list/array DESCRIPTION. The list/array of the integer of desired channel ...
This function loads the data struct and extracts machine learning features for EEGNet only from raw dataset. Parameters data_dict : dict DESCRIPTION. The EEG data dictionary ch_indices : int list/array DESCRIPTION. The list/array of the integer of desired channel fs : int DESCRIPTION. Sampling frequency in Hz epoch_p...
[ "This", "function", "loads", "the", "data", "struct", "and", "extracts", "machine", "learning", "features", "for", "EEGNet", "only", "from", "raw", "dataset", ".", "Parameters", "data_dict", ":", "dict", "DESCRIPTION", ".", "The", "EEG", "data", "dictionary", ...
def preprocess1(data_dict, ch_indices, fs, epoch_period=667): flashing = data_dict['Flashing'] types= data_dict['StimulusType'] event_time = np.where(np.diff([flashing])[0][0] > 0)[0] + 1 event_time = np.insert(event_time, 0, 0) label = types[:, event_time].flatten() epoch_len = round(epoch_peri...
[ "def", "preprocess1", "(", "data_dict", ",", "ch_indices", ",", "fs", ",", "epoch_period", "=", "667", ")", ":", "flashing", "=", "data_dict", "[", "'Flashing'", "]", "types", "=", "data_dict", "[", "'StimulusType'", "]", "event_time", "=", "np", ".", "whe...
This function loads the data struct and extracts machine learning features for EEGNet only from raw dataset.
[ "This", "function", "loads", "the", "data", "struct", "and", "extracts", "machine", "learning", "features", "for", "EEGNet", "only", "from", "raw", "dataset", "." ]
[ "'''\n This function loads the data struct and extracts machine learning features\n for EEGNet only from raw dataset. \n\n Parameters\n ----------\n data_dict : dict\n DESCRIPTION. The EEG data dictionary\n ch_indices : int list/array\n DESCRIPTION. The list/array of the integer of d...
[ { "param": "data_dict", "type": null }, { "param": "ch_indices", "type": null }, { "param": "fs", "type": null }, { "param": "epoch_period", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "data_dict", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ch_indices", "type": null, "docstring": null, "docstring...
b7a818c195719ffd5cc53ff0fa137be77212548f
haoruisun/CS254FinalProject
p300_detector.py
[ "MIT" ]
Python
plot_matrix
null
def plot_matrix(X, y, model, label): ''' This function takes trained model and testing data, and prints out its perfermance on the testing data. Parameters ---------- X : 2d array: sample x feature DESCRIPTION. Testing data y : 1d array DESCRIPTION. Testing labels model ...
This function takes trained model and testing data, and prints out its perfermance on the testing data. Parameters ---------- X : 2d array: sample x feature DESCRIPTION. Testing data y : 1d array DESCRIPTION. Testing labels model : ML object DESCRIPTION. Trained cla...
This function takes trained model and testing data, and prints out its perfermance on the testing data. Parameters X : 2d array: sample x feature DESCRIPTION. Testing data y : 1d array DESCRIPTION. Testing labels model : ML object DESCRIPTION. Trained classifer label : string DESCRIPTION. The label for confusion matr...
[ "This", "function", "takes", "trained", "model", "and", "testing", "data", "and", "prints", "out", "its", "perfermance", "on", "the", "testing", "data", ".", "Parameters", "X", ":", "2d", "array", ":", "sample", "x", "feature", "DESCRIPTION", ".", "Testing",...
def plot_matrix(X, y, model, label): print('Predict labels for tested dataset...') y_pred = model.predict(X) accuracy = accuracy_score(y, y_pred) print('Accuracy: ', accuracy) print('Plot the confusion matrix...') ConfusionMatrixDisplay.from_predictions(y, y_pred) plt.show() plt.text(4.3...
[ "def", "plot_matrix", "(", "X", ",", "y", ",", "model", ",", "label", ")", ":", "print", "(", "'Predict labels for tested dataset...'", ")", "y_pred", "=", "model", ".", "predict", "(", "X", ")", "accuracy", "=", "accuracy_score", "(", "y", ",", "y_pred", ...
This function takes trained model and testing data, and prints out its perfermance on the testing data.
[ "This", "function", "takes", "trained", "model", "and", "testing", "data", "and", "prints", "out", "its", "perfermance", "on", "the", "testing", "data", "." ]
[ "'''\n This function takes trained model and testing data, and prints out its\n perfermance on the testing data.\n\n Parameters\n ----------\n X : 2d array: sample x feature\n DESCRIPTION. Testing data\n y : 1d array\n DESCRIPTION. Testing labels\n model : ML object\n DESCR...
[ { "param": "X", "type": null }, { "param": "y", "type": null }, { "param": "model", "type": null }, { "param": "label", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "X", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": null, "docstring": null, "docstring_tokens": [], ...
b7a818c195719ffd5cc53ff0fa137be77212548f
haoruisun/CS254FinalProject
p300_detector.py
[ "MIT" ]
Python
log_reg
<not_specific>
def log_reg(X, y): ''' This function trains a logistic regression classifer on given data and evaluates its performance by plotting the confusion matrix. Parameters ---------- X : 2d array: sample x feature DESCRIPTION. Training data y : 1d array DESCRIPTION. Labels Re...
This function trains a logistic regression classifer on given data and evaluates its performance by plotting the confusion matrix. Parameters ---------- X : 2d array: sample x feature DESCRIPTION. Training data y : 1d array DESCRIPTION. Labels Returns ------- clf_...
This function trains a logistic regression classifer on given data and evaluates its performance by plotting the confusion matrix. Parameters X : 2d array: sample x feature DESCRIPTION. Training data y : 1d array DESCRIPTION. Labels Returns clf_lg : logistic regression object DESCRIPTION. The trained LG classifer
[ "This", "function", "trains", "a", "logistic", "regression", "classifer", "on", "given", "data", "and", "evaluates", "its", "performance", "by", "plotting", "the", "confusion", "matrix", ".", "Parameters", "X", ":", "2d", "array", ":", "sample", "x", "feature"...
def log_reg(X, y): X_train, X_test, y_train, y_test = train_test_split(scale(X), y) print('Train Logistic Regression model...') clf_lg = LogisticRegression(random_state=0).fit(X_train, y_train) print('Now the classifier has been trained.') label = 'LogReg_confusion_matrix' plot_matrix(X_test, y_...
[ "def", "log_reg", "(", "X", ",", "y", ")", ":", "X_train", ",", "X_test", ",", "y_train", ",", "y_test", "=", "train_test_split", "(", "scale", "(", "X", ")", ",", "y", ")", "print", "(", "'Train Logistic Regression model...'", ")", "clf_lg", "=", "Logis...
This function trains a logistic regression classifer on given data and evaluates its performance by plotting the confusion matrix.
[ "This", "function", "trains", "a", "logistic", "regression", "classifer", "on", "given", "data", "and", "evaluates", "its", "performance", "by", "plotting", "the", "confusion", "matrix", "." ]
[ "'''\n This function trains a logistic regression classifer on given data and \n evaluates its performance by plotting the confusion matrix.\n\n Parameters\n ----------\n X : 2d array: sample x feature\n DESCRIPTION. Training data\n y : 1d array\n DESCRIPTION. Labels\n\n Returns\n...
[ { "param": "X", "type": null }, { "param": "y", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "X", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": null, "docstring": null, "docstring_tokens": [], ...
b7a818c195719ffd5cc53ff0fa137be77212548f
haoruisun/CS254FinalProject
p300_detector.py
[ "MIT" ]
Python
svm
<not_specific>
def svm(X, y): ''' This function trains a SVM classifer on given data and evaluates its performance by plotting the confusion matrix. Parameters ---------- X : 2d array: sample x feature DESCRIPTION. Training data y : 1d array DESCRIPTION. Labels Returns ------...
This function trains a SVM classifer on given data and evaluates its performance by plotting the confusion matrix. Parameters ---------- X : 2d array: sample x feature DESCRIPTION. Training data y : 1d array DESCRIPTION. Labels Returns ------- clf_svm : SVM ob...
This function trains a SVM classifer on given data and evaluates its performance by plotting the confusion matrix. Parameters X : 2d array: sample x feature DESCRIPTION. Training data y : 1d array DESCRIPTION. Labels Returns clf_svm : SVM object DESCRIPTION. The trained SVM classifer
[ "This", "function", "trains", "a", "SVM", "classifer", "on", "given", "data", "and", "evaluates", "its", "performance", "by", "plotting", "the", "confusion", "matrix", ".", "Parameters", "X", ":", "2d", "array", ":", "sample", "x", "feature", "DESCRIPTION", ...
def svm(X, y): X_train, X_test, y_train, y_test = train_test_split(X, y) X_train_scaled = scale(X_train) X_test_scaled = scale(X_test) print('Optimize parameters with cross validation...') param_grid = [ {'C': [0.001, 0.01, 0.05, 0.1, 0.5, 1, 10, 100], 'kernel': ['rbf']} ] ...
[ "def", "svm", "(", "X", ",", "y", ")", ":", "X_train", ",", "X_test", ",", "y_train", ",", "y_test", "=", "train_test_split", "(", "X", ",", "y", ")", "X_train_scaled", "=", "scale", "(", "X_train", ")", "X_test_scaled", "=", "scale", "(", "X_test", ...
This function trains a SVM classifer on given data and evaluates its performance by plotting the confusion matrix.
[ "This", "function", "trains", "a", "SVM", "classifer", "on", "given", "data", "and", "evaluates", "its", "performance", "by", "plotting", "the", "confusion", "matrix", "." ]
[ "'''\n This function trains a SVM classifer on given data and evaluates its \n performance by plotting the confusion matrix.\n \n Parameters\n ----------\n X : 2d array: sample x feature\n DESCRIPTION. Training data\n y : 1d array\n DESCRIPTION. Labels\n\n Returns\n -------\...
[ { "param": "X", "type": null }, { "param": "y", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "X", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": null, "docstring": null, "docstring_tokens": [], ...
b7a818c195719ffd5cc53ff0fa137be77212548f
haoruisun/CS254FinalProject
p300_detector.py
[ "MIT" ]
Python
dnn
<not_specific>
def dnn(X, y, optimizer=optimizers.Adam(learning_rate=0.001), loss='mse'): ''' This function trains a neural network on given data. Parameters ---------- X : 2d array: sample x feature DESCRIPTION. Training data y : 1d array DESCRIPTION. Labels optimizer : optimizer object, ...
This function trains a neural network on given data. Parameters ---------- X : 2d array: sample x feature DESCRIPTION. Training data y : 1d array DESCRIPTION. Labels optimizer : optimizer object, optional DESCRIPTION. The optimizer for neural network The default...
This function trains a neural network on given data. Parameters X : 2d array: sample x feature DESCRIPTION. Training data y : 1d array DESCRIPTION. Labels optimizer : optimizer object, optional DESCRIPTION. The optimizer for neural network The default is optimizers.Adam(). loss : string, optional DESCRIPTION. The loss...
[ "This", "function", "trains", "a", "neural", "network", "on", "given", "data", ".", "Parameters", "X", ":", "2d", "array", ":", "sample", "x", "feature", "DESCRIPTION", ".", "Training", "data", "y", ":", "1d", "array", "DESCRIPTION", ".", "Labels", "optimi...
def dnn(X, y, optimizer=optimizers.Adam(learning_rate=0.001), loss='mse'): X_train, X_test, y_train, y_test = train_test_split(X, y) layers = [ Flatten(), Dense(70, activation='relu', kernel_regularizer=keras.regularizers.l1(l=0.01)), Dense(10, activation='relu'), ...
[ "def", "dnn", "(", "X", ",", "y", ",", "optimizer", "=", "optimizers", ".", "Adam", "(", "learning_rate", "=", "0.001", ")", ",", "loss", "=", "'mse'", ")", ":", "X_train", ",", "X_test", ",", "y_train", ",", "y_test", "=", "train_test_split", "(", "...
This function trains a neural network on given data.
[ "This", "function", "trains", "a", "neural", "network", "on", "given", "data", "." ]
[ "'''\n This function trains a neural network on given data.\n\n Parameters\n ----------\n X : 2d array: sample x feature\n DESCRIPTION. Training data\n y : 1d array\n DESCRIPTION. Labels\n optimizer : optimizer object, optional\n DESCRIPTION. The optimizer for neural network\n...
[ { "param": "X", "type": null }, { "param": "y", "type": null }, { "param": "optimizer", "type": null }, { "param": "loss", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "X", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": null, "docstring": null, "docstring_tokens": [], ...
1a50ecbb6b418a94ce32afde29696d109941f724
delimitry/ascii_clock
clock.py
[ "MIT" ]
Python
draw_clock_face
null
def draw_clock_face(ascii_canvas, radius, mark_char): """ Draw clock face with hour and minute marks """ x0 = ascii_canvas.cols // 2 y0 = ascii_canvas.lines // 2 # draw marks first for mark in range(1, 12 * 5 + 1): x1 = x0 + int(math.cos((mark + 45) * 6 * math.pi / 180) * radius * x_...
Draw clock face with hour and minute marks
Draw clock face with hour and minute marks
[ "Draw", "clock", "face", "with", "hour", "and", "minute", "marks" ]
def draw_clock_face(ascii_canvas, radius, mark_char): x0 = ascii_canvas.cols // 2 y0 = ascii_canvas.lines // 2 for mark in range(1, 12 * 5 + 1): x1 = x0 + int(math.cos((mark + 45) * 6 * math.pi / 180) * radius * x_scale_ratio) y1 = y0 + int(math.sin((mark + 45) * 6 * math.pi / 180) * radius)...
[ "def", "draw_clock_face", "(", "ascii_canvas", ",", "radius", ",", "mark_char", ")", ":", "x0", "=", "ascii_canvas", ".", "cols", "//", "2", "y0", "=", "ascii_canvas", ".", "lines", "//", "2", "for", "mark", "in", "range", "(", "1", ",", "12", "*", "...
Draw clock face with hour and minute marks
[ "Draw", "clock", "face", "with", "hour", "and", "minute", "marks" ]
[ "\"\"\"\n Draw clock face with hour and minute marks\n \"\"\"", "# draw marks first", "# start from 1 because at 0 index - 12 hour" ]
[ { "param": "ascii_canvas", "type": null }, { "param": "radius", "type": null }, { "param": "mark_char", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ascii_canvas", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "radius", "type": null, "docstring": null, "docstring_...
050a68a45aac9fec1f59ce9a83d603bf63b6e051
smoothnlp/DomainWords
getDomainWords.py
[ "MIT" ]
Python
eachFile
<not_specific>
def eachFile(filepath): '''get all files in file path''' pathDir = [file for file in os.listdir(filepath) if not file.startswith('.')] ## 忽略隐藏文件 all_files = [] for allDir in pathDir: all_files.append(os.path.join('%s%s' % (filepath, allDir))) return all_files
get all files in file path
get all files in file path
[ "get", "all", "files", "in", "file", "path" ]
def eachFile(filepath): pathDir = [file for file in os.listdir(filepath) if not file.startswith('.')] all_files = [] for allDir in pathDir: all_files.append(os.path.join('%s%s' % (filepath, allDir))) return all_files
[ "def", "eachFile", "(", "filepath", ")", ":", "pathDir", "=", "[", "file", "for", "file", "in", "os", ".", "listdir", "(", "filepath", ")", "if", "not", "file", ".", "startswith", "(", "'.'", ")", "]", "all_files", "=", "[", "]", "for", "allDir", "...
get all files in file path
[ "get", "all", "files", "in", "file", "path" ]
[ "'''get all files in file path'''", "## 忽略隐藏文件\r" ]
[ { "param": "filepath", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "filepath", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2904815b06db15c24543cd6e7aeb0fa403897b3d
A-Jacobson/shiba
shiba/metrics.py
[ "MIT" ]
Python
f1
<not_specific>
def f1(prediction, target): """ prediction: thresholded prediction (zeros or ones) """ EPS = 1e-10 intersection = (prediction * target).sum().float() union = (prediction.sum() + target.sum()).float() return (2 * (intersection + EPS) / (union + 2 * EPS)).item()
prediction: thresholded prediction (zeros or ones)
thresholded prediction (zeros or ones)
[ "thresholded", "prediction", "(", "zeros", "or", "ones", ")" ]
def f1(prediction, target): EPS = 1e-10 intersection = (prediction * target).sum().float() union = (prediction.sum() + target.sum()).float() return (2 * (intersection + EPS) / (union + 2 * EPS)).item()
[ "def", "f1", "(", "prediction", ",", "target", ")", ":", "EPS", "=", "1e-10", "intersection", "=", "(", "prediction", "*", "target", ")", ".", "sum", "(", ")", ".", "float", "(", ")", "union", "=", "(", "prediction", ".", "sum", "(", ")", "+", "t...
prediction: thresholded prediction (zeros or ones)
[ "prediction", ":", "thresholded", "prediction", "(", "zeros", "or", "ones", ")" ]
[ "\"\"\"\n prediction: thresholded prediction (zeros or ones)\n \"\"\"" ]
[ { "param": "prediction", "type": null }, { "param": "target", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "prediction", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "target", "type": null, "docstring": null, "docstring_to...
d64cba36aa2b918cc3425367ef5675d75e6526ef
A-Jacobson/shiba
shiba/trainer.py
[ "MIT" ]
Python
backward
null
def backward(self): """backward pass, optionally with apex loss scaling""" if self.use_apex: try: from apex import amp with amp.scale_loss(self.out['loss'], self.optimizer) as scaled_loss: scaled_loss.backward() except ImportErr...
backward pass, optionally with apex loss scaling
backward pass, optionally with apex loss scaling
[ "backward", "pass", "optionally", "with", "apex", "loss", "scaling" ]
def backward(self): if self.use_apex: try: from apex import amp with amp.scale_loss(self.out['loss'], self.optimizer) as scaled_loss: scaled_loss.backward() except ImportError: pass else: self.out['lo...
[ "def", "backward", "(", "self", ")", ":", "if", "self", ".", "use_apex", ":", "try", ":", "from", "apex", "import", "amp", "with", "amp", ".", "scale_loss", "(", "self", ".", "out", "[", "'loss'", "]", ",", "self", ".", "optimizer", ")", "as", "sca...
backward pass, optionally with apex loss scaling
[ "backward", "pass", "optionally", "with", "apex", "loss", "scaling" ]
[ "\"\"\"backward pass, optionally with apex loss scaling\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3ae3cf4e404ba8726f65c58b1454b1f9f69931aa
A-Jacobson/shiba
shiba/schedulers.py
[ "MIT" ]
Python
compute_lr
<not_specific>
def compute_lr(self): """ Compute the learning rate based on which phase of the cycle it is in. - If in the first half of training, the learning rate gradually increases. - If in the second half of training, the learning rate gradually decreases. - If in the final `end_percentage...
Compute the learning rate based on which phase of the cycle it is in. - If in the first half of training, the learning rate gradually increases. - If in the second half of training, the learning rate gradually decreases. - If in the final `end_percentage` portion of training, the learni...
Compute the learning rate based on which phase of the cycle it is in. If in the first half of training, the learning rate gradually increases. If in the second half of training, the learning rate gradually decreases. If in the final `end_percentage` portion of training, the learning rate is quickly reduced to near 100t...
[ "Compute", "the", "learning", "rate", "based", "on", "which", "phase", "of", "the", "cycle", "it", "is", "in", ".", "If", "in", "the", "first", "half", "of", "training", "the", "learning", "rate", "gradually", "increases", ".", "If", "in", "the", "second...
def compute_lr(self): if self.clr_iterations > 2 * self.mid_cycle_id: current_percentage = (self.clr_iterations - 2 * self.mid_cycle_id) current_percentage /= float((self.num_iterations - 2 * self.mid_cycle_id)) new_lr = self.initial_lr * (1. + (current_percentage * ...
[ "def", "compute_lr", "(", "self", ")", ":", "if", "self", ".", "clr_iterations", ">", "2", "*", "self", ".", "mid_cycle_id", ":", "current_percentage", "=", "(", "self", ".", "clr_iterations", "-", "2", "*", "self", ".", "mid_cycle_id", ")", "current_perce...
Compute the learning rate based on which phase of the cycle it is in.
[ "Compute", "the", "learning", "rate", "based", "on", "which", "phase", "of", "the", "cycle", "it", "is", "in", "." ]
[ "\"\"\"\n Compute the learning rate based on which phase of the cycle it is in.\n - If in the first half of training, the learning rate gradually increases.\n - If in the second half of training, the learning rate gradually decreases.\n - If in the final `end_percentage` portion of train...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3ae3cf4e404ba8726f65c58b1454b1f9f69931aa
A-Jacobson/shiba
shiba/schedulers.py
[ "MIT" ]
Python
compute_momentum
<not_specific>
def compute_momentum(self): """ Compute the momentum based on which phase of the cycle it is in. - If in the first half of training, the momentum gradually decreases. - If in the second half of training, the momentum gradually increases. - If in the final `end_percentage` portio...
Compute the momentum based on which phase of the cycle it is in. - If in the first half of training, the momentum gradually decreases. - If in the second half of training, the momentum gradually increases. - If in the final `end_percentage` portion of training, the momentum value ...
Compute the momentum based on which phase of the cycle it is in. If in the first half of training, the momentum gradually decreases. If in the second half of training, the momentum gradually increases. If in the final `end_percentage` portion of training, the momentum value is kept constant at the maximum initial value...
[ "Compute", "the", "momentum", "based", "on", "which", "phase", "of", "the", "cycle", "it", "is", "in", ".", "If", "in", "the", "first", "half", "of", "training", "the", "momentum", "gradually", "decreases", ".", "If", "in", "the", "second", "half", "of",...
def compute_momentum(self): if self.clr_iterations > 2 * self.mid_cycle_id: new_momentum = self.max_momentum elif self.clr_iterations > self.mid_cycle_id: current_percentage = 1. - ((self.clr_iterations - self.mid_cycle_id) / float( self.mid_cycle_id)) ...
[ "def", "compute_momentum", "(", "self", ")", ":", "if", "self", ".", "clr_iterations", ">", "2", "*", "self", ".", "mid_cycle_id", ":", "new_momentum", "=", "self", ".", "max_momentum", "elif", "self", ".", "clr_iterations", ">", "self", ".", "mid_cycle_id",...
Compute the momentum based on which phase of the cycle it is in.
[ "Compute", "the", "momentum", "based", "on", "which", "phase", "of", "the", "cycle", "it", "is", "in", "." ]
[ "\"\"\"\n Compute the momentum based on which phase of the cycle it is in.\n - If in the first half of training, the momentum gradually decreases.\n - If in the second half of training, the momentum gradually increases.\n - If in the final `end_percentage` portion of training, the momen...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d0153c2b10a0354a0cedd424aabe9049353e6dc8
A-Jacobson/shiba
shiba/utils.py
[ "MIT" ]
Python
update
null
def update(self, predicted, target): """Computes the confusion matrix of K x K size where K is no of classes Args: predicted (tensor): Can be an N x K tensor of predicted scores obtained from the model for N examples and K classes or an N-tensor of integer val...
Computes the confusion matrix of K x K size where K is no of classes Args: predicted (tensor): Can be an N x K tensor of predicted scores obtained from the model for N examples and K classes or an N-tensor of integer values between 0 and K-1. target (tenso...
Computes the confusion matrix of K x K size where K is no of classes
[ "Computes", "the", "confusion", "matrix", "of", "K", "x", "K", "size", "where", "K", "is", "no", "of", "classes" ]
def update(self, predicted, target): predicted = predicted.detach().cpu().numpy() target = target.detach().cpu().numpy() assert predicted.shape[0] == target.shape[0], \ 'number of targets and predicted outputs do not match' if np.ndim(predicted) != 1: assert predi...
[ "def", "update", "(", "self", ",", "predicted", ",", "target", ")", ":", "predicted", "=", "predicted", ".", "detach", "(", ")", ".", "cpu", "(", ")", ".", "numpy", "(", ")", "target", "=", "target", ".", "detach", "(", ")", ".", "cpu", "(", ")",...
Computes the confusion matrix of K x K size where K is no of classes
[ "Computes", "the", "confusion", "matrix", "of", "K", "x", "K", "size", "where", "K", "is", "no", "of", "classes" ]
[ "\"\"\"Computes the confusion matrix of K x K size where K is no of classes\n Args:\n predicted (tensor): Can be an N x K tensor of predicted scores obtained from\n the model for N examples and K classes or an N-tensor of\n integer values between 0 and K-1.\n ...
[ { "param": "self", "type": null }, { "param": "predicted", "type": null }, { "param": "target", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "predicted", "type": null, "docstring": "Can be an N x K tensor of p...
73f9f98256c98dfef062b164f570e0ff1ad72ebb
ohad182/GitReport
providers/gerrit/client.py
[ "MIT" ]
Python
changes
<not_specific>
def changes(self, email): """ performs a gerrit changes query for the configured owner email :param email: the owner email :return: a list of ChangeInfo objects that describes the changes this owner has """ # suffix = "/changes/?q=owner:\"{}\"&o=MESSAGES".format(email) # ...
performs a gerrit changes query for the configured owner email :param email: the owner email :return: a list of ChangeInfo objects that describes the changes this owner has
performs a gerrit changes query for the configured owner email
[ "performs", "a", "gerrit", "changes", "query", "for", "the", "configured", "owner", "email" ]
def changes(self, email): suffix = "/changes/?q=owner:\"{}\"&o=ALL_REVISIONS&o=COMMIT_FOOTERS".format(email) data = self._get(url="{}{}".format(self.url, suffix)) result = [] if data is not None: for item in data: result.append(ChangeInfo(**item)) retu...
[ "def", "changes", "(", "self", ",", "email", ")", ":", "suffix", "=", "\"/changes/?q=owner:\\\"{}\\\"&o=ALL_REVISIONS&o=COMMIT_FOOTERS\"", ".", "format", "(", "email", ")", "data", "=", "self", ".", "_get", "(", "url", "=", "\"{}{}\"", ".", "format", "(", "sel...
performs a gerrit changes query for the configured owner email
[ "performs", "a", "gerrit", "changes", "query", "for", "the", "configured", "owner", "email" ]
[ "\"\"\"\n performs a gerrit changes query for the configured owner email\n :param email: the owner email\n :return: a list of ChangeInfo objects that describes the changes this owner has\n \"\"\"", "# suffix = \"/changes/?q=owner:\\\"{}\\\"&o=MESSAGES\".format(email) # gets the message...
[ { "param": "self", "type": null }, { "param": "email", "type": null } ]
{ "returns": [ { "docstring": "a list of ChangeInfo objects that describes the changes this owner has", "docstring_tokens": [ "a", "list", "of", "ChangeInfo", "objects", "that", "describes", "the", "changes", "this", ...
a9a8e79e257ed31cf0f0f2649e4111928faaa924
PydraxAlpta/HowLongToBeat-PythonAPI
howlongtobeatpy/howlongtobeatpy/HowLongToBeat.py
[ "MIT" ]
Python
async_search
<not_specific>
async def async_search(self, game_name: str, search_modifiers: SearchModifiers = SearchModifiers.NONE, similarity_case_sensitive: bool = True): """ Function that search the game using an async request @param game_name: The original game name received as input @...
Function that search the game using an async request @param game_name: The original game name received as input @param search_modifiers: The "Modifiers" list in "Search Options", allow to show/isolate/hide DLCs @param similarity_case_sensitive: If the similarity check between names shou...
Function that search the game using an async request
[ "Function", "that", "search", "the", "game", "using", "an", "async", "request" ]
async def async_search(self, game_name: str, search_modifiers: SearchModifiers = SearchModifiers.NONE, similarity_case_sensitive: bool = True): if game_name is None or len(game_name) == 0: return None html_result = await HTMLRequests.send_async_web_request(game_nam...
[ "async", "def", "async_search", "(", "self", ",", "game_name", ":", "str", ",", "search_modifiers", ":", "SearchModifiers", "=", "SearchModifiers", ".", "NONE", ",", "similarity_case_sensitive", ":", "bool", "=", "True", ")", ":", "if", "game_name", "is", "Non...
Function that search the game using an async request
[ "Function", "that", "search", "the", "game", "using", "an", "async", "request" ]
[ "\"\"\"\n Function that search the game using an async request\n @param game_name: The original game name received as input\n @param search_modifiers: The \"Modifiers\" list in \"Search Options\", allow to show/isolate/hide DLCs\n @param similarity_case_sensitive: If the similarity check...
[ { "param": "self", "type": null }, { "param": "game_name", "type": "str" }, { "param": "search_modifiers", "type": "SearchModifiers" }, { "param": "similarity_case_sensitive", "type": "bool" } ]
{ "returns": [ { "docstring": "A list of possible games (or None in case of wrong parameter or failed request)", "docstring_tokens": [ "A", "list", "of", "possible", "games", "(", "or", "None", "in", "case", "of", ...
a9a8e79e257ed31cf0f0f2649e4111928faaa924
PydraxAlpta/HowLongToBeat-PythonAPI
howlongtobeatpy/howlongtobeatpy/HowLongToBeat.py
[ "MIT" ]
Python
search
<not_specific>
def search(self, game_name: str, search_modifiers: SearchModifiers = SearchModifiers.NONE, similarity_case_sensitive: bool = True): """ Function that search the game using a normal request @param game_name: The original game name received as input @param search_modifiers: ...
Function that search the game using a normal request @param game_name: The original game name received as input @param search_modifiers: The "Modifiers" list in "Search Options", allow to show/isolate/hide DLCs @param similarity_case_sensitive: If the similarity check between names shou...
Function that search the game using a normal request
[ "Function", "that", "search", "the", "game", "using", "a", "normal", "request" ]
def search(self, game_name: str, search_modifiers: SearchModifiers = SearchModifiers.NONE, similarity_case_sensitive: bool = True): if game_name is None or len(game_name) == 0: return None html_result = HTMLRequests.send_web_request(game_name, search_modifiers) if html...
[ "def", "search", "(", "self", ",", "game_name", ":", "str", ",", "search_modifiers", ":", "SearchModifiers", "=", "SearchModifiers", ".", "NONE", ",", "similarity_case_sensitive", ":", "bool", "=", "True", ")", ":", "if", "game_name", "is", "None", "or", "le...
Function that search the game using a normal request
[ "Function", "that", "search", "the", "game", "using", "a", "normal", "request" ]
[ "\"\"\"\n Function that search the game using a normal request\n @param game_name: The original game name received as input\n @param search_modifiers: The \"Modifiers\" list in \"Search Options\", allow to show/isolate/hide DLCs\n @param similarity_case_sensitive: If the similarity check...
[ { "param": "self", "type": null }, { "param": "game_name", "type": "str" }, { "param": "search_modifiers", "type": "SearchModifiers" }, { "param": "similarity_case_sensitive", "type": "bool" } ]
{ "returns": [ { "docstring": "A list of possible games (or None in case of wrong parameter or failed request)", "docstring_tokens": [ "A", "list", "of", "possible", "games", "(", "or", "None", "in", "case", "of", ...
a9a8e79e257ed31cf0f0f2649e4111928faaa924
PydraxAlpta/HowLongToBeat-PythonAPI
howlongtobeatpy/howlongtobeatpy/HowLongToBeat.py
[ "MIT" ]
Python
async_search_from_id
<not_specific>
async def async_search_from_id(self, game_id: int): """ Function that search the game using an async request To re-use code, i extract the game name and search game by name, picking only the game with the same id Otherwise a new parser is necessary, and is probably not worth to maintain ...
Function that search the game using an async request To re-use code, i extract the game name and search game by name, picking only the game with the same id Otherwise a new parser is necessary, and is probably not worth to maintain 2 different html parsers Remember that this function us...
Function that search the game using an async request To re-use code, i extract the game name and search game by name, picking only the game with the same id Otherwise a new parser is necessary, and is probably not worth to maintain 2 different html parsers Remember that this function use 2 requests: one to get the game...
[ "Function", "that", "search", "the", "game", "using", "an", "async", "request", "To", "re", "-", "use", "code", "i", "extract", "the", "game", "name", "and", "search", "game", "by", "name", "picking", "only", "the", "game", "with", "the", "same", "id", ...
async def async_search_from_id(self, game_id: int): if game_id is None or game_id == 0: return None game_title = await HTMLRequests.async_get_game_title(game_id) if game_title is not None: html_result = await HTMLRequests.send_async_web_request(game_title) if ...
[ "async", "def", "async_search_from_id", "(", "self", ",", "game_id", ":", "int", ")", ":", "if", "game_id", "is", "None", "or", "game_id", "==", "0", ":", "return", "None", "game_title", "=", "await", "HTMLRequests", ".", "async_get_game_title", "(", "game_i...
Function that search the game using an async request To re-use code, i extract the game name and search game by name, picking only the game with the same id Otherwise a new parser is necessary, and is probably not worth to maintain 2 different html parsers Remember that this function use 2 requests: one to get the game...
[ "Function", "that", "search", "the", "game", "using", "an", "async", "request", "To", "re", "-", "use", "code", "i", "extract", "the", "game", "name", "and", "search", "game", "by", "name", "picking", "only", "the", "game", "with", "the", "same", "id", ...
[ "\"\"\"\n Function that search the game using an async request\n To re-use code, i extract the game name and search game by name, picking only the game with the same id\n Otherwise a new parser is necessary, and is probably not worth to maintain 2 different html parsers\n Remember that t...
[ { "param": "self", "type": null }, { "param": "game_id", "type": "int" } ]
{ "returns": [ { "docstring": "The game data (single HowLongToBeatEntry object) or None in case of error", "docstring_tokens": [ "The", "game", "data", "(", "single", "HowLongToBeatEntry", "object", ")", "or", "None", ...