repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
mlavin/argyle | argyle/supervisor.py | upload_supervisor_app_conf | def upload_supervisor_app_conf(app_name, template_name=None, context=None):
"""Upload Supervisor app configuration from a template."""
default = {'app_name': app_name}
context = context or {}
default.update(context)
template_name = template_name or [u'supervisor/%s.conf' % app_name, u'supervisor/ba... | python | def upload_supervisor_app_conf(app_name, template_name=None, context=None):
"""Upload Supervisor app configuration from a template."""
default = {'app_name': app_name}
context = context or {}
default.update(context)
template_name = template_name or [u'supervisor/%s.conf' % app_name, u'supervisor/ba... | [
"def",
"upload_supervisor_app_conf",
"(",
"app_name",
",",
"template_name",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"default",
"=",
"{",
"'app_name'",
":",
"app_name",
"}",
"context",
"=",
"context",
"or",
"{",
"}",
"default",
".",
"update",
"(... | Upload Supervisor app configuration from a template. | [
"Upload",
"Supervisor",
"app",
"configuration",
"from",
"a",
"template",
"."
] | train | https://github.com/mlavin/argyle/blob/92cc6e1dd9b8e7cb41c5098a79d05e14b8243d72/argyle/supervisor.py#L14-L23 |
mlavin/argyle | argyle/supervisor.py | remove_supervisor_app | def remove_supervisor_app(app_name):
"""Remove Supervisor app configuration."""
app = u'/etc/supervisor/conf.d/%s.conf' % app_name
if files.exists(app):
sudo(u'rm %s' % app)
supervisor_command(u'update') | python | def remove_supervisor_app(app_name):
"""Remove Supervisor app configuration."""
app = u'/etc/supervisor/conf.d/%s.conf' % app_name
if files.exists(app):
sudo(u'rm %s' % app)
supervisor_command(u'update') | [
"def",
"remove_supervisor_app",
"(",
"app_name",
")",
":",
"app",
"=",
"u'/etc/supervisor/conf.d/%s.conf'",
"%",
"app_name",
"if",
"files",
".",
"exists",
"(",
"app",
")",
":",
"sudo",
"(",
"u'rm %s'",
"%",
"app",
")",
"supervisor_command",
"(",
"u'update'",
"... | Remove Supervisor app configuration. | [
"Remove",
"Supervisor",
"app",
"configuration",
"."
] | train | https://github.com/mlavin/argyle/blob/92cc6e1dd9b8e7cb41c5098a79d05e14b8243d72/argyle/supervisor.py#L27-L33 |
mlavin/argyle | argyle/supervisor.py | upload_celery_conf | def upload_celery_conf(command='celeryd', app_name=None, template_name=None, context=None):
"""Upload Supervisor configuration for a celery command."""
app_name = app_name or command
default = {'app_name': app_name, 'command': command}
context = context or {}
default.update(context)
template_na... | python | def upload_celery_conf(command='celeryd', app_name=None, template_name=None, context=None):
"""Upload Supervisor configuration for a celery command."""
app_name = app_name or command
default = {'app_name': app_name, 'command': command}
context = context or {}
default.update(context)
template_na... | [
"def",
"upload_celery_conf",
"(",
"command",
"=",
"'celeryd'",
",",
"app_name",
"=",
"None",
",",
"template_name",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"app_name",
"=",
"app_name",
"or",
"command",
"default",
"=",
"{",
"'app_name'",
":",
"ap... | Upload Supervisor configuration for a celery command. | [
"Upload",
"Supervisor",
"configuration",
"for",
"a",
"celery",
"command",
"."
] | train | https://github.com/mlavin/argyle/blob/92cc6e1dd9b8e7cb41c5098a79d05e14b8243d72/argyle/supervisor.py#L37-L45 |
mlavin/argyle | argyle/supervisor.py | upload_gunicorn_conf | def upload_gunicorn_conf(command='gunicorn', app_name=None, template_name=None, context=None):
"""Upload Supervisor configuration for a gunicorn server."""
app_name = app_name or command
default = {'app_name': app_name, 'command': command}
context = context or {}
default.update(context)
tem... | python | def upload_gunicorn_conf(command='gunicorn', app_name=None, template_name=None, context=None):
"""Upload Supervisor configuration for a gunicorn server."""
app_name = app_name or command
default = {'app_name': app_name, 'command': command}
context = context or {}
default.update(context)
tem... | [
"def",
"upload_gunicorn_conf",
"(",
"command",
"=",
"'gunicorn'",
",",
"app_name",
"=",
"None",
",",
"template_name",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"app_name",
"=",
"app_name",
"or",
"command",
"default",
"=",
"{",
"'app_name'",
":",
... | Upload Supervisor configuration for a gunicorn server. | [
"Upload",
"Supervisor",
"configuration",
"for",
"a",
"gunicorn",
"server",
"."
] | train | https://github.com/mlavin/argyle/blob/92cc6e1dd9b8e7cb41c5098a79d05e14b8243d72/argyle/supervisor.py#L49-L57 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/validate/NotRule.py | NotRule.validate | def validate(self, path, schema, value, results):
"""
Validates a given value against this rule.
:param path: a dot notation path to the value.
:param schema: a schema this rule is called from
:param value: a value to be validated.
:param results: a list with validati... | python | def validate(self, path, schema, value, results):
"""
Validates a given value against this rule.
:param path: a dot notation path to the value.
:param schema: a schema this rule is called from
:param value: a value to be validated.
:param results: a list with validati... | [
"def",
"validate",
"(",
"self",
",",
"path",
",",
"schema",
",",
"value",
",",
"results",
")",
":",
"if",
"self",
".",
"_rule",
"==",
"None",
":",
"return",
"name",
"=",
"path",
"if",
"path",
"!=",
"None",
"else",
"\"value\"",
"local_results",
"=",
"... | Validates a given value against this rule.
:param path: a dot notation path to the value.
:param schema: a schema this rule is called from
:param value: a value to be validated.
:param results: a list with validation results to add new results. | [
"Validates",
"a",
"given",
"value",
"against",
"this",
"rule",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/validate/NotRule.py#L38-L68 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/run/Notifier.py | Notifier.notify_one | def notify_one(correlation_id, component, args):
"""
Notifies specific component.
To be notiied components must implement [[INotifiable]] interface.
If they don't the call to this method has no effect.
:param correlation_id: (optional) transaction id to trace execution through c... | python | def notify_one(correlation_id, component, args):
"""
Notifies specific component.
To be notiied components must implement [[INotifiable]] interface.
If they don't the call to this method has no effect.
:param correlation_id: (optional) transaction id to trace execution through c... | [
"def",
"notify_one",
"(",
"correlation_id",
",",
"component",
",",
"args",
")",
":",
"if",
"component",
"==",
"None",
":",
"return",
"if",
"isinstance",
"(",
"component",
",",
"INotifiable",
")",
":",
"component",
".",
"notify",
"(",
"correlation_id",
",",
... | Notifies specific component.
To be notiied components must implement [[INotifiable]] interface.
If they don't the call to this method has no effect.
:param correlation_id: (optional) transaction id to trace execution through call chain.
:param component: the component that is to be not... | [
"Notifies",
"specific",
"component",
".",
"To",
"be",
"notiied",
"components",
"must",
"implement",
"[[",
"INotifiable",
"]]",
"interface",
".",
"If",
"they",
"don",
"t",
"the",
"call",
"to",
"this",
"method",
"has",
"no",
"effect",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/run/Notifier.py#L20-L36 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/run/Notifier.py | Notifier.notify | def notify(correlation_id, components, args = None):
"""
Notifies multiple components.
To be notified components must implement [[INotifiable]] interface.
If they don't the call to this method has no effect.
:param correlation_id: (optional) transaction id to trace execution th... | python | def notify(correlation_id, components, args = None):
"""
Notifies multiple components.
To be notified components must implement [[INotifiable]] interface.
If they don't the call to this method has no effect.
:param correlation_id: (optional) transaction id to trace execution th... | [
"def",
"notify",
"(",
"correlation_id",
",",
"components",
",",
"args",
"=",
"None",
")",
":",
"if",
"components",
"==",
"None",
":",
"return",
"args",
"=",
"args",
"if",
"args",
"!=",
"None",
"else",
"Parameters",
"(",
")",
"for",
"component",
"in",
"... | Notifies multiple components.
To be notified components must implement [[INotifiable]] interface.
If they don't the call to this method has no effect.
:param correlation_id: (optional) transaction id to trace execution through call chain.
:param components: a list of components that a... | [
"Notifies",
"multiple",
"components",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/run/Notifier.py#L39-L57 |
sbarham/dsrt | dsrt/application/Context.py | Context.build_model | def build_model(self):
'''Find out the type of model configured and dispatch the request to the appropriate method'''
if self.model_config['model-type']:
self.model = self.build_fred()
elif self.model_config['model-type']:
self.model = self.buidl_hred()
else:
... | python | def build_model(self):
'''Find out the type of model configured and dispatch the request to the appropriate method'''
if self.model_config['model-type']:
self.model = self.build_fred()
elif self.model_config['model-type']:
self.model = self.buidl_hred()
else:
... | [
"def",
"build_model",
"(",
"self",
")",
":",
"if",
"self",
".",
"model_config",
"[",
"'model-type'",
"]",
":",
"self",
".",
"model",
"=",
"self",
".",
"build_fred",
"(",
")",
"elif",
"self",
".",
"model_config",
"[",
"'model-type'",
"]",
":",
"self",
"... | Find out the type of model configured and dispatch the request to the appropriate method | [
"Find",
"out",
"the",
"type",
"of",
"model",
"configured",
"and",
"dispatch",
"the",
"request",
"to",
"the",
"appropriate",
"method"
] | train | https://github.com/sbarham/dsrt/blob/bc664739f2f52839461d3e72773b71146fd56a9a/dsrt/application/Context.py#L67-L74 |
sbarham/dsrt | dsrt/application/Context.py | Context.build_fred | def build_fred(self):
'''Build a flat recurrent encoder-decoder dialogue model'''
encoder = Encoder(data=self.dataset, config=self.model_config)
decoder = Decoder(data=self.dataset, config=self.model_config, encoder=encoder)
return EncoderDecoder(config=self.model_config, encod... | python | def build_fred(self):
'''Build a flat recurrent encoder-decoder dialogue model'''
encoder = Encoder(data=self.dataset, config=self.model_config)
decoder = Decoder(data=self.dataset, config=self.model_config, encoder=encoder)
return EncoderDecoder(config=self.model_config, encod... | [
"def",
"build_fred",
"(",
"self",
")",
":",
"encoder",
"=",
"Encoder",
"(",
"data",
"=",
"self",
".",
"dataset",
",",
"config",
"=",
"self",
".",
"model_config",
")",
"decoder",
"=",
"Decoder",
"(",
"data",
"=",
"self",
".",
"dataset",
",",
"config",
... | Build a flat recurrent encoder-decoder dialogue model | [
"Build",
"a",
"flat",
"recurrent",
"encoder",
"-",
"decoder",
"dialogue",
"model"
] | train | https://github.com/sbarham/dsrt/blob/bc664739f2f52839461d3e72773b71146fd56a9a/dsrt/application/Context.py#L76-L83 |
wooga/play-deliver | playdeliver/client.py | Client.list | def list(self, service_name, **params):
"""
convinent access method for list.
service_name describes the endpoint to call
the `list` function on.
images.list or apks.list.
"""
result = self._invoke_call(service_name, 'list', **params)
if result is not No... | python | def list(self, service_name, **params):
"""
convinent access method for list.
service_name describes the endpoint to call
the `list` function on.
images.list or apks.list.
"""
result = self._invoke_call(service_name, 'list', **params)
if result is not No... | [
"def",
"list",
"(",
"self",
",",
"service_name",
",",
"*",
"*",
"params",
")",
":",
"result",
"=",
"self",
".",
"_invoke_call",
"(",
"service_name",
",",
"'list'",
",",
"*",
"*",
"params",
")",
"if",
"result",
"is",
"not",
"None",
":",
"return",
"res... | convinent access method for list.
service_name describes the endpoint to call
the `list` function on.
images.list or apks.list. | [
"convinent",
"access",
"method",
"for",
"list",
"."
] | train | https://github.com/wooga/play-deliver/blob/9de0f35376f5342720b3a90bd3ca296b1f3a3f4c/playdeliver/client.py#L25-L37 |
wooga/play-deliver | playdeliver/client.py | Client.list_inappproducts | def list_inappproducts(self):
"""temp function to list inapp products."""
result = self.service.inappproducts().list(
packageName=self.package_name).execute()
if result is not None:
return result.get('inappproduct', list())
return list() | python | def list_inappproducts(self):
"""temp function to list inapp products."""
result = self.service.inappproducts().list(
packageName=self.package_name).execute()
if result is not None:
return result.get('inappproduct', list())
return list() | [
"def",
"list_inappproducts",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"service",
".",
"inappproducts",
"(",
")",
".",
"list",
"(",
"packageName",
"=",
"self",
".",
"package_name",
")",
".",
"execute",
"(",
")",
"if",
"result",
"is",
"not",
"N... | temp function to list inapp products. | [
"temp",
"function",
"to",
"list",
"inapp",
"products",
"."
] | train | https://github.com/wooga/play-deliver/blob/9de0f35376f5342720b3a90bd3ca296b1f3a3f4c/playdeliver/client.py#L39-L46 |
wooga/play-deliver | playdeliver/client.py | Client.commit | def commit(self):
"""commit current edits."""
request = self.edits().commit(**self.build_params()).execute()
print 'Edit "%s" has been committed' % (request['id'])
self.edit_id = None | python | def commit(self):
"""commit current edits."""
request = self.edits().commit(**self.build_params()).execute()
print 'Edit "%s" has been committed' % (request['id'])
self.edit_id = None | [
"def",
"commit",
"(",
"self",
")",
":",
"request",
"=",
"self",
".",
"edits",
"(",
")",
".",
"commit",
"(",
"*",
"*",
"self",
".",
"build_params",
"(",
")",
")",
".",
"execute",
"(",
")",
"print",
"'Edit \"%s\" has been committed'",
"%",
"(",
"request"... | commit current edits. | [
"commit",
"current",
"edits",
"."
] | train | https://github.com/wooga/play-deliver/blob/9de0f35376f5342720b3a90bd3ca296b1f3a3f4c/playdeliver/client.py#L89-L94 |
wooga/play-deliver | playdeliver/client.py | Client.build_params | def build_params(self, params={}):
"""
build a params dictionary with current editId and packageName.
use optional params parameter
to merge additional params into resulting dictionary.
"""
z = params.copy()
z.update({'editId': self.edit_id, 'packageName': self.p... | python | def build_params(self, params={}):
"""
build a params dictionary with current editId and packageName.
use optional params parameter
to merge additional params into resulting dictionary.
"""
z = params.copy()
z.update({'editId': self.edit_id, 'packageName': self.p... | [
"def",
"build_params",
"(",
"self",
",",
"params",
"=",
"{",
"}",
")",
":",
"z",
"=",
"params",
".",
"copy",
"(",
")",
"z",
".",
"update",
"(",
"{",
"'editId'",
":",
"self",
".",
"edit_id",
",",
"'packageName'",
":",
"self",
".",
"package_name",
"}... | build a params dictionary with current editId and packageName.
use optional params parameter
to merge additional params into resulting dictionary. | [
"build",
"a",
"params",
"dictionary",
"with",
"current",
"editId",
"and",
"packageName",
"."
] | train | https://github.com/wooga/play-deliver/blob/9de0f35376f5342720b3a90bd3ca296b1f3a3f4c/playdeliver/client.py#L107-L116 |
wooga/play-deliver | playdeliver/client.py | Client.ensure_edit_id | def ensure_edit_id(self):
"""create edit id if edit id is None."""
if self.edit_id is None:
edit_request = self.edits().insert(
body={}, packageName=self.package_name)
result = edit_request.execute()
self.edit_id = result['id'] | python | def ensure_edit_id(self):
"""create edit id if edit id is None."""
if self.edit_id is None:
edit_request = self.edits().insert(
body={}, packageName=self.package_name)
result = edit_request.execute()
self.edit_id = result['id'] | [
"def",
"ensure_edit_id",
"(",
"self",
")",
":",
"if",
"self",
".",
"edit_id",
"is",
"None",
":",
"edit_request",
"=",
"self",
".",
"edits",
"(",
")",
".",
"insert",
"(",
"body",
"=",
"{",
"}",
",",
"packageName",
"=",
"self",
".",
"package_name",
")"... | create edit id if edit id is None. | [
"create",
"edit",
"id",
"if",
"edit",
"id",
"is",
"None",
"."
] | train | https://github.com/wooga/play-deliver/blob/9de0f35376f5342720b3a90bd3ca296b1f3a3f4c/playdeliver/client.py#L122-L128 |
rexzhang/flask-vises | flask_vises/database/models.py | GeneralObjectQuery.set_value | def set_value(self, general_object_model_class, group, key=None, value=None):
"""set|create/update"""
if key is None:
key = group
obj = self.get_queryset_by_group_and_key(group=group, key=key).first()
if obj is None:
obj = general_object_model_class(
... | python | def set_value(self, general_object_model_class, group, key=None, value=None):
"""set|create/update"""
if key is None:
key = group
obj = self.get_queryset_by_group_and_key(group=group, key=key).first()
if obj is None:
obj = general_object_model_class(
... | [
"def",
"set_value",
"(",
"self",
",",
"general_object_model_class",
",",
"group",
",",
"key",
"=",
"None",
",",
"value",
"=",
"None",
")",
":",
"if",
"key",
"is",
"None",
":",
"key",
"=",
"group",
"obj",
"=",
"self",
".",
"get_queryset_by_group_and_key",
... | set|create/update | [
"set|create",
"/",
"update"
] | train | https://github.com/rexzhang/flask-vises/blob/6173780d648527bee8716a1eb1d74b9bc7e56acf/flask_vises/database/models.py#L52-L70 |
rexzhang/flask-vises | flask_vises/database/models.py | GeneralObjectQuery.get_value | def get_value(self, group, key=None):
"""get value"""
if key is None:
key = group
obj = self.get_queryset_by_group_and_key(group=group, key=key).first()
if obj is None:
return None
return obj.value | python | def get_value(self, group, key=None):
"""get value"""
if key is None:
key = group
obj = self.get_queryset_by_group_and_key(group=group, key=key).first()
if obj is None:
return None
return obj.value | [
"def",
"get_value",
"(",
"self",
",",
"group",
",",
"key",
"=",
"None",
")",
":",
"if",
"key",
"is",
"None",
":",
"key",
"=",
"group",
"obj",
"=",
"self",
".",
"get_queryset_by_group_and_key",
"(",
"group",
"=",
"group",
",",
"key",
"=",
"key",
")",
... | get value | [
"get",
"value"
] | train | https://github.com/rexzhang/flask-vises/blob/6173780d648527bee8716a1eb1d74b9bc7e56acf/flask_vises/database/models.py#L72-L82 |
rexzhang/flask-vises | flask_vises/database/models.py | GeneralObjectQuery.get_object | def get_object(self, group, key=None):
"""get object"""
return self.get_queryset_by_group_and_key(group=group, key=key).first() | python | def get_object(self, group, key=None):
"""get object"""
return self.get_queryset_by_group_and_key(group=group, key=key).first() | [
"def",
"get_object",
"(",
"self",
",",
"group",
",",
"key",
"=",
"None",
")",
":",
"return",
"self",
".",
"get_queryset_by_group_and_key",
"(",
"group",
"=",
"group",
",",
"key",
"=",
"key",
")",
".",
"first",
"(",
")"
] | get object | [
"get",
"object"
] | train | https://github.com/rexzhang/flask-vises/blob/6173780d648527bee8716a1eb1d74b9bc7e56acf/flask_vises/database/models.py#L84-L86 |
rexzhang/flask-vises | flask_vises/database/models.py | GeneralObjectQuery.get_queryset_by_group_and_key | def get_queryset_by_group_and_key(self, group, key=None):
"""get queryset"""
if key is None:
return self.filter_by(group=group)
else:
return self.filter_by(group=group, key=key) | python | def get_queryset_by_group_and_key(self, group, key=None):
"""get queryset"""
if key is None:
return self.filter_by(group=group)
else:
return self.filter_by(group=group, key=key) | [
"def",
"get_queryset_by_group_and_key",
"(",
"self",
",",
"group",
",",
"key",
"=",
"None",
")",
":",
"if",
"key",
"is",
"None",
":",
"return",
"self",
".",
"filter_by",
"(",
"group",
"=",
"group",
")",
"else",
":",
"return",
"self",
".",
"filter_by",
... | get queryset | [
"get",
"queryset"
] | train | https://github.com/rexzhang/flask-vises/blob/6173780d648527bee8716a1eb1d74b9bc7e56acf/flask_vises/database/models.py#L88-L94 |
rexzhang/flask-vises | flask_vises/database/models.py | GeneralObjectMixin.set_value | def set_value(cls, group, key=None, value=None):
"""set|create/update"""
return cls.query.set_value(general_object_model_class=cls, group=group, key=key, value=value) | python | def set_value(cls, group, key=None, value=None):
"""set|create/update"""
return cls.query.set_value(general_object_model_class=cls, group=group, key=key, value=value) | [
"def",
"set_value",
"(",
"cls",
",",
"group",
",",
"key",
"=",
"None",
",",
"value",
"=",
"None",
")",
":",
"return",
"cls",
".",
"query",
".",
"set_value",
"(",
"general_object_model_class",
"=",
"cls",
",",
"group",
"=",
"group",
",",
"key",
"=",
"... | set|create/update | [
"set|create",
"/",
"update"
] | train | https://github.com/rexzhang/flask-vises/blob/6173780d648527bee8716a1eb1d74b9bc7e56acf/flask_vises/database/models.py#L117-L119 |
rexzhang/flask-vises | flask_vises/database/models.py | GeneralObjectMixin.get_value | def get_value(cls, group, key=None):
"""get value"""
return cls.query.get_value(group=group, key=key) | python | def get_value(cls, group, key=None):
"""get value"""
return cls.query.get_value(group=group, key=key) | [
"def",
"get_value",
"(",
"cls",
",",
"group",
",",
"key",
"=",
"None",
")",
":",
"return",
"cls",
".",
"query",
".",
"get_value",
"(",
"group",
"=",
"group",
",",
"key",
"=",
"key",
")"
] | get value | [
"get",
"value"
] | train | https://github.com/rexzhang/flask-vises/blob/6173780d648527bee8716a1eb1d74b9bc7e56acf/flask_vises/database/models.py#L122-L124 |
mlavin/argyle | argyle/rabbitmq.py | upload_rabbitmq_environment_conf | def upload_rabbitmq_environment_conf(template_name=None, context=None, restart=True):
"""Upload RabbitMQ environment configuration from a template."""
template_name = template_name or u'rabbitmq/rabbitmq-env.conf'
destination = u'/etc/rabbitmq/rabbitmq-env.conf'
upload_template(template_name, desti... | python | def upload_rabbitmq_environment_conf(template_name=None, context=None, restart=True):
"""Upload RabbitMQ environment configuration from a template."""
template_name = template_name or u'rabbitmq/rabbitmq-env.conf'
destination = u'/etc/rabbitmq/rabbitmq-env.conf'
upload_template(template_name, desti... | [
"def",
"upload_rabbitmq_environment_conf",
"(",
"template_name",
"=",
"None",
",",
"context",
"=",
"None",
",",
"restart",
"=",
"True",
")",
":",
"template_name",
"=",
"template_name",
"or",
"u'rabbitmq/rabbitmq-env.conf'",
"destination",
"=",
"u'/etc/rabbitmq/rabbitmq-... | Upload RabbitMQ environment configuration from a template. | [
"Upload",
"RabbitMQ",
"environment",
"configuration",
"from",
"a",
"template",
"."
] | train | https://github.com/mlavin/argyle/blob/92cc6e1dd9b8e7cb41c5098a79d05e14b8243d72/argyle/rabbitmq.py#L35-L42 |
mlavin/argyle | argyle/rabbitmq.py | upload_rabbitmq_conf | def upload_rabbitmq_conf(template_name=None, context=None, restart=True):
"""Upload RabbitMQ configuration from a template."""
template_name = template_name or u'rabbitmq/rabbitmq.config'
destination = u'/etc/rabbitmq/rabbitmq.config'
upload_template(template_name, destination, context=context, use... | python | def upload_rabbitmq_conf(template_name=None, context=None, restart=True):
"""Upload RabbitMQ configuration from a template."""
template_name = template_name or u'rabbitmq/rabbitmq.config'
destination = u'/etc/rabbitmq/rabbitmq.config'
upload_template(template_name, destination, context=context, use... | [
"def",
"upload_rabbitmq_conf",
"(",
"template_name",
"=",
"None",
",",
"context",
"=",
"None",
",",
"restart",
"=",
"True",
")",
":",
"template_name",
"=",
"template_name",
"or",
"u'rabbitmq/rabbitmq.config'",
"destination",
"=",
"u'/etc/rabbitmq/rabbitmq.config'",
"u... | Upload RabbitMQ configuration from a template. | [
"Upload",
"RabbitMQ",
"configuration",
"from",
"a",
"template",
"."
] | train | https://github.com/mlavin/argyle/blob/92cc6e1dd9b8e7cb41c5098a79d05e14b8243d72/argyle/rabbitmq.py#L46-L53 |
host-anshu/simpleInterceptor | example/lint_pbook/lint.py | main | def main():
"""Run playbook"""
for flag in ('--check',):
if flag not in sys.argv:
sys.argv.append(flag)
obj = PlaybookCLI(sys.argv)
obj.parse()
obj.run() | python | def main():
"""Run playbook"""
for flag in ('--check',):
if flag not in sys.argv:
sys.argv.append(flag)
obj = PlaybookCLI(sys.argv)
obj.parse()
obj.run() | [
"def",
"main",
"(",
")",
":",
"for",
"flag",
"in",
"(",
"'--check'",
",",
")",
":",
"if",
"flag",
"not",
"in",
"sys",
".",
"argv",
":",
"sys",
".",
"argv",
".",
"append",
"(",
"flag",
")",
"obj",
"=",
"PlaybookCLI",
"(",
"sys",
".",
"argv",
")"... | Run playbook | [
"Run",
"playbook"
] | train | https://github.com/host-anshu/simpleInterceptor/blob/71238fed57c62b5f77ce32d0c9b98acad73ab6a8/example/lint_pbook/lint.py#L35-L42 |
host-anshu/simpleInterceptor | example/lint_pbook/lint.py | queue_exc | def queue_exc(*arg, **kw):
"""Queue undefined variable exception"""
_self = arg[0]
if not isinstance(_self, AnsibleUndefinedVariable):
# Run for AnsibleUndefinedVariable instance
return
_rslt_q = None
for stack_trace in inspect.stack():
# Check if method to be skipped
... | python | def queue_exc(*arg, **kw):
"""Queue undefined variable exception"""
_self = arg[0]
if not isinstance(_self, AnsibleUndefinedVariable):
# Run for AnsibleUndefinedVariable instance
return
_rslt_q = None
for stack_trace in inspect.stack():
# Check if method to be skipped
... | [
"def",
"queue_exc",
"(",
"*",
"arg",
",",
"*",
"*",
"kw",
")",
":",
"_self",
"=",
"arg",
"[",
"0",
"]",
"if",
"not",
"isinstance",
"(",
"_self",
",",
"AnsibleUndefinedVariable",
")",
":",
"# Run for AnsibleUndefinedVariable instance",
"return",
"_rslt_q",
"=... | Queue undefined variable exception | [
"Queue",
"undefined",
"variable",
"exception"
] | train | https://github.com/host-anshu/simpleInterceptor/blob/71238fed57c62b5f77ce32d0c9b98acad73ab6a8/example/lint_pbook/lint.py#L45-L67 |
host-anshu/simpleInterceptor | example/lint_pbook/lint.py | extract_worker_exc | def extract_worker_exc(*arg, **kw):
"""Get exception added by worker"""
_self = arg[0]
if not isinstance(_self, StrategyBase):
# Run for StrategyBase instance only
return
# Iterate over workers to get their task and queue
for _worker_prc, _main_q, _rslt_q in _self._workers:
_... | python | def extract_worker_exc(*arg, **kw):
"""Get exception added by worker"""
_self = arg[0]
if not isinstance(_self, StrategyBase):
# Run for StrategyBase instance only
return
# Iterate over workers to get their task and queue
for _worker_prc, _main_q, _rslt_q in _self._workers:
_... | [
"def",
"extract_worker_exc",
"(",
"*",
"arg",
",",
"*",
"*",
"kw",
")",
":",
"_self",
"=",
"arg",
"[",
"0",
"]",
"if",
"not",
"isinstance",
"(",
"_self",
",",
"StrategyBase",
")",
":",
"# Run for StrategyBase instance only",
"return",
"# Iterate over workers t... | Get exception added by worker | [
"Get",
"exception",
"added",
"by",
"worker"
] | train | https://github.com/host-anshu/simpleInterceptor/blob/71238fed57c62b5f77ce32d0c9b98acad73ab6a8/example/lint_pbook/lint.py#L70-L88 |
Bystroushaak/pyDHTMLParser | src/dhtmlparser/htmlelement/html_query.py | HTMLQuery.containsParamSubset | def containsParamSubset(self, params):
"""
Test whether this element contains at least all `params`, or more.
Args:
params (dict/SpecialDict): Subset of parameters.
Returns:
bool: True if all `params` are contained in this element.
"""
for key in... | python | def containsParamSubset(self, params):
"""
Test whether this element contains at least all `params`, or more.
Args:
params (dict/SpecialDict): Subset of parameters.
Returns:
bool: True if all `params` are contained in this element.
"""
for key in... | [
"def",
"containsParamSubset",
"(",
"self",
",",
"params",
")",
":",
"for",
"key",
"in",
"params",
".",
"keys",
"(",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"params",
":",
"return",
"False",
"if",
"params",
"[",
"key",
"]",
"!=",
"self",
".... | Test whether this element contains at least all `params`, or more.
Args:
params (dict/SpecialDict): Subset of parameters.
Returns:
bool: True if all `params` are contained in this element. | [
"Test",
"whether",
"this",
"element",
"contains",
"at",
"least",
"all",
"params",
"or",
"more",
"."
] | train | https://github.com/Bystroushaak/pyDHTMLParser/blob/4756f93dd048500b038ece2323fe26e46b6bfdea/src/dhtmlparser/htmlelement/html_query.py#L17-L34 |
Bystroushaak/pyDHTMLParser | src/dhtmlparser/htmlelement/html_query.py | HTMLQuery.isAlmostEqual | def isAlmostEqual(self, tag_name, params=None, fn=None,
case_sensitive=False):
"""
Compare element with given `tag_name`, `params` and/or by lambda
function `fn`.
Lambda function is same as in :meth:`find`.
Args:
tag_name (str): Compare just na... | python | def isAlmostEqual(self, tag_name, params=None, fn=None,
case_sensitive=False):
"""
Compare element with given `tag_name`, `params` and/or by lambda
function `fn`.
Lambda function is same as in :meth:`find`.
Args:
tag_name (str): Compare just na... | [
"def",
"isAlmostEqual",
"(",
"self",
",",
"tag_name",
",",
"params",
"=",
"None",
",",
"fn",
"=",
"None",
",",
"case_sensitive",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"tag_name",
",",
"self",
".",
"__class__",
")",
":",
"return",
"self",
"."... | Compare element with given `tag_name`, `params` and/or by lambda
function `fn`.
Lambda function is same as in :meth:`find`.
Args:
tag_name (str): Compare just name of the element.
params (dict, default None): Compare also parameters.
fn (function, default No... | [
"Compare",
"element",
"with",
"given",
"tag_name",
"params",
"and",
"/",
"or",
"by",
"lambda",
"function",
"fn",
"."
] | train | https://github.com/Bystroushaak/pyDHTMLParser/blob/4756f93dd048500b038ece2323fe26e46b6bfdea/src/dhtmlparser/htmlelement/html_query.py#L36-L87 |
Bystroushaak/pyDHTMLParser | src/dhtmlparser/htmlelement/html_query.py | HTMLQuery.find | def find(self, tag_name, params=None, fn=None, case_sensitive=False):
"""
Same as :meth:`findAll`, but without `endtags`.
You can always get them from :attr:`endtag` property.
"""
return [
x for x in self.findAll(tag_name, params, fn, case_sensitive)
if n... | python | def find(self, tag_name, params=None, fn=None, case_sensitive=False):
"""
Same as :meth:`findAll`, but without `endtags`.
You can always get them from :attr:`endtag` property.
"""
return [
x for x in self.findAll(tag_name, params, fn, case_sensitive)
if n... | [
"def",
"find",
"(",
"self",
",",
"tag_name",
",",
"params",
"=",
"None",
",",
"fn",
"=",
"None",
",",
"case_sensitive",
"=",
"False",
")",
":",
"return",
"[",
"x",
"for",
"x",
"in",
"self",
".",
"findAll",
"(",
"tag_name",
",",
"params",
",",
"fn",... | Same as :meth:`findAll`, but without `endtags`.
You can always get them from :attr:`endtag` property. | [
"Same",
"as",
":",
"meth",
":",
"findAll",
"but",
"without",
"endtags",
"."
] | train | https://github.com/Bystroushaak/pyDHTMLParser/blob/4756f93dd048500b038ece2323fe26e46b6bfdea/src/dhtmlparser/htmlelement/html_query.py#L89-L98 |
Bystroushaak/pyDHTMLParser | src/dhtmlparser/htmlelement/html_query.py | HTMLQuery.findB | def findB(self, tag_name, params=None, fn=None, case_sensitive=False):
"""
Same as :meth:`findAllB`, but without `endtags`.
You can always get them from :attr:`endtag` property.
"""
return [
x for x in self.findAllB(tag_name, params, fn, case_sensitive)
i... | python | def findB(self, tag_name, params=None, fn=None, case_sensitive=False):
"""
Same as :meth:`findAllB`, but without `endtags`.
You can always get them from :attr:`endtag` property.
"""
return [
x for x in self.findAllB(tag_name, params, fn, case_sensitive)
i... | [
"def",
"findB",
"(",
"self",
",",
"tag_name",
",",
"params",
"=",
"None",
",",
"fn",
"=",
"None",
",",
"case_sensitive",
"=",
"False",
")",
":",
"return",
"[",
"x",
"for",
"x",
"in",
"self",
".",
"findAllB",
"(",
"tag_name",
",",
"params",
",",
"fn... | Same as :meth:`findAllB`, but without `endtags`.
You can always get them from :attr:`endtag` property. | [
"Same",
"as",
":",
"meth",
":",
"findAllB",
"but",
"without",
"endtags",
"."
] | train | https://github.com/Bystroushaak/pyDHTMLParser/blob/4756f93dd048500b038ece2323fe26e46b6bfdea/src/dhtmlparser/htmlelement/html_query.py#L100-L109 |
Bystroushaak/pyDHTMLParser | src/dhtmlparser/htmlelement/html_query.py | HTMLQuery.findAll | def findAll(self, tag_name, params=None, fn=None, case_sensitive=False):
"""
Search for elements by their parameters using `Depth-first algorithm
<http://en.wikipedia.org/wiki/Depth-first_search>`_.
Args:
tag_name (str): Name of the tag you are looking for. Set to "" if
... | python | def findAll(self, tag_name, params=None, fn=None, case_sensitive=False):
"""
Search for elements by their parameters using `Depth-first algorithm
<http://en.wikipedia.org/wiki/Depth-first_search>`_.
Args:
tag_name (str): Name of the tag you are looking for. Set to "" if
... | [
"def",
"findAll",
"(",
"self",
",",
"tag_name",
",",
"params",
"=",
"None",
",",
"fn",
"=",
"None",
",",
"case_sensitive",
"=",
"False",
")",
":",
"output",
"=",
"[",
"]",
"if",
"self",
".",
"isAlmostEqual",
"(",
"tag_name",
",",
"params",
",",
"fn",... | Search for elements by their parameters using `Depth-first algorithm
<http://en.wikipedia.org/wiki/Depth-first_search>`_.
Args:
tag_name (str): Name of the tag you are looking for. Set to "" if
you wish to use only `fn` parameter.
params (dict, defaul... | [
"Search",
"for",
"elements",
"by",
"their",
"parameters",
"using",
"Depth",
"-",
"first",
"algorithm",
"<http",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Depth",
"-",
"first_search",
">",
"_",
"."
] | train | https://github.com/Bystroushaak/pyDHTMLParser/blob/4756f93dd048500b038ece2323fe26e46b6bfdea/src/dhtmlparser/htmlelement/html_query.py#L111-L141 |
Bystroushaak/pyDHTMLParser | src/dhtmlparser/htmlelement/html_query.py | HTMLQuery.findAllB | def findAllB(self, tag_name, params=None, fn=None, case_sensitive=False):
"""
Simple search engine using `Breadth-first algorithm
<http://en.wikipedia.org/wiki/Breadth-first_search>`_.
Args:
tag_name (str): Name of the tag you are looking for. Set to "" if
... | python | def findAllB(self, tag_name, params=None, fn=None, case_sensitive=False):
"""
Simple search engine using `Breadth-first algorithm
<http://en.wikipedia.org/wiki/Breadth-first_search>`_.
Args:
tag_name (str): Name of the tag you are looking for. Set to "" if
... | [
"def",
"findAllB",
"(",
"self",
",",
"tag_name",
",",
"params",
"=",
"None",
",",
"fn",
"=",
"None",
",",
"case_sensitive",
"=",
"False",
")",
":",
"output",
"=",
"[",
"]",
"if",
"self",
".",
"isAlmostEqual",
"(",
"tag_name",
",",
"params",
",",
"fn"... | Simple search engine using `Breadth-first algorithm
<http://en.wikipedia.org/wiki/Breadth-first_search>`_.
Args:
tag_name (str): Name of the tag you are looking for. Set to "" if
you wish to use only `fn` parameter.
params (dict, default None): Parame... | [
"Simple",
"search",
"engine",
"using",
"Breadth",
"-",
"first",
"algorithm",
"<http",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Breadth",
"-",
"first_search",
">",
"_",
"."
] | train | https://github.com/Bystroushaak/pyDHTMLParser/blob/4756f93dd048500b038ece2323fe26e46b6bfdea/src/dhtmlparser/htmlelement/html_query.py#L143-L174 |
Bystroushaak/pyDHTMLParser | src/dhtmlparser/htmlelement/html_query.py | HTMLQuery.wfind | def wfind(self, tag_name, params=None, fn=None, case_sensitive=False):
"""
This methods works same as :meth:`find`, but only in one level of the
:attr:`childs`.
This allows to chain :meth:`wfind` calls::
>>> dom = dhtmlparser.parseString('''
... <root>
... | python | def wfind(self, tag_name, params=None, fn=None, case_sensitive=False):
"""
This methods works same as :meth:`find`, but only in one level of the
:attr:`childs`.
This allows to chain :meth:`wfind` calls::
>>> dom = dhtmlparser.parseString('''
... <root>
... | [
"def",
"wfind",
"(",
"self",
",",
"tag_name",
",",
"params",
"=",
"None",
",",
"fn",
"=",
"None",
",",
"case_sensitive",
"=",
"False",
")",
":",
"childs",
"=",
"self",
".",
"childs",
"if",
"self",
".",
"_container",
":",
"# container object",
"childs",
... | This methods works same as :meth:`find`, but only in one level of the
:attr:`childs`.
This allows to chain :meth:`wfind` calls::
>>> dom = dhtmlparser.parseString('''
... <root>
... <some>
... <something>
... <xe id="w... | [
"This",
"methods",
"works",
"same",
"as",
":",
"meth",
":",
"find",
"but",
"only",
"in",
"one",
"level",
"of",
"the",
":",
"attr",
":",
"childs",
"."
] | train | https://github.com/Bystroushaak/pyDHTMLParser/blob/4756f93dd048500b038ece2323fe26e46b6bfdea/src/dhtmlparser/htmlelement/html_query.py#L176-L238 |
Bystroushaak/pyDHTMLParser | src/dhtmlparser/htmlelement/html_query.py | HTMLQuery.match | def match(self, *args, **kwargs):
"""
:meth:`wfind` is nice function, but still kinda long to use, because
you have to manually chain all calls together and in the end, you get
:class:`HTMLElement` instance container.
This function recursively calls :meth:`wfind` for you and in ... | python | def match(self, *args, **kwargs):
"""
:meth:`wfind` is nice function, but still kinda long to use, because
you have to manually chain all calls together and in the end, you get
:class:`HTMLElement` instance container.
This function recursively calls :meth:`wfind` for you and in ... | [
"def",
"match",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"args",
":",
"return",
"self",
".",
"childs",
"# pop one argument from argument stack (tuples, so .pop() won't work)",
"act",
"=",
"args",
"[",
"0",
"]",
"args",
"... | :meth:`wfind` is nice function, but still kinda long to use, because
you have to manually chain all calls together and in the end, you get
:class:`HTMLElement` instance container.
This function recursively calls :meth:`wfind` for you and in the end,
you get list of matching elements::
... | [
":",
"meth",
":",
"wfind",
"is",
"nice",
"function",
"but",
"still",
"kinda",
"long",
"to",
"use",
"because",
"you",
"have",
"to",
"manually",
"chain",
"all",
"calls",
"together",
"and",
"in",
"the",
"end",
"you",
"get",
":",
"class",
":",
"HTMLElement",... | train | https://github.com/Bystroushaak/pyDHTMLParser/blob/4756f93dd048500b038ece2323fe26e46b6bfdea/src/dhtmlparser/htmlelement/html_query.py#L240-L345 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/data/PagingParams.py | PagingParams.get_skip | def get_skip(self, min_skip):
"""
Gets the number of items to skip.
:param min_skip: the minimum number of items to skip.
:return: the number of items to skip.
"""
if self.skip == None:
return min_skip
if self.skip < min_skip:
return min_... | python | def get_skip(self, min_skip):
"""
Gets the number of items to skip.
:param min_skip: the minimum number of items to skip.
:return: the number of items to skip.
"""
if self.skip == None:
return min_skip
if self.skip < min_skip:
return min_... | [
"def",
"get_skip",
"(",
"self",
",",
"min_skip",
")",
":",
"if",
"self",
".",
"skip",
"==",
"None",
":",
"return",
"min_skip",
"if",
"self",
".",
"skip",
"<",
"min_skip",
":",
"return",
"min_skip",
"return",
"self",
".",
"skip"
] | Gets the number of items to skip.
:param min_skip: the minimum number of items to skip.
:return: the number of items to skip. | [
"Gets",
"the",
"number",
"of",
"items",
"to",
"skip",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/data/PagingParams.py#L53-L65 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/data/PagingParams.py | PagingParams.get_take | def get_take(self, max_take):
"""
Gets the number of items to return in a page.
:param max_take: the maximum number of items to return.
:return: the number of items to return.
"""
if self.take == None:
return max_take
if self.take < 0:
re... | python | def get_take(self, max_take):
"""
Gets the number of items to return in a page.
:param max_take: the maximum number of items to return.
:return: the number of items to return.
"""
if self.take == None:
return max_take
if self.take < 0:
re... | [
"def",
"get_take",
"(",
"self",
",",
"max_take",
")",
":",
"if",
"self",
".",
"take",
"==",
"None",
":",
"return",
"max_take",
"if",
"self",
".",
"take",
"<",
"0",
":",
"return",
"0",
"if",
"self",
".",
"take",
">",
"max_take",
":",
"return",
"max_... | Gets the number of items to return in a page.
:param max_take: the maximum number of items to return.
:return: the number of items to return. | [
"Gets",
"the",
"number",
"of",
"items",
"to",
"return",
"in",
"a",
"page",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/data/PagingParams.py#L67-L81 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/data/PagingParams.py | PagingParams.from_value | def from_value(value):
"""
Converts specified value into PagingParams.
:param value: value to be converted
:return: a newly created PagingParams.
"""
if isinstance(value, PagingParams):
return value
if isinstance(value, AnyValueMap):
retu... | python | def from_value(value):
"""
Converts specified value into PagingParams.
:param value: value to be converted
:return: a newly created PagingParams.
"""
if isinstance(value, PagingParams):
return value
if isinstance(value, AnyValueMap):
retu... | [
"def",
"from_value",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"PagingParams",
")",
":",
"return",
"value",
"if",
"isinstance",
"(",
"value",
",",
"AnyValueMap",
")",
":",
"return",
"PagingParams",
".",
"from_map",
"(",
"value",
")",
... | Converts specified value into PagingParams.
:param value: value to be converted
:return: a newly created PagingParams. | [
"Converts",
"specified",
"value",
"into",
"PagingParams",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/data/PagingParams.py#L104-L118 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/data/PagingParams.py | PagingParams.from_map | def from_map(map):
"""
Creates a new PagingParams and sets it parameters from the specified map
:param map: a AnyValueMap or StringValueMap to initialize this PagingParams
:return: a newly created PagingParams.
"""
skip = map.get_as_nullable_integer("skip")
take... | python | def from_map(map):
"""
Creates a new PagingParams and sets it parameters from the specified map
:param map: a AnyValueMap or StringValueMap to initialize this PagingParams
:return: a newly created PagingParams.
"""
skip = map.get_as_nullable_integer("skip")
take... | [
"def",
"from_map",
"(",
"map",
")",
":",
"skip",
"=",
"map",
".",
"get_as_nullable_integer",
"(",
"\"skip\"",
")",
"take",
"=",
"map",
".",
"get_as_nullable_integer",
"(",
"\"take\"",
")",
"total",
"=",
"map",
".",
"get_as_nullable_boolean",
"(",
"\"total\"",
... | Creates a new PagingParams and sets it parameters from the specified map
:param map: a AnyValueMap or StringValueMap to initialize this PagingParams
:return: a newly created PagingParams. | [
"Creates",
"a",
"new",
"PagingParams",
"and",
"sets",
"it",
"parameters",
"from",
"the",
"specified",
"map"
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/data/PagingParams.py#L133-L144 |
rvswift/EB | EB/builder/exhaustive/exhaustive_io.py | ParseArgs.get_int | def get_int(self, input_string):
"""
Return integer type user input
"""
if input_string in ('--ensemble_size', '--ncpu'):
# was the flag set?
try:
index = self.args.index(input_string) + 1
except ValueError:
# it wasn't, so if it'... | python | def get_int(self, input_string):
"""
Return integer type user input
"""
if input_string in ('--ensemble_size', '--ncpu'):
# was the flag set?
try:
index = self.args.index(input_string) + 1
except ValueError:
# it wasn't, so if it'... | [
"def",
"get_int",
"(",
"self",
",",
"input_string",
")",
":",
"if",
"input_string",
"in",
"(",
"'--ensemble_size'",
",",
"'--ncpu'",
")",
":",
"# was the flag set?",
"try",
":",
"index",
"=",
"self",
".",
"args",
".",
"index",
"(",
"input_string",
")",
"+"... | Return integer type user input | [
"Return",
"integer",
"type",
"user",
"input"
] | train | https://github.com/rvswift/EB/blob/341880b79faf8147dc9fa6e90438531cd09fabcc/EB/builder/exhaustive/exhaustive_io.py#L141-L187 |
FujiMakoto/AgentML | agentml/common.py | weighted_choice | def weighted_choice(choices):
"""
Provides a weighted version of random.choice
:param choices: A dictionary of choices, with the choice as the key and weight the value
:type choices: list of tuple of (str, int)
"""
total = sum(weight for choice, weight in choices)
rand = random.uniform(0, t... | python | def weighted_choice(choices):
"""
Provides a weighted version of random.choice
:param choices: A dictionary of choices, with the choice as the key and weight the value
:type choices: list of tuple of (str, int)
"""
total = sum(weight for choice, weight in choices)
rand = random.uniform(0, t... | [
"def",
"weighted_choice",
"(",
"choices",
")",
":",
"total",
"=",
"sum",
"(",
"weight",
"for",
"choice",
",",
"weight",
"in",
"choices",
")",
"rand",
"=",
"random",
".",
"uniform",
"(",
"0",
",",
"total",
")",
"most",
"=",
"0",
"for",
"choice",
",",
... | Provides a weighted version of random.choice
:param choices: A dictionary of choices, with the choice as the key and weight the value
:type choices: list of tuple of (str, int) | [
"Provides",
"a",
"weighted",
"version",
"of",
"random",
".",
"choice",
":",
"param",
"choices",
":",
"A",
"dictionary",
"of",
"choices",
"with",
"the",
"choice",
"as",
"the",
"key",
"and",
"weight",
"the",
"value",
":",
"type",
"choices",
":",
"list",
"o... | train | https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/common.py#L20-L33 |
FujiMakoto/AgentML | agentml/common.py | normalize | def normalize(string, pattern=False, preserve_case=False):
"""
Normalize input for comparison with other input
:param string: The string to normalize
:type string: str
:param pattern: Allow wildcard symbols for triggers
:type pattern: bool
:param preserve_case: Normalize the message with... | python | def normalize(string, pattern=False, preserve_case=False):
"""
Normalize input for comparison with other input
:param string: The string to normalize
:type string: str
:param pattern: Allow wildcard symbols for triggers
:type pattern: bool
:param preserve_case: Normalize the message with... | [
"def",
"normalize",
"(",
"string",
",",
"pattern",
"=",
"False",
",",
"preserve_case",
"=",
"False",
")",
":",
"regex",
"=",
"re",
".",
"compile",
"(",
"r'([^\\s\\w\\(\\)\\[\\]\\|\\*#])+'",
")",
"if",
"pattern",
"else",
"re",
".",
"compile",
"(",
"r'([^\\s\\... | Normalize input for comparison with other input
:param string: The string to normalize
:type string: str
:param pattern: Allow wildcard symbols for triggers
:type pattern: bool
:param preserve_case: Normalize the message without casefolding
:type preserve_case: bool
:rtype: str | [
"Normalize",
"input",
"for",
"comparison",
"with",
"other",
"input",
":",
"param",
"string",
":",
"The",
"string",
"to",
"normalize",
":",
"type",
"string",
":",
"str"
] | train | https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/common.py#L36-L61 |
FujiMakoto/AgentML | agentml/common.py | attribute | def attribute(element, attribute, default=None):
"""
Returns the value of an attribute, or a default if it's not defined
:param element: The XML Element object
:type element: etree._Element
:param attribute: The name of the attribute to evaluate
:type attribute: basestring
:param default... | python | def attribute(element, attribute, default=None):
"""
Returns the value of an attribute, or a default if it's not defined
:param element: The XML Element object
:type element: etree._Element
:param attribute: The name of the attribute to evaluate
:type attribute: basestring
:param default... | [
"def",
"attribute",
"(",
"element",
",",
"attribute",
",",
"default",
"=",
"None",
")",
":",
"attribute_value",
"=",
"element",
".",
"get",
"(",
"attribute",
")",
"return",
"attribute_value",
"if",
"attribute_value",
"is",
"not",
"None",
"else",
"default"
] | Returns the value of an attribute, or a default if it's not defined
:param element: The XML Element object
:type element: etree._Element
:param attribute: The name of the attribute to evaluate
:type attribute: basestring
:param default: The default value to return if the attribute is not defined | [
"Returns",
"the",
"value",
"of",
"an",
"attribute",
"or",
"a",
"default",
"if",
"it",
"s",
"not",
"defined",
":",
"param",
"element",
":",
"The",
"XML",
"Element",
"object",
":",
"type",
"element",
":",
"etree",
".",
"_Element"
] | train | https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/common.py#L64-L77 |
FujiMakoto/AgentML | agentml/common.py | bool_attribute | def bool_attribute(element, attribute, default=True):
"""
Returns the bool value of an attribute, or a default if it's not defined
:param element: The XML Element object
:type element: etree._Element
:param attribute: The name of the attribute to evaluate
:type attribute: str
:param defa... | python | def bool_attribute(element, attribute, default=True):
"""
Returns the bool value of an attribute, or a default if it's not defined
:param element: The XML Element object
:type element: etree._Element
:param attribute: The name of the attribute to evaluate
:type attribute: str
:param defa... | [
"def",
"bool_attribute",
"(",
"element",
",",
"attribute",
",",
"default",
"=",
"True",
")",
":",
"attribute_value",
"=",
"element",
".",
"get",
"(",
"attribute",
")",
"if",
"attribute_value",
":",
"return",
"attribute_value",
"==",
"'true'",
"return",
"defaul... | Returns the bool value of an attribute, or a default if it's not defined
:param element: The XML Element object
:type element: etree._Element
:param attribute: The name of the attribute to evaluate
:type attribute: str
:param default: The default boolean to return if the attribute is not defined... | [
"Returns",
"the",
"bool",
"value",
"of",
"an",
"attribute",
"or",
"a",
"default",
"if",
"it",
"s",
"not",
"defined",
":",
"param",
"element",
":",
"The",
"XML",
"Element",
"object",
":",
"type",
"element",
":",
"etree",
".",
"_Element"
] | train | https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/common.py#L80-L99 |
FujiMakoto/AgentML | agentml/common.py | int_attribute | def int_attribute(element, attribute, default=0):
"""
Returns the int value of an attribute, or a default if it's not defined
:param element: The XML Element object
:type element: etree._Element
:param attribute: The name of the attribute to evaluate
:type attribute: basestring
:param de... | python | def int_attribute(element, attribute, default=0):
"""
Returns the int value of an attribute, or a default if it's not defined
:param element: The XML Element object
:type element: etree._Element
:param attribute: The name of the attribute to evaluate
:type attribute: basestring
:param de... | [
"def",
"int_attribute",
"(",
"element",
",",
"attribute",
",",
"default",
"=",
"0",
")",
":",
"attribute_value",
"=",
"element",
".",
"get",
"(",
"attribute",
")",
"if",
"attribute_value",
":",
"try",
":",
"return",
"int",
"(",
"attribute_value",
")",
"exc... | Returns the int value of an attribute, or a default if it's not defined
:param element: The XML Element object
:type element: etree._Element
:param attribute: The name of the attribute to evaluate
:type attribute: basestring
:param default: The default value to return if the attribute is not def... | [
"Returns",
"the",
"int",
"value",
"of",
"an",
"attribute",
"or",
"a",
"default",
"if",
"it",
"s",
"not",
"defined",
":",
"param",
"element",
":",
"The",
"XML",
"Element",
"object",
":",
"type",
"element",
":",
"etree",
".",
"_Element"
] | train | https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/common.py#L102-L124 |
FujiMakoto/AgentML | agentml/common.py | element | def element(element, name, default=None):
"""
Returns the value of an element, or a default if it's not defined
:param element: The XML Element object
:type element: etree._Element
:param name: The name of the element to evaluate
:type name: str
:param default: The default value to retur... | python | def element(element, name, default=None):
"""
Returns the value of an element, or a default if it's not defined
:param element: The XML Element object
:type element: etree._Element
:param name: The name of the element to evaluate
:type name: str
:param default: The default value to retur... | [
"def",
"element",
"(",
"element",
",",
"name",
",",
"default",
"=",
"None",
")",
":",
"element_value",
"=",
"element",
".",
"find",
"(",
"name",
")",
"return",
"element_value",
".",
"text",
"if",
"element_value",
"is",
"not",
"None",
"else",
"default"
] | Returns the value of an element, or a default if it's not defined
:param element: The XML Element object
:type element: etree._Element
:param name: The name of the element to evaluate
:type name: str
:param default: The default value to return if the element is not defined | [
"Returns",
"the",
"value",
"of",
"an",
"element",
"or",
"a",
"default",
"if",
"it",
"s",
"not",
"defined",
":",
"param",
"element",
":",
"The",
"XML",
"Element",
"object",
":",
"type",
"element",
":",
"etree",
".",
"_Element"
] | train | https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/common.py#L127-L140 |
FujiMakoto/AgentML | agentml/common.py | bool_element | def bool_element(element, name, default=True):
"""
Returns the bool value of an element, or a default if it's not defined
:param element: The XML Element object
:type element: etree._Element
:param name: The name of the element to evaluate
:type name: str
:param default: The default valu... | python | def bool_element(element, name, default=True):
"""
Returns the bool value of an element, or a default if it's not defined
:param element: The XML Element object
:type element: etree._Element
:param name: The name of the element to evaluate
:type name: str
:param default: The default valu... | [
"def",
"bool_element",
"(",
"element",
",",
"name",
",",
"default",
"=",
"True",
")",
":",
"element_value",
"=",
"element",
".",
"find",
"(",
"name",
")",
"if",
"element_value",
"is",
"not",
"None",
":",
"return",
"element_value",
".",
"text",
"==",
"'tr... | Returns the bool value of an element, or a default if it's not defined
:param element: The XML Element object
:type element: etree._Element
:param name: The name of the element to evaluate
:type name: str
:param default: The default value to return if the element is not defined
:type defaul... | [
"Returns",
"the",
"bool",
"value",
"of",
"an",
"element",
"or",
"a",
"default",
"if",
"it",
"s",
"not",
"defined",
":",
"param",
"element",
":",
"The",
"XML",
"Element",
"object",
":",
"type",
"element",
":",
"etree",
".",
"_Element"
] | train | https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/common.py#L143-L160 |
FujiMakoto/AgentML | agentml/common.py | int_element | def int_element(element, name, default=0):
"""
Returns the int value of an element, or a default if it's not defined
:param element: The XML Element object
:type element: etree._Element
:param name: The name of the element to evaluate
:type name: str
:param default: The default value to ... | python | def int_element(element, name, default=0):
"""
Returns the int value of an element, or a default if it's not defined
:param element: The XML Element object
:type element: etree._Element
:param name: The name of the element to evaluate
:type name: str
:param default: The default value to ... | [
"def",
"int_element",
"(",
"element",
",",
"name",
",",
"default",
"=",
"0",
")",
":",
"element_value",
"=",
"element",
".",
"find",
"(",
"name",
")",
"if",
"element_value",
"is",
"not",
"None",
":",
"try",
":",
"return",
"int",
"(",
"element_value",
"... | Returns the int value of an element, or a default if it's not defined
:param element: The XML Element object
:type element: etree._Element
:param name: The name of the element to evaluate
:type name: str
:param default: The default value to return if the element is not defined
:type default... | [
"Returns",
"the",
"int",
"value",
"of",
"an",
"element",
"or",
"a",
"default",
"if",
"it",
"s",
"not",
"defined",
":",
"param",
"element",
":",
"The",
"XML",
"Element",
"object",
":",
"type",
"element",
":",
"etree",
".",
"_Element"
] | train | https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/common.py#L163-L185 |
FlaskGuys/Flask-Imagine | flask_imagine/filters/downscale.py | DownscaleFilter.apply | def apply(self, resource):
"""
Apply filter to resource.
:param resource: Image
:return: Image
"""
if not isinstance(resource, Image.Image):
raise ValueError('Unsupported resource format: %s' % str(type(resource)))
original_width, original_height = re... | python | def apply(self, resource):
"""
Apply filter to resource.
:param resource: Image
:return: Image
"""
if not isinstance(resource, Image.Image):
raise ValueError('Unsupported resource format: %s' % str(type(resource)))
original_width, original_height = re... | [
"def",
"apply",
"(",
"self",
",",
"resource",
")",
":",
"if",
"not",
"isinstance",
"(",
"resource",
",",
"Image",
".",
"Image",
")",
":",
"raise",
"ValueError",
"(",
"'Unsupported resource format: %s'",
"%",
"str",
"(",
"type",
"(",
"resource",
")",
")",
... | Apply filter to resource.
:param resource: Image
:return: Image | [
"Apply",
"filter",
"to",
"resource",
".",
":",
"param",
"resource",
":",
"Image",
":",
"return",
":",
"Image"
] | train | https://github.com/FlaskGuys/Flask-Imagine/blob/f79c6517ecb5480b63a2b3b8554edb6e2ac8be8c/flask_imagine/filters/downscale.py#L24-L49 |
sprockets/sprockets.handlers.status | sprockets/handlers/status/__init__.py | StatusHandler.get | def get(self, *args, **kwargs):
"""Tornado RequestHandler GET request endpoint for reporting status
:param list args: positional args
:param dict kwargs: keyword args
"""
self.set_status(self._status_response_code())
self.write(self._status_response()) | python | def get(self, *args, **kwargs):
"""Tornado RequestHandler GET request endpoint for reporting status
:param list args: positional args
:param dict kwargs: keyword args
"""
self.set_status(self._status_response_code())
self.write(self._status_response()) | [
"def",
"get",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"set_status",
"(",
"self",
".",
"_status_response_code",
"(",
")",
")",
"self",
".",
"write",
"(",
"self",
".",
"_status_response",
"(",
")",
")"
] | Tornado RequestHandler GET request endpoint for reporting status
:param list args: positional args
:param dict kwargs: keyword args | [
"Tornado",
"RequestHandler",
"GET",
"request",
"endpoint",
"for",
"reporting",
"status"
] | train | https://github.com/sprockets/sprockets.handlers.status/blob/99d0eababe8c5617cb04c3545df418306b3a03ef/sprockets/handlers/status/__init__.py#L37-L45 |
botswana-harvard/edc-registration | edc_registration/signals.py | update_registered_subject_from_model_on_post_save | def update_registered_subject_from_model_on_post_save(sender, instance, raw, created, using, **kwargs):
"""Updates RegisteredSubject from models using UpdatesOrCreatesRegistrationModelMixin."""
if not raw and not kwargs.get('update_fields'):
try:
instance.registration_update_or_create()
... | python | def update_registered_subject_from_model_on_post_save(sender, instance, raw, created, using, **kwargs):
"""Updates RegisteredSubject from models using UpdatesOrCreatesRegistrationModelMixin."""
if not raw and not kwargs.get('update_fields'):
try:
instance.registration_update_or_create()
... | [
"def",
"update_registered_subject_from_model_on_post_save",
"(",
"sender",
",",
"instance",
",",
"raw",
",",
"created",
",",
"using",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"raw",
"and",
"not",
"kwargs",
".",
"get",
"(",
"'update_fields'",
")",
":",... | Updates RegisteredSubject from models using UpdatesOrCreatesRegistrationModelMixin. | [
"Updates",
"RegisteredSubject",
"from",
"models",
"using",
"UpdatesOrCreatesRegistrationModelMixin",
"."
] | train | https://github.com/botswana-harvard/edc-registration/blob/3daca624a496945fd4536488f6f80790bbecc081/edc_registration/signals.py#L7-L14 |
sloria/read_env | tasks.py | publish | def publish(ctx, test=False):
"""Publish to the cheeseshop."""
clean(ctx)
if test:
run('python setup.py register -r test sdist bdist_wheel', echo=True)
run('twine upload dist/* -r test', echo=True)
else:
run('python setup.py register sdist bdist_wheel', echo=True)
run('tw... | python | def publish(ctx, test=False):
"""Publish to the cheeseshop."""
clean(ctx)
if test:
run('python setup.py register -r test sdist bdist_wheel', echo=True)
run('twine upload dist/* -r test', echo=True)
else:
run('python setup.py register sdist bdist_wheel', echo=True)
run('tw... | [
"def",
"publish",
"(",
"ctx",
",",
"test",
"=",
"False",
")",
":",
"clean",
"(",
"ctx",
")",
"if",
"test",
":",
"run",
"(",
"'python setup.py register -r test sdist bdist_wheel'",
",",
"echo",
"=",
"True",
")",
"run",
"(",
"'twine upload dist/* -r test'",
",",... | Publish to the cheeseshop. | [
"Publish",
"to",
"the",
"cheeseshop",
"."
] | train | https://github.com/sloria/read_env/blob/90c5a7b38d70f06cd96b5d9a7e68e422bb5bd605/tasks.py#L37-L45 |
ptav/django-simplecrud | simplecrud/format.py | decode_format | def decode_format(number_format):
"""
Convert style string to format string ('{}' style), suffix and value scale
This is the core function used to convert numbers to strings
"""
style = number_format[0]
prec = "." + str(int(number_format[1:])) if len(number_format) > 1 else ""
if styl... | python | def decode_format(number_format):
"""
Convert style string to format string ('{}' style), suffix and value scale
This is the core function used to convert numbers to strings
"""
style = number_format[0]
prec = "." + str(int(number_format[1:])) if len(number_format) > 1 else ""
if styl... | [
"def",
"decode_format",
"(",
"number_format",
")",
":",
"style",
"=",
"number_format",
"[",
"0",
"]",
"prec",
"=",
"\".\"",
"+",
"str",
"(",
"int",
"(",
"number_format",
"[",
"1",
":",
"]",
")",
")",
"if",
"len",
"(",
"number_format",
")",
">",
"1",
... | Convert style string to format string ('{}' style), suffix and value scale
This is the core function used to convert numbers to strings | [
"Convert",
"style",
"string",
"to",
"format",
"string",
"(",
"{}",
"style",
")",
"suffix",
"and",
"value",
"scale",
"This",
"is",
"the",
"core",
"function",
"used",
"to",
"convert",
"numbers",
"to",
"strings"
] | train | https://github.com/ptav/django-simplecrud/blob/468f6322aab35c8001311ee7920114400a040f6c/simplecrud/format.py#L38-L76 |
ptav/django-simplecrud | simplecrud/format.py | format_value | def format_value(value,number_format):
"Convert number to string using a style string"
style,sufix,scale = decode_format(number_format)
fmt = "{0:" + style + "}" + sufix
return fmt.format(scale * value) | python | def format_value(value,number_format):
"Convert number to string using a style string"
style,sufix,scale = decode_format(number_format)
fmt = "{0:" + style + "}" + sufix
return fmt.format(scale * value) | [
"def",
"format_value",
"(",
"value",
",",
"number_format",
")",
":",
"style",
",",
"sufix",
",",
"scale",
"=",
"decode_format",
"(",
"number_format",
")",
"fmt",
"=",
"\"{0:\"",
"+",
"style",
"+",
"\"}\"",
"+",
"sufix",
"return",
"fmt",
".",
"format",
"(... | Convert number to string using a style string | [
"Convert",
"number",
"to",
"string",
"using",
"a",
"style",
"string"
] | train | https://github.com/ptav/django-simplecrud/blob/468f6322aab35c8001311ee7920114400a040f6c/simplecrud/format.py#L80-L86 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/reflect/PropertyReflector.py | PropertyReflector.has_property | def has_property(obj, name):
"""
Checks if object has a property with specified name.
:param obj: an object to introspect.
:param name: a name of the property to check.
:return: true if the object has the property and false if it doesn't.
"""
if obj == None:
... | python | def has_property(obj, name):
"""
Checks if object has a property with specified name.
:param obj: an object to introspect.
:param name: a name of the property to check.
:return: true if the object has the property and false if it doesn't.
"""
if obj == None:
... | [
"def",
"has_property",
"(",
"obj",
",",
"name",
")",
":",
"if",
"obj",
"==",
"None",
":",
"raise",
"Exception",
"(",
"\"Object cannot be null\"",
")",
"if",
"name",
"==",
"None",
":",
"raise",
"Exception",
"(",
"\"Property name cannot be null\"",
")",
"name",
... | Checks if object has a property with specified name.
:param obj: an object to introspect.
:param name: a name of the property to check.
:return: true if the object has the property and false if it doesn't. | [
"Checks",
"if",
"object",
"has",
"a",
"property",
"with",
"specified",
"name",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/reflect/PropertyReflector.py#L43-L69 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/reflect/PropertyReflector.py | PropertyReflector.get_property | def get_property(obj, name):
"""
Gets value of object property specified by its name.
:param obj: an object to read property from.
:param name: a name of the property to get.
:return: the property value or null if property doesn't exist or introspection failed.
"""
... | python | def get_property(obj, name):
"""
Gets value of object property specified by its name.
:param obj: an object to read property from.
:param name: a name of the property to get.
:return: the property value or null if property doesn't exist or introspection failed.
"""
... | [
"def",
"get_property",
"(",
"obj",
",",
"name",
")",
":",
"if",
"obj",
"==",
"None",
":",
"raise",
"Exception",
"(",
"\"Object cannot be null\"",
")",
"if",
"name",
"==",
"None",
":",
"raise",
"Exception",
"(",
"\"Property name cannot be null\"",
")",
"name",
... | Gets value of object property specified by its name.
:param obj: an object to read property from.
:param name: a name of the property to get.
:return: the property value or null if property doesn't exist or introspection failed. | [
"Gets",
"value",
"of",
"object",
"property",
"specified",
"by",
"its",
"name",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/reflect/PropertyReflector.py#L73-L102 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/reflect/PropertyReflector.py | PropertyReflector.get_property_names | def get_property_names(obj):
"""
Gets names of all properties implemented in specified object.
:param obj: an objec to introspect.
:return: a list with property names.
"""
property_names = []
for property_name in dir(obj):
property = getatt... | python | def get_property_names(obj):
"""
Gets names of all properties implemented in specified object.
:param obj: an objec to introspect.
:return: a list with property names.
"""
property_names = []
for property_name in dir(obj):
property = getatt... | [
"def",
"get_property_names",
"(",
"obj",
")",
":",
"property_names",
"=",
"[",
"]",
"for",
"property_name",
"in",
"dir",
"(",
"obj",
")",
":",
"property",
"=",
"getattr",
"(",
"obj",
",",
"property_name",
")",
"if",
"PropertyReflector",
".",
"_is_property",
... | Gets names of all properties implemented in specified object.
:param obj: an objec to introspect.
:return: a list with property names. | [
"Gets",
"names",
"of",
"all",
"properties",
"implemented",
"in",
"specified",
"object",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/reflect/PropertyReflector.py#L106-L123 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/reflect/PropertyReflector.py | PropertyReflector.get_properties | def get_properties(obj):
"""
Get values of all properties in specified object and returns them as a map.
:param obj: an object to get properties from.
:return: a map, containing the names of the object's properties and their values.
"""
properties = {}
... | python | def get_properties(obj):
"""
Get values of all properties in specified object and returns them as a map.
:param obj: an object to get properties from.
:return: a map, containing the names of the object's properties and their values.
"""
properties = {}
... | [
"def",
"get_properties",
"(",
"obj",
")",
":",
"properties",
"=",
"{",
"}",
"for",
"property_name",
"in",
"dir",
"(",
"obj",
")",
":",
"property",
"=",
"getattr",
"(",
"obj",
",",
"property_name",
")",
"if",
"PropertyReflector",
".",
"_is_property",
"(",
... | Get values of all properties in specified object and returns them as a map.
:param obj: an object to get properties from.
:return: a map, containing the names of the object's properties and their values. | [
"Get",
"values",
"of",
"all",
"properties",
"in",
"specified",
"object",
"and",
"returns",
"them",
"as",
"a",
"map",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/reflect/PropertyReflector.py#L127-L144 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/reflect/PropertyReflector.py | PropertyReflector.set_property | def set_property(obj, name, value):
"""
Sets value of object property specified by its name.
If the property does not exist or introspection fails
this method doesn't do anything and doesn't any throw errors.
:param obj: an object to write property to.
:param name: a n... | python | def set_property(obj, name, value):
"""
Sets value of object property specified by its name.
If the property does not exist or introspection fails
this method doesn't do anything and doesn't any throw errors.
:param obj: an object to write property to.
:param name: a n... | [
"def",
"set_property",
"(",
"obj",
",",
"name",
",",
"value",
")",
":",
"if",
"obj",
"==",
"None",
":",
"raise",
"Exception",
"(",
"\"Object cannot be null\"",
")",
"if",
"name",
"==",
"None",
":",
"raise",
"Exception",
"(",
"\"Property name cannot be null\"",... | Sets value of object property specified by its name.
If the property does not exist or introspection fails
this method doesn't do anything and doesn't any throw errors.
:param obj: an object to write property to.
:param name: a name of the property to set.
:param value: a new... | [
"Sets",
"value",
"of",
"object",
"property",
"specified",
"by",
"its",
"name",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/reflect/PropertyReflector.py#L148-L178 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/reflect/PropertyReflector.py | PropertyReflector.set_properties | def set_properties(obj, values):
"""
Sets values of some (all) object properties.
If some properties do not exist or introspection fails
they are just silently skipped and no errors thrown.
:param obj: an object to write properties to.
:param values: a map, containing ... | python | def set_properties(obj, values):
"""
Sets values of some (all) object properties.
If some properties do not exist or introspection fails
they are just silently skipped and no errors thrown.
:param obj: an object to write properties to.
:param values: a map, containing ... | [
"def",
"set_properties",
"(",
"obj",
",",
"values",
")",
":",
"if",
"values",
"==",
"None",
"or",
"len",
"(",
"values",
")",
"==",
"0",
":",
"return",
"for",
"(",
"name",
",",
"value",
")",
"in",
"values",
":",
"PropertyReflector",
".",
"set_property",... | Sets values of some (all) object properties.
If some properties do not exist or introspection fails
they are just silently skipped and no errors thrown.
:param obj: an object to write properties to.
:param values: a map, containing property names and their values. | [
"Sets",
"values",
"of",
"some",
"(",
"all",
")",
"object",
"properties",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/reflect/PropertyReflector.py#L182-L197 |
thehq/python-crossbarhttp | crossbarhttp/crossbarhttp.py | Client.publish | def publish(self, topic, *args, **kwargs):
"""
Publishes the request to the bridge service
:param topic: The topic to publish to
:param args: The arguments
:param kwargs: The key/word arguments
:return: The ID of the publish
"""
assert topic is not None
... | python | def publish(self, topic, *args, **kwargs):
"""
Publishes the request to the bridge service
:param topic: The topic to publish to
:param args: The arguments
:param kwargs: The key/word arguments
:return: The ID of the publish
"""
assert topic is not None
... | [
"def",
"publish",
"(",
"self",
",",
"topic",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"topic",
"is",
"not",
"None",
"params",
"=",
"{",
"\"topic\"",
":",
"topic",
",",
"\"args\"",
":",
"args",
",",
"\"kwargs\"",
":",
"kwargs",
... | Publishes the request to the bridge service
:param topic: The topic to publish to
:param args: The arguments
:param kwargs: The key/word arguments
:return: The ID of the publish | [
"Publishes",
"the",
"request",
"to",
"the",
"bridge",
"service",
":",
"param",
"topic",
":",
"The",
"topic",
"to",
"publish",
"to",
":",
"param",
"args",
":",
"The",
"arguments",
":",
"param",
"kwargs",
":",
"The",
"key",
"/",
"word",
"arguments",
":",
... | train | https://github.com/thehq/python-crossbarhttp/blob/15af59969ca1ace3b11f2d94ef966e0017cb1c77/crossbarhttp/crossbarhttp.py#L76-L93 |
thehq/python-crossbarhttp | crossbarhttp/crossbarhttp.py | Client.call | def call(self, procedure, *args, **kwargs):
"""
Calls a procedure from the bridge service
:param topic: The topic to publish to
:param args: The arguments
:param kwargs: The key/word arguments
:return: The response from calling the procedure
"""
assert pro... | python | def call(self, procedure, *args, **kwargs):
"""
Calls a procedure from the bridge service
:param topic: The topic to publish to
:param args: The arguments
:param kwargs: The key/word arguments
:return: The response from calling the procedure
"""
assert pro... | [
"def",
"call",
"(",
"self",
",",
"procedure",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"procedure",
"is",
"not",
"None",
"params",
"=",
"{",
"\"procedure\"",
":",
"procedure",
",",
"\"args\"",
":",
"args",
",",
"\"kwargs\"",
":",
... | Calls a procedure from the bridge service
:param topic: The topic to publish to
:param args: The arguments
:param kwargs: The key/word arguments
:return: The response from calling the procedure | [
"Calls",
"a",
"procedure",
"from",
"the",
"bridge",
"service",
":",
"param",
"topic",
":",
"The",
"topic",
"to",
"publish",
"to",
":",
"param",
"args",
":",
"The",
"arguments",
":",
"param",
"kwargs",
":",
"The",
"key",
"/",
"word",
"arguments",
":",
"... | train | https://github.com/thehq/python-crossbarhttp/blob/15af59969ca1ace3b11f2d94ef966e0017cb1c77/crossbarhttp/crossbarhttp.py#L95-L124 |
thehq/python-crossbarhttp | crossbarhttp/crossbarhttp.py | Client._compute_signature | def _compute_signature(self, body):
"""
Computes the signature.
Described at:
http://crossbar.io/docs/HTTP-Bridge-Services-Caller/
Reference code is at:
https://github.com/crossbario/crossbar/blob/master/crossbar/adapter/rest/common.py
:return: (signature, none... | python | def _compute_signature(self, body):
"""
Computes the signature.
Described at:
http://crossbar.io/docs/HTTP-Bridge-Services-Caller/
Reference code is at:
https://github.com/crossbario/crossbar/blob/master/crossbar/adapter/rest/common.py
:return: (signature, none... | [
"def",
"_compute_signature",
"(",
"self",
",",
"body",
")",
":",
"timestamp",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
".",
"strftime",
"(",
"\"%Y-%m-%dT%H:%M:%S.%fZ\"",
")",
"nonce",
"=",
"randint",
"(",
"0",
",",
"2",
"**",
"53",
")",... | Computes the signature.
Described at:
http://crossbar.io/docs/HTTP-Bridge-Services-Caller/
Reference code is at:
https://github.com/crossbario/crossbar/blob/master/crossbar/adapter/rest/common.py
:return: (signature, none, timestamp) | [
"Computes",
"the",
"signature",
"."
] | train | https://github.com/thehq/python-crossbarhttp/blob/15af59969ca1ace3b11f2d94ef966e0017cb1c77/crossbarhttp/crossbarhttp.py#L126-L151 |
thehq/python-crossbarhttp | crossbarhttp/crossbarhttp.py | Client._make_api_call | def _make_api_call(self, method, url, json_params=None):
"""
Performs the REST API Call
:param method: HTTP Method
:param url: The URL
:param json_params: The parameters intended to be JSON serialized
:return:
"""
if self.verbose is True:
prin... | python | def _make_api_call(self, method, url, json_params=None):
"""
Performs the REST API Call
:param method: HTTP Method
:param url: The URL
:param json_params: The parameters intended to be JSON serialized
:return:
"""
if self.verbose is True:
prin... | [
"def",
"_make_api_call",
"(",
"self",
",",
"method",
",",
"url",
",",
"json_params",
"=",
"None",
")",
":",
"if",
"self",
".",
"verbose",
"is",
"True",
":",
"print",
"\"\\ncrossbarhttp: Request: %s %s\"",
"%",
"(",
"method",
",",
"url",
")",
"if",
"json_pa... | Performs the REST API Call
:param method: HTTP Method
:param url: The URL
:param json_params: The parameters intended to be JSON serialized
:return: | [
"Performs",
"the",
"REST",
"API",
"Call",
":",
"param",
"method",
":",
"HTTP",
"Method",
":",
"param",
"url",
":",
"The",
"URL",
":",
"param",
"json_params",
":",
"The",
"parameters",
"intended",
"to",
"be",
"JSON",
"serialized",
":",
"return",
":"
] | train | https://github.com/thehq/python-crossbarhttp/blob/15af59969ca1ace3b11f2d94ef966e0017cb1c77/crossbarhttp/crossbarhttp.py#L153-L207 |
twneale/hercules | hercules/lazylist.py | LazyList.exhaust | def exhaust(self, index = None):
"""Exhaust the iterator generating this LazyList's values.
if index is None, this will exhaust the iterator completely.
Otherwise, it will iterate over the iterator until either the list
has a value for index or the iterator is exhausted.
"""
... | python | def exhaust(self, index = None):
"""Exhaust the iterator generating this LazyList's values.
if index is None, this will exhaust the iterator completely.
Otherwise, it will iterate over the iterator until either the list
has a value for index or the iterator is exhausted.
"""
... | [
"def",
"exhaust",
"(",
"self",
",",
"index",
"=",
"None",
")",
":",
"if",
"self",
".",
"_exhausted",
":",
"return",
"if",
"index",
"is",
"None",
":",
"ind_range",
"=",
"itertools",
".",
"count",
"(",
"len",
"(",
"self",
")",
")",
"else",
":",
"ind_... | Exhaust the iterator generating this LazyList's values.
if index is None, this will exhaust the iterator completely.
Otherwise, it will iterate over the iterator until either the list
has a value for index or the iterator is exhausted. | [
"Exhaust",
"the",
"iterator",
"generating",
"this",
"LazyList",
"s",
"values",
".",
"if",
"index",
"is",
"None",
"this",
"will",
"exhaust",
"the",
"iterator",
"completely",
".",
"Otherwise",
"it",
"will",
"iterate",
"over",
"the",
"iterator",
"until",
"either"... | train | https://github.com/twneale/hercules/blob/cd61582ef7e593093e9b28b56798df4203d1467a/hercules/lazylist.py#L77-L95 |
klmitch/policies | policies/parser.py | binary_construct | def binary_construct(tokens):
"""
Construct proper instructions for binary expressions from a
sequence of tokens at the same precedence level. For instance, if
the tokens represent "1 + 2 + 3", this will return the instruction
array "1 2 add_op 3 add_op".
:param tokens: The sequence of tokens.... | python | def binary_construct(tokens):
"""
Construct proper instructions for binary expressions from a
sequence of tokens at the same precedence level. For instance, if
the tokens represent "1 + 2 + 3", this will return the instruction
array "1 2 add_op 3 add_op".
:param tokens: The sequence of tokens.... | [
"def",
"binary_construct",
"(",
"tokens",
")",
":",
"# Initialize the list of instructions we will return with the",
"# left-most element",
"instructions",
"=",
"[",
"tokens",
"[",
"0",
"]",
"]",
"# Now process all the remaining tokens, building up the array we",
"# will return",
... | Construct proper instructions for binary expressions from a
sequence of tokens at the same precedence level. For instance, if
the tokens represent "1 + 2 + 3", this will return the instruction
array "1 2 add_op 3 add_op".
:param tokens: The sequence of tokens.
:returns: An instance of ``Instructi... | [
"Construct",
"proper",
"instructions",
"for",
"binary",
"expressions",
"from",
"a",
"sequence",
"of",
"tokens",
"at",
"the",
"same",
"precedence",
"level",
".",
"For",
"instance",
"if",
"the",
"tokens",
"represent",
"1",
"+",
"2",
"+",
"3",
"this",
"will",
... | train | https://github.com/klmitch/policies/blob/edf26c5707a5a0cc8e9f59a209a64dee7f79b7a4/policies/parser.py#L45-L73 |
klmitch/policies | policies/parser.py | parse_rule | def parse_rule(name, rule_text, do_raise=False):
"""
Parses the given rule text.
:param name: The name of the rule. Used when emitting log
messages regarding a failure to parse the rule.
:param rule_text: The text of the rule to parse.
:param do_raise: If ``False`` and the rule fa... | python | def parse_rule(name, rule_text, do_raise=False):
"""
Parses the given rule text.
:param name: The name of the rule. Used when emitting log
messages regarding a failure to parse the rule.
:param rule_text: The text of the rule to parse.
:param do_raise: If ``False`` and the rule fa... | [
"def",
"parse_rule",
"(",
"name",
",",
"rule_text",
",",
"do_raise",
"=",
"False",
")",
":",
"try",
":",
"return",
"rule",
".",
"parseString",
"(",
"rule_text",
",",
"parseAll",
"=",
"True",
")",
"[",
"0",
"]",
"except",
"pyparsing",
".",
"ParseException... | Parses the given rule text.
:param name: The name of the rule. Used when emitting log
messages regarding a failure to parse the rule.
:param rule_text: The text of the rule to parse.
:param do_raise: If ``False`` and the rule fails to parse, a log
message is emitted t... | [
"Parses",
"the",
"given",
"rule",
"text",
"."
] | train | https://github.com/klmitch/policies/blob/edf26c5707a5a0cc8e9f59a209a64dee7f79b7a4/policies/parser.py#L369-L401 |
crypto101/arthur | arthur/util.py | MultiDeferred.tee | def tee(self):
"""
Produces a new deferred and returns it. If this C{MultiDeferred}
has not been fired (callbacked or errbacked) yet, the deferred
will not have been fired yet either, but will be fired when
and if this C{MultiDeferred} gets fired in the future. If this
C{... | python | def tee(self):
"""
Produces a new deferred and returns it. If this C{MultiDeferred}
has not been fired (callbacked or errbacked) yet, the deferred
will not have been fired yet either, but will be fired when
and if this C{MultiDeferred} gets fired in the future. If this
C{... | [
"def",
"tee",
"(",
"self",
")",
":",
"if",
"self",
".",
"_result",
"is",
"not",
"_NO_RESULT",
":",
"if",
"not",
"self",
".",
"_isFailure",
":",
"return",
"succeed",
"(",
"self",
".",
"_result",
")",
"else",
":",
"return",
"fail",
"(",
"self",
".",
... | Produces a new deferred and returns it. If this C{MultiDeferred}
has not been fired (callbacked or errbacked) yet, the deferred
will not have been fired yet either, but will be fired when
and if this C{MultiDeferred} gets fired in the future. If this
C{MultiDeferred} has been fired, retu... | [
"Produces",
"a",
"new",
"deferred",
"and",
"returns",
"it",
".",
"If",
"this",
"C",
"{",
"MultiDeferred",
"}",
"has",
"not",
"been",
"fired",
"(",
"callbacked",
"or",
"errbacked",
")",
"yet",
"the",
"deferred",
"will",
"not",
"have",
"been",
"fired",
"ye... | train | https://github.com/crypto101/arthur/blob/c32e693fb5af17eac010e3b20f7653ed6e11eb6a/arthur/util.py#L19-L40 |
crypto101/arthur | arthur/util.py | MultiDeferred.callback | def callback(self, result):
"""
Callbacks the deferreds previously produced by this object.
@param result: The object which will be passed to the
C{callback} method of all C{Deferred}s previously produced by
this object's C{tee} method.
@raise AlreadyCalledError: If L{ca... | python | def callback(self, result):
"""
Callbacks the deferreds previously produced by this object.
@param result: The object which will be passed to the
C{callback} method of all C{Deferred}s previously produced by
this object's C{tee} method.
@raise AlreadyCalledError: If L{ca... | [
"def",
"callback",
"(",
"self",
",",
"result",
")",
":",
"self",
".",
"_setResult",
"(",
"result",
")",
"self",
".",
"_isFailure",
"=",
"False",
"for",
"d",
"in",
"self",
".",
"_deferreds",
":",
"d",
".",
"callback",
"(",
"result",
")"
] | Callbacks the deferreds previously produced by this object.
@param result: The object which will be passed to the
C{callback} method of all C{Deferred}s previously produced by
this object's C{tee} method.
@raise AlreadyCalledError: If L{callback} or L{errback} has
already been c... | [
"Callbacks",
"the",
"deferreds",
"previously",
"produced",
"by",
"this",
"object",
"."
] | train | https://github.com/crypto101/arthur/blob/c32e693fb5af17eac010e3b20f7653ed6e11eb6a/arthur/util.py#L43-L57 |
crypto101/arthur | arthur/util.py | MultiDeferred.errback | def errback(self, failure):
"""
Errbacks the deferreds previously produced by this object.
@param failure: The object which will be passed to the
C{errback} method of all C{Deferred}s previously produced by
this object's C{tee} method.
@raise AlreadyCalledError: If L{cal... | python | def errback(self, failure):
"""
Errbacks the deferreds previously produced by this object.
@param failure: The object which will be passed to the
C{errback} method of all C{Deferred}s previously produced by
this object's C{tee} method.
@raise AlreadyCalledError: If L{cal... | [
"def",
"errback",
"(",
"self",
",",
"failure",
")",
":",
"self",
".",
"_setResult",
"(",
"failure",
")",
"self",
".",
"_isFailure",
"=",
"True",
"for",
"d",
"in",
"self",
".",
"_deferreds",
":",
"d",
".",
"errback",
"(",
"failure",
")"
] | Errbacks the deferreds previously produced by this object.
@param failure: The object which will be passed to the
C{errback} method of all C{Deferred}s previously produced by
this object's C{tee} method.
@raise AlreadyCalledError: If L{callback} or L{errback} has
already been ca... | [
"Errbacks",
"the",
"deferreds",
"previously",
"produced",
"by",
"this",
"object",
"."
] | train | https://github.com/crypto101/arthur/blob/c32e693fb5af17eac010e3b20f7653ed6e11eb6a/arthur/util.py#L60-L74 |
crypto101/arthur | arthur/util.py | MultiDeferred._setResult | def _setResult(self, result):
"""
Sets the result. If the result is already set, raises
C{AlreadyCalledError}.
@raise AlreadyCalledError: The result was already set.
@return: C{None}, if the result was successfully set.
"""
if self._result is not _NO_RESULT:
... | python | def _setResult(self, result):
"""
Sets the result. If the result is already set, raises
C{AlreadyCalledError}.
@raise AlreadyCalledError: The result was already set.
@return: C{None}, if the result was successfully set.
"""
if self._result is not _NO_RESULT:
... | [
"def",
"_setResult",
"(",
"self",
",",
"result",
")",
":",
"if",
"self",
".",
"_result",
"is",
"not",
"_NO_RESULT",
":",
"raise",
"AlreadyCalledError",
"(",
")",
"self",
".",
"_result",
"=",
"result"
] | Sets the result. If the result is already set, raises
C{AlreadyCalledError}.
@raise AlreadyCalledError: The result was already set.
@return: C{None}, if the result was successfully set. | [
"Sets",
"the",
"result",
".",
"If",
"the",
"result",
"is",
"already",
"set",
"raises",
"C",
"{",
"AlreadyCalledError",
"}",
"."
] | train | https://github.com/crypto101/arthur/blob/c32e693fb5af17eac010e3b20f7653ed6e11eb6a/arthur/util.py#L77-L88 |
ZeitOnline/sphinx_elasticsearch | src/sphinx_elasticsearch/parse_json.py | process_all_json_files | def process_all_json_files(build_dir):
"""Return a list of pages to index"""
html_files = []
for root, _, files in os.walk(build_dir):
for filename in fnmatch.filter(files, '*.fjson'):
if filename in ['search.fjson', 'genindex.fjson',
'py-modindex.fjson']:
... | python | def process_all_json_files(build_dir):
"""Return a list of pages to index"""
html_files = []
for root, _, files in os.walk(build_dir):
for filename in fnmatch.filter(files, '*.fjson'):
if filename in ['search.fjson', 'genindex.fjson',
'py-modindex.fjson']:
... | [
"def",
"process_all_json_files",
"(",
"build_dir",
")",
":",
"html_files",
"=",
"[",
"]",
"for",
"root",
",",
"_",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"build_dir",
")",
":",
"for",
"filename",
"in",
"fnmatch",
".",
"filter",
"(",
"files",
",",
... | Return a list of pages to index | [
"Return",
"a",
"list",
"of",
"pages",
"to",
"index"
] | train | https://github.com/ZeitOnline/sphinx_elasticsearch/blob/cc5ebc18683439bd0949069045fcfd0290476edd/src/sphinx_elasticsearch/parse_json.py#L38-L56 |
ZeitOnline/sphinx_elasticsearch | src/sphinx_elasticsearch/parse_json.py | process_file | def process_file(filename):
"""Read a file from disk and parse it into a structured dict."""
try:
with codecs.open(filename, encoding='utf-8', mode='r') as f:
file_contents = f.read()
except IOError:
log.info('Unable to read file: %s', filename)
return None
data = jso... | python | def process_file(filename):
"""Read a file from disk and parse it into a structured dict."""
try:
with codecs.open(filename, encoding='utf-8', mode='r') as f:
file_contents = f.read()
except IOError:
log.info('Unable to read file: %s', filename)
return None
data = jso... | [
"def",
"process_file",
"(",
"filename",
")",
":",
"try",
":",
"with",
"codecs",
".",
"open",
"(",
"filename",
",",
"encoding",
"=",
"'utf-8'",
",",
"mode",
"=",
"'r'",
")",
"as",
"f",
":",
"file_contents",
"=",
"f",
".",
"read",
"(",
")",
"except",
... | Read a file from disk and parse it into a structured dict. | [
"Read",
"a",
"file",
"from",
"disk",
"and",
"parse",
"it",
"into",
"a",
"structured",
"dict",
"."
] | train | https://github.com/ZeitOnline/sphinx_elasticsearch/blob/cc5ebc18683439bd0949069045fcfd0290476edd/src/sphinx_elasticsearch/parse_json.py#L59-L88 |
ZeitOnline/sphinx_elasticsearch | src/sphinx_elasticsearch/parse_json.py | process_headers | def process_headers(data, filename):
"""Read headers from toc data."""
headers = []
if 'toc' in data:
for element in PyQuery(data['toc'])('a'):
headers.append(recurse_while_none(element))
if None in headers:
log.info('Unable to index file headers for: %s', filename)
... | python | def process_headers(data, filename):
"""Read headers from toc data."""
headers = []
if 'toc' in data:
for element in PyQuery(data['toc'])('a'):
headers.append(recurse_while_none(element))
if None in headers:
log.info('Unable to index file headers for: %s', filename)
... | [
"def",
"process_headers",
"(",
"data",
",",
"filename",
")",
":",
"headers",
"=",
"[",
"]",
"if",
"'toc'",
"in",
"data",
":",
"for",
"element",
"in",
"PyQuery",
"(",
"data",
"[",
"'toc'",
"]",
")",
"(",
"'a'",
")",
":",
"headers",
".",
"append",
"(... | Read headers from toc data. | [
"Read",
"headers",
"from",
"toc",
"data",
"."
] | train | https://github.com/ZeitOnline/sphinx_elasticsearch/blob/cc5ebc18683439bd0949069045fcfd0290476edd/src/sphinx_elasticsearch/parse_json.py#L91-L99 |
siemens/django-dingos | dingos/importer.py | Generic_XML_Import.xml_import | def xml_import(self,
filepath=None,
xml_content = None,
markings=None,
identifier_ns_uri = None,
uid = None,
**kargs):
"""
Call this function for generic import of an XML file with the foll... | python | def xml_import(self,
filepath=None,
xml_content = None,
markings=None,
identifier_ns_uri = None,
uid = None,
**kargs):
"""
Call this function for generic import of an XML file with the foll... | [
"def",
"xml_import",
"(",
"self",
",",
"filepath",
"=",
"None",
",",
"xml_content",
"=",
"None",
",",
"markings",
"=",
"None",
",",
"identifier_ns_uri",
"=",
"None",
",",
"uid",
"=",
"None",
",",
"*",
"*",
"kargs",
")",
":",
"# Reset bookkeeping dictionari... | Call this function for generic import of an XML file with the following arguments:
- filename: Path to XML file
- markings (optional): List of information objects with which the imported object
should be marked
- identifier_ns_uri: Namespace of the identifiers, if identifiers are to b... | [
"Call",
"this",
"function",
"for",
"generic",
"import",
"of",
"an",
"XML",
"file",
"with",
"the",
"following",
"arguments",
":"
] | train | https://github.com/siemens/django-dingos/blob/7154f75b06d2538568e2f2455a76f3d0db0b7d70/dingos/importer.py#L121-L197 |
siemens/django-dingos | dingos/importer.py | DingoImportCommand.create_import_marking | def create_import_marking(self, args, options):
"""
This function parses the `--marking_json` and `--marking_pfill` arguments
and creates a marking object if these parameters are specified.
Look into 'dingos/management/commands/dingos_generic_xml_import.py to see how
this is use... | python | def create_import_marking(self, args, options):
"""
This function parses the `--marking_json` and `--marking_pfill` arguments
and creates a marking object if these parameters are specified.
Look into 'dingos/management/commands/dingos_generic_xml_import.py to see how
this is use... | [
"def",
"create_import_marking",
"(",
"self",
",",
"args",
",",
"options",
")",
":",
"marking_json",
"=",
"None",
"placeholder_dict",
"=",
"{",
"}",
"if",
"options",
".",
"get",
"(",
"'marking_json'",
")",
":",
"# Open json",
"with",
"open",
"(",
"options",
... | This function parses the `--marking_json` and `--marking_pfill` arguments
and creates a marking object if these parameters are specified.
Look into 'dingos/management/commands/dingos_generic_xml_import.py to see how
this is used to specify a Django command line argument 'dingos_generic_xml_impo... | [
"This",
"function",
"parses",
"the",
"--",
"marking_json",
"and",
"--",
"marking_pfill",
"arguments",
"and",
"creates",
"a",
"marking",
"object",
"if",
"these",
"parameters",
"are",
"specified",
"."
] | train | https://github.com/siemens/django-dingos/blob/7154f75b06d2538568e2f2455a76f3d0db0b7d70/dingos/importer.py#L291-L356 |
kervi/kervi-devices | kervi/devices/sensors/TSL2561.py | TSL2561DeviceDriver.set_gain | def set_gain(self, gain=1):
""" Set the gain """
if gain == 1:
self.i2c.write8(0x81, 0x02)
else:
self.i2c.write8(0x81, 0x12)
time.sleep(self.pause) | python | def set_gain(self, gain=1):
""" Set the gain """
if gain == 1:
self.i2c.write8(0x81, 0x02)
else:
self.i2c.write8(0x81, 0x12)
time.sleep(self.pause) | [
"def",
"set_gain",
"(",
"self",
",",
"gain",
"=",
"1",
")",
":",
"if",
"gain",
"==",
"1",
":",
"self",
".",
"i2c",
".",
"write8",
"(",
"0x81",
",",
"0x02",
")",
"else",
":",
"self",
".",
"i2c",
".",
"write8",
"(",
"0x81",
",",
"0x12",
")",
"t... | Set the gain | [
"Set",
"the",
"gain"
] | train | https://github.com/kervi/kervi-devices/blob/c6aaddc6da1d0bce0ea2b0c6eb8393ba10aefa56/kervi/devices/sensors/TSL2561.py#L31-L38 |
kervi/kervi-devices | kervi/devices/sensors/TSL2561.py | TSL2561DeviceDriver.read_value | def read_value(self):
"""Grabs a lux reading either with autoranging (gain=0) or with a specified gain (1, 16)"""
if self.gain == 1 or self.gain == 16:
self.set_gain(self.gain)
ambient = self.read_full()
ir_reading = self.read_ir()
elif self.gain == 0:
... | python | def read_value(self):
"""Grabs a lux reading either with autoranging (gain=0) or with a specified gain (1, 16)"""
if self.gain == 1 or self.gain == 16:
self.set_gain(self.gain)
ambient = self.read_full()
ir_reading = self.read_ir()
elif self.gain == 0:
... | [
"def",
"read_value",
"(",
"self",
")",
":",
"if",
"self",
".",
"gain",
"==",
"1",
"or",
"self",
".",
"gain",
"==",
"16",
":",
"self",
".",
"set_gain",
"(",
"self",
".",
"gain",
")",
"ambient",
"=",
"self",
".",
"read_full",
"(",
")",
"ir_reading",
... | Grabs a lux reading either with autoranging (gain=0) or with a specified gain (1, 16) | [
"Grabs",
"a",
"lux",
"reading",
"either",
"with",
"autoranging",
"(",
"gain",
"=",
"0",
")",
"or",
"with",
"a",
"specified",
"gain",
"(",
"1",
"16",
")"
] | train | https://github.com/kervi/kervi-devices/blob/c6aaddc6da1d0bce0ea2b0c6eb8393ba10aefa56/kervi/devices/sensors/TSL2561.py#L59-L95 |
mback2k/python-appengine-auth | social_appengine_auth/backends.py | BaseGoogleAppEngineAuth.get_user_details | def get_user_details(self, response):
"""Return user details from OAuth Profile Google App Engine App"""
email = response['email']
username = response.get('nickname', email).split('@', 1)[0]
return {'username': username,
'email': email,
'fullname': '',
... | python | def get_user_details(self, response):
"""Return user details from OAuth Profile Google App Engine App"""
email = response['email']
username = response.get('nickname', email).split('@', 1)[0]
return {'username': username,
'email': email,
'fullname': '',
... | [
"def",
"get_user_details",
"(",
"self",
",",
"response",
")",
":",
"email",
"=",
"response",
"[",
"'email'",
"]",
"username",
"=",
"response",
".",
"get",
"(",
"'nickname'",
",",
"email",
")",
".",
"split",
"(",
"'@'",
",",
"1",
")",
"[",
"0",
"]",
... | Return user details from OAuth Profile Google App Engine App | [
"Return",
"user",
"details",
"from",
"OAuth",
"Profile",
"Google",
"App",
"Engine",
"App"
] | train | https://github.com/mback2k/python-appengine-auth/blob/dd27a0c53c7bebe147f7a6e3606c67ec673ac4d6/social_appengine_auth/backends.py#L24-L32 |
mback2k/python-appengine-auth | social_appengine_auth/backends.py | GoogleAppEngineOAuth.user_data | def user_data(self, access_token, *args, **kwargs):
"""Load user data from OAuth Profile Google App Engine App"""
url = GOOGLE_APPENGINE_PROFILE_V1
auth = self.oauth_auth(access_token)
return self.get_json(url,
auth=auth, params=auth
) | python | def user_data(self, access_token, *args, **kwargs):
"""Load user data from OAuth Profile Google App Engine App"""
url = GOOGLE_APPENGINE_PROFILE_V1
auth = self.oauth_auth(access_token)
return self.get_json(url,
auth=auth, params=auth
) | [
"def",
"user_data",
"(",
"self",
",",
"access_token",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"GOOGLE_APPENGINE_PROFILE_V1",
"auth",
"=",
"self",
".",
"oauth_auth",
"(",
"access_token",
")",
"return",
"self",
".",
"get_json",
"(",
... | Load user data from OAuth Profile Google App Engine App | [
"Load",
"user",
"data",
"from",
"OAuth",
"Profile",
"Google",
"App",
"Engine",
"App"
] | train | https://github.com/mback2k/python-appengine-auth/blob/dd27a0c53c7bebe147f7a6e3606c67ec673ac4d6/social_appengine_auth/backends.py#L42-L48 |
mback2k/python-appengine-auth | social_appengine_auth/backends.py | GoogleAppEngineOAuth2.user_data | def user_data(self, access_token, *args, **kwargs):
"""Load user data from OAuth Profile Google App Engine App"""
url = GOOGLE_APPENGINE_PROFILE_V2
return self.get_json(url, headers={
'Authorization': 'Bearer ' + access_token
}) | python | def user_data(self, access_token, *args, **kwargs):
"""Load user data from OAuth Profile Google App Engine App"""
url = GOOGLE_APPENGINE_PROFILE_V2
return self.get_json(url, headers={
'Authorization': 'Bearer ' + access_token
}) | [
"def",
"user_data",
"(",
"self",
",",
"access_token",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"GOOGLE_APPENGINE_PROFILE_V2",
"return",
"self",
".",
"get_json",
"(",
"url",
",",
"headers",
"=",
"{",
"'Authorization'",
":",
"'Bearer ... | Load user data from OAuth Profile Google App Engine App | [
"Load",
"user",
"data",
"from",
"OAuth",
"Profile",
"Google",
"App",
"Engine",
"App"
] | train | https://github.com/mback2k/python-appengine-auth/blob/dd27a0c53c7bebe147f7a6e3606c67ec673ac4d6/social_appengine_auth/backends.py#L56-L61 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/convert/RecursiveMapConverter.py | RecursiveMapConverter.to_map_with_default | def to_map_with_default(value, default_value):
"""
Converts value into map object or returns default when conversion is not possible
:param value: the value to convert.
:param default_value: the default value.
:return: map object or emptu map when conversion is not supported.
... | python | def to_map_with_default(value, default_value):
"""
Converts value into map object or returns default when conversion is not possible
:param value: the value to convert.
:param default_value: the default value.
:return: map object or emptu map when conversion is not supported.
... | [
"def",
"to_map_with_default",
"(",
"value",
",",
"default_value",
")",
":",
"result",
"=",
"RecursiveMapConverter",
".",
"to_nullable_map",
"(",
"value",
")",
"return",
"result",
"if",
"result",
"!=",
"None",
"else",
"default_value"
] | Converts value into map object or returns default when conversion is not possible
:param value: the value to convert.
:param default_value: the default value.
:return: map object or emptu map when conversion is not supported. | [
"Converts",
"value",
"into",
"map",
"object",
"or",
"returns",
"default",
"when",
"conversion",
"is",
"not",
"possible"
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/convert/RecursiveMapConverter.py#L72-L83 |
JeremyGrosser/bamboo | bamboo/log.py | BambooHandler.makePickle | def makePickle(self, record):
"""
Use JSON.
"""
#ei = record.exc_info
#if ei:
# dummy = self.format(record) # just to get traceback text into record.exc_text
# record.exc_info = None # to avoid Unpickleable error
s = '%s%s:%i:%s\n' % (self.prefix, r... | python | def makePickle(self, record):
"""
Use JSON.
"""
#ei = record.exc_info
#if ei:
# dummy = self.format(record) # just to get traceback text into record.exc_text
# record.exc_info = None # to avoid Unpickleable error
s = '%s%s:%i:%s\n' % (self.prefix, r... | [
"def",
"makePickle",
"(",
"self",
",",
"record",
")",
":",
"#ei = record.exc_info",
"#if ei:",
"# dummy = self.format(record) # just to get traceback text into record.exc_text",
"# record.exc_info = None # to avoid Unpickleable error",
"s",
"=",
"'%s%s:%i:%s\\n'",
"%",
"(",
... | Use JSON. | [
"Use",
"JSON",
"."
] | train | https://github.com/JeremyGrosser/bamboo/blob/a1ce4c5a0024599a9512c36045babba8bd9d98d7/bamboo/log.py#L19-L30 |
vmalloc/dessert | dessert/rewrite.py | _make_rewritten_pyc | def _make_rewritten_pyc(state, fn, pyc, co):
"""Try to dump rewritten code to *pyc*."""
if sys.platform.startswith("win"):
# Windows grants exclusive access to open files and doesn't have atomic
# rename, so just write into the final file.
_write_pyc(state, co, fn, pyc)
else:
... | python | def _make_rewritten_pyc(state, fn, pyc, co):
"""Try to dump rewritten code to *pyc*."""
if sys.platform.startswith("win"):
# Windows grants exclusive access to open files and doesn't have atomic
# rename, so just write into the final file.
_write_pyc(state, co, fn, pyc)
else:
... | [
"def",
"_make_rewritten_pyc",
"(",
"state",
",",
"fn",
",",
"pyc",
",",
"co",
")",
":",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"\"win\"",
")",
":",
"# Windows grants exclusive access to open files and doesn't have atomic",
"# rename, so just write into th... | Try to dump rewritten code to *pyc*. | [
"Try",
"to",
"dump",
"rewritten",
"code",
"to",
"*",
"pyc",
"*",
"."
] | train | https://github.com/vmalloc/dessert/blob/fa86b39da4853f2c35f0686942db777c7cc57728/dessert/rewrite.py#L325-L336 |
vmalloc/dessert | dessert/rewrite.py | _read_pyc | def _read_pyc(source, pyc):
"""Possibly read a pytest pyc containing rewritten code.
Return rewritten code if successful or None if not.
"""
try:
fp = open(pyc, "rb")
except IOError:
return None
try:
try:
mtime = int(os.stat(source).st_mtime)
data... | python | def _read_pyc(source, pyc):
"""Possibly read a pytest pyc containing rewritten code.
Return rewritten code if successful or None if not.
"""
try:
fp = open(pyc, "rb")
except IOError:
return None
try:
try:
mtime = int(os.stat(source).st_mtime)
data... | [
"def",
"_read_pyc",
"(",
"source",
",",
"pyc",
")",
":",
"try",
":",
"fp",
"=",
"open",
"(",
"pyc",
",",
"\"rb\"",
")",
"except",
"IOError",
":",
"return",
"None",
"try",
":",
"try",
":",
"mtime",
"=",
"int",
"(",
"os",
".",
"stat",
"(",
"source"... | Possibly read a pytest pyc containing rewritten code.
Return rewritten code if successful or None if not. | [
"Possibly",
"read",
"a",
"pytest",
"pyc",
"containing",
"rewritten",
"code",
"."
] | train | https://github.com/vmalloc/dessert/blob/fa86b39da4853f2c35f0686942db777c7cc57728/dessert/rewrite.py#L338-L363 |
vmalloc/dessert | dessert/rewrite.py | _saferepr | def _saferepr(obj):
"""Get a safe repr of an object for assertion error messages.
The assertion formatting (util.format_explanation()) requires
newlines to be escaped since they are a special character for it.
Normally assertion.util.format_explanation() does this but for a
custom repr it is possib... | python | def _saferepr(obj):
"""Get a safe repr of an object for assertion error messages.
The assertion formatting (util.format_explanation()) requires
newlines to be escaped since they are a special character for it.
Normally assertion.util.format_explanation() does this but for a
custom repr it is possib... | [
"def",
"_saferepr",
"(",
"obj",
")",
":",
"repr",
"=",
"py",
".",
"io",
".",
"saferepr",
"(",
"obj",
")",
"if",
"py",
".",
"builtin",
".",
"_istext",
"(",
"repr",
")",
":",
"t",
"=",
"py",
".",
"builtin",
".",
"text",
"else",
":",
"t",
"=",
"... | Get a safe repr of an object for assertion error messages.
The assertion formatting (util.format_explanation()) requires
newlines to be escaped since they are a special character for it.
Normally assertion.util.format_explanation() does this but for a
custom repr it is possible to contain one of the sp... | [
"Get",
"a",
"safe",
"repr",
"of",
"an",
"object",
"for",
"assertion",
"error",
"messages",
"."
] | train | https://github.com/vmalloc/dessert/blob/fa86b39da4853f2c35f0686942db777c7cc57728/dessert/rewrite.py#L371-L387 |
vmalloc/dessert | dessert/rewrite.py | _format_assertmsg | def _format_assertmsg(obj):
"""Format the custom assertion message given.
For strings this simply replaces newlines with '\n~' so that
util.format_explanation() will preserve them instead of escaping
newlines. For other objects py.io.saferepr() is used first.
"""
# reprlib appears to have a b... | python | def _format_assertmsg(obj):
"""Format the custom assertion message given.
For strings this simply replaces newlines with '\n~' so that
util.format_explanation() will preserve them instead of escaping
newlines. For other objects py.io.saferepr() is used first.
"""
# reprlib appears to have a b... | [
"def",
"_format_assertmsg",
"(",
"obj",
")",
":",
"# reprlib appears to have a bug which means that if a string",
"# contains a newline it gets escaped, however if an object has a",
"# .__repr__() which contains newlines it does not get escaped.",
"# However in either case we want to preserve the ... | Format the custom assertion message given.
For strings this simply replaces newlines with '\n~' so that
util.format_explanation() will preserve them instead of escaping
newlines. For other objects py.io.saferepr() is used first. | [
"Format",
"the",
"custom",
"assertion",
"message",
"given",
"."
] | train | https://github.com/vmalloc/dessert/blob/fa86b39da4853f2c35f0686942db777c7cc57728/dessert/rewrite.py#L389-L414 |
vmalloc/dessert | dessert/rewrite.py | set_location | def set_location(node, lineno, col_offset):
"""Set node location information recursively."""
def _fix(node, lineno, col_offset):
if "lineno" in node._attributes:
node.lineno = lineno
if "col_offset" in node._attributes:
node.col_offset = col_offset
for child in as... | python | def set_location(node, lineno, col_offset):
"""Set node location information recursively."""
def _fix(node, lineno, col_offset):
if "lineno" in node._attributes:
node.lineno = lineno
if "col_offset" in node._attributes:
node.col_offset = col_offset
for child in as... | [
"def",
"set_location",
"(",
"node",
",",
"lineno",
",",
"col_offset",
")",
":",
"def",
"_fix",
"(",
"node",
",",
"lineno",
",",
"col_offset",
")",
":",
"if",
"\"lineno\"",
"in",
"node",
".",
"_attributes",
":",
"node",
".",
"lineno",
"=",
"lineno",
"if... | Set node location information recursively. | [
"Set",
"node",
"location",
"information",
"recursively",
"."
] | train | https://github.com/vmalloc/dessert/blob/fa86b39da4853f2c35f0686942db777c7cc57728/dessert/rewrite.py#L488-L498 |
vmalloc/dessert | dessert/rewrite.py | AssertionRewritingHook.mark_rewrite | def mark_rewrite(self, *names):
"""Mark import names as needing to be re-written.
The named module or package as well as any nested modules will
be re-written on import.
"""
already_imported = set(names).intersection(set(sys.modules))
if already_imported:
for... | python | def mark_rewrite(self, *names):
"""Mark import names as needing to be re-written.
The named module or package as well as any nested modules will
be re-written on import.
"""
already_imported = set(names).intersection(set(sys.modules))
if already_imported:
for... | [
"def",
"mark_rewrite",
"(",
"self",
",",
"*",
"names",
")",
":",
"already_imported",
"=",
"set",
"(",
"names",
")",
".",
"intersection",
"(",
"set",
"(",
"sys",
".",
"modules",
")",
")",
"if",
"already_imported",
":",
"for",
"name",
"in",
"already_import... | Mark import names as needing to be re-written.
The named module or package as well as any nested modules will
be re-written on import. | [
"Mark",
"import",
"names",
"as",
"needing",
"to",
"be",
"re",
"-",
"written",
"."
] | train | https://github.com/vmalloc/dessert/blob/fa86b39da4853f2c35f0686942db777c7cc57728/dessert/rewrite.py#L163-L174 |
vmalloc/dessert | dessert/rewrite.py | AssertionRewritingHook._register_with_pkg_resources | def _register_with_pkg_resources(cls):
"""
Ensure package resources can be loaded from this loader. May be called
multiple times, as the operation is idempotent.
"""
try:
import pkg_resources
# access an attribute in case a deferred importer is present
... | python | def _register_with_pkg_resources(cls):
"""
Ensure package resources can be loaded from this loader. May be called
multiple times, as the operation is idempotent.
"""
try:
import pkg_resources
# access an attribute in case a deferred importer is present
... | [
"def",
"_register_with_pkg_resources",
"(",
"cls",
")",
":",
"try",
":",
"import",
"pkg_resources",
"# access an attribute in case a deferred importer is present",
"pkg_resources",
".",
"__name__",
"except",
"ImportError",
":",
"return",
"# Since pytest tests are always located i... | Ensure package resources can be loaded from this loader. May be called
multiple times, as the operation is idempotent. | [
"Ensure",
"package",
"resources",
"can",
"be",
"loaded",
"from",
"this",
"loader",
".",
"May",
"be",
"called",
"multiple",
"times",
"as",
"the",
"operation",
"is",
"idempotent",
"."
] | train | https://github.com/vmalloc/dessert/blob/fa86b39da4853f2c35f0686942db777c7cc57728/dessert/rewrite.py#L216-L230 |
vmalloc/dessert | dessert/rewrite.py | AssertionRewriter.run | def run(self, mod):
"""Find all assert statements in *mod* and rewrite them."""
if not mod.body:
# Nothing to do.
return
# Insert some special imports at the top of the module but after any
# docstrings and __future__ imports.
aliases = [ast.alias(py.built... | python | def run(self, mod):
"""Find all assert statements in *mod* and rewrite them."""
if not mod.body:
# Nothing to do.
return
# Insert some special imports at the top of the module but after any
# docstrings and __future__ imports.
aliases = [ast.alias(py.built... | [
"def",
"run",
"(",
"self",
",",
"mod",
")",
":",
"if",
"not",
"mod",
".",
"body",
":",
"# Nothing to do.",
"return",
"# Insert some special imports at the top of the module but after any",
"# docstrings and __future__ imports.",
"aliases",
"=",
"[",
"ast",
".",
"alias",... | Find all assert statements in *mod* and rewrite them. | [
"Find",
"all",
"assert",
"statements",
"in",
"*",
"mod",
"*",
"and",
"rewrite",
"them",
"."
] | train | https://github.com/vmalloc/dessert/blob/fa86b39da4853f2c35f0686942db777c7cc57728/dessert/rewrite.py#L508-L557 |
vmalloc/dessert | dessert/rewrite.py | AssertionRewriter.variable | def variable(self):
"""Get a new variable."""
# Use a character invalid in python identifiers to avoid clashing.
name = "@py_assert" + str(next(self.variable_counter))
self.variables.append(name)
return name | python | def variable(self):
"""Get a new variable."""
# Use a character invalid in python identifiers to avoid clashing.
name = "@py_assert" + str(next(self.variable_counter))
self.variables.append(name)
return name | [
"def",
"variable",
"(",
"self",
")",
":",
"# Use a character invalid in python identifiers to avoid clashing.",
"name",
"=",
"\"@py_assert\"",
"+",
"str",
"(",
"next",
"(",
"self",
".",
"variable_counter",
")",
")",
"self",
".",
"variables",
".",
"append",
"(",
"n... | Get a new variable. | [
"Get",
"a",
"new",
"variable",
"."
] | train | https://github.com/vmalloc/dessert/blob/fa86b39da4853f2c35f0686942db777c7cc57728/dessert/rewrite.py#L559-L564 |
vmalloc/dessert | dessert/rewrite.py | AssertionRewriter.assign | def assign(self, expr):
"""Give *expr* a name."""
name = self.variable()
self.statements.append(ast.Assign([ast.Name(name, ast.Store())], expr))
return ast.Name(name, ast.Load()) | python | def assign(self, expr):
"""Give *expr* a name."""
name = self.variable()
self.statements.append(ast.Assign([ast.Name(name, ast.Store())], expr))
return ast.Name(name, ast.Load()) | [
"def",
"assign",
"(",
"self",
",",
"expr",
")",
":",
"name",
"=",
"self",
".",
"variable",
"(",
")",
"self",
".",
"statements",
".",
"append",
"(",
"ast",
".",
"Assign",
"(",
"[",
"ast",
".",
"Name",
"(",
"name",
",",
"ast",
".",
"Store",
"(",
... | Give *expr* a name. | [
"Give",
"*",
"expr",
"*",
"a",
"name",
"."
] | train | https://github.com/vmalloc/dessert/blob/fa86b39da4853f2c35f0686942db777c7cc57728/dessert/rewrite.py#L566-L570 |
vmalloc/dessert | dessert/rewrite.py | AssertionRewriter.helper | def helper(self, name, *args):
"""Call a helper in this module."""
py_name = ast.Name("@dessert_ar", ast.Load())
attr = ast.Attribute(py_name, "_" + name, ast.Load())
return ast_Call(attr, list(args), []) | python | def helper(self, name, *args):
"""Call a helper in this module."""
py_name = ast.Name("@dessert_ar", ast.Load())
attr = ast.Attribute(py_name, "_" + name, ast.Load())
return ast_Call(attr, list(args), []) | [
"def",
"helper",
"(",
"self",
",",
"name",
",",
"*",
"args",
")",
":",
"py_name",
"=",
"ast",
".",
"Name",
"(",
"\"@dessert_ar\"",
",",
"ast",
".",
"Load",
"(",
")",
")",
"attr",
"=",
"ast",
".",
"Attribute",
"(",
"py_name",
",",
"\"_\"",
"+",
"n... | Call a helper in this module. | [
"Call",
"a",
"helper",
"in",
"this",
"module",
"."
] | train | https://github.com/vmalloc/dessert/blob/fa86b39da4853f2c35f0686942db777c7cc57728/dessert/rewrite.py#L576-L580 |
vmalloc/dessert | dessert/rewrite.py | AssertionRewriter.builtin | def builtin(self, name):
"""Return the builtin called *name*."""
builtin_name = ast.Name("@py_builtins", ast.Load())
return ast.Attribute(builtin_name, name, ast.Load()) | python | def builtin(self, name):
"""Return the builtin called *name*."""
builtin_name = ast.Name("@py_builtins", ast.Load())
return ast.Attribute(builtin_name, name, ast.Load()) | [
"def",
"builtin",
"(",
"self",
",",
"name",
")",
":",
"builtin_name",
"=",
"ast",
".",
"Name",
"(",
"\"@py_builtins\"",
",",
"ast",
".",
"Load",
"(",
")",
")",
"return",
"ast",
".",
"Attribute",
"(",
"builtin_name",
",",
"name",
",",
"ast",
".",
"Loa... | Return the builtin called *name*. | [
"Return",
"the",
"builtin",
"called",
"*",
"name",
"*",
"."
] | train | https://github.com/vmalloc/dessert/blob/fa86b39da4853f2c35f0686942db777c7cc57728/dessert/rewrite.py#L582-L585 |
vmalloc/dessert | dessert/rewrite.py | AssertionRewriter.generic_visit | def generic_visit(self, node):
"""Handle expressions we don't have custom code for."""
assert isinstance(node, ast.expr)
res = self.assign(node)
return res, self.explanation_param(self.display(res)) | python | def generic_visit(self, node):
"""Handle expressions we don't have custom code for."""
assert isinstance(node, ast.expr)
res = self.assign(node)
return res, self.explanation_param(self.display(res)) | [
"def",
"generic_visit",
"(",
"self",
",",
"node",
")",
":",
"assert",
"isinstance",
"(",
"node",
",",
"ast",
".",
"expr",
")",
"res",
"=",
"self",
".",
"assign",
"(",
"node",
")",
"return",
"res",
",",
"self",
".",
"explanation_param",
"(",
"self",
"... | Handle expressions we don't have custom code for. | [
"Handle",
"expressions",
"we",
"don",
"t",
"have",
"custom",
"code",
"for",
"."
] | train | https://github.com/vmalloc/dessert/blob/fa86b39da4853f2c35f0686942db777c7cc57728/dessert/rewrite.py#L607-L611 |
vmalloc/dessert | dessert/rewrite.py | AssertionRewriter.visit_Assert | def visit_Assert(self, assert_):
"""Return the AST statements to replace the ast.Assert instance.
This re-writes the test of an assertion to provide
intermediate values and replace it with an if statement which
raises an assertion error with a detailed explanation in case
the ex... | python | def visit_Assert(self, assert_):
"""Return the AST statements to replace the ast.Assert instance.
This re-writes the test of an assertion to provide
intermediate values and replace it with an if statement which
raises an assertion error with a detailed explanation in case
the ex... | [
"def",
"visit_Assert",
"(",
"self",
",",
"assert_",
")",
":",
"if",
"isinstance",
"(",
"assert_",
".",
"test",
",",
"ast",
".",
"Tuple",
")",
"and",
"self",
".",
"config",
"is",
"not",
"None",
":",
"fslocation",
"=",
"(",
"self",
".",
"module_path",
... | Return the AST statements to replace the ast.Assert instance.
This re-writes the test of an assertion to provide
intermediate values and replace it with an if statement which
raises an assertion error with a detailed explanation in case
the expression is false. | [
"Return",
"the",
"AST",
"statements",
"to",
"replace",
"the",
"ast",
".",
"Assert",
"instance",
"."
] | train | https://github.com/vmalloc/dessert/blob/fa86b39da4853f2c35f0686942db777c7cc57728/dessert/rewrite.py#L613-L667 |
vmalloc/dessert | dessert/rewrite.py | AssertionRewriter.visit_Call_35 | def visit_Call_35(self, call):
"""
visit `ast.Call` nodes on Python3.5 and after
"""
new_func, func_expl = self.visit(call.func)
arg_expls = []
new_args = []
new_kwargs = []
for arg in call.args:
res, expl = self.visit(arg)
arg_expl... | python | def visit_Call_35(self, call):
"""
visit `ast.Call` nodes on Python3.5 and after
"""
new_func, func_expl = self.visit(call.func)
arg_expls = []
new_args = []
new_kwargs = []
for arg in call.args:
res, expl = self.visit(arg)
arg_expl... | [
"def",
"visit_Call_35",
"(",
"self",
",",
"call",
")",
":",
"new_func",
",",
"func_expl",
"=",
"self",
".",
"visit",
"(",
"call",
".",
"func",
")",
"arg_expls",
"=",
"[",
"]",
"new_args",
"=",
"[",
"]",
"new_kwargs",
"=",
"[",
"]",
"for",
"arg",
"i... | visit `ast.Call` nodes on Python3.5 and after | [
"visit",
"ast",
".",
"Call",
"nodes",
"on",
"Python3",
".",
"5",
"and",
"after"
] | train | https://github.com/vmalloc/dessert/blob/fa86b39da4853f2c35f0686942db777c7cc57728/dessert/rewrite.py#L728-L753 |
vrtsystems/pyat | pyat/sync.py | SynchronousScheduledTask.cancel | def cancel(self):
'''
Cancel the scheduled task.
'''
if (not self.cancelled) and (self._fn is not None):
self._cancelled = True
self._drop_fn() | python | def cancel(self):
'''
Cancel the scheduled task.
'''
if (not self.cancelled) and (self._fn is not None):
self._cancelled = True
self._drop_fn() | [
"def",
"cancel",
"(",
"self",
")",
":",
"if",
"(",
"not",
"self",
".",
"cancelled",
")",
"and",
"(",
"self",
".",
"_fn",
"is",
"not",
"None",
")",
":",
"self",
".",
"_cancelled",
"=",
"True",
"self",
".",
"_drop_fn",
"(",
")"
] | Cancel the scheduled task. | [
"Cancel",
"the",
"scheduled",
"task",
"."
] | train | https://github.com/vrtsystems/pyat/blob/23f87904e5f9f6902665bbf825e65e7eddd64995/pyat/sync.py#L111-L117 |
vrtsystems/pyat | pyat/sync.py | SynchronousScheduledTask.result | def result(self):
'''
The result from the executed task. Raises NotExecutedYet if not yet
executed.
'''
if self.cancelled or (self._fn is not None):
raise NotExecutedYet()
if self._fn_exc is not None:
six.reraise(*self._fn_exc)
else:
... | python | def result(self):
'''
The result from the executed task. Raises NotExecutedYet if not yet
executed.
'''
if self.cancelled or (self._fn is not None):
raise NotExecutedYet()
if self._fn_exc is not None:
six.reraise(*self._fn_exc)
else:
... | [
"def",
"result",
"(",
"self",
")",
":",
"if",
"self",
".",
"cancelled",
"or",
"(",
"self",
".",
"_fn",
"is",
"not",
"None",
")",
":",
"raise",
"NotExecutedYet",
"(",
")",
"if",
"self",
".",
"_fn_exc",
"is",
"not",
"None",
":",
"six",
".",
"reraise"... | The result from the executed task. Raises NotExecutedYet if not yet
executed. | [
"The",
"result",
"from",
"the",
"executed",
"task",
".",
"Raises",
"NotExecutedYet",
"if",
"not",
"yet",
"executed",
"."
] | train | https://github.com/vrtsystems/pyat/blob/23f87904e5f9f6902665bbf825e65e7eddd64995/pyat/sync.py#L120-L131 |
cltrudeau/wrench | wrench/utils.py | rows_to_columns | def rows_to_columns(matrix):
#hammer
"""Takes a two dimensional array and returns an new one where rows in the
first become columns in the second."""
num_rows = len(matrix)
num_cols = len(matrix[0])
data = []
for i in range(0, num_cols):
data.append([matrix[j][i] for j in range(0, num_r... | python | def rows_to_columns(matrix):
#hammer
"""Takes a two dimensional array and returns an new one where rows in the
first become columns in the second."""
num_rows = len(matrix)
num_cols = len(matrix[0])
data = []
for i in range(0, num_cols):
data.append([matrix[j][i] for j in range(0, num_r... | [
"def",
"rows_to_columns",
"(",
"matrix",
")",
":",
"#hammer",
"num_rows",
"=",
"len",
"(",
"matrix",
")",
"num_cols",
"=",
"len",
"(",
"matrix",
"[",
"0",
"]",
")",
"data",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"num_cols",
")",
... | Takes a two dimensional array and returns an new one where rows in the
first become columns in the second. | [
"Takes",
"a",
"two",
"dimensional",
"array",
"and",
"returns",
"an",
"new",
"one",
"where",
"rows",
"in",
"the",
"first",
"become",
"columns",
"in",
"the",
"second",
"."
] | train | https://github.com/cltrudeau/wrench/blob/bc231dd085050a63a87ff3eb8f0a863928f65a41/wrench/utils.py#L322-L333 |
cltrudeau/wrench | wrench/utils.py | parse_link | def parse_link(html):
#hammer
"""Parses an HTML anchor tag, returning the href and content text. Any
content before or after the anchor tag pair is ignored.
:param html:
Snippet of html to parse
:returns:
namedtuple('ParsedLink', ['url', 'text'])
Example:
.. code-block:: pyth... | python | def parse_link(html):
#hammer
"""Parses an HTML anchor tag, returning the href and content text. Any
content before or after the anchor tag pair is ignored.
:param html:
Snippet of html to parse
:returns:
namedtuple('ParsedLink', ['url', 'text'])
Example:
.. code-block:: pyth... | [
"def",
"parse_link",
"(",
"html",
")",
":",
"#hammer",
"parser",
"=",
"AnchorParser",
"(",
")",
"parser",
".",
"feed",
"(",
"html",
")",
"return",
"parser",
".",
"ParsedLink",
"(",
"parser",
".",
"url",
",",
"parser",
".",
"text",
")"
] | Parses an HTML anchor tag, returning the href and content text. Any
content before or after the anchor tag pair is ignored.
:param html:
Snippet of html to parse
:returns:
namedtuple('ParsedLink', ['url', 'text'])
Example:
.. code-block:: python
>>> parse_link('things <a... | [
"Parses",
"an",
"HTML",
"anchor",
"tag",
"returning",
"the",
"href",
"and",
"content",
"text",
".",
"Any",
"content",
"before",
"or",
"after",
"the",
"anchor",
"tag",
"pair",
"is",
"ignored",
"."
] | train | https://github.com/cltrudeau/wrench/blob/bc231dd085050a63a87ff3eb8f0a863928f65a41/wrench/utils.py#L370-L389 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.