partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
Library.tdSensorValue
Get the sensor value for a given sensor. :return: a dict with the keys: value, timestamp.
tellcore/library.py
def tdSensorValue(self, protocol, model, sid, datatype): """Get the sensor value for a given sensor. :return: a dict with the keys: value, timestamp. """ value = create_string_buffer(20) timestamp = c_int() self._lib.tdSensorValue(protocol, model, sid, datatype, ...
def tdSensorValue(self, protocol, model, sid, datatype): """Get the sensor value for a given sensor. :return: a dict with the keys: value, timestamp. """ value = create_string_buffer(20) timestamp = c_int() self._lib.tdSensorValue(protocol, model, sid, datatype, ...
[ "Get", "the", "sensor", "value", "for", "a", "given", "sensor", "." ]
erijo/tellcore-py
python
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/library.py#L425-L435
[ "def", "tdSensorValue", "(", "self", ",", "protocol", ",", "model", ",", "sid", ",", "datatype", ")", ":", "value", "=", "create_string_buffer", "(", "20", ")", "timestamp", "=", "c_int", "(", ")", "self", ".", "_lib", ".", "tdSensorValue", "(", "protoco...
7a1eb53e12ef039a2350933e502633df7560f6a8
train
Library.tdController
Get the next controller while iterating. :return: a dict with the keys: id, type, name, available.
tellcore/library.py
def tdController(self): """Get the next controller while iterating. :return: a dict with the keys: id, type, name, available. """ cid = c_int() ctype = c_int() name = create_string_buffer(255) available = c_int() self._lib.tdController(byref(cid), byref(...
def tdController(self): """Get the next controller while iterating. :return: a dict with the keys: id, type, name, available. """ cid = c_int() ctype = c_int() name = create_string_buffer(255) available = c_int() self._lib.tdController(byref(cid), byref(...
[ "Get", "the", "next", "controller", "while", "iterating", "." ]
erijo/tellcore-py
python
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/library.py#L437-L450
[ "def", "tdController", "(", "self", ")", ":", "cid", "=", "c_int", "(", ")", "ctype", "=", "c_int", "(", ")", "name", "=", "create_string_buffer", "(", "255", ")", "available", "=", "c_int", "(", ")", "self", ".", "_lib", ".", "tdController", "(", "b...
7a1eb53e12ef039a2350933e502633df7560f6a8
train
make_passwordmanager
schemes contains a list of replace this list with the hash(es) you wish to support. this example sets pbkdf2_sha256 as the default, with support for legacy bcrypt hashes. :param schemes: :return: CryptContext()
ziggurat_foundations/__init__.py
def make_passwordmanager(schemes=None): """ schemes contains a list of replace this list with the hash(es) you wish to support. this example sets pbkdf2_sha256 as the default, with support for legacy bcrypt hashes. :param schemes: :return: CryptContext() """ from passlib.context imp...
def make_passwordmanager(schemes=None): """ schemes contains a list of replace this list with the hash(es) you wish to support. this example sets pbkdf2_sha256 as the default, with support for legacy bcrypt hashes. :param schemes: :return: CryptContext() """ from passlib.context imp...
[ "schemes", "contains", "a", "list", "of", "replace", "this", "list", "with", "the", "hash", "(", "es", ")", "you", "wish", "to", "support", ".", "this", "example", "sets", "pbkdf2_sha256", "as", "the", "default", "with", "support", "for", "legacy", "bcrypt...
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/__init__.py#L43-L58
[ "def", "make_passwordmanager", "(", "schemes", "=", "None", ")", ":", "from", "passlib", ".", "context", "import", "CryptContext", "if", "not", "schemes", ":", "schemes", "=", "[", "\"pbkdf2_sha256\"", ",", "\"bcrypt\"", "]", "pwd_context", "=", "CryptContext", ...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ziggurat_model_init
This function handles attaching model to service if model has one specified as `_ziggurat_service`, Also attached a proxy object holding all model definitions that services might use :param args: :param kwargs: :param passwordmanager, the password manager to override default one :param password...
ziggurat_foundations/__init__.py
def ziggurat_model_init( user=None, group=None, user_group=None, group_permission=None, user_permission=None, user_resource_permission=None, group_resource_permission=None, resource=None, external_identity=None, *args, **kwargs ): """ This function handles attaching m...
def ziggurat_model_init( user=None, group=None, user_group=None, group_permission=None, user_permission=None, user_resource_permission=None, group_resource_permission=None, resource=None, external_identity=None, *args, **kwargs ): """ This function handles attaching m...
[ "This", "function", "handles", "attaching", "model", "to", "service", "if", "model", "has", "one", "specified", "as", "_ziggurat_service", "Also", "attached", "a", "proxy", "object", "holding", "all", "model", "definitions", "that", "services", "might", "use" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/__init__.py#L61-L111
[ "def", "ziggurat_model_init", "(", "user", "=", "None", ",", "group", "=", "None", ",", "user_group", "=", "None", ",", "group_permission", "=", "None", ",", "user_permission", "=", "None", ",", "user_resource_permission", "=", "None", ",", "group_resource_permi...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
messages
Show messages for the given query or day.
gnotty/views.py
def messages(request, year=None, month=None, day=None, template="gnotty/messages.html"): """ Show messages for the given query or day. """ query = request.REQUEST.get("q") prev_url, next_url = None, None messages = IRCMessage.objects.all() if hide_joins_and_leaves(request): ...
def messages(request, year=None, month=None, day=None, template="gnotty/messages.html"): """ Show messages for the given query or day. """ query = request.REQUEST.get("q") prev_url, next_url = None, None messages = IRCMessage.objects.all() if hide_joins_and_leaves(request): ...
[ "Show", "messages", "for", "the", "given", "query", "or", "day", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/views.py#L25-L56
[ "def", "messages", "(", "request", ",", "year", "=", "None", ",", "month", "=", "None", ",", "day", "=", "None", ",", "template", "=", "\"gnotty/messages.html\"", ")", ":", "query", "=", "request", ".", "REQUEST", ".", "get", "(", "\"q\"", ")", "prev_u...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
calendar
Show calendar months for the given year/month.
gnotty/views.py
def calendar(request, year=None, month=None, template="gnotty/calendar.html"): """ Show calendar months for the given year/month. """ try: year = int(year) except TypeError: year = datetime.now().year lookup = {"message_time__year": year} if month: lookup["message_ti...
def calendar(request, year=None, month=None, template="gnotty/calendar.html"): """ Show calendar months for the given year/month. """ try: year = int(year) except TypeError: year = datetime.now().year lookup = {"message_time__year": year} if month: lookup["message_ti...
[ "Show", "calendar", "months", "for", "the", "given", "year", "/", "month", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/views.py#L59-L102
[ "def", "calendar", "(", "request", ",", "year", "=", "None", ",", "month", "=", "None", ",", "template", "=", "\"gnotty/calendar.html\"", ")", ":", "try", ":", "year", "=", "int", "(", "year", ")", "except", "TypeError", ":", "year", "=", "datetime", "...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
decorate_client
A helper for decorating :class:`bravado.client.SwaggerClient`. :class:`bravado.client.SwaggerClient` can be extended by creating a class which wraps all calls to it. This helper is used in a :func:`__getattr__` to check if the attr exists on the api_client. If the attr does not exist raise :class:`Attri...
swagger_zipkin/decorate_client.py
def decorate_client(api_client, func, name): """A helper for decorating :class:`bravado.client.SwaggerClient`. :class:`bravado.client.SwaggerClient` can be extended by creating a class which wraps all calls to it. This helper is used in a :func:`__getattr__` to check if the attr exists on the api_client...
def decorate_client(api_client, func, name): """A helper for decorating :class:`bravado.client.SwaggerClient`. :class:`bravado.client.SwaggerClient` can be extended by creating a class which wraps all calls to it. This helper is used in a :func:`__getattr__` to check if the attr exists on the api_client...
[ "A", "helper", "for", "decorating", ":", "class", ":", "bravado", ".", "client", ".", "SwaggerClient", ".", ":", "class", ":", "bravado", ".", "client", ".", "SwaggerClient", "can", "be", "extended", "by", "creating", "a", "class", "which", "wraps", "all",...
Yelp/swagger_zipkin
python
https://github.com/Yelp/swagger_zipkin/blob/8159b5d04f2c1089ae0a60851a5f097d7e09a40e/swagger_zipkin/decorate_client.py#L33-L71
[ "def", "decorate_client", "(", "api_client", ",", "func", ",", "name", ")", ":", "client_attr", "=", "getattr", "(", "api_client", ",", "name", ")", "if", "not", "callable", "(", "client_attr", ")", ":", "return", "client_attr", "return", "OperationDecorator",...
8159b5d04f2c1089ae0a60851a5f097d7e09a40e
train
db_mutex.delete_expired_locks
Deletes all expired mutex locks if a ttl is provided.
db_mutex/db_mutex.py
def delete_expired_locks(self): """ Deletes all expired mutex locks if a ttl is provided. """ ttl_seconds = self.get_mutex_ttl_seconds() if ttl_seconds is not None: DBMutex.objects.filter(creation_time__lte=timezone.now() - timedelta(seconds=ttl_seconds)).delete()
def delete_expired_locks(self): """ Deletes all expired mutex locks if a ttl is provided. """ ttl_seconds = self.get_mutex_ttl_seconds() if ttl_seconds is not None: DBMutex.objects.filter(creation_time__lte=timezone.now() - timedelta(seconds=ttl_seconds)).delete()
[ "Deletes", "all", "expired", "mutex", "locks", "if", "a", "ttl", "is", "provided", "." ]
ambitioninc/django-db-mutex
python
https://github.com/ambitioninc/django-db-mutex/blob/7112ed202fa3135afbb280273c1bdc8dee4e8426/db_mutex/db_mutex.py#L81-L87
[ "def", "delete_expired_locks", "(", "self", ")", ":", "ttl_seconds", "=", "self", ".", "get_mutex_ttl_seconds", "(", ")", "if", "ttl_seconds", "is", "not", "None", ":", "DBMutex", ".", "objects", ".", "filter", "(", "creation_time__lte", "=", "timezone", ".", ...
7112ed202fa3135afbb280273c1bdc8dee4e8426
train
db_mutex.start
Acquires the db mutex lock. Takes the necessary steps to delete any stale locks. Throws a DBMutexError if it can't acquire the lock.
db_mutex/db_mutex.py
def start(self): """ Acquires the db mutex lock. Takes the necessary steps to delete any stale locks. Throws a DBMutexError if it can't acquire the lock. """ # Delete any expired locks first self.delete_expired_locks() try: with transaction.atomic(): ...
def start(self): """ Acquires the db mutex lock. Takes the necessary steps to delete any stale locks. Throws a DBMutexError if it can't acquire the lock. """ # Delete any expired locks first self.delete_expired_locks() try: with transaction.atomic(): ...
[ "Acquires", "the", "db", "mutex", "lock", ".", "Takes", "the", "necessary", "steps", "to", "delete", "any", "stale", "locks", ".", "Throws", "a", "DBMutexError", "if", "it", "can", "t", "acquire", "the", "lock", "." ]
ambitioninc/django-db-mutex
python
https://github.com/ambitioninc/django-db-mutex/blob/7112ed202fa3135afbb280273c1bdc8dee4e8426/db_mutex/db_mutex.py#L98-L109
[ "def", "start", "(", "self", ")", ":", "# Delete any expired locks first", "self", ".", "delete_expired_locks", "(", ")", "try", ":", "with", "transaction", ".", "atomic", "(", ")", ":", "self", ".", "lock", "=", "DBMutex", ".", "objects", ".", "create", "...
7112ed202fa3135afbb280273c1bdc8dee4e8426
train
db_mutex.stop
Releases the db mutex lock. Throws an error if the lock was released before the function finished.
db_mutex/db_mutex.py
def stop(self): """ Releases the db mutex lock. Throws an error if the lock was released before the function finished. """ if not DBMutex.objects.filter(id=self.lock.id).exists(): raise DBMutexTimeoutError('Lock {0} expired before function completed'.format(self.lock_id)) ...
def stop(self): """ Releases the db mutex lock. Throws an error if the lock was released before the function finished. """ if not DBMutex.objects.filter(id=self.lock.id).exists(): raise DBMutexTimeoutError('Lock {0} expired before function completed'.format(self.lock_id)) ...
[ "Releases", "the", "db", "mutex", "lock", ".", "Throws", "an", "error", "if", "the", "lock", "was", "released", "before", "the", "function", "finished", "." ]
ambitioninc/django-db-mutex
python
https://github.com/ambitioninc/django-db-mutex/blob/7112ed202fa3135afbb280273c1bdc8dee4e8426/db_mutex/db_mutex.py#L111-L118
[ "def", "stop", "(", "self", ")", ":", "if", "not", "DBMutex", ".", "objects", ".", "filter", "(", "id", "=", "self", ".", "lock", ".", "id", ")", ".", "exists", "(", ")", ":", "raise", "DBMutexTimeoutError", "(", "'Lock {0} expired before function complete...
7112ed202fa3135afbb280273c1bdc8dee4e8426
train
db_mutex.decorate_callable
Decorates a function with the db_mutex decorator by using this class as a context manager around it.
db_mutex/db_mutex.py
def decorate_callable(self, func): """ Decorates a function with the db_mutex decorator by using this class as a context manager around it. """ def wrapper(*args, **kwargs): try: with self: result = func(*args, **kwargs) ...
def decorate_callable(self, func): """ Decorates a function with the db_mutex decorator by using this class as a context manager around it. """ def wrapper(*args, **kwargs): try: with self: result = func(*args, **kwargs) ...
[ "Decorates", "a", "function", "with", "the", "db_mutex", "decorator", "by", "using", "this", "class", "as", "a", "context", "manager", "around", "it", "." ]
ambitioninc/django-db-mutex
python
https://github.com/ambitioninc/django-db-mutex/blob/7112ed202fa3135afbb280273c1bdc8dee4e8426/db_mutex/db_mutex.py#L120-L136
[ "def", "decorate_callable", "(", "self", ",", "func", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "with", "self", ":", "result", "=", "func", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return...
7112ed202fa3135afbb280273c1bdc8dee4e8426
train
groupfinder
Default groupfinder implementaion for pyramid applications :param userid: :param request: :return:
ziggurat_foundations/models/__init__.py
def groupfinder(userid, request): """ Default groupfinder implementaion for pyramid applications :param userid: :param request: :return: """ if userid and hasattr(request, "user") and request.user: groups = ["group:%s" % g.id for g in request.user.groups] return groups r...
def groupfinder(userid, request): """ Default groupfinder implementaion for pyramid applications :param userid: :param request: :return: """ if userid and hasattr(request, "user") and request.user: groups = ["group:%s" % g.id for g in request.user.groups] return groups r...
[ "Default", "groupfinder", "implementaion", "for", "pyramid", "applications" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/__init__.py#L7-L18
[ "def", "groupfinder", "(", "userid", ",", "request", ")", ":", "if", "userid", "and", "hasattr", "(", "request", ",", "\"user\"", ")", "and", "request", ".", "user", ":", "groups", "=", "[", "\"group:%s\"", "%", "g", ".", "id", "for", "g", "in", "req...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
force_atlas2_layout
Position nodes using ForceAtlas2 force-directed algorithm Parameters ---------- graph: NetworkX graph A position will be assigned to every node in G. pos_list : dict or None optional (default=None) Initial positions for nodes as a dictionary with node as keys and values as a c...
fa2l/fa2l.py
def force_atlas2_layout(graph, pos_list=None, node_masses=None, iterations=100, outbound_attraction_distribution=False, lin_log_mode=False, prevent_overlapping=False, ...
def force_atlas2_layout(graph, pos_list=None, node_masses=None, iterations=100, outbound_attraction_distribution=False, lin_log_mode=False, prevent_overlapping=False, ...
[ "Position", "nodes", "using", "ForceAtlas2", "force", "-", "directed", "algorithm" ]
bosiakov/fa2l
python
https://github.com/bosiakov/fa2l/blob/46b8494c2ad4429bbe1042b6e87b139dd7422c31/fa2l/fa2l.py#L10-L243
[ "def", "force_atlas2_layout", "(", "graph", ",", "pos_list", "=", "None", ",", "node_masses", "=", "None", ",", "iterations", "=", "100", ",", "outbound_attraction_distribution", "=", "False", ",", "lin_log_mode", "=", "False", ",", "prevent_overlapping", "=", "...
46b8494c2ad4429bbe1042b6e87b139dd7422c31
train
apply_repulsion
Iterate through the nodes or edges and apply the forces directly to the node objects.
fa2l/force.py
def apply_repulsion(repulsion, nodes, barnes_hut_optimize=False, region=None, barnes_hut_theta=1.2): """ Iterate through the nodes or edges and apply the forces directly to the node objects. """ if not barnes_hut_optimize: for i in range(0, len(nodes)): for j in range(0, i): ...
def apply_repulsion(repulsion, nodes, barnes_hut_optimize=False, region=None, barnes_hut_theta=1.2): """ Iterate through the nodes or edges and apply the forces directly to the node objects. """ if not barnes_hut_optimize: for i in range(0, len(nodes)): for j in range(0, i): ...
[ "Iterate", "through", "the", "nodes", "or", "edges", "and", "apply", "the", "forces", "directly", "to", "the", "node", "objects", "." ]
bosiakov/fa2l
python
https://github.com/bosiakov/fa2l/blob/46b8494c2ad4429bbe1042b6e87b139dd7422c31/fa2l/force.py#L4-L14
[ "def", "apply_repulsion", "(", "repulsion", ",", "nodes", ",", "barnes_hut_optimize", "=", "False", ",", "region", "=", "None", ",", "barnes_hut_theta", "=", "1.2", ")", ":", "if", "not", "barnes_hut_optimize", ":", "for", "i", "in", "range", "(", "0", ","...
46b8494c2ad4429bbe1042b6e87b139dd7422c31
train
apply_gravity
Iterate through the nodes or edges and apply the gravity directly to the node objects.
fa2l/force.py
def apply_gravity(repulsion, nodes, gravity, scaling_ratio): """ Iterate through the nodes or edges and apply the gravity directly to the node objects. """ for i in range(0, len(nodes)): repulsion.apply_gravitation(nodes[i], gravity / scaling_ratio)
def apply_gravity(repulsion, nodes, gravity, scaling_ratio): """ Iterate through the nodes or edges and apply the gravity directly to the node objects. """ for i in range(0, len(nodes)): repulsion.apply_gravitation(nodes[i], gravity / scaling_ratio)
[ "Iterate", "through", "the", "nodes", "or", "edges", "and", "apply", "the", "gravity", "directly", "to", "the", "node", "objects", "." ]
bosiakov/fa2l
python
https://github.com/bosiakov/fa2l/blob/46b8494c2ad4429bbe1042b6e87b139dd7422c31/fa2l/force.py#L17-L22
[ "def", "apply_gravity", "(", "repulsion", ",", "nodes", ",", "gravity", ",", "scaling_ratio", ")", ":", "for", "i", "in", "range", "(", "0", ",", "len", "(", "nodes", ")", ")", ":", "repulsion", ".", "apply_gravitation", "(", "nodes", "[", "i", "]", ...
46b8494c2ad4429bbe1042b6e87b139dd7422c31
train
ExternalIdentityService.get
Fetch row using primary key - will use existing object in session if already present :param external_id: :param local_user_id: :param provider_name: :param db_session: :return:
ziggurat_foundations/models/services/external_identity.py
def get(cls, external_id, local_user_id, provider_name, db_session=None): """ Fetch row using primary key - will use existing object in session if already present :param external_id: :param local_user_id: :param provider_name: :param db_session: :return: ...
def get(cls, external_id, local_user_id, provider_name, db_session=None): """ Fetch row using primary key - will use existing object in session if already present :param external_id: :param local_user_id: :param provider_name: :param db_session: :return: ...
[ "Fetch", "row", "using", "primary", "key", "-", "will", "use", "existing", "object", "in", "session", "if", "already", "present" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/external_identity.py#L12-L26
[ "def", "get", "(", "cls", ",", "external_id", ",", "local_user_id", ",", "provider_name", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "return", "db_session", ".", "query", "(", "cls", ".", "model", ...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ExternalIdentityService.by_external_id_and_provider
Returns ExternalIdentity instance based on search params :param external_id: :param provider_name: :param db_session: :return: ExternalIdentity
ziggurat_foundations/models/services/external_identity.py
def by_external_id_and_provider(cls, external_id, provider_name, db_session=None): """ Returns ExternalIdentity instance based on search params :param external_id: :param provider_name: :param db_session: :return: ExternalIdentity """ db_session = get_db_...
def by_external_id_and_provider(cls, external_id, provider_name, db_session=None): """ Returns ExternalIdentity instance based on search params :param external_id: :param provider_name: :param db_session: :return: ExternalIdentity """ db_session = get_db_...
[ "Returns", "ExternalIdentity", "instance", "based", "on", "search", "params" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/external_identity.py#L29-L42
[ "def", "by_external_id_and_provider", "(", "cls", ",", "external_id", ",", "provider_name", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "query", "=", "db_session", ".", "query", "(", "cls", ".", "model...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ExternalIdentityService.user_by_external_id_and_provider
Returns User instance based on search params :param external_id: :param provider_name: :param db_session: :return: User
ziggurat_foundations/models/services/external_identity.py
def user_by_external_id_and_provider( cls, external_id, provider_name, db_session=None ): """ Returns User instance based on search params :param external_id: :param provider_name: :param db_session: :return: User """ db_session = get_db_sessi...
def user_by_external_id_and_provider( cls, external_id, provider_name, db_session=None ): """ Returns User instance based on search params :param external_id: :param provider_name: :param db_session: :return: User """ db_session = get_db_sessi...
[ "Returns", "User", "instance", "based", "on", "search", "params" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/external_identity.py#L45-L61
[ "def", "user_by_external_id_and_provider", "(", "cls", ",", "external_id", ",", "provider_name", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "query", "=", "db_session", ".", "query", "(", "cls", ".", "...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
UserPermissionService.by_user_and_perm
return by user and permission name :param user_id: :param perm_name: :param db_session: :return:
ziggurat_foundations/models/services/user_permission.py
def by_user_and_perm(cls, user_id, perm_name, db_session=None): """ return by user and permission name :param user_id: :param perm_name: :param db_session: :return: """ db_session = get_db_session(db_session) query = db_session.query(cls.model).fi...
def by_user_and_perm(cls, user_id, perm_name, db_session=None): """ return by user and permission name :param user_id: :param perm_name: :param db_session: :return: """ db_session = get_db_session(db_session) query = db_session.query(cls.model).fi...
[ "return", "by", "user", "and", "permission", "name" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/user_permission.py#L26-L38
[ "def", "by_user_and_perm", "(", "cls", ",", "user_id", ",", "perm_name", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "query", "=", "db_session", ".", "query", "(", "cls", ".", "model", ")", ".", ...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
node_is_subclass
Checks if cls node has parent with subclass_name.
pylint_mongoengine/utils.py
def node_is_subclass(cls, *subclass_names): """Checks if cls node has parent with subclass_name.""" if not isinstance(cls, (ClassDef, Instance)): return False # if cls.bases == YES: # return False for base_cls in cls.bases: try: for inf in base_cls.inferred(): # pra...
def node_is_subclass(cls, *subclass_names): """Checks if cls node has parent with subclass_name.""" if not isinstance(cls, (ClassDef, Instance)): return False # if cls.bases == YES: # return False for base_cls in cls.bases: try: for inf in base_cls.inferred(): # pra...
[ "Checks", "if", "cls", "node", "has", "parent", "with", "subclass_name", "." ]
jucacrispim/pylint-mongoengine
python
https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/utils.py#L39-L60
[ "def", "node_is_subclass", "(", "cls", ",", "*", "subclass_names", ")", ":", "if", "not", "isinstance", "(", "cls", ",", "(", "ClassDef", ",", "Instance", ")", ")", ":", "return", "False", "# if cls.bases == YES:", "# return False", "for", "base_cls", "in"...
b873653d1224a5748f75dd507f492f8c60d95ce3
train
is_field_method
Checks if a call to a field instance method is valid. A call is valid if the call is a method of the underlying type. So, in a StringField the methods from str are valid, in a ListField the methods from list are valid and so on...
pylint_mongoengine/utils.py
def is_field_method(node): """Checks if a call to a field instance method is valid. A call is valid if the call is a method of the underlying type. So, in a StringField the methods from str are valid, in a ListField the methods from list are valid and so on...""" name = node.attrname parent = no...
def is_field_method(node): """Checks if a call to a field instance method is valid. A call is valid if the call is a method of the underlying type. So, in a StringField the methods from str are valid, in a ListField the methods from list are valid and so on...""" name = node.attrname parent = no...
[ "Checks", "if", "a", "call", "to", "a", "field", "instance", "method", "is", "valid", ".", "A", "call", "is", "valid", "if", "the", "call", "is", "a", "method", "of", "the", "underlying", "type", ".", "So", "in", "a", "StringField", "the", "methods", ...
jucacrispim/pylint-mongoengine
python
https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/utils.py#L83-L99
[ "def", "is_field_method", "(", "node", ")", ":", "name", "=", "node", ".", "attrname", "parent", "=", "node", ".", "last_child", "(", ")", "inferred", "=", "safe_infer", "(", "parent", ")", "if", "not", "inferred", ":", "return", "False", "for", "cls_nam...
b873653d1224a5748f75dd507f492f8c60d95ce3
train
get_node_parent_class
Supposes that node is a mongoengine field in a class and tries to get its parent class
pylint_mongoengine/utils.py
def get_node_parent_class(node): """Supposes that node is a mongoengine field in a class and tries to get its parent class""" while node.parent: # pragma no branch if isinstance(node, ClassDef): return node node = node.parent
def get_node_parent_class(node): """Supposes that node is a mongoengine field in a class and tries to get its parent class""" while node.parent: # pragma no branch if isinstance(node, ClassDef): return node node = node.parent
[ "Supposes", "that", "node", "is", "a", "mongoengine", "field", "in", "a", "class", "and", "tries", "to", "get", "its", "parent", "class" ]
jucacrispim/pylint-mongoengine
python
https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/utils.py#L102-L110
[ "def", "get_node_parent_class", "(", "node", ")", ":", "while", "node", ".", "parent", ":", "# pragma no branch", "if", "isinstance", "(", "node", ",", "ClassDef", ")", ":", "return", "node", "node", "=", "node", ".", "parent" ]
b873653d1224a5748f75dd507f492f8c60d95ce3
train
get_field_definition
node is a class attribute that is a mongoengine. Returns the definition statement for the attribute
pylint_mongoengine/utils.py
def get_field_definition(node): """"node is a class attribute that is a mongoengine. Returns the definition statement for the attribute """ name = node.attrname cls = get_node_parent_class(node) definition = cls.lookup(name)[1][0].statement() return definition
def get_field_definition(node): """"node is a class attribute that is a mongoengine. Returns the definition statement for the attribute """ name = node.attrname cls = get_node_parent_class(node) definition = cls.lookup(name)[1][0].statement() return definition
[ "node", "is", "a", "class", "attribute", "that", "is", "a", "mongoengine", ".", "Returns", "the", "definition", "statement", "for", "the", "attribute" ]
jucacrispim/pylint-mongoengine
python
https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/utils.py#L122-L130
[ "def", "get_field_definition", "(", "node", ")", ":", "name", "=", "node", ".", "attrname", "cls", "=", "get_node_parent_class", "(", "node", ")", "definition", "=", "cls", ".", "lookup", "(", "name", ")", "[", "1", "]", "[", "0", "]", ".", "statement"...
b873653d1224a5748f75dd507f492f8c60d95ce3
train
get_field_embedded_doc
Returns de ClassDef for the related embedded document in a embedded document field.
pylint_mongoengine/utils.py
def get_field_embedded_doc(node): """Returns de ClassDef for the related embedded document in a embedded document field.""" definition = get_field_definition(node) cls_name = definition.last_child().last_child() cls = next(cls_name.infer()) return cls
def get_field_embedded_doc(node): """Returns de ClassDef for the related embedded document in a embedded document field.""" definition = get_field_definition(node) cls_name = definition.last_child().last_child() cls = next(cls_name.infer()) return cls
[ "Returns", "de", "ClassDef", "for", "the", "related", "embedded", "document", "in", "a", "embedded", "document", "field", "." ]
jucacrispim/pylint-mongoengine
python
https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/utils.py#L133-L140
[ "def", "get_field_embedded_doc", "(", "node", ")", ":", "definition", "=", "get_field_definition", "(", "node", ")", "cls_name", "=", "definition", ".", "last_child", "(", ")", ".", "last_child", "(", ")", "cls", "=", "next", "(", "cls_name", ".", "infer", ...
b873653d1224a5748f75dd507f492f8c60d95ce3
train
node_is_embedded_doc_attr
Checks if a node is a valid field or method in a embedded document.
pylint_mongoengine/utils.py
def node_is_embedded_doc_attr(node): """Checks if a node is a valid field or method in a embedded document. """ embedded_doc = get_field_embedded_doc(node.last_child()) name = node.attrname try: r = bool(embedded_doc.lookup(name)[1][0]) except IndexError: r = False return r
def node_is_embedded_doc_attr(node): """Checks if a node is a valid field or method in a embedded document. """ embedded_doc = get_field_embedded_doc(node.last_child()) name = node.attrname try: r = bool(embedded_doc.lookup(name)[1][0]) except IndexError: r = False return r
[ "Checks", "if", "a", "node", "is", "a", "valid", "field", "or", "method", "in", "a", "embedded", "document", "." ]
jucacrispim/pylint-mongoengine
python
https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/utils.py#L143-L153
[ "def", "node_is_embedded_doc_attr", "(", "node", ")", ":", "embedded_doc", "=", "get_field_embedded_doc", "(", "node", ".", "last_child", "(", ")", ")", "name", "=", "node", ".", "attrname", "try", ":", "r", "=", "bool", "(", "embedded_doc", ".", "lookup", ...
b873653d1224a5748f75dd507f492f8c60d95ce3
train
BaseBot._dispatcher
This is the method in ``SimpleIRCClient`` that all IRC events get passed through. Here we map events to our own custom event handlers, and call them.
gnotty/bots/base.py
def _dispatcher(self, connection, event): """ This is the method in ``SimpleIRCClient`` that all IRC events get passed through. Here we map events to our own custom event handlers, and call them. """ super(BaseBot, self)._dispatcher(connection, event) for handler ...
def _dispatcher(self, connection, event): """ This is the method in ``SimpleIRCClient`` that all IRC events get passed through. Here we map events to our own custom event handlers, and call them. """ super(BaseBot, self)._dispatcher(connection, event) for handler ...
[ "This", "is", "the", "method", "in", "SimpleIRCClient", "that", "all", "IRC", "events", "get", "passed", "through", ".", "Here", "we", "map", "events", "to", "our", "own", "custom", "event", "handlers", "and", "call", "them", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/base.py#L57-L65
[ "def", "_dispatcher", "(", "self", ",", "connection", ",", "event", ")", ":", "super", "(", "BaseBot", ",", "self", ")", ".", "_dispatcher", "(", "connection", ",", "event", ")", "for", "handler", "in", "self", ".", "events", "[", "event", ".", "eventt...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
BaseBot.message_channel
We won't receive our own messages, so log them manually.
gnotty/bots/base.py
def message_channel(self, message): """ We won't receive our own messages, so log them manually. """ self.log(None, message) super(BaseBot, self).message_channel(message)
def message_channel(self, message): """ We won't receive our own messages, so log them manually. """ self.log(None, message) super(BaseBot, self).message_channel(message)
[ "We", "won", "t", "receive", "our", "own", "messages", "so", "log", "them", "manually", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/base.py#L76-L81
[ "def", "message_channel", "(", "self", ",", "message", ")", ":", "self", ".", "log", "(", "None", ",", "message", ")", "super", "(", "BaseBot", ",", "self", ")", ".", "message_channel", "(", "message", ")" ]
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
BaseBot.on_pubmsg
Log any public messages, and also handle the command event.
gnotty/bots/base.py
def on_pubmsg(self, connection, event): """ Log any public messages, and also handle the command event. """ for message in event.arguments(): self.log(event, message) command_args = filter(None, message.split()) command_name = command_args.pop(0) ...
def on_pubmsg(self, connection, event): """ Log any public messages, and also handle the command event. """ for message in event.arguments(): self.log(event, message) command_args = filter(None, message.split()) command_name = command_args.pop(0) ...
[ "Log", "any", "public", "messages", "and", "also", "handle", "the", "command", "event", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/base.py#L92-L102
[ "def", "on_pubmsg", "(", "self", ",", "connection", ",", "event", ")", ":", "for", "message", "in", "event", ".", "arguments", "(", ")", ":", "self", ".", "log", "(", "event", ",", "message", ")", "command_args", "=", "filter", "(", "None", ",", "mes...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
BaseBot.handle_command_event
Command handler - treats each word in the message that triggered the command as an argument to the command, and does some validation to ensure that the number of arguments match.
gnotty/bots/base.py
def handle_command_event(self, event, command, args): """ Command handler - treats each word in the message that triggered the command as an argument to the command, and does some validation to ensure that the number of arguments match. """ argspec = getargspec(co...
def handle_command_event(self, event, command, args): """ Command handler - treats each word in the message that triggered the command as an argument to the command, and does some validation to ensure that the number of arguments match. """ argspec = getargspec(co...
[ "Command", "handler", "-", "treats", "each", "word", "in", "the", "message", "that", "triggered", "the", "command", "as", "an", "argument", "to", "the", "command", "and", "does", "some", "validation", "to", "ensure", "that", "the", "number", "of", "arguments...
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/base.py#L104-L123
[ "def", "handle_command_event", "(", "self", ",", "event", ",", "command", ",", "args", ")", ":", "argspec", "=", "getargspec", "(", "command", ")", "num_all_args", "=", "len", "(", "argspec", ".", "args", ")", "-", "2", "# Ignore self/event args", "num_pos_a...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
BaseBot.handle_timer_event
Runs each timer handler in a separate greenlet thread.
gnotty/bots/base.py
def handle_timer_event(self, handler): """ Runs each timer handler in a separate greenlet thread. """ while True: handler(self) sleep(handler.event.args["seconds"])
def handle_timer_event(self, handler): """ Runs each timer handler in a separate greenlet thread. """ while True: handler(self) sleep(handler.event.args["seconds"])
[ "Runs", "each", "timer", "handler", "in", "a", "separate", "greenlet", "thread", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/base.py#L125-L131
[ "def", "handle_timer_event", "(", "self", ",", "handler", ")", ":", "while", "True", ":", "handler", "(", "self", ")", "sleep", "(", "handler", ".", "event", ".", "args", "[", "\"seconds\"", "]", ")" ]
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
BaseBot.handle_webhook_event
Webhook handler - each handler for the webhook event takes an initial pattern argument for matching the URL requested. Here we match the URL to the pattern for each webhook handler, and bail out if it returns a response.
gnotty/bots/base.py
def handle_webhook_event(self, environ, url, params): """ Webhook handler - each handler for the webhook event takes an initial pattern argument for matching the URL requested. Here we match the URL to the pattern for each webhook handler, and bail out if it returns a response. ...
def handle_webhook_event(self, environ, url, params): """ Webhook handler - each handler for the webhook event takes an initial pattern argument for matching the URL requested. Here we match the URL to the pattern for each webhook handler, and bail out if it returns a response. ...
[ "Webhook", "handler", "-", "each", "handler", "for", "the", "webhook", "event", "takes", "an", "initial", "pattern", "argument", "for", "matching", "the", "URL", "requested", ".", "Here", "we", "match", "the", "URL", "to", "the", "pattern", "for", "each", ...
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/base.py#L133-L145
[ "def", "handle_webhook_event", "(", "self", ",", "environ", ",", "url", ",", "params", ")", ":", "for", "handler", "in", "self", ".", "events", "[", "\"webhook\"", "]", ":", "urlpattern", "=", "handler", ".", "event", ".", "args", "[", "\"urlpattern\"", ...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
DeviceFactory
Create the correct device instance based on device type and return it. :return: a :class:`Device` or :class:`DeviceGroup` instance.
tellcore/telldus.py
def DeviceFactory(id, lib=None): """Create the correct device instance based on device type and return it. :return: a :class:`Device` or :class:`DeviceGroup` instance. """ lib = lib or Library() if lib.tdGetDeviceType(id) == const.TELLSTICK_TYPE_GROUP: return DeviceGroup(id, lib=lib) re...
def DeviceFactory(id, lib=None): """Create the correct device instance based on device type and return it. :return: a :class:`Device` or :class:`DeviceGroup` instance. """ lib = lib or Library() if lib.tdGetDeviceType(id) == const.TELLSTICK_TYPE_GROUP: return DeviceGroup(id, lib=lib) re...
[ "Create", "the", "correct", "device", "instance", "based", "on", "device", "type", "and", "return", "it", "." ]
erijo/tellcore-py
python
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L266-L274
[ "def", "DeviceFactory", "(", "id", ",", "lib", "=", "None", ")", ":", "lib", "=", "lib", "or", "Library", "(", ")", "if", "lib", ".", "tdGetDeviceType", "(", "id", ")", "==", "const", ".", "TELLSTICK_TYPE_GROUP", ":", "return", "DeviceGroup", "(", "id"...
7a1eb53e12ef039a2350933e502633df7560f6a8
train
QueuedCallbackDispatcher.process_callback
Dispatch a single callback in the current thread. :param boolean block: If True, blocks waiting for a callback to come. :return: True if a callback was processed; otherwise False.
tellcore/telldus.py
def process_callback(self, block=True): """Dispatch a single callback in the current thread. :param boolean block: If True, blocks waiting for a callback to come. :return: True if a callback was processed; otherwise False. """ try: (callback, args) = self._queue.get(...
def process_callback(self, block=True): """Dispatch a single callback in the current thread. :param boolean block: If True, blocks waiting for a callback to come. :return: True if a callback was processed; otherwise False. """ try: (callback, args) = self._queue.get(...
[ "Dispatch", "a", "single", "callback", "in", "the", "current", "thread", "." ]
erijo/tellcore-py
python
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L48-L62
[ "def", "process_callback", "(", "self", ",", "block", "=", "True", ")", ":", "try", ":", "(", "callback", ",", "args", ")", "=", "self", ".", "_queue", ".", "get", "(", "block", "=", "block", ")", "try", ":", "callback", "(", "*", "args", ")", "f...
7a1eb53e12ef039a2350933e502633df7560f6a8
train
TelldusCore.devices
Return all known devices. :return: list of :class:`Device` or :class:`DeviceGroup` instances.
tellcore/telldus.py
def devices(self): """Return all known devices. :return: list of :class:`Device` or :class:`DeviceGroup` instances. """ devices = [] count = self.lib.tdGetNumberOfDevices() for i in range(count): device = DeviceFactory(self.lib.tdGetDeviceId(i), lib=self.lib)...
def devices(self): """Return all known devices. :return: list of :class:`Device` or :class:`DeviceGroup` instances. """ devices = [] count = self.lib.tdGetNumberOfDevices() for i in range(count): device = DeviceFactory(self.lib.tdGetDeviceId(i), lib=self.lib)...
[ "Return", "all", "known", "devices", "." ]
erijo/tellcore-py
python
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L169-L179
[ "def", "devices", "(", "self", ")", ":", "devices", "=", "[", "]", "count", "=", "self", ".", "lib", ".", "tdGetNumberOfDevices", "(", ")", "for", "i", "in", "range", "(", "count", ")", ":", "device", "=", "DeviceFactory", "(", "self", ".", "lib", ...
7a1eb53e12ef039a2350933e502633df7560f6a8
train
TelldusCore.sensors
Return all known sensors. :return: list of :class:`Sensor` instances.
tellcore/telldus.py
def sensors(self): """Return all known sensors. :return: list of :class:`Sensor` instances. """ sensors = [] try: while True: sensor = self.lib.tdSensor() sensors.append(Sensor(lib=self.lib, **sensor)) except TelldusError as e:...
def sensors(self): """Return all known sensors. :return: list of :class:`Sensor` instances. """ sensors = [] try: while True: sensor = self.lib.tdSensor() sensors.append(Sensor(lib=self.lib, **sensor)) except TelldusError as e:...
[ "Return", "all", "known", "sensors", "." ]
erijo/tellcore-py
python
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L181-L194
[ "def", "sensors", "(", "self", ")", ":", "sensors", "=", "[", "]", "try", ":", "while", "True", ":", "sensor", "=", "self", ".", "lib", ".", "tdSensor", "(", ")", "sensors", ".", "append", "(", "Sensor", "(", "lib", "=", "self", ".", "lib", ",", ...
7a1eb53e12ef039a2350933e502633df7560f6a8
train
TelldusCore.controllers
Return all known controllers. Requires Telldus core library version >= 2.1.2. :return: list of :class:`Controller` instances.
tellcore/telldus.py
def controllers(self): """Return all known controllers. Requires Telldus core library version >= 2.1.2. :return: list of :class:`Controller` instances. """ controllers = [] try: while True: controller = self.lib.tdController() ...
def controllers(self): """Return all known controllers. Requires Telldus core library version >= 2.1.2. :return: list of :class:`Controller` instances. """ controllers = [] try: while True: controller = self.lib.tdController() ...
[ "Return", "all", "known", "controllers", "." ]
erijo/tellcore-py
python
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L196-L213
[ "def", "controllers", "(", "self", ")", ":", "controllers", "=", "[", "]", "try", ":", "while", "True", ":", "controller", "=", "self", ".", "lib", ".", "tdController", "(", ")", "del", "controller", "[", "\"name\"", "]", "del", "controller", "[", "\"a...
7a1eb53e12ef039a2350933e502633df7560f6a8
train
TelldusCore.add_device
Add a new device. :return: a :class:`Device` or :class:`DeviceGroup` instance.
tellcore/telldus.py
def add_device(self, name, protocol, model=None, **parameters): """Add a new device. :return: a :class:`Device` or :class:`DeviceGroup` instance. """ device = Device(self.lib.tdAddDevice(), lib=self.lib) try: device.name = name device.protocol = protocol ...
def add_device(self, name, protocol, model=None, **parameters): """Add a new device. :return: a :class:`Device` or :class:`DeviceGroup` instance. """ device = Device(self.lib.tdAddDevice(), lib=self.lib) try: device.name = name device.protocol = protocol ...
[ "Add", "a", "new", "device", "." ]
erijo/tellcore-py
python
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L215-L242
[ "def", "add_device", "(", "self", ",", "name", ",", "protocol", ",", "model", "=", "None", ",", "*", "*", "parameters", ")", ":", "device", "=", "Device", "(", "self", ".", "lib", ".", "tdAddDevice", "(", ")", ",", "lib", "=", "self", ".", "lib", ...
7a1eb53e12ef039a2350933e502633df7560f6a8
train
TelldusCore.add_group
Add a new device group. :return: a :class:`DeviceGroup` instance.
tellcore/telldus.py
def add_group(self, name, devices): """Add a new device group. :return: a :class:`DeviceGroup` instance. """ device = self.add_device(name, "group") device.add_to_group(devices) return device
def add_group(self, name, devices): """Add a new device group. :return: a :class:`DeviceGroup` instance. """ device = self.add_device(name, "group") device.add_to_group(devices) return device
[ "Add", "a", "new", "device", "group", "." ]
erijo/tellcore-py
python
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L244-L251
[ "def", "add_group", "(", "self", ",", "name", ",", "devices", ")", ":", "device", "=", "self", ".", "add_device", "(", "name", ",", "\"group\"", ")", "device", ".", "add_to_group", "(", "devices", ")", "return", "device" ]
7a1eb53e12ef039a2350933e502633df7560f6a8
train
TelldusCore.connect_controller
Connect a controller.
tellcore/telldus.py
def connect_controller(self, vid, pid, serial): """Connect a controller.""" self.lib.tdConnectTellStickController(vid, pid, serial)
def connect_controller(self, vid, pid, serial): """Connect a controller.""" self.lib.tdConnectTellStickController(vid, pid, serial)
[ "Connect", "a", "controller", "." ]
erijo/tellcore-py
python
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L257-L259
[ "def", "connect_controller", "(", "self", ",", "vid", ",", "pid", ",", "serial", ")", ":", "self", ".", "lib", ".", "tdConnectTellStickController", "(", "vid", ",", "pid", ",", "serial", ")" ]
7a1eb53e12ef039a2350933e502633df7560f6a8
train
TelldusCore.disconnect_controller
Disconnect a controller.
tellcore/telldus.py
def disconnect_controller(self, vid, pid, serial): """Disconnect a controller.""" self.lib.tdDisconnectTellStickController(vid, pid, serial)
def disconnect_controller(self, vid, pid, serial): """Disconnect a controller.""" self.lib.tdDisconnectTellStickController(vid, pid, serial)
[ "Disconnect", "a", "controller", "." ]
erijo/tellcore-py
python
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L261-L263
[ "def", "disconnect_controller", "(", "self", ",", "vid", ",", "pid", ",", "serial", ")", ":", "self", ".", "lib", ".", "tdDisconnectTellStickController", "(", "vid", ",", "pid", ",", "serial", ")" ]
7a1eb53e12ef039a2350933e502633df7560f6a8
train
Device.parameters
Get dict with all set parameters.
tellcore/telldus.py
def parameters(self): """Get dict with all set parameters.""" parameters = {} for name in self.PARAMETERS: try: parameters[name] = self.get_parameter(name) except AttributeError: pass return parameters
def parameters(self): """Get dict with all set parameters.""" parameters = {} for name in self.PARAMETERS: try: parameters[name] = self.get_parameter(name) except AttributeError: pass return parameters
[ "Get", "dict", "with", "all", "set", "parameters", "." ]
erijo/tellcore-py
python
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L323-L331
[ "def", "parameters", "(", "self", ")", ":", "parameters", "=", "{", "}", "for", "name", "in", "self", ".", "PARAMETERS", ":", "try", ":", "parameters", "[", "name", "]", "=", "self", ".", "get_parameter", "(", "name", ")", "except", "AttributeError", "...
7a1eb53e12ef039a2350933e502633df7560f6a8
train
Device.get_parameter
Get a parameter.
tellcore/telldus.py
def get_parameter(self, name): """Get a parameter.""" default_value = "$%!)(INVALID)(!%$" value = self.lib.tdGetDeviceParameter(self.id, name, default_value) if value == default_value: raise AttributeError(name) return value
def get_parameter(self, name): """Get a parameter.""" default_value = "$%!)(INVALID)(!%$" value = self.lib.tdGetDeviceParameter(self.id, name, default_value) if value == default_value: raise AttributeError(name) return value
[ "Get", "a", "parameter", "." ]
erijo/tellcore-py
python
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L333-L339
[ "def", "get_parameter", "(", "self", ",", "name", ")", ":", "default_value", "=", "\"$%!)(INVALID)(!%$\"", "value", "=", "self", ".", "lib", ".", "tdGetDeviceParameter", "(", "self", ".", "id", ",", "name", ",", "default_value", ")", "if", "value", "==", "...
7a1eb53e12ef039a2350933e502633df7560f6a8
train
Device.set_parameter
Set a parameter.
tellcore/telldus.py
def set_parameter(self, name, value): """Set a parameter.""" self.lib.tdSetDeviceParameter(self.id, name, str(value))
def set_parameter(self, name, value): """Set a parameter.""" self.lib.tdSetDeviceParameter(self.id, name, str(value))
[ "Set", "a", "parameter", "." ]
erijo/tellcore-py
python
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L341-L343
[ "def", "set_parameter", "(", "self", ",", "name", ",", "value", ")", ":", "self", ".", "lib", ".", "tdSetDeviceParameter", "(", "self", ".", "id", ",", "name", ",", "str", "(", "value", ")", ")" ]
7a1eb53e12ef039a2350933e502633df7560f6a8
train
DeviceGroup.add_to_group
Add device(s) to the group.
tellcore/telldus.py
def add_to_group(self, devices): """Add device(s) to the group.""" ids = {d.id for d in self.devices_in_group()} ids.update(self._device_ids(devices)) self._set_group(ids)
def add_to_group(self, devices): """Add device(s) to the group.""" ids = {d.id for d in self.devices_in_group()} ids.update(self._device_ids(devices)) self._set_group(ids)
[ "Add", "device", "(", "s", ")", "to", "the", "group", "." ]
erijo/tellcore-py
python
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L406-L410
[ "def", "add_to_group", "(", "self", ",", "devices", ")", ":", "ids", "=", "{", "d", ".", "id", "for", "d", "in", "self", ".", "devices_in_group", "(", ")", "}", "ids", ".", "update", "(", "self", ".", "_device_ids", "(", "devices", ")", ")", "self"...
7a1eb53e12ef039a2350933e502633df7560f6a8
train
DeviceGroup.remove_from_group
Remove device(s) from the group.
tellcore/telldus.py
def remove_from_group(self, devices): """Remove device(s) from the group.""" ids = {d.id for d in self.devices_in_group()} ids.difference_update(self._device_ids(devices)) self._set_group(ids)
def remove_from_group(self, devices): """Remove device(s) from the group.""" ids = {d.id for d in self.devices_in_group()} ids.difference_update(self._device_ids(devices)) self._set_group(ids)
[ "Remove", "device", "(", "s", ")", "from", "the", "group", "." ]
erijo/tellcore-py
python
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L412-L416
[ "def", "remove_from_group", "(", "self", ",", "devices", ")", ":", "ids", "=", "{", "d", ".", "id", "for", "d", "in", "self", ".", "devices_in_group", "(", ")", "}", "ids", ".", "difference_update", "(", "self", ".", "_device_ids", "(", "devices", ")",...
7a1eb53e12ef039a2350933e502633df7560f6a8
train
DeviceGroup.devices_in_group
Fetch list of devices in group.
tellcore/telldus.py
def devices_in_group(self): """Fetch list of devices in group.""" try: devices = self.get_parameter('devices') except AttributeError: return [] ctor = DeviceFactory return [ctor(int(x), lib=self.lib) for x in devices.split(',') if x]
def devices_in_group(self): """Fetch list of devices in group.""" try: devices = self.get_parameter('devices') except AttributeError: return [] ctor = DeviceFactory return [ctor(int(x), lib=self.lib) for x in devices.split(',') if x]
[ "Fetch", "list", "of", "devices", "in", "group", "." ]
erijo/tellcore-py
python
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L418-L426
[ "def", "devices_in_group", "(", "self", ")", ":", "try", ":", "devices", "=", "self", ".", "get_parameter", "(", "'devices'", ")", "except", "AttributeError", ":", "return", "[", "]", "ctor", "=", "DeviceFactory", "return", "[", "ctor", "(", "int", "(", ...
7a1eb53e12ef039a2350933e502633df7560f6a8
train
Sensor.value
Return the :class:`SensorValue` for the given data type. sensor.value(TELLSTICK_TEMPERATURE) is identical to calling sensor.temperature().
tellcore/telldus.py
def value(self, datatype): """Return the :class:`SensorValue` for the given data type. sensor.value(TELLSTICK_TEMPERATURE) is identical to calling sensor.temperature(). """ value = self.lib.tdSensorValue( self.protocol, self.model, self.id, datatype) return S...
def value(self, datatype): """Return the :class:`SensorValue` for the given data type. sensor.value(TELLSTICK_TEMPERATURE) is identical to calling sensor.temperature(). """ value = self.lib.tdSensorValue( self.protocol, self.model, self.id, datatype) return S...
[ "Return", "the", ":", "class", ":", "SensorValue", "for", "the", "given", "data", "type", "." ]
erijo/tellcore-py
python
https://github.com/erijo/tellcore-py/blob/7a1eb53e12ef039a2350933e502633df7560f6a8/tellcore/telldus.py#L478-L486
[ "def", "value", "(", "self", ",", "datatype", ")", ":", "value", "=", "self", ".", "lib", ".", "tdSensorValue", "(", "self", ".", "protocol", ",", "self", ".", "model", ",", "self", ".", "id", ",", "datatype", ")", "return", "SensorValue", "(", "data...
7a1eb53e12ef039a2350933e502633df7560f6a8
train
_prepPointsForSegments
Move any off curves at the end of the contour to the beginning of the contour. This makes segmentation easier.
Lib/booleanOperations/flatten.py
def _prepPointsForSegments(points): """ Move any off curves at the end of the contour to the beginning of the contour. This makes segmentation easier. """ while 1: point = points[-1] if point.segmentType: break else: point = points.pop() ...
def _prepPointsForSegments(points): """ Move any off curves at the end of the contour to the beginning of the contour. This makes segmentation easier. """ while 1: point = points[-1] if point.segmentType: break else: point = points.pop() ...
[ "Move", "any", "off", "curves", "at", "the", "end", "of", "the", "contour", "to", "the", "beginning", "of", "the", "contour", ".", "This", "makes", "segmentation", "easier", "." ]
typemytype/booleanOperations
python
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L360-L374
[ "def", "_prepPointsForSegments", "(", "points", ")", ":", "while", "1", ":", "point", "=", "points", "[", "-", "1", "]", "if", "point", ".", "segmentType", ":", "break", "else", ":", "point", "=", "points", ".", "pop", "(", ")", "points", ".", "inser...
b7d9fc95c155824662f4a0020e653c77b7723d24
train
_reversePoints
Reverse the points. This differs from the reversal point pen in RoboFab in that it doesn't worry about maintaing the start point position. That has no benefit within the context of this module.
Lib/booleanOperations/flatten.py
def _reversePoints(points): """ Reverse the points. This differs from the reversal point pen in RoboFab in that it doesn't worry about maintaing the start point position. That has no benefit within the context of this module. """ # copy the points points = _copyPoints(points) # find ...
def _reversePoints(points): """ Reverse the points. This differs from the reversal point pen in RoboFab in that it doesn't worry about maintaing the start point position. That has no benefit within the context of this module. """ # copy the points points = _copyPoints(points) # find ...
[ "Reverse", "the", "points", ".", "This", "differs", "from", "the", "reversal", "point", "pen", "in", "RoboFab", "in", "that", "it", "doesn", "t", "worry", "about", "maintaing", "the", "start", "point", "position", ".", "That", "has", "no", "benefit", "with...
typemytype/booleanOperations
python
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L385-L416
[ "def", "_reversePoints", "(", "points", ")", ":", "# copy the points", "points", "=", "_copyPoints", "(", "points", ")", "# find the first on curve type and recycle", "# it for the last on curve type", "firstOnCurve", "=", "None", "for", "index", ",", "point", "in", "en...
b7d9fc95c155824662f4a0020e653c77b7723d24
train
_convertPointsToSegments
Compile points into InputSegment objects.
Lib/booleanOperations/flatten.py
def _convertPointsToSegments(points, willBeReversed=False): """ Compile points into InputSegment objects. """ # get the last on curve previousOnCurve = None for point in reversed(points): if point.segmentType is not None: previousOnCurve = point.coordinates break ...
def _convertPointsToSegments(points, willBeReversed=False): """ Compile points into InputSegment objects. """ # get the last on curve previousOnCurve = None for point in reversed(points): if point.segmentType is not None: previousOnCurve = point.coordinates break ...
[ "Compile", "points", "into", "InputSegment", "objects", "." ]
typemytype/booleanOperations
python
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L419-L447
[ "def", "_convertPointsToSegments", "(", "points", ",", "willBeReversed", "=", "False", ")", ":", "# get the last on curve", "previousOnCurve", "=", "None", "for", "point", "in", "reversed", "(", "points", ")", ":", "if", "point", ".", "segmentType", "is", "not",...
b7d9fc95c155824662f4a0020e653c77b7723d24
train
_tValueForPointOnCubicCurve
Finds a t value on a curve from a point. The points must be originaly be a point on the curve. This will only back trace the t value, needed to split the curve in parts
Lib/booleanOperations/flatten.py
def _tValueForPointOnCubicCurve(point, cubicCurve, isHorizontal=0): """ Finds a t value on a curve from a point. The points must be originaly be a point on the curve. This will only back trace the t value, needed to split the curve in parts """ pt1, pt2, pt3, pt4 = cubicCurve a, b, c, d = be...
def _tValueForPointOnCubicCurve(point, cubicCurve, isHorizontal=0): """ Finds a t value on a curve from a point. The points must be originaly be a point on the curve. This will only back trace the t value, needed to split the curve in parts """ pt1, pt2, pt3, pt4 = cubicCurve a, b, c, d = be...
[ "Finds", "a", "t", "value", "on", "a", "curve", "from", "a", "point", ".", "The", "points", "must", "be", "originaly", "be", "a", "point", "on", "the", "curve", ".", "This", "will", "only", "back", "trace", "the", "t", "value", "needed", "to", "split...
typemytype/booleanOperations
python
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L950-L972
[ "def", "_tValueForPointOnCubicCurve", "(", "point", ",", "cubicCurve", ",", "isHorizontal", "=", "0", ")", ":", "pt1", ",", "pt2", ",", "pt3", ",", "pt4", "=", "cubicCurve", "a", ",", "b", ",", "c", ",", "d", "=", "bezierTools", ".", "calcCubicParameters...
b7d9fc95c155824662f4a0020e653c77b7723d24
train
_scalePoints
Scale points and optionally convert them to integers.
Lib/booleanOperations/flatten.py
def _scalePoints(points, scale=1, convertToInteger=True): """ Scale points and optionally convert them to integers. """ if convertToInteger: points = [ (int(round(x * scale)), int(round(y * scale))) for (x, y) in points ] else: points = [(x * scale, y ...
def _scalePoints(points, scale=1, convertToInteger=True): """ Scale points and optionally convert them to integers. """ if convertToInteger: points = [ (int(round(x * scale)), int(round(y * scale))) for (x, y) in points ] else: points = [(x * scale, y ...
[ "Scale", "points", "and", "optionally", "convert", "them", "to", "integers", "." ]
typemytype/booleanOperations
python
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L1007-L1018
[ "def", "_scalePoints", "(", "points", ",", "scale", "=", "1", ",", "convertToInteger", "=", "True", ")", ":", "if", "convertToInteger", ":", "points", "=", "[", "(", "int", "(", "round", "(", "x", "*", "scale", ")", ")", ",", "int", "(", "round", "...
b7d9fc95c155824662f4a0020e653c77b7723d24
train
_scaleSinglePoint
Scale a single point
Lib/booleanOperations/flatten.py
def _scaleSinglePoint(point, scale=1, convertToInteger=True): """ Scale a single point """ x, y = point if convertToInteger: return int(round(x * scale)), int(round(y * scale)) else: return (x * scale, y * scale)
def _scaleSinglePoint(point, scale=1, convertToInteger=True): """ Scale a single point """ x, y = point if convertToInteger: return int(round(x * scale)), int(round(y * scale)) else: return (x * scale, y * scale)
[ "Scale", "a", "single", "point" ]
typemytype/booleanOperations
python
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L1021-L1029
[ "def", "_scaleSinglePoint", "(", "point", ",", "scale", "=", "1", ",", "convertToInteger", "=", "True", ")", ":", "x", ",", "y", "=", "point", "if", "convertToInteger", ":", "return", "int", "(", "round", "(", "x", "*", "scale", ")", ")", ",", "int",...
b7d9fc95c155824662f4a0020e653c77b7723d24
train
_flattenSegment
Flatten the curve segment int a list of points. The first and last points in the segment must be on curves. The returned list of points will not include the first on curve point. false curves (where the off curves are not any different from the on curves) must not be sent here. duplicate points ...
Lib/booleanOperations/flatten.py
def _flattenSegment(segment, approximateSegmentLength=_approximateSegmentLength): """ Flatten the curve segment int a list of points. The first and last points in the segment must be on curves. The returned list of points will not include the first on curve point. false curves (where the off cur...
def _flattenSegment(segment, approximateSegmentLength=_approximateSegmentLength): """ Flatten the curve segment int a list of points. The first and last points in the segment must be on curves. The returned list of points will not include the first on curve point. false curves (where the off cur...
[ "Flatten", "the", "curve", "segment", "int", "a", "list", "of", "points", ".", "The", "first", "and", "last", "points", "in", "the", "segment", "must", "be", "on", "curves", ".", "The", "returned", "list", "of", "points", "will", "not", "include", "the",...
typemytype/booleanOperations
python
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L1059-L1086
[ "def", "_flattenSegment", "(", "segment", ",", "approximateSegmentLength", "=", "_approximateSegmentLength", ")", ":", "onCurve1", ",", "offCurve1", ",", "offCurve2", ",", "onCurve2", "=", "segment", "if", "_pointOnLine", "(", "onCurve1", ",", "onCurve2", ",", "of...
b7d9fc95c155824662f4a0020e653c77b7723d24
train
_estimateCubicCurveLength
Estimate the length of this curve by iterating through it and averaging the length of the flat bits.
Lib/booleanOperations/flatten.py
def _estimateCubicCurveLength(pt0, pt1, pt2, pt3, precision=10): """ Estimate the length of this curve by iterating through it and averaging the length of the flat bits. """ points = [] length = 0 step = 1.0 / precision factors = range(0, precision + 1) for i in factors: poin...
def _estimateCubicCurveLength(pt0, pt1, pt2, pt3, precision=10): """ Estimate the length of this curve by iterating through it and averaging the length of the flat bits. """ points = [] length = 0 step = 1.0 / precision factors = range(0, precision + 1) for i in factors: poin...
[ "Estimate", "the", "length", "of", "this", "curve", "by", "iterating", "through", "it", "and", "averaging", "the", "length", "of", "the", "flat", "bits", "." ]
typemytype/booleanOperations
python
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L1097-L1112
[ "def", "_estimateCubicCurveLength", "(", "pt0", ",", "pt1", ",", "pt2", ",", "pt3", ",", "precision", "=", "10", ")", ":", "points", "=", "[", "]", "length", "=", "0", "step", "=", "1.0", "/", "precision", "factors", "=", "range", "(", "0", ",", "p...
b7d9fc95c155824662f4a0020e653c77b7723d24
train
_mid
(Point, Point) -> Point Return the point that lies in between the two input points.
Lib/booleanOperations/flatten.py
def _mid(pt1, pt2): """ (Point, Point) -> Point Return the point that lies in between the two input points. """ (x0, y0), (x1, y1) = pt1, pt2 return 0.5 * (x0 + x1), 0.5 * (y0 + y1)
def _mid(pt1, pt2): """ (Point, Point) -> Point Return the point that lies in between the two input points. """ (x0, y0), (x1, y1) = pt1, pt2 return 0.5 * (x0 + x1), 0.5 * (y0 + y1)
[ "(", "Point", "Point", ")", "-", ">", "Point", "Return", "the", "point", "that", "lies", "in", "between", "the", "two", "input", "points", "." ]
typemytype/booleanOperations
python
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L1115-L1121
[ "def", "_mid", "(", "pt1", ",", "pt2", ")", ":", "(", "x0", ",", "y0", ")", ",", "(", "x1", ",", "y1", ")", "=", "pt1", ",", "pt2", "return", "0.5", "*", "(", "x0", "+", "x1", ")", ",", "0.5", "*", "(", "y0", "+", "y1", ")" ]
b7d9fc95c155824662f4a0020e653c77b7723d24
train
InputSegment.split
Split the segment according the t values
Lib/booleanOperations/flatten.py
def split(self, tValues): """ Split the segment according the t values """ if self.segmentType == "curve": on1 = self.previousOnCurve off1 = self.points[0].coordinates off2 = self.points[1].coordinates on2 = self.points[2].coordinates ...
def split(self, tValues): """ Split the segment according the t values """ if self.segmentType == "curve": on1 = self.previousOnCurve off1 = self.points[0].coordinates off2 = self.points[1].coordinates on2 = self.points[2].coordinates ...
[ "Split", "the", "segment", "according", "the", "t", "values" ]
typemytype/booleanOperations
python
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L211-L237
[ "def", "split", "(", "self", ",", "tValues", ")", ":", "if", "self", ".", "segmentType", "==", "\"curve\"", ":", "on1", "=", "self", ".", "previousOnCurve", "off1", "=", "self", ".", "points", "[", "0", "]", ".", "coordinates", "off2", "=", "self", "...
b7d9fc95c155824662f4a0020e653c77b7723d24
train
InputSegment.tValueForPoint
get a t values for a given point required: the point must be a point on the curve. in an overlap cause the point will be an intersection points wich is alwasy a point on the curve
Lib/booleanOperations/flatten.py
def tValueForPoint(self, point): """ get a t values for a given point required: the point must be a point on the curve. in an overlap cause the point will be an intersection points wich is alwasy a point on the curve """ if self.segmentType == "curve": ...
def tValueForPoint(self, point): """ get a t values for a given point required: the point must be a point on the curve. in an overlap cause the point will be an intersection points wich is alwasy a point on the curve """ if self.segmentType == "curve": ...
[ "get", "a", "t", "values", "for", "a", "given", "point", "required", ":", "the", "point", "must", "be", "a", "point", "on", "the", "curve", ".", "in", "an", "overlap", "cause", "the", "point", "will", "be", "an", "intersection", "points", "wich", "is",...
typemytype/booleanOperations
python
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L239-L257
[ "def", "tValueForPoint", "(", "self", ",", "point", ")", ":", "if", "self", ".", "segmentType", "==", "\"curve\"", ":", "on1", "=", "self", ".", "previousOnCurve", "off1", "=", "self", ".", "points", "[", "0", "]", ".", "coordinates", "off2", "=", "sel...
b7d9fc95c155824662f4a0020e653c77b7723d24
train
ContourPointDataPen.getData
Return a list of normalized InputPoint objects for the contour drawn with this pen.
Lib/booleanOperations/flatten.py
def getData(self): """ Return a list of normalized InputPoint objects for the contour drawn with this pen. """ # organize the points into segments # 1. make sure there is an on curve haveOnCurve = False for point in self._points: if point.segme...
def getData(self): """ Return a list of normalized InputPoint objects for the contour drawn with this pen. """ # organize the points into segments # 1. make sure there is an on curve haveOnCurve = False for point in self._points: if point.segme...
[ "Return", "a", "list", "of", "normalized", "InputPoint", "objects", "for", "the", "contour", "drawn", "with", "this", "pen", "." ]
typemytype/booleanOperations
python
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L307-L332
[ "def", "getData", "(", "self", ")", ":", "# organize the points into segments", "# 1. make sure there is an on curve", "haveOnCurve", "=", "False", "for", "point", "in", "self", ".", "_points", ":", "if", "point", ".", "segmentType", "is", "not", "None", ":", "hav...
b7d9fc95c155824662f4a0020e653c77b7723d24
train
OutputContour.reCurveFromEntireInputContour
Match if entire input contour matches entire output contour, allowing for different start point.
Lib/booleanOperations/flatten.py
def reCurveFromEntireInputContour(self, inputContour): """ Match if entire input contour matches entire output contour, allowing for different start point. """ if self.clockwise: inputFlat = inputContour.clockwiseFlat else: inputFlat = inputContour...
def reCurveFromEntireInputContour(self, inputContour): """ Match if entire input contour matches entire output contour, allowing for different start point. """ if self.clockwise: inputFlat = inputContour.clockwiseFlat else: inputFlat = inputContour...
[ "Match", "if", "entire", "input", "contour", "matches", "entire", "output", "contour", "allowing", "for", "different", "start", "point", "." ]
typemytype/booleanOperations
python
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L496-L559
[ "def", "reCurveFromEntireInputContour", "(", "self", ",", "inputContour", ")", ":", "if", "self", ".", "clockwise", ":", "inputFlat", "=", "inputContour", ".", "clockwiseFlat", "else", ":", "inputFlat", "=", "inputContour", ".", "counterClockwiseFlat", "outputFlat",...
b7d9fc95c155824662f4a0020e653c77b7723d24
train
_is_custom_qs_manager
Checks if a function definition is a queryset manager created with the @queryset_manager decorator.
pylint_mongoengine/suppression.py
def _is_custom_qs_manager(funcdef): """Checks if a function definition is a queryset manager created with the @queryset_manager decorator.""" decors = getattr(funcdef, 'decorators', None) if decors: for dec in decors.get_children(): try: if dec.name == 'queryset_mana...
def _is_custom_qs_manager(funcdef): """Checks if a function definition is a queryset manager created with the @queryset_manager decorator.""" decors = getattr(funcdef, 'decorators', None) if decors: for dec in decors.get_children(): try: if dec.name == 'queryset_mana...
[ "Checks", "if", "a", "function", "definition", "is", "a", "queryset", "manager", "created", "with", "the" ]
jucacrispim/pylint-mongoengine
python
https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/suppression.py#L27-L40
[ "def", "_is_custom_qs_manager", "(", "funcdef", ")", ":", "decors", "=", "getattr", "(", "funcdef", ",", "'decorators'", ",", "None", ")", "if", "decors", ":", "for", "dec", "in", "decors", ".", "get_children", "(", ")", ":", "try", ":", "if", "dec", "...
b873653d1224a5748f75dd507f492f8c60d95ce3
train
_is_call2custom_manager
Checks if the call is being done to a custom queryset manager.
pylint_mongoengine/suppression.py
def _is_call2custom_manager(node): """Checks if the call is being done to a custom queryset manager.""" called = safe_infer(node.func) funcdef = getattr(called, '_proxied', None) return _is_custom_qs_manager(funcdef)
def _is_call2custom_manager(node): """Checks if the call is being done to a custom queryset manager.""" called = safe_infer(node.func) funcdef = getattr(called, '_proxied', None) return _is_custom_qs_manager(funcdef)
[ "Checks", "if", "the", "call", "is", "being", "done", "to", "a", "custom", "queryset", "manager", "." ]
jucacrispim/pylint-mongoengine
python
https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/suppression.py#L43-L47
[ "def", "_is_call2custom_manager", "(", "node", ")", ":", "called", "=", "safe_infer", "(", "node", ".", "func", ")", "funcdef", "=", "getattr", "(", "called", ",", "'_proxied'", ",", "None", ")", "return", "_is_custom_qs_manager", "(", "funcdef", ")" ]
b873653d1224a5748f75dd507f492f8c60d95ce3
train
_is_custom_manager_attribute
Checks if the attribute is a valid attribute for a queryset manager.
pylint_mongoengine/suppression.py
def _is_custom_manager_attribute(node): """Checks if the attribute is a valid attribute for a queryset manager. """ attrname = node.attrname if not name_is_from_qs(attrname): return False for attr in node.get_children(): inferred = safe_infer(attr) funcdef = getattr(inferre...
def _is_custom_manager_attribute(node): """Checks if the attribute is a valid attribute for a queryset manager. """ attrname = node.attrname if not name_is_from_qs(attrname): return False for attr in node.get_children(): inferred = safe_infer(attr) funcdef = getattr(inferre...
[ "Checks", "if", "the", "attribute", "is", "a", "valid", "attribute", "for", "a", "queryset", "manager", "." ]
jucacrispim/pylint-mongoengine
python
https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/suppression.py#L50-L64
[ "def", "_is_custom_manager_attribute", "(", "node", ")", ":", "attrname", "=", "node", ".", "attrname", "if", "not", "name_is_from_qs", "(", "attrname", ")", ":", "return", "False", "for", "attr", "in", "node", ".", "get_children", "(", ")", ":", "inferred",...
b873653d1224a5748f75dd507f492f8c60d95ce3
train
GroupPermissionService.by_group_and_perm
return by by_user_and_perm and permission name :param group_id: :param perm_name: :param db_session: :return:
ziggurat_foundations/models/services/group_permission.py
def by_group_and_perm(cls, group_id, perm_name, db_session=None): """ return by by_user_and_perm and permission name :param group_id: :param perm_name: :param db_session: :return: """ db_session = get_db_session(db_session) query = db_session.quer...
def by_group_and_perm(cls, group_id, perm_name, db_session=None): """ return by by_user_and_perm and permission name :param group_id: :param perm_name: :param db_session: :return: """ db_session = get_db_session(db_session) query = db_session.quer...
[ "return", "by", "by_user_and_perm", "and", "permission", "name" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/group_permission.py#L26-L38
[ "def", "by_group_and_perm", "(", "cls", ",", "group_id", ",", "perm_name", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "query", "=", "db_session", ".", "query", "(", "cls", ".", "model", ")", ".", ...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
serve_forever
Starts the gevent-socketio server.
gnotty/server.py
def serve_forever(django=False): """ Starts the gevent-socketio server. """ logger = getLogger("irc.dispatch") logger.setLevel(settings.LOG_LEVEL) logger.addHandler(StreamHandler()) app = IRCApplication(django) server = SocketIOServer((settings.HTTP_HOST, settings.HTTP_PORT), app) pr...
def serve_forever(django=False): """ Starts the gevent-socketio server. """ logger = getLogger("irc.dispatch") logger.setLevel(settings.LOG_LEVEL) logger.addHandler(StreamHandler()) app = IRCApplication(django) server = SocketIOServer((settings.HTTP_HOST, settings.HTTP_PORT), app) pr...
[ "Starts", "the", "gevent", "-", "socketio", "server", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/server.py#L243-L258
[ "def", "serve_forever", "(", "django", "=", "False", ")", ":", "logger", "=", "getLogger", "(", "\"irc.dispatch\"", ")", "logger", ".", "setLevel", "(", "settings", ".", "LOG_LEVEL", ")", "logger", ".", "addHandler", "(", "StreamHandler", "(", ")", ")", "a...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
kill
Attempts to shut down a previously started daemon.
gnotty/server.py
def kill(pid_file): """ Attempts to shut down a previously started daemon. """ try: with open(pid_file) as f: os.kill(int(f.read()), 9) os.remove(pid_file) except (IOError, OSError): return False return True
def kill(pid_file): """ Attempts to shut down a previously started daemon. """ try: with open(pid_file) as f: os.kill(int(f.read()), 9) os.remove(pid_file) except (IOError, OSError): return False return True
[ "Attempts", "to", "shut", "down", "a", "previously", "started", "daemon", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/server.py#L261-L271
[ "def", "kill", "(", "pid_file", ")", ":", "try", ":", "with", "open", "(", "pid_file", ")", "as", "f", ":", "os", ".", "kill", "(", "int", "(", "f", ".", "read", "(", ")", ")", ",", "9", ")", "os", ".", "remove", "(", "pid_file", ")", "except...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
run
CLI entry point. Parses args and starts the gevent-socketio server.
gnotty/server.py
def run(): """ CLI entry point. Parses args and starts the gevent-socketio server. """ settings.parse_args() pid_name = "gnotty-%s-%s.pid" % (settings.HTTP_HOST, settings.HTTP_PORT) pid_file = settings.PID_FILE or os.path.join(gettempdir(), pid_name) if settings.KILL: if kill(pid_fil...
def run(): """ CLI entry point. Parses args and starts the gevent-socketio server. """ settings.parse_args() pid_name = "gnotty-%s-%s.pid" % (settings.HTTP_HOST, settings.HTTP_PORT) pid_file = settings.PID_FILE or os.path.join(gettempdir(), pid_name) if settings.KILL: if kill(pid_fil...
[ "CLI", "entry", "point", ".", "Parses", "args", "and", "starts", "the", "gevent", "-", "socketio", "server", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/server.py#L274-L291
[ "def", "run", "(", ")", ":", "settings", ".", "parse_args", "(", ")", "pid_name", "=", "\"gnotty-%s-%s.pid\"", "%", "(", "settings", ".", "HTTP_HOST", ",", "settings", ".", "HTTP_PORT", ")", "pid_file", "=", "settings", ".", "PID_FILE", "or", "os", ".", ...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
IRCNamespace.on_start
A WebSocket session has started - create a greenlet to host the IRC client, and start it.
gnotty/server.py
def on_start(self, host, port, channel, nickname, password): """ A WebSocket session has started - create a greenlet to host the IRC client, and start it. """ self.client = WebSocketIRCClient(host, port, channel, nickname, password, self) ...
def on_start(self, host, port, channel, nickname, password): """ A WebSocket session has started - create a greenlet to host the IRC client, and start it. """ self.client = WebSocketIRCClient(host, port, channel, nickname, password, self) ...
[ "A", "WebSocket", "session", "has", "started", "-", "create", "a", "greenlet", "to", "host", "the", "IRC", "client", "and", "start", "it", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/server.py#L39-L46
[ "def", "on_start", "(", "self", ",", "host", ",", "port", ",", "channel", ",", "nickname", ",", "password", ")", ":", "self", ".", "client", "=", "WebSocketIRCClient", "(", "host", ",", "port", ",", "channel", ",", "nickname", ",", "password", ",", "se...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
IRCNamespace.disconnect
WebSocket was disconnected - leave the IRC channel.
gnotty/server.py
def disconnect(self, *args, **kwargs): """ WebSocket was disconnected - leave the IRC channel. """ quit_message = "%s %s" % (settings.GNOTTY_VERSION_STRING, settings.GNOTTY_PROJECT_URL) self.client.connection.quit(quit_message) super(IRCN...
def disconnect(self, *args, **kwargs): """ WebSocket was disconnected - leave the IRC channel. """ quit_message = "%s %s" % (settings.GNOTTY_VERSION_STRING, settings.GNOTTY_PROJECT_URL) self.client.connection.quit(quit_message) super(IRCN...
[ "WebSocket", "was", "disconnected", "-", "leave", "the", "IRC", "channel", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/server.py#L55-L62
[ "def", "disconnect", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "quit_message", "=", "\"%s %s\"", "%", "(", "settings", ".", "GNOTTY_VERSION_STRING", ",", "settings", ".", "GNOTTY_PROJECT_URL", ")", "self", ".", "client", ".", "conne...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
IRCApplication.bot_watcher
Thread (greenlet) that will try and reconnect the bot if it's not connected.
gnotty/server.py
def bot_watcher(self): """ Thread (greenlet) that will try and reconnect the bot if it's not connected. """ default_interval = 5 interval = default_interval while True: if not self.bot.connection.connected: if self.bot.reconnect(): ...
def bot_watcher(self): """ Thread (greenlet) that will try and reconnect the bot if it's not connected. """ default_interval = 5 interval = default_interval while True: if not self.bot.connection.connected: if self.bot.reconnect(): ...
[ "Thread", "(", "greenlet", ")", "that", "will", "try", "and", "reconnect", "the", "bot", "if", "it", "s", "not", "connected", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/server.py#L86-L99
[ "def", "bot_watcher", "(", "self", ")", ":", "default_interval", "=", "5", "interval", "=", "default_interval", "while", "True", ":", "if", "not", "self", ".", "bot", ".", "connection", ".", "connected", ":", "if", "self", ".", "bot", ".", "reconnect", "...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
IRCApplication.respond_webhook
Passes the request onto a bot with a webhook if the webhook path is requested.
gnotty/server.py
def respond_webhook(self, environ): """ Passes the request onto a bot with a webhook if the webhook path is requested. """ request = FieldStorage(fp=environ["wsgi.input"], environ=environ) url = environ["PATH_INFO"] params = dict([(k, request[k].value) for k in re...
def respond_webhook(self, environ): """ Passes the request onto a bot with a webhook if the webhook path is requested. """ request = FieldStorage(fp=environ["wsgi.input"], environ=environ) url = environ["PATH_INFO"] params = dict([(k, request[k].value) for k in re...
[ "Passes", "the", "request", "onto", "a", "bot", "with", "a", "webhook", "if", "the", "webhook", "path", "is", "requested", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/server.py#L101-L118
[ "def", "respond_webhook", "(", "self", ",", "environ", ")", ":", "request", "=", "FieldStorage", "(", "fp", "=", "environ", "[", "\"wsgi.input\"", "]", ",", "environ", "=", "environ", ")", "url", "=", "environ", "[", "\"PATH_INFO\"", "]", "params", "=", ...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
IRCApplication.respond_static
Serves a static file when Django isn't being used.
gnotty/server.py
def respond_static(self, environ): """ Serves a static file when Django isn't being used. """ path = os.path.normpath(environ["PATH_INFO"]) if path == "/": content = self.index() content_type = "text/html" else: path = os.path.join(os.p...
def respond_static(self, environ): """ Serves a static file when Django isn't being used. """ path = os.path.normpath(environ["PATH_INFO"]) if path == "/": content = self.index() content_type = "text/html" else: path = os.path.join(os.p...
[ "Serves", "a", "static", "file", "when", "Django", "isn", "t", "being", "used", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/server.py#L120-L136
[ "def", "respond_static", "(", "self", ",", "environ", ")", ":", "path", "=", "os", ".", "path", ".", "normpath", "(", "environ", "[", "\"PATH_INFO\"", "]", ")", "if", "path", "==", "\"/\"", ":", "content", "=", "self", ".", "index", "(", ")", "conten...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
IRCApplication.index
Loads the chat interface template when Django isn't being used, manually dealing with the Django template bits.
gnotty/server.py
def index(self): """ Loads the chat interface template when Django isn't being used, manually dealing with the Django template bits. """ root_dir = os.path.dirname(__file__) template_dir = os.path.join(root_dir, "templates", "gnotty") with open(os.path.join(templa...
def index(self): """ Loads the chat interface template when Django isn't being used, manually dealing with the Django template bits. """ root_dir = os.path.dirname(__file__) template_dir = os.path.join(root_dir, "templates", "gnotty") with open(os.path.join(templa...
[ "Loads", "the", "chat", "interface", "template", "when", "Django", "isn", "t", "being", "used", "manually", "dealing", "with", "the", "Django", "template", "bits", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/server.py#L138-L164
[ "def", "index", "(", "self", ")", ":", "root_dir", "=", "os", ".", "path", ".", "dirname", "(", "__file__", ")", "template_dir", "=", "os", ".", "path", ".", "join", "(", "root_dir", ",", "\"templates\"", ",", "\"gnotty\"", ")", "with", "open", "(", ...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
IRCApplication.authorized
If we're running Django and ``GNOTTY_LOGIN_REQUIRED`` is set to ``True``, pull the session cookie from the environment and validate that the user is authenticated.
gnotty/server.py
def authorized(self, environ): """ If we're running Django and ``GNOTTY_LOGIN_REQUIRED`` is set to ``True``, pull the session cookie from the environment and validate that the user is authenticated. """ if self.django and settings.LOGIN_REQUIRED: try: ...
def authorized(self, environ): """ If we're running Django and ``GNOTTY_LOGIN_REQUIRED`` is set to ``True``, pull the session cookie from the environment and validate that the user is authenticated. """ if self.django and settings.LOGIN_REQUIRED: try: ...
[ "If", "we", "re", "running", "Django", "and", "GNOTTY_LOGIN_REQUIRED", "is", "set", "to", "True", "pull", "the", "session", "cookie", "from", "the", "environment", "and", "validate", "that", "the", "user", "is", "authenticated", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/server.py#L186-L207
[ "def", "authorized", "(", "self", ",", "environ", ")", ":", "if", "self", ".", "django", "and", "settings", ".", "LOGIN_REQUIRED", ":", "try", ":", "from", "django", ".", "conf", "import", "settings", "as", "django_settings", "from", "django", ".", "contri...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
Migration.forwards
Write your forwards methods here.
gnotty/migrations/0003_joins_leaves.py
def forwards(self, orm): "Write your forwards methods here." # Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..." if not db.dry_run: orm['gnotty.IRCMessage'].objects.filter(message="joins").update(join_or_leave=True) orm['gnotty.IRCMessage...
def forwards(self, orm): "Write your forwards methods here." # Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..." if not db.dry_run: orm['gnotty.IRCMessage'].objects.filter(message="joins").update(join_or_leave=True) orm['gnotty.IRCMessage...
[ "Write", "your", "forwards", "methods", "here", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/migrations/0003_joins_leaves.py#L9-L14
[ "def", "forwards", "(", "self", ",", "orm", ")", ":", "# Note: Remember to use orm['appname.ModelName'] rather than \"from appname.models...\"", "if", "not", "db", ".", "dry_run", ":", "orm", "[", "'gnotty.IRCMessage'", "]", ".", "objects", ".", "filter", "(", "messag...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
resource_permissions_for_users
Returns permission tuples that match one of passed permission names perm_names - list of permissions that can be matched user_ids - restrict to specific users group_ids - restrict to specific groups resource_ids - restrict to specific resources limit_group_permissions - should be used if we do not w...
ziggurat_foundations/permissions.py
def resource_permissions_for_users( models_proxy, perm_names, resource_ids=None, user_ids=None, group_ids=None, resource_types=None, limit_group_permissions=False, skip_user_perms=False, skip_group_perms=False, db_session=None, ): """ Returns permission tuples that match ...
def resource_permissions_for_users( models_proxy, perm_names, resource_ids=None, user_ids=None, group_ids=None, resource_types=None, limit_group_permissions=False, skip_user_perms=False, skip_group_perms=False, db_session=None, ): """ Returns permission tuples that match ...
[ "Returns", "permission", "tuples", "that", "match", "one", "of", "passed", "permission", "names", "perm_names", "-", "list", "of", "permissions", "that", "can", "be", "matched", "user_ids", "-", "restrict", "to", "specific", "users", "group_ids", "-", "restrict"...
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/permissions.py#L59-L186
[ "def", "resource_permissions_for_users", "(", "models_proxy", ",", "perm_names", ",", "resource_ids", "=", "None", ",", "user_ids", "=", "None", ",", "group_ids", "=", "None", ",", "resource_types", "=", "None", ",", "limit_group_permissions", "=", "False", ",", ...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
permission_to_04_acls
Legacy acl format kept for bw. compatibility :param permissions: :return:
ziggurat_foundations/permissions.py
def permission_to_04_acls(permissions): """ Legacy acl format kept for bw. compatibility :param permissions: :return: """ acls = [] for perm in permissions: if perm.type == "user": acls.append((perm.user.id, perm.perm_name)) elif perm.type == "group": ...
def permission_to_04_acls(permissions): """ Legacy acl format kept for bw. compatibility :param permissions: :return: """ acls = [] for perm in permissions: if perm.type == "user": acls.append((perm.user.id, perm.perm_name)) elif perm.type == "group": ...
[ "Legacy", "acl", "format", "kept", "for", "bw", ".", "compatibility", ":", "param", "permissions", ":", ":", "return", ":" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/permissions.py#L189-L201
[ "def", "permission_to_04_acls", "(", "permissions", ")", ":", "acls", "=", "[", "]", "for", "perm", "in", "permissions", ":", "if", "perm", ".", "type", "==", "\"user\"", ":", "acls", ".", "append", "(", "(", "perm", ".", "user", ".", "id", ",", "per...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
permission_to_pyramid_acls
Returns a list of permissions in a format understood by pyramid :param permissions: :return:
ziggurat_foundations/permissions.py
def permission_to_pyramid_acls(permissions): """ Returns a list of permissions in a format understood by pyramid :param permissions: :return: """ acls = [] for perm in permissions: if perm.type == "user": acls.append((Allow, perm.user.id, perm.perm_name)) elif per...
def permission_to_pyramid_acls(permissions): """ Returns a list of permissions in a format understood by pyramid :param permissions: :return: """ acls = [] for perm in permissions: if perm.type == "user": acls.append((Allow, perm.user.id, perm.perm_name)) elif per...
[ "Returns", "a", "list", "of", "permissions", "in", "a", "format", "understood", "by", "pyramid", ":", "param", "permissions", ":", ":", "return", ":" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/permissions.py#L204-L216
[ "def", "permission_to_pyramid_acls", "(", "permissions", ")", ":", "acls", "=", "[", "]", "for", "perm", "in", "permissions", ":", "if", "perm", ".", "type", "==", "\"user\"", ":", "acls", ".", "append", "(", "(", "Allow", ",", "perm", ".", "user", "."...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ChunkBy
[ { 'self': [1, 1, 3, 3, 1, 1], 'f': lambda x: x%2, 'assert': lambda ret: ret == [[1, 1], [3, 3], [1, 1]] } ]
linq/standard/general.py
def ChunkBy(self, f=None): """ [ { 'self': [1, 1, 3, 3, 1, 1], 'f': lambda x: x%2, 'assert': lambda ret: ret == [[1, 1], [3, 3], [1, 1]] } ] """ if f is None: return _chunk(self) if is_to_destruct(f): f = destruct_func(f) r...
def ChunkBy(self, f=None): """ [ { 'self': [1, 1, 3, 3, 1, 1], 'f': lambda x: x%2, 'assert': lambda ret: ret == [[1, 1], [3, 3], [1, 1]] } ] """ if f is None: return _chunk(self) if is_to_destruct(f): f = destruct_func(f) r...
[ "[", "{", "self", ":", "[", "1", "1", "3", "3", "1", "1", "]", "f", ":", "lambda", "x", ":", "x%2", "assert", ":", "lambda", "ret", ":", "ret", "==", "[[", "1", "1", "]", "[", "3", "3", "]", "[", "1", "1", "]]", "}", "]" ]
Xython/Linq.py
python
https://github.com/Xython/Linq.py/blob/ffb65f92f1df0d8161d5f835f5947554f6f33d72/linq/standard/general.py#L88-L102
[ "def", "ChunkBy", "(", "self", ",", "f", "=", "None", ")", ":", "if", "f", "is", "None", ":", "return", "_chunk", "(", "self", ")", "if", "is_to_destruct", "(", "f", ")", ":", "f", "=", "destruct_func", "(", "f", ")", "return", "_chunk", "(", "se...
ffb65f92f1df0d8161d5f835f5947554f6f33d72
train
GroupBy
[ { 'self': [1, 2, 3], 'f': lambda x: x%2, 'assert': lambda ret: ret[0] == [2] and ret[1] == [1, 3] } ]
linq/standard/general.py
def GroupBy(self: Iterable, f=None): """ [ { 'self': [1, 2, 3], 'f': lambda x: x%2, 'assert': lambda ret: ret[0] == [2] and ret[1] == [1, 3] } ] """ if f and is_to_destruct(f): f = destruct_func(f) return _group_by(self, f)
def GroupBy(self: Iterable, f=None): """ [ { 'self': [1, 2, 3], 'f': lambda x: x%2, 'assert': lambda ret: ret[0] == [2] and ret[1] == [1, 3] } ] """ if f and is_to_destruct(f): f = destruct_func(f) return _group_by(self, f)
[ "[", "{", "self", ":", "[", "1", "2", "3", "]", "f", ":", "lambda", "x", ":", "x%2", "assert", ":", "lambda", "ret", ":", "ret", "[", "0", "]", "==", "[", "2", "]", "and", "ret", "[", "1", "]", "==", "[", "1", "3", "]", "}", "]" ]
Xython/Linq.py
python
https://github.com/Xython/Linq.py/blob/ffb65f92f1df0d8161d5f835f5947554f6f33d72/linq/standard/general.py#L111-L123
[ "def", "GroupBy", "(", "self", ":", "Iterable", ",", "f", "=", "None", ")", ":", "if", "f", "and", "is_to_destruct", "(", "f", ")", ":", "f", "=", "destruct_func", "(", "f", ")", "return", "_group_by", "(", "self", ",", "f", ")" ]
ffb65f92f1df0d8161d5f835f5947554f6f33d72
train
Take
[ { 'self': [1, 2, 3], 'n': 2, 'assert': lambda ret: list(ret) == [1, 2] } ]
linq/standard/general.py
def Take(self: Iterable, n): """ [ { 'self': [1, 2, 3], 'n': 2, 'assert': lambda ret: list(ret) == [1, 2] } ] """ for i, e in enumerate(self): if i == n: break yield e
def Take(self: Iterable, n): """ [ { 'self': [1, 2, 3], 'n': 2, 'assert': lambda ret: list(ret) == [1, 2] } ] """ for i, e in enumerate(self): if i == n: break yield e
[ "[", "{", "self", ":", "[", "1", "2", "3", "]", "n", ":", "2", "assert", ":", "lambda", "ret", ":", "list", "(", "ret", ")", "==", "[", "1", "2", "]", "}", "]" ]
Xython/Linq.py
python
https://github.com/Xython/Linq.py/blob/ffb65f92f1df0d8161d5f835f5947554f6f33d72/linq/standard/general.py#L127-L141
[ "def", "Take", "(", "self", ":", "Iterable", ",", "n", ")", ":", "for", "i", ",", "e", "in", "enumerate", "(", "self", ")", ":", "if", "i", "==", "n", ":", "break", "yield", "e" ]
ffb65f92f1df0d8161d5f835f5947554f6f33d72
train
TakeIf
[ { 'self': [1, 2, 3], 'f': lambda e: e%2, 'assert': lambda ret: list(ret) == [1, 3] } ]
linq/standard/general.py
def TakeIf(self: Iterable, f): """ [ { 'self': [1, 2, 3], 'f': lambda e: e%2, 'assert': lambda ret: list(ret) == [1, 3] } ] """ if is_to_destruct(f): f = destruct_func(f) return (e for e in self if f(e))
def TakeIf(self: Iterable, f): """ [ { 'self': [1, 2, 3], 'f': lambda e: e%2, 'assert': lambda ret: list(ret) == [1, 3] } ] """ if is_to_destruct(f): f = destruct_func(f) return (e for e in self if f(e))
[ "[", "{", "self", ":", "[", "1", "2", "3", "]", "f", ":", "lambda", "e", ":", "e%2", "assert", ":", "lambda", "ret", ":", "list", "(", "ret", ")", "==", "[", "1", "3", "]", "}", "]" ]
Xython/Linq.py
python
https://github.com/Xython/Linq.py/blob/ffb65f92f1df0d8161d5f835f5947554f6f33d72/linq/standard/general.py#L145-L158
[ "def", "TakeIf", "(", "self", ":", "Iterable", ",", "f", ")", ":", "if", "is_to_destruct", "(", "f", ")", ":", "f", "=", "destruct_func", "(", "f", ")", "return", "(", "e", "for", "e", "in", "self", "if", "f", "(", "e", ")", ")" ]
ffb65f92f1df0d8161d5f835f5947554f6f33d72
train
TakeWhile
[ { 'self': [1, 2, 3, 4, 5], 'f': lambda x: x < 4, 'assert': lambda ret: list(ret) == [1, 2, 3] } ]
linq/standard/general.py
def TakeWhile(self: Iterable, f): """ [ { 'self': [1, 2, 3, 4, 5], 'f': lambda x: x < 4, 'assert': lambda ret: list(ret) == [1, 2, 3] } ] """ if is_to_destruct(f): f = destruct_func(f) for e in self: if not f(e): ...
def TakeWhile(self: Iterable, f): """ [ { 'self': [1, 2, 3, 4, 5], 'f': lambda x: x < 4, 'assert': lambda ret: list(ret) == [1, 2, 3] } ] """ if is_to_destruct(f): f = destruct_func(f) for e in self: if not f(e): ...
[ "[", "{", "self", ":", "[", "1", "2", "3", "4", "5", "]", "f", ":", "lambda", "x", ":", "x", "<", "4", "assert", ":", "lambda", "ret", ":", "list", "(", "ret", ")", "==", "[", "1", "2", "3", "]", "}", "]" ]
Xython/Linq.py
python
https://github.com/Xython/Linq.py/blob/ffb65f92f1df0d8161d5f835f5947554f6f33d72/linq/standard/general.py#L162-L178
[ "def", "TakeWhile", "(", "self", ":", "Iterable", ",", "f", ")", ":", "if", "is_to_destruct", "(", "f", ")", ":", "f", "=", "destruct_func", "(", "f", ")", "for", "e", "in", "self", ":", "if", "not", "f", "(", "e", ")", ":", "break", "yield", "...
ffb65f92f1df0d8161d5f835f5947554f6f33d72
train
Drop
[ { 'self': [1, 2, 3, 4, 5], 'n': 3, 'assert': lambda ret: list(ret) == [1, 2] } ]
linq/standard/general.py
def Drop(self: Iterable, n): """ [ { 'self': [1, 2, 3, 4, 5], 'n': 3, 'assert': lambda ret: list(ret) == [1, 2] } ] """ con = tuple(self) n = len(con) - n if n <= 0: yield from con else: for i, e in enumerate(con): ...
def Drop(self: Iterable, n): """ [ { 'self': [1, 2, 3, 4, 5], 'n': 3, 'assert': lambda ret: list(ret) == [1, 2] } ] """ con = tuple(self) n = len(con) - n if n <= 0: yield from con else: for i, e in enumerate(con): ...
[ "[", "{", "self", ":", "[", "1", "2", "3", "4", "5", "]", "n", ":", "3", "assert", ":", "lambda", "ret", ":", "list", "(", "ret", ")", "==", "[", "1", "2", "]", "}", "]" ]
Xython/Linq.py
python
https://github.com/Xython/Linq.py/blob/ffb65f92f1df0d8161d5f835f5947554f6f33d72/linq/standard/general.py#L187-L205
[ "def", "Drop", "(", "self", ":", "Iterable", ",", "n", ")", ":", "con", "=", "tuple", "(", "self", ")", "n", "=", "len", "(", "con", ")", "-", "n", "if", "n", "<=", "0", ":", "yield", "from", "con", "else", ":", "for", "i", ",", "e", "in", ...
ffb65f92f1df0d8161d5f835f5947554f6f33d72
train
Skip
[ { 'self': [1, 2, 3, 4, 5], 'n': 3, 'assert': lambda ret: list(ret) == [4, 5] } ]
linq/standard/general.py
def Skip(self: Iterable, n): """ [ { 'self': [1, 2, 3, 4, 5], 'n': 3, 'assert': lambda ret: list(ret) == [4, 5] } ] """ con = iter(self) for i, _ in enumerate(con): if i == n: break retur...
def Skip(self: Iterable, n): """ [ { 'self': [1, 2, 3, 4, 5], 'n': 3, 'assert': lambda ret: list(ret) == [4, 5] } ] """ con = iter(self) for i, _ in enumerate(con): if i == n: break retur...
[ "[", "{", "self", ":", "[", "1", "2", "3", "4", "5", "]", "n", ":", "3", "assert", ":", "lambda", "ret", ":", "list", "(", "ret", ")", "==", "[", "4", "5", "]", "}", "]" ]
Xython/Linq.py
python
https://github.com/Xython/Linq.py/blob/ffb65f92f1df0d8161d5f835f5947554f6f33d72/linq/standard/general.py#L209-L223
[ "def", "Skip", "(", "self", ":", "Iterable", ",", "n", ")", ":", "con", "=", "iter", "(", "self", ")", "for", "i", ",", "_", "in", "enumerate", "(", "con", ")", ":", "if", "i", "==", "n", ":", "break", "return", "con" ]
ffb65f92f1df0d8161d5f835f5947554f6f33d72
train
Shift
[ { 'self': [1, 2, 3, 4, 5], 'n': 3, 'assert': lambda ret: list(ret) == [4, 5, 1, 2, 3] } ]
linq/standard/general.py
def Shift(self, n): """ [ { 'self': [1, 2, 3, 4, 5], 'n': 3, 'assert': lambda ret: list(ret) == [4, 5, 1, 2, 3] } ] """ headn = tuple(Take(self, n)) yield from self yield from headn
def Shift(self, n): """ [ { 'self': [1, 2, 3, 4, 5], 'n': 3, 'assert': lambda ret: list(ret) == [4, 5, 1, 2, 3] } ] """ headn = tuple(Take(self, n)) yield from self yield from headn
[ "[", "{", "self", ":", "[", "1", "2", "3", "4", "5", "]", "n", ":", "3", "assert", ":", "lambda", "ret", ":", "list", "(", "ret", ")", "==", "[", "4", "5", "1", "2", "3", "]", "}", "]" ]
Xython/Linq.py
python
https://github.com/Xython/Linq.py/blob/ffb65f92f1df0d8161d5f835f5947554f6f33d72/linq/standard/general.py#L227-L239
[ "def", "Shift", "(", "self", ",", "n", ")", ":", "headn", "=", "tuple", "(", "Take", "(", "self", ",", "n", ")", ")", "yield", "from", "self", "yield", "from", "headn" ]
ffb65f92f1df0d8161d5f835f5947554f6f33d72
train
Concat
[ { 'self': [1, 2, 3], ':args': [[4, 5, 6], [7, 8, 9]], 'assert': lambda ret: list(ret) == [1, 2, 3, 4, 5, 6, 7, 8, 9] } ]
linq/standard/general.py
def Concat(self: Iterable, *others): """ [ { 'self': [1, 2, 3], ':args': [[4, 5, 6], [7, 8, 9]], 'assert': lambda ret: list(ret) == [1, 2, 3, 4, 5, 6, 7, 8, 9] } ] """ return concat_generator(self, *[unbox_if_flow(other) for other in others])
def Concat(self: Iterable, *others): """ [ { 'self': [1, 2, 3], ':args': [[4, 5, 6], [7, 8, 9]], 'assert': lambda ret: list(ret) == [1, 2, 3, 4, 5, 6, 7, 8, 9] } ] """ return concat_generator(self, *[unbox_if_flow(other) for other in others])
[ "[", "{", "self", ":", "[", "1", "2", "3", "]", ":", "args", ":", "[[", "4", "5", "6", "]", "[", "7", "8", "9", "]]", "assert", ":", "lambda", "ret", ":", "list", "(", "ret", ")", "==", "[", "1", "2", "3", "4", "5", "6", "7", "8", "9"...
Xython/Linq.py
python
https://github.com/Xython/Linq.py/blob/ffb65f92f1df0d8161d5f835f5947554f6f33d72/linq/standard/general.py#L243-L253
[ "def", "Concat", "(", "self", ":", "Iterable", ",", "*", "others", ")", ":", "return", "concat_generator", "(", "self", ",", "*", "[", "unbox_if_flow", "(", "other", ")", "for", "other", "in", "others", "]", ")" ]
ffb65f92f1df0d8161d5f835f5947554f6f33d72
train
MongoEngineChecker._called_thru_default_qs
Checks if an attribute is being accessed throught the default queryset manager, ie: MyClass.objects.filter(some='value')
pylint_mongoengine/checkers/mongoengine.py
def _called_thru_default_qs(self, node): """Checks if an attribute is being accessed throught the default queryset manager, ie: MyClass.objects.filter(some='value')""" last_child = node.last_child() if not last_child: return False # the default qs manager is called '...
def _called_thru_default_qs(self, node): """Checks if an attribute is being accessed throught the default queryset manager, ie: MyClass.objects.filter(some='value')""" last_child = node.last_child() if not last_child: return False # the default qs manager is called '...
[ "Checks", "if", "an", "attribute", "is", "being", "accessed", "throught", "the", "default", "queryset", "manager", "ie", ":", "MyClass", ".", "objects", ".", "filter", "(", "some", "=", "value", ")" ]
jucacrispim/pylint-mongoengine
python
https://github.com/jucacrispim/pylint-mongoengine/blob/b873653d1224a5748f75dd507f492f8c60d95ce3/pylint_mongoengine/checkers/mongoengine.py#L46-L64
[ "def", "_called_thru_default_qs", "(", "self", ",", "node", ")", ":", "last_child", "=", "node", ".", "last_child", "(", ")", "if", "not", "last_child", ":", "return", "False", "# the default qs manager is called 'objects', we check for it here", "attrname", "=", "get...
b873653d1224a5748f75dd507f492f8c60d95ce3
train
BaseService.all
returns all objects of specific type - will work correctly with sqlalchemy inheritance models, you should normally use models base_query() instead of this function its for bw. compat purposes :param klass: :param db_session: :return:
ziggurat_foundations/models/services/__init__.py
def all(cls, klass, db_session=None): """ returns all objects of specific type - will work correctly with sqlalchemy inheritance models, you should normally use models base_query() instead of this function its for bw. compat purposes :param klass: :param db_session: ...
def all(cls, klass, db_session=None): """ returns all objects of specific type - will work correctly with sqlalchemy inheritance models, you should normally use models base_query() instead of this function its for bw. compat purposes :param klass: :param db_session: ...
[ "returns", "all", "objects", "of", "specific", "type", "-", "will", "work", "correctly", "with", "sqlalchemy", "inheritance", "models", "you", "should", "normally", "use", "models", "base_query", "()", "instead", "of", "this", "function", "its", "for", "bw", "...
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/__init__.py#L12-L23
[ "def", "all", "(", "cls", ",", "klass", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "return", "db_session", ".", "query", "(", "klass", ")" ]
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
BaseService.base_query
returns base query for specific service :param db_session: :return: query
ziggurat_foundations/models/services/__init__.py
def base_query(cls, db_session=None): """ returns base query for specific service :param db_session: :return: query """ db_session = get_db_session(db_session) return db_session.query(cls.model)
def base_query(cls, db_session=None): """ returns base query for specific service :param db_session: :return: query """ db_session = get_db_session(db_session) return db_session.query(cls.model)
[ "returns", "base", "query", "for", "specific", "service" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/__init__.py#L26-L34
[ "def", "base_query", "(", "cls", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "return", "db_session", ".", "query", "(", "cls", ".", "model", ")" ]
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
on
Event method wrapper for bot mixins. When a bot is constructed, its metaclass inspects all members of all base classes, and looks for methods marked with an event attribute which is assigned via this wrapper. It then stores all the methods in a dict that maps event names to lists of these methods, which...
gnotty/bots/events.py
def on(event, *args, **kwargs): """ Event method wrapper for bot mixins. When a bot is constructed, its metaclass inspects all members of all base classes, and looks for methods marked with an event attribute which is assigned via this wrapper. It then stores all the methods in a dict that maps ...
def on(event, *args, **kwargs): """ Event method wrapper for bot mixins. When a bot is constructed, its metaclass inspects all members of all base classes, and looks for methods marked with an event attribute which is assigned via this wrapper. It then stores all the methods in a dict that maps ...
[ "Event", "method", "wrapper", "for", "bot", "mixins", ".", "When", "a", "bot", "is", "constructed", "its", "metaclass", "inspects", "all", "members", "of", "all", "base", "classes", "and", "looks", "for", "methods", "marked", "with", "an", "event", "attribut...
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/events.py#L8-L22
[ "def", "on", "(", "event", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "wrapper", "(", "func", ")", ":", "for", "i", ",", "arg", "in", "args", ":", "kwargs", "[", "i", "]", "=", "arg", "func", ".", "event", "=", "Event", "(", ...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
get_db_session
utility function that attempts to return sqlalchemy session that could have been created/passed in one of few ways: * It first tries to read session attached to instance if object argument was passed * then it tries to return session passed as argument * finally tries to read pylons-like threa...
ziggurat_foundations/models/base.py
def get_db_session(session=None, obj=None): """ utility function that attempts to return sqlalchemy session that could have been created/passed in one of few ways: * It first tries to read session attached to instance if object argument was passed * then it tries to return session passed as...
def get_db_session(session=None, obj=None): """ utility function that attempts to return sqlalchemy session that could have been created/passed in one of few ways: * It first tries to read session attached to instance if object argument was passed * then it tries to return session passed as...
[ "utility", "function", "that", "attempts", "to", "return", "sqlalchemy", "session", "that", "could", "have", "been", "created", "/", "passed", "in", "one", "of", "few", "ways", ":" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/base.py#L162-L191
[ "def", "get_db_session", "(", "session", "=", "None", ",", "obj", "=", "None", ")", ":", "# try to read the session from instance", "from", "ziggurat_foundations", "import", "models", "if", "obj", ":", "return", "sa", ".", "orm", ".", "session", ".", "object_ses...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
BaseModel.get_dict
return dictionary of keys and values corresponding to this model's data - if include_keys is null the function will return all keys :param exclude_keys: (optional) is a list of columns from model that should not be returned by this function :param include_keys: (optional) is a list of c...
ziggurat_foundations/models/base.py
def get_dict(self, exclude_keys=None, include_keys=None): """ return dictionary of keys and values corresponding to this model's data - if include_keys is null the function will return all keys :param exclude_keys: (optional) is a list of columns from model that should not be re...
def get_dict(self, exclude_keys=None, include_keys=None): """ return dictionary of keys and values corresponding to this model's data - if include_keys is null the function will return all keys :param exclude_keys: (optional) is a list of columns from model that should not be re...
[ "return", "dictionary", "of", "keys", "and", "values", "corresponding", "to", "this", "model", "s", "data", "-", "if", "include_keys", "is", "null", "the", "function", "will", "return", "all", "keys" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/base.py#L24-L43
[ "def", "get_dict", "(", "self", ",", "exclude_keys", "=", "None", ",", "include_keys", "=", "None", ")", ":", "d", "=", "{", "}", "exclude_keys_list", "=", "exclude_keys", "or", "[", "]", "include_keys_list", "=", "include_keys", "or", "[", "]", "for", "...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
BaseModel.get_appstruct
return list of tuples keys and values corresponding to this model's data
ziggurat_foundations/models/base.py
def get_appstruct(self): """ return list of tuples keys and values corresponding to this model's data """ result = [] for k in self._get_keys(): result.append((k, getattr(self, k))) return result
def get_appstruct(self): """ return list of tuples keys and values corresponding to this model's data """ result = [] for k in self._get_keys(): result.append((k, getattr(self, k))) return result
[ "return", "list", "of", "tuples", "keys", "and", "values", "corresponding", "to", "this", "model", "s", "data" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/base.py#L45-L51
[ "def", "get_appstruct", "(", "self", ")", ":", "result", "=", "[", "]", "for", "k", "in", "self", ".", "_get_keys", "(", ")", ":", "result", ".", "append", "(", "(", "k", ",", "getattr", "(", "self", ",", "k", ")", ")", ")", "return", "result" ]
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
BaseModel.populate_obj
updates instance properties *for column names that exist* for this model and are keys present in passed dictionary :param appstruct: (dictionary) :param exclude_keys: (optional) is a list of columns from model that should not be updated by this function :param include_keys: (opt...
ziggurat_foundations/models/base.py
def populate_obj(self, appstruct, exclude_keys=None, include_keys=None): """ updates instance properties *for column names that exist* for this model and are keys present in passed dictionary :param appstruct: (dictionary) :param exclude_keys: (optional) is a list of columns fro...
def populate_obj(self, appstruct, exclude_keys=None, include_keys=None): """ updates instance properties *for column names that exist* for this model and are keys present in passed dictionary :param appstruct: (dictionary) :param exclude_keys: (optional) is a list of columns fro...
[ "updates", "instance", "properties", "*", "for", "column", "names", "that", "exist", "*", "for", "this", "model", "and", "are", "keys", "present", "in", "passed", "dictionary" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/base.py#L53-L73
[ "def", "populate_obj", "(", "self", ",", "appstruct", ",", "exclude_keys", "=", "None", ",", "include_keys", "=", "None", ")", ":", "exclude_keys_list", "=", "exclude_keys", "or", "[", "]", "include_keys_list", "=", "include_keys", "or", "[", "]", "for", "k"...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
BaseModel.populate_obj_from_obj
updates instance properties *for column names that exist* for this model and are properties present in passed dictionary :param instance: :param exclude_keys: (optional) is a list of columns from model that should not be updated by this function :param include_keys: (optional) i...
ziggurat_foundations/models/base.py
def populate_obj_from_obj(self, instance, exclude_keys=None, include_keys=None): """ updates instance properties *for column names that exist* for this model and are properties present in passed dictionary :param instance: :param exclude_keys: (optional) is a list of columns fro...
def populate_obj_from_obj(self, instance, exclude_keys=None, include_keys=None): """ updates instance properties *for column names that exist* for this model and are properties present in passed dictionary :param instance: :param exclude_keys: (optional) is a list of columns fro...
[ "updates", "instance", "properties", "*", "for", "column", "names", "that", "exist", "*", "for", "this", "model", "and", "are", "properties", "present", "in", "passed", "dictionary" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/base.py#L75-L95
[ "def", "populate_obj_from_obj", "(", "self", ",", "instance", ",", "exclude_keys", "=", "None", ",", "include_keys", "=", "None", ")", ":", "exclude_keys_list", "=", "exclude_keys", "or", "[", "]", "include_keys_list", "=", "include_keys", "or", "[", "]", "for...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
BaseModel.delete
Deletes the object via session, this will permanently delete the object from storage on commit :param db_session: :return:
ziggurat_foundations/models/base.py
def delete(self, db_session=None): """ Deletes the object via session, this will permanently delete the object from storage on commit :param db_session: :return: """ db_session = get_db_session(db_session, self) db_session.delete(self)
def delete(self, db_session=None): """ Deletes the object via session, this will permanently delete the object from storage on commit :param db_session: :return: """ db_session = get_db_session(db_session, self) db_session.delete(self)
[ "Deletes", "the", "object", "via", "session", "this", "will", "permanently", "delete", "the", "object", "from", "storage", "on", "commit" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/base.py#L123-L132
[ "def", "delete", "(", "self", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ",", "self", ")", "db_session", ".", "delete", "(", "self", ")" ]
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
HX711.power_down
turn off the HX711 :return: always True :rtype bool
hx711/__init__.py
def power_down(self): """ turn off the HX711 :return: always True :rtype bool """ GPIO.output(self._pd_sck, False) GPIO.output(self._pd_sck, True) time.sleep(0.01) return True
def power_down(self): """ turn off the HX711 :return: always True :rtype bool """ GPIO.output(self._pd_sck, False) GPIO.output(self._pd_sck, True) time.sleep(0.01) return True
[ "turn", "off", "the", "HX711", ":", "return", ":", "always", "True", ":", "rtype", "bool" ]
mpibpc-mroose/hx711
python
https://github.com/mpibpc-mroose/hx711/blob/2f3a39880cdd2d2fa8ba79a7f9245d1a35d89f1d/hx711/__init__.py#L91-L100
[ "def", "power_down", "(", "self", ")", ":", "GPIO", ".", "output", "(", "self", ".", "_pd_sck", ",", "False", ")", "GPIO", ".", "output", "(", "self", ".", "_pd_sck", ",", "True", ")", "time", ".", "sleep", "(", "0.01", ")", "return", "True" ]
2f3a39880cdd2d2fa8ba79a7f9245d1a35d89f1d
train
HX711.power_up
power up the HX711 :return: always True :rtype bool
hx711/__init__.py
def power_up(self): """ power up the HX711 :return: always True :rtype bool """ GPIO.output(self._pd_sck, False) time.sleep(0.01) return True
def power_up(self): """ power up the HX711 :return: always True :rtype bool """ GPIO.output(self._pd_sck, False) time.sleep(0.01) return True
[ "power", "up", "the", "HX711" ]
mpibpc-mroose/hx711
python
https://github.com/mpibpc-mroose/hx711/blob/2f3a39880cdd2d2fa8ba79a7f9245d1a35d89f1d/hx711/__init__.py#L102-L111
[ "def", "power_up", "(", "self", ")", ":", "GPIO", ".", "output", "(", "self", ".", "_pd_sck", ",", "False", ")", "time", ".", "sleep", "(", "0.01", ")", "return", "True" ]
2f3a39880cdd2d2fa8ba79a7f9245d1a35d89f1d
train
HX711.reset
reset the HX711 and prepare it for the next reading :return: True on success :rtype bool :raises GenericHX711Exception
hx711/__init__.py
def reset(self): """ reset the HX711 and prepare it for the next reading :return: True on success :rtype bool :raises GenericHX711Exception """ logging.debug("power down") self.power_down() logging.debug("power up") self.power_up() ...
def reset(self): """ reset the HX711 and prepare it for the next reading :return: True on success :rtype bool :raises GenericHX711Exception """ logging.debug("power down") self.power_down() logging.debug("power up") self.power_up() ...
[ "reset", "the", "HX711", "and", "prepare", "it", "for", "the", "next", "reading" ]
mpibpc-mroose/hx711
python
https://github.com/mpibpc-mroose/hx711/blob/2f3a39880cdd2d2fa8ba79a7f9245d1a35d89f1d/hx711/__init__.py#L113-L130
[ "def", "reset", "(", "self", ")", ":", "logging", ".", "debug", "(", "\"power down\"", ")", "self", ".", "power_down", "(", ")", "logging", ".", "debug", "(", "\"power up\"", ")", "self", ".", "power_up", "(", ")", "logging", ".", "debug", "(", "\"read...
2f3a39880cdd2d2fa8ba79a7f9245d1a35d89f1d