repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
eugene-eeo/mailthon
mailthon/helpers.py
guess
def guess(filename, fallback='application/octet-stream'): """ Using the mimetypes library, guess the mimetype and encoding for a given *filename*. If the mimetype cannot be guessed, *fallback* is assumed instead. :param filename: Filename- can be absolute path. :param fallback: A fallback mimet...
python
def guess(filename, fallback='application/octet-stream'): """ Using the mimetypes library, guess the mimetype and encoding for a given *filename*. If the mimetype cannot be guessed, *fallback* is assumed instead. :param filename: Filename- can be absolute path. :param fallback: A fallback mimet...
[ "def", "guess", "(", "filename", ",", "fallback", "=", "'application/octet-stream'", ")", ":", "guessed", ",", "encoding", "=", "mimetypes", ".", "guess_type", "(", "filename", ",", "strict", "=", "False", ")", "if", "guessed", "is", "None", ":", "return", ...
Using the mimetypes library, guess the mimetype and encoding for a given *filename*. If the mimetype cannot be guessed, *fallback* is assumed instead. :param filename: Filename- can be absolute path. :param fallback: A fallback mimetype.
[ "Using", "the", "mimetypes", "library", "guess", "the", "mimetype", "and", "encoding", "for", "a", "given", "*", "filename", "*", ".", "If", "the", "mimetype", "cannot", "be", "guessed", "*", "fallback", "*", "is", "assumed", "instead", "." ]
e3d5aef62505acb4edbc33e3378a04951c3199cb
https://github.com/eugene-eeo/mailthon/blob/e3d5aef62505acb4edbc33e3378a04951c3199cb/mailthon/helpers.py#L23-L35
train
eugene-eeo/mailthon
mailthon/helpers.py
format_addresses
def format_addresses(addrs): """ Given an iterable of addresses or name-address tuples *addrs*, return a header value that joins all of them together with a space and a comma. """ return ', '.join( formataddr(item) if isinstance(item, tuple) else item for item in addrs )
python
def format_addresses(addrs): """ Given an iterable of addresses or name-address tuples *addrs*, return a header value that joins all of them together with a space and a comma. """ return ', '.join( formataddr(item) if isinstance(item, tuple) else item for item in addrs )
[ "def", "format_addresses", "(", "addrs", ")", ":", "return", "', '", ".", "join", "(", "formataddr", "(", "item", ")", "if", "isinstance", "(", "item", ",", "tuple", ")", "else", "item", "for", "item", "in", "addrs", ")" ]
Given an iterable of addresses or name-address tuples *addrs*, return a header value that joins all of them together with a space and a comma.
[ "Given", "an", "iterable", "of", "addresses", "or", "name", "-", "address", "tuples", "*", "addrs", "*", "return", "a", "header", "value", "that", "joins", "all", "of", "them", "together", "with", "a", "space", "and", "a", "comma", "." ]
e3d5aef62505acb4edbc33e3378a04951c3199cb
https://github.com/eugene-eeo/mailthon/blob/e3d5aef62505acb4edbc33e3378a04951c3199cb/mailthon/helpers.py#L38-L47
train
eugene-eeo/mailthon
mailthon/helpers.py
stringify_address
def stringify_address(addr, encoding='utf-8'): """ Given an email address *addr*, try to encode it with ASCII. If it's not possible, encode the *local-part* with the *encoding* and the *domain* with IDNA. The result is a unicode string with the domain encoded as idna. """ if isinsta...
python
def stringify_address(addr, encoding='utf-8'): """ Given an email address *addr*, try to encode it with ASCII. If it's not possible, encode the *local-part* with the *encoding* and the *domain* with IDNA. The result is a unicode string with the domain encoded as idna. """ if isinsta...
[ "def", "stringify_address", "(", "addr", ",", "encoding", "=", "'utf-8'", ")", ":", "if", "isinstance", "(", "addr", ",", "bytes_type", ")", ":", "return", "addr", "try", ":", "addr", "=", "addr", ".", "encode", "(", "'ascii'", ")", "except", "UnicodeEnc...
Given an email address *addr*, try to encode it with ASCII. If it's not possible, encode the *local-part* with the *encoding* and the *domain* with IDNA. The result is a unicode string with the domain encoded as idna.
[ "Given", "an", "email", "address", "*", "addr", "*", "try", "to", "encode", "it", "with", "ASCII", ".", "If", "it", "s", "not", "possible", "encode", "the", "*", "local", "-", "part", "*", "with", "the", "*", "encoding", "*", "and", "the", "*", "do...
e3d5aef62505acb4edbc33e3378a04951c3199cb
https://github.com/eugene-eeo/mailthon/blob/e3d5aef62505acb4edbc33e3378a04951c3199cb/mailthon/helpers.py#L50-L73
train
eugene-eeo/mailthon
mailthon/api.py
email
def email(sender=None, receivers=(), cc=(), bcc=(), subject=None, content=None, encoding='utf8', attachments=()): """ Creates a Collection object with a HTML *content*, and *attachments*. :param content: HTML content. :param encoding: Encoding of the email. :param attachment...
python
def email(sender=None, receivers=(), cc=(), bcc=(), subject=None, content=None, encoding='utf8', attachments=()): """ Creates a Collection object with a HTML *content*, and *attachments*. :param content: HTML content. :param encoding: Encoding of the email. :param attachment...
[ "def", "email", "(", "sender", "=", "None", ",", "receivers", "=", "(", ")", ",", "cc", "=", "(", ")", ",", "bcc", "=", "(", ")", ",", "subject", "=", "None", ",", "content", "=", "None", ",", "encoding", "=", "'utf8'", ",", "attachments", "=", ...
Creates a Collection object with a HTML *content*, and *attachments*. :param content: HTML content. :param encoding: Encoding of the email. :param attachments: List of filenames to attach to the email.
[ "Creates", "a", "Collection", "object", "with", "a", "HTML", "*", "content", "*", "and", "*", "attachments", "*", "." ]
e3d5aef62505acb4edbc33e3378a04951c3199cb
https://github.com/eugene-eeo/mailthon/blob/e3d5aef62505acb4edbc33e3378a04951c3199cb/mailthon/api.py#L18-L43
train
eugene-eeo/mailthon
mailthon/api.py
postman
def postman(host, port=587, auth=(None, None), force_tls=False, options=None): """ Creates a Postman object with TLS and Auth middleware. TLS is placed before authentication because usually authentication happens and is accepted only after TLS is enabled. :param auth: Tuple of (user...
python
def postman(host, port=587, auth=(None, None), force_tls=False, options=None): """ Creates a Postman object with TLS and Auth middleware. TLS is placed before authentication because usually authentication happens and is accepted only after TLS is enabled. :param auth: Tuple of (user...
[ "def", "postman", "(", "host", ",", "port", "=", "587", ",", "auth", "=", "(", "None", ",", "None", ")", ",", "force_tls", "=", "False", ",", "options", "=", "None", ")", ":", "return", "Postman", "(", "host", "=", "host", ",", "port", "=", "port...
Creates a Postman object with TLS and Auth middleware. TLS is placed before authentication because usually authentication happens and is accepted only after TLS is enabled. :param auth: Tuple of (username, password) to be used to ``login`` to the server. :param force_tls: Whether TLS should...
[ "Creates", "a", "Postman", "object", "with", "TLS", "and", "Auth", "middleware", ".", "TLS", "is", "placed", "before", "authentication", "because", "usually", "authentication", "happens", "and", "is", "accepted", "only", "after", "TLS", "is", "enabled", "." ]
e3d5aef62505acb4edbc33e3378a04951c3199cb
https://github.com/eugene-eeo/mailthon/blob/e3d5aef62505acb4edbc33e3378a04951c3199cb/mailthon/api.py#L46-L68
train
eugene-eeo/mailthon
mailthon/enclosure.py
Enclosure.mime
def mime(self): """ Returns the finalised mime object, after applying the internal headers. Usually this is not to be overriden. """ mime = self.mime_object() self.headers.prepare(mime) return mime
python
def mime(self): """ Returns the finalised mime object, after applying the internal headers. Usually this is not to be overriden. """ mime = self.mime_object() self.headers.prepare(mime) return mime
[ "def", "mime", "(", "self", ")", ":", "mime", "=", "self", ".", "mime_object", "(", ")", "self", ".", "headers", ".", "prepare", "(", "mime", ")", "return", "mime" ]
Returns the finalised mime object, after applying the internal headers. Usually this is not to be overriden.
[ "Returns", "the", "finalised", "mime", "object", "after", "applying", "the", "internal", "headers", ".", "Usually", "this", "is", "not", "to", "be", "overriden", "." ]
e3d5aef62505acb4edbc33e3378a04951c3199cb
https://github.com/eugene-eeo/mailthon/blob/e3d5aef62505acb4edbc33e3378a04951c3199cb/mailthon/enclosure.py#L56-L64
train
eugene-eeo/mailthon
mailthon/postman.py
Session.send
def send(self, envelope): """ Send an *envelope* which may be an envelope or an enclosure-like object, see :class:`~mailthon.enclosure.Enclosure` and :class:`~mailthon.envelope.Envelope`, and returns a :class:`~mailthon.response.SendmailResponse` object. "...
python
def send(self, envelope): """ Send an *envelope* which may be an envelope or an enclosure-like object, see :class:`~mailthon.enclosure.Enclosure` and :class:`~mailthon.envelope.Envelope`, and returns a :class:`~mailthon.response.SendmailResponse` object. "...
[ "def", "send", "(", "self", ",", "envelope", ")", ":", "rejected", "=", "self", ".", "conn", ".", "sendmail", "(", "stringify_address", "(", "envelope", ".", "sender", ")", ",", "[", "stringify_address", "(", "k", ")", "for", "k", "in", "envelope", "."...
Send an *envelope* which may be an envelope or an enclosure-like object, see :class:`~mailthon.enclosure.Enclosure` and :class:`~mailthon.envelope.Envelope`, and returns a :class:`~mailthon.response.SendmailResponse` object.
[ "Send", "an", "*", "envelope", "*", "which", "may", "be", "an", "envelope", "or", "an", "enclosure", "-", "like", "object", "see", ":", "class", ":", "~mailthon", ".", "enclosure", ".", "Enclosure", "and", ":", "class", ":", "~mailthon", ".", "envelope",...
e3d5aef62505acb4edbc33e3378a04951c3199cb
https://github.com/eugene-eeo/mailthon/blob/e3d5aef62505acb4edbc33e3378a04951c3199cb/mailthon/postman.py#L37-L56
train
eugene-eeo/mailthon
mailthon/postman.py
Postman.connection
def connection(self): """ A context manager that returns a connection to the server using some *session*. """ conn = self.session(**self.options) try: for item in self.middlewares: item(conn) yield conn finally: ...
python
def connection(self): """ A context manager that returns a connection to the server using some *session*. """ conn = self.session(**self.options) try: for item in self.middlewares: item(conn) yield conn finally: ...
[ "def", "connection", "(", "self", ")", ":", "conn", "=", "self", ".", "session", "(", "*", "*", "self", ".", "options", ")", "try", ":", "for", "item", "in", "self", ".", "middlewares", ":", "item", "(", "conn", ")", "yield", "conn", "finally", ":"...
A context manager that returns a connection to the server using some *session*.
[ "A", "context", "manager", "that", "returns", "a", "connection", "to", "the", "server", "using", "some", "*", "session", "*", "." ]
e3d5aef62505acb4edbc33e3378a04951c3199cb
https://github.com/eugene-eeo/mailthon/blob/e3d5aef62505acb4edbc33e3378a04951c3199cb/mailthon/postman.py#L87-L98
train
eugene-eeo/mailthon
mailthon/headers.py
Headers.sender
def sender(self): """ Returns the sender, respecting the Resent-* headers. In any case, prefer Sender over From, meaning that if Sender is present then From is ignored, as per the RFC. """ to_fetch = ( ['Resent-Sender', 'Resent-From'] if self.resent el...
python
def sender(self): """ Returns the sender, respecting the Resent-* headers. In any case, prefer Sender over From, meaning that if Sender is present then From is ignored, as per the RFC. """ to_fetch = ( ['Resent-Sender', 'Resent-From'] if self.resent el...
[ "def", "sender", "(", "self", ")", ":", "to_fetch", "=", "(", "[", "'Resent-Sender'", ",", "'Resent-From'", "]", "if", "self", ".", "resent", "else", "[", "'Sender'", ",", "'From'", "]", ")", "for", "item", "in", "to_fetch", ":", "if", "item", "in", ...
Returns the sender, respecting the Resent-* headers. In any case, prefer Sender over From, meaning that if Sender is present then From is ignored, as per the RFC.
[ "Returns", "the", "sender", "respecting", "the", "Resent", "-", "*", "headers", ".", "In", "any", "case", "prefer", "Sender", "over", "From", "meaning", "that", "if", "Sender", "is", "present", "then", "From", "is", "ignored", "as", "per", "the", "RFC", ...
e3d5aef62505acb4edbc33e3378a04951c3199cb
https://github.com/eugene-eeo/mailthon/blob/e3d5aef62505acb4edbc33e3378a04951c3199cb/mailthon/headers.py#L42-L56
train
eugene-eeo/mailthon
mailthon/headers.py
Headers.receivers
def receivers(self): """ Returns a list of receivers, obtained from the To, Cc, and Bcc headers, respecting the Resent-* headers if the email was resent. """ attrs = ( ['Resent-To', 'Resent-Cc', 'Resent-Bcc'] if self.resent else ['To', 'Cc', 'Bcc']...
python
def receivers(self): """ Returns a list of receivers, obtained from the To, Cc, and Bcc headers, respecting the Resent-* headers if the email was resent. """ attrs = ( ['Resent-To', 'Resent-Cc', 'Resent-Bcc'] if self.resent else ['To', 'Cc', 'Bcc']...
[ "def", "receivers", "(", "self", ")", ":", "attrs", "=", "(", "[", "'Resent-To'", ",", "'Resent-Cc'", ",", "'Resent-Bcc'", "]", "if", "self", ".", "resent", "else", "[", "'To'", ",", "'Cc'", ",", "'Bcc'", "]", ")", "addrs", "=", "(", "v", "for", "v...
Returns a list of receivers, obtained from the To, Cc, and Bcc headers, respecting the Resent-* headers if the email was resent.
[ "Returns", "a", "list", "of", "receivers", "obtained", "from", "the", "To", "Cc", "and", "Bcc", "headers", "respecting", "the", "Resent", "-", "*", "headers", "if", "the", "email", "was", "resent", "." ]
e3d5aef62505acb4edbc33e3378a04951c3199cb
https://github.com/eugene-eeo/mailthon/blob/e3d5aef62505acb4edbc33e3378a04951c3199cb/mailthon/headers.py#L59-L70
train
eugene-eeo/mailthon
mailthon/headers.py
Headers.prepare
def prepare(self, mime): """ Prepares a MIME object by applying the headers to the *mime* object. Ignores any Bcc or Resent-Bcc headers. """ for key in self: if key == 'Bcc' or key == 'Resent-Bcc': continue del mime[key] ...
python
def prepare(self, mime): """ Prepares a MIME object by applying the headers to the *mime* object. Ignores any Bcc or Resent-Bcc headers. """ for key in self: if key == 'Bcc' or key == 'Resent-Bcc': continue del mime[key] ...
[ "def", "prepare", "(", "self", ",", "mime", ")", ":", "for", "key", "in", "self", ":", "if", "key", "==", "'Bcc'", "or", "key", "==", "'Resent-Bcc'", ":", "continue", "del", "mime", "[", "key", "]", "# Python 3.* email's compatibility layer will handle", "# ...
Prepares a MIME object by applying the headers to the *mime* object. Ignores any Bcc or Resent-Bcc headers.
[ "Prepares", "a", "MIME", "object", "by", "applying", "the", "headers", "to", "the", "*", "mime", "*", "object", ".", "Ignores", "any", "Bcc", "or", "Resent", "-", "Bcc", "headers", "." ]
e3d5aef62505acb4edbc33e3378a04951c3199cb
https://github.com/eugene-eeo/mailthon/blob/e3d5aef62505acb4edbc33e3378a04951c3199cb/mailthon/headers.py#L72-L90
train
eugene-eeo/mailthon
mailthon/middleware.py
tls
def tls(force=False): """ Middleware implementing TLS for SMTP connections. By default this is not forced- TLS is only used if STARTTLS is available. If the *force* parameter is set to True, it will not query the server for TLS features before upgrading to TLS. """ def middleware(conn): ...
python
def tls(force=False): """ Middleware implementing TLS for SMTP connections. By default this is not forced- TLS is only used if STARTTLS is available. If the *force* parameter is set to True, it will not query the server for TLS features before upgrading to TLS. """ def middleware(conn): ...
[ "def", "tls", "(", "force", "=", "False", ")", ":", "def", "middleware", "(", "conn", ")", ":", "if", "force", "or", "conn", ".", "has_extn", "(", "'STARTTLS'", ")", ":", "conn", ".", "starttls", "(", ")", "conn", ".", "ehlo", "(", ")", "return", ...
Middleware implementing TLS for SMTP connections. By default this is not forced- TLS is only used if STARTTLS is available. If the *force* parameter is set to True, it will not query the server for TLS features before upgrading to TLS.
[ "Middleware", "implementing", "TLS", "for", "SMTP", "connections", ".", "By", "default", "this", "is", "not", "forced", "-", "TLS", "is", "only", "used", "if", "STARTTLS", "is", "available", ".", "If", "the", "*", "force", "*", "parameter", "is", "set", ...
e3d5aef62505acb4edbc33e3378a04951c3199cb
https://github.com/eugene-eeo/mailthon/blob/e3d5aef62505acb4edbc33e3378a04951c3199cb/mailthon/middleware.py#L14-L26
train
eugene-eeo/mailthon
mailthon/middleware.py
auth
def auth(username, password): """ Middleware implementing authentication via LOGIN. Most of the time this middleware needs to be placed *after* TLS. :param username: Username to login with. :param password: Password of the user. """ def middleware(conn): conn.login(username, pas...
python
def auth(username, password): """ Middleware implementing authentication via LOGIN. Most of the time this middleware needs to be placed *after* TLS. :param username: Username to login with. :param password: Password of the user. """ def middleware(conn): conn.login(username, pas...
[ "def", "auth", "(", "username", ",", "password", ")", ":", "def", "middleware", "(", "conn", ")", ":", "conn", ".", "login", "(", "username", ",", "password", ")", "return", "middleware" ]
Middleware implementing authentication via LOGIN. Most of the time this middleware needs to be placed *after* TLS. :param username: Username to login with. :param password: Password of the user.
[ "Middleware", "implementing", "authentication", "via", "LOGIN", ".", "Most", "of", "the", "time", "this", "middleware", "needs", "to", "be", "placed", "*", "after", "*", "TLS", "." ]
e3d5aef62505acb4edbc33e3378a04951c3199cb
https://github.com/eugene-eeo/mailthon/blob/e3d5aef62505acb4edbc33e3378a04951c3199cb/mailthon/middleware.py#L29-L40
train
ramses-tech/ramses
ramses/models.py
get_existing_model
def get_existing_model(model_name): """ Try to find existing model class named `model_name`. :param model_name: String name of the model class. """ try: model_cls = engine.get_document_cls(model_name) log.debug('Model `{}` already exists. Using existing one'.format( model_na...
python
def get_existing_model(model_name): """ Try to find existing model class named `model_name`. :param model_name: String name of the model class. """ try: model_cls = engine.get_document_cls(model_name) log.debug('Model `{}` already exists. Using existing one'.format( model_na...
[ "def", "get_existing_model", "(", "model_name", ")", ":", "try", ":", "model_cls", "=", "engine", ".", "get_document_cls", "(", "model_name", ")", "log", ".", "debug", "(", "'Model `{}` already exists. Using existing one'", ".", "format", "(", "model_name", ")", "...
Try to find existing model class named `model_name`. :param model_name: String name of the model class.
[ "Try", "to", "find", "existing", "model", "class", "named", "model_name", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/models.py#L45-L56
train
ramses-tech/ramses
ramses/models.py
prepare_relationship
def prepare_relationship(config, model_name, raml_resource): """ Create referenced model if it doesn't exist. When preparing a relationship, we check to see if the model that will be referenced already exists. If not, it is created so that it will be possible to use it in a relationship. Thus the first...
python
def prepare_relationship(config, model_name, raml_resource): """ Create referenced model if it doesn't exist. When preparing a relationship, we check to see if the model that will be referenced already exists. If not, it is created so that it will be possible to use it in a relationship. Thus the first...
[ "def", "prepare_relationship", "(", "config", ",", "model_name", ",", "raml_resource", ")", ":", "if", "get_existing_model", "(", "model_name", ")", "is", "None", ":", "plural_route", "=", "'/'", "+", "pluralize", "(", "model_name", ".", "lower", "(", ")", "...
Create referenced model if it doesn't exist. When preparing a relationship, we check to see if the model that will be referenced already exists. If not, it is created so that it will be possible to use it in a relationship. Thus the first usage of this model in RAML file must provide its schema in POST...
[ "Create", "referenced", "model", "if", "it", "doesn", "t", "exist", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/models.py#L59-L82
train
ramses-tech/ramses
ramses/models.py
generate_model_cls
def generate_model_cls(config, schema, model_name, raml_resource, es_based=True): """ Generate model class. Engine DB field types are determined using `type_fields` and only those types may be used. :param schema: Model schema dict parsed from RAML. :param model_name: String...
python
def generate_model_cls(config, schema, model_name, raml_resource, es_based=True): """ Generate model class. Engine DB field types are determined using `type_fields` and only those types may be used. :param schema: Model schema dict parsed from RAML. :param model_name: String...
[ "def", "generate_model_cls", "(", "config", ",", "schema", ",", "model_name", ",", "raml_resource", ",", "es_based", "=", "True", ")", ":", "from", "nefertari", ".", "authentication", ".", "models", "import", "AuthModelMethodsMixin", "base_cls", "=", "engine", "...
Generate model class. Engine DB field types are determined using `type_fields` and only those types may be used. :param schema: Model schema dict parsed from RAML. :param model_name: String that is used as new model's name. :param raml_resource: Instance of ramlfications.raml.ResourceNode. :pa...
[ "Generate", "model", "class", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/models.py#L85-L169
train
ramses-tech/ramses
ramses/models.py
setup_data_model
def setup_data_model(config, raml_resource, model_name): """ Setup storage/data model and return generated model class. Process follows these steps: * Resource schema is found and restructured by `resource_schema`. * Model class is generated from properties dict using util function `generat...
python
def setup_data_model(config, raml_resource, model_name): """ Setup storage/data model and return generated model class. Process follows these steps: * Resource schema is found and restructured by `resource_schema`. * Model class is generated from properties dict using util function `generat...
[ "def", "setup_data_model", "(", "config", ",", "raml_resource", ",", "model_name", ")", ":", "model_cls", "=", "get_existing_model", "(", "model_name", ")", "schema", "=", "resource_schema", "(", "raml_resource", ")", "if", "not", "schema", ":", "raise", "Except...
Setup storage/data model and return generated model class. Process follows these steps: * Resource schema is found and restructured by `resource_schema`. * Model class is generated from properties dict using util function `generate_model_cls`. :param raml_resource: Instance of ramlfication...
[ "Setup", "storage", "/", "data", "model", "and", "return", "generated", "model", "class", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/models.py#L172-L198
train
ramses-tech/ramses
ramses/models.py
handle_model_generation
def handle_model_generation(config, raml_resource): """ Generates model name and runs `setup_data_model` to get or generate actual model class. :param raml_resource: Instance of ramlfications.raml.ResourceNode. """ model_name = generate_model_name(raml_resource) try: return setup_data_m...
python
def handle_model_generation(config, raml_resource): """ Generates model name and runs `setup_data_model` to get or generate actual model class. :param raml_resource: Instance of ramlfications.raml.ResourceNode. """ model_name = generate_model_name(raml_resource) try: return setup_data_m...
[ "def", "handle_model_generation", "(", "config", ",", "raml_resource", ")", ":", "model_name", "=", "generate_model_name", "(", "raml_resource", ")", "try", ":", "return", "setup_data_model", "(", "config", ",", "raml_resource", ",", "model_name", ")", "except", "...
Generates model name and runs `setup_data_model` to get or generate actual model class. :param raml_resource: Instance of ramlfications.raml.ResourceNode.
[ "Generates", "model", "name", "and", "runs", "setup_data_model", "to", "get", "or", "generate", "actual", "model", "class", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/models.py#L201-L211
train
ramses-tech/ramses
ramses/models.py
setup_model_event_subscribers
def setup_model_event_subscribers(config, model_cls, schema): """ Set up model event subscribers. :param config: Pyramid Configurator instance. :param model_cls: Model class for which handlers should be connected. :param schema: Dict of model JSON schema. """ events_map = get_events_map() m...
python
def setup_model_event_subscribers(config, model_cls, schema): """ Set up model event subscribers. :param config: Pyramid Configurator instance. :param model_cls: Model class for which handlers should be connected. :param schema: Dict of model JSON schema. """ events_map = get_events_map() m...
[ "def", "setup_model_event_subscribers", "(", "config", ",", "model_cls", ",", "schema", ")", ":", "events_map", "=", "get_events_map", "(", ")", "model_events", "=", "schema", ".", "get", "(", "'_event_handlers'", ",", "{", "}", ")", "event_kwargs", "=", "{", ...
Set up model event subscribers. :param config: Pyramid Configurator instance. :param model_cls: Model class for which handlers should be connected. :param schema: Dict of model JSON schema.
[ "Set", "up", "model", "event", "subscribers", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/models.py#L214-L235
train
ramses-tech/ramses
ramses/models.py
setup_fields_processors
def setup_fields_processors(config, model_cls, schema): """ Set up model fields' processors. :param config: Pyramid Configurator instance. :param model_cls: Model class for field of which processors should be set up. :param schema: Dict of model JSON schema. """ properties = schema.get(...
python
def setup_fields_processors(config, model_cls, schema): """ Set up model fields' processors. :param config: Pyramid Configurator instance. :param model_cls: Model class for field of which processors should be set up. :param schema: Dict of model JSON schema. """ properties = schema.get(...
[ "def", "setup_fields_processors", "(", "config", ",", "model_cls", ",", "schema", ")", ":", "properties", "=", "schema", ".", "get", "(", "'properties'", ",", "{", "}", ")", "for", "field_name", ",", "props", "in", "properties", ".", "items", "(", ")", "...
Set up model fields' processors. :param config: Pyramid Configurator instance. :param model_cls: Model class for field of which processors should be set up. :param schema: Dict of model JSON schema.
[ "Set", "up", "model", "fields", "processors", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/models.py#L238-L274
train
ramses-tech/ramses
ramses/auth.py
_setup_ticket_policy
def _setup_ticket_policy(config, params): """ Setup Pyramid AuthTktAuthenticationPolicy. Notes: * Initial `secret` params value is considered to be a name of config param that represents a cookie name. * `auth_model.get_groups_by_userid` is used as a `callback`. * Also connects basic ...
python
def _setup_ticket_policy(config, params): """ Setup Pyramid AuthTktAuthenticationPolicy. Notes: * Initial `secret` params value is considered to be a name of config param that represents a cookie name. * `auth_model.get_groups_by_userid` is used as a `callback`. * Also connects basic ...
[ "def", "_setup_ticket_policy", "(", "config", ",", "params", ")", ":", "from", "nefertari", ".", "authentication", ".", "views", "import", "(", "TicketAuthRegisterView", ",", "TicketAuthLoginView", ",", "TicketAuthLogoutView", ")", "log", ".", "info", "(", "'Confi...
Setup Pyramid AuthTktAuthenticationPolicy. Notes: * Initial `secret` params value is considered to be a name of config param that represents a cookie name. * `auth_model.get_groups_by_userid` is used as a `callback`. * Also connects basic routes to perform authentication actions. :pa...
[ "Setup", "Pyramid", "AuthTktAuthenticationPolicy", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/auth.py#L46-L102
train
ramses-tech/ramses
ramses/auth.py
_setup_apikey_policy
def _setup_apikey_policy(config, params): """ Setup `nefertari.ApiKeyAuthenticationPolicy`. Notes: * User may provide model name in :params['user_model']: do define the name of the user model. * `auth_model.get_groups_by_token` is used to perform username and token check * `au...
python
def _setup_apikey_policy(config, params): """ Setup `nefertari.ApiKeyAuthenticationPolicy`. Notes: * User may provide model name in :params['user_model']: do define the name of the user model. * `auth_model.get_groups_by_token` is used to perform username and token check * `au...
[ "def", "_setup_apikey_policy", "(", "config", ",", "params", ")", ":", "from", "nefertari", ".", "authentication", ".", "views", "import", "(", "TokenAuthRegisterView", ",", "TokenAuthClaimView", ",", "TokenAuthResetView", ")", "log", ".", "info", "(", "'Configuri...
Setup `nefertari.ApiKeyAuthenticationPolicy`. Notes: * User may provide model name in :params['user_model']: do define the name of the user model. * `auth_model.get_groups_by_token` is used to perform username and token check * `auth_model.get_token_credentials` is used to get use...
[ "Setup", "nefertari", ".", "ApiKeyAuthenticationPolicy", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/auth.py#L105-L160
train
ramses-tech/ramses
ramses/auth.py
setup_auth_policies
def setup_auth_policies(config, raml_root): """ Setup authentication, authorization policies. Performs basic validation to check all the required values are present and performs authentication, authorization policies generation using generator functions from `AUTHENTICATION_POLICIES`. :param confi...
python
def setup_auth_policies(config, raml_root): """ Setup authentication, authorization policies. Performs basic validation to check all the required values are present and performs authentication, authorization policies generation using generator functions from `AUTHENTICATION_POLICIES`. :param confi...
[ "def", "setup_auth_policies", "(", "config", ",", "raml_root", ")", ":", "log", ".", "info", "(", "'Configuring auth policies'", ")", "secured_by_all", "=", "raml_root", ".", "secured_by", "or", "[", "]", "secured_by", "=", "[", "item", "for", "item", "in", ...
Setup authentication, authorization policies. Performs basic validation to check all the required values are present and performs authentication, authorization policies generation using generator functions from `AUTHENTICATION_POLICIES`. :param config: Pyramid Configurator instance. :param raml_ro...
[ "Setup", "authentication", "authorization", "policies", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/auth.py#L178-L217
train
ramses-tech/ramses
ramses/auth.py
get_authuser_model
def get_authuser_model(): """ Define and return AuthUser model using nefertari base classes """ from nefertari.authentication.models import AuthUserMixin from nefertari import engine class AuthUser(AuthUserMixin, engine.BaseDocument): __tablename__ = 'ramses_authuser' return AuthUser
python
def get_authuser_model(): """ Define and return AuthUser model using nefertari base classes """ from nefertari.authentication.models import AuthUserMixin from nefertari import engine class AuthUser(AuthUserMixin, engine.BaseDocument): __tablename__ = 'ramses_authuser' return AuthUser
[ "def", "get_authuser_model", "(", ")", ":", "from", "nefertari", ".", "authentication", ".", "models", "import", "AuthUserMixin", "from", "nefertari", "import", "engine", "class", "AuthUser", "(", "AuthUserMixin", ",", "engine", ".", "BaseDocument", ")", ":", "_...
Define and return AuthUser model using nefertari base classes
[ "Define", "and", "return", "AuthUser", "model", "using", "nefertari", "base", "classes" ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/auth.py#L245-L253
train
ramses-tech/ramses
ramses/acl.py
validate_permissions
def validate_permissions(perms): """ Validate :perms: contains valid permissions. :param perms: List of permission names or ALL_PERMISSIONS. """ if not isinstance(perms, (list, tuple)): perms = [perms] valid_perms = set(PERMISSIONS.values()) if ALL_PERMISSIONS in perms: return p...
python
def validate_permissions(perms): """ Validate :perms: contains valid permissions. :param perms: List of permission names or ALL_PERMISSIONS. """ if not isinstance(perms, (list, tuple)): perms = [perms] valid_perms = set(PERMISSIONS.values()) if ALL_PERMISSIONS in perms: return p...
[ "def", "validate_permissions", "(", "perms", ")", ":", "if", "not", "isinstance", "(", "perms", ",", "(", "list", ",", "tuple", ")", ")", ":", "perms", "=", "[", "perms", "]", "valid_perms", "=", "set", "(", "PERMISSIONS", ".", "values", "(", ")", ")...
Validate :perms: contains valid permissions. :param perms: List of permission names or ALL_PERMISSIONS.
[ "Validate", ":", "perms", ":", "contains", "valid", "permissions", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/acl.py#L29-L43
train
ramses-tech/ramses
ramses/acl.py
parse_permissions
def parse_permissions(perms): """ Parse permissions ("perms") which are either exact permission names or the keyword 'all'. :param perms: List or comma-separated string of nefertari permission names, or 'all' """ if isinstance(perms, six.string_types): perms = perms.split(',') p...
python
def parse_permissions(perms): """ Parse permissions ("perms") which are either exact permission names or the keyword 'all'. :param perms: List or comma-separated string of nefertari permission names, or 'all' """ if isinstance(perms, six.string_types): perms = perms.split(',') p...
[ "def", "parse_permissions", "(", "perms", ")", ":", "if", "isinstance", "(", "perms", ",", "six", ".", "string_types", ")", ":", "perms", "=", "perms", ".", "split", "(", "','", ")", "perms", "=", "[", "perm", ".", "strip", "(", ")", ".", "lower", ...
Parse permissions ("perms") which are either exact permission names or the keyword 'all'. :param perms: List or comma-separated string of nefertari permission names, or 'all'
[ "Parse", "permissions", "(", "perms", ")", "which", "are", "either", "exact", "permission", "names", "or", "the", "keyword", "all", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/acl.py#L46-L58
train
ramses-tech/ramses
ramses/acl.py
parse_acl
def parse_acl(acl_string): """ Parse raw string :acl_string: of RAML-defined ACLs. If :acl_string: is blank or None, all permissions are given. Values of ACL action and principal are parsed using `actions` and `special_principals` maps and are looked up after `strip()` and `lower()`. ACEs in :...
python
def parse_acl(acl_string): """ Parse raw string :acl_string: of RAML-defined ACLs. If :acl_string: is blank or None, all permissions are given. Values of ACL action and principal are parsed using `actions` and `special_principals` maps and are looked up after `strip()` and `lower()`. ACEs in :...
[ "def", "parse_acl", "(", "acl_string", ")", ":", "if", "not", "acl_string", ":", "return", "[", "ALLOW_ALL", "]", "aces_list", "=", "acl_string", ".", "replace", "(", "'\\n'", ",", "';'", ")", ".", "split", "(", "';'", ")", "aces_list", "=", "[", "ace"...
Parse raw string :acl_string: of RAML-defined ACLs. If :acl_string: is blank or None, all permissions are given. Values of ACL action and principal are parsed using `actions` and `special_principals` maps and are looked up after `strip()` and `lower()`. ACEs in :acl_string: may be separated by new...
[ "Parse", "raw", "string", ":", "acl_string", ":", "of", "RAML", "-", "defined", "ACLs", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/acl.py#L61-L107
train
ramses-tech/ramses
ramses/acl.py
generate_acl
def generate_acl(config, model_cls, raml_resource, es_based=True): """ Generate an ACL. Generated ACL class has a `item_model` attribute set to :model_cls:. ACLs used for collection and item access control are generated from a first security scheme with type `x-ACL`. If :raml_resource: has no ...
python
def generate_acl(config, model_cls, raml_resource, es_based=True): """ Generate an ACL. Generated ACL class has a `item_model` attribute set to :model_cls:. ACLs used for collection and item access control are generated from a first security scheme with type `x-ACL`. If :raml_resource: has no ...
[ "def", "generate_acl", "(", "config", ",", "model_cls", ",", "raml_resource", ",", "es_based", "=", "True", ")", ":", "schemes", "=", "raml_resource", ".", "security_schemes", "or", "[", "]", "schemes", "=", "[", "sch", "for", "sch", "in", "schemes", "if",...
Generate an ACL. Generated ACL class has a `item_model` attribute set to :model_cls:. ACLs used for collection and item access control are generated from a first security scheme with type `x-ACL`. If :raml_resource: has no x-ACL security schemes defined then ALLOW_ALL ACL is used. If the `...
[ "Generate", "an", "ACL", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/acl.py#L217-L264
train
ramses-tech/ramses
ramses/acl.py
BaseACL._apply_callables
def _apply_callables(self, acl, obj=None): """ Iterate over ACEs from :acl: and apply callable principals if any. Principals are passed 3 arguments on call: :ace: Single ACE object that looks like (action, callable, permission or [permission]) :request: C...
python
def _apply_callables(self, acl, obj=None): """ Iterate over ACEs from :acl: and apply callable principals if any. Principals are passed 3 arguments on call: :ace: Single ACE object that looks like (action, callable, permission or [permission]) :request: C...
[ "def", "_apply_callables", "(", "self", ",", "acl", ",", "obj", "=", "None", ")", ":", "new_acl", "=", "[", "]", "for", "i", ",", "ace", "in", "enumerate", "(", "acl", ")", ":", "principal", "=", "ace", "[", "1", "]", "if", "six", ".", "callable"...
Iterate over ACEs from :acl: and apply callable principals if any. Principals are passed 3 arguments on call: :ace: Single ACE object that looks like (action, callable, permission or [permission]) :request: Current request object :obj: Object instance...
[ "Iterate", "over", "ACEs", "from", ":", "acl", ":", "and", "apply", "callable", "principals", "if", "any", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/acl.py#L117-L144
train
ramses-tech/ramses
ramses/acl.py
DatabaseACLMixin.item_acl
def item_acl(self, item): """ Objectify ACL if ES is used or call item.get_acl() if db is used. """ if self.es_based: from nefertari_guards.elasticsearch import get_es_item_acl return get_es_item_acl(item) return super(DatabaseACLMixin, self).item_acl(item...
python
def item_acl(self, item): """ Objectify ACL if ES is used or call item.get_acl() if db is used. """ if self.es_based: from nefertari_guards.elasticsearch import get_es_item_acl return get_es_item_acl(item) return super(DatabaseACLMixin, self).item_acl(item...
[ "def", "item_acl", "(", "self", ",", "item", ")", ":", "if", "self", ".", "es_based", ":", "from", "nefertari_guards", ".", "elasticsearch", "import", "get_es_item_acl", "return", "get_es_item_acl", "(", "item", ")", "return", "super", "(", "DatabaseACLMixin", ...
Objectify ACL if ES is used or call item.get_acl() if db is used.
[ "Objectify", "ACL", "if", "ES", "is", "used", "or", "call", "item", ".", "get_acl", "()", "if", "db", "is", "used", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/acl.py#L189-L196
train
ramses-tech/ramses
ramses/acl.py
DatabaseACLMixin.getitem_es
def getitem_es(self, key): """ Override to support ACL filtering. To do so: passes `self.request` to `get_item` and uses `ACLFilterES`. """ from nefertari_guards.elasticsearch import ACLFilterES es = ACLFilterES(self.item_model.__name__) params = { 'i...
python
def getitem_es(self, key): """ Override to support ACL filtering. To do so: passes `self.request` to `get_item` and uses `ACLFilterES`. """ from nefertari_guards.elasticsearch import ACLFilterES es = ACLFilterES(self.item_model.__name__) params = { 'i...
[ "def", "getitem_es", "(", "self", ",", "key", ")", ":", "from", "nefertari_guards", ".", "elasticsearch", "import", "ACLFilterES", "es", "=", "ACLFilterES", "(", "self", ".", "item_model", ".", "__name__", ")", "params", "=", "{", "'id'", ":", "key", ",", ...
Override to support ACL filtering. To do so: passes `self.request` to `get_item` and uses `ACLFilterES`.
[ "Override", "to", "support", "ACL", "filtering", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/acl.py#L198-L214
train
ramses-tech/ramses
ramses/utils.py
convert_schema
def convert_schema(raml_schema, mime_type): """ Restructure `raml_schema` to a dictionary that has 'properties' as well as other schema keys/values. The resulting dictionary looks like this:: { "properties": { "field1": { "required": boolean, "type":...
python
def convert_schema(raml_schema, mime_type): """ Restructure `raml_schema` to a dictionary that has 'properties' as well as other schema keys/values. The resulting dictionary looks like this:: { "properties": { "field1": { "required": boolean, "type":...
[ "def", "convert_schema", "(", "raml_schema", ",", "mime_type", ")", ":", "if", "mime_type", "==", "ContentTypes", ".", "JSON", ":", "if", "not", "isinstance", "(", "raml_schema", ",", "dict", ")", ":", "raise", "TypeError", "(", "'Schema is not a valid JSON. Ple...
Restructure `raml_schema` to a dictionary that has 'properties' as well as other schema keys/values. The resulting dictionary looks like this:: { "properties": { "field1": { "required": boolean, "type": ..., ...more field options ...
[ "Restructure", "raml_schema", "to", "a", "dictionary", "that", "has", "properties", "as", "well", "as", "other", "schema", "keys", "/", "values", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/utils.py#L22-L54
train
ramses-tech/ramses
ramses/utils.py
generate_model_name
def generate_model_name(raml_resource): """ Generate model name. :param raml_resource: Instance of ramlfications.raml.ResourceNode. """ resource_uri = get_resource_uri(raml_resource).strip('/') resource_uri = re.sub('\W', ' ', resource_uri) model_name = inflection.titleize(resource_uri) ret...
python
def generate_model_name(raml_resource): """ Generate model name. :param raml_resource: Instance of ramlfications.raml.ResourceNode. """ resource_uri = get_resource_uri(raml_resource).strip('/') resource_uri = re.sub('\W', ' ', resource_uri) model_name = inflection.titleize(resource_uri) ret...
[ "def", "generate_model_name", "(", "raml_resource", ")", ":", "resource_uri", "=", "get_resource_uri", "(", "raml_resource", ")", ".", "strip", "(", "'/'", ")", "resource_uri", "=", "re", ".", "sub", "(", "'\\W'", ",", "' '", ",", "resource_uri", ")", "model...
Generate model name. :param raml_resource: Instance of ramlfications.raml.ResourceNode.
[ "Generate", "model", "name", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/utils.py#L76-L84
train
ramses-tech/ramses
ramses/utils.py
dynamic_part_name
def dynamic_part_name(raml_resource, route_name, pk_field): """ Generate a dynamic part for a resource :raml_resource:. A dynamic part is generated using 2 parts: :route_name: of the resource and the dynamic part of first dynamic child resources. If :raml_resource: has no dynamic child resources, 'id' ...
python
def dynamic_part_name(raml_resource, route_name, pk_field): """ Generate a dynamic part for a resource :raml_resource:. A dynamic part is generated using 2 parts: :route_name: of the resource and the dynamic part of first dynamic child resources. If :raml_resource: has no dynamic child resources, 'id' ...
[ "def", "dynamic_part_name", "(", "raml_resource", ",", "route_name", ",", "pk_field", ")", ":", "subresources", "=", "get_resource_children", "(", "raml_resource", ")", "dynamic_uris", "=", "[", "res", ".", "path", "for", "res", "in", "subresources", "if", "is_d...
Generate a dynamic part for a resource :raml_resource:. A dynamic part is generated using 2 parts: :route_name: of the resource and the dynamic part of first dynamic child resources. If :raml_resource: has no dynamic child resources, 'id' is used as the 2nd part. E.g. if your dynamic part on route ...
[ "Generate", "a", "dynamic", "part", "for", "a", "resource", ":", "raml_resource", ":", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/utils.py#L87-L109
train
ramses-tech/ramses
ramses/utils.py
extract_dynamic_part
def extract_dynamic_part(uri): """ Extract dynamic url part from :uri: string. :param uri: URI string that may contain dynamic part. """ for part in uri.split('/'): part = part.strip() if part.startswith('{') and part.endswith('}'): return clean_dynamic_uri(part)
python
def extract_dynamic_part(uri): """ Extract dynamic url part from :uri: string. :param uri: URI string that may contain dynamic part. """ for part in uri.split('/'): part = part.strip() if part.startswith('{') and part.endswith('}'): return clean_dynamic_uri(part)
[ "def", "extract_dynamic_part", "(", "uri", ")", ":", "for", "part", "in", "uri", ".", "split", "(", "'/'", ")", ":", "part", "=", "part", ".", "strip", "(", ")", "if", "part", ".", "startswith", "(", "'{'", ")", "and", "part", ".", "endswith", "(",...
Extract dynamic url part from :uri: string. :param uri: URI string that may contain dynamic part.
[ "Extract", "dynamic", "url", "part", "from", ":", "uri", ":", "string", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/utils.py#L112-L120
train
ramses-tech/ramses
ramses/utils.py
resource_view_attrs
def resource_view_attrs(raml_resource, singular=False): """ Generate view method names needed for `raml_resource` view. Collects HTTP method names from resource siblings and dynamic children if exist. Collected methods are then translated to `nefertari.view.BaseView` method names, each of which is use...
python
def resource_view_attrs(raml_resource, singular=False): """ Generate view method names needed for `raml_resource` view. Collects HTTP method names from resource siblings and dynamic children if exist. Collected methods are then translated to `nefertari.view.BaseView` method names, each of which is use...
[ "def", "resource_view_attrs", "(", "raml_resource", ",", "singular", "=", "False", ")", ":", "from", ".", "views", "import", "collection_methods", ",", "item_methods", "# Singular resource doesn't have collection methods though", "# it looks like a collection", "if", "singula...
Generate view method names needed for `raml_resource` view. Collects HTTP method names from resource siblings and dynamic children if exist. Collected methods are then translated to `nefertari.view.BaseView` method names, each of which is used to process a particular HTTP method request. Maps of ...
[ "Generate", "view", "method", "names", "needed", "for", "raml_resource", "view", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/utils.py#L123-L156
train
ramses-tech/ramses
ramses/utils.py
resource_schema
def resource_schema(raml_resource): """ Get schema properties of RAML resource :raml_resource:. Must be called with RAML resource that defines body schema. First body that defines schema is used. Schema is converted on return using 'convert_schema'. :param raml_resource: Instance of ramlfications....
python
def resource_schema(raml_resource): """ Get schema properties of RAML resource :raml_resource:. Must be called with RAML resource that defines body schema. First body that defines schema is used. Schema is converted on return using 'convert_schema'. :param raml_resource: Instance of ramlfications....
[ "def", "resource_schema", "(", "raml_resource", ")", ":", "# NOTE: Must be called with resource that defines body schema", "log", ".", "info", "(", "'Searching for model schema'", ")", "if", "not", "raml_resource", ".", "body", ":", "raise", "ValueError", "(", "'RAML reso...
Get schema properties of RAML resource :raml_resource:. Must be called with RAML resource that defines body schema. First body that defines schema is used. Schema is converted on return using 'convert_schema'. :param raml_resource: Instance of ramlfications.raml.ResourceNode of POST method.
[ "Get", "schema", "properties", "of", "RAML", "resource", ":", "raml_resource", ":", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/utils.py#L159-L178
train
ramses-tech/ramses
ramses/utils.py
get_static_parent
def get_static_parent(raml_resource, method=None): """ Get static parent resource of :raml_resource: with HTTP method :method:. :param raml_resource:Instance of ramlfications.raml.ResourceNode. :param method: HTTP method name which matching static resource must have. """ parent = raml_r...
python
def get_static_parent(raml_resource, method=None): """ Get static parent resource of :raml_resource: with HTTP method :method:. :param raml_resource:Instance of ramlfications.raml.ResourceNode. :param method: HTTP method name which matching static resource must have. """ parent = raml_r...
[ "def", "get_static_parent", "(", "raml_resource", ",", "method", "=", "None", ")", ":", "parent", "=", "raml_resource", ".", "parent", "while", "is_dynamic_resource", "(", "parent", ")", ":", "parent", "=", "parent", ".", "parent", "if", "parent", "is", "Non...
Get static parent resource of :raml_resource: with HTTP method :method:. :param raml_resource:Instance of ramlfications.raml.ResourceNode. :param method: HTTP method name which matching static resource must have.
[ "Get", "static", "parent", "resource", "of", ":", "raml_resource", ":", "with", "HTTP", "method", ":", "method", ":", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/utils.py#L189-L214
train
ramses-tech/ramses
ramses/utils.py
attr_subresource
def attr_subresource(raml_resource, route_name): """ Determine if :raml_resource: is an attribute subresource. :param raml_resource: Instance of ramlfications.raml.ResourceNode. :param route_name: Name of the :raml_resource:. """ static_parent = get_static_parent(raml_resource, method='POST') i...
python
def attr_subresource(raml_resource, route_name): """ Determine if :raml_resource: is an attribute subresource. :param raml_resource: Instance of ramlfications.raml.ResourceNode. :param route_name: Name of the :raml_resource:. """ static_parent = get_static_parent(raml_resource, method='POST') i...
[ "def", "attr_subresource", "(", "raml_resource", ",", "route_name", ")", ":", "static_parent", "=", "get_static_parent", "(", "raml_resource", ",", "method", "=", "'POST'", ")", "if", "static_parent", "is", "None", ":", "return", "False", "schema", "=", "resourc...
Determine if :raml_resource: is an attribute subresource. :param raml_resource: Instance of ramlfications.raml.ResourceNode. :param route_name: Name of the :raml_resource:.
[ "Determine", "if", ":", "raml_resource", ":", "is", "an", "attribute", "subresource", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/utils.py#L217-L231
train
ramses-tech/ramses
ramses/utils.py
singular_subresource
def singular_subresource(raml_resource, route_name): """ Determine if :raml_resource: is a singular subresource. :param raml_resource: Instance of ramlfications.raml.ResourceNode. :param route_name: Name of the :raml_resource:. """ static_parent = get_static_parent(raml_resource, method='POST') ...
python
def singular_subresource(raml_resource, route_name): """ Determine if :raml_resource: is a singular subresource. :param raml_resource: Instance of ramlfications.raml.ResourceNode. :param route_name: Name of the :raml_resource:. """ static_parent = get_static_parent(raml_resource, method='POST') ...
[ "def", "singular_subresource", "(", "raml_resource", ",", "route_name", ")", ":", "static_parent", "=", "get_static_parent", "(", "raml_resource", ",", "method", "=", "'POST'", ")", "if", "static_parent", "is", "None", ":", "return", "False", "schema", "=", "res...
Determine if :raml_resource: is a singular subresource. :param raml_resource: Instance of ramlfications.raml.ResourceNode. :param route_name: Name of the :raml_resource:.
[ "Determine", "if", ":", "raml_resource", ":", "is", "a", "singular", "subresource", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/utils.py#L234-L251
train
ramses-tech/ramses
ramses/utils.py
is_callable_tag
def is_callable_tag(tag): """ Determine whether :tag: is a valid callable string tag. String is assumed to be valid callable if it starts with '{{' and ends with '}}'. :param tag: String name of tag. """ return (isinstance(tag, six.string_types) and tag.strip().startswith('{{') and...
python
def is_callable_tag(tag): """ Determine whether :tag: is a valid callable string tag. String is assumed to be valid callable if it starts with '{{' and ends with '}}'. :param tag: String name of tag. """ return (isinstance(tag, six.string_types) and tag.strip().startswith('{{') and...
[ "def", "is_callable_tag", "(", "tag", ")", ":", "return", "(", "isinstance", "(", "tag", ",", "six", ".", "string_types", ")", "and", "tag", ".", "strip", "(", ")", ".", "startswith", "(", "'{{'", ")", "and", "tag", ".", "strip", "(", ")", ".", "en...
Determine whether :tag: is a valid callable string tag. String is assumed to be valid callable if it starts with '{{' and ends with '}}'. :param tag: String name of tag.
[ "Determine", "whether", ":", "tag", ":", "is", "a", "valid", "callable", "string", "tag", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/utils.py#L254-L264
train
ramses-tech/ramses
ramses/utils.py
resolve_to_callable
def resolve_to_callable(callable_name): """ Resolve string :callable_name: to a callable. :param callable_name: String representing callable name as registered in ramses registry or dotted import path of callable. Can be wrapped in double curly brackets, e.g. '{{my_callable}}'. """ from...
python
def resolve_to_callable(callable_name): """ Resolve string :callable_name: to a callable. :param callable_name: String representing callable name as registered in ramses registry or dotted import path of callable. Can be wrapped in double curly brackets, e.g. '{{my_callable}}'. """ from...
[ "def", "resolve_to_callable", "(", "callable_name", ")", ":", "from", ".", "import", "registry", "clean_callable_name", "=", "callable_name", ".", "replace", "(", "'{{'", ",", "''", ")", ".", "replace", "(", "'}}'", ",", "''", ")", ".", "strip", "(", ")", ...
Resolve string :callable_name: to a callable. :param callable_name: String representing callable name as registered in ramses registry or dotted import path of callable. Can be wrapped in double curly brackets, e.g. '{{my_callable}}'.
[ "Resolve", "string", ":", "callable_name", ":", "to", "a", "callable", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/utils.py#L267-L285
train
ramses-tech/ramses
ramses/utils.py
get_resource_siblings
def get_resource_siblings(raml_resource): """ Get siblings of :raml_resource:. :param raml_resource: Instance of ramlfications.raml.ResourceNode. """ path = raml_resource.path return [res for res in raml_resource.root.resources if res.path == path]
python
def get_resource_siblings(raml_resource): """ Get siblings of :raml_resource:. :param raml_resource: Instance of ramlfications.raml.ResourceNode. """ path = raml_resource.path return [res for res in raml_resource.root.resources if res.path == path]
[ "def", "get_resource_siblings", "(", "raml_resource", ")", ":", "path", "=", "raml_resource", ".", "path", "return", "[", "res", "for", "res", "in", "raml_resource", ".", "root", ".", "resources", "if", "res", ".", "path", "==", "path", "]" ]
Get siblings of :raml_resource:. :param raml_resource: Instance of ramlfications.raml.ResourceNode.
[ "Get", "siblings", "of", ":", "raml_resource", ":", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/utils.py#L288-L295
train
ramses-tech/ramses
ramses/utils.py
get_resource_children
def get_resource_children(raml_resource): """ Get children of :raml_resource:. :param raml_resource: Instance of ramlfications.raml.ResourceNode. """ path = raml_resource.path return [res for res in raml_resource.root.resources if res.parent and res.parent.path == path]
python
def get_resource_children(raml_resource): """ Get children of :raml_resource:. :param raml_resource: Instance of ramlfications.raml.ResourceNode. """ path = raml_resource.path return [res for res in raml_resource.root.resources if res.parent and res.parent.path == path]
[ "def", "get_resource_children", "(", "raml_resource", ")", ":", "path", "=", "raml_resource", ".", "path", "return", "[", "res", "for", "res", "in", "raml_resource", ".", "root", ".", "resources", "if", "res", ".", "parent", "and", "res", ".", "parent", "....
Get children of :raml_resource:. :param raml_resource: Instance of ramlfications.raml.ResourceNode.
[ "Get", "children", "of", ":", "raml_resource", ":", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/utils.py#L298-L305
train
ramses-tech/ramses
ramses/utils.py
get_events_map
def get_events_map(): """ Prepare map of event subscribers. * Extends copies of BEFORE_EVENTS and AFTER_EVENTS maps with 'set' action. * Returns map of {before/after: {action: event class(es)}} """ from nefertari import events set_keys = ('create', 'update', 'replace', 'update_many', 'r...
python
def get_events_map(): """ Prepare map of event subscribers. * Extends copies of BEFORE_EVENTS and AFTER_EVENTS maps with 'set' action. * Returns map of {before/after: {action: event class(es)}} """ from nefertari import events set_keys = ('create', 'update', 'replace', 'update_many', 'r...
[ "def", "get_events_map", "(", ")", ":", "from", "nefertari", "import", "events", "set_keys", "=", "(", "'create'", ",", "'update'", ",", "'replace'", ",", "'update_many'", ",", "'register'", ")", "before_events", "=", "events", ".", "BEFORE_EVENTS", ".", "copy...
Prepare map of event subscribers. * Extends copies of BEFORE_EVENTS and AFTER_EVENTS maps with 'set' action. * Returns map of {before/after: {action: event class(es)}}
[ "Prepare", "map", "of", "event", "subscribers", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/utils.py#L308-L324
train
ramses-tech/ramses
ramses/utils.py
patch_view_model
def patch_view_model(view_cls, model_cls): """ Patches view_cls.Model with model_cls. :param view_cls: View class "Model" param of which should be patched :param model_cls: Model class which should be used to patch view_cls.Model """ original_model = view_cls.Model view_cls.Mode...
python
def patch_view_model(view_cls, model_cls): """ Patches view_cls.Model with model_cls. :param view_cls: View class "Model" param of which should be patched :param model_cls: Model class which should be used to patch view_cls.Model """ original_model = view_cls.Model view_cls.Mode...
[ "def", "patch_view_model", "(", "view_cls", ",", "model_cls", ")", ":", "original_model", "=", "view_cls", ".", "Model", "view_cls", ".", "Model", "=", "model_cls", "try", ":", "yield", "finally", ":", "view_cls", ".", "Model", "=", "original_model" ]
Patches view_cls.Model with model_cls. :param view_cls: View class "Model" param of which should be patched :param model_cls: Model class which should be used to patch view_cls.Model
[ "Patches", "view_cls", ".", "Model", "with", "model_cls", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/utils.py#L328-L342
train
ramses-tech/ramses
ramses/utils.py
get_route_name
def get_route_name(resource_uri): """ Get route name from RAML resource URI. :param resource_uri: String representing RAML resource URI. :returns string: String with route name, which is :resource_uri: stripped of non-word characters. """ resource_uri = resource_uri.strip('/') resource_...
python
def get_route_name(resource_uri): """ Get route name from RAML resource URI. :param resource_uri: String representing RAML resource URI. :returns string: String with route name, which is :resource_uri: stripped of non-word characters. """ resource_uri = resource_uri.strip('/') resource_...
[ "def", "get_route_name", "(", "resource_uri", ")", ":", "resource_uri", "=", "resource_uri", ".", "strip", "(", "'/'", ")", "resource_uri", "=", "re", ".", "sub", "(", "'\\W'", ",", "''", ",", "resource_uri", ")", "return", "resource_uri" ]
Get route name from RAML resource URI. :param resource_uri: String representing RAML resource URI. :returns string: String with route name, which is :resource_uri: stripped of non-word characters.
[ "Get", "route", "name", "from", "RAML", "resource", "URI", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/utils.py#L345-L354
train
ramses-tech/ramses
ramses/generators.py
generate_resource
def generate_resource(config, raml_resource, parent_resource): """ Perform complete one resource configuration process This function generates: ACL, view, route, resource, database model for a given `raml_resource`. New nefertari resource is attached to `parent_resource` class which is an instance of ...
python
def generate_resource(config, raml_resource, parent_resource): """ Perform complete one resource configuration process This function generates: ACL, view, route, resource, database model for a given `raml_resource`. New nefertari resource is attached to `parent_resource` class which is an instance of ...
[ "def", "generate_resource", "(", "config", ",", "raml_resource", ",", "parent_resource", ")", ":", "from", ".", "models", "import", "get_existing_model", "# Don't generate resources for dynamic routes as they are already", "# generated by their parent", "resource_uri", "=", "ge...
Perform complete one resource configuration process This function generates: ACL, view, route, resource, database model for a given `raml_resource`. New nefertari resource is attached to `parent_resource` class which is an instance of `nefertari.resource.Resource`. Things to consider: * Top-...
[ "Perform", "complete", "one", "resource", "configuration", "process" ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/generators.py#L32-L122
train
ramses-tech/ramses
ramses/generators.py
generate_server
def generate_server(raml_root, config): """ Handle server generation process. :param raml_root: Instance of ramlfications.raml.RootNode. :param config: Pyramid Configurator instance. """ log.info('Server generation started') if not raml_root.resources: return root_resource = confi...
python
def generate_server(raml_root, config): """ Handle server generation process. :param raml_root: Instance of ramlfications.raml.RootNode. :param config: Pyramid Configurator instance. """ log.info('Server generation started') if not raml_root.resources: return root_resource = confi...
[ "def", "generate_server", "(", "raml_root", ",", "config", ")", ":", "log", ".", "info", "(", "'Server generation started'", ")", "if", "not", "raml_root", ".", "resources", ":", "return", "root_resource", "=", "config", ".", "get_root_resource", "(", ")", "ge...
Handle server generation process. :param raml_root: Instance of ramlfications.raml.RootNode. :param config: Pyramid Configurator instance.
[ "Handle", "server", "generation", "process", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/generators.py#L125-L151
train
ramses-tech/ramses
ramses/generators.py
generate_models
def generate_models(config, raml_resources): """ Generate model for each resource in :raml_resources: The DB model name is generated using singular titled version of current resource's url. E.g. for resource under url '/stories', model with name 'Story' will be generated. :param config: Pyramid Co...
python
def generate_models(config, raml_resources): """ Generate model for each resource in :raml_resources: The DB model name is generated using singular titled version of current resource's url. E.g. for resource under url '/stories', model with name 'Story' will be generated. :param config: Pyramid Co...
[ "def", "generate_models", "(", "config", ",", "raml_resources", ")", ":", "from", ".", "models", "import", "handle_model_generation", "if", "not", "raml_resources", ":", "return", "for", "raml_resource", "in", "raml_resources", ":", "# No need to generate models for dyn...
Generate model for each resource in :raml_resources: The DB model name is generated using singular titled version of current resource's url. E.g. for resource under url '/stories', model with name 'Story' will be generated. :param config: Pyramid Configurator instance. :param raml_resources: List ...
[ "Generate", "model", "for", "each", "resource", "in", ":", "raml_resources", ":" ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/generators.py#L154-L186
train
ramses-tech/ramses
ramses/views.py
generate_rest_view
def generate_rest_view(config, model_cls, attrs=None, es_based=True, attr_view=False, singular=False): """ Generate REST view for a model class. :param model_cls: Generated DB model class. :param attr: List of strings that represent names of view methods, new generated view s...
python
def generate_rest_view(config, model_cls, attrs=None, es_based=True, attr_view=False, singular=False): """ Generate REST view for a model class. :param model_cls: Generated DB model class. :param attr: List of strings that represent names of view methods, new generated view s...
[ "def", "generate_rest_view", "(", "config", ",", "model_cls", ",", "attrs", "=", "None", ",", "es_based", "=", "True", ",", "attr_view", "=", "False", ",", "singular", "=", "False", ")", ":", "valid_attrs", "=", "(", "list", "(", "collection_methods", ".",...
Generate REST view for a model class. :param model_cls: Generated DB model class. :param attr: List of strings that represent names of view methods, new generated view should support. Not supported methods are replaced with property that raises AttributeError to display MethodNotAllowed ...
[ "Generate", "REST", "view", "for", "a", "model", "class", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/views.py#L447-L491
train
ramses-tech/ramses
ramses/views.py
SetObjectACLMixin.set_object_acl
def set_object_acl(self, obj): """ Set object ACL on creation if not already present. """ if not obj._acl: from nefertari_guards import engine as guards_engine acl = self._factory(self.request).generate_item_acl(obj) obj._acl = guards_engine.ACLField.stringify_acl(acl...
python
def set_object_acl(self, obj): """ Set object ACL on creation if not already present. """ if not obj._acl: from nefertari_guards import engine as guards_engine acl = self._factory(self.request).generate_item_acl(obj) obj._acl = guards_engine.ACLField.stringify_acl(acl...
[ "def", "set_object_acl", "(", "self", ",", "obj", ")", ":", "if", "not", "obj", ".", "_acl", ":", "from", "nefertari_guards", "import", "engine", "as", "guards_engine", "acl", "=", "self", ".", "_factory", "(", "self", ".", "request", ")", ".", "generate...
Set object ACL on creation if not already present.
[ "Set", "object", "ACL", "on", "creation", "if", "not", "already", "present", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/views.py#L37-L42
train
ramses-tech/ramses
ramses/views.py
BaseView.resolve_kw
def resolve_kw(self, kwargs): """ Resolve :kwargs: like `story_id: 1` to the form of `id: 1`. """ resolved = {} for key, value in kwargs.items(): split = key.split('_', 1) if len(split) > 1: key = split[1] resolved[key] = value ...
python
def resolve_kw(self, kwargs): """ Resolve :kwargs: like `story_id: 1` to the form of `id: 1`. """ resolved = {} for key, value in kwargs.items(): split = key.split('_', 1) if len(split) > 1: key = split[1] resolved[key] = value ...
[ "def", "resolve_kw", "(", "self", ",", "kwargs", ")", ":", "resolved", "=", "{", "}", "for", "key", ",", "value", "in", "kwargs", ".", "items", "(", ")", ":", "split", "=", "key", ".", "split", "(", "'_'", ",", "1", ")", "if", "len", "(", "spli...
Resolve :kwargs: like `story_id: 1` to the form of `id: 1`.
[ "Resolve", ":", "kwargs", ":", "like", "story_id", ":", "1", "to", "the", "form", "of", "id", ":", "1", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/views.py#L62-L72
train
ramses-tech/ramses
ramses/views.py
BaseView._location
def _location(self, obj): """ Get location of the `obj` Arguments: :obj: self.Model instance. """ field_name = self.clean_id_name return self.request.route_url( self._resource.uid, **{self._resource.id_name: getattr(obj, field_name)})
python
def _location(self, obj): """ Get location of the `obj` Arguments: :obj: self.Model instance. """ field_name = self.clean_id_name return self.request.route_url( self._resource.uid, **{self._resource.id_name: getattr(obj, field_name)})
[ "def", "_location", "(", "self", ",", "obj", ")", ":", "field_name", "=", "self", ".", "clean_id_name", "return", "self", ".", "request", ".", "route_url", "(", "self", ".", "_resource", ".", "uid", ",", "*", "*", "{", "self", ".", "_resource", ".", ...
Get location of the `obj` Arguments: :obj: self.Model instance.
[ "Get", "location", "of", "the", "obj" ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/views.py#L74-L83
train
ramses-tech/ramses
ramses/views.py
BaseView._parent_queryset
def _parent_queryset(self): """ Get queryset of parent view. Generated queryset is used to run queries in the current level view. """ parent = self._resource.parent if hasattr(parent, 'view'): req = self.request.blank(self.request.path) req.registry = sel...
python
def _parent_queryset(self): """ Get queryset of parent view. Generated queryset is used to run queries in the current level view. """ parent = self._resource.parent if hasattr(parent, 'view'): req = self.request.blank(self.request.path) req.registry = sel...
[ "def", "_parent_queryset", "(", "self", ")", ":", "parent", "=", "self", ".", "_resource", ".", "parent", "if", "hasattr", "(", "parent", ",", "'view'", ")", ":", "req", "=", "self", ".", "request", ".", "blank", "(", "self", ".", "request", ".", "pa...
Get queryset of parent view. Generated queryset is used to run queries in the current level view.
[ "Get", "queryset", "of", "parent", "view", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/views.py#L85-L101
train
ramses-tech/ramses
ramses/views.py
BaseView.get_collection
def get_collection(self, **kwargs): """ Get objects collection taking into account generated queryset of parent view. This method allows working with nested resources properly. Thus a queryset returned by this method will be a subset of its parent view's queryset, thus filtering...
python
def get_collection(self, **kwargs): """ Get objects collection taking into account generated queryset of parent view. This method allows working with nested resources properly. Thus a queryset returned by this method will be a subset of its parent view's queryset, thus filtering...
[ "def", "get_collection", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_query_params", ".", "update", "(", "kwargs", ")", "objects", "=", "self", ".", "_parent_queryset", "(", ")", "if", "objects", "is", "not", "None", ":", "return", "s...
Get objects collection taking into account generated queryset of parent view. This method allows working with nested resources properly. Thus a queryset returned by this method will be a subset of its parent view's queryset, thus filtering out objects that don't belong to the pa...
[ "Get", "objects", "collection", "taking", "into", "account", "generated", "queryset", "of", "parent", "view", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/views.py#L103-L117
train
ramses-tech/ramses
ramses/views.py
BaseView.get_item
def get_item(self, **kwargs): """ Get collection item taking into account generated queryset of parent view. This method allows working with nested resources properly. Thus an item returned by this method will belong to its parent view's queryset, thus filtering out objects that...
python
def get_item(self, **kwargs): """ Get collection item taking into account generated queryset of parent view. This method allows working with nested resources properly. Thus an item returned by this method will belong to its parent view's queryset, thus filtering out objects that...
[ "def", "get_item", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "six", ".", "callable", "(", "self", ".", "context", ")", ":", "self", ".", "reload_context", "(", "es_based", "=", "False", ",", "*", "*", "kwargs", ")", "objects", "=", "sel...
Get collection item taking into account generated queryset of parent view. This method allows working with nested resources properly. Thus an item returned by this method will belong to its parent view's queryset, thus filtering out objects that don't belong to the parent object. ...
[ "Get", "collection", "item", "taking", "into", "account", "generated", "queryset", "of", "parent", "view", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/views.py#L119-L139
train
ramses-tech/ramses
ramses/views.py
BaseView.reload_context
def reload_context(self, es_based, **kwargs): """ Reload `self.context` object into a DB or ES object. A reload is performed by getting the object ID from :kwargs: and then getting a context key item from the new instance of `self._factory` which is an ACL class used by the current view...
python
def reload_context(self, es_based, **kwargs): """ Reload `self.context` object into a DB or ES object. A reload is performed by getting the object ID from :kwargs: and then getting a context key item from the new instance of `self._factory` which is an ACL class used by the current view...
[ "def", "reload_context", "(", "self", ",", "es_based", ",", "*", "*", "kwargs", ")", ":", "from", ".", "acl", "import", "BaseACL", "key", "=", "self", ".", "_get_context_key", "(", "*", "*", "kwargs", ")", "kwargs", "=", "{", "'request'", ":", "self", ...
Reload `self.context` object into a DB or ES object. A reload is performed by getting the object ID from :kwargs: and then getting a context key item from the new instance of `self._factory` which is an ACL class used by the current view. Arguments: :es_based: Boolean. Whet...
[ "Reload", "self", ".", "context", "object", "into", "a", "DB", "or", "ES", "object", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/views.py#L145-L168
train
ramses-tech/ramses
ramses/views.py
ESBaseView._parent_queryset_es
def _parent_queryset_es(self): """ Get queryset (list of object IDs) of parent view. The generated queryset is used to run queries in the current level's view. """ parent = self._resource.parent if hasattr(parent, 'view'): req = self.request.blank(self.reques...
python
def _parent_queryset_es(self): """ Get queryset (list of object IDs) of parent view. The generated queryset is used to run queries in the current level's view. """ parent = self._resource.parent if hasattr(parent, 'view'): req = self.request.blank(self.reques...
[ "def", "_parent_queryset_es", "(", "self", ")", ":", "parent", "=", "self", ".", "_resource", ".", "parent", "if", "hasattr", "(", "parent", ",", "'view'", ")", ":", "req", "=", "self", ".", "request", ".", "blank", "(", "self", ".", "request", ".", ...
Get queryset (list of object IDs) of parent view. The generated queryset is used to run queries in the current level's view.
[ "Get", "queryset", "(", "list", "of", "object", "IDs", ")", "of", "parent", "view", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/views.py#L218-L234
train
ramses-tech/ramses
ramses/views.py
ESBaseView.get_es_object_ids
def get_es_object_ids(self, objects): """ Return IDs of :objects: if they are not IDs already. """ id_field = self.clean_id_name ids = [getattr(obj, id_field, obj) for obj in objects] return list(set(str(id_) for id_ in ids))
python
def get_es_object_ids(self, objects): """ Return IDs of :objects: if they are not IDs already. """ id_field = self.clean_id_name ids = [getattr(obj, id_field, obj) for obj in objects] return list(set(str(id_) for id_ in ids))
[ "def", "get_es_object_ids", "(", "self", ",", "objects", ")", ":", "id_field", "=", "self", ".", "clean_id_name", "ids", "=", "[", "getattr", "(", "obj", ",", "id_field", ",", "obj", ")", "for", "obj", "in", "objects", "]", "return", "list", "(", "set"...
Return IDs of :objects: if they are not IDs already.
[ "Return", "IDs", "of", ":", "objects", ":", "if", "they", "are", "not", "IDs", "already", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/views.py#L236-L240
train
ramses-tech/ramses
ramses/views.py
ESBaseView.get_collection_es
def get_collection_es(self): """ Get ES objects collection taking into account the generated queryset of parent view. This method allows working with nested resources properly. Thus a queryset returned by this method will be a subset of its parent view's queryset, thus filtering...
python
def get_collection_es(self): """ Get ES objects collection taking into account the generated queryset of parent view. This method allows working with nested resources properly. Thus a queryset returned by this method will be a subset of its parent view's queryset, thus filtering...
[ "def", "get_collection_es", "(", "self", ")", ":", "objects_ids", "=", "self", ".", "_parent_queryset_es", "(", ")", "if", "objects_ids", "is", "not", "None", ":", "objects_ids", "=", "self", ".", "get_es_object_ids", "(", "objects_ids", ")", "if", "not", "o...
Get ES objects collection taking into account the generated queryset of parent view. This method allows working with nested resources properly. Thus a queryset returned by this method will be a subset of its parent view's queryset, thus filtering out objects that don't belong to the par...
[ "Get", "ES", "objects", "collection", "taking", "into", "account", "the", "generated", "queryset", "of", "parent", "view", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/views.py#L242-L259
train
ramses-tech/ramses
ramses/views.py
ESBaseView.get_item_es
def get_item_es(self, **kwargs): """ Get ES collection item taking into account generated queryset of parent view. This method allows working with nested resources properly. Thus an item returned by this method will belong to its parent view's queryset, thus filtering out object...
python
def get_item_es(self, **kwargs): """ Get ES collection item taking into account generated queryset of parent view. This method allows working with nested resources properly. Thus an item returned by this method will belong to its parent view's queryset, thus filtering out object...
[ "def", "get_item_es", "(", "self", ",", "*", "*", "kwargs", ")", ":", "item_id", "=", "self", ".", "_get_context_key", "(", "*", "*", "kwargs", ")", "objects_ids", "=", "self", ".", "_parent_queryset_es", "(", ")", "if", "objects_ids", "is", "not", "None...
Get ES collection item taking into account generated queryset of parent view. This method allows working with nested resources properly. Thus an item returned by this method will belong to its parent view's queryset, thus filtering out objects that don't belong to the parent object. ...
[ "Get", "ES", "collection", "item", "taking", "into", "account", "generated", "queryset", "of", "parent", "view", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/views.py#L261-L284
train
ramses-tech/ramses
ramses/views.py
ESCollectionView.update
def update(self, **kwargs): """ Explicitly reload context with DB usage to get access to complete DB object. """ self.reload_context(es_based=False, **kwargs) return super(ESCollectionView, self).update(**kwargs)
python
def update(self, **kwargs): """ Explicitly reload context with DB usage to get access to complete DB object. """ self.reload_context(es_based=False, **kwargs) return super(ESCollectionView, self).update(**kwargs)
[ "def", "update", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "reload_context", "(", "es_based", "=", "False", ",", "*", "*", "kwargs", ")", "return", "super", "(", "ESCollectionView", ",", "self", ")", ".", "update", "(", "*", "*", ...
Explicitly reload context with DB usage to get access to complete DB object.
[ "Explicitly", "reload", "context", "with", "DB", "usage", "to", "get", "access", "to", "complete", "DB", "object", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/views.py#L298-L303
train
ramses-tech/ramses
ramses/views.py
ESCollectionView.delete
def delete(self, **kwargs): """ Explicitly reload context with DB usage to get access to complete DB object. """ self.reload_context(es_based=False, **kwargs) return super(ESCollectionView, self).delete(**kwargs)
python
def delete(self, **kwargs): """ Explicitly reload context with DB usage to get access to complete DB object. """ self.reload_context(es_based=False, **kwargs) return super(ESCollectionView, self).delete(**kwargs)
[ "def", "delete", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "reload_context", "(", "es_based", "=", "False", ",", "*", "*", "kwargs", ")", "return", "super", "(", "ESCollectionView", ",", "self", ")", ".", "delete", "(", "*", "*", ...
Explicitly reload context with DB usage to get access to complete DB object.
[ "Explicitly", "reload", "context", "with", "DB", "usage", "to", "get", "access", "to", "complete", "DB", "object", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/views.py#L305-L310
train
ramses-tech/ramses
ramses/views.py
ESCollectionView.get_dbcollection_with_es
def get_dbcollection_with_es(self, **kwargs): """ Get DB objects collection by first querying ES. """ es_objects = self.get_collection_es() db_objects = self.Model.filter_objects(es_objects) return db_objects
python
def get_dbcollection_with_es(self, **kwargs): """ Get DB objects collection by first querying ES. """ es_objects = self.get_collection_es() db_objects = self.Model.filter_objects(es_objects) return db_objects
[ "def", "get_dbcollection_with_es", "(", "self", ",", "*", "*", "kwargs", ")", ":", "es_objects", "=", "self", ".", "get_collection_es", "(", ")", "db_objects", "=", "self", ".", "Model", ".", "filter_objects", "(", "es_objects", ")", "return", "db_objects" ]
Get DB objects collection by first querying ES.
[ "Get", "DB", "objects", "collection", "by", "first", "querying", "ES", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/views.py#L312-L316
train
ramses-tech/ramses
ramses/views.py
ESCollectionView.delete_many
def delete_many(self, **kwargs): """ Delete multiple objects from collection. First ES is queried, then the results are used to query the DB. This is done to make sure deleted objects are those filtered by ES in the 'index' method (so user deletes what he saw). """ db_ob...
python
def delete_many(self, **kwargs): """ Delete multiple objects from collection. First ES is queried, then the results are used to query the DB. This is done to make sure deleted objects are those filtered by ES in the 'index' method (so user deletes what he saw). """ db_ob...
[ "def", "delete_many", "(", "self", ",", "*", "*", "kwargs", ")", ":", "db_objects", "=", "self", ".", "get_dbcollection_with_es", "(", "*", "*", "kwargs", ")", "return", "self", ".", "Model", ".", "_delete_many", "(", "db_objects", ",", "self", ".", "req...
Delete multiple objects from collection. First ES is queried, then the results are used to query the DB. This is done to make sure deleted objects are those filtered by ES in the 'index' method (so user deletes what he saw).
[ "Delete", "multiple", "objects", "from", "collection", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/views.py#L318-L326
train
ramses-tech/ramses
ramses/views.py
ESCollectionView.update_many
def update_many(self, **kwargs): """ Update multiple objects from collection. First ES is queried, then the results are used to query DB. This is done to make sure updated objects are those filtered by ES in the 'index' method (so user updates what he saw). """ db_object...
python
def update_many(self, **kwargs): """ Update multiple objects from collection. First ES is queried, then the results are used to query DB. This is done to make sure updated objects are those filtered by ES in the 'index' method (so user updates what he saw). """ db_object...
[ "def", "update_many", "(", "self", ",", "*", "*", "kwargs", ")", ":", "db_objects", "=", "self", ".", "get_dbcollection_with_es", "(", "*", "*", "kwargs", ")", "return", "self", ".", "Model", ".", "_update_many", "(", "db_objects", ",", "self", ".", "_js...
Update multiple objects from collection. First ES is queried, then the results are used to query DB. This is done to make sure updated objects are those filtered by ES in the 'index' method (so user updates what he saw).
[ "Update", "multiple", "objects", "from", "collection", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/views.py#L328-L337
train
ramses-tech/ramses
ramses/views.py
ItemSubresourceBaseView._get_context_key
def _get_context_key(self, **kwargs): """ Get value of `self._resource.parent.id_name` from :kwargs: """ return str(kwargs.get(self._resource.parent.id_name))
python
def _get_context_key(self, **kwargs): """ Get value of `self._resource.parent.id_name` from :kwargs: """ return str(kwargs.get(self._resource.parent.id_name))
[ "def", "_get_context_key", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "str", "(", "kwargs", ".", "get", "(", "self", ".", "_resource", ".", "parent", ".", "id_name", ")", ")" ]
Get value of `self._resource.parent.id_name` from :kwargs:
[ "Get", "value", "of", "self", ".", "_resource", ".", "parent", ".", "id_name", "from", ":", "kwargs", ":" ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/views.py#L359-L361
train
ramses-tech/ramses
ramses/views.py
ItemSubresourceBaseView.get_item
def get_item(self, **kwargs): """ Reload context on each access. """ self.reload_context(es_based=False, **kwargs) return super(ItemSubresourceBaseView, self).get_item(**kwargs)
python
def get_item(self, **kwargs): """ Reload context on each access. """ self.reload_context(es_based=False, **kwargs) return super(ItemSubresourceBaseView, self).get_item(**kwargs)
[ "def", "get_item", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "reload_context", "(", "es_based", "=", "False", ",", "*", "*", "kwargs", ")", "return", "super", "(", "ItemSubresourceBaseView", ",", "self", ")", ".", "get_item", "(", "*...
Reload context on each access.
[ "Reload", "context", "on", "each", "access", "." ]
ea2e1e896325b7256cdf5902309e05fd98e0c14c
https://github.com/ramses-tech/ramses/blob/ea2e1e896325b7256cdf5902309e05fd98e0c14c/ramses/views.py#L363-L366
train
edoburu/sphinxcontrib-django
sphinxcontrib_django/__init__.py
setup
def setup(app): """Allow this module to be used as sphinx extension. This attaches the Sphinx hooks. :type app: sphinx.application.Sphinx """ import sphinxcontrib_django.docstrings import sphinxcontrib_django.roles # Setup both modules at once. They can also be separately imported to #...
python
def setup(app): """Allow this module to be used as sphinx extension. This attaches the Sphinx hooks. :type app: sphinx.application.Sphinx """ import sphinxcontrib_django.docstrings import sphinxcontrib_django.roles # Setup both modules at once. They can also be separately imported to #...
[ "def", "setup", "(", "app", ")", ":", "import", "sphinxcontrib_django", ".", "docstrings", "import", "sphinxcontrib_django", ".", "roles", "# Setup both modules at once. They can also be separately imported to", "# use only fragments of this package.", "sphinxcontrib_django", ".", ...
Allow this module to be used as sphinx extension. This attaches the Sphinx hooks. :type app: sphinx.application.Sphinx
[ "Allow", "this", "module", "to", "be", "used", "as", "sphinx", "extension", ".", "This", "attaches", "the", "Sphinx", "hooks", "." ]
5116ac7f1510a76b1ff58cf7f8d2fab7d8bbe2a9
https://github.com/edoburu/sphinxcontrib-django/blob/5116ac7f1510a76b1ff58cf7f8d2fab7d8bbe2a9/sphinxcontrib_django/__init__.py#L8-L20
train
edoburu/sphinxcontrib-django
sphinxcontrib_django/patches.py
patch_django_for_autodoc
def patch_django_for_autodoc(): """Fix the appearance of some classes in autodoc. This avoids query evaluation. """ # Fix Django's manager appearance ManagerDescriptor.__get__ = lambda self, *args, **kwargs: self.manager # Stop Django from executing DB queries models.QuerySet.__repr__ = la...
python
def patch_django_for_autodoc(): """Fix the appearance of some classes in autodoc. This avoids query evaluation. """ # Fix Django's manager appearance ManagerDescriptor.__get__ = lambda self, *args, **kwargs: self.manager # Stop Django from executing DB queries models.QuerySet.__repr__ = la...
[ "def", "patch_django_for_autodoc", "(", ")", ":", "# Fix Django's manager appearance", "ManagerDescriptor", ".", "__get__", "=", "lambda", "self", ",", "*", "args", ",", "*", "*", "kwargs", ":", "self", ".", "manager", "# Stop Django from executing DB queries", "model...
Fix the appearance of some classes in autodoc. This avoids query evaluation.
[ "Fix", "the", "appearance", "of", "some", "classes", "in", "autodoc", "." ]
5116ac7f1510a76b1ff58cf7f8d2fab7d8bbe2a9
https://github.com/edoburu/sphinxcontrib-django/blob/5116ac7f1510a76b1ff58cf7f8d2fab7d8bbe2a9/sphinxcontrib_django/patches.py#L5-L14
train
edoburu/sphinxcontrib-django
sphinxcontrib_django/docstrings.py
setup
def setup(app): """Allow this package to be used as Sphinx extension. This is also called from the top-level ``__init__.py``. :type app: sphinx.application.Sphinx """ from .patches import patch_django_for_autodoc # When running, make sure Django doesn't execute querysets patch_django_for_a...
python
def setup(app): """Allow this package to be used as Sphinx extension. This is also called from the top-level ``__init__.py``. :type app: sphinx.application.Sphinx """ from .patches import patch_django_for_autodoc # When running, make sure Django doesn't execute querysets patch_django_for_a...
[ "def", "setup", "(", "app", ")", ":", "from", ".", "patches", "import", "patch_django_for_autodoc", "# When running, make sure Django doesn't execute querysets", "patch_django_for_autodoc", "(", ")", "# Generate docstrings for Django model fields", "# Register the docstring processor...
Allow this package to be used as Sphinx extension. This is also called from the top-level ``__init__.py``. :type app: sphinx.application.Sphinx
[ "Allow", "this", "package", "to", "be", "used", "as", "Sphinx", "extension", ".", "This", "is", "also", "called", "from", "the", "top", "-", "level", "__init__", ".", "py", "." ]
5116ac7f1510a76b1ff58cf7f8d2fab7d8bbe2a9
https://github.com/edoburu/sphinxcontrib-django/blob/5116ac7f1510a76b1ff58cf7f8d2fab7d8bbe2a9/sphinxcontrib_django/docstrings.py#L43-L59
train
edoburu/sphinxcontrib-django
sphinxcontrib_django/docstrings.py
autodoc_skip
def autodoc_skip(app, what, name, obj, skip, options): """Hook that tells autodoc to include or exclude certain fields. Sadly, it doesn't give a reference to the parent object, so only the ``name`` can be used for referencing. :type app: sphinx.application.Sphinx :param what: The parent type, ``cl...
python
def autodoc_skip(app, what, name, obj, skip, options): """Hook that tells autodoc to include or exclude certain fields. Sadly, it doesn't give a reference to the parent object, so only the ``name`` can be used for referencing. :type app: sphinx.application.Sphinx :param what: The parent type, ``cl...
[ "def", "autodoc_skip", "(", "app", ",", "what", ",", "name", ",", "obj", ",", "skip", ",", "options", ")", ":", "if", "name", "in", "config", ".", "EXCLUDE_MEMBERS", ":", "return", "True", "if", "name", "in", "config", ".", "INCLUDE_MEMBERS", ":", "ret...
Hook that tells autodoc to include or exclude certain fields. Sadly, it doesn't give a reference to the parent object, so only the ``name`` can be used for referencing. :type app: sphinx.application.Sphinx :param what: The parent type, ``class`` or ``module`` :type what: str :param name: The n...
[ "Hook", "that", "tells", "autodoc", "to", "include", "or", "exclude", "certain", "fields", "." ]
5116ac7f1510a76b1ff58cf7f8d2fab7d8bbe2a9
https://github.com/edoburu/sphinxcontrib-django/blob/5116ac7f1510a76b1ff58cf7f8d2fab7d8bbe2a9/sphinxcontrib_django/docstrings.py#L62-L85
train
edoburu/sphinxcontrib-django
sphinxcontrib_django/docstrings.py
improve_model_docstring
def improve_model_docstring(app, what, name, obj, options, lines): """Hook that improves the autodoc docstrings for Django models. :type app: sphinx.application.Sphinx :param what: The parent type, ``class`` or ``module`` :type what: str :param name: The dotted path to the child method/attribute. ...
python
def improve_model_docstring(app, what, name, obj, options, lines): """Hook that improves the autodoc docstrings for Django models. :type app: sphinx.application.Sphinx :param what: The parent type, ``class`` or ``module`` :type what: str :param name: The dotted path to the child method/attribute. ...
[ "def", "improve_model_docstring", "(", "app", ",", "what", ",", "name", ",", "obj", ",", "options", ",", "lines", ")", ":", "if", "what", "==", "'class'", ":", "_improve_class_docs", "(", "app", ",", "obj", ",", "lines", ")", "elif", "what", "==", "'at...
Hook that improves the autodoc docstrings for Django models. :type app: sphinx.application.Sphinx :param what: The parent type, ``class`` or ``module`` :type what: str :param name: The dotted path to the child method/attribute. :type name: str :param obj: The Python object that i s being docume...
[ "Hook", "that", "improves", "the", "autodoc", "docstrings", "for", "Django", "models", "." ]
5116ac7f1510a76b1ff58cf7f8d2fab7d8bbe2a9
https://github.com/edoburu/sphinxcontrib-django/blob/5116ac7f1510a76b1ff58cf7f8d2fab7d8bbe2a9/sphinxcontrib_django/docstrings.py#L88-L110
train
edoburu/sphinxcontrib-django
sphinxcontrib_django/docstrings.py
_improve_class_docs
def _improve_class_docs(app, cls, lines): """Improve the documentation of a class.""" if issubclass(cls, models.Model): _add_model_fields_as_params(app, cls, lines) elif issubclass(cls, forms.Form): _add_form_fields(cls, lines)
python
def _improve_class_docs(app, cls, lines): """Improve the documentation of a class.""" if issubclass(cls, models.Model): _add_model_fields_as_params(app, cls, lines) elif issubclass(cls, forms.Form): _add_form_fields(cls, lines)
[ "def", "_improve_class_docs", "(", "app", ",", "cls", ",", "lines", ")", ":", "if", "issubclass", "(", "cls", ",", "models", ".", "Model", ")", ":", "_add_model_fields_as_params", "(", "app", ",", "cls", ",", "lines", ")", "elif", "issubclass", "(", "cls...
Improve the documentation of a class.
[ "Improve", "the", "documentation", "of", "a", "class", "." ]
5116ac7f1510a76b1ff58cf7f8d2fab7d8bbe2a9
https://github.com/edoburu/sphinxcontrib-django/blob/5116ac7f1510a76b1ff58cf7f8d2fab7d8bbe2a9/sphinxcontrib_django/docstrings.py#L113-L118
train
edoburu/sphinxcontrib-django
sphinxcontrib_django/docstrings.py
_add_model_fields_as_params
def _add_model_fields_as_params(app, obj, lines): """Improve the documentation of a Django model subclass. This adds all model fields as parameters to the ``__init__()`` method. :type app: sphinx.application.Sphinx :type lines: list """ for field in obj._meta.get_fields(): try: ...
python
def _add_model_fields_as_params(app, obj, lines): """Improve the documentation of a Django model subclass. This adds all model fields as parameters to the ``__init__()`` method. :type app: sphinx.application.Sphinx :type lines: list """ for field in obj._meta.get_fields(): try: ...
[ "def", "_add_model_fields_as_params", "(", "app", ",", "obj", ",", "lines", ")", ":", "for", "field", "in", "obj", ".", "_meta", ".", "get_fields", "(", ")", ":", "try", ":", "help_text", "=", "strip_tags", "(", "force_text", "(", "field", ".", "help_tex...
Improve the documentation of a Django model subclass. This adds all model fields as parameters to the ``__init__()`` method. :type app: sphinx.application.Sphinx :type lines: list
[ "Improve", "the", "documentation", "of", "a", "Django", "model", "subclass", "." ]
5116ac7f1510a76b1ff58cf7f8d2fab7d8bbe2a9
https://github.com/edoburu/sphinxcontrib-django/blob/5116ac7f1510a76b1ff58cf7f8d2fab7d8bbe2a9/sphinxcontrib_django/docstrings.py#L121-L149
train
edoburu/sphinxcontrib-django
sphinxcontrib_django/docstrings.py
_add_form_fields
def _add_form_fields(obj, lines): """Improve the documentation of a Django Form class. This highlights the available fields in the form. """ lines.append("**Form fields:**") lines.append("") for name, field in obj.base_fields.items(): field_type = "{}.{}".format(field.__class__.__module...
python
def _add_form_fields(obj, lines): """Improve the documentation of a Django Form class. This highlights the available fields in the form. """ lines.append("**Form fields:**") lines.append("") for name, field in obj.base_fields.items(): field_type = "{}.{}".format(field.__class__.__module...
[ "def", "_add_form_fields", "(", "obj", ",", "lines", ")", ":", "lines", ".", "append", "(", "\"**Form fields:**\"", ")", "lines", ".", "append", "(", "\"\"", ")", "for", "name", ",", "field", "in", "obj", ".", "base_fields", ".", "items", "(", ")", ":"...
Improve the documentation of a Django Form class. This highlights the available fields in the form.
[ "Improve", "the", "documentation", "of", "a", "Django", "Form", "class", "." ]
5116ac7f1510a76b1ff58cf7f8d2fab7d8bbe2a9
https://github.com/edoburu/sphinxcontrib-django/blob/5116ac7f1510a76b1ff58cf7f8d2fab7d8bbe2a9/sphinxcontrib_django/docstrings.py#L152-L167
train
edoburu/sphinxcontrib-django
sphinxcontrib_django/docstrings.py
_improve_attribute_docs
def _improve_attribute_docs(obj, name, lines): """Improve the documentation of various attributes. This improves the navigation between related objects. :param obj: the instance of the object to document. :param name: full dotted path to the object. :param lines: expected documentation lines. "...
python
def _improve_attribute_docs(obj, name, lines): """Improve the documentation of various attributes. This improves the navigation between related objects. :param obj: the instance of the object to document. :param name: full dotted path to the object. :param lines: expected documentation lines. "...
[ "def", "_improve_attribute_docs", "(", "obj", ",", "name", ",", "lines", ")", ":", "if", "obj", "is", "None", ":", "# Happens with form attributes.", "return", "if", "isinstance", "(", "obj", ",", "DeferredAttribute", ")", ":", "# This only points to a field name, n...
Improve the documentation of various attributes. This improves the navigation between related objects. :param obj: the instance of the object to document. :param name: full dotted path to the object. :param lines: expected documentation lines.
[ "Improve", "the", "documentation", "of", "various", "attributes", ".", "This", "improves", "the", "navigation", "between", "related", "objects", "." ]
5116ac7f1510a76b1ff58cf7f8d2fab7d8bbe2a9
https://github.com/edoburu/sphinxcontrib-django/blob/5116ac7f1510a76b1ff58cf7f8d2fab7d8bbe2a9/sphinxcontrib_django/docstrings.py#L195-L268
train
edoburu/sphinxcontrib-django
sphinxcontrib_django/docstrings.py
_improve_method_docs
def _improve_method_docs(obj, name, lines): """Improve the documentation of various methods. :param obj: the instance of the method to document. :param name: full dotted path to the object. :param lines: expected documentation lines. """ if not lines: # Not doing obj.__module__ lookups ...
python
def _improve_method_docs(obj, name, lines): """Improve the documentation of various methods. :param obj: the instance of the method to document. :param name: full dotted path to the object. :param lines: expected documentation lines. """ if not lines: # Not doing obj.__module__ lookups ...
[ "def", "_improve_method_docs", "(", "obj", ",", "name", ",", "lines", ")", ":", "if", "not", "lines", ":", "# Not doing obj.__module__ lookups to avoid performance issues.", "if", "name", ".", "endswith", "(", "'_display'", ")", ":", "match", "=", "RE_GET_FOO_DISPLA...
Improve the documentation of various methods. :param obj: the instance of the method to document. :param name: full dotted path to the object. :param lines: expected documentation lines.
[ "Improve", "the", "documentation", "of", "various", "methods", "." ]
5116ac7f1510a76b1ff58cf7f8d2fab7d8bbe2a9
https://github.com/edoburu/sphinxcontrib-django/blob/5116ac7f1510a76b1ff58cf7f8d2fab7d8bbe2a9/sphinxcontrib_django/docstrings.py#L271-L300
train
ramazanpolat/prodict
prodict/__init__.py
Prodict.attr_names
def attr_names(cls) -> List[str]: """ Returns annotated attribute names :return: List[str] """ return [k for k, v in cls.attr_types().items()]
python
def attr_names(cls) -> List[str]: """ Returns annotated attribute names :return: List[str] """ return [k for k, v in cls.attr_types().items()]
[ "def", "attr_names", "(", "cls", ")", "->", "List", "[", "str", "]", ":", "return", "[", "k", "for", "k", ",", "v", "in", "cls", ".", "attr_types", "(", ")", ".", "items", "(", ")", "]" ]
Returns annotated attribute names :return: List[str]
[ "Returns", "annotated", "attribute", "names", ":", "return", ":", "List", "[", "str", "]" ]
e67e34738af1542f3b6c91c0e838f5be9a84aad4
https://github.com/ramazanpolat/prodict/blob/e67e34738af1542f3b6c91c0e838f5be9a84aad4/prodict/__init__.py#L49-L54
train
hbldh/pyefd
pyefd.py
elliptic_fourier_descriptors
def elliptic_fourier_descriptors(contour, order=10, normalize=False): """Calculate elliptical Fourier descriptors for a contour. :param numpy.ndarray contour: A contour array of size ``[M x 2]``. :param int order: The order of Fourier coefficients to calculate. :param bool normalize: If the coefficient...
python
def elliptic_fourier_descriptors(contour, order=10, normalize=False): """Calculate elliptical Fourier descriptors for a contour. :param numpy.ndarray contour: A contour array of size ``[M x 2]``. :param int order: The order of Fourier coefficients to calculate. :param bool normalize: If the coefficient...
[ "def", "elliptic_fourier_descriptors", "(", "contour", ",", "order", "=", "10", ",", "normalize", "=", "False", ")", ":", "dxy", "=", "np", ".", "diff", "(", "contour", ",", "axis", "=", "0", ")", "dt", "=", "np", ".", "sqrt", "(", "(", "dxy", "**"...
Calculate elliptical Fourier descriptors for a contour. :param numpy.ndarray contour: A contour array of size ``[M x 2]``. :param int order: The order of Fourier coefficients to calculate. :param bool normalize: If the coefficients should be normalized; see references for details. :return: A ``...
[ "Calculate", "elliptical", "Fourier", "descriptors", "for", "a", "contour", "." ]
5c4e880fd6e70e8077fc8c0be4eec9df5b9ee596
https://github.com/hbldh/pyefd/blob/5c4e880fd6e70e8077fc8c0be4eec9df5b9ee596/pyefd.py#L37-L70
train
hbldh/pyefd
pyefd.py
normalize_efd
def normalize_efd(coeffs, size_invariant=True): """Normalizes an array of Fourier coefficients. See [#a]_ and [#b]_ for details. :param numpy.ndarray coeffs: A ``[n x 4]`` Fourier coefficient array. :param bool size_invariant: If size invariance normalizing should be done as well. Default is `...
python
def normalize_efd(coeffs, size_invariant=True): """Normalizes an array of Fourier coefficients. See [#a]_ and [#b]_ for details. :param numpy.ndarray coeffs: A ``[n x 4]`` Fourier coefficient array. :param bool size_invariant: If size invariance normalizing should be done as well. Default is `...
[ "def", "normalize_efd", "(", "coeffs", ",", "size_invariant", "=", "True", ")", ":", "# Make the coefficients have a zero phase shift from", "# the first major axis. Theta_1 is that shift angle.", "theta_1", "=", "0.5", "*", "np", ".", "arctan2", "(", "2", "*", "(", "("...
Normalizes an array of Fourier coefficients. See [#a]_ and [#b]_ for details. :param numpy.ndarray coeffs: A ``[n x 4]`` Fourier coefficient array. :param bool size_invariant: If size invariance normalizing should be done as well. Default is ``True``. :return: The normalized ``[n x 4]`` Fourie...
[ "Normalizes", "an", "array", "of", "Fourier", "coefficients", "." ]
5c4e880fd6e70e8077fc8c0be4eec9df5b9ee596
https://github.com/hbldh/pyefd/blob/5c4e880fd6e70e8077fc8c0be4eec9df5b9ee596/pyefd.py#L73-L113
train
hbldh/pyefd
pyefd.py
calculate_dc_coefficients
def calculate_dc_coefficients(contour): """Calculate the :math:`A_0` and :math:`C_0` coefficients of the elliptic Fourier series. :param numpy.ndarray contour: A contour array of size ``[M x 2]``. :return: The :math:`A_0` and :math:`C_0` coefficients. :rtype: tuple """ dxy = np.diff(contour, a...
python
def calculate_dc_coefficients(contour): """Calculate the :math:`A_0` and :math:`C_0` coefficients of the elliptic Fourier series. :param numpy.ndarray contour: A contour array of size ``[M x 2]``. :return: The :math:`A_0` and :math:`C_0` coefficients. :rtype: tuple """ dxy = np.diff(contour, a...
[ "def", "calculate_dc_coefficients", "(", "contour", ")", ":", "dxy", "=", "np", ".", "diff", "(", "contour", ",", "axis", "=", "0", ")", "dt", "=", "np", ".", "sqrt", "(", "(", "dxy", "**", "2", ")", ".", "sum", "(", "axis", "=", "1", ")", ")",...
Calculate the :math:`A_0` and :math:`C_0` coefficients of the elliptic Fourier series. :param numpy.ndarray contour: A contour array of size ``[M x 2]``. :return: The :math:`A_0` and :math:`C_0` coefficients. :rtype: tuple
[ "Calculate", "the", ":", "math", ":", "A_0", "and", ":", "math", ":", "C_0", "coefficients", "of", "the", "elliptic", "Fourier", "series", "." ]
5c4e880fd6e70e8077fc8c0be4eec9df5b9ee596
https://github.com/hbldh/pyefd/blob/5c4e880fd6e70e8077fc8c0be4eec9df5b9ee596/pyefd.py#L116-L136
train
hbldh/pyefd
pyefd.py
plot_efd
def plot_efd(coeffs, locus=(0., 0.), image=None, contour=None, n=300): """Plot a ``[2 x (N / 2)]`` grid of successive truncations of the series. .. note:: Requires `matplotlib <http://matplotlib.org/>`_! :param numpy.ndarray coeffs: ``[N x 4]`` Fourier coefficient array. :param list, tuple or...
python
def plot_efd(coeffs, locus=(0., 0.), image=None, contour=None, n=300): """Plot a ``[2 x (N / 2)]`` grid of successive truncations of the series. .. note:: Requires `matplotlib <http://matplotlib.org/>`_! :param numpy.ndarray coeffs: ``[N x 4]`` Fourier coefficient array. :param list, tuple or...
[ "def", "plot_efd", "(", "coeffs", ",", "locus", "=", "(", "0.", ",", "0.", ")", ",", "image", "=", "None", ",", "contour", "=", "None", ",", "n", "=", "300", ")", ":", "try", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", "except", "Imp...
Plot a ``[2 x (N / 2)]`` grid of successive truncations of the series. .. note:: Requires `matplotlib <http://matplotlib.org/>`_! :param numpy.ndarray coeffs: ``[N x 4]`` Fourier coefficient array. :param list, tuple or numpy.ndarray locus: The :math:`A_0` and :math:`C_0` elliptic locus i...
[ "Plot", "a", "[", "2", "x", "(", "N", "/", "2", ")", "]", "grid", "of", "successive", "truncations", "of", "the", "series", "." ]
5c4e880fd6e70e8077fc8c0be4eec9df5b9ee596
https://github.com/hbldh/pyefd/blob/5c4e880fd6e70e8077fc8c0be4eec9df5b9ee596/pyefd.py#L139-L179
train
rshk/python-libxdo
xdo/xdo.py
_errcheck
def _errcheck(result, func, arguments): """ Error checker for functions returning an integer indicating success (0) / failure (1). Raises a XdoException in case of error, otherwise just returns ``None`` (returning the original code, 0, would be useless anyways..) """ if result != 0: ...
python
def _errcheck(result, func, arguments): """ Error checker for functions returning an integer indicating success (0) / failure (1). Raises a XdoException in case of error, otherwise just returns ``None`` (returning the original code, 0, would be useless anyways..) """ if result != 0: ...
[ "def", "_errcheck", "(", "result", ",", "func", ",", "arguments", ")", ":", "if", "result", "!=", "0", ":", "raise", "XdoException", "(", "'Function {0} returned error code {1}'", ".", "format", "(", "func", ".", "__name__", ",", "result", ")", ")", "return"...
Error checker for functions returning an integer indicating success (0) / failure (1). Raises a XdoException in case of error, otherwise just returns ``None`` (returning the original code, 0, would be useless anyways..)
[ "Error", "checker", "for", "functions", "returning", "an", "integer", "indicating", "success", "(", "0", ")", "/", "failure", "(", "1", ")", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/xdo.py#L37-L51
train
rshk/python-libxdo
xdo/__init__.py
_gen_input_mask
def _gen_input_mask(mask): """Generate input mask from bytemask""" return input_mask( shift=bool(mask & MOD_Shift), lock=bool(mask & MOD_Lock), control=bool(mask & MOD_Control), mod1=bool(mask & MOD_Mod1), mod2=bool(mask & MOD_Mod2), mod3=bool(mask & MOD_Mod3), ...
python
def _gen_input_mask(mask): """Generate input mask from bytemask""" return input_mask( shift=bool(mask & MOD_Shift), lock=bool(mask & MOD_Lock), control=bool(mask & MOD_Control), mod1=bool(mask & MOD_Mod1), mod2=bool(mask & MOD_Mod2), mod3=bool(mask & MOD_Mod3), ...
[ "def", "_gen_input_mask", "(", "mask", ")", ":", "return", "input_mask", "(", "shift", "=", "bool", "(", "mask", "&", "MOD_Shift", ")", ",", "lock", "=", "bool", "(", "mask", "&", "MOD_Lock", ")", ",", "control", "=", "bool", "(", "mask", "&", "MOD_C...
Generate input mask from bytemask
[ "Generate", "input", "mask", "from", "bytemask" ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L43-L53
train
rshk/python-libxdo
xdo/__init__.py
Xdo.move_mouse
def move_mouse(self, x, y, screen=0): """ Move the mouse to a specific location. :param x: the target X coordinate on the screen in pixels. :param y: the target Y coordinate on the screen in pixels. :param screen: the screen (number) you want to move on. """ # to...
python
def move_mouse(self, x, y, screen=0): """ Move the mouse to a specific location. :param x: the target X coordinate on the screen in pixels. :param y: the target Y coordinate on the screen in pixels. :param screen: the screen (number) you want to move on. """ # to...
[ "def", "move_mouse", "(", "self", ",", "x", ",", "y", ",", "screen", "=", "0", ")", ":", "# todo: apparently the \"screen\" argument is not behaving properly", "# and sometimes even making the interpreter crash..", "# Figure out why (changed API / using wrong header?)", ...
Move the mouse to a specific location. :param x: the target X coordinate on the screen in pixels. :param y: the target Y coordinate on the screen in pixels. :param screen: the screen (number) you want to move on.
[ "Move", "the", "mouse", "to", "a", "specific", "location", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L83-L110
train
rshk/python-libxdo
xdo/__init__.py
Xdo.move_mouse_relative_to_window
def move_mouse_relative_to_window(self, window, x, y): """ Move the mouse to a specific location relative to the top-left corner of a window. :param x: the target X coordinate on the screen in pixels. :param y: the target Y coordinate on the screen in pixels. """ ...
python
def move_mouse_relative_to_window(self, window, x, y): """ Move the mouse to a specific location relative to the top-left corner of a window. :param x: the target X coordinate on the screen in pixels. :param y: the target Y coordinate on the screen in pixels. """ ...
[ "def", "move_mouse_relative_to_window", "(", "self", ",", "window", ",", "x", ",", "y", ")", ":", "_libxdo", ".", "xdo_move_mouse_relative_to_window", "(", "self", ".", "_xdo", ",", "ctypes", ".", "c_ulong", "(", "window", ")", ",", "x", ",", "y", ")" ]
Move the mouse to a specific location relative to the top-left corner of a window. :param x: the target X coordinate on the screen in pixels. :param y: the target Y coordinate on the screen in pixels.
[ "Move", "the", "mouse", "to", "a", "specific", "location", "relative", "to", "the", "top", "-", "left", "corner", "of", "a", "window", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L112-L121
train
rshk/python-libxdo
xdo/__init__.py
Xdo.move_mouse_relative
def move_mouse_relative(self, x, y): """ Move the mouse relative to it's current position. :param x: the distance in pixels to move on the X axis. :param y: the distance in pixels to move on the Y axis. """ _libxdo.xdo_move_mouse_relative(self._xdo, x, y)
python
def move_mouse_relative(self, x, y): """ Move the mouse relative to it's current position. :param x: the distance in pixels to move on the X axis. :param y: the distance in pixels to move on the Y axis. """ _libxdo.xdo_move_mouse_relative(self._xdo, x, y)
[ "def", "move_mouse_relative", "(", "self", ",", "x", ",", "y", ")", ":", "_libxdo", ".", "xdo_move_mouse_relative", "(", "self", ".", "_xdo", ",", "x", ",", "y", ")" ]
Move the mouse relative to it's current position. :param x: the distance in pixels to move on the X axis. :param y: the distance in pixels to move on the Y axis.
[ "Move", "the", "mouse", "relative", "to", "it", "s", "current", "position", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L123-L130
train
rshk/python-libxdo
xdo/__init__.py
Xdo.mouse_down
def mouse_down(self, window, button): """ Send a mouse press (aka mouse down) for a given button at the current mouse location. :param window: The window you want to send the event to or CURRENTWINDOW :param button: The mouse button. Generally, 1 is left,...
python
def mouse_down(self, window, button): """ Send a mouse press (aka mouse down) for a given button at the current mouse location. :param window: The window you want to send the event to or CURRENTWINDOW :param button: The mouse button. Generally, 1 is left,...
[ "def", "mouse_down", "(", "self", ",", "window", ",", "button", ")", ":", "_libxdo", ".", "xdo_mouse_down", "(", "self", ".", "_xdo", ",", "ctypes", ".", "c_ulong", "(", "window", ")", ",", "ctypes", ".", "c_int", "(", "button", ")", ")" ]
Send a mouse press (aka mouse down) for a given button at the current mouse location. :param window: The window you want to send the event to or CURRENTWINDOW :param button: The mouse button. Generally, 1 is left, 2 is middle, 3 is right, 4 is wheel up, 5 is ...
[ "Send", "a", "mouse", "press", "(", "aka", "mouse", "down", ")", "for", "a", "given", "button", "at", "the", "current", "mouse", "location", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L132-L144
train
rshk/python-libxdo
xdo/__init__.py
Xdo.mouse_up
def mouse_up(self, window, button): """ Send a mouse release (aka mouse up) for a given button at the current mouse location. :param window: The window you want to send the event to or CURRENTWINDOW :param button: The mouse button. Generally, 1 is left, 2...
python
def mouse_up(self, window, button): """ Send a mouse release (aka mouse up) for a given button at the current mouse location. :param window: The window you want to send the event to or CURRENTWINDOW :param button: The mouse button. Generally, 1 is left, 2...
[ "def", "mouse_up", "(", "self", ",", "window", ",", "button", ")", ":", "_libxdo", ".", "xdo_mouse_up", "(", "self", ".", "_xdo", ",", "ctypes", ".", "c_ulong", "(", "window", ")", ",", "ctypes", ".", "c_int", "(", "button", ")", ")" ]
Send a mouse release (aka mouse up) for a given button at the current mouse location. :param window: The window you want to send the event to or CURRENTWINDOW :param button: The mouse button. Generally, 1 is left, 2 is middle, 3 is right, 4 is wheel up, 5 is ...
[ "Send", "a", "mouse", "release", "(", "aka", "mouse", "up", ")", "for", "a", "given", "button", "at", "the", "current", "mouse", "location", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L146-L158
train
rshk/python-libxdo
xdo/__init__.py
Xdo.get_mouse_location
def get_mouse_location(self): """ Get the current mouse location (coordinates and screen number). :return: a namedtuple with ``x``, ``y`` and ``screen_num`` fields """ x = ctypes.c_int(0) y = ctypes.c_int(0) screen_num = ctypes.c_int(0) _libxdo.xdo_get_mo...
python
def get_mouse_location(self): """ Get the current mouse location (coordinates and screen number). :return: a namedtuple with ``x``, ``y`` and ``screen_num`` fields """ x = ctypes.c_int(0) y = ctypes.c_int(0) screen_num = ctypes.c_int(0) _libxdo.xdo_get_mo...
[ "def", "get_mouse_location", "(", "self", ")", ":", "x", "=", "ctypes", ".", "c_int", "(", "0", ")", "y", "=", "ctypes", ".", "c_int", "(", "0", ")", "screen_num", "=", "ctypes", ".", "c_int", "(", "0", ")", "_libxdo", ".", "xdo_get_mouse_location", ...
Get the current mouse location (coordinates and screen number). :return: a namedtuple with ``x``, ``y`` and ``screen_num`` fields
[ "Get", "the", "current", "mouse", "location", "(", "coordinates", "and", "screen", "number", ")", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L160-L172
train
rshk/python-libxdo
xdo/__init__.py
Xdo.get_window_at_mouse
def get_window_at_mouse(self): """ Get the window the mouse is currently over """ window_ret = ctypes.c_ulong(0) _libxdo.xdo_get_window_at_mouse(self._xdo, ctypes.byref(window_ret)) return window_ret.value
python
def get_window_at_mouse(self): """ Get the window the mouse is currently over """ window_ret = ctypes.c_ulong(0) _libxdo.xdo_get_window_at_mouse(self._xdo, ctypes.byref(window_ret)) return window_ret.value
[ "def", "get_window_at_mouse", "(", "self", ")", ":", "window_ret", "=", "ctypes", ".", "c_ulong", "(", "0", ")", "_libxdo", ".", "xdo_get_window_at_mouse", "(", "self", ".", "_xdo", ",", "ctypes", ".", "byref", "(", "window_ret", ")", ")", "return", "windo...
Get the window the mouse is currently over
[ "Get", "the", "window", "the", "mouse", "is", "currently", "over" ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L174-L180
train
rshk/python-libxdo
xdo/__init__.py
Xdo.get_mouse_location2
def get_mouse_location2(self): """ Get all mouse location-related data. :return: a namedtuple with ``x``, ``y``, ``screen_num`` and ``window`` fields """ x = ctypes.c_int(0) y = ctypes.c_int(0) screen_num_ret = ctypes.c_ulong(0) window_ret = c...
python
def get_mouse_location2(self): """ Get all mouse location-related data. :return: a namedtuple with ``x``, ``y``, ``screen_num`` and ``window`` fields """ x = ctypes.c_int(0) y = ctypes.c_int(0) screen_num_ret = ctypes.c_ulong(0) window_ret = c...
[ "def", "get_mouse_location2", "(", "self", ")", ":", "x", "=", "ctypes", ".", "c_int", "(", "0", ")", "y", "=", "ctypes", ".", "c_int", "(", "0", ")", "screen_num_ret", "=", "ctypes", ".", "c_ulong", "(", "0", ")", "window_ret", "=", "ctypes", ".", ...
Get all mouse location-related data. :return: a namedtuple with ``x``, ``y``, ``screen_num`` and ``window`` fields
[ "Get", "all", "mouse", "location", "-", "related", "data", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L182-L197
train
rshk/python-libxdo
xdo/__init__.py
Xdo.wait_for_mouse_move_from
def wait_for_mouse_move_from(self, origin_x, origin_y): """ Wait for the mouse to move from a location. This function will block until the condition has been satisified. :param origin_x: the X position you expect the mouse to move from :param origin_y: the Y position you expect ...
python
def wait_for_mouse_move_from(self, origin_x, origin_y): """ Wait for the mouse to move from a location. This function will block until the condition has been satisified. :param origin_x: the X position you expect the mouse to move from :param origin_y: the Y position you expect ...
[ "def", "wait_for_mouse_move_from", "(", "self", ",", "origin_x", ",", "origin_y", ")", ":", "_libxdo", ".", "xdo_wait_for_mouse_move_from", "(", "self", ".", "_xdo", ",", "origin_x", ",", "origin_y", ")" ]
Wait for the mouse to move from a location. This function will block until the condition has been satisified. :param origin_x: the X position you expect the mouse to move from :param origin_y: the Y position you expect the mouse to move from
[ "Wait", "for", "the", "mouse", "to", "move", "from", "a", "location", ".", "This", "function", "will", "block", "until", "the", "condition", "has", "been", "satisified", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L199-L207
train
rshk/python-libxdo
xdo/__init__.py
Xdo.wait_for_mouse_move_to
def wait_for_mouse_move_to(self, dest_x, dest_y): """ Wait for the mouse to move to a location. This function will block until the condition has been satisified. :param dest_x: the X position you expect the mouse to move to :param dest_y: the Y position you expect the mouse to m...
python
def wait_for_mouse_move_to(self, dest_x, dest_y): """ Wait for the mouse to move to a location. This function will block until the condition has been satisified. :param dest_x: the X position you expect the mouse to move to :param dest_y: the Y position you expect the mouse to m...
[ "def", "wait_for_mouse_move_to", "(", "self", ",", "dest_x", ",", "dest_y", ")", ":", "_libxdo", ".", "xdo_wait_for_mouse_move_from", "(", "self", ".", "_xdo", ",", "dest_x", ",", "dest_y", ")" ]
Wait for the mouse to move to a location. This function will block until the condition has been satisified. :param dest_x: the X position you expect the mouse to move to :param dest_y: the Y position you expect the mouse to move to
[ "Wait", "for", "the", "mouse", "to", "move", "to", "a", "location", ".", "This", "function", "will", "block", "until", "the", "condition", "has", "been", "satisified", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L209-L217
train
rshk/python-libxdo
xdo/__init__.py
Xdo.click_window
def click_window(self, window, button): """ Send a click for a specific mouse button at the current mouse location. :param window: The window you want to send the event to or CURRENTWINDOW :param button: The mouse button. Generally, 1 is left, 2 is middle, 3 is ...
python
def click_window(self, window, button): """ Send a click for a specific mouse button at the current mouse location. :param window: The window you want to send the event to or CURRENTWINDOW :param button: The mouse button. Generally, 1 is left, 2 is middle, 3 is ...
[ "def", "click_window", "(", "self", ",", "window", ",", "button", ")", ":", "_libxdo", ".", "xdo_click_window", "(", "self", ".", "_xdo", ",", "window", ",", "button", ")" ]
Send a click for a specific mouse button at the current mouse location. :param window: The window you want to send the event to or CURRENTWINDOW :param button: The mouse button. Generally, 1 is left, 2 is middle, 3 is right, 4 is wheel up, 5 is wheel down.
[ "Send", "a", "click", "for", "a", "specific", "mouse", "button", "at", "the", "current", "mouse", "location", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L219-L229
train
rshk/python-libxdo
xdo/__init__.py
Xdo.click_window_multiple
def click_window_multiple(self, window, button, repeat=2, delay=100000): """ Send a one or more clicks for a specific mouse button at the current mouse location. :param window: The window you want to send the event to or CURRENTWINDOW :param button: The m...
python
def click_window_multiple(self, window, button, repeat=2, delay=100000): """ Send a one or more clicks for a specific mouse button at the current mouse location. :param window: The window you want to send the event to or CURRENTWINDOW :param button: The m...
[ "def", "click_window_multiple", "(", "self", ",", "window", ",", "button", ",", "repeat", "=", "2", ",", "delay", "=", "100000", ")", ":", "_libxdo", ".", "xdo_click_window_multiple", "(", "self", ".", "_xdo", ",", "window", ",", "button", ",", "repeat", ...
Send a one or more clicks for a specific mouse button at the current mouse location. :param window: The window you want to send the event to or CURRENTWINDOW :param button: The mouse button. Generally, 1 is left, 2 is middle, 3 is right, 4 is wheel up, 5 is w...
[ "Send", "a", "one", "or", "more", "clicks", "for", "a", "specific", "mouse", "button", "at", "the", "current", "mouse", "location", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L231-L245
train
rshk/python-libxdo
xdo/__init__.py
Xdo.enter_text_window
def enter_text_window(self, window, string, delay=12000): """ Type a string to the specified window. If you want to send a specific key or key sequence, such as "alt+l", you want instead ``send_keysequence_window(...)``. :param window: The window you want to send ke...
python
def enter_text_window(self, window, string, delay=12000): """ Type a string to the specified window. If you want to send a specific key or key sequence, such as "alt+l", you want instead ``send_keysequence_window(...)``. :param window: The window you want to send ke...
[ "def", "enter_text_window", "(", "self", ",", "window", ",", "string", ",", "delay", "=", "12000", ")", ":", "return", "_libxdo", ".", "xdo_enter_text_window", "(", "self", ".", "_xdo", ",", "window", ",", "string", ",", "delay", ")" ]
Type a string to the specified window. If you want to send a specific key or key sequence, such as "alt+l", you want instead ``send_keysequence_window(...)``. :param window: The window you want to send keystrokes to or CURRENTWINDOW :param string: The string to ...
[ "Type", "a", "string", "to", "the", "specified", "window", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L247-L262
train
rshk/python-libxdo
xdo/__init__.py
Xdo.send_keysequence_window
def send_keysequence_window(self, window, keysequence, delay=12000): """ Send a keysequence to the specified window. This allows you to send keysequences by symbol name. Any combination of X11 KeySym names separated by '+' are valid. Single KeySym names are valid, too. ...
python
def send_keysequence_window(self, window, keysequence, delay=12000): """ Send a keysequence to the specified window. This allows you to send keysequences by symbol name. Any combination of X11 KeySym names separated by '+' are valid. Single KeySym names are valid, too. ...
[ "def", "send_keysequence_window", "(", "self", ",", "window", ",", "keysequence", ",", "delay", "=", "12000", ")", ":", "_libxdo", ".", "xdo_send_keysequence_window", "(", "self", ".", "_xdo", ",", "window", ",", "keysequence", ",", "delay", ")" ]
Send a keysequence to the specified window. This allows you to send keysequences by symbol name. Any combination of X11 KeySym names separated by '+' are valid. Single KeySym names are valid, too. Examples: "l" "semicolon" "alt+Return" "Alt_L+Tab...
[ "Send", "a", "keysequence", "to", "the", "specified", "window", "." ]
84cafa5943b005bc423edd28203a5266b3579ac3
https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L264-L287
train