partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
PasswordChangeSerializer.update
Check the old password is valid and set the new password.
user_management/api/serializers.py
def update(self, instance, validated_data): """Check the old password is valid and set the new password.""" if not instance.check_password(validated_data['old_password']): msg = _('Invalid password.') raise serializers.ValidationError({'old_password': msg}) instance.set_...
def update(self, instance, validated_data): """Check the old password is valid and set the new password.""" if not instance.check_password(validated_data['old_password']): msg = _('Invalid password.') raise serializers.ValidationError({'old_password': msg}) instance.set_...
[ "Check", "the", "old", "password", "is", "valid", "and", "set", "the", "new", "password", "." ]
incuna/django-user-management
python
https://github.com/incuna/django-user-management/blob/6784e33191d4eff624d2cf2df9ca01db4f23c9c6/user_management/api/serializers.py#L96-L104
[ "def", "update", "(", "self", ",", "instance", ",", "validated_data", ")", ":", "if", "not", "instance", ".", "check_password", "(", "validated_data", "[", "'old_password'", "]", ")", ":", "msg", "=", "_", "(", "'Invalid password.'", ")", "raise", "serialize...
6784e33191d4eff624d2cf2df9ca01db4f23c9c6
test
PasswordResetSerializer.update
Set the new password for the user.
user_management/api/serializers.py
def update(self, instance, validated_data): """Set the new password for the user.""" instance.set_password(validated_data['new_password']) instance.save() return instance
def update(self, instance, validated_data): """Set the new password for the user.""" instance.set_password(validated_data['new_password']) instance.save() return instance
[ "Set", "the", "new", "password", "for", "the", "user", "." ]
incuna/django-user-management
python
https://github.com/incuna/django-user-management/blob/6784e33191d4eff624d2cf2df9ca01db4f23c9c6/user_management/api/serializers.py#L133-L137
[ "def", "update", "(", "self", ",", "instance", ",", "validated_data", ")", ":", "instance", ".", "set_password", "(", "validated_data", "[", "'new_password'", "]", ")", "instance", ".", "save", "(", ")", "return", "instance" ]
6784e33191d4eff624d2cf2df9ca01db4f23c9c6
test
ResendConfirmationEmailSerializer.validate_email
Validate if email exists and requires a verification. `validate_email` will set a `user` attribute on the instance allowing the view to send an email confirmation.
user_management/api/serializers.py
def validate_email(self, email): """ Validate if email exists and requires a verification. `validate_email` will set a `user` attribute on the instance allowing the view to send an email confirmation. """ try: self.user = User.objects.get_by_natural_key(email...
def validate_email(self, email): """ Validate if email exists and requires a verification. `validate_email` will set a `user` attribute on the instance allowing the view to send an email confirmation. """ try: self.user = User.objects.get_by_natural_key(email...
[ "Validate", "if", "email", "exists", "and", "requires", "a", "verification", "." ]
incuna/django-user-management
python
https://github.com/incuna/django-user-management/blob/6784e33191d4eff624d2cf2df9ca01db4f23c9c6/user_management/api/serializers.py#L159-L175
[ "def", "validate_email", "(", "self", ",", "email", ")", ":", "try", ":", "self", ".", "user", "=", "User", ".", "objects", ".", "get_by_natural_key", "(", "email", ")", "except", "User", ".", "DoesNotExist", ":", "msg", "=", "_", "(", "'A user with this...
6784e33191d4eff624d2cf2df9ca01db4f23c9c6
test
GetAuthToken.post
Create auth token. Differs from DRF that it always creates new token but not re-using them.
user_management/api/views.py
def post(self, request): """Create auth token. Differs from DRF that it always creates new token but not re-using them.""" serializer = self.serializer_class(data=request.data) if serializer.is_valid(): user = serializer.validated_data['user'] signals.user_logged_...
def post(self, request): """Create auth token. Differs from DRF that it always creates new token but not re-using them.""" serializer = self.serializer_class(data=request.data) if serializer.is_valid(): user = serializer.validated_data['user'] signals.user_logged_...
[ "Create", "auth", "token", ".", "Differs", "from", "DRF", "that", "it", "always", "creates", "new", "token", "but", "not", "re", "-", "using", "them", "." ]
incuna/django-user-management
python
https://github.com/incuna/django-user-management/blob/6784e33191d4eff624d2cf2df9ca01db4f23c9c6/user_management/api/views.py#L35-L47
[ "def", "post", "(", "self", ",", "request", ")", ":", "serializer", "=", "self", ".", "serializer_class", "(", "data", "=", "request", ".", "data", ")", "if", "serializer", ".", "is_valid", "(", ")", ":", "user", "=", "serializer", ".", "validated_data",...
6784e33191d4eff624d2cf2df9ca01db4f23c9c6
test
GetAuthToken.delete
Delete auth token when `delete` request was issued.
user_management/api/views.py
def delete(self, request, *args, **kwargs): """Delete auth token when `delete` request was issued.""" # Logic repeated from DRF because one cannot easily reuse it auth = get_authorization_header(request).split() if not auth or auth[0].lower() != b'token': return response.Res...
def delete(self, request, *args, **kwargs): """Delete auth token when `delete` request was issued.""" # Logic repeated from DRF because one cannot easily reuse it auth = get_authorization_header(request).split() if not auth or auth[0].lower() != b'token': return response.Res...
[ "Delete", "auth", "token", "when", "delete", "request", "was", "issued", "." ]
incuna/django-user-management
python
https://github.com/incuna/django-user-management/blob/6784e33191d4eff624d2cf2df9ca01db4f23c9c6/user_management/api/views.py#L49-L75
[ "def", "delete", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Logic repeated from DRF because one cannot easily reuse it", "auth", "=", "get_authorization_header", "(", "request", ")", ".", "split", "(", ")", "if", "not", ...
6784e33191d4eff624d2cf2df9ca01db4f23c9c6
test
ResendConfirmationEmail.initial
Disallow users other than the user whose email is being reset.
user_management/api/views.py
def initial(self, request, *args, **kwargs): """Disallow users other than the user whose email is being reset.""" email = request.data.get('email') if request.user.is_authenticated() and email != request.user.email: raise PermissionDenied() return super(ResendConfirmationEma...
def initial(self, request, *args, **kwargs): """Disallow users other than the user whose email is being reset.""" email = request.data.get('email') if request.user.is_authenticated() and email != request.user.email: raise PermissionDenied() return super(ResendConfirmationEma...
[ "Disallow", "users", "other", "than", "the", "user", "whose", "email", "is", "being", "reset", "." ]
incuna/django-user-management
python
https://github.com/incuna/django-user-management/blob/6784e33191d4eff624d2cf2df9ca01db4f23c9c6/user_management/api/views.py#L277-L287
[ "def", "initial", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "email", "=", "request", ".", "data", ".", "get", "(", "'email'", ")", "if", "request", ".", "user", ".", "is_authenticated", "(", ")", "and", "emai...
6784e33191d4eff624d2cf2df9ca01db4f23c9c6
test
ResendConfirmationEmail.post
Validate `email` and send a request to confirm it.
user_management/api/views.py
def post(self, request, *args, **kwargs): """Validate `email` and send a request to confirm it.""" serializer = self.serializer_class(data=request.data) if not serializer.is_valid(): return response.Response( serializer.errors, status=status.HTTP_400_...
def post(self, request, *args, **kwargs): """Validate `email` and send a request to confirm it.""" serializer = self.serializer_class(data=request.data) if not serializer.is_valid(): return response.Response( serializer.errors, status=status.HTTP_400_...
[ "Validate", "email", "and", "send", "a", "request", "to", "confirm", "it", "." ]
incuna/django-user-management
python
https://github.com/incuna/django-user-management/blob/6784e33191d4eff624d2cf2df9ca01db4f23c9c6/user_management/api/views.py#L289-L301
[ "def", "post", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "serializer", "=", "self", ".", "serializer_class", "(", "data", "=", "request", ".", "data", ")", "if", "not", "serializer", ".", "is_valid", "(", ")", ...
6784e33191d4eff624d2cf2df9ca01db4f23c9c6
test
UserCreationForm.clean_email
Since User.email is unique, this check is redundant, but it sets a nicer error message than the ORM. See #13147.
user_management/models/admin_forms.py
def clean_email(self): """ Since User.email is unique, this check is redundant, but it sets a nicer error message than the ORM. See #13147. """ email = self.cleaned_data['email'] try: User._default_manager.get(email__iexact=email) except User.DoesNotEx...
def clean_email(self): """ Since User.email is unique, this check is redundant, but it sets a nicer error message than the ORM. See #13147. """ email = self.cleaned_data['email'] try: User._default_manager.get(email__iexact=email) except User.DoesNotEx...
[ "Since", "User", ".", "email", "is", "unique", "this", "check", "is", "redundant", "but", "it", "sets", "a", "nicer", "error", "message", "than", "the", "ORM", ".", "See", "#13147", "." ]
incuna/django-user-management
python
https://github.com/incuna/django-user-management/blob/6784e33191d4eff624d2cf2df9ca01db4f23c9c6/user_management/models/admin_forms.py#L33-L43
[ "def", "clean_email", "(", "self", ")", ":", "email", "=", "self", ".", "cleaned_data", "[", "'email'", "]", "try", ":", "User", ".", "_default_manager", ".", "get", "(", "email__iexact", "=", "email", ")", "except", "User", ".", "DoesNotExist", ":", "re...
6784e33191d4eff624d2cf2df9ca01db4f23c9c6
test
AuthToken.update_expiry
Update token's expiration datetime on every auth action.
user_management/api/models.py
def update_expiry(self, commit=True): """Update token's expiration datetime on every auth action.""" self.expires = update_expiry(self.created) if commit: self.save()
def update_expiry(self, commit=True): """Update token's expiration datetime on every auth action.""" self.expires = update_expiry(self.created) if commit: self.save()
[ "Update", "token", "s", "expiration", "datetime", "on", "every", "auth", "action", "." ]
incuna/django-user-management
python
https://github.com/incuna/django-user-management/blob/6784e33191d4eff624d2cf2df9ca01db4f23c9c6/user_management/api/models.py#L68-L72
[ "def", "update_expiry", "(", "self", ",", "commit", "=", "True", ")", ":", "self", ".", "expires", "=", "update_expiry", "(", "self", ".", "created", ")", "if", "commit", ":", "self", ".", "save", "(", ")" ]
6784e33191d4eff624d2cf2df9ca01db4f23c9c6
test
password_reset_email_context
Email context to reset a user password.
user_management/utils/notifications.py
def password_reset_email_context(notification): """Email context to reset a user password.""" return { 'protocol': 'https', 'uid': notification.user.generate_uid(), 'token': notification.user.generate_token(), 'site': notification.site, }
def password_reset_email_context(notification): """Email context to reset a user password.""" return { 'protocol': 'https', 'uid': notification.user.generate_uid(), 'token': notification.user.generate_token(), 'site': notification.site, }
[ "Email", "context", "to", "reset", "a", "user", "password", "." ]
incuna/django-user-management
python
https://github.com/incuna/django-user-management/blob/6784e33191d4eff624d2cf2df9ca01db4f23c9c6/user_management/utils/notifications.py#L7-L14
[ "def", "password_reset_email_context", "(", "notification", ")", ":", "return", "{", "'protocol'", ":", "'https'", ",", "'uid'", ":", "notification", ".", "user", ".", "generate_uid", "(", ")", ",", "'token'", ":", "notification", ".", "user", ".", "generate_t...
6784e33191d4eff624d2cf2df9ca01db4f23c9c6
test
email_handler
Send a notification by email.
user_management/utils/notifications.py
def email_handler(notification, email_context): """Send a notification by email.""" incuna_mail.send( to=notification.user.email, subject=notification.email_subject, template_name=notification.text_email_template, html_template_name=notification.html_email_template, conte...
def email_handler(notification, email_context): """Send a notification by email.""" incuna_mail.send( to=notification.user.email, subject=notification.email_subject, template_name=notification.text_email_template, html_template_name=notification.html_email_template, conte...
[ "Send", "a", "notification", "by", "email", "." ]
incuna/django-user-management
python
https://github.com/incuna/django-user-management/blob/6784e33191d4eff624d2cf2df9ca01db4f23c9c6/user_management/utils/notifications.py#L26-L35
[ "def", "email_handler", "(", "notification", ",", "email_context", ")", ":", "incuna_mail", ".", "send", "(", "to", "=", "notification", ".", "user", ".", "email", ",", "subject", "=", "notification", ".", "email_subject", ",", "template_name", "=", "notificat...
6784e33191d4eff624d2cf2df9ca01db4f23c9c6
test
password_reset_email_handler
Password reset email handler.
user_management/utils/notifications.py
def password_reset_email_handler(notification): """Password reset email handler.""" base_subject = _('{domain} password reset').format(domain=notification.site.domain) subject = getattr(settings, 'DUM_PASSWORD_RESET_SUBJECT', base_subject) notification.email_subject = subject email_handler(notificat...
def password_reset_email_handler(notification): """Password reset email handler.""" base_subject = _('{domain} password reset').format(domain=notification.site.domain) subject = getattr(settings, 'DUM_PASSWORD_RESET_SUBJECT', base_subject) notification.email_subject = subject email_handler(notificat...
[ "Password", "reset", "email", "handler", "." ]
incuna/django-user-management
python
https://github.com/incuna/django-user-management/blob/6784e33191d4eff624d2cf2df9ca01db4f23c9c6/user_management/utils/notifications.py#L38-L43
[ "def", "password_reset_email_handler", "(", "notification", ")", ":", "base_subject", "=", "_", "(", "'{domain} password reset'", ")", ".", "format", "(", "domain", "=", "notification", ".", "site", ".", "domain", ")", "subject", "=", "getattr", "(", "settings",...
6784e33191d4eff624d2cf2df9ca01db4f23c9c6
test
validation_email_handler
Validation email handler.
user_management/utils/notifications.py
def validation_email_handler(notification): """Validation email handler.""" base_subject = _('{domain} account validate').format(domain=notification.site.domain) subject = getattr(settings, 'DUM_VALIDATE_EMAIL_SUBJECT', base_subject) notification.email_subject = subject email_handler(notification, v...
def validation_email_handler(notification): """Validation email handler.""" base_subject = _('{domain} account validate').format(domain=notification.site.domain) subject = getattr(settings, 'DUM_VALIDATE_EMAIL_SUBJECT', base_subject) notification.email_subject = subject email_handler(notification, v...
[ "Validation", "email", "handler", "." ]
incuna/django-user-management
python
https://github.com/incuna/django-user-management/blob/6784e33191d4eff624d2cf2df9ca01db4f23c9c6/user_management/utils/notifications.py#L46-L51
[ "def", "validation_email_handler", "(", "notification", ")", ":", "base_subject", "=", "_", "(", "'{domain} account validate'", ")", ".", "format", "(", "domain", "=", "notification", ".", "site", ".", "domain", ")", "subject", "=", "getattr", "(", "settings", ...
6784e33191d4eff624d2cf2df9ca01db4f23c9c6
test
FormTokenAuthentication.authenticate
Authenticate a user from a token form field Errors thrown here will be swallowed by django-rest-framework, and it expects us to return None if authentication fails.
user_management/api/authentication.py
def authenticate(self, request): """ Authenticate a user from a token form field Errors thrown here will be swallowed by django-rest-framework, and it expects us to return None if authentication fails. """ try: key = request.data['token'] except KeyEr...
def authenticate(self, request): """ Authenticate a user from a token form field Errors thrown here will be swallowed by django-rest-framework, and it expects us to return None if authentication fails. """ try: key = request.data['token'] except KeyEr...
[ "Authenticate", "a", "user", "from", "a", "token", "form", "field" ]
incuna/django-user-management
python
https://github.com/incuna/django-user-management/blob/6784e33191d4eff624d2cf2df9ca01db4f23c9c6/user_management/api/authentication.py#L10-L27
[ "def", "authenticate", "(", "self", ",", "request", ")", ":", "try", ":", "key", "=", "request", ".", "data", "[", "'token'", "]", "except", "KeyError", ":", "return", "try", ":", "token", "=", "AuthToken", ".", "objects", ".", "get", "(", "key", "="...
6784e33191d4eff624d2cf2df9ca01db4f23c9c6
test
TokenAuthentication.authenticate_credentials
Custom authentication to check if auth token has expired.
user_management/api/authentication.py
def authenticate_credentials(self, key): """Custom authentication to check if auth token has expired.""" user, token = super(TokenAuthentication, self).authenticate_credentials(key) if token.expires < timezone.now(): msg = _('Token has expired.') raise exceptions.Authent...
def authenticate_credentials(self, key): """Custom authentication to check if auth token has expired.""" user, token = super(TokenAuthentication, self).authenticate_credentials(key) if token.expires < timezone.now(): msg = _('Token has expired.') raise exceptions.Authent...
[ "Custom", "authentication", "to", "check", "if", "auth", "token", "has", "expired", "." ]
incuna/django-user-management
python
https://github.com/incuna/django-user-management/blob/6784e33191d4eff624d2cf2df9ca01db4f23c9c6/user_management/api/authentication.py#L33-L44
[ "def", "authenticate_credentials", "(", "self", ",", "key", ")", ":", "user", ",", "token", "=", "super", "(", "TokenAuthentication", ",", "self", ")", ".", "authenticate_credentials", "(", "key", ")", "if", "token", ".", "expires", "<", "timezone", ".", "...
6784e33191d4eff624d2cf2df9ca01db4f23c9c6
test
notebook_show
Displays bokeh output inside a notebook.
parambokeh/__init__.py
def notebook_show(obj, doc, comm): """ Displays bokeh output inside a notebook. """ target = obj.ref['id'] load_mime = 'application/vnd.holoviews_load.v0+json' exec_mime = 'application/vnd.holoviews_exec.v0+json' # Publish plot HTML bokeh_script, bokeh_div, _ = bokeh.embed.notebook.note...
def notebook_show(obj, doc, comm): """ Displays bokeh output inside a notebook. """ target = obj.ref['id'] load_mime = 'application/vnd.holoviews_load.v0+json' exec_mime = 'application/vnd.holoviews_exec.v0+json' # Publish plot HTML bokeh_script, bokeh_div, _ = bokeh.embed.notebook.note...
[ "Displays", "bokeh", "output", "inside", "a", "notebook", "." ]
ioam/parambokeh
python
https://github.com/ioam/parambokeh/blob/fb9744f216273c7b24e65d037b1d621c08d7fde6/parambokeh/__init__.py#L53-L77
[ "def", "notebook_show", "(", "obj", ",", "doc", ",", "comm", ")", ":", "target", "=", "obj", ".", "ref", "[", "'id'", "]", "load_mime", "=", "'application/vnd.holoviews_load.v0+json'", "exec_mime", "=", "'application/vnd.holoviews_exec.v0+json'", "# Publish plot HTML"...
fb9744f216273c7b24e65d037b1d621c08d7fde6
test
process_hv_plots
Temporary fix to patch HoloViews plot comms
parambokeh/__init__.py
def process_hv_plots(widgets, plots): """ Temporary fix to patch HoloViews plot comms """ bokeh_plots = [] for plot in plots: if hasattr(plot, '_update_callbacks'): for subplot in plot.traverse(lambda x: x): subplot.comm = widgets.server_comm for c...
def process_hv_plots(widgets, plots): """ Temporary fix to patch HoloViews plot comms """ bokeh_plots = [] for plot in plots: if hasattr(plot, '_update_callbacks'): for subplot in plot.traverse(lambda x: x): subplot.comm = widgets.server_comm for c...
[ "Temporary", "fix", "to", "patch", "HoloViews", "plot", "comms" ]
ioam/parambokeh
python
https://github.com/ioam/parambokeh/blob/fb9744f216273c7b24e65d037b1d621c08d7fde6/parambokeh/__init__.py#L80-L94
[ "def", "process_hv_plots", "(", "widgets", ",", "plots", ")", ":", "bokeh_plots", "=", "[", "]", "for", "plot", "in", "plots", ":", "if", "hasattr", "(", "plot", ",", "'_update_callbacks'", ")", ":", "for", "subplot", "in", "plot", ".", "traverse", "(", ...
fb9744f216273c7b24e65d037b1d621c08d7fde6
test
Widgets._get_customjs
Returns a CustomJS callback that can be attached to send the widget state across the notebook comms.
parambokeh/__init__.py
def _get_customjs(self, change, p_name): """ Returns a CustomJS callback that can be attached to send the widget state across the notebook comms. """ data_template = "data = {{p_name: '{p_name}', value: cb_obj['{change}']}};" fetch_data = data_template.format(change=chang...
def _get_customjs(self, change, p_name): """ Returns a CustomJS callback that can be attached to send the widget state across the notebook comms. """ data_template = "data = {{p_name: '{p_name}', value: cb_obj['{change}']}};" fetch_data = data_template.format(change=chang...
[ "Returns", "a", "CustomJS", "callback", "that", "can", "be", "attached", "to", "send", "the", "widget", "state", "across", "the", "notebook", "comms", "." ]
ioam/parambokeh
python
https://github.com/ioam/parambokeh/blob/fb9744f216273c7b24e65d037b1d621c08d7fde6/parambokeh/__init__.py#L442-L455
[ "def", "_get_customjs", "(", "self", ",", "change", ",", "p_name", ")", ":", "data_template", "=", "\"data = {{p_name: '{p_name}', value: cb_obj['{change}']}};\"", "fetch_data", "=", "data_template", ".", "format", "(", "change", "=", "change", ",", "p_name", "=", "...
fb9744f216273c7b24e65d037b1d621c08d7fde6
test
Widgets.widget
Get widget for param_name
parambokeh/__init__.py
def widget(self, param_name): """Get widget for param_name""" if param_name not in self._widgets: self._widgets[param_name] = self._make_widget(param_name) return self._widgets[param_name]
def widget(self, param_name): """Get widget for param_name""" if param_name not in self._widgets: self._widgets[param_name] = self._make_widget(param_name) return self._widgets[param_name]
[ "Get", "widget", "for", "param_name" ]
ioam/parambokeh
python
https://github.com/ioam/parambokeh/blob/fb9744f216273c7b24e65d037b1d621c08d7fde6/parambokeh/__init__.py#L458-L462
[ "def", "widget", "(", "self", ",", "param_name", ")", ":", "if", "param_name", "not", "in", "self", ".", "_widgets", ":", "self", ".", "_widgets", "[", "param_name", "]", "=", "self", ".", "_make_widget", "(", "param_name", ")", "return", "self", ".", ...
fb9744f216273c7b24e65d037b1d621c08d7fde6
test
Widgets.widgets
Return name,widget boxes for all parameters (i.e., a property sheet)
parambokeh/__init__.py
def widgets(self): """Return name,widget boxes for all parameters (i.e., a property sheet)""" params = self.parameterized.params().items() key_fn = lambda x: x[1].precedence if x[1].precedence is not None else self.p.default_precedence sorted_precedence = sorted(params, key=key_fn) ...
def widgets(self): """Return name,widget boxes for all parameters (i.e., a property sheet)""" params = self.parameterized.params().items() key_fn = lambda x: x[1].precedence if x[1].precedence is not None else self.p.default_precedence sorted_precedence = sorted(params, key=key_fn) ...
[ "Return", "name", "widget", "boxes", "for", "all", "parameters", "(", "i", ".", "e", ".", "a", "property", "sheet", ")" ]
ioam/parambokeh
python
https://github.com/ioam/parambokeh/blob/fb9744f216273c7b24e65d037b1d621c08d7fde6/parambokeh/__init__.py#L472-L515
[ "def", "widgets", "(", "self", ")", ":", "params", "=", "self", ".", "parameterized", ".", "params", "(", ")", ".", "items", "(", ")", "key_fn", "=", "lambda", "x", ":", "x", "[", "1", "]", ".", "precedence", "if", "x", "[", "1", "]", ".", "pre...
fb9744f216273c7b24e65d037b1d621c08d7fde6
test
render_function
The default Renderer function which handles HoloViews objects.
parambokeh/view.py
def render_function(obj, view): """ The default Renderer function which handles HoloViews objects. """ try: import holoviews as hv except: hv = None if hv and isinstance(obj, hv.core.Dimensioned): renderer = hv.renderer('bokeh') if not view._notebook: ...
def render_function(obj, view): """ The default Renderer function which handles HoloViews objects. """ try: import holoviews as hv except: hv = None if hv and isinstance(obj, hv.core.Dimensioned): renderer = hv.renderer('bokeh') if not view._notebook: ...
[ "The", "default", "Renderer", "function", "which", "handles", "HoloViews", "objects", "." ]
ioam/parambokeh
python
https://github.com/ioam/parambokeh/blob/fb9744f216273c7b24e65d037b1d621c08d7fde6/parambokeh/view.py#L3-L21
[ "def", "render_function", "(", "obj", ",", "view", ")", ":", "try", ":", "import", "holoviews", "as", "hv", "except", ":", "hv", "=", "None", "if", "hv", "and", "isinstance", "(", "obj", ",", "hv", ".", "core", ".", "Dimensioned", ")", ":", "renderer...
fb9744f216273c7b24e65d037b1d621c08d7fde6
test
TextWidget
Forces a parameter value to be text
parambokeh/widgets.py
def TextWidget(*args, **kw): """Forces a parameter value to be text""" kw['value'] = str(kw['value']) kw.pop('options', None) return TextInput(*args,**kw)
def TextWidget(*args, **kw): """Forces a parameter value to be text""" kw['value'] = str(kw['value']) kw.pop('options', None) return TextInput(*args,**kw)
[ "Forces", "a", "parameter", "value", "to", "be", "text" ]
ioam/parambokeh
python
https://github.com/ioam/parambokeh/blob/fb9744f216273c7b24e65d037b1d621c08d7fde6/parambokeh/widgets.py#L16-L20
[ "def", "TextWidget", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "kw", "[", "'value'", "]", "=", "str", "(", "kw", "[", "'value'", "]", ")", "kw", ".", "pop", "(", "'options'", ",", "None", ")", "return", "TextInput", "(", "*", "args", ","...
fb9744f216273c7b24e65d037b1d621c08d7fde6
test
named_objs
Given a list of objects, returns a dictionary mapping from string name for the object to the object itself.
parambokeh/util.py
def named_objs(objlist): """ Given a list of objects, returns a dictionary mapping from string name for the object to the object itself. """ objs = [] for k, obj in objlist: if hasattr(k, '__name__'): k = k.__name__ else: k = as_unicode(k) objs.app...
def named_objs(objlist): """ Given a list of objects, returns a dictionary mapping from string name for the object to the object itself. """ objs = [] for k, obj in objlist: if hasattr(k, '__name__'): k = k.__name__ else: k = as_unicode(k) objs.app...
[ "Given", "a", "list", "of", "objects", "returns", "a", "dictionary", "mapping", "from", "string", "name", "for", "the", "object", "to", "the", "object", "itself", "." ]
ioam/parambokeh
python
https://github.com/ioam/parambokeh/blob/fb9744f216273c7b24e65d037b1d621c08d7fde6/parambokeh/util.py#L19-L31
[ "def", "named_objs", "(", "objlist", ")", ":", "objs", "=", "[", "]", "for", "k", ",", "obj", "in", "objlist", ":", "if", "hasattr", "(", "k", ",", "'__name__'", ")", ":", "k", "=", "k", ".", "__name__", "else", ":", "k", "=", "as_unicode", "(", ...
fb9744f216273c7b24e65d037b1d621c08d7fde6
test
get_method_owner
Returns the instance owning the supplied instancemethod or the class owning the supplied classmethod.
parambokeh/util.py
def get_method_owner(meth): """ Returns the instance owning the supplied instancemethod or the class owning the supplied classmethod. """ if inspect.ismethod(meth): if sys.version_info < (3,0): return meth.im_class if meth.im_self is None else meth.im_self else: ...
def get_method_owner(meth): """ Returns the instance owning the supplied instancemethod or the class owning the supplied classmethod. """ if inspect.ismethod(meth): if sys.version_info < (3,0): return meth.im_class if meth.im_self is None else meth.im_self else: ...
[ "Returns", "the", "instance", "owning", "the", "supplied", "instancemethod", "or", "the", "class", "owning", "the", "supplied", "classmethod", "." ]
ioam/parambokeh
python
https://github.com/ioam/parambokeh/blob/fb9744f216273c7b24e65d037b1d621c08d7fde6/parambokeh/util.py#L34-L43
[ "def", "get_method_owner", "(", "meth", ")", ":", "if", "inspect", ".", "ismethod", "(", "meth", ")", ":", "if", "sys", ".", "version_info", "<", "(", "3", ",", "0", ")", ":", "return", "meth", ".", "im_class", "if", "meth", ".", "im_self", "is", "...
fb9744f216273c7b24e65d037b1d621c08d7fde6
test
AsyncHttpConnection._assign_auth_values
Take the http_auth value and split it into the attributes that carry the http auth username and password :param str|tuple http_auth: The http auth value
tornado_elasticsearch.py
def _assign_auth_values(self, http_auth): """Take the http_auth value and split it into the attributes that carry the http auth username and password :param str|tuple http_auth: The http auth value """ if not http_auth: pass elif isinstance(http_auth, (tuple...
def _assign_auth_values(self, http_auth): """Take the http_auth value and split it into the attributes that carry the http auth username and password :param str|tuple http_auth: The http auth value """ if not http_auth: pass elif isinstance(http_auth, (tuple...
[ "Take", "the", "http_auth", "value", "and", "split", "it", "into", "the", "attributes", "that", "carry", "the", "http", "auth", "username", "and", "password" ]
gmr/tornado-elasticsearch
python
https://github.com/gmr/tornado-elasticsearch/blob/fafe0de680277ce6faceb7449ded0b33822438d0/tornado_elasticsearch.py#L105-L120
[ "def", "_assign_auth_values", "(", "self", ",", "http_auth", ")", ":", "if", "not", "http_auth", ":", "pass", "elif", "isinstance", "(", "http_auth", ",", "(", "tuple", ",", "list", ")", ")", ":", "self", ".", "_auth_user", ",", "self", ".", "_auth_passw...
fafe0de680277ce6faceb7449ded0b33822438d0
test
AsyncElasticsearch.ping
Returns True if the cluster is up, False otherwise.
tornado_elasticsearch.py
def ping(self, params=None): """ Returns True if the cluster is up, False otherwise. """ try: self.transport.perform_request('HEAD', '/', params=params) except TransportError: raise gen.Return(False) raise gen.Return(True)
def ping(self, params=None): """ Returns True if the cluster is up, False otherwise. """ try: self.transport.perform_request('HEAD', '/', params=params) except TransportError: raise gen.Return(False) raise gen.Return(True)
[ "Returns", "True", "if", "the", "cluster", "is", "up", "False", "otherwise", "." ]
gmr/tornado-elasticsearch
python
https://github.com/gmr/tornado-elasticsearch/blob/fafe0de680277ce6faceb7449ded0b33822438d0/tornado_elasticsearch.py#L248-L254
[ "def", "ping", "(", "self", ",", "params", "=", "None", ")", ":", "try", ":", "self", ".", "transport", ".", "perform_request", "(", "'HEAD'", ",", "'/'", ",", "params", "=", "params", ")", "except", "TransportError", ":", "raise", "gen", ".", "Return"...
fafe0de680277ce6faceb7449ded0b33822438d0
test
AsyncElasticsearch.info
Get the basic info from the current cluster. :rtype: dict
tornado_elasticsearch.py
def info(self, params=None): """Get the basic info from the current cluster. :rtype: dict """ _, data = yield self.transport.perform_request('GET', '/', params=params) raise gen.Return(data)
def info(self, params=None): """Get the basic info from the current cluster. :rtype: dict """ _, data = yield self.transport.perform_request('GET', '/', params=params) raise gen.Return(data)
[ "Get", "the", "basic", "info", "from", "the", "current", "cluster", "." ]
gmr/tornado-elasticsearch
python
https://github.com/gmr/tornado-elasticsearch/blob/fafe0de680277ce6faceb7449ded0b33822438d0/tornado_elasticsearch.py#L258-L266
[ "def", "info", "(", "self", ",", "params", "=", "None", ")", ":", "_", ",", "data", "=", "yield", "self", ".", "transport", ".", "perform_request", "(", "'GET'", ",", "'/'", ",", "params", "=", "params", ")", "raise", "gen", ".", "Return", "(", "da...
fafe0de680277ce6faceb7449ded0b33822438d0
test
AsyncElasticsearch.health
Coroutine. Queries cluster Health API. Returns a 2-tuple, where first element is request status, and second element is a dictionary with response data. :param params: dictionary of query parameters, will be handed over to the underlying :class:`~torando_elasticsearch.AsyncHTTPConne...
tornado_elasticsearch.py
def health(self, params=None): """Coroutine. Queries cluster Health API. Returns a 2-tuple, where first element is request status, and second element is a dictionary with response data. :param params: dictionary of query parameters, will be handed over to the underlying :cl...
def health(self, params=None): """Coroutine. Queries cluster Health API. Returns a 2-tuple, where first element is request status, and second element is a dictionary with response data. :param params: dictionary of query parameters, will be handed over to the underlying :cl...
[ "Coroutine", ".", "Queries", "cluster", "Health", "API", "." ]
gmr/tornado-elasticsearch
python
https://github.com/gmr/tornado-elasticsearch/blob/fafe0de680277ce6faceb7449ded0b33822438d0/tornado_elasticsearch.py#L269-L282
[ "def", "health", "(", "self", ",", "params", "=", "None", ")", ":", "status", ",", "data", "=", "yield", "self", ".", "transport", ".", "perform_request", "(", "\"GET\"", ",", "\"/_cluster/health\"", ",", "params", "=", "params", ")", "raise", "gen", "."...
fafe0de680277ce6faceb7449ded0b33822438d0
test
AsyncElasticsearch.create
Adds a typed JSON document in a specific index, making it searchable. Behind the scenes this method calls index(..., op_type='create') `<http://elasticsearch.org/guide/reference/api/index_/>`_ :arg index: The name of the index :arg doc_type: The type of the document :arg id: Doc...
tornado_elasticsearch.py
def create(self, index, doc_type, body, id=None, params=None): """ Adds a typed JSON document in a specific index, making it searchable. Behind the scenes this method calls index(..., op_type='create') `<http://elasticsearch.org/guide/reference/api/index_/>`_ :arg index: The nam...
def create(self, index, doc_type, body, id=None, params=None): """ Adds a typed JSON document in a specific index, making it searchable. Behind the scenes this method calls index(..., op_type='create') `<http://elasticsearch.org/guide/reference/api/index_/>`_ :arg index: The nam...
[ "Adds", "a", "typed", "JSON", "document", "in", "a", "specific", "index", "making", "it", "searchable", ".", "Behind", "the", "scenes", "this", "method", "calls", "index", "(", "...", "op_type", "=", "create", ")", "<http", ":", "//", "elasticsearch", ".",...
gmr/tornado-elasticsearch
python
https://github.com/gmr/tornado-elasticsearch/blob/fafe0de680277ce6faceb7449ded0b33822438d0/tornado_elasticsearch.py#L288-L313
[ "def", "create", "(", "self", ",", "index", ",", "doc_type", ",", "body", ",", "id", "=", "None", ",", "params", "=", "None", ")", ":", "result", "=", "yield", "self", ".", "index", "(", "index", ",", "doc_type", ",", "body", ",", "id", "=", "id"...
fafe0de680277ce6faceb7449ded0b33822438d0
test
AsyncElasticsearch.index
Adds or updates a typed JSON document in a specific index, making it searchable. `<http://elasticsearch.org/guide/reference/api/index_/>`_ :arg index: The name of the index :arg doc_type: The type of the document :arg body: The document :arg id: Document ID :arg consiste...
tornado_elasticsearch.py
def index(self, index, doc_type, body, id=None, params=None): """ Adds or updates a typed JSON document in a specific index, making it searchable. `<http://elasticsearch.org/guide/reference/api/index_/>`_ :arg index: The name of the index :arg doc_type: The type of the document ...
def index(self, index, doc_type, body, id=None, params=None): """ Adds or updates a typed JSON document in a specific index, making it searchable. `<http://elasticsearch.org/guide/reference/api/index_/>`_ :arg index: The name of the index :arg doc_type: The type of the document ...
[ "Adds", "or", "updates", "a", "typed", "JSON", "document", "in", "a", "specific", "index", "making", "it", "searchable", ".", "<http", ":", "//", "elasticsearch", ".", "org", "/", "guide", "/", "reference", "/", "api", "/", "index_", "/", ">", "_" ]
gmr/tornado-elasticsearch
python
https://github.com/gmr/tornado-elasticsearch/blob/fafe0de680277ce6faceb7449ded0b33822438d0/tornado_elasticsearch.py#L319-L345
[ "def", "index", "(", "self", ",", "index", ",", "doc_type", ",", "body", ",", "id", "=", "None", ",", "params", "=", "None", ")", ":", "_", ",", "data", "=", "yield", "self", ".", "transport", ".", "perform_request", "(", "'PUT'", "if", "id", "else...
fafe0de680277ce6faceb7449ded0b33822438d0
test
AsyncElasticsearch.exists
Returns a boolean indicating whether or not given document exists in Elasticsearch. `<http://elasticsearch.org/guide/reference/api/get/>`_ :arg index: The name of the index :arg id: The document ID :arg doc_type: The type of the document (uses `_all` by default to fetch the ...
tornado_elasticsearch.py
def exists(self, index, id, doc_type='_all', params=None): """ Returns a boolean indicating whether or not given document exists in Elasticsearch. `<http://elasticsearch.org/guide/reference/api/get/>`_ :arg index: The name of the index :arg id: The document ID :arg doc_t...
def exists(self, index, id, doc_type='_all', params=None): """ Returns a boolean indicating whether or not given document exists in Elasticsearch. `<http://elasticsearch.org/guide/reference/api/get/>`_ :arg index: The name of the index :arg id: The document ID :arg doc_t...
[ "Returns", "a", "boolean", "indicating", "whether", "or", "not", "given", "document", "exists", "in", "Elasticsearch", ".", "<http", ":", "//", "elasticsearch", ".", "org", "/", "guide", "/", "reference", "/", "api", "/", "get", "/", ">", "_" ]
gmr/tornado-elasticsearch
python
https://github.com/gmr/tornado-elasticsearch/blob/fafe0de680277ce6faceb7449ded0b33822438d0/tornado_elasticsearch.py#L349-L372
[ "def", "exists", "(", "self", ",", "index", ",", "id", ",", "doc_type", "=", "'_all'", ",", "params", "=", "None", ")", ":", "try", ":", "self", ".", "transport", ".", "perform_request", "(", "'HEAD'", ",", "_make_path", "(", "index", ",", "doc_type", ...
fafe0de680277ce6faceb7449ded0b33822438d0
test
AsyncElasticsearch.get_alias
Retrieve a specified alias. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html>`_ :arg index: A comma-separated list of index names to filter aliases :arg name: A comma-separated list of alias names to return :arg allow_no_indices: Whether to ignore if ...
tornado_elasticsearch.py
def get_alias(self, index=None, name=None, params=None): """ Retrieve a specified alias. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html>`_ :arg index: A comma-separated list of index names to filter aliases :arg name: A comma-separated list ...
def get_alias(self, index=None, name=None, params=None): """ Retrieve a specified alias. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html>`_ :arg index: A comma-separated list of index names to filter aliases :arg name: A comma-separated list ...
[ "Retrieve", "a", "specified", "alias", ".", "<http", ":", "//", "www", ".", "elastic", ".", "co", "/", "guide", "/", "en", "/", "elasticsearch", "/", "reference", "/", "current", "/", "indices", "-", "aliases", ".", "html", ">", "_", ":", "arg", "ind...
gmr/tornado-elasticsearch
python
https://github.com/gmr/tornado-elasticsearch/blob/fafe0de680277ce6faceb7449ded0b33822438d0/tornado_elasticsearch.py#L409-L428
[ "def", "get_alias", "(", "self", ",", "index", "=", "None", ",", "name", "=", "None", ",", "params", "=", "None", ")", ":", "_", ",", "result", "=", "yield", "self", ".", "transport", ".", "perform_request", "(", "'GET'", ",", "_make_path", "(", "ind...
fafe0de680277ce6faceb7449ded0b33822438d0
test
AsyncElasticsearch.search
Execute a search query and get back search hits that match the query. `<http://www.elasticsearch.org/guide/reference/api/search/>`_ :arg index: A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices :arg doc_type: A comma-...
tornado_elasticsearch.py
def search(self, index=None, doc_type=None, body=None, params=None): """ Execute a search query and get back search hits that match the query. `<http://www.elasticsearch.org/guide/reference/api/search/>`_ :arg index: A comma-separated list of index names to search; use `_all` ...
def search(self, index=None, doc_type=None, body=None, params=None): """ Execute a search query and get back search hits that match the query. `<http://www.elasticsearch.org/guide/reference/api/search/>`_ :arg index: A comma-separated list of index names to search; use `_all` ...
[ "Execute", "a", "search", "query", "and", "get", "back", "search", "hits", "that", "match", "the", "query", ".", "<http", ":", "//", "www", ".", "elasticsearch", ".", "org", "/", "guide", "/", "reference", "/", "api", "/", "search", "/", ">", "_" ]
gmr/tornado-elasticsearch
python
https://github.com/gmr/tornado-elasticsearch/blob/fafe0de680277ce6faceb7449ded0b33822438d0/tornado_elasticsearch.py#L541-L609
[ "def", "search", "(", "self", ",", "index", "=", "None", ",", "doc_type", "=", "None", ",", "body", "=", "None", ",", "params", "=", "None", ")", ":", "# from is a reserved word so it cannot be used, use from_ instead", "if", "'from_'", "in", "params", ":", "p...
fafe0de680277ce6faceb7449ded0b33822438d0
test
AsyncElasticsearch.scroll
Scroll a search request created by specifying the scroll parameter. `<http://www.elasticsearch.org/guide/reference/api/search/scroll/>`_ :arg scroll_id: The scroll ID :arg scroll: Specify how long a consistent view of the index should be maintained for scrolled search
tornado_elasticsearch.py
def scroll(self, scroll_id, scroll, params=None): """ Scroll a search request created by specifying the scroll parameter. `<http://www.elasticsearch.org/guide/reference/api/search/scroll/>`_ :arg scroll_id: The scroll ID :arg scroll: Specify how long a consistent view of the ind...
def scroll(self, scroll_id, scroll, params=None): """ Scroll a search request created by specifying the scroll parameter. `<http://www.elasticsearch.org/guide/reference/api/search/scroll/>`_ :arg scroll_id: The scroll ID :arg scroll: Specify how long a consistent view of the ind...
[ "Scroll", "a", "search", "request", "created", "by", "specifying", "the", "scroll", "parameter", ".", "<http", ":", "//", "www", ".", "elasticsearch", ".", "org", "/", "guide", "/", "reference", "/", "api", "/", "search", "/", "scroll", "/", ">", "_" ]
gmr/tornado-elasticsearch
python
https://github.com/gmr/tornado-elasticsearch/blob/fafe0de680277ce6faceb7449ded0b33822438d0/tornado_elasticsearch.py#L661-L686
[ "def", "scroll", "(", "self", ",", "scroll_id", ",", "scroll", ",", "params", "=", "None", ")", ":", "body", "=", "{", "\"scroll\"", ":", "scroll", ",", "\"scroll_id\"", ":", "scroll_id", "}", "if", "params", ":", "if", "\"scroll\"", "in", "params", "....
fafe0de680277ce6faceb7449ded0b33822438d0
test
AsyncElasticsearch.clear_scroll
Clear the scroll request created by specifying the scroll parameter to search. `<http://www.elasticsearch.org/guide/reference/api/search/scroll/>`_ :arg scroll_id: The scroll ID or a list of scroll IDs
tornado_elasticsearch.py
def clear_scroll(self, scroll_id, params=None): """ Clear the scroll request created by specifying the scroll parameter to search. `<http://www.elasticsearch.org/guide/reference/api/search/scroll/>`_ :arg scroll_id: The scroll ID or a list of scroll IDs """ if no...
def clear_scroll(self, scroll_id, params=None): """ Clear the scroll request created by specifying the scroll parameter to search. `<http://www.elasticsearch.org/guide/reference/api/search/scroll/>`_ :arg scroll_id: The scroll ID or a list of scroll IDs """ if no...
[ "Clear", "the", "scroll", "request", "created", "by", "specifying", "the", "scroll", "parameter", "to", "search", ".", "<http", ":", "//", "www", ".", "elasticsearch", ".", "org", "/", "guide", "/", "reference", "/", "api", "/", "search", "/", "scroll", ...
gmr/tornado-elasticsearch
python
https://github.com/gmr/tornado-elasticsearch/blob/fafe0de680277ce6faceb7449ded0b33822438d0/tornado_elasticsearch.py#L690-L713
[ "def", "clear_scroll", "(", "self", ",", "scroll_id", ",", "params", "=", "None", ")", ":", "if", "not", "isinstance", "(", "scroll_id", ",", "list", ")", ":", "scroll_id", "=", "[", "scroll_id", "]", "body", "=", "{", "\"scroll_id\"", ":", "scroll_id", ...
fafe0de680277ce6faceb7449ded0b33822438d0
test
AsyncElasticsearch.get_mapping
Retrieve mapping definition of index or index/type. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html>`_ :arg index: A comma-separated list of index names :arg doc_type: A comma-separated list of document types :arg allow_no_indices: Whether to ign...
tornado_elasticsearch.py
def get_mapping(self, index=None, doc_type=None, params=None): """ Retrieve mapping definition of index or index/type. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html>`_ :arg index: A comma-separated list of index names :arg doc_type: A c...
def get_mapping(self, index=None, doc_type=None, params=None): """ Retrieve mapping definition of index or index/type. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html>`_ :arg index: A comma-separated list of index names :arg doc_type: A c...
[ "Retrieve", "mapping", "definition", "of", "index", "or", "index", "/", "type", ".", "<http", ":", "//", "www", ".", "elastic", ".", "co", "/", "guide", "/", "en", "/", "elasticsearch", "/", "reference", "/", "current", "/", "indices", "-", "get", "-",...
gmr/tornado-elasticsearch
python
https://github.com/gmr/tornado-elasticsearch/blob/fafe0de680277ce6faceb7449ded0b33822438d0/tornado_elasticsearch.py#L847-L869
[ "def", "get_mapping", "(", "self", ",", "index", "=", "None", ",", "doc_type", "=", "None", ",", "params", "=", "None", ")", ":", "_", ",", "data", "=", "yield", "self", ".", "transport", ".", "perform_request", "(", "'GET'", ",", "_make_path", "(", ...
fafe0de680277ce6faceb7449ded0b33822438d0
test
AsyncElasticsearch.suggest
The suggest feature suggests similar looking terms based on a provided text by using a suggester. `<http://elasticsearch.org/guide/reference/api/search/suggest/>`_ :arg index: A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the ...
tornado_elasticsearch.py
def suggest(self, index=None, body=None, params=None): """ The suggest feature suggests similar looking terms based on a provided text by using a suggester. `<http://elasticsearch.org/guide/reference/api/search/suggest/>`_ :arg index: A comma-separated list of index names to res...
def suggest(self, index=None, body=None, params=None): """ The suggest feature suggests similar looking terms based on a provided text by using a suggester. `<http://elasticsearch.org/guide/reference/api/search/suggest/>`_ :arg index: A comma-separated list of index names to res...
[ "The", "suggest", "feature", "suggests", "similar", "looking", "terms", "based", "on", "a", "provided", "text", "by", "using", "a", "suggester", ".", "<http", ":", "//", "elasticsearch", ".", "org", "/", "guide", "/", "reference", "/", "api", "/", "search"...
gmr/tornado-elasticsearch
python
https://github.com/gmr/tornado-elasticsearch/blob/fafe0de680277ce6faceb7449ded0b33822438d0/tornado_elasticsearch.py#L873-L895
[ "def", "suggest", "(", "self", ",", "index", "=", "None", ",", "body", "=", "None", ",", "params", "=", "None", ")", ":", "_", ",", "data", "=", "yield", "self", ".", "transport", ".", "perform_request", "(", "'POST'", ",", "_make_path", "(", "index"...
fafe0de680277ce6faceb7449ded0b33822438d0
test
SynoFormatHelper.bytes_to_readable
Converts bytes to a human readable format
SynologyDSM/SynologyDSM.py
def bytes_to_readable(num): """Converts bytes to a human readable format""" if num < 512: return "0 Kb" elif num < 1024: return "1 Kb" for unit in ['', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb', 'Zb']: if abs(num) < 1024.0: return "%...
def bytes_to_readable(num): """Converts bytes to a human readable format""" if num < 512: return "0 Kb" elif num < 1024: return "1 Kb" for unit in ['', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb', 'Zb']: if abs(num) < 1024.0: return "%...
[ "Converts", "bytes", "to", "a", "human", "readable", "format" ]
StaticCube/python-synology
python
https://github.com/StaticCube/python-synology/blob/a5446a052fc91a38f7589803dc7a654180db2566/SynologyDSM/SynologyDSM.py#L12-L23
[ "def", "bytes_to_readable", "(", "num", ")", ":", "if", "num", "<", "512", ":", "return", "\"0 Kb\"", "elif", "num", "<", "1024", ":", "return", "\"1 Kb\"", "for", "unit", "in", "[", "''", ",", "'Kb'", ",", "'Mb'", ",", "'Gb'", ",", "'Tb'", ",", "'...
a5446a052fc91a38f7589803dc7a654180db2566
test
SynoUtilization.cpu_total_load
Total CPU load for Synology DSM
SynologyDSM/SynologyDSM.py
def cpu_total_load(self): """Total CPU load for Synology DSM""" system_load = self.cpu_system_load user_load = self.cpu_user_load other_load = self.cpu_other_load if system_load is not None and \ user_load is not None and \ other_load is not None: ...
def cpu_total_load(self): """Total CPU load for Synology DSM""" system_load = self.cpu_system_load user_load = self.cpu_user_load other_load = self.cpu_other_load if system_load is not None and \ user_load is not None and \ other_load is not None: ...
[ "Total", "CPU", "load", "for", "Synology", "DSM" ]
StaticCube/python-synology
python
https://github.com/StaticCube/python-synology/blob/a5446a052fc91a38f7589803dc7a654180db2566/SynologyDSM/SynologyDSM.py#L77-L86
[ "def", "cpu_total_load", "(", "self", ")", ":", "system_load", "=", "self", ".", "cpu_system_load", "user_load", "=", "self", ".", "cpu_user_load", "other_load", "=", "self", ".", "cpu_other_load", "if", "system_load", "is", "not", "None", "and", "user_load", ...
a5446a052fc91a38f7589803dc7a654180db2566
test
SynoUtilization.memory_size
Total Memory Size of Synology DSM
SynologyDSM/SynologyDSM.py
def memory_size(self, human_readable=True): """Total Memory Size of Synology DSM""" if self._data is not None: # Memory is actually returned in KB's so multiply before converting return_data = int(self._data["memory"]["memory_size"]) * 1024 if human_readable: ...
def memory_size(self, human_readable=True): """Total Memory Size of Synology DSM""" if self._data is not None: # Memory is actually returned in KB's so multiply before converting return_data = int(self._data["memory"]["memory_size"]) * 1024 if human_readable: ...
[ "Total", "Memory", "Size", "of", "Synology", "DSM" ]
StaticCube/python-synology
python
https://github.com/StaticCube/python-synology/blob/a5446a052fc91a38f7589803dc7a654180db2566/SynologyDSM/SynologyDSM.py#L112-L121
[ "def", "memory_size", "(", "self", ",", "human_readable", "=", "True", ")", ":", "if", "self", ".", "_data", "is", "not", "None", ":", "# Memory is actually returned in KB's so multiply before converting\r", "return_data", "=", "int", "(", "self", ".", "_data", "[...
a5446a052fc91a38f7589803dc7a654180db2566
test
SynoUtilization._get_network
Function to get specific network (eth0, total, etc)
SynologyDSM/SynologyDSM.py
def _get_network(self, network_id): """Function to get specific network (eth0, total, etc)""" if self._data is not None: for network in self._data["network"]: if network["device"] == network_id: return network
def _get_network(self, network_id): """Function to get specific network (eth0, total, etc)""" if self._data is not None: for network in self._data["network"]: if network["device"] == network_id: return network
[ "Function", "to", "get", "specific", "network", "(", "eth0", "total", "etc", ")" ]
StaticCube/python-synology
python
https://github.com/StaticCube/python-synology/blob/a5446a052fc91a38f7589803dc7a654180db2566/SynologyDSM/SynologyDSM.py#L178-L183
[ "def", "_get_network", "(", "self", ",", "network_id", ")", ":", "if", "self", ".", "_data", "is", "not", "None", ":", "for", "network", "in", "self", ".", "_data", "[", "\"network\"", "]", ":", "if", "network", "[", "\"device\"", "]", "==", "network_i...
a5446a052fc91a38f7589803dc7a654180db2566
test
SynoUtilization.network_up
Total upload speed being used
SynologyDSM/SynologyDSM.py
def network_up(self, human_readable=True): """Total upload speed being used""" network = self._get_network("total") if network is not None: return_data = int(network["tx"]) if human_readable: return SynoFormatHelper.bytes_to_readable( ...
def network_up(self, human_readable=True): """Total upload speed being used""" network = self._get_network("total") if network is not None: return_data = int(network["tx"]) if human_readable: return SynoFormatHelper.bytes_to_readable( ...
[ "Total", "upload", "speed", "being", "used" ]
StaticCube/python-synology
python
https://github.com/StaticCube/python-synology/blob/a5446a052fc91a38f7589803dc7a654180db2566/SynologyDSM/SynologyDSM.py#L185-L194
[ "def", "network_up", "(", "self", ",", "human_readable", "=", "True", ")", ":", "network", "=", "self", ".", "_get_network", "(", "\"total\"", ")", "if", "network", "is", "not", "None", ":", "return_data", "=", "int", "(", "network", "[", "\"tx\"", "]", ...
a5446a052fc91a38f7589803dc7a654180db2566
test
SynoStorage.volumes
Returns all available volumes
SynologyDSM/SynologyDSM.py
def volumes(self): """Returns all available volumes""" if self._data is not None: volumes = [] for volume in self._data["volumes"]: volumes.append(volume["id"]) return volumes
def volumes(self): """Returns all available volumes""" if self._data is not None: volumes = [] for volume in self._data["volumes"]: volumes.append(volume["id"]) return volumes
[ "Returns", "all", "available", "volumes" ]
StaticCube/python-synology
python
https://github.com/StaticCube/python-synology/blob/a5446a052fc91a38f7589803dc7a654180db2566/SynologyDSM/SynologyDSM.py#L220-L226
[ "def", "volumes", "(", "self", ")", ":", "if", "self", ".", "_data", "is", "not", "None", ":", "volumes", "=", "[", "]", "for", "volume", "in", "self", ".", "_data", "[", "\"volumes\"", "]", ":", "volumes", ".", "append", "(", "volume", "[", "\"id\...
a5446a052fc91a38f7589803dc7a654180db2566
test
SynoStorage._get_volume
Returns a specific volume
SynologyDSM/SynologyDSM.py
def _get_volume(self, volume_id): """Returns a specific volume""" if self._data is not None: for volume in self._data["volumes"]: if volume["id"] == volume_id: return volume
def _get_volume(self, volume_id): """Returns a specific volume""" if self._data is not None: for volume in self._data["volumes"]: if volume["id"] == volume_id: return volume
[ "Returns", "a", "specific", "volume" ]
StaticCube/python-synology
python
https://github.com/StaticCube/python-synology/blob/a5446a052fc91a38f7589803dc7a654180db2566/SynologyDSM/SynologyDSM.py#L228-L233
[ "def", "_get_volume", "(", "self", ",", "volume_id", ")", ":", "if", "self", ".", "_data", "is", "not", "None", ":", "for", "volume", "in", "self", ".", "_data", "[", "\"volumes\"", "]", ":", "if", "volume", "[", "\"id\"", "]", "==", "volume_id", ":"...
a5446a052fc91a38f7589803dc7a654180db2566
test
SynoStorage.volume_size_total
Total size of volume
SynologyDSM/SynologyDSM.py
def volume_size_total(self, volume, human_readable=True): """Total size of volume""" volume = self._get_volume(volume) if volume is not None: return_data = int(volume["size"]["total"]) if human_readable: return SynoFormatHelper.bytes_to_readable( ...
def volume_size_total(self, volume, human_readable=True): """Total size of volume""" volume = self._get_volume(volume) if volume is not None: return_data = int(volume["size"]["total"]) if human_readable: return SynoFormatHelper.bytes_to_readable( ...
[ "Total", "size", "of", "volume" ]
StaticCube/python-synology
python
https://github.com/StaticCube/python-synology/blob/a5446a052fc91a38f7589803dc7a654180db2566/SynologyDSM/SynologyDSM.py#L247-L256
[ "def", "volume_size_total", "(", "self", ",", "volume", ",", "human_readable", "=", "True", ")", ":", "volume", "=", "self", ".", "_get_volume", "(", "volume", ")", "if", "volume", "is", "not", "None", ":", "return_data", "=", "int", "(", "volume", "[", ...
a5446a052fc91a38f7589803dc7a654180db2566
test
SynoStorage.volume_percentage_used
Total used size in percentage for volume
SynologyDSM/SynologyDSM.py
def volume_percentage_used(self, volume): """Total used size in percentage for volume""" volume = self._get_volume(volume) if volume is not None: total = int(volume["size"]["total"]) used = int(volume["size"]["used"]) if used is not None and used > 0 a...
def volume_percentage_used(self, volume): """Total used size in percentage for volume""" volume = self._get_volume(volume) if volume is not None: total = int(volume["size"]["total"]) used = int(volume["size"]["used"]) if used is not None and used > 0 a...
[ "Total", "used", "size", "in", "percentage", "for", "volume" ]
StaticCube/python-synology
python
https://github.com/StaticCube/python-synology/blob/a5446a052fc91a38f7589803dc7a654180db2566/SynologyDSM/SynologyDSM.py#L269-L278
[ "def", "volume_percentage_used", "(", "self", ",", "volume", ")", ":", "volume", "=", "self", ".", "_get_volume", "(", "volume", ")", "if", "volume", "is", "not", "None", ":", "total", "=", "int", "(", "volume", "[", "\"size\"", "]", "[", "\"total\"", ...
a5446a052fc91a38f7589803dc7a654180db2566
test
SynoStorage.volume_disk_temp_avg
Average temperature of all disks making up the volume
SynologyDSM/SynologyDSM.py
def volume_disk_temp_avg(self, volume): """Average temperature of all disks making up the volume""" volume = self._get_volume(volume) if volume is not None: vol_disks = volume["disks"] if vol_disks is not None: total_temp = 0 total_d...
def volume_disk_temp_avg(self, volume): """Average temperature of all disks making up the volume""" volume = self._get_volume(volume) if volume is not None: vol_disks = volume["disks"] if vol_disks is not None: total_temp = 0 total_d...
[ "Average", "temperature", "of", "all", "disks", "making", "up", "the", "volume" ]
StaticCube/python-synology
python
https://github.com/StaticCube/python-synology/blob/a5446a052fc91a38f7589803dc7a654180db2566/SynologyDSM/SynologyDSM.py#L280-L296
[ "def", "volume_disk_temp_avg", "(", "self", ",", "volume", ")", ":", "volume", "=", "self", ".", "_get_volume", "(", "volume", ")", "if", "volume", "is", "not", "None", ":", "vol_disks", "=", "volume", "[", "\"disks\"", "]", "if", "vol_disks", "is", "not...
a5446a052fc91a38f7589803dc7a654180db2566
test
SynoStorage.volume_disk_temp_max
Maximum temperature of all disks making up the volume
SynologyDSM/SynologyDSM.py
def volume_disk_temp_max(self, volume): """Maximum temperature of all disks making up the volume""" volume = self._get_volume(volume) if volume is not None: vol_disks = volume["disks"] if vol_disks is not None: max_temp = 0 for vol...
def volume_disk_temp_max(self, volume): """Maximum temperature of all disks making up the volume""" volume = self._get_volume(volume) if volume is not None: vol_disks = volume["disks"] if vol_disks is not None: max_temp = 0 for vol...
[ "Maximum", "temperature", "of", "all", "disks", "making", "up", "the", "volume" ]
StaticCube/python-synology
python
https://github.com/StaticCube/python-synology/blob/a5446a052fc91a38f7589803dc7a654180db2566/SynologyDSM/SynologyDSM.py#L298-L311
[ "def", "volume_disk_temp_max", "(", "self", ",", "volume", ")", ":", "volume", "=", "self", ".", "_get_volume", "(", "volume", ")", "if", "volume", "is", "not", "None", ":", "vol_disks", "=", "volume", "[", "\"disks\"", "]", "if", "vol_disks", "is", "not...
a5446a052fc91a38f7589803dc7a654180db2566
test
SynoStorage.disks
Returns all available (internal) disks
SynologyDSM/SynologyDSM.py
def disks(self): """Returns all available (internal) disks""" if self._data is not None: disks = [] for disk in self._data["disks"]: disks.append(disk["id"]) return disks
def disks(self): """Returns all available (internal) disks""" if self._data is not None: disks = [] for disk in self._data["disks"]: disks.append(disk["id"]) return disks
[ "Returns", "all", "available", "(", "internal", ")", "disks" ]
StaticCube/python-synology
python
https://github.com/StaticCube/python-synology/blob/a5446a052fc91a38f7589803dc7a654180db2566/SynologyDSM/SynologyDSM.py#L314-L320
[ "def", "disks", "(", "self", ")", ":", "if", "self", ".", "_data", "is", "not", "None", ":", "disks", "=", "[", "]", "for", "disk", "in", "self", ".", "_data", "[", "\"disks\"", "]", ":", "disks", ".", "append", "(", "disk", "[", "\"id\"", "]", ...
a5446a052fc91a38f7589803dc7a654180db2566
test
SynoStorage._get_disk
Returns a specific disk
SynologyDSM/SynologyDSM.py
def _get_disk(self, disk_id): """Returns a specific disk""" if self._data is not None: for disk in self._data["disks"]: if disk["id"] == disk_id: return disk
def _get_disk(self, disk_id): """Returns a specific disk""" if self._data is not None: for disk in self._data["disks"]: if disk["id"] == disk_id: return disk
[ "Returns", "a", "specific", "disk" ]
StaticCube/python-synology
python
https://github.com/StaticCube/python-synology/blob/a5446a052fc91a38f7589803dc7a654180db2566/SynologyDSM/SynologyDSM.py#L322-L327
[ "def", "_get_disk", "(", "self", ",", "disk_id", ")", ":", "if", "self", ".", "_data", "is", "not", "None", ":", "for", "disk", "in", "self", ".", "_data", "[", "\"disks\"", "]", ":", "if", "disk", "[", "\"id\"", "]", "==", "disk_id", ":", "return"...
a5446a052fc91a38f7589803dc7a654180db2566
test
SynologyDSM._login
Build and execute login request
SynologyDSM/SynologyDSM.py
def _login(self): """Build and execute login request""" api_path = "%s/auth.cgi?api=SYNO.API.Auth&version=2" % ( self.base_url, ) login_path = "method=login&%s" % (self._encode_credentials()) url = "%s&%s&session=Core&format=cookie" % ( api_path...
def _login(self): """Build and execute login request""" api_path = "%s/auth.cgi?api=SYNO.API.Auth&version=2" % ( self.base_url, ) login_path = "method=login&%s" % (self._encode_credentials()) url = "%s&%s&session=Core&format=cookie" % ( api_path...
[ "Build", "and", "execute", "login", "request" ]
StaticCube/python-synology
python
https://github.com/StaticCube/python-synology/blob/a5446a052fc91a38f7589803dc7a654180db2566/SynologyDSM/SynologyDSM.py#L417-L438
[ "def", "_login", "(", "self", ")", ":", "api_path", "=", "\"%s/auth.cgi?api=SYNO.API.Auth&version=2\"", "%", "(", "self", ".", "base_url", ",", ")", "login_path", "=", "\"method=login&%s\"", "%", "(", "self", ".", "_encode_credentials", "(", ")", ")", "url", "...
a5446a052fc91a38f7589803dc7a654180db2566
test
SynologyDSM._get_url
Function to handle sessions for a GET request
SynologyDSM/SynologyDSM.py
def _get_url(self, url, retry_on_error=True): """Function to handle sessions for a GET request""" # Check if we failed to request the url or need to login if self.access_token is None or \ self._session is None or \ self._session_error: # Clear Access Toke...
def _get_url(self, url, retry_on_error=True): """Function to handle sessions for a GET request""" # Check if we failed to request the url or need to login if self.access_token is None or \ self._session is None or \ self._session_error: # Clear Access Toke...
[ "Function", "to", "handle", "sessions", "for", "a", "GET", "request" ]
StaticCube/python-synology
python
https://github.com/StaticCube/python-synology/blob/a5446a052fc91a38f7589803dc7a654180db2566/SynologyDSM/SynologyDSM.py#L440-L473
[ "def", "_get_url", "(", "self", ",", "url", ",", "retry_on_error", "=", "True", ")", ":", "# Check if we failed to request the url or need to login\r", "if", "self", ".", "access_token", "is", "None", "or", "self", ".", "_session", "is", "None", "or", "self", "....
a5446a052fc91a38f7589803dc7a654180db2566
test
SynologyDSM._execute_get_url
Function to execute and handle a GET request
SynologyDSM/SynologyDSM.py
def _execute_get_url(self, request_url, append_sid=True): """Function to execute and handle a GET request""" # Prepare Request self._debuglog("Requesting URL: '" + request_url + "'") if append_sid: self._debuglog("Appending access_token (SID: " + ...
def _execute_get_url(self, request_url, append_sid=True): """Function to execute and handle a GET request""" # Prepare Request self._debuglog("Requesting URL: '" + request_url + "'") if append_sid: self._debuglog("Appending access_token (SID: " + ...
[ "Function", "to", "execute", "and", "handle", "a", "GET", "request" ]
StaticCube/python-synology
python
https://github.com/StaticCube/python-synology/blob/a5446a052fc91a38f7589803dc7a654180db2566/SynologyDSM/SynologyDSM.py#L475-L509
[ "def", "_execute_get_url", "(", "self", ",", "request_url", ",", "append_sid", "=", "True", ")", ":", "# Prepare Request\r", "self", ".", "_debuglog", "(", "\"Requesting URL: '\"", "+", "request_url", "+", "\"'\"", ")", "if", "append_sid", ":", "self", ".", "_...
a5446a052fc91a38f7589803dc7a654180db2566
test
SynologyDSM.update
Updates the various instanced modules
SynologyDSM/SynologyDSM.py
def update(self): """Updates the various instanced modules""" if self._utilisation is not None: api = "SYNO.Core.System.Utilization" url = "%s/entry.cgi?api=%s&version=1&method=get&_sid=%s" % ( self.base_url, api, self.access...
def update(self): """Updates the various instanced modules""" if self._utilisation is not None: api = "SYNO.Core.System.Utilization" url = "%s/entry.cgi?api=%s&version=1&method=get&_sid=%s" % ( self.base_url, api, self.access...
[ "Updates", "the", "various", "instanced", "modules" ]
StaticCube/python-synology
python
https://github.com/StaticCube/python-synology/blob/a5446a052fc91a38f7589803dc7a654180db2566/SynologyDSM/SynologyDSM.py#L512-L527
[ "def", "update", "(", "self", ")", ":", "if", "self", ".", "_utilisation", "is", "not", "None", ":", "api", "=", "\"SYNO.Core.System.Utilization\"", "url", "=", "\"%s/entry.cgi?api=%s&version=1&method=get&_sid=%s\"", "%", "(", "self", ".", "base_url", ",", "api", ...
a5446a052fc91a38f7589803dc7a654180db2566
test
SynologyDSM.utilisation
Getter for various Utilisation variables
SynologyDSM/SynologyDSM.py
def utilisation(self): """Getter for various Utilisation variables""" if self._utilisation is None: api = "SYNO.Core.System.Utilization" url = "%s/entry.cgi?api=%s&version=1&method=get" % ( self.base_url, api) self._utilisation =...
def utilisation(self): """Getter for various Utilisation variables""" if self._utilisation is None: api = "SYNO.Core.System.Utilization" url = "%s/entry.cgi?api=%s&version=1&method=get" % ( self.base_url, api) self._utilisation =...
[ "Getter", "for", "various", "Utilisation", "variables" ]
StaticCube/python-synology
python
https://github.com/StaticCube/python-synology/blob/a5446a052fc91a38f7589803dc7a654180db2566/SynologyDSM/SynologyDSM.py#L530-L538
[ "def", "utilisation", "(", "self", ")", ":", "if", "self", ".", "_utilisation", "is", "None", ":", "api", "=", "\"SYNO.Core.System.Utilization\"", "url", "=", "\"%s/entry.cgi?api=%s&version=1&method=get\"", "%", "(", "self", ".", "base_url", ",", "api", ")", "se...
a5446a052fc91a38f7589803dc7a654180db2566
test
SynologyDSM.storage
Getter for various Storage variables
SynologyDSM/SynologyDSM.py
def storage(self): """Getter for various Storage variables""" if self._storage is None: api = "SYNO.Storage.CGI.Storage" url = "%s/entry.cgi?api=%s&version=1&method=load_info" % ( self.base_url, api) self._storage = SynoStorage(s...
def storage(self): """Getter for various Storage variables""" if self._storage is None: api = "SYNO.Storage.CGI.Storage" url = "%s/entry.cgi?api=%s&version=1&method=load_info" % ( self.base_url, api) self._storage = SynoStorage(s...
[ "Getter", "for", "various", "Storage", "variables" ]
StaticCube/python-synology
python
https://github.com/StaticCube/python-synology/blob/a5446a052fc91a38f7589803dc7a654180db2566/SynologyDSM/SynologyDSM.py#L541-L549
[ "def", "storage", "(", "self", ")", ":", "if", "self", ".", "_storage", "is", "None", ":", "api", "=", "\"SYNO.Storage.CGI.Storage\"", "url", "=", "\"%s/entry.cgi?api=%s&version=1&method=load_info\"", "%", "(", "self", ".", "base_url", ",", "api", ")", "self", ...
a5446a052fc91a38f7589803dc7a654180db2566
test
Context.for_request
Creates the context for a specific request.
sentry_hipchat_ac/models.py
def for_request(request, body=None): """Creates the context for a specific request.""" tenant, jwt_data = Tenant.objects.for_request(request, body) webhook_sender_id = jwt_data.get('sub') sender_data = None if body and 'item' in body: if 'sender' in body['item']: ...
def for_request(request, body=None): """Creates the context for a specific request.""" tenant, jwt_data = Tenant.objects.for_request(request, body) webhook_sender_id = jwt_data.get('sub') sender_data = None if body and 'item' in body: if 'sender' in body['item']: ...
[ "Creates", "the", "context", "for", "a", "specific", "request", "." ]
getsentry/sentry-hipchat-ac
python
https://github.com/getsentry/sentry-hipchat-ac/blob/9063666f1e06cf352fed0530a8a437e45badc917/sentry_hipchat_ac/models.py#L245-L271
[ "def", "for_request", "(", "request", ",", "body", "=", "None", ")", ":", "tenant", ",", "jwt_data", "=", "Tenant", ".", "objects", ".", "for_request", "(", "request", ",", "body", ")", "webhook_sender_id", "=", "jwt_data", ".", "get", "(", "'sub'", ")",...
9063666f1e06cf352fed0530a8a437e45badc917
test
Context.tenant_token
The cached token of the current tenant.
sentry_hipchat_ac/models.py
def tenant_token(self): """The cached token of the current tenant.""" rv = getattr(self, '_tenant_token', None) if rv is None: rv = self._tenant_token = self.tenant.get_token() return rv
def tenant_token(self): """The cached token of the current tenant.""" rv = getattr(self, '_tenant_token', None) if rv is None: rv = self._tenant_token = self.tenant.get_token() return rv
[ "The", "cached", "token", "of", "the", "current", "tenant", "." ]
getsentry/sentry-hipchat-ac
python
https://github.com/getsentry/sentry-hipchat-ac/blob/9063666f1e06cf352fed0530a8a437e45badc917/sentry_hipchat_ac/models.py#L283-L288
[ "def", "tenant_token", "(", "self", ")", ":", "rv", "=", "getattr", "(", "self", ",", "'_tenant_token'", ",", "None", ")", "if", "rv", "is", "None", ":", "rv", "=", "self", ".", "_tenant_token", "=", "self", ".", "tenant", ".", "get_token", "(", ")",...
9063666f1e06cf352fed0530a8a437e45badc917
test
WidgetWrapperMixin.build_attrs
Helper function for building an attribute dictionary.
django_addanother/widgets.py
def build_attrs(self, extra_attrs=None, **kwargs): "Helper function for building an attribute dictionary." self.attrs = self.widget.build_attrs(extra_attrs=None, **kwargs) return self.attrs
def build_attrs(self, extra_attrs=None, **kwargs): "Helper function for building an attribute dictionary." self.attrs = self.widget.build_attrs(extra_attrs=None, **kwargs) return self.attrs
[ "Helper", "function", "for", "building", "an", "attribute", "dictionary", "." ]
jonashaag/django-addanother
python
https://github.com/jonashaag/django-addanother/blob/83dc0c8cc7665cc481dd58da0b9a746972264046/django_addanother/widgets.py#L28-L31
[ "def", "build_attrs", "(", "self", ",", "extra_attrs", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "attrs", "=", "self", ".", "widget", ".", "build_attrs", "(", "extra_attrs", "=", "None", ",", "*", "*", "kwargs", ")", "return", "sel...
83dc0c8cc7665cc481dd58da0b9a746972264046
test
with_apps
Class decorator that makes sure the passed apps are present in INSTALLED_APPS.
override_settings/__init__.py
def with_apps(*apps): """ Class decorator that makes sure the passed apps are present in INSTALLED_APPS. """ apps_set = set(settings.INSTALLED_APPS) apps_set.update(apps) return override_settings(INSTALLED_APPS=list(apps_set))
def with_apps(*apps): """ Class decorator that makes sure the passed apps are present in INSTALLED_APPS. """ apps_set = set(settings.INSTALLED_APPS) apps_set.update(apps) return override_settings(INSTALLED_APPS=list(apps_set))
[ "Class", "decorator", "that", "makes", "sure", "the", "passed", "apps", "are", "present", "in", "INSTALLED_APPS", "." ]
edavis/django-override-settings
python
https://github.com/edavis/django-override-settings/blob/016a2ba44cf7132d3aeefbfeddaf201217b1d4b6/override_settings/__init__.py#L66-L73
[ "def", "with_apps", "(", "*", "apps", ")", ":", "apps_set", "=", "set", "(", "settings", ".", "INSTALLED_APPS", ")", "apps_set", ".", "update", "(", "apps", ")", "return", "override_settings", "(", "INSTALLED_APPS", "=", "list", "(", "apps_set", ")", ")" ]
016a2ba44cf7132d3aeefbfeddaf201217b1d4b6
test
without_apps
Class decorator that makes sure the passed apps are not present in INSTALLED_APPS.
override_settings/__init__.py
def without_apps(*apps): """ Class decorator that makes sure the passed apps are not present in INSTALLED_APPS. """ apps_list = [a for a in settings.INSTALLED_APPS if a not in apps] return override_settings(INSTALLED_APPS=apps_list)
def without_apps(*apps): """ Class decorator that makes sure the passed apps are not present in INSTALLED_APPS. """ apps_list = [a for a in settings.INSTALLED_APPS if a not in apps] return override_settings(INSTALLED_APPS=apps_list)
[ "Class", "decorator", "that", "makes", "sure", "the", "passed", "apps", "are", "not", "present", "in", "INSTALLED_APPS", "." ]
edavis/django-override-settings
python
https://github.com/edavis/django-override-settings/blob/016a2ba44cf7132d3aeefbfeddaf201217b1d4b6/override_settings/__init__.py#L75-L81
[ "def", "without_apps", "(", "*", "apps", ")", ":", "apps_list", "=", "[", "a", "for", "a", "in", "settings", ".", "INSTALLED_APPS", "if", "a", "not", "in", "apps", "]", "return", "override_settings", "(", "INSTALLED_APPS", "=", "apps_list", ")" ]
016a2ba44cf7132d3aeefbfeddaf201217b1d4b6
test
override_settings.get_global_settings
Return a dictionary of all global_settings values.
override_settings/__init__.py
def get_global_settings(self): """ Return a dictionary of all global_settings values. """ return dict((key, getattr(global_settings, key)) for key in dir(global_settings) if key.isupper())
def get_global_settings(self): """ Return a dictionary of all global_settings values. """ return dict((key, getattr(global_settings, key)) for key in dir(global_settings) if key.isupper())
[ "Return", "a", "dictionary", "of", "all", "global_settings", "values", "." ]
edavis/django-override-settings
python
https://github.com/edavis/django-override-settings/blob/016a2ba44cf7132d3aeefbfeddaf201217b1d4b6/override_settings/__init__.py#L14-L19
[ "def", "get_global_settings", "(", "self", ")", ":", "return", "dict", "(", "(", "key", ",", "getattr", "(", "global_settings", ",", "key", ")", ")", "for", "key", "in", "dir", "(", "global_settings", ")", "if", "key", ".", "isupper", "(", ")", ")" ]
016a2ba44cf7132d3aeefbfeddaf201217b1d4b6
test
OAuth2UtilRequestHandler.do_GET
Handle the retrieval of the code
OAuth2Util/OAuth2Util.py
def do_GET(self): """ Handle the retrieval of the code """ parsed_url = urlparse(self.path) if parsed_url[2] == "/" + SERVER_REDIRECT_PATH: # 2 = Path parsed_query = parse_qs(parsed_url[4]) # 4 = Query if "code" not in parsed_query: self.send_response(200) self.send_header("Content-Type", "t...
def do_GET(self): """ Handle the retrieval of the code """ parsed_url = urlparse(self.path) if parsed_url[2] == "/" + SERVER_REDIRECT_PATH: # 2 = Path parsed_query = parse_qs(parsed_url[4]) # 4 = Query if "code" not in parsed_query: self.send_response(200) self.send_header("Content-Type", "t...
[ "Handle", "the", "retrieval", "of", "the", "code" ]
SmBe19/praw-OAuth2Util
python
https://github.com/SmBe19/praw-OAuth2Util/blob/ca0a2d4d7eefcc681aac92c9cd4b83cd9ea6c5fe/OAuth2Util/OAuth2Util.py#L58-L95
[ "def", "do_GET", "(", "self", ")", ":", "parsed_url", "=", "urlparse", "(", "self", ".", "path", ")", "if", "parsed_url", "[", "2", "]", "==", "\"/\"", "+", "SERVER_REDIRECT_PATH", ":", "# 2 = Path", "parsed_query", "=", "parse_qs", "(", "parsed_url", "[",...
ca0a2d4d7eefcc681aac92c9cd4b83cd9ea6c5fe
test
OAuth2Util._set_app_info
Set the app info (id & secret) read from the config file on the Reddit object
OAuth2Util/OAuth2Util.py
def _set_app_info(self): """ Set the app info (id & secret) read from the config file on the Reddit object """ redirect_url = "http://{0}:{1}/{2}".format(SERVER_URL, SERVER_PORT, SERVER_REDIRECT_PATH) self.r.set_oauth_app_info(self._get_value(CONFIGKEY_APP_KEY), self._get_value(CONFIG...
def _set_app_info(self): """ Set the app info (id & secret) read from the config file on the Reddit object """ redirect_url = "http://{0}:{1}/{2}".format(SERVER_URL, SERVER_PORT, SERVER_REDIRECT_PATH) self.r.set_oauth_app_info(self._get_value(CONFIGKEY_APP_KEY), self._get_value(CONFIG...
[ "Set", "the", "app", "info", "(", "id", "&", "secret", ")", "read", "from", "the", "config", "file", "on", "the", "Reddit", "object" ]
SmBe19/praw-OAuth2Util
python
https://github.com/SmBe19/praw-OAuth2Util/blob/ca0a2d4d7eefcc681aac92c9cd4b83cd9ea6c5fe/OAuth2Util/OAuth2Util.py#L167-L175
[ "def", "_set_app_info", "(", "self", ")", ":", "redirect_url", "=", "\"http://{0}:{1}/{2}\"", ".", "format", "(", "SERVER_URL", ",", "SERVER_PORT", ",", "SERVER_REDIRECT_PATH", ")", "self", ".", "r", ".", "set_oauth_app_info", "(", "self", ".", "_get_value", "("...
ca0a2d4d7eefcc681aac92c9cd4b83cd9ea6c5fe
test
OAuth2Util._get_value
Helper method to get a value from the config
OAuth2Util/OAuth2Util.py
def _get_value(self, key, func=None, split_val=None, as_boolean=False, exception_default=None): """ Helper method to get a value from the config """ try: if as_boolean: return self.config.getboolean(key[0], key[1]) value = self.config.get(key[0], key[1]) if split_val is not None: value = valu...
def _get_value(self, key, func=None, split_val=None, as_boolean=False, exception_default=None): """ Helper method to get a value from the config """ try: if as_boolean: return self.config.getboolean(key[0], key[1]) value = self.config.get(key[0], key[1]) if split_val is not None: value = valu...
[ "Helper", "method", "to", "get", "a", "value", "from", "the", "config" ]
SmBe19/praw-OAuth2Util
python
https://github.com/SmBe19/praw-OAuth2Util/blob/ca0a2d4d7eefcc681aac92c9cd4b83cd9ea6c5fe/OAuth2Util/OAuth2Util.py#L177-L194
[ "def", "_get_value", "(", "self", ",", "key", ",", "func", "=", "None", ",", "split_val", "=", "None", ",", "as_boolean", "=", "False", ",", "exception_default", "=", "None", ")", ":", "try", ":", "if", "as_boolean", ":", "return", "self", ".", "config...
ca0a2d4d7eefcc681aac92c9cd4b83cd9ea6c5fe
test
OAuth2Util._change_value
Change the value of the given key in the given file to the given value
OAuth2Util/OAuth2Util.py
def _change_value(self, key, value): """ Change the value of the given key in the given file to the given value """ if not self.config.has_section(key[0]): self.config.add_section(key[0]) self.config.set(key[0], key[1], str(value)) with open(self.configfile, "w") as f: self.config.write(f)
def _change_value(self, key, value): """ Change the value of the given key in the given file to the given value """ if not self.config.has_section(key[0]): self.config.add_section(key[0]) self.config.set(key[0], key[1], str(value)) with open(self.configfile, "w") as f: self.config.write(f)
[ "Change", "the", "value", "of", "the", "given", "key", "in", "the", "given", "file", "to", "the", "given", "value" ]
SmBe19/praw-OAuth2Util
python
https://github.com/SmBe19/praw-OAuth2Util/blob/ca0a2d4d7eefcc681aac92c9cd4b83cd9ea6c5fe/OAuth2Util/OAuth2Util.py#L196-L206
[ "def", "_change_value", "(", "self", ",", "key", ",", "value", ")", ":", "if", "not", "self", ".", "config", ".", "has_section", "(", "key", "[", "0", "]", ")", ":", "self", ".", "config", ".", "add_section", "(", "key", "[", "0", "]", ")", "self...
ca0a2d4d7eefcc681aac92c9cd4b83cd9ea6c5fe
test
OAuth2Util._migrate_config
Migrates the old config file format to the new one
OAuth2Util/OAuth2Util.py
def _migrate_config(self, oldname=DEFAULT_CONFIG, newname=DEFAULT_CONFIG): """ Migrates the old config file format to the new one """ self._log("Your OAuth2Util config file is in an old format and needs " "to be changed. I tried as best as I could to migrate it.", logging.WARNING) with open(oldname, "r")...
def _migrate_config(self, oldname=DEFAULT_CONFIG, newname=DEFAULT_CONFIG): """ Migrates the old config file format to the new one """ self._log("Your OAuth2Util config file is in an old format and needs " "to be changed. I tried as best as I could to migrate it.", logging.WARNING) with open(oldname, "r")...
[ "Migrates", "the", "old", "config", "file", "format", "to", "the", "new", "one" ]
SmBe19/praw-OAuth2Util
python
https://github.com/SmBe19/praw-OAuth2Util/blob/ca0a2d4d7eefcc681aac92c9cd4b83cd9ea6c5fe/OAuth2Util/OAuth2Util.py#L208-L218
[ "def", "_migrate_config", "(", "self", ",", "oldname", "=", "DEFAULT_CONFIG", ",", "newname", "=", "DEFAULT_CONFIG", ")", ":", "self", ".", "_log", "(", "\"Your OAuth2Util config file is in an old format and needs \"", "\"to be changed. I tried as best as I could to migrate it....
ca0a2d4d7eefcc681aac92c9cd4b83cd9ea6c5fe
test
OAuth2Util._start_webserver
Start the webserver that will receive the code
OAuth2Util/OAuth2Util.py
def _start_webserver(self, authorize_url=None): """ Start the webserver that will receive the code """ server_address = (SERVER_URL, SERVER_PORT) self.server = HTTPServer(server_address, OAuth2UtilRequestHandler) self.server.response_code = None self.server.authorize_url = authorize_url t = Thread(targe...
def _start_webserver(self, authorize_url=None): """ Start the webserver that will receive the code """ server_address = (SERVER_URL, SERVER_PORT) self.server = HTTPServer(server_address, OAuth2UtilRequestHandler) self.server.response_code = None self.server.authorize_url = authorize_url t = Thread(targe...
[ "Start", "the", "webserver", "that", "will", "receive", "the", "code" ]
SmBe19/praw-OAuth2Util
python
https://github.com/SmBe19/praw-OAuth2Util/blob/ca0a2d4d7eefcc681aac92c9cd4b83cd9ea6c5fe/OAuth2Util/OAuth2Util.py#L222-L232
[ "def", "_start_webserver", "(", "self", ",", "authorize_url", "=", "None", ")", ":", "server_address", "=", "(", "SERVER_URL", ",", "SERVER_PORT", ")", "self", ".", "server", "=", "HTTPServer", "(", "server_address", ",", "OAuth2UtilRequestHandler", ")", "self",...
ca0a2d4d7eefcc681aac92c9cd4b83cd9ea6c5fe
test
OAuth2Util._wait_for_response
Wait until the user accepted or rejected the request
OAuth2Util/OAuth2Util.py
def _wait_for_response(self): """ Wait until the user accepted or rejected the request """ while not self.server.response_code: time.sleep(2) time.sleep(5) self.server.shutdown()
def _wait_for_response(self): """ Wait until the user accepted or rejected the request """ while not self.server.response_code: time.sleep(2) time.sleep(5) self.server.shutdown()
[ "Wait", "until", "the", "user", "accepted", "or", "rejected", "the", "request" ]
SmBe19/praw-OAuth2Util
python
https://github.com/SmBe19/praw-OAuth2Util/blob/ca0a2d4d7eefcc681aac92c9cd4b83cd9ea6c5fe/OAuth2Util/OAuth2Util.py#L234-L241
[ "def", "_wait_for_response", "(", "self", ")", ":", "while", "not", "self", ".", "server", ".", "response_code", ":", "time", ".", "sleep", "(", "2", ")", "time", ".", "sleep", "(", "5", ")", "self", ".", "server", ".", "shutdown", "(", ")" ]
ca0a2d4d7eefcc681aac92c9cd4b83cd9ea6c5fe
test
OAuth2Util._get_new_access_information
Request new access information from reddit using the built in webserver
OAuth2Util/OAuth2Util.py
def _get_new_access_information(self): """ Request new access information from reddit using the built in webserver """ if not self.r.has_oauth_app_info: self._log('Cannot obtain authorize url from PRAW. Please check your configuration.', logging.ERROR) raise AttributeError('Reddit Session invalid, please ...
def _get_new_access_information(self): """ Request new access information from reddit using the built in webserver """ if not self.r.has_oauth_app_info: self._log('Cannot obtain authorize url from PRAW. Please check your configuration.', logging.ERROR) raise AttributeError('Reddit Session invalid, please ...
[ "Request", "new", "access", "information", "from", "reddit", "using", "the", "built", "in", "webserver" ]
SmBe19/praw-OAuth2Util
python
https://github.com/SmBe19/praw-OAuth2Util/blob/ca0a2d4d7eefcc681aac92c9cd4b83cd9ea6c5fe/OAuth2Util/OAuth2Util.py#L243-L272
[ "def", "_get_new_access_information", "(", "self", ")", ":", "if", "not", "self", ".", "r", ".", "has_oauth_app_info", ":", "self", ".", "_log", "(", "'Cannot obtain authorize url from PRAW. Please check your configuration.'", ",", "logging", ".", "ERROR", ")", "raise...
ca0a2d4d7eefcc681aac92c9cd4b83cd9ea6c5fe
test
OAuth2Util._check_token_present
Check whether the tokens are set and request new ones if not
OAuth2Util/OAuth2Util.py
def _check_token_present(self): """ Check whether the tokens are set and request new ones if not """ try: self._get_value(CONFIGKEY_TOKEN) self._get_value(CONFIGKEY_REFRESH_TOKEN) self._get_value(CONFIGKEY_REFRESHABLE) except KeyError: self._log("Request new Token (CTP)") self._get_new_access_i...
def _check_token_present(self): """ Check whether the tokens are set and request new ones if not """ try: self._get_value(CONFIGKEY_TOKEN) self._get_value(CONFIGKEY_REFRESH_TOKEN) self._get_value(CONFIGKEY_REFRESHABLE) except KeyError: self._log("Request new Token (CTP)") self._get_new_access_i...
[ "Check", "whether", "the", "tokens", "are", "set", "and", "request", "new", "ones", "if", "not" ]
SmBe19/praw-OAuth2Util
python
https://github.com/SmBe19/praw-OAuth2Util/blob/ca0a2d4d7eefcc681aac92c9cd4b83cd9ea6c5fe/OAuth2Util/OAuth2Util.py#L274-L284
[ "def", "_check_token_present", "(", "self", ")", ":", "try", ":", "self", ".", "_get_value", "(", "CONFIGKEY_TOKEN", ")", "self", ".", "_get_value", "(", "CONFIGKEY_REFRESH_TOKEN", ")", "self", ".", "_get_value", "(", "CONFIGKEY_REFRESHABLE", ")", "except", "Key...
ca0a2d4d7eefcc681aac92c9cd4b83cd9ea6c5fe
test
OAuth2Util.set_access_credentials
Set the token on the Reddit Object again
OAuth2Util/OAuth2Util.py
def set_access_credentials(self, _retry=0): """ Set the token on the Reddit Object again """ if _retry >= 5: raise ConnectionAbortedError('Reddit is not accessible right now, cannot refresh OAuth2 tokens.') self._check_token_present() try: self.r.set_access_credentials(self._get_value(CONFIGKEY_SCOP...
def set_access_credentials(self, _retry=0): """ Set the token on the Reddit Object again """ if _retry >= 5: raise ConnectionAbortedError('Reddit is not accessible right now, cannot refresh OAuth2 tokens.') self._check_token_present() try: self.r.set_access_credentials(self._get_value(CONFIGKEY_SCOP...
[ "Set", "the", "token", "on", "the", "Reddit", "Object", "again" ]
SmBe19/praw-OAuth2Util
python
https://github.com/SmBe19/praw-OAuth2Util/blob/ca0a2d4d7eefcc681aac92c9cd4b83cd9ea6c5fe/OAuth2Util/OAuth2Util.py#L296-L316
[ "def", "set_access_credentials", "(", "self", ",", "_retry", "=", "0", ")", ":", "if", "_retry", ">=", "5", ":", "raise", "ConnectionAbortedError", "(", "'Reddit is not accessible right now, cannot refresh OAuth2 tokens.'", ")", "self", ".", "_check_token_present", "(",...
ca0a2d4d7eefcc681aac92c9cd4b83cd9ea6c5fe
test
OAuth2Util.refresh
Check if the token is still valid and requests a new if it is not valid anymore Call this method before a call to praw if there might have passed more than one hour force: if true, a new token will be retrieved no matter what
OAuth2Util/OAuth2Util.py
def refresh(self, force=False, _retry=0): """ Check if the token is still valid and requests a new if it is not valid anymore Call this method before a call to praw if there might have passed more than one hour force: if true, a new token will be retrieved no matter what """ if _retry >= 5: raise C...
def refresh(self, force=False, _retry=0): """ Check if the token is still valid and requests a new if it is not valid anymore Call this method before a call to praw if there might have passed more than one hour force: if true, a new token will be retrieved no matter what """ if _retry >= 5: raise C...
[ "Check", "if", "the", "token", "is", "still", "valid", "and", "requests", "a", "new", "if", "it", "is", "not", "valid", "anymore" ]
SmBe19/praw-OAuth2Util
python
https://github.com/SmBe19/praw-OAuth2Util/blob/ca0a2d4d7eefcc681aac92c9cd4b83cd9ea6c5fe/OAuth2Util/OAuth2Util.py#L320-L356
[ "def", "refresh", "(", "self", ",", "force", "=", "False", ",", "_retry", "=", "0", ")", ":", "if", "_retry", ">=", "5", ":", "raise", "ConnectionAbortedError", "(", "'Reddit is not accessible right now, cannot refresh OAuth2 tokens.'", ")", "self", ".", "_check_t...
ca0a2d4d7eefcc681aac92c9cd4b83cd9ea6c5fe
test
create_manifest_table
Create DynamoDB table for run manifests Arguments: dynamodb_client - boto3 DynamoDB client (not service) table_name - string representing existing table name
snowplow_analytics_sdk/run_manifests.py
def create_manifest_table(dynamodb_client, table_name): """Create DynamoDB table for run manifests Arguments: dynamodb_client - boto3 DynamoDB client (not service) table_name - string representing existing table name """ try: dynamodb_client.create_table( AttributeDefinition...
def create_manifest_table(dynamodb_client, table_name): """Create DynamoDB table for run manifests Arguments: dynamodb_client - boto3 DynamoDB client (not service) table_name - string representing existing table name """ try: dynamodb_client.create_table( AttributeDefinition...
[ "Create", "DynamoDB", "table", "for", "run", "manifests" ]
snowplow/snowplow-python-analytics-sdk
python
https://github.com/snowplow/snowplow-python-analytics-sdk/blob/0ddca91e3f6d8bed88627fa557790aa4868bdace/snowplow_analytics_sdk/run_manifests.py#L38-L71
[ "def", "create_manifest_table", "(", "dynamodb_client", ",", "table_name", ")", ":", "try", ":", "dynamodb_client", ".", "create_table", "(", "AttributeDefinitions", "=", "[", "{", "'AttributeName'", ":", "DYNAMODB_RUNID_ATTRIBUTE", ",", "'AttributeType'", ":", "'S'",...
0ddca91e3f6d8bed88627fa557790aa4868bdace
test
list_runids
Return list of all run ids inside S3 folder. It does not respect S3 pagination (`MaxKeys`) and returns **all** keys from bucket and won't list any prefixes with object archived to AWS Glacier Arguments: s3_client - boto3 S3 client (not service) full_path - full valid S3 path to events (such as enri...
snowplow_analytics_sdk/run_manifests.py
def list_runids(s3_client, full_path): """Return list of all run ids inside S3 folder. It does not respect S3 pagination (`MaxKeys`) and returns **all** keys from bucket and won't list any prefixes with object archived to AWS Glacier Arguments: s3_client - boto3 S3 client (not service) full_pat...
def list_runids(s3_client, full_path): """Return list of all run ids inside S3 folder. It does not respect S3 pagination (`MaxKeys`) and returns **all** keys from bucket and won't list any prefixes with object archived to AWS Glacier Arguments: s3_client - boto3 S3 client (not service) full_pat...
[ "Return", "list", "of", "all", "run", "ids", "inside", "S3", "folder", ".", "It", "does", "not", "respect", "S3", "pagination", "(", "MaxKeys", ")", "and", "returns", "**", "all", "**", "keys", "from", "bucket", "and", "won", "t", "list", "any", "prefi...
snowplow/snowplow-python-analytics-sdk
python
https://github.com/snowplow/snowplow-python-analytics-sdk/blob/0ddca91e3f6d8bed88627fa557790aa4868bdace/snowplow_analytics_sdk/run_manifests.py#L74-L109
[ "def", "list_runids", "(", "s3_client", ",", "full_path", ")", ":", "listing_finished", "=", "False", "# last response was not truncated", "run_ids_buffer", "=", "[", "]", "last_continuation_token", "=", "None", "(", "bucket", ",", "prefix", ")", "=", "split_full_pa...
0ddca91e3f6d8bed88627fa557790aa4868bdace
test
split_full_path
Return pair of bucket without protocol and path Arguments: path - valid S3 path, such as s3://somebucket/events >>> split_full_path('s3://mybucket/path-to-events') ('mybucket', 'path-to-events/') >>> split_full_path('s3://mybucket') ('mybucket', None) >>> split_full_path('s3n://snowplow-bu...
snowplow_analytics_sdk/run_manifests.py
def split_full_path(path): """Return pair of bucket without protocol and path Arguments: path - valid S3 path, such as s3://somebucket/events >>> split_full_path('s3://mybucket/path-to-events') ('mybucket', 'path-to-events/') >>> split_full_path('s3://mybucket') ('mybucket', None) >>> ...
def split_full_path(path): """Return pair of bucket without protocol and path Arguments: path - valid S3 path, such as s3://somebucket/events >>> split_full_path('s3://mybucket/path-to-events') ('mybucket', 'path-to-events/') >>> split_full_path('s3://mybucket') ('mybucket', None) >>> ...
[ "Return", "pair", "of", "bucket", "without", "protocol", "and", "path" ]
snowplow/snowplow-python-analytics-sdk
python
https://github.com/snowplow/snowplow-python-analytics-sdk/blob/0ddca91e3f6d8bed88627fa557790aa4868bdace/snowplow_analytics_sdk/run_manifests.py#L112-L137
[ "def", "split_full_path", "(", "path", ")", ":", "if", "path", ".", "startswith", "(", "'s3://'", ")", ":", "path", "=", "path", "[", "5", ":", "]", "elif", "path", ".", "startswith", "(", "'s3n://'", ")", ":", "path", "=", "path", "[", "6", ":", ...
0ddca91e3f6d8bed88627fa557790aa4868bdace
test
is_glacier
Check if prefix is archived in Glacier, by checking storage class of first object inside that prefix Arguments: s3_client - boto3 S3 client (not service) bucket - valid extracted bucket (without protocol and prefix) example: sowplow-events-data prefix - valid S3 prefix (usually, run_id...
snowplow_analytics_sdk/run_manifests.py
def is_glacier(s3_client, bucket, prefix): """Check if prefix is archived in Glacier, by checking storage class of first object inside that prefix Arguments: s3_client - boto3 S3 client (not service) bucket - valid extracted bucket (without protocol and prefix) example: sowplow-events-...
def is_glacier(s3_client, bucket, prefix): """Check if prefix is archived in Glacier, by checking storage class of first object inside that prefix Arguments: s3_client - boto3 S3 client (not service) bucket - valid extracted bucket (without protocol and prefix) example: sowplow-events-...
[ "Check", "if", "prefix", "is", "archived", "in", "Glacier", "by", "checking", "storage", "class", "of", "first", "object", "inside", "that", "prefix" ]
snowplow/snowplow-python-analytics-sdk
python
https://github.com/snowplow/snowplow-python-analytics-sdk/blob/0ddca91e3f6d8bed88627fa557790aa4868bdace/snowplow_analytics_sdk/run_manifests.py#L140-L158
[ "def", "is_glacier", "(", "s3_client", ",", "bucket", ",", "prefix", ")", ":", "response", "=", "s3_client", ".", "list_objects_v2", "(", "Bucket", "=", "bucket", ",", "Prefix", "=", "prefix", ",", "MaxKeys", "=", "3", ")", "# 3 to not fetch _SUCCESS", "for"...
0ddca91e3f6d8bed88627fa557790aa4868bdace
test
extract_run_id
Extract date part from run id Arguments: key - full key name, such as shredded-archive/run=2012-12-11-01-31-33/ (trailing slash is required) >>> extract_run_id('shredded-archive/run=2012-12-11-01-11-33/') 'shredded-archive/run=2012-12-11-01-11-33/' >>> extract_run_id('shredded-archive/ru...
snowplow_analytics_sdk/run_manifests.py
def extract_run_id(key): """Extract date part from run id Arguments: key - full key name, such as shredded-archive/run=2012-12-11-01-31-33/ (trailing slash is required) >>> extract_run_id('shredded-archive/run=2012-12-11-01-11-33/') 'shredded-archive/run=2012-12-11-01-11-33/' >>> ext...
def extract_run_id(key): """Extract date part from run id Arguments: key - full key name, such as shredded-archive/run=2012-12-11-01-31-33/ (trailing slash is required) >>> extract_run_id('shredded-archive/run=2012-12-11-01-11-33/') 'shredded-archive/run=2012-12-11-01-11-33/' >>> ext...
[ "Extract", "date", "part", "from", "run", "id" ]
snowplow/snowplow-python-analytics-sdk
python
https://github.com/snowplow/snowplow-python-analytics-sdk/blob/0ddca91e3f6d8bed88627fa557790aa4868bdace/snowplow_analytics_sdk/run_manifests.py#L161-L179
[ "def", "extract_run_id", "(", "key", ")", ":", "filename", "=", "key", ".", "split", "(", "'/'", ")", "[", "-", "2", "]", "# -1 element is empty string", "run_id", "=", "filename", ".", "lstrip", "(", "'run='", ")", "try", ":", "datetime", ".", "strptime...
0ddca91e3f6d8bed88627fa557790aa4868bdace
test
clean_dict
Remove all keys with Nones as values >>> clean_dict({'key': None}) {} >>> clean_dict({'empty_s': ''}) {'empty_s': ''}
snowplow_analytics_sdk/run_manifests.py
def clean_dict(dict): """Remove all keys with Nones as values >>> clean_dict({'key': None}) {} >>> clean_dict({'empty_s': ''}) {'empty_s': ''} """ if sys.version_info[0] < 3: return {k: v for k, v in dict.iteritems() if v is not None} else: return {k: v for k, v in dict....
def clean_dict(dict): """Remove all keys with Nones as values >>> clean_dict({'key': None}) {} >>> clean_dict({'empty_s': ''}) {'empty_s': ''} """ if sys.version_info[0] < 3: return {k: v for k, v in dict.iteritems() if v is not None} else: return {k: v for k, v in dict....
[ "Remove", "all", "keys", "with", "Nones", "as", "values" ]
snowplow/snowplow-python-analytics-sdk
python
https://github.com/snowplow/snowplow-python-analytics-sdk/blob/0ddca91e3f6d8bed88627fa557790aa4868bdace/snowplow_analytics_sdk/run_manifests.py#L198-L209
[ "def", "clean_dict", "(", "dict", ")", ":", "if", "sys", ".", "version_info", "[", "0", "]", "<", "3", ":", "return", "{", "k", ":", "v", "for", "k", ",", "v", "in", "dict", ".", "iteritems", "(", ")", "if", "v", "is", "not", "None", "}", "el...
0ddca91e3f6d8bed88627fa557790aa4868bdace
test
add_to_manifest
Add run_id into DynamoDB manifest table Arguments: dynamodb_client - boto3 DynamoDB client (not service) table_name - string representing existing table name run_id - string representing run_id to store
snowplow_analytics_sdk/run_manifests.py
def add_to_manifest(dynamodb_client, table_name, run_id): """Add run_id into DynamoDB manifest table Arguments: dynamodb_client - boto3 DynamoDB client (not service) table_name - string representing existing table name run_id - string representing run_id to store """ dynamodb_client.put_ite...
def add_to_manifest(dynamodb_client, table_name, run_id): """Add run_id into DynamoDB manifest table Arguments: dynamodb_client - boto3 DynamoDB client (not service) table_name - string representing existing table name run_id - string representing run_id to store """ dynamodb_client.put_ite...
[ "Add", "run_id", "into", "DynamoDB", "manifest", "table" ]
snowplow/snowplow-python-analytics-sdk
python
https://github.com/snowplow/snowplow-python-analytics-sdk/blob/0ddca91e3f6d8bed88627fa557790aa4868bdace/snowplow_analytics_sdk/run_manifests.py#L212-L227
[ "def", "add_to_manifest", "(", "dynamodb_client", ",", "table_name", ",", "run_id", ")", ":", "dynamodb_client", ".", "put_item", "(", "TableName", "=", "table_name", ",", "Item", "=", "{", "DYNAMODB_RUNID_ATTRIBUTE", ":", "{", "'S'", ":", "run_id", "}", "}", ...
0ddca91e3f6d8bed88627fa557790aa4868bdace
test
is_in_manifest
Check if run_id is stored in DynamoDB table. Return True if run_id is stored or False otherwise. Arguments: dynamodb_client - boto3 DynamoDB client (not service) table_name - string representing existing table name run_id - string representing run_id to store
snowplow_analytics_sdk/run_manifests.py
def is_in_manifest(dynamodb_client, table_name, run_id): """Check if run_id is stored in DynamoDB table. Return True if run_id is stored or False otherwise. Arguments: dynamodb_client - boto3 DynamoDB client (not service) table_name - string representing existing table name run_id - string repr...
def is_in_manifest(dynamodb_client, table_name, run_id): """Check if run_id is stored in DynamoDB table. Return True if run_id is stored or False otherwise. Arguments: dynamodb_client - boto3 DynamoDB client (not service) table_name - string representing existing table name run_id - string repr...
[ "Check", "if", "run_id", "is", "stored", "in", "DynamoDB", "table", ".", "Return", "True", "if", "run_id", "is", "stored", "or", "False", "otherwise", "." ]
snowplow/snowplow-python-analytics-sdk
python
https://github.com/snowplow/snowplow-python-analytics-sdk/blob/0ddca91e3f6d8bed88627fa557790aa4868bdace/snowplow_analytics_sdk/run_manifests.py#L230-L247
[ "def", "is_in_manifest", "(", "dynamodb_client", ",", "table_name", ",", "run_id", ")", ":", "response", "=", "dynamodb_client", ".", "get_item", "(", "TableName", "=", "table_name", ",", "Key", "=", "{", "DYNAMODB_RUNID_ATTRIBUTE", ":", "{", "'S'", ":", "run_...
0ddca91e3f6d8bed88627fa557790aa4868bdace
test
extract_schema
Extracts Schema information from Iglu URI >>> extract_schema("iglu:com.acme-corporation_underscore/event_name-dash/jsonschema/1-10-1")['vendor'] 'com.acme-corporation_underscore'
snowplow_analytics_sdk/json_shredder.py
def extract_schema(uri): """ Extracts Schema information from Iglu URI >>> extract_schema("iglu:com.acme-corporation_underscore/event_name-dash/jsonschema/1-10-1")['vendor'] 'com.acme-corporation_underscore' """ match = re.match(SCHEMA_URI_REGEX, uri) if match: return { ...
def extract_schema(uri): """ Extracts Schema information from Iglu URI >>> extract_schema("iglu:com.acme-corporation_underscore/event_name-dash/jsonschema/1-10-1")['vendor'] 'com.acme-corporation_underscore' """ match = re.match(SCHEMA_URI_REGEX, uri) if match: return { ...
[ "Extracts", "Schema", "information", "from", "Iglu", "URI" ]
snowplow/snowplow-python-analytics-sdk
python
https://github.com/snowplow/snowplow-python-analytics-sdk/blob/0ddca91e3f6d8bed88627fa557790aa4868bdace/snowplow_analytics_sdk/json_shredder.py#L37-L56
[ "def", "extract_schema", "(", "uri", ")", ":", "match", "=", "re", ".", "match", "(", "SCHEMA_URI_REGEX", ",", "uri", ")", "if", "match", ":", "return", "{", "'vendor'", ":", "match", ".", "group", "(", "1", ")", ",", "'name'", ":", "match", ".", "...
0ddca91e3f6d8bed88627fa557790aa4868bdace
test
fix_schema
Create an Elasticsearch field name from a schema string
snowplow_analytics_sdk/json_shredder.py
def fix_schema(prefix, schema): """ Create an Elasticsearch field name from a schema string """ schema_dict = extract_schema(schema) snake_case_organization = schema_dict['vendor'].replace('.', '_').lower() snake_case_name = re.sub('([^A-Z_])([A-Z])', '\g<1>_\g<2>', schema_dict['name']).lower() ...
def fix_schema(prefix, schema): """ Create an Elasticsearch field name from a schema string """ schema_dict = extract_schema(schema) snake_case_organization = schema_dict['vendor'].replace('.', '_').lower() snake_case_name = re.sub('([^A-Z_])([A-Z])', '\g<1>_\g<2>', schema_dict['name']).lower() ...
[ "Create", "an", "Elasticsearch", "field", "name", "from", "a", "schema", "string" ]
snowplow/snowplow-python-analytics-sdk
python
https://github.com/snowplow/snowplow-python-analytics-sdk/blob/0ddca91e3f6d8bed88627fa557790aa4868bdace/snowplow_analytics_sdk/json_shredder.py#L59-L67
[ "def", "fix_schema", "(", "prefix", ",", "schema", ")", ":", "schema_dict", "=", "extract_schema", "(", "schema", ")", "snake_case_organization", "=", "schema_dict", "[", "'vendor'", "]", ".", "replace", "(", "'.'", ",", "'_'", ")", ".", "lower", "(", ")",...
0ddca91e3f6d8bed88627fa557790aa4868bdace
test
parse_contexts
Convert a contexts JSON to an Elasticsearch-compatible list of key-value pairs For example, the JSON { "data": [ { "data": { "unique": true }, "schema": "iglu:com.acme/unduplicated/jsonschema/1-0-0" }, { "data": { "va...
snowplow_analytics_sdk/json_shredder.py
def parse_contexts(contexts): """ Convert a contexts JSON to an Elasticsearch-compatible list of key-value pairs For example, the JSON { "data": [ { "data": { "unique": true }, "schema": "iglu:com.acme/unduplicated/jsonschema/1-0-0" }, ...
def parse_contexts(contexts): """ Convert a contexts JSON to an Elasticsearch-compatible list of key-value pairs For example, the JSON { "data": [ { "data": { "unique": true }, "schema": "iglu:com.acme/unduplicated/jsonschema/1-0-0" }, ...
[ "Convert", "a", "contexts", "JSON", "to", "an", "Elasticsearch", "-", "compatible", "list", "of", "key", "-", "value", "pairs", "For", "example", "the", "JSON" ]
snowplow/snowplow-python-analytics-sdk
python
https://github.com/snowplow/snowplow-python-analytics-sdk/blob/0ddca91e3f6d8bed88627fa557790aa4868bdace/snowplow_analytics_sdk/json_shredder.py#L70-L119
[ "def", "parse_contexts", "(", "contexts", ")", ":", "my_json", "=", "json", ".", "loads", "(", "contexts", ")", "data", "=", "my_json", "[", "'data'", "]", "distinct_contexts", "=", "{", "}", "for", "context", "in", "data", ":", "schema", "=", "fix_schem...
0ddca91e3f6d8bed88627fa557790aa4868bdace
test
parse_unstruct
Convert an unstructured event JSON to a list containing one Elasticsearch-compatible key-value pair For example, the JSON { "data": { "data": { "key": "value" }, "schema": "iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-1" }, "schema": "iglu:co...
snowplow_analytics_sdk/json_shredder.py
def parse_unstruct(unstruct): """ Convert an unstructured event JSON to a list containing one Elasticsearch-compatible key-value pair For example, the JSON { "data": { "data": { "key": "value" }, "schema": "iglu:com.snowplowanalytics.snowplow/link_click/jsonschem...
def parse_unstruct(unstruct): """ Convert an unstructured event JSON to a list containing one Elasticsearch-compatible key-value pair For example, the JSON { "data": { "data": { "key": "value" }, "schema": "iglu:com.snowplowanalytics.snowplow/link_click/jsonschem...
[ "Convert", "an", "unstructured", "event", "JSON", "to", "a", "list", "containing", "one", "Elasticsearch", "-", "compatible", "key", "-", "value", "pair", "For", "example", "the", "JSON" ]
snowplow/snowplow-python-analytics-sdk
python
https://github.com/snowplow/snowplow-python-analytics-sdk/blob/0ddca91e3f6d8bed88627fa557790aa4868bdace/snowplow_analytics_sdk/json_shredder.py#L122-L155
[ "def", "parse_unstruct", "(", "unstruct", ")", ":", "my_json", "=", "json", ".", "loads", "(", "unstruct", ")", "data", "=", "my_json", "[", "'data'", "]", "schema", "=", "data", "[", "'schema'", "]", "if", "'data'", "in", "data", ":", "inner_data", "=...
0ddca91e3f6d8bed88627fa557790aa4868bdace
test
transform
Convert a Snowplow enriched event TSV into a JSON
snowplow_analytics_sdk/event_transformer.py
def transform(line, known_fields=ENRICHED_EVENT_FIELD_TYPES, add_geolocation_data=True): """ Convert a Snowplow enriched event TSV into a JSON """ return jsonify_good_event(line.split('\t'), known_fields, add_geolocation_data)
def transform(line, known_fields=ENRICHED_EVENT_FIELD_TYPES, add_geolocation_data=True): """ Convert a Snowplow enriched event TSV into a JSON """ return jsonify_good_event(line.split('\t'), known_fields, add_geolocation_data)
[ "Convert", "a", "Snowplow", "enriched", "event", "TSV", "into", "a", "JSON" ]
snowplow/snowplow-python-analytics-sdk
python
https://github.com/snowplow/snowplow-python-analytics-sdk/blob/0ddca91e3f6d8bed88627fa557790aa4868bdace/snowplow_analytics_sdk/event_transformer.py#L192-L196
[ "def", "transform", "(", "line", ",", "known_fields", "=", "ENRICHED_EVENT_FIELD_TYPES", ",", "add_geolocation_data", "=", "True", ")", ":", "return", "jsonify_good_event", "(", "line", ".", "split", "(", "'\\t'", ")", ",", "known_fields", ",", "add_geolocation_da...
0ddca91e3f6d8bed88627fa557790aa4868bdace
test
jsonify_good_event
Convert a Snowplow enriched event in the form of an array of fields into a JSON
snowplow_analytics_sdk/event_transformer.py
def jsonify_good_event(event, known_fields=ENRICHED_EVENT_FIELD_TYPES, add_geolocation_data=True): """ Convert a Snowplow enriched event in the form of an array of fields into a JSON """ if len(event) != len(known_fields): raise SnowplowEventTransformationException( ["Expected {} fie...
def jsonify_good_event(event, known_fields=ENRICHED_EVENT_FIELD_TYPES, add_geolocation_data=True): """ Convert a Snowplow enriched event in the form of an array of fields into a JSON """ if len(event) != len(known_fields): raise SnowplowEventTransformationException( ["Expected {} fie...
[ "Convert", "a", "Snowplow", "enriched", "event", "in", "the", "form", "of", "an", "array", "of", "fields", "into", "a", "JSON" ]
snowplow/snowplow-python-analytics-sdk
python
https://github.com/snowplow/snowplow-python-analytics-sdk/blob/0ddca91e3f6d8bed88627fa557790aa4868bdace/snowplow_analytics_sdk/event_transformer.py#L199-L230
[ "def", "jsonify_good_event", "(", "event", ",", "known_fields", "=", "ENRICHED_EVENT_FIELD_TYPES", ",", "add_geolocation_data", "=", "True", ")", ":", "if", "len", "(", "event", ")", "!=", "len", "(", "known_fields", ")", ":", "raise", "SnowplowEventTransformation...
0ddca91e3f6d8bed88627fa557790aa4868bdace
test
ViewPanel._get_view_data
Extract the used view from the TemplateResponse context (ContextMixin)
debugtools/panels/view.py
def _get_view_data(self, context_data): """ Extract the used view from the TemplateResponse context (ContextMixin) """ view = context_data.get('view') if not isinstance(view, View): view = None # Denote interesting objects in the template context temp...
def _get_view_data(self, context_data): """ Extract the used view from the TemplateResponse context (ContextMixin) """ view = context_data.get('view') if not isinstance(view, View): view = None # Denote interesting objects in the template context temp...
[ "Extract", "the", "used", "view", "from", "the", "TemplateResponse", "context", "(", "ContextMixin", ")" ]
edoburu/django-debugtools
python
https://github.com/edoburu/django-debugtools/blob/5c609c00fa9954330cd135fc62a1e18b8e7fea8a/debugtools/panels/view.py#L47-L65
[ "def", "_get_view_data", "(", "self", ",", "context_data", ")", ":", "view", "=", "context_data", ".", "get", "(", "'view'", ")", "if", "not", "isinstance", "(", "view", ",", "View", ")", ":", "view", "=", "None", "# Denote interesting objects in the template ...
5c609c00fa9954330cd135fc62a1e18b8e7fea8a
test
get_used_template
Get the template used in a TemplateResponse. This returns a tuple of "active choice, all choices"
debugtools/utils/xview.py
def get_used_template(response): """ Get the template used in a TemplateResponse. This returns a tuple of "active choice, all choices" """ if not hasattr(response, 'template_name'): return None, None template = response.template_name if template is None: return None, None ...
def get_used_template(response): """ Get the template used in a TemplateResponse. This returns a tuple of "active choice, all choices" """ if not hasattr(response, 'template_name'): return None, None template = response.template_name if template is None: return None, None ...
[ "Get", "the", "template", "used", "in", "a", "TemplateResponse", ".", "This", "returns", "a", "tuple", "of", "active", "choice", "all", "choices" ]
edoburu/django-debugtools
python
https://github.com/edoburu/django-debugtools/blob/5c609c00fa9954330cd135fc62a1e18b8e7fea8a/debugtools/utils/xview.py#L29-L55
[ "def", "get_used_template", "(", "response", ")", ":", "if", "not", "hasattr", "(", "response", ",", "'template_name'", ")", ":", "return", "None", ",", "None", "template", "=", "response", ".", "template_name", "if", "template", "is", "None", ":", "return",...
5c609c00fa9954330cd135fc62a1e18b8e7fea8a
test
PrintNode.print_context
Print the entire template context
debugtools/templatetags/debugtools_tags.py
def print_context(self, context): """ Print the entire template context """ text = [CONTEXT_TITLE] for i, context_scope in enumerate(context): dump1 = linebreaksbr(pformat_django_context_html(context_scope)) dump2 = pformat_dict_summary_html(context_scope)...
def print_context(self, context): """ Print the entire template context """ text = [CONTEXT_TITLE] for i, context_scope in enumerate(context): dump1 = linebreaksbr(pformat_django_context_html(context_scope)) dump2 = pformat_dict_summary_html(context_scope)...
[ "Print", "the", "entire", "template", "context" ]
edoburu/django-debugtools
python
https://github.com/edoburu/django-debugtools/blob/5c609c00fa9954330cd135fc62a1e18b8e7fea8a/debugtools/templatetags/debugtools_tags.py#L64-L83
[ "def", "print_context", "(", "self", ",", "context", ")", ":", "text", "=", "[", "CONTEXT_TITLE", "]", "for", "i", ",", "context_scope", "in", "enumerate", "(", "context", ")", ":", "dump1", "=", "linebreaksbr", "(", "pformat_django_context_html", "(", "cont...
5c609c00fa9954330cd135fc62a1e18b8e7fea8a
test
PrintNode.print_variables
Print a set of variables
debugtools/templatetags/debugtools_tags.py
def print_variables(self, context): """ Print a set of variables """ text = [] for name, expr in self.variables: # Some extended resolving, to handle unknown variables data = '' try: if isinstance(expr.var, Variable): ...
def print_variables(self, context): """ Print a set of variables """ text = [] for name, expr in self.variables: # Some extended resolving, to handle unknown variables data = '' try: if isinstance(expr.var, Variable): ...
[ "Print", "a", "set", "of", "variables" ]
edoburu/django-debugtools
python
https://github.com/edoburu/django-debugtools/blob/5c609c00fa9954330cd135fc62a1e18b8e7fea8a/debugtools/templatetags/debugtools_tags.py#L85-L114
[ "def", "print_variables", "(", "self", ",", "context", ")", ":", "text", "=", "[", "]", "for", "name", ",", "expr", "in", "self", ".", "variables", ":", "# Some extended resolving, to handle unknown variables", "data", "=", "''", "try", ":", "if", "isinstance"...
5c609c00fa9954330cd135fc62a1e18b8e7fea8a
test
pformat_sql_html
Highlight common SQL words in a string.
debugtools/formatter.py
def pformat_sql_html(sql): """ Highlight common SQL words in a string. """ sql = escape(sql) sql = RE_SQL_NL.sub(u'<br>\n\\1', sql) sql = RE_SQL.sub(u'<strong>\\1</strong>', sql) return sql
def pformat_sql_html(sql): """ Highlight common SQL words in a string. """ sql = escape(sql) sql = RE_SQL_NL.sub(u'<br>\n\\1', sql) sql = RE_SQL.sub(u'<strong>\\1</strong>', sql) return sql
[ "Highlight", "common", "SQL", "words", "in", "a", "string", "." ]
edoburu/django-debugtools
python
https://github.com/edoburu/django-debugtools/blob/5c609c00fa9954330cd135fc62a1e18b8e7fea8a/debugtools/formatter.py#L52-L59
[ "def", "pformat_sql_html", "(", "sql", ")", ":", "sql", "=", "escape", "(", "sql", ")", "sql", "=", "RE_SQL_NL", ".", "sub", "(", "u'<br>\\n\\\\1'", ",", "sql", ")", "sql", "=", "RE_SQL", ".", "sub", "(", "u'<strong>\\\\1</strong>'", ",", "sql", ")", "...
5c609c00fa9954330cd135fc62a1e18b8e7fea8a
test
pformat_django_context_html
Dump a variable to a HTML string with sensible output for template context fields. It filters out all fields which are not usable in a template context.
debugtools/formatter.py
def pformat_django_context_html(object): """ Dump a variable to a HTML string with sensible output for template context fields. It filters out all fields which are not usable in a template context. """ if isinstance(object, QuerySet): text = '' lineno = 0 for item in object.a...
def pformat_django_context_html(object): """ Dump a variable to a HTML string with sensible output for template context fields. It filters out all fields which are not usable in a template context. """ if isinstance(object, QuerySet): text = '' lineno = 0 for item in object.a...
[ "Dump", "a", "variable", "to", "a", "HTML", "string", "with", "sensible", "output", "for", "template", "context", "fields", ".", "It", "filters", "out", "all", "fields", "which", "are", "not", "usable", "in", "a", "template", "context", "." ]
edoburu/django-debugtools
python
https://github.com/edoburu/django-debugtools/blob/5c609c00fa9954330cd135fc62a1e18b8e7fea8a/debugtools/formatter.py#L62-L94
[ "def", "pformat_django_context_html", "(", "object", ")", ":", "if", "isinstance", "(", "object", ",", "QuerySet", ")", ":", "text", "=", "''", "lineno", "=", "0", "for", "item", "in", "object", ".", "all", "(", ")", "[", ":", "21", "]", ":", "lineno...
5c609c00fa9954330cd135fc62a1e18b8e7fea8a
test
pformat_dict_summary_html
Briefly print the dictionary keys.
debugtools/formatter.py
def pformat_dict_summary_html(dict): """ Briefly print the dictionary keys. """ if not dict: return ' {}' html = [] for key, value in sorted(six.iteritems(dict)): if not isinstance(value, DICT_EXPANDED_TYPES): value = '...' html.append(_format_dict_item(ke...
def pformat_dict_summary_html(dict): """ Briefly print the dictionary keys. """ if not dict: return ' {}' html = [] for key, value in sorted(six.iteritems(dict)): if not isinstance(value, DICT_EXPANDED_TYPES): value = '...' html.append(_format_dict_item(ke...
[ "Briefly", "print", "the", "dictionary", "keys", "." ]
edoburu/django-debugtools
python
https://github.com/edoburu/django-debugtools/blob/5c609c00fa9954330cd135fc62a1e18b8e7fea8a/debugtools/formatter.py#L97-L111
[ "def", "pformat_dict_summary_html", "(", "dict", ")", ":", "if", "not", "dict", ":", "return", "' {}'", "html", "=", "[", "]", "for", "key", ",", "value", "in", "sorted", "(", "six", ".", "iteritems", "(", "dict", ")", ")", ":", "if", "not", "isins...
5c609c00fa9954330cd135fc62a1e18b8e7fea8a
test
_style_text
Apply some HTML highlighting to the contents. This can't be done in the
debugtools/formatter.py
def _style_text(text): """ Apply some HTML highlighting to the contents. This can't be done in the """ # Escape text and apply some formatting. # To have really good highlighting, pprint would have to be re-implemented. text = escape(text) text = text.replace(' &lt;iterator object&gt;', ...
def _style_text(text): """ Apply some HTML highlighting to the contents. This can't be done in the """ # Escape text and apply some formatting. # To have really good highlighting, pprint would have to be re-implemented. text = escape(text) text = text.replace(' &lt;iterator object&gt;', ...
[ "Apply", "some", "HTML", "highlighting", "to", "the", "contents", ".", "This", "can", "t", "be", "done", "in", "the" ]
edoburu/django-debugtools
python
https://github.com/edoburu/django-debugtools/blob/5c609c00fa9954330cd135fc62a1e18b8e7fea8a/debugtools/formatter.py#L129-L152
[ "def", "_style_text", "(", "text", ")", ":", "# Escape text and apply some formatting.", "# To have really good highlighting, pprint would have to be re-implemented.", "text", "=", "escape", "(", "text", ")", "text", "=", "text", ".", "replace", "(", "' &lt;iterator object&gt...
5c609c00fa9954330cd135fc62a1e18b8e7fea8a
test
_format_object
# Instead of just printing <SomeType at 0xfoobar>, expand the fields.
debugtools/formatter.py
def _format_object(object): """ # Instead of just printing <SomeType at 0xfoobar>, expand the fields. """ attrs = iter(object.__dict__.items()) if object.__class__: # Add class members too. attrs = chain(attrs, iter(object.__class__.__dict__.items())) # Remove private and prote...
def _format_object(object): """ # Instead of just printing <SomeType at 0xfoobar>, expand the fields. """ attrs = iter(object.__dict__.items()) if object.__class__: # Add class members too. attrs = chain(attrs, iter(object.__class__.__dict__.items())) # Remove private and prote...
[ "#", "Instead", "of", "just", "printing", "<SomeType", "at", "0xfoobar", ">", "expand", "the", "fields", "." ]
edoburu/django-debugtools
python
https://github.com/edoburu/django-debugtools/blob/5c609c00fa9954330cd135fc62a1e18b8e7fea8a/debugtools/formatter.py#L155-L246
[ "def", "_format_object", "(", "object", ")", ":", "attrs", "=", "iter", "(", "object", ".", "__dict__", ".", "items", "(", ")", ")", "if", "object", ".", "__class__", ":", "# Add class members too.", "attrs", "=", "chain", "(", "attrs", ",", "iter", "(",...
5c609c00fa9954330cd135fc62a1e18b8e7fea8a
test
_format_lazy
Expand a _("TEST") call to something meaningful.
debugtools/formatter.py
def _format_lazy(value): """ Expand a _("TEST") call to something meaningful. """ args = value._proxy____args kw = value._proxy____kw if not kw and len(args) == 1 and isinstance(args[0], six.string_types): # Found one of the Xgettext_lazy() calls. return LiteralStr(u'ugettext_laz...
def _format_lazy(value): """ Expand a _("TEST") call to something meaningful. """ args = value._proxy____args kw = value._proxy____kw if not kw and len(args) == 1 and isinstance(args[0], six.string_types): # Found one of the Xgettext_lazy() calls. return LiteralStr(u'ugettext_laz...
[ "Expand", "a", "_", "(", "TEST", ")", "call", "to", "something", "meaningful", "." ]
edoburu/django-debugtools
python
https://github.com/edoburu/django-debugtools/blob/5c609c00fa9954330cd135fc62a1e18b8e7fea8a/debugtools/formatter.py#L296-L307
[ "def", "_format_lazy", "(", "value", ")", ":", "args", "=", "value", ".", "_proxy____args", "kw", "=", "value", ".", "_proxy____kw", "if", "not", "kw", "and", "len", "(", "args", ")", "==", "1", "and", "isinstance", "(", "args", "[", "0", "]", ",", ...
5c609c00fa9954330cd135fc62a1e18b8e7fea8a
test
_try_call
Call a method, but :param func: :type func: :param extra_exceptions: :type extra_exceptions: :return: :rtype:
debugtools/formatter.py
def _try_call(func, extra_exceptions=(), return_exceptions=False): """ Call a method, but :param func: :type func: :param extra_exceptions: :type extra_exceptions: :return: :rtype: """ try: return func() except HANDLED_EXCEPTIONS as e: if return_exceptions: ...
def _try_call(func, extra_exceptions=(), return_exceptions=False): """ Call a method, but :param func: :type func: :param extra_exceptions: :type extra_exceptions: :return: :rtype: """ try: return func() except HANDLED_EXCEPTIONS as e: if return_exceptions: ...
[ "Call", "a", "method", "but", ":", "param", "func", ":", ":", "type", "func", ":", ":", "param", "extra_exceptions", ":", ":", "type", "extra_exceptions", ":", ":", "return", ":", ":", "rtype", ":" ]
edoburu/django-debugtools
python
https://github.com/edoburu/django-debugtools/blob/5c609c00fa9954330cd135fc62a1e18b8e7fea8a/debugtools/formatter.py#L326-L347
[ "def", "_try_call", "(", "func", ",", "extra_exceptions", "=", "(", ")", ",", "return_exceptions", "=", "False", ")", ":", "try", ":", "return", "func", "(", ")", "except", "HANDLED_EXCEPTIONS", "as", "e", ":", "if", "return_exceptions", ":", "return", "e"...
5c609c00fa9954330cd135fc62a1e18b8e7fea8a
test
DebugPrettyPrinter.format
Format an item in the result. Could be a dictionary key, value, etc..
debugtools/formatter.py
def format(self, object, context, maxlevels, level): """ Format an item in the result. Could be a dictionary key, value, etc.. """ try: return PrettyPrinter.format(self, object, context, maxlevels, level) except HANDLED_EXCEPTIONS as e: return _for...
def format(self, object, context, maxlevels, level): """ Format an item in the result. Could be a dictionary key, value, etc.. """ try: return PrettyPrinter.format(self, object, context, maxlevels, level) except HANDLED_EXCEPTIONS as e: return _for...
[ "Format", "an", "item", "in", "the", "result", ".", "Could", "be", "a", "dictionary", "key", "value", "etc", ".." ]
edoburu/django-debugtools
python
https://github.com/edoburu/django-debugtools/blob/5c609c00fa9954330cd135fc62a1e18b8e7fea8a/debugtools/formatter.py#L374-L382
[ "def", "format", "(", "self", ",", "object", ",", "context", ",", "maxlevels", ",", "level", ")", ":", "try", ":", "return", "PrettyPrinter", ".", "format", "(", "self", ",", "object", ",", "context", ",", "maxlevels", ",", "level", ")", "except", "HAN...
5c609c00fa9954330cd135fc62a1e18b8e7fea8a
test
DebugPrettyPrinter._format
Recursive part of the formatting
debugtools/formatter.py
def _format(self, object, stream, indent, allowance, context, level): """ Recursive part of the formatting """ try: PrettyPrinter._format(self, object, stream, indent, allowance, context, level) except Exception as e: stream.write(_format_exception(e))
def _format(self, object, stream, indent, allowance, context, level): """ Recursive part of the formatting """ try: PrettyPrinter._format(self, object, stream, indent, allowance, context, level) except Exception as e: stream.write(_format_exception(e))
[ "Recursive", "part", "of", "the", "formatting" ]
edoburu/django-debugtools
python
https://github.com/edoburu/django-debugtools/blob/5c609c00fa9954330cd135fc62a1e18b8e7fea8a/debugtools/formatter.py#L384-L391
[ "def", "_format", "(", "self", ",", "object", ",", "stream", ",", "indent", ",", "allowance", ",", "context", ",", "level", ")", ":", "try", ":", "PrettyPrinter", ".", "_format", "(", "self", ",", "object", ",", "stream", ",", "indent", ",", "allowance...
5c609c00fa9954330cd135fc62a1e18b8e7fea8a