repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
jbittel/django-mama-cas
mama_cas/models.py
TicketManager.create_ticket
def create_ticket(self, ticket=None, **kwargs): """ Create a new ``Ticket``. Additional arguments are passed to the ``create()`` function. Return the newly created ``Ticket``. """ if not ticket: ticket = self.create_ticket_str() if 'service' in kwargs: ...
python
def create_ticket(self, ticket=None, **kwargs): """ Create a new ``Ticket``. Additional arguments are passed to the ``create()`` function. Return the newly created ``Ticket``. """ if not ticket: ticket = self.create_ticket_str() if 'service' in kwargs: ...
[ "def", "create_ticket", "(", "self", ",", "ticket", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "ticket", ":", "ticket", "=", "self", ".", "create_ticket_str", "(", ")", "if", "'service'", "in", "kwargs", ":", "kwargs", "[", "'service'...
Create a new ``Ticket``. Additional arguments are passed to the ``create()`` function. Return the newly created ``Ticket``.
[ "Create", "a", "new", "Ticket", ".", "Additional", "arguments", "are", "passed", "to", "the", "create", "()", "function", ".", "Return", "the", "newly", "created", "Ticket", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/models.py#L42-L56
jbittel/django-mama-cas
mama_cas/models.py
TicketManager.create_ticket_str
def create_ticket_str(self, prefix=None): """ Generate a sufficiently opaque ticket string to ensure the ticket is not guessable. If a prefix is provided, prepend it to the string. """ if not prefix: prefix = self.model.TICKET_PREFIX return "%s-%d-%s" % (prefi...
python
def create_ticket_str(self, prefix=None): """ Generate a sufficiently opaque ticket string to ensure the ticket is not guessable. If a prefix is provided, prepend it to the string. """ if not prefix: prefix = self.model.TICKET_PREFIX return "%s-%d-%s" % (prefi...
[ "def", "create_ticket_str", "(", "self", ",", "prefix", "=", "None", ")", ":", "if", "not", "prefix", ":", "prefix", "=", "self", ".", "model", ".", "TICKET_PREFIX", "return", "\"%s-%d-%s\"", "%", "(", "prefix", ",", "int", "(", "time", ".", "time", "(...
Generate a sufficiently opaque ticket string to ensure the ticket is not guessable. If a prefix is provided, prepend it to the string.
[ "Generate", "a", "sufficiently", "opaque", "ticket", "string", "to", "ensure", "the", "ticket", "is", "not", "guessable", ".", "If", "a", "prefix", "is", "provided", "prepend", "it", "to", "the", "string", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/models.py#L58-L66
jbittel/django-mama-cas
mama_cas/models.py
TicketManager.validate_ticket
def validate_ticket(self, ticket, service, renew=False, require_https=False): """ Given a ticket string and service identifier, validate the corresponding ``Ticket``. If validation succeeds, return the ``Ticket``. If validation fails, raise an appropriate error. If ``renew`` is ...
python
def validate_ticket(self, ticket, service, renew=False, require_https=False): """ Given a ticket string and service identifier, validate the corresponding ``Ticket``. If validation succeeds, return the ``Ticket``. If validation fails, raise an appropriate error. If ``renew`` is ...
[ "def", "validate_ticket", "(", "self", ",", "ticket", ",", "service", ",", "renew", "=", "False", ",", "require_https", "=", "False", ")", ":", "if", "not", "ticket", ":", "raise", "InvalidRequest", "(", "\"No ticket string provided\"", ")", "if", "not", "se...
Given a ticket string and service identifier, validate the corresponding ``Ticket``. If validation succeeds, return the ``Ticket``. If validation fails, raise an appropriate error. If ``renew`` is ``True``, ``ServiceTicket`` validation will only succeed if the ticket was issued from the...
[ "Given", "a", "ticket", "string", "and", "service", "identifier", "validate", "the", "corresponding", "Ticket", ".", "If", "validation", "succeeds", "return", "the", "Ticket", ".", "If", "validation", "fails", "raise", "an", "appropriate", "error", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/models.py#L68-L123
jbittel/django-mama-cas
mama_cas/models.py
TicketManager.delete_invalid_tickets
def delete_invalid_tickets(self): """ Delete consumed or expired ``Ticket``s that are not referenced by other ``Ticket``s. Invalid tickets are no longer valid for authentication and can be safely deleted. A custom management command is provided that executes this method ...
python
def delete_invalid_tickets(self): """ Delete consumed or expired ``Ticket``s that are not referenced by other ``Ticket``s. Invalid tickets are no longer valid for authentication and can be safely deleted. A custom management command is provided that executes this method ...
[ "def", "delete_invalid_tickets", "(", "self", ")", ":", "for", "ticket", "in", "self", ".", "filter", "(", "Q", "(", "consumed__isnull", "=", "False", ")", "|", "Q", "(", "expires__lte", "=", "now", "(", ")", ")", ")", ".", "order_by", "(", "'-expires'...
Delete consumed or expired ``Ticket``s that are not referenced by other ``Ticket``s. Invalid tickets are no longer valid for authentication and can be safely deleted. A custom management command is provided that executes this method on all applicable models by running ``manage.py cleanu...
[ "Delete", "consumed", "or", "expired", "Ticket", "s", "that", "are", "not", "referenced", "by", "other", "Ticket", "s", ".", "Invalid", "tickets", "are", "no", "longer", "valid", "for", "authentication", "and", "can", "be", "safely", "deleted", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/models.py#L125-L139
jbittel/django-mama-cas
mama_cas/models.py
TicketManager.consume_tickets
def consume_tickets(self, user): """ Consume all valid ``Ticket``s for a specified user. This is run when the user logs out to ensure all issued tickets are no longer valid for future authentication attempts. """ for ticket in self.filter(user=user, consumed__isnull=True,...
python
def consume_tickets(self, user): """ Consume all valid ``Ticket``s for a specified user. This is run when the user logs out to ensure all issued tickets are no longer valid for future authentication attempts. """ for ticket in self.filter(user=user, consumed__isnull=True,...
[ "def", "consume_tickets", "(", "self", ",", "user", ")", ":", "for", "ticket", "in", "self", ".", "filter", "(", "user", "=", "user", ",", "consumed__isnull", "=", "True", ",", "expires__gt", "=", "now", "(", ")", ")", ":", "ticket", ".", "consume", ...
Consume all valid ``Ticket``s for a specified user. This is run when the user logs out to ensure all issued tickets are no longer valid for future authentication attempts.
[ "Consume", "all", "valid", "Ticket", "s", "for", "a", "specified", "user", ".", "This", "is", "run", "when", "the", "user", "logs", "out", "to", "ensure", "all", "issued", "tickets", "are", "no", "longer", "valid", "for", "future", "authentication", "attem...
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/models.py#L141-L149
jbittel/django-mama-cas
mama_cas/models.py
ServiceTicketManager.request_sign_out
def request_sign_out(self, user): """ Send a single logout request to each service accessed by a specified user. This is called at logout when single logout is enabled. If requests-futures is installed, asynchronous requests will be sent. Otherwise, synchronous requests ...
python
def request_sign_out(self, user): """ Send a single logout request to each service accessed by a specified user. This is called at logout when single logout is enabled. If requests-futures is installed, asynchronous requests will be sent. Otherwise, synchronous requests ...
[ "def", "request_sign_out", "(", "self", ",", "user", ")", ":", "session", "=", "Session", "(", ")", "for", "ticket", "in", "self", ".", "filter", "(", "user", "=", "user", ",", "consumed__gte", "=", "user", ".", "last_login", ")", ":", "ticket", ".", ...
Send a single logout request to each service accessed by a specified user. This is called at logout when single logout is enabled. If requests-futures is installed, asynchronous requests will be sent. Otherwise, synchronous requests will be sent.
[ "Send", "a", "single", "logout", "request", "to", "each", "service", "accessed", "by", "a", "specified", "user", ".", "This", "is", "called", "at", "logout", "when", "single", "logout", "is", "enabled", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/models.py#L207-L218
jbittel/django-mama-cas
mama_cas/models.py
ServiceTicket.request_sign_out
def request_sign_out(self, session=requests): """ Send a POST request to the ``ServiceTicket``s logout URL to request sign-out. """ if logout_allowed(self.service): request = SingleSignOutRequest(context={'ticket': self}) url = get_logout_url(self.service)...
python
def request_sign_out(self, session=requests): """ Send a POST request to the ``ServiceTicket``s logout URL to request sign-out. """ if logout_allowed(self.service): request = SingleSignOutRequest(context={'ticket': self}) url = get_logout_url(self.service)...
[ "def", "request_sign_out", "(", "self", ",", "session", "=", "requests", ")", ":", "if", "logout_allowed", "(", "self", ".", "service", ")", ":", "request", "=", "SingleSignOutRequest", "(", "context", "=", "{", "'ticket'", ":", "self", "}", ")", "url", ...
Send a POST request to the ``ServiceTicket``s logout URL to request sign-out.
[ "Send", "a", "POST", "request", "to", "the", "ServiceTicket", "s", "logout", "URL", "to", "request", "sign", "-", "out", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/models.py#L248-L257
jbittel/django-mama-cas
mama_cas/models.py
ProxyGrantingTicketManager.create_ticket
def create_ticket(self, service, pgturl, **kwargs): """ When a ``pgtUrl`` parameter is provided to ``/serviceValidate`` or ``/proxyValidate``, attempt to create a new ``ProxyGrantingTicket``. If validation succeeds, create and return the ``ProxyGrantingTicket``. If validation fai...
python
def create_ticket(self, service, pgturl, **kwargs): """ When a ``pgtUrl`` parameter is provided to ``/serviceValidate`` or ``/proxyValidate``, attempt to create a new ``ProxyGrantingTicket``. If validation succeeds, create and return the ``ProxyGrantingTicket``. If validation fai...
[ "def", "create_ticket", "(", "self", ",", "service", ",", "pgturl", ",", "*", "*", "kwargs", ")", ":", "pgtid", "=", "self", ".", "create_ticket_str", "(", ")", "pgtiou", "=", "self", ".", "create_ticket_str", "(", "prefix", "=", "self", ".", "model", ...
When a ``pgtUrl`` parameter is provided to ``/serviceValidate`` or ``/proxyValidate``, attempt to create a new ``ProxyGrantingTicket``. If validation succeeds, create and return the ``ProxyGrantingTicket``. If validation fails, return ``None``.
[ "When", "a", "pgtUrl", "parameter", "is", "provided", "to", "/", "serviceValidate", "or", "/", "proxyValidate", "attempt", "to", "create", "a", "new", "ProxyGrantingTicket", ".", "If", "validation", "succeeds", "create", "and", "return", "the", "ProxyGrantingTicke...
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/models.py#L280-L297
jbittel/django-mama-cas
mama_cas/models.py
ProxyGrantingTicketManager.validate_callback
def validate_callback(self, service, pgturl, pgtid, pgtiou): """Verify the provided proxy callback URL.""" if not proxy_allowed(service): raise UnauthorizedServiceProxy("%s is not authorized to use proxy authentication" % service) if not is_scheme_https(pgturl): raise In...
python
def validate_callback(self, service, pgturl, pgtid, pgtiou): """Verify the provided proxy callback URL.""" if not proxy_allowed(service): raise UnauthorizedServiceProxy("%s is not authorized to use proxy authentication" % service) if not is_scheme_https(pgturl): raise In...
[ "def", "validate_callback", "(", "self", ",", "service", ",", "pgturl", ",", "pgtid", ",", "pgtiou", ")", ":", "if", "not", "proxy_allowed", "(", "service", ")", ":", "raise", "UnauthorizedServiceProxy", "(", "\"%s is not authorized to use proxy authentication\"", "...
Verify the provided proxy callback URL.
[ "Verify", "the", "provided", "proxy", "callback", "URL", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/models.py#L299-L329
jbittel/django-mama-cas
mama_cas/services/__init__.py
_get_backends
def _get_backends(): """Retrieve the list of configured service backends.""" backends = [] backend_paths = getattr( settings, 'MAMA_CAS_SERVICE_BACKENDS', ['mama_cas.services.backends.SettingsBackend'] ) for backend_path in backend_paths: backend = import_string(backend_path)...
python
def _get_backends(): """Retrieve the list of configured service backends.""" backends = [] backend_paths = getattr( settings, 'MAMA_CAS_SERVICE_BACKENDS', ['mama_cas.services.backends.SettingsBackend'] ) for backend_path in backend_paths: backend = import_string(backend_path)...
[ "def", "_get_backends", "(", ")", ":", "backends", "=", "[", "]", "backend_paths", "=", "getattr", "(", "settings", ",", "'MAMA_CAS_SERVICE_BACKENDS'", ",", "[", "'mama_cas.services.backends.SettingsBackend'", "]", ")", "for", "backend_path", "in", "backend_paths", ...
Retrieve the list of configured service backends.
[ "Retrieve", "the", "list", "of", "configured", "service", "backends", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/services/__init__.py#L8-L18
jbittel/django-mama-cas
mama_cas/services/__init__.py
_is_allowed
def _is_allowed(attr, *args): """ Test if a given attribute is allowed according to the current set of configured service backends. """ for backend in _get_backends(): try: if getattr(backend, attr)(*args): return True except AttributeError: ra...
python
def _is_allowed(attr, *args): """ Test if a given attribute is allowed according to the current set of configured service backends. """ for backend in _get_backends(): try: if getattr(backend, attr)(*args): return True except AttributeError: ra...
[ "def", "_is_allowed", "(", "attr", ",", "*", "args", ")", ":", "for", "backend", "in", "_get_backends", "(", ")", ":", "try", ":", "if", "getattr", "(", "backend", ",", "attr", ")", "(", "*", "args", ")", ":", "return", "True", "except", "AttributeEr...
Test if a given attribute is allowed according to the current set of configured service backends.
[ "Test", "if", "a", "given", "attribute", "is", "allowed", "according", "to", "the", "current", "set", "of", "configured", "service", "backends", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/services/__init__.py#L21-L34
jbittel/django-mama-cas
mama_cas/services/__init__.py
_is_valid_service_url
def _is_valid_service_url(url): """Access services list from ``MAMA_CAS_VALID_SERVICES``.""" valid_services = getattr(settings, 'MAMA_CAS_VALID_SERVICES', ()) if not valid_services: return True warnings.warn( 'The MAMA_CAS_VALID_SERVICES setting is deprecated. Services ' 'should ...
python
def _is_valid_service_url(url): """Access services list from ``MAMA_CAS_VALID_SERVICES``.""" valid_services = getattr(settings, 'MAMA_CAS_VALID_SERVICES', ()) if not valid_services: return True warnings.warn( 'The MAMA_CAS_VALID_SERVICES setting is deprecated. Services ' 'should ...
[ "def", "_is_valid_service_url", "(", "url", ")", ":", "valid_services", "=", "getattr", "(", "settings", ",", "'MAMA_CAS_VALID_SERVICES'", ",", "(", ")", ")", "if", "not", "valid_services", ":", "return", "True", "warnings", ".", "warn", "(", "'The MAMA_CAS_VALI...
Access services list from ``MAMA_CAS_VALID_SERVICES``.
[ "Access", "services", "list", "from", "MAMA_CAS_VALID_SERVICES", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/services/__init__.py#L37-L48
jbittel/django-mama-cas
mama_cas/services/__init__.py
get_backend_path
def get_backend_path(service): """Return the dotted path of the matching backend.""" for backend in _get_backends(): try: if backend.service_allowed(service): return "%s.%s" % (backend.__class__.__module__, backend.__class__.__name__) except AttributeError: ...
python
def get_backend_path(service): """Return the dotted path of the matching backend.""" for backend in _get_backends(): try: if backend.service_allowed(service): return "%s.%s" % (backend.__class__.__module__, backend.__class__.__name__) except AttributeError: ...
[ "def", "get_backend_path", "(", "service", ")", ":", "for", "backend", "in", "_get_backends", "(", ")", ":", "try", ":", "if", "backend", ".", "service_allowed", "(", "service", ")", ":", "return", "\"%s.%s\"", "%", "(", "backend", ".", "__class__", ".", ...
Return the dotted path of the matching backend.
[ "Return", "the", "dotted", "path", "of", "the", "matching", "backend", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/services/__init__.py#L51-L61
jbittel/django-mama-cas
mama_cas/services/__init__.py
get_callbacks
def get_callbacks(service): """Get configured callbacks list for a given service identifier.""" callbacks = list(getattr(settings, 'MAMA_CAS_ATTRIBUTE_CALLBACKS', [])) if callbacks: warnings.warn( 'The MAMA_CAS_ATTRIBUTE_CALLBACKS setting is deprecated. Service callbacks ' 's...
python
def get_callbacks(service): """Get configured callbacks list for a given service identifier.""" callbacks = list(getattr(settings, 'MAMA_CAS_ATTRIBUTE_CALLBACKS', [])) if callbacks: warnings.warn( 'The MAMA_CAS_ATTRIBUTE_CALLBACKS setting is deprecated. Service callbacks ' 's...
[ "def", "get_callbacks", "(", "service", ")", ":", "callbacks", "=", "list", "(", "getattr", "(", "settings", ",", "'MAMA_CAS_ATTRIBUTE_CALLBACKS'", ",", "[", "]", ")", ")", "if", "callbacks", ":", "warnings", ".", "warn", "(", "'The MAMA_CAS_ATTRIBUTE_CALLBACKS ...
Get configured callbacks list for a given service identifier.
[ "Get", "configured", "callbacks", "list", "for", "a", "given", "service", "identifier", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/services/__init__.py#L64-L79
jbittel/django-mama-cas
mama_cas/services/__init__.py
get_logout_url
def get_logout_url(service): """Get the configured logout URL for a given service identifier, if any.""" for backend in _get_backends(): try: return backend.get_logout_url(service) except AttributeError: raise NotImplementedError("%s.%s.get_logout_url() not implemented" %...
python
def get_logout_url(service): """Get the configured logout URL for a given service identifier, if any.""" for backend in _get_backends(): try: return backend.get_logout_url(service) except AttributeError: raise NotImplementedError("%s.%s.get_logout_url() not implemented" %...
[ "def", "get_logout_url", "(", "service", ")", ":", "for", "backend", "in", "_get_backends", "(", ")", ":", "try", ":", "return", "backend", ".", "get_logout_url", "(", "service", ")", "except", "AttributeError", ":", "raise", "NotImplementedError", "(", "\"%s....
Get the configured logout URL for a given service identifier, if any.
[ "Get", "the", "configured", "logout", "URL", "for", "a", "given", "service", "identifier", "if", "any", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/services/__init__.py#L82-L91
jbittel/django-mama-cas
mama_cas/services/__init__.py
logout_allowed
def logout_allowed(service): """Check if a given service identifier should be sent a logout request.""" if hasattr(settings, 'MAMA_CAS_SERVICES'): return _is_allowed('logout_allowed', service) if hasattr(settings, 'MAMA_CAS_ENABLE_SINGLE_SIGN_OUT'): warnings.warn( 'The MAMA_CAS_...
python
def logout_allowed(service): """Check if a given service identifier should be sent a logout request.""" if hasattr(settings, 'MAMA_CAS_SERVICES'): return _is_allowed('logout_allowed', service) if hasattr(settings, 'MAMA_CAS_ENABLE_SINGLE_SIGN_OUT'): warnings.warn( 'The MAMA_CAS_...
[ "def", "logout_allowed", "(", "service", ")", ":", "if", "hasattr", "(", "settings", ",", "'MAMA_CAS_SERVICES'", ")", ":", "return", "_is_allowed", "(", "'logout_allowed'", ",", "service", ")", "if", "hasattr", "(", "settings", ",", "'MAMA_CAS_ENABLE_SINGLE_SIGN_O...
Check if a given service identifier should be sent a logout request.
[ "Check", "if", "a", "given", "service", "identifier", "should", "be", "sent", "a", "logout", "request", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/services/__init__.py#L94-L103
jbittel/django-mama-cas
mama_cas/services/__init__.py
proxy_callback_allowed
def proxy_callback_allowed(service, pgturl): """Check if a given proxy callback is allowed for the given service identifier.""" if hasattr(settings, 'MAMA_CAS_SERVICES'): return _is_allowed('proxy_callback_allowed', service, pgturl) return _is_valid_service_url(service)
python
def proxy_callback_allowed(service, pgturl): """Check if a given proxy callback is allowed for the given service identifier.""" if hasattr(settings, 'MAMA_CAS_SERVICES'): return _is_allowed('proxy_callback_allowed', service, pgturl) return _is_valid_service_url(service)
[ "def", "proxy_callback_allowed", "(", "service", ",", "pgturl", ")", ":", "if", "hasattr", "(", "settings", ",", "'MAMA_CAS_SERVICES'", ")", ":", "return", "_is_allowed", "(", "'proxy_callback_allowed'", ",", "service", ",", "pgturl", ")", "return", "_is_valid_ser...
Check if a given proxy callback is allowed for the given service identifier.
[ "Check", "if", "a", "given", "proxy", "callback", "is", "allowed", "for", "the", "given", "service", "identifier", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/services/__init__.py#L111-L115
jbittel/django-mama-cas
mama_cas/forms.py
LoginForm.clean
def clean(self): """ Pass the provided username and password to the active authentication backends and verify the user account is not disabled. If authentication succeeds, the ``User`` object is assigned to the form so it can be accessed in the view. """ username ...
python
def clean(self): """ Pass the provided username and password to the active authentication backends and verify the user account is not disabled. If authentication succeeds, the ``User`` object is assigned to the form so it can be accessed in the view. """ username ...
[ "def", "clean", "(", "self", ")", ":", "username", "=", "self", ".", "cleaned_data", ".", "get", "(", "'username'", ")", "password", "=", "self", ".", "cleaned_data", ".", "get", "(", "'password'", ")", "if", "username", "and", "password", ":", "try", ...
Pass the provided username and password to the active authentication backends and verify the user account is not disabled. If authentication succeeds, the ``User`` object is assigned to the form so it can be accessed in the view.
[ "Pass", "the", "provided", "username", "and", "password", "to", "the", "active", "authentication", "backends", "and", "verify", "the", "user", "account", "is", "not", "disabled", ".", "If", "authentication", "succeeds", "the", "User", "object", "is", "assigned",...
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/forms.py#L34-L62
jbittel/django-mama-cas
mama_cas/forms.py
LoginFormEmail.clean_username
def clean_username(self): """ Remove an '@<domain>' suffix if present and return only the username. """ username = self.cleaned_data.get('username').split('@')[0] if not username: raise forms.ValidationError(_('Invalid username provided')) return usern...
python
def clean_username(self): """ Remove an '@<domain>' suffix if present and return only the username. """ username = self.cleaned_data.get('username').split('@')[0] if not username: raise forms.ValidationError(_('Invalid username provided')) return usern...
[ "def", "clean_username", "(", "self", ")", ":", "username", "=", "self", ".", "cleaned_data", ".", "get", "(", "'username'", ")", ".", "split", "(", "'@'", ")", "[", "0", "]", "if", "not", "username", ":", "raise", "forms", ".", "ValidationError", "(",...
Remove an '@<domain>' suffix if present and return only the username.
[ "Remove", "an" ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/forms.py#L70-L78
jbittel/django-mama-cas
mama_cas/request.py
CasRequestBase.ns
def ns(self, prefix, tag): """ Given a prefix and an XML tag, output the qualified name for proper namespace handling on output. """ return etree.QName(self.prefixes[prefix], tag)
python
def ns(self, prefix, tag): """ Given a prefix and an XML tag, output the qualified name for proper namespace handling on output. """ return etree.QName(self.prefixes[prefix], tag)
[ "def", "ns", "(", "self", ",", "prefix", ",", "tag", ")", ":", "return", "etree", ".", "QName", "(", "self", ".", "prefixes", "[", "prefix", "]", ",", "tag", ")" ]
Given a prefix and an XML tag, output the qualified name for proper namespace handling on output.
[ "Given", "a", "prefix", "and", "an", "XML", "tag", "output", "the", "qualified", "name", "for", "proper", "namespace", "handling", "on", "output", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/request.py#L19-L24
jbittel/django-mama-cas
mama_cas/cas.py
validate_service_ticket
def validate_service_ticket(service, ticket, pgturl=None, renew=False, require_https=False): """ Validate a service ticket string. Return a triplet containing a ``ServiceTicket`` and an optional ``ProxyGrantingTicket``, or a ``ValidationError`` if ticket validation failed. """ logger.debug("Serv...
python
def validate_service_ticket(service, ticket, pgturl=None, renew=False, require_https=False): """ Validate a service ticket string. Return a triplet containing a ``ServiceTicket`` and an optional ``ProxyGrantingTicket``, or a ``ValidationError`` if ticket validation failed. """ logger.debug("Serv...
[ "def", "validate_service_ticket", "(", "service", ",", "ticket", ",", "pgturl", "=", "None", ",", "renew", "=", "False", ",", "require_https", "=", "False", ")", ":", "logger", ".", "debug", "(", "\"Service validation request received for %s\"", "%", "ticket", "...
Validate a service ticket string. Return a triplet containing a ``ServiceTicket`` and an optional ``ProxyGrantingTicket``, or a ``ValidationError`` if ticket validation failed.
[ "Validate", "a", "service", "ticket", "string", ".", "Return", "a", "triplet", "containing", "a", "ServiceTicket", "and", "an", "optional", "ProxyGrantingTicket", "or", "a", "ValidationError", "if", "ticket", "validation", "failed", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/cas.py#L18-L38
jbittel/django-mama-cas
mama_cas/cas.py
validate_proxy_ticket
def validate_proxy_ticket(service, ticket, pgturl=None): """ Validate a proxy ticket string. Return a 4-tuple containing a ``ProxyTicket``, an optional ``ProxyGrantingTicket`` and a list of proxies through which authentication proceeded, or a ``ValidationError`` if ticket validation failed. """ ...
python
def validate_proxy_ticket(service, ticket, pgturl=None): """ Validate a proxy ticket string. Return a 4-tuple containing a ``ProxyTicket``, an optional ``ProxyGrantingTicket`` and a list of proxies through which authentication proceeded, or a ``ValidationError`` if ticket validation failed. """ ...
[ "def", "validate_proxy_ticket", "(", "service", ",", "ticket", ",", "pgturl", "=", "None", ")", ":", "logger", ".", "debug", "(", "\"Proxy validation request received for %s\"", "%", "ticket", ")", "pt", "=", "ProxyTicket", ".", "objects", ".", "validate_ticket", ...
Validate a proxy ticket string. Return a 4-tuple containing a ``ProxyTicket``, an optional ``ProxyGrantingTicket`` and a list of proxies through which authentication proceeded, or a ``ValidationError`` if ticket validation failed.
[ "Validate", "a", "proxy", "ticket", "string", ".", "Return", "a", "4", "-", "tuple", "containing", "a", "ProxyTicket", "an", "optional", "ProxyGrantingTicket", "and", "a", "list", "of", "proxies", "through", "which", "authentication", "proceeded", "or", "a", "...
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/cas.py#L41-L66
jbittel/django-mama-cas
mama_cas/cas.py
validate_proxy_granting_ticket
def validate_proxy_granting_ticket(pgt, target_service): """ Validate a proxy granting ticket string. Return an ordered pair containing a ``ProxyTicket``, or a ``ValidationError`` if ticket validation failed. """ logger.debug("Proxy ticket request received for %s using %s" % (target_service, pgt...
python
def validate_proxy_granting_ticket(pgt, target_service): """ Validate a proxy granting ticket string. Return an ordered pair containing a ``ProxyTicket``, or a ``ValidationError`` if ticket validation failed. """ logger.debug("Proxy ticket request received for %s using %s" % (target_service, pgt...
[ "def", "validate_proxy_granting_ticket", "(", "pgt", ",", "target_service", ")", ":", "logger", ".", "debug", "(", "\"Proxy ticket request received for %s using %s\"", "%", "(", "target_service", ",", "pgt", ")", ")", "pgt", "=", "ProxyGrantingTicket", ".", "objects",...
Validate a proxy granting ticket string. Return an ordered pair containing a ``ProxyTicket``, or a ``ValidationError`` if ticket validation failed.
[ "Validate", "a", "proxy", "granting", "ticket", "string", ".", "Return", "an", "ordered", "pair", "containing", "a", "ProxyTicket", "or", "a", "ValidationError", "if", "ticket", "validation", "failed", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/cas.py#L69-L79
jbittel/django-mama-cas
mama_cas/cas.py
get_attributes
def get_attributes(user, service): """ Return a dictionary of user attributes from the set of configured callback functions. """ attributes = {} for path in get_callbacks(service): callback = import_string(path) attributes.update(callback(user, service)) return attributes
python
def get_attributes(user, service): """ Return a dictionary of user attributes from the set of configured callback functions. """ attributes = {} for path in get_callbacks(service): callback = import_string(path) attributes.update(callback(user, service)) return attributes
[ "def", "get_attributes", "(", "user", ",", "service", ")", ":", "attributes", "=", "{", "}", "for", "path", "in", "get_callbacks", "(", "service", ")", ":", "callback", "=", "import_string", "(", "path", ")", "attributes", ".", "update", "(", "callback", ...
Return a dictionary of user attributes from the set of configured callback functions.
[ "Return", "a", "dictionary", "of", "user", "attributes", "from", "the", "set", "of", "configured", "callback", "functions", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/cas.py#L82-L91
jbittel/django-mama-cas
mama_cas/cas.py
logout_user
def logout_user(request): """End a single sign-on session for the current user.""" logger.debug("Logout request received for %s" % request.user) if is_authenticated(request.user): ServiceTicket.objects.consume_tickets(request.user) ProxyTicket.objects.consume_tickets(request.user) Pr...
python
def logout_user(request): """End a single sign-on session for the current user.""" logger.debug("Logout request received for %s" % request.user) if is_authenticated(request.user): ServiceTicket.objects.consume_tickets(request.user) ProxyTicket.objects.consume_tickets(request.user) Pr...
[ "def", "logout_user", "(", "request", ")", ":", "logger", ".", "debug", "(", "\"Logout request received for %s\"", "%", "request", ".", "user", ")", "if", "is_authenticated", "(", "request", ".", "user", ")", ":", "ServiceTicket", ".", "objects", ".", "consume...
End a single sign-on session for the current user.
[ "End", "a", "single", "sign", "-", "on", "session", "for", "the", "current", "user", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/cas.py#L94-L106
jbittel/django-mama-cas
mama_cas/callbacks.py
user_name_attributes
def user_name_attributes(user, service): """Return all available user name related fields and methods.""" attributes = {} attributes['username'] = user.get_username() attributes['full_name'] = user.get_full_name() attributes['short_name'] = user.get_short_name() return attributes
python
def user_name_attributes(user, service): """Return all available user name related fields and methods.""" attributes = {} attributes['username'] = user.get_username() attributes['full_name'] = user.get_full_name() attributes['short_name'] = user.get_short_name() return attributes
[ "def", "user_name_attributes", "(", "user", ",", "service", ")", ":", "attributes", "=", "{", "}", "attributes", "[", "'username'", "]", "=", "user", ".", "get_username", "(", ")", "attributes", "[", "'full_name'", "]", "=", "user", ".", "get_full_name", "...
Return all available user name related fields and methods.
[ "Return", "all", "available", "user", "name", "related", "fields", "and", "methods", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/callbacks.py#L1-L7
jbittel/django-mama-cas
mama_cas/callbacks.py
user_model_attributes
def user_model_attributes(user, service): """ Return all fields on the user object that are not in the list of fields to ignore. """ ignore_fields = ['id', 'password'] attributes = {} for field in user._meta.fields: if field.name not in ignore_fields: attributes[field.nam...
python
def user_model_attributes(user, service): """ Return all fields on the user object that are not in the list of fields to ignore. """ ignore_fields = ['id', 'password'] attributes = {} for field in user._meta.fields: if field.name not in ignore_fields: attributes[field.nam...
[ "def", "user_model_attributes", "(", "user", ",", "service", ")", ":", "ignore_fields", "=", "[", "'id'", ",", "'password'", "]", "attributes", "=", "{", "}", "for", "field", "in", "user", ".", "_meta", ".", "fields", ":", "if", "field", ".", "name", "...
Return all fields on the user object that are not in the list of fields to ignore.
[ "Return", "all", "fields", "on", "the", "user", "object", "that", "are", "not", "in", "the", "list", "of", "fields", "to", "ignore", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/callbacks.py#L10-L20
jbittel/django-mama-cas
mama_cas/utils.py
add_query_params
def add_query_params(url, params): """ Inject additional query parameters into an existing URL. If parameters already exist with the same name, they will be overwritten. Parameters with empty values are ignored. Return the modified URL as a string. """ def encode(s): return force_byt...
python
def add_query_params(url, params): """ Inject additional query parameters into an existing URL. If parameters already exist with the same name, they will be overwritten. Parameters with empty values are ignored. Return the modified URL as a string. """ def encode(s): return force_byt...
[ "def", "add_query_params", "(", "url", ",", "params", ")", ":", "def", "encode", "(", "s", ")", ":", "return", "force_bytes", "(", "s", ",", "settings", ".", "DEFAULT_CHARSET", ")", "params", "=", "dict", "(", "[", "(", "encode", "(", "k", ")", ",", ...
Inject additional query parameters into an existing URL. If parameters already exist with the same name, they will be overwritten. Parameters with empty values are ignored. Return the modified URL as a string.
[ "Inject", "additional", "query", "parameters", "into", "an", "existing", "URL", ".", "If", "parameters", "already", "exist", "with", "the", "same", "name", "they", "will", "be", "overwritten", ".", "Parameters", "with", "empty", "values", "are", "ignored", "."...
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/utils.py#L23-L38
jbittel/django-mama-cas
mama_cas/utils.py
clean_service_url
def clean_service_url(url): """ Return only the scheme, hostname (with optional port) and path components of the parameter URL. """ parts = urlparse(url) return urlunparse((parts.scheme, parts.netloc, parts.path, '', '', ''))
python
def clean_service_url(url): """ Return only the scheme, hostname (with optional port) and path components of the parameter URL. """ parts = urlparse(url) return urlunparse((parts.scheme, parts.netloc, parts.path, '', '', ''))
[ "def", "clean_service_url", "(", "url", ")", ":", "parts", "=", "urlparse", "(", "url", ")", "return", "urlunparse", "(", "(", "parts", ".", "scheme", ",", "parts", ".", "netloc", ",", "parts", ".", "path", ",", "''", ",", "''", ",", "''", ")", ")"...
Return only the scheme, hostname (with optional port) and path components of the parameter URL.
[ "Return", "only", "the", "scheme", "hostname", "(", "with", "optional", "port", ")", "and", "path", "components", "of", "the", "parameter", "URL", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/utils.py#L49-L55
jbittel/django-mama-cas
mama_cas/utils.py
match_service
def match_service(service1, service2): """ Compare two service URLs. Return ``True`` if the scheme, hostname, optional port and path match. """ s1, s2 = urlparse(service1), urlparse(service2) try: return (s1.scheme, s1.netloc, s1.path) == (s2.scheme, s2.netloc, s2.path) except ValueE...
python
def match_service(service1, service2): """ Compare two service URLs. Return ``True`` if the scheme, hostname, optional port and path match. """ s1, s2 = urlparse(service1), urlparse(service2) try: return (s1.scheme, s1.netloc, s1.path) == (s2.scheme, s2.netloc, s2.path) except ValueE...
[ "def", "match_service", "(", "service1", ",", "service2", ")", ":", "s1", ",", "s2", "=", "urlparse", "(", "service1", ")", ",", "urlparse", "(", "service2", ")", "try", ":", "return", "(", "s1", ".", "scheme", ",", "s1", ".", "netloc", ",", "s1", ...
Compare two service URLs. Return ``True`` if the scheme, hostname, optional port and path match.
[ "Compare", "two", "service", "URLs", ".", "Return", "True", "if", "the", "scheme", "hostname", "optional", "port", "and", "path", "match", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/utils.py#L58-L67
jbittel/django-mama-cas
mama_cas/utils.py
redirect
def redirect(to, *args, **kwargs): """ Similar to the Django ``redirect`` shortcut but with altered functionality. If an optional ``params`` argument is provided, the dictionary items will be injected as query parameters on the redirection URL. """ params = kwargs.pop('params', {}) try:...
python
def redirect(to, *args, **kwargs): """ Similar to the Django ``redirect`` shortcut but with altered functionality. If an optional ``params`` argument is provided, the dictionary items will be injected as query parameters on the redirection URL. """ params = kwargs.pop('params', {}) try:...
[ "def", "redirect", "(", "to", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "params", "=", "kwargs", ".", "pop", "(", "'params'", ",", "{", "}", ")", "try", ":", "to", "=", "reverse", "(", "to", ",", "args", "=", "args", ",", "kwargs", ...
Similar to the Django ``redirect`` shortcut but with altered functionality. If an optional ``params`` argument is provided, the dictionary items will be injected as query parameters on the redirection URL.
[ "Similar", "to", "the", "Django", "redirect", "shortcut", "but", "with", "altered", "functionality", ".", "If", "an", "optional", "params", "argument", "is", "provided", "the", "dictionary", "items", "will", "be", "injected", "as", "query", "parameters", "on", ...
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/utils.py#L70-L91
jbittel/django-mama-cas
mama_cas/services/backends.py
ServiceConfig.get_config
def get_config(self, service, setting): """ Access the configuration for a given service and setting. If the service is not found, return a default value. """ try: return self.get_service(service)[setting] except KeyError: return getattr(self, sett...
python
def get_config(self, service, setting): """ Access the configuration for a given service and setting. If the service is not found, return a default value. """ try: return self.get_service(service)[setting] except KeyError: return getattr(self, sett...
[ "def", "get_config", "(", "self", ",", "service", ",", "setting", ")", ":", "try", ":", "return", "self", ".", "get_service", "(", "service", ")", "[", "setting", "]", "except", "KeyError", ":", "return", "getattr", "(", "self", ",", "setting", "+", "'...
Access the configuration for a given service and setting. If the service is not found, return a default value.
[ "Access", "the", "configuration", "for", "a", "given", "service", "and", "setting", ".", "If", "the", "service", "is", "not", "found", "return", "a", "default", "value", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/services/backends.py#L47-L55
jbittel/django-mama-cas
mama_cas/response.py
SamlValidationResponse.get_status
def get_status(self, status_value, message=None): """ Build a Status XML block for a SAML 1.1 Response. """ status = etree.Element('Status') status_code = etree.SubElement(status, 'StatusCode') status_code.set('Value', 'samlp:' + status_value) if message: ...
python
def get_status(self, status_value, message=None): """ Build a Status XML block for a SAML 1.1 Response. """ status = etree.Element('Status') status_code = etree.SubElement(status, 'StatusCode') status_code.set('Value', 'samlp:' + status_value) if message: ...
[ "def", "get_status", "(", "self", ",", "status_value", ",", "message", "=", "None", ")", ":", "status", "=", "etree", ".", "Element", "(", "'Status'", ")", "status_code", "=", "etree", ".", "SubElement", "(", "status", ",", "'StatusCode'", ")", "status_cod...
Build a Status XML block for a SAML 1.1 Response.
[ "Build", "a", "Status", "XML", "block", "for", "a", "SAML", "1", ".", "1", "Response", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/response.py#L185-L195
jbittel/django-mama-cas
mama_cas/response.py
SamlValidationResponse.get_assertion
def get_assertion(self, ticket, attributes): """ Build a SAML 1.1 Assertion XML block. """ assertion = etree.Element('Assertion') assertion.set('xmlns', 'urn:oasis:names:tc:SAML:1.0:assertion') assertion.set('AssertionID', self.generate_id()) assertion.set('IssueI...
python
def get_assertion(self, ticket, attributes): """ Build a SAML 1.1 Assertion XML block. """ assertion = etree.Element('Assertion') assertion.set('xmlns', 'urn:oasis:names:tc:SAML:1.0:assertion') assertion.set('AssertionID', self.generate_id()) assertion.set('IssueI...
[ "def", "get_assertion", "(", "self", ",", "ticket", ",", "attributes", ")", ":", "assertion", "=", "etree", ".", "Element", "(", "'Assertion'", ")", "assertion", ".", "set", "(", "'xmlns'", ",", "'urn:oasis:names:tc:SAML:1.0:assertion'", ")", "assertion", ".", ...
Build a SAML 1.1 Assertion XML block.
[ "Build", "a", "SAML", "1", ".", "1", "Assertion", "XML", "block", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/response.py#L197-L214
jbittel/django-mama-cas
mama_cas/response.py
SamlValidationResponse.get_conditions
def get_conditions(self, service_id): """ Build a Conditions XML block for a SAML 1.1 Assertion. """ conditions = etree.Element('Conditions') conditions.set('NotBefore', self.instant()) conditions.set('NotOnOrAfter', self.instant(offset=30)) restriction = etree.Su...
python
def get_conditions(self, service_id): """ Build a Conditions XML block for a SAML 1.1 Assertion. """ conditions = etree.Element('Conditions') conditions.set('NotBefore', self.instant()) conditions.set('NotOnOrAfter', self.instant(offset=30)) restriction = etree.Su...
[ "def", "get_conditions", "(", "self", ",", "service_id", ")", ":", "conditions", "=", "etree", ".", "Element", "(", "'Conditions'", ")", "conditions", ".", "set", "(", "'NotBefore'", ",", "self", ".", "instant", "(", ")", ")", "conditions", ".", "set", "...
Build a Conditions XML block for a SAML 1.1 Assertion.
[ "Build", "a", "Conditions", "XML", "block", "for", "a", "SAML", "1", ".", "1", "Assertion", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/response.py#L216-L226
jbittel/django-mama-cas
mama_cas/response.py
SamlValidationResponse.get_attribute_statement
def get_attribute_statement(self, subject, attributes): """ Build an AttributeStatement XML block for a SAML 1.1 Assertion. """ attribute_statement = etree.Element('AttributeStatement') attribute_statement.append(subject) for name, value in attributes.items(): ...
python
def get_attribute_statement(self, subject, attributes): """ Build an AttributeStatement XML block for a SAML 1.1 Assertion. """ attribute_statement = etree.Element('AttributeStatement') attribute_statement.append(subject) for name, value in attributes.items(): ...
[ "def", "get_attribute_statement", "(", "self", ",", "subject", ",", "attributes", ")", ":", "attribute_statement", "=", "etree", ".", "Element", "(", "'AttributeStatement'", ")", "attribute_statement", ".", "append", "(", "subject", ")", "for", "name", ",", "val...
Build an AttributeStatement XML block for a SAML 1.1 Assertion.
[ "Build", "an", "AttributeStatement", "XML", "block", "for", "a", "SAML", "1", ".", "1", "Assertion", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/response.py#L228-L245
jbittel/django-mama-cas
mama_cas/response.py
SamlValidationResponse.get_authentication_statement
def get_authentication_statement(self, subject, ticket): """ Build an AuthenticationStatement XML block for a SAML 1.1 Assertion. """ authentication_statement = etree.Element('AuthenticationStatement') authentication_statement.set('AuthenticationInstant', ...
python
def get_authentication_statement(self, subject, ticket): """ Build an AuthenticationStatement XML block for a SAML 1.1 Assertion. """ authentication_statement = etree.Element('AuthenticationStatement') authentication_statement.set('AuthenticationInstant', ...
[ "def", "get_authentication_statement", "(", "self", ",", "subject", ",", "ticket", ")", ":", "authentication_statement", "=", "etree", ".", "Element", "(", "'AuthenticationStatement'", ")", "authentication_statement", ".", "set", "(", "'AuthenticationInstant'", ",", "...
Build an AuthenticationStatement XML block for a SAML 1.1 Assertion.
[ "Build", "an", "AuthenticationStatement", "XML", "block", "for", "a", "SAML", "1", ".", "1", "Assertion", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/response.py#L247-L258
jbittel/django-mama-cas
mama_cas/response.py
SamlValidationResponse.get_subject
def get_subject(self, identifier): """ Build a Subject XML block for a SAML 1.1 AuthenticationStatement or AttributeStatement. """ subject = etree.Element('Subject') name = etree.SubElement(subject, 'NameIdentifier') name.text = identifier subject_confirma...
python
def get_subject(self, identifier): """ Build a Subject XML block for a SAML 1.1 AuthenticationStatement or AttributeStatement. """ subject = etree.Element('Subject') name = etree.SubElement(subject, 'NameIdentifier') name.text = identifier subject_confirma...
[ "def", "get_subject", "(", "self", ",", "identifier", ")", ":", "subject", "=", "etree", ".", "Element", "(", "'Subject'", ")", "name", "=", "etree", ".", "SubElement", "(", "subject", ",", "'NameIdentifier'", ")", "name", ".", "text", "=", "identifier", ...
Build a Subject XML block for a SAML 1.1 AuthenticationStatement or AttributeStatement.
[ "Build", "a", "Subject", "XML", "block", "for", "a", "SAML", "1", ".", "1", "AuthenticationStatement", "or", "AttributeStatement", "." ]
train
https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/response.py#L260-L271
sarugaku/vistir
src/vistir/compat.py
is_bytes
def is_bytes(string): """Check if a string is a bytes instance :param Union[str, bytes] string: A string that may be string or bytes like :return: Whether the provided string is a bytes type or not :rtype: bool """ if six.PY3 and isinstance(string, (bytes, memoryview, bytearray)): # noqa ...
python
def is_bytes(string): """Check if a string is a bytes instance :param Union[str, bytes] string: A string that may be string or bytes like :return: Whether the provided string is a bytes type or not :rtype: bool """ if six.PY3 and isinstance(string, (bytes, memoryview, bytearray)): # noqa ...
[ "def", "is_bytes", "(", "string", ")", ":", "if", "six", ".", "PY3", "and", "isinstance", "(", "string", ",", "(", "bytes", ",", "memoryview", ",", "bytearray", ")", ")", ":", "# noqa", "return", "True", "elif", "six", ".", "PY2", "and", "isinstance", ...
Check if a string is a bytes instance :param Union[str, bytes] string: A string that may be string or bytes like :return: Whether the provided string is a bytes type or not :rtype: bool
[ "Check", "if", "a", "string", "is", "a", "bytes", "instance" ]
train
https://github.com/sarugaku/vistir/blob/96c008ee62a43608d1e70797f74634cb66a004c1/src/vistir/compat.py#L205-L216
sarugaku/vistir
src/vistir/compat.py
fs_encode
def fs_encode(path): """ Encode a filesystem path to the proper filesystem encoding :param Union[str, bytes] path: A string-like path :returns: A bytes-encoded filesystem path representation """ path = _get_path(path) if path is None: raise TypeError("expected a valid path to encod...
python
def fs_encode(path): """ Encode a filesystem path to the proper filesystem encoding :param Union[str, bytes] path: A string-like path :returns: A bytes-encoded filesystem path representation """ path = _get_path(path) if path is None: raise TypeError("expected a valid path to encod...
[ "def", "fs_encode", "(", "path", ")", ":", "path", "=", "_get_path", "(", "path", ")", "if", "path", "is", "None", ":", "raise", "TypeError", "(", "\"expected a valid path to encode\"", ")", "if", "isinstance", "(", "path", ",", "six", ".", "text_type", ")...
Encode a filesystem path to the proper filesystem encoding :param Union[str, bytes] path: A string-like path :returns: A bytes-encoded filesystem path representation
[ "Encode", "a", "filesystem", "path", "to", "the", "proper", "filesystem", "encoding" ]
train
https://github.com/sarugaku/vistir/blob/96c008ee62a43608d1e70797f74634cb66a004c1/src/vistir/compat.py#L316-L338
sarugaku/vistir
src/vistir/compat.py
fs_decode
def fs_decode(path): """ Decode a filesystem path using the proper filesystem encoding :param path: The filesystem path to decode from bytes or string :return: The filesystem path, decoded with the determined encoding :rtype: Text """ path = _get_path(path) if path is None: rai...
python
def fs_decode(path): """ Decode a filesystem path using the proper filesystem encoding :param path: The filesystem path to decode from bytes or string :return: The filesystem path, decoded with the determined encoding :rtype: Text """ path = _get_path(path) if path is None: rai...
[ "def", "fs_decode", "(", "path", ")", ":", "path", "=", "_get_path", "(", "path", ")", "if", "path", "is", "None", ":", "raise", "TypeError", "(", "\"expected a valid path to decode\"", ")", "if", "isinstance", "(", "path", ",", "six", ".", "binary_type", ...
Decode a filesystem path using the proper filesystem encoding :param path: The filesystem path to decode from bytes or string :return: The filesystem path, decoded with the determined encoding :rtype: Text
[ "Decode", "a", "filesystem", "path", "using", "the", "proper", "filesystem", "encoding" ]
train
https://github.com/sarugaku/vistir/blob/96c008ee62a43608d1e70797f74634cb66a004c1/src/vistir/compat.py#L341-L363
sarugaku/vistir
src/vistir/termcolors.py
colored
def colored(text, color=None, on_color=None, attrs=None): """Colorize text using a reimplementation of the colorizer from https://github.com/pavdmyt/yaspin so that it works on windows. Available text colors: red, green, yellow, blue, magenta, cyan, white. Available text highlights: on_...
python
def colored(text, color=None, on_color=None, attrs=None): """Colorize text using a reimplementation of the colorizer from https://github.com/pavdmyt/yaspin so that it works on windows. Available text colors: red, green, yellow, blue, magenta, cyan, white. Available text highlights: on_...
[ "def", "colored", "(", "text", ",", "color", "=", "None", ",", "on_color", "=", "None", ",", "attrs", "=", "None", ")", ":", "return", "colorize", "(", "text", ",", "fg", "=", "color", ",", "bg", "=", "on_color", ",", "attrs", "=", "attrs", ")" ]
Colorize text using a reimplementation of the colorizer from https://github.com/pavdmyt/yaspin so that it works on windows. Available text colors: red, green, yellow, blue, magenta, cyan, white. Available text highlights: on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white....
[ "Colorize", "text", "using", "a", "reimplementation", "of", "the", "colorizer", "from", "https", ":", "//", "github", ".", "com", "/", "pavdmyt", "/", "yaspin", "so", "that", "it", "works", "on", "windows", "." ]
train
https://github.com/sarugaku/vistir/blob/96c008ee62a43608d1e70797f74634cb66a004c1/src/vistir/termcolors.py#L57-L74
sarugaku/vistir
src/vistir/misc.py
partialclass
def partialclass(cls, *args, **kwargs): """Returns a partially instantiated class :return: A partial class instance :rtype: cls >>> source = partialclass(Source, url="https://pypi.org/simple") >>> source <class '__main__.Source'> >>> source(name="pypi") >>> source.__dict__ mappingp...
python
def partialclass(cls, *args, **kwargs): """Returns a partially instantiated class :return: A partial class instance :rtype: cls >>> source = partialclass(Source, url="https://pypi.org/simple") >>> source <class '__main__.Source'> >>> source(name="pypi") >>> source.__dict__ mappingp...
[ "def", "partialclass", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "name_attrs", "=", "[", "n", "for", "n", "in", "(", "getattr", "(", "cls", ",", "name", ",", "str", "(", "cls", ")", ")", "for", "name", "in", "(", "\"__nam...
Returns a partially instantiated class :return: A partial class instance :rtype: cls >>> source = partialclass(Source, url="https://pypi.org/simple") >>> source <class '__main__.Source'> >>> source(name="pypi") >>> source.__dict__ mappingproxy({'__module__': '__main__', '__dict__': <at...
[ "Returns", "a", "partially", "instantiated", "class" ]
train
https://github.com/sarugaku/vistir/blob/96c008ee62a43608d1e70797f74634cb66a004c1/src/vistir/misc.py#L371-L404
sarugaku/vistir
src/vistir/misc.py
to_bytes
def to_bytes(string, encoding="utf-8", errors=None): """Force a value to bytes. :param string: Some input that can be converted to a bytes. :type string: str or bytes unicode or a memoryview subclass :param encoding: The encoding to use for conversions, defaults to "utf-8" :param encoding: str, opt...
python
def to_bytes(string, encoding="utf-8", errors=None): """Force a value to bytes. :param string: Some input that can be converted to a bytes. :type string: str or bytes unicode or a memoryview subclass :param encoding: The encoding to use for conversions, defaults to "utf-8" :param encoding: str, opt...
[ "def", "to_bytes", "(", "string", ",", "encoding", "=", "\"utf-8\"", ",", "errors", "=", "None", ")", ":", "unicode_name", "=", "get_canonical_encoding_name", "(", "\"utf-8\"", ")", "if", "not", "errors", ":", "if", "get_canonical_encoding_name", "(", "encoding"...
Force a value to bytes. :param string: Some input that can be converted to a bytes. :type string: str or bytes unicode or a memoryview subclass :param encoding: The encoding to use for conversions, defaults to "utf-8" :param encoding: str, optional :return: Corresponding byte representation (for us...
[ "Force", "a", "value", "to", "bytes", "." ]
train
https://github.com/sarugaku/vistir/blob/96c008ee62a43608d1e70797f74634cb66a004c1/src/vistir/misc.py#L409-L447
sarugaku/vistir
src/vistir/misc.py
to_text
def to_text(string, encoding="utf-8", errors=None): """Force a value to a text-type. :param string: Some input that can be converted to a unicode representation. :type string: str or bytes unicode :param encoding: The encoding to use for conversions, defaults to "utf-8" :param encoding: str, option...
python
def to_text(string, encoding="utf-8", errors=None): """Force a value to a text-type. :param string: Some input that can be converted to a unicode representation. :type string: str or bytes unicode :param encoding: The encoding to use for conversions, defaults to "utf-8" :param encoding: str, option...
[ "def", "to_text", "(", "string", ",", "encoding", "=", "\"utf-8\"", ",", "errors", "=", "None", ")", ":", "unicode_name", "=", "get_canonical_encoding_name", "(", "\"utf-8\"", ")", "if", "not", "errors", ":", "if", "get_canonical_encoding_name", "(", "encoding",...
Force a value to a text-type. :param string: Some input that can be converted to a unicode representation. :type string: str or bytes unicode :param encoding: The encoding to use for conversions, defaults to "utf-8" :param encoding: str, optional :return: The unicode representation of the string ...
[ "Force", "a", "value", "to", "a", "text", "-", "type", "." ]
train
https://github.com/sarugaku/vistir/blob/96c008ee62a43608d1e70797f74634cb66a004c1/src/vistir/misc.py#L450-L487
sarugaku/vistir
src/vistir/misc.py
get_wrapped_stream
def get_wrapped_stream(stream, encoding=None, errors="replace"): """ Given a stream, wrap it in a `StreamWrapper` instance and return the wrapped stream. :param stream: A stream instance to wrap :param str encoding: The encoding to use for the stream :param str errors: The error handler to use, def...
python
def get_wrapped_stream(stream, encoding=None, errors="replace"): """ Given a stream, wrap it in a `StreamWrapper` instance and return the wrapped stream. :param stream: A stream instance to wrap :param str encoding: The encoding to use for the stream :param str errors: The error handler to use, def...
[ "def", "get_wrapped_stream", "(", "stream", ",", "encoding", "=", "None", ",", "errors", "=", "\"replace\"", ")", ":", "if", "stream", "is", "None", ":", "raise", "TypeError", "(", "\"must provide a stream to wrap\"", ")", "stream", "=", "_get_binary_buffer", "(...
Given a stream, wrap it in a `StreamWrapper` instance and return the wrapped stream. :param stream: A stream instance to wrap :param str encoding: The encoding to use for the stream :param str errors: The error handler to use, default "replace" :returns: A new, wrapped stream :rtype: :class:`Stream...
[ "Given", "a", "stream", "wrap", "it", "in", "a", "StreamWrapper", "instance", "and", "return", "the", "wrapped", "stream", "." ]
train
https://github.com/sarugaku/vistir/blob/96c008ee62a43608d1e70797f74634cb66a004c1/src/vistir/misc.py#L660-L680
sarugaku/vistir
src/vistir/misc.py
get_text_stream
def get_text_stream(stream="stdout", encoding=None): """Retrieve a unicode stream wrapper around **sys.stdout** or **sys.stderr**. :param str stream: The name of the stream to wrap from the :mod:`sys` module. :param str encoding: An optional encoding to use. :return: A new :class:`~vistir.misc.StreamWr...
python
def get_text_stream(stream="stdout", encoding=None): """Retrieve a unicode stream wrapper around **sys.stdout** or **sys.stderr**. :param str stream: The name of the stream to wrap from the :mod:`sys` module. :param str encoding: An optional encoding to use. :return: A new :class:`~vistir.misc.StreamWr...
[ "def", "get_text_stream", "(", "stream", "=", "\"stdout\"", ",", "encoding", "=", "None", ")", ":", "stream_map", "=", "{", "\"stdin\"", ":", "sys", ".", "stdin", ",", "\"stdout\"", ":", "sys", ".", "stdout", ",", "\"stderr\"", ":", "sys", ".", "stderr",...
Retrieve a unicode stream wrapper around **sys.stdout** or **sys.stderr**. :param str stream: The name of the stream to wrap from the :mod:`sys` module. :param str encoding: An optional encoding to use. :return: A new :class:`~vistir.misc.StreamWrapper` instance around the stream :rtype: `vistir.misc.S...
[ "Retrieve", "a", "unicode", "stream", "wrapper", "around", "**", "sys", ".", "stdout", "**", "or", "**", "sys", ".", "stderr", "**", "." ]
train
https://github.com/sarugaku/vistir/blob/96c008ee62a43608d1e70797f74634cb66a004c1/src/vistir/misc.py#L863-L886
sarugaku/vistir
src/vistir/misc.py
replace_with_text_stream
def replace_with_text_stream(stream_name): """Given a stream name, replace the target stream with a text-converted equivalent :param str stream_name: The name of a target stream, such as **stdout** or **stderr** :return: None """ new_stream = TEXT_STREAMS.get(stream_name) if new_stream is not N...
python
def replace_with_text_stream(stream_name): """Given a stream name, replace the target stream with a text-converted equivalent :param str stream_name: The name of a target stream, such as **stdout** or **stderr** :return: None """ new_stream = TEXT_STREAMS.get(stream_name) if new_stream is not N...
[ "def", "replace_with_text_stream", "(", "stream_name", ")", ":", "new_stream", "=", "TEXT_STREAMS", ".", "get", "(", "stream_name", ")", "if", "new_stream", "is", "not", "None", ":", "new_stream", "=", "new_stream", "(", ")", "setattr", "(", "sys", ",", "str...
Given a stream name, replace the target stream with a text-converted equivalent :param str stream_name: The name of a target stream, such as **stdout** or **stderr** :return: None
[ "Given", "a", "stream", "name", "replace", "the", "target", "stream", "with", "a", "text", "-", "converted", "equivalent" ]
train
https://github.com/sarugaku/vistir/blob/96c008ee62a43608d1e70797f74634cb66a004c1/src/vistir/misc.py#L913-L923
sarugaku/vistir
src/vistir/misc.py
echo
def echo(text, fg=None, bg=None, style=None, file=None, err=False, color=None): """Write the given text to the provided stream or **sys.stdout** by default. Provides optional foreground and background colors from the ansi defaults: **grey**, **red**, **green**, **yellow**, **blue**, **magenta**, **cyan** ...
python
def echo(text, fg=None, bg=None, style=None, file=None, err=False, color=None): """Write the given text to the provided stream or **sys.stdout** by default. Provides optional foreground and background colors from the ansi defaults: **grey**, **red**, **green**, **yellow**, **blue**, **magenta**, **cyan** ...
[ "def", "echo", "(", "text", ",", "fg", "=", "None", ",", "bg", "=", "None", ",", "style", "=", "None", ",", "file", "=", "None", ",", "err", "=", "False", ",", "color", "=", "None", ")", ":", "if", "file", "and", "not", "hasattr", "(", "file", ...
Write the given text to the provided stream or **sys.stdout** by default. Provides optional foreground and background colors from the ansi defaults: **grey**, **red**, **green**, **yellow**, **blue**, **magenta**, **cyan** or **white**. Available styles include **bold**, **dark**, **underline**, **bli...
[ "Write", "the", "given", "text", "to", "the", "provided", "stream", "or", "**", "sys", ".", "stdout", "**", "by", "default", "." ]
train
https://github.com/sarugaku/vistir/blob/96c008ee62a43608d1e70797f74634cb66a004c1/src/vistir/misc.py#L938-L987
sarugaku/vistir
src/vistir/cursor.py
get_stream_handle
def get_stream_handle(stream=sys.stdout): """ Get the OS appropriate handle for the corresponding output stream. :param str stream: The the stream to get the handle for :return: A handle to the appropriate stream, either a ctypes buffer or **sys.stdout** or **sys.stderr**. """ hand...
python
def get_stream_handle(stream=sys.stdout): """ Get the OS appropriate handle for the corresponding output stream. :param str stream: The the stream to get the handle for :return: A handle to the appropriate stream, either a ctypes buffer or **sys.stdout** or **sys.stderr**. """ hand...
[ "def", "get_stream_handle", "(", "stream", "=", "sys", ".", "stdout", ")", ":", "handle", "=", "stream", "if", "os", ".", "name", "==", "\"nt\"", ":", "from", ".", "_winconsole", "import", "get_stream_handle", "as", "get_win_stream_handle", "return", "get_win_...
Get the OS appropriate handle for the corresponding output stream. :param str stream: The the stream to get the handle for :return: A handle to the appropriate stream, either a ctypes buffer or **sys.stdout** or **sys.stderr**.
[ "Get", "the", "OS", "appropriate", "handle", "for", "the", "corresponding", "output", "stream", "." ]
train
https://github.com/sarugaku/vistir/blob/96c008ee62a43608d1e70797f74634cb66a004c1/src/vistir/cursor.py#L10-L23
sarugaku/vistir
src/vistir/cursor.py
hide_cursor
def hide_cursor(stream=sys.stdout): """ Hide the console cursor on the given stream :param stream: The name of the stream to get the handle for :return: None :rtype: None """ handle = get_stream_handle(stream=stream) if os.name == "nt": from ._winconsole import hide_cursor ...
python
def hide_cursor(stream=sys.stdout): """ Hide the console cursor on the given stream :param stream: The name of the stream to get the handle for :return: None :rtype: None """ handle = get_stream_handle(stream=stream) if os.name == "nt": from ._winconsole import hide_cursor ...
[ "def", "hide_cursor", "(", "stream", "=", "sys", ".", "stdout", ")", ":", "handle", "=", "get_stream_handle", "(", "stream", "=", "stream", ")", "if", "os", ".", "name", "==", "\"nt\"", ":", "from", ".", "_winconsole", "import", "hide_cursor", "hide_cursor...
Hide the console cursor on the given stream :param stream: The name of the stream to get the handle for :return: None :rtype: None
[ "Hide", "the", "console", "cursor", "on", "the", "given", "stream" ]
train
https://github.com/sarugaku/vistir/blob/96c008ee62a43608d1e70797f74634cb66a004c1/src/vistir/cursor.py#L26-L42
sarugaku/vistir
tasks/__init__.py
clean
def clean(ctx): """Clean previously built package artifacts. """ ctx.run(f"python setup.py clean") dist = ROOT.joinpath("dist") print(f"[clean] Removing {dist}") if dist.exists(): shutil.rmtree(str(dist))
python
def clean(ctx): """Clean previously built package artifacts. """ ctx.run(f"python setup.py clean") dist = ROOT.joinpath("dist") print(f"[clean] Removing {dist}") if dist.exists(): shutil.rmtree(str(dist))
[ "def", "clean", "(", "ctx", ")", ":", "ctx", ".", "run", "(", "f\"python setup.py clean\"", ")", "dist", "=", "ROOT", ".", "joinpath", "(", "\"dist\"", ")", "print", "(", "f\"[clean] Removing {dist}\"", ")", "if", "dist", ".", "exists", "(", ")", ":", "s...
Clean previously built package artifacts.
[ "Clean", "previously", "built", "package", "artifacts", "." ]
train
https://github.com/sarugaku/vistir/blob/96c008ee62a43608d1e70797f74634cb66a004c1/tasks/__init__.py#L26-L33
sarugaku/vistir
src/vistir/backports/tempfile.py
_sanitize_params
def _sanitize_params(prefix, suffix, dir): """Common parameter processing for most APIs in this module.""" output_type = _infer_return_type(prefix, suffix, dir) if suffix is None: suffix = output_type() if prefix is None: if output_type is str: prefix = "tmp" else: ...
python
def _sanitize_params(prefix, suffix, dir): """Common parameter processing for most APIs in this module.""" output_type = _infer_return_type(prefix, suffix, dir) if suffix is None: suffix = output_type() if prefix is None: if output_type is str: prefix = "tmp" else: ...
[ "def", "_sanitize_params", "(", "prefix", ",", "suffix", ",", "dir", ")", ":", "output_type", "=", "_infer_return_type", "(", "prefix", ",", "suffix", ",", "dir", ")", "if", "suffix", "is", "None", ":", "suffix", "=", "output_type", "(", ")", "if", "pref...
Common parameter processing for most APIs in this module.
[ "Common", "parameter", "processing", "for", "most", "APIs", "in", "this", "module", "." ]
train
https://github.com/sarugaku/vistir/blob/96c008ee62a43608d1e70797f74634cb66a004c1/src/vistir/backports/tempfile.py#L55-L70
sarugaku/vistir
src/vistir/backports/surrogateescape.py
register_surrogateescape
def register_surrogateescape(): """ Registers the surrogateescape error handler on Python 2 (only) """ if six.PY3: return try: codecs.lookup_error(FS_ERRORS) except LookupError: codecs.register_error(FS_ERRORS, surrogateescape_handler)
python
def register_surrogateescape(): """ Registers the surrogateescape error handler on Python 2 (only) """ if six.PY3: return try: codecs.lookup_error(FS_ERRORS) except LookupError: codecs.register_error(FS_ERRORS, surrogateescape_handler)
[ "def", "register_surrogateescape", "(", ")", ":", "if", "six", ".", "PY3", ":", "return", "try", ":", "codecs", ".", "lookup_error", "(", "FS_ERRORS", ")", "except", "LookupError", ":", "codecs", ".", "register_error", "(", "FS_ERRORS", ",", "surrogateescape_h...
Registers the surrogateescape error handler on Python 2 (only)
[ "Registers", "the", "surrogateescape", "error", "handler", "on", "Python", "2", "(", "only", ")" ]
train
https://github.com/sarugaku/vistir/blob/96c008ee62a43608d1e70797f74634cb66a004c1/src/vistir/backports/surrogateescape.py#L183-L192
sarugaku/vistir
src/vistir/path.py
set_write_bit
def set_write_bit(fn): # type: (str) -> None """ Set read-write permissions for the current user on the target path. Fail silently if the path doesn't exist. :param str fn: The target filename or path :return: None """ fn = fs_encode(fn) if not os.path.exists(fn): return ...
python
def set_write_bit(fn): # type: (str) -> None """ Set read-write permissions for the current user on the target path. Fail silently if the path doesn't exist. :param str fn: The target filename or path :return: None """ fn = fs_encode(fn) if not os.path.exists(fn): return ...
[ "def", "set_write_bit", "(", "fn", ")", ":", "# type: (str) -> None", "fn", "=", "fs_encode", "(", "fn", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "fn", ")", ":", "return", "file_stat", "=", "os", ".", "stat", "(", "fn", ")", ".", "s...
Set read-write permissions for the current user on the target path. Fail silently if the path doesn't exist. :param str fn: The target filename or path :return: None
[ "Set", "read", "-", "write", "permissions", "for", "the", "current", "user", "on", "the", "target", "path", ".", "Fail", "silently", "if", "the", "path", "doesn", "t", "exist", "." ]
train
https://github.com/sarugaku/vistir/blob/96c008ee62a43608d1e70797f74634cb66a004c1/src/vistir/path.py#L325-L362
danielholmstrom/dictalchemy
dictalchemy/utils.py
arg_to_dict
def arg_to_dict(arg): """Convert an argument that can be None, list/tuple or dict to dict Example:: >>> arg_to_dict(None) [] >>> arg_to_dict(['a', 'b']) {'a':{},'b':{}} >>> arg_to_dict({'a':{'only': 'id'}, 'b':{'only': 'id'}}) {'a':{'only':'id'},'b':{'only':'id'...
python
def arg_to_dict(arg): """Convert an argument that can be None, list/tuple or dict to dict Example:: >>> arg_to_dict(None) [] >>> arg_to_dict(['a', 'b']) {'a':{},'b':{}} >>> arg_to_dict({'a':{'only': 'id'}, 'b':{'only': 'id'}}) {'a':{'only':'id'},'b':{'only':'id'...
[ "def", "arg_to_dict", "(", "arg", ")", ":", "if", "arg", "is", "None", ":", "arg", "=", "[", "]", "try", ":", "arg", "=", "dict", "(", "arg", ")", "except", "ValueError", ":", "arg", "=", "dict", ".", "fromkeys", "(", "list", "(", "arg", ")", "...
Convert an argument that can be None, list/tuple or dict to dict Example:: >>> arg_to_dict(None) [] >>> arg_to_dict(['a', 'b']) {'a':{},'b':{}} >>> arg_to_dict({'a':{'only': 'id'}, 'b':{'only': 'id'}}) {'a':{'only':'id'},'b':{'only':'id'}} :return: dict with ke...
[ "Convert", "an", "argument", "that", "can", "be", "None", "list", "/", "tuple", "or", "dict", "to", "dict" ]
train
https://github.com/danielholmstrom/dictalchemy/blob/038b8822b0ed66feef78a80b3af8f3a09f795b5a/dictalchemy/utils.py#L20-L41
danielholmstrom/dictalchemy
dictalchemy/utils.py
asdict
def asdict(model, exclude=None, exclude_underscore=None, exclude_pk=None, follow=None, include=None, only=None, method='asdict', **kwargs): """Get a dict from a model Using the `method` parameter makes it possible to have multiple methods that formats the result. Additional keyword argument...
python
def asdict(model, exclude=None, exclude_underscore=None, exclude_pk=None, follow=None, include=None, only=None, method='asdict', **kwargs): """Get a dict from a model Using the `method` parameter makes it possible to have multiple methods that formats the result. Additional keyword argument...
[ "def", "asdict", "(", "model", ",", "exclude", "=", "None", ",", "exclude_underscore", "=", "None", ",", "exclude_pk", "=", "None", ",", "follow", "=", "None", ",", "include", "=", "None", ",", "only", "=", "None", ",", "method", "=", "'asdict'", ",", ...
Get a dict from a model Using the `method` parameter makes it possible to have multiple methods that formats the result. Additional keyword arguments will be passed to all relationships that are followed. This can be used to pass on things like request or context. :param follow: List or dict of r...
[ "Get", "a", "dict", "from", "a", "model" ]
train
https://github.com/danielholmstrom/dictalchemy/blob/038b8822b0ed66feef78a80b3af8f3a09f795b5a/dictalchemy/utils.py#L44-L183
danielholmstrom/dictalchemy
dictalchemy/utils.py
fromdict
def fromdict(model, data, exclude=None, exclude_underscore=None, allow_pk=None, follow=None, include=None, only=None): """Update a model from a dict Works almost identically as :meth:`dictalchemy.utils.asdict`. However, it will not create missing instances or update collections. This meth...
python
def fromdict(model, data, exclude=None, exclude_underscore=None, allow_pk=None, follow=None, include=None, only=None): """Update a model from a dict Works almost identically as :meth:`dictalchemy.utils.asdict`. However, it will not create missing instances or update collections. This meth...
[ "def", "fromdict", "(", "model", ",", "data", ",", "exclude", "=", "None", ",", "exclude_underscore", "=", "None", ",", "allow_pk", "=", "None", ",", "follow", "=", "None", ",", "include", "=", "None", ",", "only", "=", "None", ")", ":", "follow", "=...
Update a model from a dict Works almost identically as :meth:`dictalchemy.utils.asdict`. However, it will not create missing instances or update collections. This method updates the following properties on a model: * Simple columns * Synonyms * Simple 1-m relationships :param data: dict ...
[ "Update", "a", "model", "from", "a", "dict" ]
train
https://github.com/danielholmstrom/dictalchemy/blob/038b8822b0ed66feef78a80b3af8f3a09f795b5a/dictalchemy/utils.py#L186-L283
danielholmstrom/dictalchemy
dictalchemy/utils.py
make_class_dictable
def make_class_dictable( cls, exclude=constants.default_exclude, exclude_underscore=constants.default_exclude_underscore, fromdict_allow_pk=constants.default_fromdict_allow_pk, include=None, asdict_include=None, fromdict_include=None): """Make a class dictable...
python
def make_class_dictable( cls, exclude=constants.default_exclude, exclude_underscore=constants.default_exclude_underscore, fromdict_allow_pk=constants.default_fromdict_allow_pk, include=None, asdict_include=None, fromdict_include=None): """Make a class dictable...
[ "def", "make_class_dictable", "(", "cls", ",", "exclude", "=", "constants", ".", "default_exclude", ",", "exclude_underscore", "=", "constants", ".", "default_exclude_underscore", ",", "fromdict_allow_pk", "=", "constants", ".", "default_fromdict_allow_pk", ",", "includ...
Make a class dictable Useful for when the Base class is already defined, for example when using Flask-SQLAlchemy. Warning: This method will overwrite existing attributes if they exists. :param exclude: Will be set as dictalchemy_exclude on the class :param exclude_underscore: Will be set as dicta...
[ "Make", "a", "class", "dictable" ]
train
https://github.com/danielholmstrom/dictalchemy/blob/038b8822b0ed66feef78a80b3af8f3a09f795b5a/dictalchemy/utils.py#L295-L333
simon-anders/htseq
python2/HTSeq/__init__.py
parse_GFF_attribute_string
def parse_GFF_attribute_string(attrStr, extra_return_first_value=False): """Parses a GFF attribute string and returns it as a dictionary. If 'extra_return_first_value' is set, a pair is returned: the dictionary and the value of the first attribute. This might be useful if this is the ID. """ if...
python
def parse_GFF_attribute_string(attrStr, extra_return_first_value=False): """Parses a GFF attribute string and returns it as a dictionary. If 'extra_return_first_value' is set, a pair is returned: the dictionary and the value of the first attribute. This might be useful if this is the ID. """ if...
[ "def", "parse_GFF_attribute_string", "(", "attrStr", ",", "extra_return_first_value", "=", "False", ")", ":", "if", "attrStr", ".", "endswith", "(", "\"\\n\"", ")", ":", "attrStr", "=", "attrStr", "[", ":", "-", "1", "]", "d", "=", "{", "}", "first_val", ...
Parses a GFF attribute string and returns it as a dictionary. If 'extra_return_first_value' is set, a pair is returned: the dictionary and the value of the first attribute. This might be useful if this is the ID.
[ "Parses", "a", "GFF", "attribute", "string", "and", "returns", "it", "as", "a", "dictionary", "." ]
train
https://github.com/simon-anders/htseq/blob/6f7d66e757e610228c33ebf2bb5dc8cc5051c7f0/python2/HTSeq/__init__.py#L144-L175
simon-anders/htseq
python2/HTSeq/__init__.py
make_feature_dict
def make_feature_dict(feature_sequence): """A feature dict is a convenient way to organize a sequence of Feature object (which you have got, e.g., from parse_GFF). The function returns a dict with all the feature types as keys. Each value of this dict is again a dict, now of feature names. The values o...
python
def make_feature_dict(feature_sequence): """A feature dict is a convenient way to organize a sequence of Feature object (which you have got, e.g., from parse_GFF). The function returns a dict with all the feature types as keys. Each value of this dict is again a dict, now of feature names. The values o...
[ "def", "make_feature_dict", "(", "feature_sequence", ")", ":", "res", "=", "{", "}", "for", "f", "in", "feature_sequence", ":", "if", "f", ".", "type", "not", "in", "res", ":", "res", "[", "f", ".", "type", "]", "=", "{", "}", "res_ftype", "=", "re...
A feature dict is a convenient way to organize a sequence of Feature object (which you have got, e.g., from parse_GFF). The function returns a dict with all the feature types as keys. Each value of this dict is again a dict, now of feature names. The values of this dict is a list of feature. An ex...
[ "A", "feature", "dict", "is", "a", "convenient", "way", "to", "organize", "a", "sequence", "of", "Feature", "object", "(", "which", "you", "have", "got", "e", ".", "g", ".", "from", "parse_GFF", ")", "." ]
train
https://github.com/simon-anders/htseq/blob/6f7d66e757e610228c33ebf2bb5dc8cc5051c7f0/python2/HTSeq/__init__.py#L231-L263
simon-anders/htseq
python2/HTSeq/__init__.py
pair_SAM_alignments
def pair_SAM_alignments( alignments, bundle=False, primary_only=False): '''Iterate over SAM aligments, name-sorted paired-end Args: alignments (iterator of SAM/BAM alignments): the alignments to wrap bundle (bool): if True, bundle all alignments from one read pair into a...
python
def pair_SAM_alignments( alignments, bundle=False, primary_only=False): '''Iterate over SAM aligments, name-sorted paired-end Args: alignments (iterator of SAM/BAM alignments): the alignments to wrap bundle (bool): if True, bundle all alignments from one read pair into a...
[ "def", "pair_SAM_alignments", "(", "alignments", ",", "bundle", "=", "False", ",", "primary_only", "=", "False", ")", ":", "mate_missing_count", "=", "[", "0", "]", "def", "process_list", "(", "almnt_list", ")", ":", "'''Transform a list of alignment with the same r...
Iterate over SAM aligments, name-sorted paired-end Args: alignments (iterator of SAM/BAM alignments): the alignments to wrap bundle (bool): if True, bundle all alignments from one read pair into a single yield. If False (default), each pair of alignments is yielded separatel...
[ "Iterate", "over", "SAM", "aligments", "name", "-", "sorted", "paired", "-", "end" ]
train
https://github.com/simon-anders/htseq/blob/6f7d66e757e610228c33ebf2bb5dc8cc5051c7f0/python2/HTSeq/__init__.py#L634-L736
simon-anders/htseq
python2/src/StepVector.py
StepVector.create
def create( cls, length = sys.maxint, typecode = 'd', start_index = 0 ): """Construct a StepVector of the given length, with indices starting at the given start_index and counting up to (but not including) start_index + length. The typecode may be: 'd' for float values (C type 'double')...
python
def create( cls, length = sys.maxint, typecode = 'd', start_index = 0 ): """Construct a StepVector of the given length, with indices starting at the given start_index and counting up to (but not including) start_index + length. The typecode may be: 'd' for float values (C type 'double')...
[ "def", "create", "(", "cls", ",", "length", "=", "sys", ".", "maxint", ",", "typecode", "=", "'d'", ",", "start_index", "=", "0", ")", ":", "if", "typecode", "==", "'d'", ":", "swigclass", "=", "_StepVector_float", "elif", "typecode", "==", "'i'", ":",...
Construct a StepVector of the given length, with indices starting at the given start_index and counting up to (but not including) start_index + length. The typecode may be: 'd' for float values (C type 'double'), 'i' for int values, 'b' for Boolean values, 'O' for arbi...
[ "Construct", "a", "StepVector", "of", "the", "given", "length", "with", "indices", "starting", "at", "the", "given", "start_index", "and", "counting", "up", "to", "(", "but", "not", "including", ")", "start_index", "+", "length", "." ]
train
https://github.com/simon-anders/htseq/blob/6f7d66e757e610228c33ebf2bb5dc8cc5051c7f0/python2/src/StepVector.py#L466-L495
simon-anders/htseq
python3/src/StepVector.py
StepVector.get_steps
def get_steps( self, values_only = False, merge_steps=True ): """To get a succinct representation of the StepVector's content, call the 'get_steps' method. It returns an iterator that generates triples of values. Each triple contains one step, giving first the start index of the step, then the s...
python
def get_steps( self, values_only = False, merge_steps=True ): """To get a succinct representation of the StepVector's content, call the 'get_steps' method. It returns an iterator that generates triples of values. Each triple contains one step, giving first the start index of the step, then the s...
[ "def", "get_steps", "(", "self", ",", "values_only", "=", "False", ",", "merge_steps", "=", "True", ")", ":", "startvals", "=", "self", ".", "_swigobj", ".", "get_values_pystyle", "(", "self", ".", "start", ")", "prevstart", "=", "self", ".", "start", "p...
To get a succinct representation of the StepVector's content, call the 'get_steps' method. It returns an iterator that generates triples of values. Each triple contains one step, giving first the start index of the step, then the stop index (i.e., one more than the index of the last element), a...
[ "To", "get", "a", "succinct", "representation", "of", "the", "StepVector", "s", "content", "call", "the", "get_steps", "method", ".", "It", "returns", "an", "iterator", "that", "generates", "triples", "of", "values", ".", "Each", "triple", "contains", "one", ...
train
https://github.com/simon-anders/htseq/blob/6f7d66e757e610228c33ebf2bb5dc8cc5051c7f0/python3/src/StepVector.py#L535-L571
simon-anders/htseq
python3/HTSeq/__init__.py
bundle_multiple_alignments
def bundle_multiple_alignments(sequence_of_alignments): """Some alignment programs, e.g., Bowtie, can output multiple alignments, i.e., the same read is reported consecutively with different alignments. This function takes an iterator over alignments and bundles consecutive alignments regarding the same...
python
def bundle_multiple_alignments(sequence_of_alignments): """Some alignment programs, e.g., Bowtie, can output multiple alignments, i.e., the same read is reported consecutively with different alignments. This function takes an iterator over alignments and bundles consecutive alignments regarding the same...
[ "def", "bundle_multiple_alignments", "(", "sequence_of_alignments", ")", ":", "alignment_iter", "=", "iter", "(", "sequence_of_alignments", ")", "algnt", "=", "next", "(", "alignment_iter", ")", "ma", "=", "[", "algnt", "]", "for", "algnt", "in", "alignment_iter",...
Some alignment programs, e.g., Bowtie, can output multiple alignments, i.e., the same read is reported consecutively with different alignments. This function takes an iterator over alignments and bundles consecutive alignments regarding the same read to a list of Alignment objects and returns an iterato...
[ "Some", "alignment", "programs", "e", ".", "g", ".", "Bowtie", "can", "output", "multiple", "alignments", "i", ".", "e", ".", "the", "same", "read", "is", "reported", "consecutively", "with", "different", "alignments", ".", "This", "function", "takes", "an",...
train
https://github.com/simon-anders/htseq/blob/6f7d66e757e610228c33ebf2bb5dc8cc5051c7f0/python3/HTSeq/__init__.py#L463-L479
simon-anders/htseq
python3/HTSeq/__init__.py
pair_SAM_alignments_with_buffer
def pair_SAM_alignments_with_buffer( alignments, max_buffer_size=30000000, primary_only=False): '''Iterate over SAM aligments with buffer, position-sorted paired-end Args: alignments (iterator of SAM/BAM alignments): the alignments to wrap max_buffer_size (int): maxmal n...
python
def pair_SAM_alignments_with_buffer( alignments, max_buffer_size=30000000, primary_only=False): '''Iterate over SAM aligments with buffer, position-sorted paired-end Args: alignments (iterator of SAM/BAM alignments): the alignments to wrap max_buffer_size (int): maxmal n...
[ "def", "pair_SAM_alignments_with_buffer", "(", "alignments", ",", "max_buffer_size", "=", "30000000", ",", "primary_only", "=", "False", ")", ":", "almnt_buffer", "=", "{", "}", "ambiguous_pairing_counter", "=", "0", "for", "almnt", "in", "alignments", ":", "if", ...
Iterate over SAM aligments with buffer, position-sorted paired-end Args: alignments (iterator of SAM/BAM alignments): the alignments to wrap max_buffer_size (int): maxmal numer of alignments to keep in memory. primary_only (bool): for each read, consider only the primary line (S...
[ "Iterate", "over", "SAM", "aligments", "with", "buffer", "position", "-", "sorted", "paired", "-", "end" ]
train
https://github.com/simon-anders/htseq/blob/6f7d66e757e610228c33ebf2bb5dc8cc5051c7f0/python3/HTSeq/__init__.py#L742-L824
sqreen/PyMiniRacer
py_mini_racer/extension/v8_build.py
ensure_v8_src
def ensure_v8_src(): """ Ensure that v8 src are presents and up-to-date """ path = local_path('v8') if not os.path.isdir(path): fetch_v8(path) else: update_v8(path) checkout_v8_version(local_path("v8/v8"), V8_VERSION) dependencies_sync(path)
python
def ensure_v8_src(): """ Ensure that v8 src are presents and up-to-date """ path = local_path('v8') if not os.path.isdir(path): fetch_v8(path) else: update_v8(path) checkout_v8_version(local_path("v8/v8"), V8_VERSION) dependencies_sync(path)
[ "def", "ensure_v8_src", "(", ")", ":", "path", "=", "local_path", "(", "'v8'", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "fetch_v8", "(", "path", ")", "else", ":", "update_v8", "(", "path", ")", "checkout_v8_version", ...
Ensure that v8 src are presents and up-to-date
[ "Ensure", "that", "v8", "src", "are", "presents", "and", "up", "-", "to", "-", "date" ]
train
https://github.com/sqreen/PyMiniRacer/blob/86747cddb13895ccaba990704ad68e5e059587f9/py_mini_racer/extension/v8_build.py#L57-L68
sqreen/PyMiniRacer
wheel_pymalloc.py
get_filenames
def get_filenames(directory): """Get all the file to copy""" for filename in os.listdir(directory): if re.search(r"cp\d{2}mu?-manylinux1_\S+\.whl", filename): yield filename
python
def get_filenames(directory): """Get all the file to copy""" for filename in os.listdir(directory): if re.search(r"cp\d{2}mu?-manylinux1_\S+\.whl", filename): yield filename
[ "def", "get_filenames", "(", "directory", ")", ":", "for", "filename", "in", "os", ".", "listdir", "(", "directory", ")", ":", "if", "re", ".", "search", "(", "r\"cp\\d{2}mu?-manylinux1_\\S+\\.whl\"", ",", "filename", ")", ":", "yield", "filename" ]
Get all the file to copy
[ "Get", "all", "the", "file", "to", "copy" ]
train
https://github.com/sqreen/PyMiniRacer/blob/86747cddb13895ccaba990704ad68e5e059587f9/wheel_pymalloc.py#L11-L15
sqreen/PyMiniRacer
wheel_pymalloc.py
copy_file
def copy_file(filename): """Copy the file and put the correct tag""" print("Updating file %s" % filename) out_dir = os.path.abspath(DIRECTORY) tags = filename[:-4].split("-") tags[-2] = tags[-2].replace("m", "") new_name = "-".join(tags) + ".whl" wheel_flag = "-".join(tags[2:]) with...
python
def copy_file(filename): """Copy the file and put the correct tag""" print("Updating file %s" % filename) out_dir = os.path.abspath(DIRECTORY) tags = filename[:-4].split("-") tags[-2] = tags[-2].replace("m", "") new_name = "-".join(tags) + ".whl" wheel_flag = "-".join(tags[2:]) with...
[ "def", "copy_file", "(", "filename", ")", ":", "print", "(", "\"Updating file %s\"", "%", "filename", ")", "out_dir", "=", "os", ".", "path", ".", "abspath", "(", "DIRECTORY", ")", "tags", "=", "filename", "[", ":", "-", "4", "]", ".", "split", "(", ...
Copy the file and put the correct tag
[ "Copy", "the", "file", "and", "put", "the", "correct", "tag" ]
train
https://github.com/sqreen/PyMiniRacer/blob/86747cddb13895ccaba990704ad68e5e059587f9/wheel_pymalloc.py#L17-L40
sqreen/PyMiniRacer
py_mini_racer/py_mini_racer.py
is_unicode
def is_unicode(value): """ Check if a value is a valid unicode string, compatible with python 2 and python 3 >>> is_unicode(u'foo') True >>> is_unicode(u'✌') True >>> is_unicode(b'foo') False >>> is_unicode(42) False >>> is_unicode(('abc',)) False """ python_version ...
python
def is_unicode(value): """ Check if a value is a valid unicode string, compatible with python 2 and python 3 >>> is_unicode(u'foo') True >>> is_unicode(u'✌') True >>> is_unicode(b'foo') False >>> is_unicode(42) False >>> is_unicode(('abc',)) False """ python_version ...
[ "def", "is_unicode", "(", "value", ")", ":", "python_version", "=", "sys", ".", "version_info", "[", "0", "]", "if", "python_version", "==", "2", ":", "return", "isinstance", "(", "value", ",", "unicode", ")", "elif", "python_version", "==", "3", ":", "r...
Check if a value is a valid unicode string, compatible with python 2 and python 3 >>> is_unicode(u'foo') True >>> is_unicode(u'✌') True >>> is_unicode(b'foo') False >>> is_unicode(42) False >>> is_unicode(('abc',)) False
[ "Check", "if", "a", "value", "is", "a", "valid", "unicode", "string", "compatible", "with", "python", "2", "and", "python", "3" ]
train
https://github.com/sqreen/PyMiniRacer/blob/86747cddb13895ccaba990704ad68e5e059587f9/py_mini_racer/py_mini_racer.py#L59-L80
sqreen/PyMiniRacer
py_mini_racer/py_mini_racer.py
MiniRacer.execute
def execute(self, js_str, timeout=0, max_memory=0): """ Exec the given JS value """ wrapped = "(function(){return (%s)})()" % js_str return self.eval(wrapped, timeout, max_memory)
python
def execute(self, js_str, timeout=0, max_memory=0): """ Exec the given JS value """ wrapped = "(function(){return (%s)})()" % js_str return self.eval(wrapped, timeout, max_memory)
[ "def", "execute", "(", "self", ",", "js_str", ",", "timeout", "=", "0", ",", "max_memory", "=", "0", ")", ":", "wrapped", "=", "\"(function(){return (%s)})()\"", "%", "js_str", "return", "self", ".", "eval", "(", "wrapped", ",", "timeout", ",", "max_memory...
Exec the given JS value
[ "Exec", "the", "given", "JS", "value" ]
train
https://github.com/sqreen/PyMiniRacer/blob/86747cddb13895ccaba990704ad68e5e059587f9/py_mini_racer/py_mini_racer.py#L136-L140
sqreen/PyMiniRacer
py_mini_racer/py_mini_racer.py
MiniRacer.eval
def eval(self, js_str, timeout=0, max_memory=0): """ Eval the JavaScript string """ if is_unicode(js_str): bytes_val = js_str.encode("utf8") else: bytes_val = js_str res = None self.lock.acquire() try: res = self.ext.mr_eval_context(s...
python
def eval(self, js_str, timeout=0, max_memory=0): """ Eval the JavaScript string """ if is_unicode(js_str): bytes_val = js_str.encode("utf8") else: bytes_val = js_str res = None self.lock.acquire() try: res = self.ext.mr_eval_context(s...
[ "def", "eval", "(", "self", ",", "js_str", ",", "timeout", "=", "0", ",", "max_memory", "=", "0", ")", ":", "if", "is_unicode", "(", "js_str", ")", ":", "bytes_val", "=", "js_str", ".", "encode", "(", "\"utf8\"", ")", "else", ":", "bytes_val", "=", ...
Eval the JavaScript string
[ "Eval", "the", "JavaScript", "string" ]
train
https://github.com/sqreen/PyMiniRacer/blob/86747cddb13895ccaba990704ad68e5e059587f9/py_mini_racer/py_mini_racer.py#L142-L166
sqreen/PyMiniRacer
py_mini_racer/py_mini_racer.py
MiniRacer.call
def call(self, identifier, *args, **kwargs): """ Call the named function with provided arguments You can pass a custom JSON encoder by passing it in the encoder keyword only argument. """ encoder = kwargs.get('encoder', None) timeout = kwargs.get('timeout', 0) ma...
python
def call(self, identifier, *args, **kwargs): """ Call the named function with provided arguments You can pass a custom JSON encoder by passing it in the encoder keyword only argument. """ encoder = kwargs.get('encoder', None) timeout = kwargs.get('timeout', 0) ma...
[ "def", "call", "(", "self", ",", "identifier", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "encoder", "=", "kwargs", ".", "get", "(", "'encoder'", ",", "None", ")", "timeout", "=", "kwargs", ".", "get", "(", "'timeout'", ",", "0", ")", "...
Call the named function with provided arguments You can pass a custom JSON encoder by passing it in the encoder keyword only argument.
[ "Call", "the", "named", "function", "with", "provided", "arguments", "You", "can", "pass", "a", "custom", "JSON", "encoder", "by", "passing", "it", "in", "the", "encoder", "keyword", "only", "argument", "." ]
train
https://github.com/sqreen/PyMiniRacer/blob/86747cddb13895ccaba990704ad68e5e059587f9/py_mini_racer/py_mini_racer.py#L168-L180
sqreen/PyMiniRacer
py_mini_racer/py_mini_racer.py
MiniRacer.heap_stats
def heap_stats(self): """ Return heap statistics """ self.lock.acquire() res = self.ext.mr_heap_stats(self.ctx) self.lock.release() python_value = res.contents.to_python() self.free(res) return python_value
python
def heap_stats(self): """ Return heap statistics """ self.lock.acquire() res = self.ext.mr_heap_stats(self.ctx) self.lock.release() python_value = res.contents.to_python() self.free(res) return python_value
[ "def", "heap_stats", "(", "self", ")", ":", "self", ".", "lock", ".", "acquire", "(", ")", "res", "=", "self", ".", "ext", ".", "mr_heap_stats", "(", "self", ".", "ctx", ")", "self", ".", "lock", ".", "release", "(", ")", "python_value", "=", "res"...
Return heap statistics
[ "Return", "heap", "statistics" ]
train
https://github.com/sqreen/PyMiniRacer/blob/86747cddb13895ccaba990704ad68e5e059587f9/py_mini_racer/py_mini_racer.py#L182-L191
sqreen/PyMiniRacer
py_mini_racer/py_mini_racer.py
MiniRacer.heap_snapshot
def heap_snapshot(self): """ Return heap snapshot """ self.lock.acquire() res = self.ext.mr_heap_snapshot(self.ctx) self.lock.release() python_value = res.contents.to_python() self.free(res) return python_value
python
def heap_snapshot(self): """ Return heap snapshot """ self.lock.acquire() res = self.ext.mr_heap_snapshot(self.ctx) self.lock.release() python_value = res.contents.to_python() self.free(res) return python_value
[ "def", "heap_snapshot", "(", "self", ")", ":", "self", ".", "lock", ".", "acquire", "(", ")", "res", "=", "self", ".", "ext", ".", "mr_heap_snapshot", "(", "self", ".", "ctx", ")", "self", ".", "lock", ".", "release", "(", ")", "python_value", "=", ...
Return heap snapshot
[ "Return", "heap", "snapshot" ]
train
https://github.com/sqreen/PyMiniRacer/blob/86747cddb13895ccaba990704ad68e5e059587f9/py_mini_racer/py_mini_racer.py#L196-L205
sqreen/PyMiniRacer
py_mini_racer/py_mini_racer.py
PythonValue.to_python
def to_python(self): """ Return an object as native Python """ result = None if self.type == PythonTypes.null: result = None elif self.type == PythonTypes.bool: result = self.value == 1 elif self.type == PythonTypes.integer: if self.value is N...
python
def to_python(self): """ Return an object as native Python """ result = None if self.type == PythonTypes.null: result = None elif self.type == PythonTypes.bool: result = self.value == 1 elif self.type == PythonTypes.integer: if self.value is N...
[ "def", "to_python", "(", "self", ")", ":", "result", "=", "None", "if", "self", ".", "type", "==", "PythonTypes", ".", "null", ":", "result", "=", "None", "elif", "self", ".", "type", "==", "PythonTypes", ".", "bool", ":", "result", "=", "self", ".",...
Return an object as native Python
[ "Return", "an", "object", "as", "native", "Python" ]
train
https://github.com/sqreen/PyMiniRacer/blob/86747cddb13895ccaba990704ad68e5e059587f9/py_mini_racer/py_mini_racer.py#L248-L308
sqreen/PyMiniRacer
setup.py
libv8_object
def libv8_object(object_name): """ Return a path for object_name which is OS independent """ filename = join(V8_LIB_DIRECTORY, 'out.gn/x64.release/obj/{}'.format(object_name)) if not isfile(filename): filename = join(local_path('vendor/v8/out.gn/libv8/obj/{}'.format(object_name))) if not ...
python
def libv8_object(object_name): """ Return a path for object_name which is OS independent """ filename = join(V8_LIB_DIRECTORY, 'out.gn/x64.release/obj/{}'.format(object_name)) if not isfile(filename): filename = join(local_path('vendor/v8/out.gn/libv8/obj/{}'.format(object_name))) if not ...
[ "def", "libv8_object", "(", "object_name", ")", ":", "filename", "=", "join", "(", "V8_LIB_DIRECTORY", ",", "'out.gn/x64.release/obj/{}'", ".", "format", "(", "object_name", ")", ")", "if", "not", "isfile", "(", "filename", ")", ":", "filename", "=", "join", ...
Return a path for object_name which is OS independent
[ "Return", "a", "path", "for", "object_name", "which", "is", "OS", "independent" ]
train
https://github.com/sqreen/PyMiniRacer/blob/86747cddb13895ccaba990704ad68e5e059587f9/setup.py#L88-L100
sqreen/PyMiniRacer
setup.py
get_static_lib_paths
def get_static_lib_paths(): """ Return the required static libraries path """ libs = [] is_linux = sys.platform.startswith('linux') if is_linux: libs += ['-Wl,--start-group'] libs += get_raw_static_lib_path() if is_linux: libs += ['-Wl,--end-group'] return libs
python
def get_static_lib_paths(): """ Return the required static libraries path """ libs = [] is_linux = sys.platform.startswith('linux') if is_linux: libs += ['-Wl,--start-group'] libs += get_raw_static_lib_path() if is_linux: libs += ['-Wl,--end-group'] return libs
[ "def", "get_static_lib_paths", "(", ")", ":", "libs", "=", "[", "]", "is_linux", "=", "sys", ".", "platform", ".", "startswith", "(", "'linux'", ")", "if", "is_linux", ":", "libs", "+=", "[", "'-Wl,--start-group'", "]", "libs", "+=", "get_raw_static_lib_path...
Return the required static libraries path
[ "Return", "the", "required", "static", "libraries", "path" ]
train
https://github.com/sqreen/PyMiniRacer/blob/86747cddb13895ccaba990704ad68e5e059587f9/setup.py#L110-L120
sqreen/PyMiniRacer
setup.py
MiniRacerBuildExt.build_extension
def build_extension(self, ext): """ Compile manually the py_mini_racer extension, bypass setuptools """ try: if not is_v8_built(): self.run_command('build_v8') self.debug = True if V8_PATH: dest_filename = join(self.build_lib, ...
python
def build_extension(self, ext): """ Compile manually the py_mini_racer extension, bypass setuptools """ try: if not is_v8_built(): self.run_command('build_v8') self.debug = True if V8_PATH: dest_filename = join(self.build_lib, ...
[ "def", "build_extension", "(", "self", ",", "ext", ")", ":", "try", ":", "if", "not", "is_v8_built", "(", ")", ":", "self", ".", "run_command", "(", "'build_v8'", ")", "self", ".", "debug", "=", "True", "if", "V8_PATH", ":", "dest_filename", "=", "join...
Compile manually the py_mini_racer extension, bypass setuptools
[ "Compile", "manually", "the", "py_mini_racer", "extension", "bypass", "setuptools" ]
train
https://github.com/sqreen/PyMiniRacer/blob/86747cddb13895ccaba990704ad68e5e059587f9/setup.py#L156-L180
sqreen/PyMiniRacer
helpers/babel.py
babel_transform
def babel_transform(es_string): """ Transform the provided string using babel.transform """ path_to_babel = os.path.join(os.path.dirname(__file__), '..', 'tests', 'fixtures', 'babel.js') es6 = '[1,2,3].map(n => n + 1);' babel_source = open(path_to_babel, "r").read() ...
python
def babel_transform(es_string): """ Transform the provided string using babel.transform """ path_to_babel = os.path.join(os.path.dirname(__file__), '..', 'tests', 'fixtures', 'babel.js') es6 = '[1,2,3].map(n => n + 1);' babel_source = open(path_to_babel, "r").read() ...
[ "def", "babel_transform", "(", "es_string", ")", ":", "path_to_babel", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "'..'", ",", "'tests'", ",", "'fixtures'", ",", "'babel.js'", ")", "es6", "="...
Transform the provided string using babel.transform
[ "Transform", "the", "provided", "string", "using", "babel", ".", "transform" ]
train
https://github.com/sqreen/PyMiniRacer/blob/86747cddb13895ccaba990704ad68e5e059587f9/helpers/babel.py#L8-L27
Giphy/giphy-python-client
giphy_client/apis/default_api.py
DefaultApi.gifs_categories_category_get
def gifs_categories_category_get(self, api_key, category, **kwargs): """ Category Tags Endpoint. Returns a list of tags for a given category. NOTE `limit` and `offset` must both be set; otherwise they're ignored. This method makes a synchronous HTTP request by default. To make an ...
python
def gifs_categories_category_get(self, api_key, category, **kwargs): """ Category Tags Endpoint. Returns a list of tags for a given category. NOTE `limit` and `offset` must both be set; otherwise they're ignored. This method makes a synchronous HTTP request by default. To make an ...
[ "def", "gifs_categories_category_get", "(", "self", ",", "api_key", ",", "category", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'callback'", ")", ":", "return", "self", ...
Category Tags Endpoint. Returns a list of tags for a given category. NOTE `limit` and `offset` must both be set; otherwise they're ignored. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked whe...
[ "Category", "Tags", "Endpoint", ".", "Returns", "a", "list", "of", "tags", "for", "a", "given", "category", ".", "NOTE", "limit", "and", "offset", "must", "both", "be", "set", ";", "otherwise", "they", "re", "ignored", ".", "This", "method", "makes", "a"...
train
https://github.com/Giphy/giphy-python-client/blob/e89b67c3bf65e2241f32a74e012ab3462dd2599d/giphy_client/apis/default_api.py#L50-L77
Giphy/giphy-python-client
giphy_client/apis/default_api.py
DefaultApi.gifs_categories_category_tag_get
def gifs_categories_category_tag_get(self, api_key, category, tag, **kwargs): """ Tagged Gifs Endpoint. Returns a list of gifs for a given tag (alias to `/gif/search`). This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a ...
python
def gifs_categories_category_tag_get(self, api_key, category, tag, **kwargs): """ Tagged Gifs Endpoint. Returns a list of gifs for a given tag (alias to `/gif/search`). This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a ...
[ "def", "gifs_categories_category_tag_get", "(", "self", ",", "api_key", ",", "category", ",", "tag", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'callback'", ")", ":", "r...
Tagged Gifs Endpoint. Returns a list of gifs for a given tag (alias to `/gif/search`). This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_fu...
[ "Tagged", "Gifs", "Endpoint", ".", "Returns", "a", "list", "of", "gifs", "for", "a", "given", "tag", "(", "alias", "to", "/", "gif", "/", "search", ")", ".", "This", "method", "makes", "a", "synchronous", "HTTP", "request", "by", "default", ".", "To", ...
train
https://github.com/Giphy/giphy-python-client/blob/e89b67c3bf65e2241f32a74e012ab3462dd2599d/giphy_client/apis/default_api.py#L180-L208
Giphy/giphy-python-client
giphy_client/apis/default_api.py
DefaultApi.gifs_categories_get
def gifs_categories_get(self, api_key, **kwargs): """ Categories Endpoint. Returns a list of categories. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the res...
python
def gifs_categories_get(self, api_key, **kwargs): """ Categories Endpoint. Returns a list of categories. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the res...
[ "def", "gifs_categories_get", "(", "self", ",", "api_key", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'callback'", ")", ":", "return", "self", ".", "gifs_categories_get_wi...
Categories Endpoint. Returns a list of categories. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pp...
[ "Categories", "Endpoint", ".", "Returns", "a", "list", "of", "categories", ".", "This", "method", "makes", "a", "synchronous", "HTTP", "request", "by", "default", ".", "To", "make", "an", "asynchronous", "HTTP", "request", "please", "define", "a", "callback", ...
train
https://github.com/Giphy/giphy-python-client/blob/e89b67c3bf65e2241f32a74e012ab3462dd2599d/giphy_client/apis/default_api.py#L317-L342
Giphy/giphy-python-client
giphy_client/apis/default_api.py
DefaultApi.gifs_get
def gifs_get(self, api_key, ids, **kwargs): """ Get GIFs by ID Endpoint A multiget version of the get GIF by ID endpoint. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when ...
python
def gifs_get(self, api_key, ids, **kwargs): """ Get GIFs by ID Endpoint A multiget version of the get GIF by ID endpoint. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when ...
[ "def", "gifs_get", "(", "self", ",", "api_key", ",", "ids", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'callback'", ")", ":", "return", "self", ".", "gifs_get_with_htt...
Get GIFs by ID Endpoint A multiget version of the get GIF by ID endpoint. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(respon...
[ "Get", "GIFs", "by", "ID", "Endpoint", "A", "multiget", "version", "of", "the", "get", "GIF", "by", "ID", "endpoint", ".", "This", "method", "makes", "a", "synchronous", "HTTP", "request", "by", "default", ".", "To", "make", "an", "asynchronous", "HTTP", ...
train
https://github.com/Giphy/giphy-python-client/blob/e89b67c3bf65e2241f32a74e012ab3462dd2599d/giphy_client/apis/default_api.py#L432-L457
Giphy/giphy-python-client
giphy_client/apis/default_api.py
DefaultApi.gifs_gif_id_get
def gifs_gif_id_get(self, api_key, gif_id, **kwargs): """ Get GIF by ID Endpoint Returns a GIF given that GIF's unique ID This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when ...
python
def gifs_gif_id_get(self, api_key, gif_id, **kwargs): """ Get GIF by ID Endpoint Returns a GIF given that GIF's unique ID This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when ...
[ "def", "gifs_gif_id_get", "(", "self", ",", "api_key", ",", "gif_id", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'callback'", ")", ":", "return", "self", ".", "gifs_gi...
Get GIF by ID Endpoint Returns a GIF given that GIF's unique ID This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): ...
[ "Get", "GIF", "by", "ID", "Endpoint", "Returns", "a", "GIF", "given", "that", "GIF", "s", "unique", "ID", "This", "method", "makes", "a", "synchronous", "HTTP", "request", "by", "default", ".", "To", "make", "an", "asynchronous", "HTTP", "request", "please...
train
https://github.com/Giphy/giphy-python-client/blob/e89b67c3bf65e2241f32a74e012ab3462dd2599d/giphy_client/apis/default_api.py#L546-L571
Giphy/giphy-python-client
giphy_client/apis/default_api.py
DefaultApi.gifs_random_get
def gifs_random_get(self, api_key, **kwargs): """ Random Endpoint Returns a random GIF, limited by tag. Excluding the tag parameter will return a random GIF from the GIPHY catalog. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, plea...
python
def gifs_random_get(self, api_key, **kwargs): """ Random Endpoint Returns a random GIF, limited by tag. Excluding the tag parameter will return a random GIF from the GIPHY catalog. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, plea...
[ "def", "gifs_random_get", "(", "self", ",", "api_key", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'callback'", ")", ":", "return", "self", ".", "gifs_random_get_with_http_...
Random Endpoint Returns a random GIF, limited by tag. Excluding the tag parameter will return a random GIF from the GIPHY catalog. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receivi...
[ "Random", "Endpoint", "Returns", "a", "random", "GIF", "limited", "by", "tag", ".", "Excluding", "the", "tag", "parameter", "will", "return", "a", "random", "GIF", "from", "the", "GIPHY", "catalog", ".", "This", "method", "makes", "a", "synchronous", "HTTP",...
train
https://github.com/Giphy/giphy-python-client/blob/e89b67c3bf65e2241f32a74e012ab3462dd2599d/giphy_client/apis/default_api.py#L660-L687
Giphy/giphy-python-client
giphy_client/apis/default_api.py
DefaultApi.gifs_search_get
def gifs_search_get(self, api_key, q, **kwargs): """ Search Endpoint Search all Giphy GIFs for a word or phrase. Punctuation will be stripped and ignored. Use a plus or url encode for phrases. Example paul+rudd, ryan+gosling or american+psycho. This method makes a synchronous HTTP reques...
python
def gifs_search_get(self, api_key, q, **kwargs): """ Search Endpoint Search all Giphy GIFs for a word or phrase. Punctuation will be stripped and ignored. Use a plus or url encode for phrases. Example paul+rudd, ryan+gosling or american+psycho. This method makes a synchronous HTTP reques...
[ "def", "gifs_search_get", "(", "self", ",", "api_key", ",", "q", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'callback'", ")", ":", "return", "self", ".", "gifs_search_...
Search Endpoint Search all Giphy GIFs for a word or phrase. Punctuation will be stripped and ignored. Use a plus or url encode for phrases. Example paul+rudd, ryan+gosling or american+psycho. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please de...
[ "Search", "Endpoint", "Search", "all", "Giphy", "GIFs", "for", "a", "word", "or", "phrase", ".", "Punctuation", "will", "be", "stripped", "and", "ignored", ".", "Use", "a", "plus", "or", "url", "encode", "for", "phrases", ".", "Example", "paul", "+", "ru...
train
https://github.com/Giphy/giphy-python-client/blob/e89b67c3bf65e2241f32a74e012ab3462dd2599d/giphy_client/apis/default_api.py#L779-L809
Giphy/giphy-python-client
giphy_client/apis/default_api.py
DefaultApi.gifs_translate_get
def gifs_translate_get(self, api_key, s, **kwargs): """ Translate Endpoint The translate API draws on search, but uses the Giphy `special sauce` to handle translating from one vocabulary to another. In this case, words and phrases to GIFs. This method makes a synchronous HTTP request by ...
python
def gifs_translate_get(self, api_key, s, **kwargs): """ Translate Endpoint The translate API draws on search, but uses the Giphy `special sauce` to handle translating from one vocabulary to another. In this case, words and phrases to GIFs. This method makes a synchronous HTTP request by ...
[ "def", "gifs_translate_get", "(", "self", ",", "api_key", ",", "s", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'callback'", ")", ":", "return", "self", ".", "gifs_tran...
Translate Endpoint The translate API draws on search, but uses the Giphy `special sauce` to handle translating from one vocabulary to another. In this case, words and phrases to GIFs. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `...
[ "Translate", "Endpoint", "The", "translate", "API", "draws", "on", "search", "but", "uses", "the", "Giphy", "special", "sauce", "to", "handle", "translating", "from", "one", "vocabulary", "to", "another", ".", "In", "this", "case", "words", "and", "phrases", ...
train
https://github.com/Giphy/giphy-python-client/blob/e89b67c3bf65e2241f32a74e012ab3462dd2599d/giphy_client/apis/default_api.py#L921-L946
Giphy/giphy-python-client
giphy_client/apis/default_api.py
DefaultApi.gifs_trending_get
def gifs_trending_get(self, api_key, **kwargs): """ Trending GIFs Endpoint Fetch GIFs currently trending online. Hand curated by the GIPHY editorial team. The data returned mirrors the GIFs showcased on the <a href = \"http://www.giphy.com\">GIPHY homepage</a>. Returns 25 results by default. ...
python
def gifs_trending_get(self, api_key, **kwargs): """ Trending GIFs Endpoint Fetch GIFs currently trending online. Hand curated by the GIPHY editorial team. The data returned mirrors the GIFs showcased on the <a href = \"http://www.giphy.com\">GIPHY homepage</a>. Returns 25 results by default. ...
[ "def", "gifs_trending_get", "(", "self", ",", "api_key", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'callback'", ")", ":", "return", "self", ".", "gifs_trending_get_with_h...
Trending GIFs Endpoint Fetch GIFs currently trending online. Hand curated by the GIPHY editorial team. The data returned mirrors the GIFs showcased on the <a href = \"http://www.giphy.com\">GIPHY homepage</a>. Returns 25 results by default. This method makes a synchronous HTTP request by default. To mak...
[ "Trending", "GIFs", "Endpoint", "Fetch", "GIFs", "currently", "trending", "online", ".", "Hand", "curated", "by", "the", "GIPHY", "editorial", "team", ".", "The", "data", "returned", "mirrors", "the", "GIFs", "showcased", "on", "the", "<a", "href", "=", "\\"...
train
https://github.com/Giphy/giphy-python-client/blob/e89b67c3bf65e2241f32a74e012ab3462dd2599d/giphy_client/apis/default_api.py#L1035-L1062
Giphy/giphy-python-client
giphy_client/apis/default_api.py
DefaultApi.stickers_random_get
def stickers_random_get(self, api_key, **kwargs): """ Random Sticker Endpoint Returns a random GIF, limited by tag. Excluding the tag parameter will return a random GIF from the GIPHY catalog. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP r...
python
def stickers_random_get(self, api_key, **kwargs): """ Random Sticker Endpoint Returns a random GIF, limited by tag. Excluding the tag parameter will return a random GIF from the GIPHY catalog. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP r...
[ "def", "stickers_random_get", "(", "self", ",", "api_key", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'callback'", ")", ":", "return", "self", ".", "stickers_random_get_wi...
Random Sticker Endpoint Returns a random GIF, limited by tag. Excluding the tag parameter will return a random GIF from the GIPHY catalog. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when...
[ "Random", "Sticker", "Endpoint", "Returns", "a", "random", "GIF", "limited", "by", "tag", ".", "Excluding", "the", "tag", "parameter", "will", "return", "a", "random", "GIF", "from", "the", "GIPHY", "catalog", ".", "This", "method", "makes", "a", "synchronou...
train
https://github.com/Giphy/giphy-python-client/blob/e89b67c3bf65e2241f32a74e012ab3462dd2599d/giphy_client/apis/default_api.py#L1158-L1185
Giphy/giphy-python-client
giphy_client/apis/default_api.py
DefaultApi.stickers_search_get
def stickers_search_get(self, api_key, q, **kwargs): """ Sticker Search Endpoint Replicates the functionality and requirements of the classic GIPHY search, but returns animated stickers rather than GIFs. This method makes a synchronous HTTP request by default. To make an asynchro...
python
def stickers_search_get(self, api_key, q, **kwargs): """ Sticker Search Endpoint Replicates the functionality and requirements of the classic GIPHY search, but returns animated stickers rather than GIFs. This method makes a synchronous HTTP request by default. To make an asynchro...
[ "def", "stickers_search_get", "(", "self", ",", "api_key", ",", "q", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'callback'", ")", ":", "return", "self", ".", "stickers...
Sticker Search Endpoint Replicates the functionality and requirements of the classic GIPHY search, but returns animated stickers rather than GIFs. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invo...
[ "Sticker", "Search", "Endpoint", "Replicates", "the", "functionality", "and", "requirements", "of", "the", "classic", "GIPHY", "search", "but", "returns", "animated", "stickers", "rather", "than", "GIFs", ".", "This", "method", "makes", "a", "synchronous", "HTTP",...
train
https://github.com/Giphy/giphy-python-client/blob/e89b67c3bf65e2241f32a74e012ab3462dd2599d/giphy_client/apis/default_api.py#L1277-L1307
Giphy/giphy-python-client
giphy_client/apis/default_api.py
DefaultApi.stickers_translate_get
def stickers_translate_get(self, api_key, s, **kwargs): """ Sticker Translate Endpoint The translate API draws on search, but uses the Giphy `special sauce` to handle translating from one vocabulary to another. In this case, words and phrases to GIFs. This method makes a synchronous HTTP...
python
def stickers_translate_get(self, api_key, s, **kwargs): """ Sticker Translate Endpoint The translate API draws on search, but uses the Giphy `special sauce` to handle translating from one vocabulary to another. In this case, words and phrases to GIFs. This method makes a synchronous HTTP...
[ "def", "stickers_translate_get", "(", "self", ",", "api_key", ",", "s", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'callback'", ")", ":", "return", "self", ".", "stick...
Sticker Translate Endpoint The translate API draws on search, but uses the Giphy `special sauce` to handle translating from one vocabulary to another. In this case, words and phrases to GIFs. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please de...
[ "Sticker", "Translate", "Endpoint", "The", "translate", "API", "draws", "on", "search", "but", "uses", "the", "Giphy", "special", "sauce", "to", "handle", "translating", "from", "one", "vocabulary", "to", "another", ".", "In", "this", "case", "words", "and", ...
train
https://github.com/Giphy/giphy-python-client/blob/e89b67c3bf65e2241f32a74e012ab3462dd2599d/giphy_client/apis/default_api.py#L1419-L1444
Giphy/giphy-python-client
giphy_client/apis/default_api.py
DefaultApi.stickers_trending_get
def stickers_trending_get(self, api_key, **kwargs): """ Trending Stickers Endpoint Fetch GIFs currently trending online. Hand curated by the GIPHY editorial team. The data returned mirrors the GIFs showcased on the <a href = \"http://www.giphy.com\">GIPHY homepage</a>. Returns 25 results by defa...
python
def stickers_trending_get(self, api_key, **kwargs): """ Trending Stickers Endpoint Fetch GIFs currently trending online. Hand curated by the GIPHY editorial team. The data returned mirrors the GIFs showcased on the <a href = \"http://www.giphy.com\">GIPHY homepage</a>. Returns 25 results by defa...
[ "def", "stickers_trending_get", "(", "self", ",", "api_key", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'callback'", ")", ":", "return", "self", ".", "stickers_trending_ge...
Trending Stickers Endpoint Fetch GIFs currently trending online. Hand curated by the GIPHY editorial team. The data returned mirrors the GIFs showcased on the <a href = \"http://www.giphy.com\">GIPHY homepage</a>. Returns 25 results by default. This method makes a synchronous HTTP request by default. To...
[ "Trending", "Stickers", "Endpoint", "Fetch", "GIFs", "currently", "trending", "online", ".", "Hand", "curated", "by", "the", "GIPHY", "editorial", "team", ".", "The", "data", "returned", "mirrors", "the", "GIFs", "showcased", "on", "the", "<a", "href", "=", ...
train
https://github.com/Giphy/giphy-python-client/blob/e89b67c3bf65e2241f32a74e012ab3462dd2599d/giphy_client/apis/default_api.py#L1533-L1560
Giphy/giphy-python-client
giphy_client/api_client.py
ApiClient.call_api
def call_api(self, resource_path, method, path_params=None, query_params=None, header_params=None, body=None, post_params=None, files=None, response_type=None, auth_settings=None, callback=None, _return_http_data_only=None, collection_formats=None, _pr...
python
def call_api(self, resource_path, method, path_params=None, query_params=None, header_params=None, body=None, post_params=None, files=None, response_type=None, auth_settings=None, callback=None, _return_http_data_only=None, collection_formats=None, _pr...
[ "def", "call_api", "(", "self", ",", "resource_path", ",", "method", ",", "path_params", "=", "None", ",", "query_params", "=", "None", ",", "header_params", "=", "None", ",", "body", "=", "None", ",", "post_params", "=", "None", ",", "files", "=", "None...
Makes the HTTP request (synchronous) and return the deserialized data. To make an async request, define a function for callback. :param resource_path: Path to method endpoint. :param method: Method to call. :param path_params: Path parameters in the url. :param query_params: Que...
[ "Makes", "the", "HTTP", "request", "(", "synchronous", ")", "and", "return", "the", "deserialized", "data", ".", "To", "make", "an", "async", "request", "define", "a", "function", "for", "callback", "." ]
train
https://github.com/Giphy/giphy-python-client/blob/e89b67c3bf65e2241f32a74e012ab3462dd2599d/giphy_client/api_client.py#L285-L341
Giphy/giphy-python-client
giphy_client/api_client.py
ApiClient.update_params_for_auth
def update_params_for_auth(self, headers, querys, auth_settings): """ Updates header and query params based on authentication setting. :param headers: Header parameters dict to be updated. :param querys: Query parameters tuple list to be updated. :param auth_settings: Authentica...
python
def update_params_for_auth(self, headers, querys, auth_settings): """ Updates header and query params based on authentication setting. :param headers: Header parameters dict to be updated. :param querys: Query parameters tuple list to be updated. :param auth_settings: Authentica...
[ "def", "update_params_for_auth", "(", "self", ",", "headers", ",", "querys", ",", "auth_settings", ")", ":", "config", "=", "Configuration", "(", ")", "if", "not", "auth_settings", ":", "return", "for", "auth", "in", "auth_settings", ":", "auth_setting", "=", ...
Updates header and query params based on authentication setting. :param headers: Header parameters dict to be updated. :param querys: Query parameters tuple list to be updated. :param auth_settings: Authentication setting identifiers list.
[ "Updates", "header", "and", "query", "params", "based", "on", "authentication", "setting", "." ]
train
https://github.com/Giphy/giphy-python-client/blob/e89b67c3bf65e2241f32a74e012ab3462dd2599d/giphy_client/api_client.py#L498-L523
ajbosco/dag-factory
dagfactory/dagbuilder.py
DagBuilder.get_dag_params
def get_dag_params(self) -> Dict[str, Any]: """ Merges default config with dag config, sets dag_id, and extropolates dag_start_date :returns: dict of dag parameters """ try: dag_params: Dict[str, Any] = utils.merge_configs(self.dag_config, self.default_config) ...
python
def get_dag_params(self) -> Dict[str, Any]: """ Merges default config with dag config, sets dag_id, and extropolates dag_start_date :returns: dict of dag parameters """ try: dag_params: Dict[str, Any] = utils.merge_configs(self.dag_config, self.default_config) ...
[ "def", "get_dag_params", "(", "self", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "try", ":", "dag_params", ":", "Dict", "[", "str", ",", "Any", "]", "=", "utils", ".", "merge_configs", "(", "self", ".", "dag_config", ",", "self", ".", "de...
Merges default config with dag config, sets dag_id, and extropolates dag_start_date :returns: dict of dag parameters
[ "Merges", "default", "config", "with", "dag", "config", "sets", "dag_id", "and", "extropolates", "dag_start_date" ]
train
https://github.com/ajbosco/dag-factory/blob/cc7cfe74e62f82859fe38d527e95311a2805723b/dagfactory/dagbuilder.py#L24-L43
ajbosco/dag-factory
dagfactory/dagbuilder.py
DagBuilder.make_task
def make_task(operator: str, task_params: Dict[str, Any]) -> BaseOperator: """ Takes an operator and params and creates an instance of that operator. :returns: instance of operator object """ try: # class is a Callable https://stackoverflow.com/a/34578836/3679900 ...
python
def make_task(operator: str, task_params: Dict[str, Any]) -> BaseOperator: """ Takes an operator and params and creates an instance of that operator. :returns: instance of operator object """ try: # class is a Callable https://stackoverflow.com/a/34578836/3679900 ...
[ "def", "make_task", "(", "operator", ":", "str", ",", "task_params", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "BaseOperator", ":", "try", ":", "# class is a Callable https://stackoverflow.com/a/34578836/3679900", "operator_obj", ":", "Callable", "[", "...
Takes an operator and params and creates an instance of that operator. :returns: instance of operator object
[ "Takes", "an", "operator", "and", "params", "and", "creates", "an", "instance", "of", "that", "operator", "." ]
train
https://github.com/ajbosco/dag-factory/blob/cc7cfe74e62f82859fe38d527e95311a2805723b/dagfactory/dagbuilder.py#L46-L61
ajbosco/dag-factory
dagfactory/dagbuilder.py
DagBuilder.build
def build(self) -> Dict[str, Union[str, DAG]]: """ Generates a DAG from the DAG parameters. :returns: dict with dag_id and DAG object :type: Dict[str, Union[str, DAG]] """ dag_params: Dict[str, Any] = self.get_dag_params() dag: DAG = DAG( dag_id=dag_p...
python
def build(self) -> Dict[str, Union[str, DAG]]: """ Generates a DAG from the DAG parameters. :returns: dict with dag_id and DAG object :type: Dict[str, Union[str, DAG]] """ dag_params: Dict[str, Any] = self.get_dag_params() dag: DAG = DAG( dag_id=dag_p...
[ "def", "build", "(", "self", ")", "->", "Dict", "[", "str", ",", "Union", "[", "str", ",", "DAG", "]", "]", ":", "dag_params", ":", "Dict", "[", "str", ",", "Any", "]", "=", "self", ".", "get_dag_params", "(", ")", "dag", ":", "DAG", "=", "DAG"...
Generates a DAG from the DAG parameters. :returns: dict with dag_id and DAG object :type: Dict[str, Union[str, DAG]]
[ "Generates", "a", "DAG", "from", "the", "DAG", "parameters", "." ]
train
https://github.com/ajbosco/dag-factory/blob/cc7cfe74e62f82859fe38d527e95311a2805723b/dagfactory/dagbuilder.py#L63-L101
ajbosco/dag-factory
dagfactory/utils.py
get_start_date
def get_start_date(date_value: Union[str, datetime, date], timezone: str = "UTC") -> datetime: """ Takes value from DAG config and generates valid start_date. Defaults to today, if not a valid date or relative time (1 hours, 1 days, etc.) :param date_value: either a datetime (or date) or a relative tim...
python
def get_start_date(date_value: Union[str, datetime, date], timezone: str = "UTC") -> datetime: """ Takes value from DAG config and generates valid start_date. Defaults to today, if not a valid date or relative time (1 hours, 1 days, etc.) :param date_value: either a datetime (or date) or a relative tim...
[ "def", "get_start_date", "(", "date_value", ":", "Union", "[", "str", ",", "datetime", ",", "date", "]", ",", "timezone", ":", "str", "=", "\"UTC\"", ")", "->", "datetime", ":", "try", ":", "local_tz", ":", "pendulum", ".", "Timezone", "=", "pendulum", ...
Takes value from DAG config and generates valid start_date. Defaults to today, if not a valid date or relative time (1 hours, 1 days, etc.) :param date_value: either a datetime (or date) or a relative time as string :type date_value: Uniont[datetime, date, str] :param timezone: string value representin...
[ "Takes", "value", "from", "DAG", "config", "and", "generates", "valid", "start_date", ".", "Defaults", "to", "today", "if", "not", "a", "valid", "date", "or", "relative", "time", "(", "1", "hours", "1", "days", "etc", ".", ")" ]
train
https://github.com/ajbosco/dag-factory/blob/cc7cfe74e62f82859fe38d527e95311a2805723b/dagfactory/utils.py#L8-L36
ajbosco/dag-factory
dagfactory/utils.py
get_time_delta
def get_time_delta(time_string: str) -> timedelta: """ Takes a time string (1 hours, 10 days, etc.) and returns a python timedelta object :param time_string: the time value to convert to a timedelta :type time_string: str :returns: datetime.timedelta for relative time :type datetime.timedel...
python
def get_time_delta(time_string: str) -> timedelta: """ Takes a time string (1 hours, 10 days, etc.) and returns a python timedelta object :param time_string: the time value to convert to a timedelta :type time_string: str :returns: datetime.timedelta for relative time :type datetime.timedel...
[ "def", "get_time_delta", "(", "time_string", ":", "str", ")", "->", "timedelta", ":", "rel_time", ":", "Pattern", "=", "re", ".", "compile", "(", "pattern", "=", "r\"((?P<hours>\\d+?)\\s+hour)?((?P<minutes>\\d+?)\\s+minute)?((?P<seconds>\\d+?)\\s+second)?((?P<days>\\d+?)\\s+d...
Takes a time string (1 hours, 10 days, etc.) and returns a python timedelta object :param time_string: the time value to convert to a timedelta :type time_string: str :returns: datetime.timedelta for relative time :type datetime.timedelta
[ "Takes", "a", "time", "string", "(", "1", "hours", "10", "days", "etc", ".", ")", "and", "returns", "a", "python", "timedelta", "object" ]
train
https://github.com/ajbosco/dag-factory/blob/cc7cfe74e62f82859fe38d527e95311a2805723b/dagfactory/utils.py#L39-L65