repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
cocaine/cocaine-tools | cocaine/tools/dispatch.py | crashlog_clean | def crashlog_clean(name, timestamp, size, **kwargs):
"""
For application NAME leave SIZE crashlogs or remove all crashlogs with timestamp > TIMESTAMP.
"""
ctx = Context(**kwargs)
ctx.execute_action('crashlog:clean', **{
'storage': ctx.repo.create_secure_service('storage'),
'name': na... | python | def crashlog_clean(name, timestamp, size, **kwargs):
"""
For application NAME leave SIZE crashlogs or remove all crashlogs with timestamp > TIMESTAMP.
"""
ctx = Context(**kwargs)
ctx.execute_action('crashlog:clean', **{
'storage': ctx.repo.create_secure_service('storage'),
'name': na... | [
"def",
"crashlog_clean",
"(",
"name",
",",
"timestamp",
",",
"size",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'crashlog:clean'",
",",
"*",
"*",
"{",
"'storage'",
":",
... | For application NAME leave SIZE crashlogs or remove all crashlogs with timestamp > TIMESTAMP. | [
"For",
"application",
"NAME",
"leave",
"SIZE",
"crashlogs",
"or",
"remove",
"all",
"crashlogs",
"with",
"timestamp",
">",
"TIMESTAMP",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1231-L1241 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | crashlog_cleanrange | def crashlog_cleanrange(from_day, up_to_day, **kwargs):
"""
Remove all crashlogs from one date up to another.
The date can be specified as DAY-[MONTH-[YEAR]].
Example:
today, yesterday, 10, 10-09, 10-09-2015
"""
ctx = Context(**kwargs)
ctx.execute_action('crashlog:cleanwhen', **{
... | python | def crashlog_cleanrange(from_day, up_to_day, **kwargs):
"""
Remove all crashlogs from one date up to another.
The date can be specified as DAY-[MONTH-[YEAR]].
Example:
today, yesterday, 10, 10-09, 10-09-2015
"""
ctx = Context(**kwargs)
ctx.execute_action('crashlog:cleanwhen', **{
... | [
"def",
"crashlog_cleanrange",
"(",
"from_day",
",",
"up_to_day",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'crashlog:cleanwhen'",
",",
"*",
"*",
"{",
"'storage'",
":",
"ctx... | Remove all crashlogs from one date up to another.
The date can be specified as DAY-[MONTH-[YEAR]].
Example:
today, yesterday, 10, 10-09, 10-09-2015 | [
"Remove",
"all",
"crashlogs",
"from",
"one",
"date",
"up",
"to",
"another",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1248-L1262 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | group_list | def group_list(**kwargs):
"""
Show available routing groups.
"""
ctx = Context(**kwargs)
ctx.execute_action('group:list', **{
'storage': ctx.repo.create_secure_service('storage'),
}) | python | def group_list(**kwargs):
"""
Show available routing groups.
"""
ctx = Context(**kwargs)
ctx.execute_action('group:list', **{
'storage': ctx.repo.create_secure_service('storage'),
}) | [
"def",
"group_list",
"(",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'group:list'",
",",
"*",
"*",
"{",
"'storage'",
":",
"ctx",
".",
"repo",
".",
"create_secure_service",
"(",... | Show available routing groups. | [
"Show",
"available",
"routing",
"groups",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1267-L1274 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | group_view | def group_view(name, **kwargs):
"""
Show specified routing group.
"""
ctx = Context(**kwargs)
ctx.execute_action('group:view', **{
'storage': ctx.repo.create_secure_service('storage'),
'name': name,
}) | python | def group_view(name, **kwargs):
"""
Show specified routing group.
"""
ctx = Context(**kwargs)
ctx.execute_action('group:view', **{
'storage': ctx.repo.create_secure_service('storage'),
'name': name,
}) | [
"def",
"group_view",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'group:view'",
",",
"*",
"*",
"{",
"'storage'",
":",
"ctx",
".",
"repo",
".",
"create_secure... | Show specified routing group. | [
"Show",
"specified",
"routing",
"group",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1280-L1288 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | group_create | def group_create(name, content, **kwargs):
"""
Create routing group.
You can optionally specify content for created routing group. It can be either direct JSON
expression in single quotes, or path to the json file with settings. Settings itself must be
key-value list, where `key` represents applica... | python | def group_create(name, content, **kwargs):
"""
Create routing group.
You can optionally specify content for created routing group. It can be either direct JSON
expression in single quotes, or path to the json file with settings. Settings itself must be
key-value list, where `key` represents applica... | [
"def",
"group_create",
"(",
"name",
",",
"content",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'group:create'",
",",
"*",
"*",
"{",
"'storage'",
":",
"ctx",
".",
"repo",... | Create routing group.
You can optionally specify content for created routing group. It can be either direct JSON
expression in single quotes, or path to the json file with settings. Settings itself must be
key-value list, where `key` represents application name, and `value` represents its weight.
For ... | [
"Create",
"routing",
"group",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1295-L1317 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | group_remove | def group_remove(name, **kwargs):
"""
Remove routing group from the storage.
"""
ctx = Context(**kwargs)
ctx.execute_action('group:remove', **{
'storage': ctx.repo.create_secure_service('storage'),
'name': name,
}) | python | def group_remove(name, **kwargs):
"""
Remove routing group from the storage.
"""
ctx = Context(**kwargs)
ctx.execute_action('group:remove', **{
'storage': ctx.repo.create_secure_service('storage'),
'name': name,
}) | [
"def",
"group_remove",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'group:remove'",
",",
"*",
"*",
"{",
"'storage'",
":",
"ctx",
".",
"repo",
".",
"create_se... | Remove routing group from the storage. | [
"Remove",
"routing",
"group",
"from",
"the",
"storage",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1323-L1331 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | group_copy | def group_copy(name, copyname, **kwargs):
"""
Copy routing group.
"""
ctx = Context(**kwargs)
ctx.execute_action('group:copy', **{
'storage': ctx.repo.create_secure_service('storage'),
'name': name,
'copyname': copyname,
}) | python | def group_copy(name, copyname, **kwargs):
"""
Copy routing group.
"""
ctx = Context(**kwargs)
ctx.execute_action('group:copy', **{
'storage': ctx.repo.create_secure_service('storage'),
'name': name,
'copyname': copyname,
}) | [
"def",
"group_copy",
"(",
"name",
",",
"copyname",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'group:copy'",
",",
"*",
"*",
"{",
"'storage'",
":",
"ctx",
".",
"repo",
... | Copy routing group. | [
"Copy",
"routing",
"group",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1338-L1347 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | group_refresh | def group_refresh(name, **kwargs):
"""
Refresh routing group.
If the name option is empty, this command will refresh all groups.
"""
ctx = Context(**kwargs)
ctx.execute_action('group:refresh', **{
'locator': ctx.locator,
'storage': ctx.repo.create_secure_service('storage'),
... | python | def group_refresh(name, **kwargs):
"""
Refresh routing group.
If the name option is empty, this command will refresh all groups.
"""
ctx = Context(**kwargs)
ctx.execute_action('group:refresh', **{
'locator': ctx.locator,
'storage': ctx.repo.create_secure_service('storage'),
... | [
"def",
"group_refresh",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'group:refresh'",
",",
"*",
"*",
"{",
"'locator'",
":",
"ctx",
".",
"locator",
",",
"'sto... | Refresh routing group.
If the name option is empty, this command will refresh all groups. | [
"Refresh",
"routing",
"group",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1369-L1380 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | group_push | def group_push(name, app, weight, **kwargs):
"""
Add application with its weight into the routing group.
Warning: application weight must be positive integer.
"""
ctx = Context(**kwargs)
ctx.execute_action('group:app:add', **{
'storage': ctx.repo.create_secure_service('storage'),
... | python | def group_push(name, app, weight, **kwargs):
"""
Add application with its weight into the routing group.
Warning: application weight must be positive integer.
"""
ctx = Context(**kwargs)
ctx.execute_action('group:app:add', **{
'storage': ctx.repo.create_secure_service('storage'),
... | [
"def",
"group_push",
"(",
"name",
",",
"app",
",",
"weight",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'group:app:add'",
",",
"*",
"*",
"{",
"'storage'",
":",
"ctx",
... | Add application with its weight into the routing group.
Warning: application weight must be positive integer. | [
"Add",
"application",
"with",
"its",
"weight",
"into",
"the",
"routing",
"group",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1388-L1400 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | group_pop | def group_pop(name, app, **kwargs):
"""
Remove application from the specified routing group.
"""
ctx = Context(**kwargs)
ctx.execute_action('group:app:remove', **{
'storage': ctx.repo.create_secure_service('storage'),
'name': name,
'app': app,
}) | python | def group_pop(name, app, **kwargs):
"""
Remove application from the specified routing group.
"""
ctx = Context(**kwargs)
ctx.execute_action('group:app:remove', **{
'storage': ctx.repo.create_secure_service('storage'),
'name': name,
'app': app,
}) | [
"def",
"group_pop",
"(",
"name",
",",
"app",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'group:app:remove'",
",",
"*",
"*",
"{",
"'storage'",
":",
"ctx",
".",
"repo",
... | Remove application from the specified routing group. | [
"Remove",
"application",
"from",
"the",
"specified",
"routing",
"group",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1407-L1416 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | unicorn_edit | def unicorn_edit(path, **kwargs):
"""Edit Unicorn node interactively.
"""
ctx = Context(**kwargs)
ctx.timeout = None
ctx.execute_action('unicorn:edit', **{
'unicorn': ctx.repo.create_secure_service('unicorn'),
'path': path,
}) | python | def unicorn_edit(path, **kwargs):
"""Edit Unicorn node interactively.
"""
ctx = Context(**kwargs)
ctx.timeout = None
ctx.execute_action('unicorn:edit', **{
'unicorn': ctx.repo.create_secure_service('unicorn'),
'path': path,
}) | [
"def",
"unicorn_edit",
"(",
"path",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"timeout",
"=",
"None",
"ctx",
".",
"execute_action",
"(",
"'unicorn:edit'",
",",
"*",
"*",
"{",
"'unicorn'",
":",... | Edit Unicorn node interactively. | [
"Edit",
"Unicorn",
"node",
"interactively",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1472-L1480 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | logging_list_loggers | def logging_list_loggers(**kwargs):
"""
List all registered logger names.
"""
ctx = Context(**kwargs)
ctx.execute_action('logging:list_loggers', **{
'logging_service': ctx.repo.create_secure_service('logging'),
}) | python | def logging_list_loggers(**kwargs):
"""
List all registered logger names.
"""
ctx = Context(**kwargs)
ctx.execute_action('logging:list_loggers', **{
'logging_service': ctx.repo.create_secure_service('logging'),
}) | [
"def",
"logging_list_loggers",
"(",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'logging:list_loggers'",
",",
"*",
"*",
"{",
"'logging_service'",
":",
"ctx",
".",
"repo",
".",
"cr... | List all registered logger names. | [
"List",
"all",
"registered",
"logger",
"names",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1579-L1586 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | logging_set_filter | def logging_set_filter(name, filter_def, ttl, **kwargs):
"""
Set local filter.
"""
ctx = Context(**kwargs)
ctx.execute_action('logging:set_filter', **{
'logging_service': ctx.repo.create_secure_service('logging'),
'logger_name': name,
'filter_def': filter_def,
'ttl': ... | python | def logging_set_filter(name, filter_def, ttl, **kwargs):
"""
Set local filter.
"""
ctx = Context(**kwargs)
ctx.execute_action('logging:set_filter', **{
'logging_service': ctx.repo.create_secure_service('logging'),
'logger_name': name,
'filter_def': filter_def,
'ttl': ... | [
"def",
"logging_set_filter",
"(",
"name",
",",
"filter_def",
",",
"ttl",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'logging:set_filter'",
",",
"*",
"*",
"{",
"'logging_serv... | Set local filter. | [
"Set",
"local",
"filter",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1594-L1604 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | logging_remove_filter | def logging_remove_filter(filter_id, **kwargs):
"""
Remove filter by filter id.
"""
ctx = Context(**kwargs)
ctx.execute_action('logging:remove_filter', **{
'logging_service': ctx.repo.create_secure_service('logging'),
'filter_id': filter_id,
}) | python | def logging_remove_filter(filter_id, **kwargs):
"""
Remove filter by filter id.
"""
ctx = Context(**kwargs)
ctx.execute_action('logging:remove_filter', **{
'logging_service': ctx.repo.create_secure_service('logging'),
'filter_id': filter_id,
}) | [
"def",
"logging_remove_filter",
"(",
"filter_id",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'logging:remove_filter'",
",",
"*",
"*",
"{",
"'logging_service'",
":",
"ctx",
"."... | Remove filter by filter id. | [
"Remove",
"filter",
"by",
"filter",
"id",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1610-L1618 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | logging_list_filters | def logging_list_filters(**kwargs):
"""
List all available filters.
"""
ctx = Context(**kwargs)
ctx.execute_action('logging:list_filters', **{
'logging_service': ctx.repo.create_secure_service('logging'),
}) | python | def logging_list_filters(**kwargs):
"""
List all available filters.
"""
ctx = Context(**kwargs)
ctx.execute_action('logging:list_filters', **{
'logging_service': ctx.repo.create_secure_service('logging'),
}) | [
"def",
"logging_list_filters",
"(",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'logging:list_filters'",
",",
"*",
"*",
"{",
"'logging_service'",
":",
"ctx",
".",
"repo",
".",
"cr... | List all available filters. | [
"List",
"all",
"available",
"filters",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1623-L1630 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | auth_list | def auth_list(**kwargs):
"""
Shows available authorization groups.
"""
ctx = Context(**kwargs)
ctx.execute_action('auth:group:list', **{
'storage': ctx.repo.create_secure_service('storage'),
}) | python | def auth_list(**kwargs):
"""
Shows available authorization groups.
"""
ctx = Context(**kwargs)
ctx.execute_action('auth:group:list', **{
'storage': ctx.repo.create_secure_service('storage'),
}) | [
"def",
"auth_list",
"(",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'auth:group:list'",
",",
"*",
"*",
"{",
"'storage'",
":",
"ctx",
".",
"repo",
".",
"create_secure_service",
... | Shows available authorization groups. | [
"Shows",
"available",
"authorization",
"groups",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1653-L1660 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | auth_create | def auth_create(name, token, force, **kwargs):
"""
Creates an authorization group.
The group sets a named association between an authorization token and the list of services. This
is useful for group of applications that want to share a single token.
"""
ctx = Context(**kwargs)
ctx.execute_... | python | def auth_create(name, token, force, **kwargs):
"""
Creates an authorization group.
The group sets a named association between an authorization token and the list of services. This
is useful for group of applications that want to share a single token.
"""
ctx = Context(**kwargs)
ctx.execute_... | [
"def",
"auth_create",
"(",
"name",
",",
"token",
",",
"force",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'auth:group:create'",
",",
"*",
"*",
"{",
"'storage'",
":",
"ct... | Creates an authorization group.
The group sets a named association between an authorization token and the list of services. This
is useful for group of applications that want to share a single token. | [
"Creates",
"an",
"authorization",
"group",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1668-L1681 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | auth_edit | def auth_edit(name, **kwargs):
"""
Interactively edits an authorization group.
"""
ctx = Context(**kwargs)
ctx.timeout = None
ctx.execute_action('auth:group:edit', **{
'storage': ctx.repo.create_secure_service('storage'),
'name': name,
}) | python | def auth_edit(name, **kwargs):
"""
Interactively edits an authorization group.
"""
ctx = Context(**kwargs)
ctx.timeout = None
ctx.execute_action('auth:group:edit', **{
'storage': ctx.repo.create_secure_service('storage'),
'name': name,
}) | [
"def",
"auth_edit",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"timeout",
"=",
"None",
"ctx",
".",
"execute_action",
"(",
"'auth:group:edit'",
",",
"*",
"*",
"{",
"'storage'",
":",... | Interactively edits an authorization group. | [
"Interactively",
"edits",
"an",
"authorization",
"group",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1687-L1696 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | auth_remove | def auth_remove(name, drop, **kwargs):
"""
Removes an authorization group.
Removes an authorization group with or without excluding associated members depending on --drop
flag (disabled by default).
"""
ctx = Context(**kwargs)
ctx.execute_action('auth:group:remove', **{
'storage': c... | python | def auth_remove(name, drop, **kwargs):
"""
Removes an authorization group.
Removes an authorization group with or without excluding associated members depending on --drop
flag (disabled by default).
"""
ctx = Context(**kwargs)
ctx.execute_action('auth:group:remove', **{
'storage': c... | [
"def",
"auth_remove",
"(",
"name",
",",
"drop",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'auth:group:remove'",
",",
"*",
"*",
"{",
"'storage'",
":",
"ctx",
".",
"repo"... | Removes an authorization group.
Removes an authorization group with or without excluding associated members depending on --drop
flag (disabled by default). | [
"Removes",
"an",
"authorization",
"group",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1703-L1715 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | auth_view | def auth_view(name, **kwargs):
"""
Shows an authorization group's content.
"""
ctx = Context(**kwargs)
ctx.execute_action('auth:group:view', **{
'storage': ctx.repo.create_secure_service('storage'),
'name': name,
}) | python | def auth_view(name, **kwargs):
"""
Shows an authorization group's content.
"""
ctx = Context(**kwargs)
ctx.execute_action('auth:group:view', **{
'storage': ctx.repo.create_secure_service('storage'),
'name': name,
}) | [
"def",
"auth_view",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'auth:group:view'",
",",
"*",
"*",
"{",
"'storage'",
":",
"ctx",
".",
"repo",
".",
"create_se... | Shows an authorization group's content. | [
"Shows",
"an",
"authorization",
"group",
"s",
"content",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1721-L1729 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | auth_add | def auth_add(name, service, **kwargs):
"""
Adds a member of an authorization group.
"""
ctx = Context(**kwargs)
ctx.execute_action('auth:group:members:add', **{
'storage': ctx.repo.create_secure_service('storage'),
'name': name,
'service': service,
}) | python | def auth_add(name, service, **kwargs):
"""
Adds a member of an authorization group.
"""
ctx = Context(**kwargs)
ctx.execute_action('auth:group:members:add', **{
'storage': ctx.repo.create_secure_service('storage'),
'name': name,
'service': service,
}) | [
"def",
"auth_add",
"(",
"name",
",",
"service",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'auth:group:members:add'",
",",
"*",
"*",
"{",
"'storage'",
":",
"ctx",
".",
"... | Adds a member of an authorization group. | [
"Adds",
"a",
"member",
"of",
"an",
"authorization",
"group",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1736-L1745 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | access_storage_list | def access_storage_list(**kwargs):
"""
Shows collections with ACL.
"""
ctx = Context(**kwargs)
ctx.execute_action('access:storage:list', **{
'storage': ctx.repo.create_secure_service('storage'),
}) | python | def access_storage_list(**kwargs):
"""
Shows collections with ACL.
"""
ctx = Context(**kwargs)
ctx.execute_action('access:storage:list', **{
'storage': ctx.repo.create_secure_service('storage'),
}) | [
"def",
"access_storage_list",
"(",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'access:storage:list'",
",",
"*",
"*",
"{",
"'storage'",
":",
"ctx",
".",
"repo",
".",
"create_secur... | Shows collections with ACL. | [
"Shows",
"collections",
"with",
"ACL",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1816-L1823 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | access_storage_view | def access_storage_view(name, **kwargs):
"""
Shows ACL for the specified collection.
"""
ctx = Context(**kwargs)
ctx.execute_action('access:storage:view', **{
'storage': ctx.repo.create_secure_service('storage'),
'name': name,
}) | python | def access_storage_view(name, **kwargs):
"""
Shows ACL for the specified collection.
"""
ctx = Context(**kwargs)
ctx.execute_action('access:storage:view', **{
'storage': ctx.repo.create_secure_service('storage'),
'name': name,
}) | [
"def",
"access_storage_view",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'access:storage:view'",
",",
"*",
"*",
"{",
"'storage'",
":",
"ctx",
".",
"repo",
"."... | Shows ACL for the specified collection. | [
"Shows",
"ACL",
"for",
"the",
"specified",
"collection",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1829-L1837 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | access_storage_create | def access_storage_create(name, **kwargs):
"""
Creates new ACL for the specified collection.
Does nothing if ACL already exists.
"""
ctx = Context(**kwargs)
ctx.execute_action('access:storage:create', **{
'storage': ctx.repo.create_secure_service('storage'),
'name': name,
}) | python | def access_storage_create(name, **kwargs):
"""
Creates new ACL for the specified collection.
Does nothing if ACL already exists.
"""
ctx = Context(**kwargs)
ctx.execute_action('access:storage:create', **{
'storage': ctx.repo.create_secure_service('storage'),
'name': name,
}) | [
"def",
"access_storage_create",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'access:storage:create'",
",",
"*",
"*",
"{",
"'storage'",
":",
"ctx",
".",
"repo",
... | Creates new ACL for the specified collection.
Does nothing if ACL already exists. | [
"Creates",
"new",
"ACL",
"for",
"the",
"specified",
"collection",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1843-L1853 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | access_storage_edit | def access_storage_edit(name, cid, uid, perm, **kwargs):
"""
Edits ACL for the specified collection.
Creates if necessary.
"""
ctx = Context(**kwargs)
ctx.execute_action('access:storage:edit', **{
'storage': ctx.repo.create_secure_service('storage'),
'name': name,
'cids'... | python | def access_storage_edit(name, cid, uid, perm, **kwargs):
"""
Edits ACL for the specified collection.
Creates if necessary.
"""
ctx = Context(**kwargs)
ctx.execute_action('access:storage:edit', **{
'storage': ctx.repo.create_secure_service('storage'),
'name': name,
'cids'... | [
"def",
"access_storage_edit",
"(",
"name",
",",
"cid",
",",
"uid",
",",
"perm",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'access:storage:edit'",
",",
"*",
"*",
"{",
"'... | Edits ACL for the specified collection.
Creates if necessary. | [
"Edits",
"ACL",
"for",
"the",
"specified",
"collection",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1863-L1876 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | access_storage_rm | def access_storage_rm(name, yes, **kwargs):
"""
Remove ACL for the specified collection.
If none is specified - removes ACL for all collections.
"""
if name is None:
if not yes:
click.confirm('Are you sure you want to remove all ACL?', abort=True)
ctx = Context(**kwargs)
... | python | def access_storage_rm(name, yes, **kwargs):
"""
Remove ACL for the specified collection.
If none is specified - removes ACL for all collections.
"""
if name is None:
if not yes:
click.confirm('Are you sure you want to remove all ACL?', abort=True)
ctx = Context(**kwargs)
... | [
"def",
"access_storage_rm",
"(",
"name",
",",
"yes",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"name",
"is",
"None",
":",
"if",
"not",
"yes",
":",
"click",
".",
"confirm",
"(",
"'Are you sure you want to remove all ACL?'",
",",
"abort",
"=",
"True",
")",
... | Remove ACL for the specified collection.
If none is specified - removes ACL for all collections. | [
"Remove",
"ACL",
"for",
"the",
"specified",
"collection",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1883-L1897 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | access_list | def access_list(**kwargs):
"""
Shows services for which there are ACL specified.
"""
ctx = Context(**kwargs)
ctx.execute_action('access:list', **{
'unicorn': ctx.repo.create_secure_service('unicorn'),
}) | python | def access_list(**kwargs):
"""
Shows services for which there are ACL specified.
"""
ctx = Context(**kwargs)
ctx.execute_action('access:list', **{
'unicorn': ctx.repo.create_secure_service('unicorn'),
}) | [
"def",
"access_list",
"(",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'access:list'",
",",
"*",
"*",
"{",
"'unicorn'",
":",
"ctx",
".",
"repo",
".",
"create_secure_service",
"(... | Shows services for which there are ACL specified. | [
"Shows",
"services",
"for",
"which",
"there",
"are",
"ACL",
"specified",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1902-L1909 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | access_view | def access_view(name, **kwargs):
"""
Shows ACL for the specified service.
"""
ctx = Context(**kwargs)
ctx.execute_action('access:view', **{
'unicorn': ctx.repo.create_secure_service('unicorn'),
'service': name,
}) | python | def access_view(name, **kwargs):
"""
Shows ACL for the specified service.
"""
ctx = Context(**kwargs)
ctx.execute_action('access:view', **{
'unicorn': ctx.repo.create_secure_service('unicorn'),
'service': name,
}) | [
"def",
"access_view",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'access:view'",
",",
"*",
"*",
"{",
"'unicorn'",
":",
"ctx",
".",
"repo",
".",
"create_secu... | Shows ACL for the specified service. | [
"Shows",
"ACL",
"for",
"the",
"specified",
"service",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1915-L1923 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | keyring_view | def keyring_view(**kwargs):
"""
View saved public keys.
"""
ctx = Context(**kwargs)
ctx.execute_action('keyring:view', **{
'storage': ctx.repo.create_secure_service('storage'),
}) | python | def keyring_view(**kwargs):
"""
View saved public keys.
"""
ctx = Context(**kwargs)
ctx.execute_action('keyring:view', **{
'storage': ctx.repo.create_secure_service('storage'),
}) | [
"def",
"keyring_view",
"(",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'keyring:view'",
",",
"*",
"*",
"{",
"'storage'",
":",
"ctx",
".",
"repo",
".",
"create_secure_service",
... | View saved public keys. | [
"View",
"saved",
"public",
"keys",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1966-L1973 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | keyring_remove | def keyring_remove(key, yes, **kwargs):
"""
Removes a public key from the keyring.
Does nothing if a key is already not in the keyring. If none is specified - clears the keyring.
To force the cocaine-runtime to refresh its keyring, call `refresh` method.
"""
if key is None:
if not yes:
... | python | def keyring_remove(key, yes, **kwargs):
"""
Removes a public key from the keyring.
Does nothing if a key is already not in the keyring. If none is specified - clears the keyring.
To force the cocaine-runtime to refresh its keyring, call `refresh` method.
"""
if key is None:
if not yes:
... | [
"def",
"keyring_remove",
"(",
"key",
",",
"yes",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"key",
"is",
"None",
":",
"if",
"not",
"yes",
":",
"click",
".",
"confirm",
"(",
"'Are you sure you want to remove all keys?'",
",",
"abort",
"=",
"True",
")",
"ctx... | Removes a public key from the keyring.
Does nothing if a key is already not in the keyring. If none is specified - clears the keyring.
To force the cocaine-runtime to refresh its keyring, call `refresh` method. | [
"Removes",
"a",
"public",
"key",
"from",
"the",
"keyring",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1998-L2013 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | keyring_edit | def keyring_edit(**kwargs):
"""
Edits interactively the keyring.
"""
ctx = Context(**kwargs)
ctx.timeout = None
ctx.execute_action('keyring:edit', **{
'storage': ctx.repo.create_secure_service('storage'),
}) | python | def keyring_edit(**kwargs):
"""
Edits interactively the keyring.
"""
ctx = Context(**kwargs)
ctx.timeout = None
ctx.execute_action('keyring:edit', **{
'storage': ctx.repo.create_secure_service('storage'),
}) | [
"def",
"keyring_edit",
"(",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"timeout",
"=",
"None",
"ctx",
".",
"execute_action",
"(",
"'keyring:edit'",
",",
"*",
"*",
"{",
"'storage'",
":",
"ctx",
".",
... | Edits interactively the keyring. | [
"Edits",
"interactively",
"the",
"keyring",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L2018-L2026 | train |
cocaine/cocaine-tools | cocaine/tools/dispatch.py | keyring_refresh | def keyring_refresh(**kwargs):
"""
Refresh the keyring in the cocaine-runtime.
"""
ctx = Context(**kwargs)
ctx.execute_action('keyring:refresh', **{
'tvm': ctx.repo.create_secure_service('tvm'),
}) | python | def keyring_refresh(**kwargs):
"""
Refresh the keyring in the cocaine-runtime.
"""
ctx = Context(**kwargs)
ctx.execute_action('keyring:refresh', **{
'tvm': ctx.repo.create_secure_service('tvm'),
}) | [
"def",
"keyring_refresh",
"(",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"Context",
"(",
"*",
"*",
"kwargs",
")",
"ctx",
".",
"execute_action",
"(",
"'keyring:refresh'",
",",
"*",
"*",
"{",
"'tvm'",
":",
"ctx",
".",
"repo",
".",
"create_secure_service",
... | Refresh the keyring in the cocaine-runtime. | [
"Refresh",
"the",
"keyring",
"in",
"the",
"cocaine",
"-",
"runtime",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L2031-L2038 | train |
pjamesjoyce/lcopt | lcopt/bw2_export.py | Bw2Exporter.evaluate_parameter_sets | def evaluate_parameter_sets(self):
"""
This takes the parameter sets of the model instance and evaluates any formulas using the parameter values to create a
fixed, full set of parameters for each parameter set in the model
"""
#parameter_interpreter = ParameterInterpreter(self.... | python | def evaluate_parameter_sets(self):
"""
This takes the parameter sets of the model instance and evaluates any formulas using the parameter values to create a
fixed, full set of parameters for each parameter set in the model
"""
#parameter_interpreter = ParameterInterpreter(self.... | [
"def",
"evaluate_parameter_sets",
"(",
"self",
")",
":",
"#parameter_interpreter = ParameterInterpreter(self.modelInstance)",
"#parameter_interpreter.evaluate_parameter_sets()",
"self",
".",
"parameter_interpreter",
"=",
"LcoptParameterSet",
"(",
"self",
".",
"modelInstance",
")",
... | This takes the parameter sets of the model instance and evaluates any formulas using the parameter values to create a
fixed, full set of parameters for each parameter set in the model | [
"This",
"takes",
"the",
"parameter",
"sets",
"of",
"the",
"model",
"instance",
"and",
"evaluates",
"any",
"formulas",
"using",
"the",
"parameter",
"values",
"to",
"create",
"a",
"fixed",
"full",
"set",
"of",
"parameters",
"for",
"each",
"parameter",
"set",
"... | 3f1caca31fece4a3068a384900707e6d21d04597 | https://github.com/pjamesjoyce/lcopt/blob/3f1caca31fece4a3068a384900707e6d21d04597/lcopt/bw2_export.py#L18-L28 | train |
pjamesjoyce/lcopt | lcopt/bw2_export.py | Bw2Exporter.create_parameter_map | def create_parameter_map(self):
"""
Creates a parameter map which takes a tuple of the exchange 'from' and exchange 'to' codes
and returns the parameter name for that exchange
"""
names = self.modelInstance.names
db = self.modelInstance.database['items']
paramete... | python | def create_parameter_map(self):
"""
Creates a parameter map which takes a tuple of the exchange 'from' and exchange 'to' codes
and returns the parameter name for that exchange
"""
names = self.modelInstance.names
db = self.modelInstance.database['items']
paramete... | [
"def",
"create_parameter_map",
"(",
"self",
")",
":",
"names",
"=",
"self",
".",
"modelInstance",
".",
"names",
"db",
"=",
"self",
".",
"modelInstance",
".",
"database",
"[",
"'items'",
"]",
"parameter_map",
"=",
"{",
"}",
"def",
"get_names_index",
"(",
"m... | Creates a parameter map which takes a tuple of the exchange 'from' and exchange 'to' codes
and returns the parameter name for that exchange | [
"Creates",
"a",
"parameter",
"map",
"which",
"takes",
"a",
"tuple",
"of",
"the",
"exchange",
"from",
"and",
"exchange",
"to",
"codes",
"and",
"returns",
"the",
"parameter",
"name",
"for",
"that",
"exchange"
] | 3f1caca31fece4a3068a384900707e6d21d04597 | https://github.com/pjamesjoyce/lcopt/blob/3f1caca31fece4a3068a384900707e6d21d04597/lcopt/bw2_export.py#L30-L55 | train |
gabfl/dbschema | src/schema_change.py | get_config | def get_config(override=None):
""" Get config file """
# Set location
config_path = os.path.expanduser('~') + '/.dbschema.yml'
if override:
config_path = override
# Check if the config file exists
check_exists(config_path)
# Load config
with open(config_path) as f:
# u... | python | def get_config(override=None):
""" Get config file """
# Set location
config_path = os.path.expanduser('~') + '/.dbschema.yml'
if override:
config_path = override
# Check if the config file exists
check_exists(config_path)
# Load config
with open(config_path) as f:
# u... | [
"def",
"get_config",
"(",
"override",
"=",
"None",
")",
":",
"# Set location",
"config_path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~'",
")",
"+",
"'/.dbschema.yml'",
"if",
"override",
":",
"config_path",
"=",
"override",
"# Check if the config file ... | Get config file | [
"Get",
"config",
"file"
] | 37722e6654e9f0374fac5518ebdca22f4c39f92f | https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L15-L31 | train |
gabfl/dbschema | src/schema_change.py | check_exists | def check_exists(path, type='file'):
""" Check if a file or a folder exists """
if type == 'file':
if not os.path.isfile(path):
raise RuntimeError('The file `%s` does not exist.' % path)
else:
if not os.path.isdir(path):
raise RuntimeError('The folder `%s` does not e... | python | def check_exists(path, type='file'):
""" Check if a file or a folder exists """
if type == 'file':
if not os.path.isfile(path):
raise RuntimeError('The file `%s` does not exist.' % path)
else:
if not os.path.isdir(path):
raise RuntimeError('The folder `%s` does not e... | [
"def",
"check_exists",
"(",
"path",
",",
"type",
"=",
"'file'",
")",
":",
"if",
"type",
"==",
"'file'",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
":",
"raise",
"RuntimeError",
"(",
"'The file `%s` does not exist.'",
"%",
"path... | Check if a file or a folder exists | [
"Check",
"if",
"a",
"file",
"or",
"a",
"folder",
"exists"
] | 37722e6654e9f0374fac5518ebdca22f4c39f92f | https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L34-L44 | train |
gabfl/dbschema | src/schema_change.py | get_connection | def get_connection(engine, host, user, port, password, database, ssl={}):
""" Returns a PostgreSQL or MySQL connection """
if engine == 'mysql':
# Connection
return get_mysql_connection(host, user, port, password, database, ssl)
elif engine == 'postgresql':
# Connection
retu... | python | def get_connection(engine, host, user, port, password, database, ssl={}):
""" Returns a PostgreSQL or MySQL connection """
if engine == 'mysql':
# Connection
return get_mysql_connection(host, user, port, password, database, ssl)
elif engine == 'postgresql':
# Connection
retu... | [
"def",
"get_connection",
"(",
"engine",
",",
"host",
",",
"user",
",",
"port",
",",
"password",
",",
"database",
",",
"ssl",
"=",
"{",
"}",
")",
":",
"if",
"engine",
"==",
"'mysql'",
":",
"# Connection",
"return",
"get_mysql_connection",
"(",
"host",
","... | Returns a PostgreSQL or MySQL connection | [
"Returns",
"a",
"PostgreSQL",
"or",
"MySQL",
"connection"
] | 37722e6654e9f0374fac5518ebdca22f4c39f92f | https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L81-L91 | train |
gabfl/dbschema | src/schema_change.py | parse_statements | def parse_statements(queries_input, engine):
""" Parse input and return a list of SQL statements """
queries = []
query = ''
sql_delimiter = ';'
# Possible delimiters used in PostgreSQL functions
postgres_func_delimiters = ['$$', '##']
# Split input by lines
lines = queries_input.stri... | python | def parse_statements(queries_input, engine):
""" Parse input and return a list of SQL statements """
queries = []
query = ''
sql_delimiter = ';'
# Possible delimiters used in PostgreSQL functions
postgres_func_delimiters = ['$$', '##']
# Split input by lines
lines = queries_input.stri... | [
"def",
"parse_statements",
"(",
"queries_input",
",",
"engine",
")",
":",
"queries",
"=",
"[",
"]",
"query",
"=",
"''",
"sql_delimiter",
"=",
"';'",
"# Possible delimiters used in PostgreSQL functions",
"postgres_func_delimiters",
"=",
"[",
"'$$'",
",",
"'##'",
"]",... | Parse input and return a list of SQL statements | [
"Parse",
"input",
"and",
"return",
"a",
"list",
"of",
"SQL",
"statements"
] | 37722e6654e9f0374fac5518ebdca22f4c39f92f | https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L124-L169 | train |
gabfl/dbschema | src/schema_change.py | run_migration | def run_migration(connection, queries, engine):
""" Apply a migration to the SQL server """
# Execute query
with connection.cursor() as cursorMig:
# Parse statements
queries = parse_statements(queries, engine)
for query in queries:
cursorMig.execute(query)
conne... | python | def run_migration(connection, queries, engine):
""" Apply a migration to the SQL server """
# Execute query
with connection.cursor() as cursorMig:
# Parse statements
queries = parse_statements(queries, engine)
for query in queries:
cursorMig.execute(query)
conne... | [
"def",
"run_migration",
"(",
"connection",
",",
"queries",
",",
"engine",
")",
":",
"# Execute query",
"with",
"connection",
".",
"cursor",
"(",
")",
"as",
"cursorMig",
":",
"# Parse statements",
"queries",
"=",
"parse_statements",
"(",
"queries",
",",
"engine",... | Apply a migration to the SQL server | [
"Apply",
"a",
"migration",
"to",
"the",
"SQL",
"server"
] | 37722e6654e9f0374fac5518ebdca22f4c39f92f | https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L172-L184 | train |
gabfl/dbschema | src/schema_change.py | save_migration | def save_migration(connection, basename):
""" Save a migration in `migrations_applied` table """
# Prepare query
sql = "INSERT INTO migrations_applied (name, date) VALUES (%s, NOW())"
# Run
with connection.cursor() as cursor:
cursor.execute(sql, (basename,))
connection.commit()
... | python | def save_migration(connection, basename):
""" Save a migration in `migrations_applied` table """
# Prepare query
sql = "INSERT INTO migrations_applied (name, date) VALUES (%s, NOW())"
# Run
with connection.cursor() as cursor:
cursor.execute(sql, (basename,))
connection.commit()
... | [
"def",
"save_migration",
"(",
"connection",
",",
"basename",
")",
":",
"# Prepare query",
"sql",
"=",
"\"INSERT INTO migrations_applied (name, date) VALUES (%s, NOW())\"",
"# Run",
"with",
"connection",
".",
"cursor",
"(",
")",
"as",
"cursor",
":",
"cursor",
".",
"exe... | Save a migration in `migrations_applied` table | [
"Save",
"a",
"migration",
"in",
"migrations_applied",
"table"
] | 37722e6654e9f0374fac5518ebdca22f4c39f92f | https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L187-L198 | train |
gabfl/dbschema | src/schema_change.py | delete_migration | def delete_migration(connection, basename):
""" Delete a migration in `migrations_applied` table """
# Prepare query
sql = "DELETE FROM migrations_applied WHERE name = %s"
# Run
with connection.cursor() as cursor:
cursor.execute(sql, (basename,))
connection.commit()
return Tru... | python | def delete_migration(connection, basename):
""" Delete a migration in `migrations_applied` table """
# Prepare query
sql = "DELETE FROM migrations_applied WHERE name = %s"
# Run
with connection.cursor() as cursor:
cursor.execute(sql, (basename,))
connection.commit()
return Tru... | [
"def",
"delete_migration",
"(",
"connection",
",",
"basename",
")",
":",
"# Prepare query",
"sql",
"=",
"\"DELETE FROM migrations_applied WHERE name = %s\"",
"# Run",
"with",
"connection",
".",
"cursor",
"(",
")",
"as",
"cursor",
":",
"cursor",
".",
"execute",
"(",
... | Delete a migration in `migrations_applied` table | [
"Delete",
"a",
"migration",
"in",
"migrations_applied",
"table"
] | 37722e6654e9f0374fac5518ebdca22f4c39f92f | https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L201-L212 | train |
gabfl/dbschema | src/schema_change.py | get_migrations_applied | def get_migrations_applied(engine, connection):
""" Get list of migrations already applied """
try:
# Get cursor based on engine
if engine == 'postgresql':
cursor = connection.cursor(
cursor_factory=psycopg2.extras.RealDictCursor)
else:
cursor = c... | python | def get_migrations_applied(engine, connection):
""" Get list of migrations already applied """
try:
# Get cursor based on engine
if engine == 'postgresql':
cursor = connection.cursor(
cursor_factory=psycopg2.extras.RealDictCursor)
else:
cursor = c... | [
"def",
"get_migrations_applied",
"(",
"engine",
",",
"connection",
")",
":",
"try",
":",
"# Get cursor based on engine",
"if",
"engine",
"==",
"'postgresql'",
":",
"cursor",
"=",
"connection",
".",
"cursor",
"(",
"cursor_factory",
"=",
"psycopg2",
".",
"extras",
... | Get list of migrations already applied | [
"Get",
"list",
"of",
"migrations",
"already",
"applied"
] | 37722e6654e9f0374fac5518ebdca22f4c39f92f | https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L221-L242 | train |
gabfl/dbschema | src/schema_change.py | apply_migrations | def apply_migrations(engine, connection, path):
""" Apply all migrations in a chronological order """
# Get migrations applied
migrations_applied = get_migrations_applied(engine, connection)
# print(migrationsApplied)
# Get migrations folder
for file in get_migrations_files(path):
# Se... | python | def apply_migrations(engine, connection, path):
""" Apply all migrations in a chronological order """
# Get migrations applied
migrations_applied = get_migrations_applied(engine, connection)
# print(migrationsApplied)
# Get migrations folder
for file in get_migrations_files(path):
# Se... | [
"def",
"apply_migrations",
"(",
"engine",
",",
"connection",
",",
"path",
")",
":",
"# Get migrations applied",
"migrations_applied",
"=",
"get_migrations_applied",
"(",
"engine",
",",
"connection",
")",
"# print(migrationsApplied)",
"# Get migrations folder",
"for",
"fil... | Apply all migrations in a chronological order | [
"Apply",
"all",
"migrations",
"in",
"a",
"chronological",
"order"
] | 37722e6654e9f0374fac5518ebdca22f4c39f92f | https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L245-L277 | train |
gabfl/dbschema | src/schema_change.py | rollback_migration | def rollback_migration(engine, connection, path, migration_to_rollback):
""" Rollback a migration """
# Get migrations applied
migrations_applied = get_migrations_applied(engine, connection)
# Ensure that the migration was previously applied
if not is_applied(migrations_applied, migration_to_rollb... | python | def rollback_migration(engine, connection, path, migration_to_rollback):
""" Rollback a migration """
# Get migrations applied
migrations_applied = get_migrations_applied(engine, connection)
# Ensure that the migration was previously applied
if not is_applied(migrations_applied, migration_to_rollb... | [
"def",
"rollback_migration",
"(",
"engine",
",",
"connection",
",",
"path",
",",
"migration_to_rollback",
")",
":",
"# Get migrations applied",
"migrations_applied",
"=",
"get_migrations_applied",
"(",
"engine",
",",
"connection",
")",
"# Ensure that the migration was previ... | Rollback a migration | [
"Rollback",
"a",
"migration"
] | 37722e6654e9f0374fac5518ebdca22f4c39f92f | https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L280-L313 | train |
gabfl/dbschema | src/schema_change.py | get_ssl | def get_ssl(database):
""" Returns SSL options for the selected engine """
# Set available keys per engine
if database['engine'] == 'postgresql':
keys = ['sslmode', 'sslcert', 'sslkey',
'sslrootcert', 'sslcrl', 'sslcompression']
else:
keys = ['ssl_ca', 'ssl_capath', 'ssl... | python | def get_ssl(database):
""" Returns SSL options for the selected engine """
# Set available keys per engine
if database['engine'] == 'postgresql':
keys = ['sslmode', 'sslcert', 'sslkey',
'sslrootcert', 'sslcrl', 'sslcompression']
else:
keys = ['ssl_ca', 'ssl_capath', 'ssl... | [
"def",
"get_ssl",
"(",
"database",
")",
":",
"# Set available keys per engine",
"if",
"database",
"[",
"'engine'",
"]",
"==",
"'postgresql'",
":",
"keys",
"=",
"[",
"'sslmode'",
",",
"'sslcert'",
",",
"'sslkey'",
",",
"'sslrootcert'",
",",
"'sslcrl'",
",",
"'s... | Returns SSL options for the selected engine | [
"Returns",
"SSL",
"options",
"for",
"the",
"selected",
"engine"
] | 37722e6654e9f0374fac5518ebdca22f4c39f92f | https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L316-L334 | train |
gabfl/dbschema | src/schema_change.py | apply | def apply(config_override=None, tag_override=None, rollback=None, skip_missing=None):
""" Look thru migrations and apply them """
# Load config
config = get_config(config_override)
databases = config['databases']
# If we are rolling back, ensure that we have a database tag
if rollback and not ... | python | def apply(config_override=None, tag_override=None, rollback=None, skip_missing=None):
""" Look thru migrations and apply them """
# Load config
config = get_config(config_override)
databases = config['databases']
# If we are rolling back, ensure that we have a database tag
if rollback and not ... | [
"def",
"apply",
"(",
"config_override",
"=",
"None",
",",
"tag_override",
"=",
"None",
",",
"rollback",
"=",
"None",
",",
"skip_missing",
"=",
"None",
")",
":",
"# Load config",
"config",
"=",
"get_config",
"(",
"config_override",
")",
"databases",
"=",
"con... | Look thru migrations and apply them | [
"Look",
"thru",
"migrations",
"and",
"apply",
"them"
] | 37722e6654e9f0374fac5518ebdca22f4c39f92f | https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L337-L396 | train |
lucianoratamero/django_apistar | django_apistar/authentication/components.py | DjangoBasicAuthentication.resolve | def resolve(self, authorization: http.Header):
"""
Determine the user associated with a request, using HTTP Basic Authentication.
"""
if authorization is None:
return None
scheme, token = authorization.split()
if scheme.lower() != 'basic':
return ... | python | def resolve(self, authorization: http.Header):
"""
Determine the user associated with a request, using HTTP Basic Authentication.
"""
if authorization is None:
return None
scheme, token = authorization.split()
if scheme.lower() != 'basic':
return ... | [
"def",
"resolve",
"(",
"self",
",",
"authorization",
":",
"http",
".",
"Header",
")",
":",
"if",
"authorization",
"is",
"None",
":",
"return",
"None",
"scheme",
",",
"token",
"=",
"authorization",
".",
"split",
"(",
")",
"if",
"scheme",
".",
"lower",
"... | Determine the user associated with a request, using HTTP Basic Authentication. | [
"Determine",
"the",
"user",
"associated",
"with",
"a",
"request",
"using",
"HTTP",
"Basic",
"Authentication",
"."
] | 615024680b8033aa346acd188cd542db3341064f | https://github.com/lucianoratamero/django_apistar/blob/615024680b8033aa346acd188cd542db3341064f/django_apistar/authentication/components.py#L9-L23 | train |
lucianoratamero/django_apistar | django_apistar/authentication/components.py | DjangoTokenAuthentication.resolve | def resolve(self, authorization: http.Header):
"""
Determine the user associated with a request, using Token Authentication.
"""
from django_apistar.authentication.models import Token
if authorization is None:
return None
scheme, token = authorization.split(... | python | def resolve(self, authorization: http.Header):
"""
Determine the user associated with a request, using Token Authentication.
"""
from django_apistar.authentication.models import Token
if authorization is None:
return None
scheme, token = authorization.split(... | [
"def",
"resolve",
"(",
"self",
",",
"authorization",
":",
"http",
".",
"Header",
")",
":",
"from",
"django_apistar",
".",
"authentication",
".",
"models",
"import",
"Token",
"if",
"authorization",
"is",
"None",
":",
"return",
"None",
"scheme",
",",
"token",
... | Determine the user associated with a request, using Token Authentication. | [
"Determine",
"the",
"user",
"associated",
"with",
"a",
"request",
"using",
"Token",
"Authentication",
"."
] | 615024680b8033aa346acd188cd542db3341064f | https://github.com/lucianoratamero/django_apistar/blob/615024680b8033aa346acd188cd542db3341064f/django_apistar/authentication/components.py#L27-L45 | train |
cocaine/cocaine-tools | cocaine/tools/cli.py | Executor.loop | def loop(self):
"""Lazy event loop initialization"""
if not self._loop:
self._loop = IOLoop.current()
return self._loop
return self._loop | python | def loop(self):
"""Lazy event loop initialization"""
if not self._loop:
self._loop = IOLoop.current()
return self._loop
return self._loop | [
"def",
"loop",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_loop",
":",
"self",
".",
"_loop",
"=",
"IOLoop",
".",
"current",
"(",
")",
"return",
"self",
".",
"_loop",
"return",
"self",
".",
"_loop"
] | Lazy event loop initialization | [
"Lazy",
"event",
"loop",
"initialization"
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/cli.py#L245-L250 | train |
cocaine/cocaine-tools | cocaine/tools/cli.py | Executor.execute_action | def execute_action(self, action_name, **options):
"""Execute action with specified options.
Tries to create action from its name and invokes it.
:param action_name: action name.
:param options: various action configuration.
"""
assert action_name in NG_ACTIONS, 'wrong a... | python | def execute_action(self, action_name, **options):
"""Execute action with specified options.
Tries to create action from its name and invokes it.
:param action_name: action name.
:param options: various action configuration.
"""
assert action_name in NG_ACTIONS, 'wrong a... | [
"def",
"execute_action",
"(",
"self",
",",
"action_name",
",",
"*",
"*",
"options",
")",
":",
"assert",
"action_name",
"in",
"NG_ACTIONS",
",",
"'wrong action - {0}'",
".",
"format",
"(",
"action_name",
")",
"action",
"=",
"NG_ACTIONS",
"[",
"action_name",
"]"... | Execute action with specified options.
Tries to create action from its name and invokes it.
:param action_name: action name.
:param options: various action configuration. | [
"Execute",
"action",
"with",
"specified",
"options",
"."
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/cli.py#L252-L263 | train |
cnschema/cdata | cdata/table.py | json2excel | def json2excel(items, keys, filename, page_size=60000):
""" max_page_size is 65000 because we output old excel .xls format
"""
wb = xlwt.Workbook()
rowindex = 0
sheetindex = 0
for item in items:
if rowindex % page_size == 0:
sheetname = "%02d" % sheetindex
ws = wb... | python | def json2excel(items, keys, filename, page_size=60000):
""" max_page_size is 65000 because we output old excel .xls format
"""
wb = xlwt.Workbook()
rowindex = 0
sheetindex = 0
for item in items:
if rowindex % page_size == 0:
sheetname = "%02d" % sheetindex
ws = wb... | [
"def",
"json2excel",
"(",
"items",
",",
"keys",
",",
"filename",
",",
"page_size",
"=",
"60000",
")",
":",
"wb",
"=",
"xlwt",
".",
"Workbook",
"(",
")",
"rowindex",
"=",
"0",
"sheetindex",
"=",
"0",
"for",
"item",
"in",
"items",
":",
"if",
"rowindex"... | max_page_size is 65000 because we output old excel .xls format | [
"max_page_size",
"is",
"65000",
"because",
"we",
"output",
"old",
"excel",
".",
"xls",
"format"
] | 893e2e1e27b61c8551c8b5f5f9bf05ec61490e23 | https://github.com/cnschema/cdata/blob/893e2e1e27b61c8551c8b5f5f9bf05ec61490e23/cdata/table.py#L22-L53 | train |
pjamesjoyce/lcopt | lcopt/parameters.py | LcoptParameterSet.check_production_parameters_exist | def check_production_parameters_exist(self):
""" old versions of models won't have produciton parameters, leading to ZeroDivision errors and breaking things"""
for k, v in self.modelInstance.parameter_sets.items():
for p_id in self.modelInstance.production_params.keys():
if v... | python | def check_production_parameters_exist(self):
""" old versions of models won't have produciton parameters, leading to ZeroDivision errors and breaking things"""
for k, v in self.modelInstance.parameter_sets.items():
for p_id in self.modelInstance.production_params.keys():
if v... | [
"def",
"check_production_parameters_exist",
"(",
"self",
")",
":",
"for",
"k",
",",
"v",
"in",
"self",
".",
"modelInstance",
".",
"parameter_sets",
".",
"items",
"(",
")",
":",
"for",
"p_id",
"in",
"self",
".",
"modelInstance",
".",
"production_params",
".",... | old versions of models won't have produciton parameters, leading to ZeroDivision errors and breaking things | [
"old",
"versions",
"of",
"models",
"won",
"t",
"have",
"produciton",
"parameters",
"leading",
"to",
"ZeroDivision",
"errors",
"and",
"breaking",
"things"
] | 3f1caca31fece4a3068a384900707e6d21d04597 | https://github.com/pjamesjoyce/lcopt/blob/3f1caca31fece4a3068a384900707e6d21d04597/lcopt/parameters.py#L100-L117 | train |
camptocamp/Studio | studio/lib/mapserializer.py | Mapfile._create_symbol | def _create_symbol(self, id, symbolobj):
"""Creates the JSON representation of a symbol"""
result = {'id': symbolobj.name, 'isPoint': False, 'isStroke': False, 'isFill': False}
matcher = Mapfile._SYMBOL_NAME_REGEXP.match(symbolobj.name)
if matcher:
result['name'] = matcher.gr... | python | def _create_symbol(self, id, symbolobj):
"""Creates the JSON representation of a symbol"""
result = {'id': symbolobj.name, 'isPoint': False, 'isStroke': False, 'isFill': False}
matcher = Mapfile._SYMBOL_NAME_REGEXP.match(symbolobj.name)
if matcher:
result['name'] = matcher.gr... | [
"def",
"_create_symbol",
"(",
"self",
",",
"id",
",",
"symbolobj",
")",
":",
"result",
"=",
"{",
"'id'",
":",
"symbolobj",
".",
"name",
",",
"'isPoint'",
":",
"False",
",",
"'isStroke'",
":",
"False",
",",
"'isFill'",
":",
"False",
"}",
"matcher",
"=",... | Creates the JSON representation of a symbol | [
"Creates",
"the",
"JSON",
"representation",
"of",
"a",
"symbol"
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/mapserializer.py#L90-L102 | train |
mete0r/hypua2jamo | src/hypua2jamo/__init__.py | translate | def translate(pua, composed=True):
''' Convert a unicode string with Hanyang-PUA codes
to a Syllable-Initial-Peak-Final encoded unicode string.
:param pua: a unicode string with Hanyang-PUA codes
:param composed: the result should be composed as possible (default True)
:return: Syllable-Initial-Pea... | python | def translate(pua, composed=True):
''' Convert a unicode string with Hanyang-PUA codes
to a Syllable-Initial-Peak-Final encoded unicode string.
:param pua: a unicode string with Hanyang-PUA codes
:param composed: the result should be composed as possible (default True)
:return: Syllable-Initial-Pea... | [
"def",
"translate",
"(",
"pua",
",",
"composed",
"=",
"True",
")",
":",
"from",
".",
"encoder",
"import",
"PUAComposedEncoder",
"from",
".",
"encoder",
"import",
"PUADecomposedEncoder",
"if",
"composed",
":",
"JamoEncoder",
"=",
"PUAComposedEncoder",
"else",
":"... | Convert a unicode string with Hanyang-PUA codes
to a Syllable-Initial-Peak-Final encoded unicode string.
:param pua: a unicode string with Hanyang-PUA codes
:param composed: the result should be composed as possible (default True)
:return: Syllable-Initial-Peak-Final encoded unicode string | [
"Convert",
"a",
"unicode",
"string",
"with",
"Hanyang",
"-",
"PUA",
"codes",
"to",
"a",
"Syllable",
"-",
"Initial",
"-",
"Peak",
"-",
"Final",
"encoded",
"unicode",
"string",
"."
] | caceb33a26c27645703d659a82bb1152deef1469 | https://github.com/mete0r/hypua2jamo/blob/caceb33a26c27645703d659a82bb1152deef1469/src/hypua2jamo/__init__.py#L32-L49 | train |
mete0r/hypua2jamo | src/hypua2jamo/__init__.py | codes2unicode | def codes2unicode(codes, composed=True):
''' Convert Hanyang-PUA code iterable to Syllable-Initial-Peak-Final
encoded unicode string.
:param codes:
an iterable of Hanyang-PUA code
:param composed:
the result should be composed as much as possible (default True)
:return: Syllable-Ini... | python | def codes2unicode(codes, composed=True):
''' Convert Hanyang-PUA code iterable to Syllable-Initial-Peak-Final
encoded unicode string.
:param codes:
an iterable of Hanyang-PUA code
:param composed:
the result should be composed as much as possible (default True)
:return: Syllable-Ini... | [
"def",
"codes2unicode",
"(",
"codes",
",",
"composed",
"=",
"True",
")",
":",
"pua",
"=",
"u''",
".",
"join",
"(",
"unichr",
"(",
"code",
")",
"for",
"code",
"in",
"codes",
")",
"return",
"translate",
"(",
"pua",
",",
"composed",
"=",
"composed",
")"... | Convert Hanyang-PUA code iterable to Syllable-Initial-Peak-Final
encoded unicode string.
:param codes:
an iterable of Hanyang-PUA code
:param composed:
the result should be composed as much as possible (default True)
:return: Syllable-Initial-Peak-Final encoded unicode string | [
"Convert",
"Hanyang",
"-",
"PUA",
"code",
"iterable",
"to",
"Syllable",
"-",
"Initial",
"-",
"Peak",
"-",
"Final",
"encoded",
"unicode",
"string",
"."
] | caceb33a26c27645703d659a82bb1152deef1469 | https://github.com/mete0r/hypua2jamo/blob/caceb33a26c27645703d659a82bb1152deef1469/src/hypua2jamo/__init__.py#L52-L63 | train |
teepark/greenhouse | greenhouse/io/ssl.py | SSLSocket.read | def read(self, len=1024):
'read up to len bytes and return them, or empty string on EOF'
return self._with_retry(
functools.partial(self._read_attempt, len),
self.gettimeout()) | python | def read(self, len=1024):
'read up to len bytes and return them, or empty string on EOF'
return self._with_retry(
functools.partial(self._read_attempt, len),
self.gettimeout()) | [
"def",
"read",
"(",
"self",
",",
"len",
"=",
"1024",
")",
":",
"return",
"self",
".",
"_with_retry",
"(",
"functools",
".",
"partial",
"(",
"self",
".",
"_read_attempt",
",",
"len",
")",
",",
"self",
".",
"gettimeout",
"(",
")",
")"
] | read up to len bytes and return them, or empty string on EOF | [
"read",
"up",
"to",
"len",
"bytes",
"and",
"return",
"them",
"or",
"empty",
"string",
"on",
"EOF"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/io/ssl.py#L114-L118 | train |
teepark/greenhouse | greenhouse/io/ssl.py | SSLSocket.connect | def connect(self, address):
'connects to the address and wraps the connection in an SSL context'
tout = _timeout(self.gettimeout())
while 1:
self._wait_event(tout.now, write=True)
err = self._connect(address, tout.now)
if err in (errno.EINPROGRESS, errno.EALRE... | python | def connect(self, address):
'connects to the address and wraps the connection in an SSL context'
tout = _timeout(self.gettimeout())
while 1:
self._wait_event(tout.now, write=True)
err = self._connect(address, tout.now)
if err in (errno.EINPROGRESS, errno.EALRE... | [
"def",
"connect",
"(",
"self",
",",
"address",
")",
":",
"tout",
"=",
"_timeout",
"(",
"self",
".",
"gettimeout",
"(",
")",
")",
"while",
"1",
":",
"self",
".",
"_wait_event",
"(",
"tout",
".",
"now",
",",
"write",
"=",
"True",
")",
"err",
"=",
"... | connects to the address and wraps the connection in an SSL context | [
"connects",
"to",
"the",
"address",
"and",
"wraps",
"the",
"connection",
"in",
"an",
"SSL",
"context"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/io/ssl.py#L287-L297 | train |
teepark/greenhouse | greenhouse/io/ssl.py | SSLSocket.accept | def accept(self):
"""accept a connection attempt from a remote client
returns a two-tuple with the ssl-context-wrapped connection,
and the address of the remote client
"""
while 1:
try:
sock, addr = self._sock.accept()
return (type(sel... | python | def accept(self):
"""accept a connection attempt from a remote client
returns a two-tuple with the ssl-context-wrapped connection,
and the address of the remote client
"""
while 1:
try:
sock, addr = self._sock.accept()
return (type(sel... | [
"def",
"accept",
"(",
"self",
")",
":",
"while",
"1",
":",
"try",
":",
"sock",
",",
"addr",
"=",
"self",
".",
"_sock",
".",
"accept",
"(",
")",
"return",
"(",
"type",
"(",
"self",
")",
"(",
"sock",
",",
"keyfile",
"=",
"self",
".",
"keyfile",
"... | accept a connection attempt from a remote client
returns a two-tuple with the ssl-context-wrapped connection,
and the address of the remote client | [
"accept",
"a",
"connection",
"attempt",
"from",
"a",
"remote",
"client"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/io/ssl.py#L299-L322 | train |
teepark/greenhouse | greenhouse/io/ssl.py | SSLSocket.makefile | def makefile(self, mode='r', bufsize=-1):
'return a file-like object that operates on the ssl connection'
sockfile = gsock.SocketFile.__new__(gsock.SocketFile)
gfiles.FileBase.__init__(sockfile)
sockfile._sock = self
sockfile.mode = mode
if bufsize > 0:
sockfi... | python | def makefile(self, mode='r', bufsize=-1):
'return a file-like object that operates on the ssl connection'
sockfile = gsock.SocketFile.__new__(gsock.SocketFile)
gfiles.FileBase.__init__(sockfile)
sockfile._sock = self
sockfile.mode = mode
if bufsize > 0:
sockfi... | [
"def",
"makefile",
"(",
"self",
",",
"mode",
"=",
"'r'",
",",
"bufsize",
"=",
"-",
"1",
")",
":",
"sockfile",
"=",
"gsock",
".",
"SocketFile",
".",
"__new__",
"(",
"gsock",
".",
"SocketFile",
")",
"gfiles",
".",
"FileBase",
".",
"__init__",
"(",
"soc... | return a file-like object that operates on the ssl connection | [
"return",
"a",
"file",
"-",
"like",
"object",
"that",
"operates",
"on",
"the",
"ssl",
"connection"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/io/ssl.py#L324-L332 | train |
polysquare/cmake-ast | container-setup.py | run | def run(cont, util, shell, argv=None):
"""Set up language runtimes and pass control to python project script."""
cont.fetch_and_import("setup/python/setup.py").run(cont,
util,
shell,
... | python | def run(cont, util, shell, argv=None):
"""Set up language runtimes and pass control to python project script."""
cont.fetch_and_import("setup/python/setup.py").run(cont,
util,
shell,
... | [
"def",
"run",
"(",
"cont",
",",
"util",
",",
"shell",
",",
"argv",
"=",
"None",
")",
":",
"cont",
".",
"fetch_and_import",
"(",
"\"setup/python/setup.py\"",
")",
".",
"run",
"(",
"cont",
",",
"util",
",",
"shell",
",",
"argv",
")",
"cmake_cont",
"=",
... | Set up language runtimes and pass control to python project script. | [
"Set",
"up",
"language",
"runtimes",
"and",
"pass",
"control",
"to",
"python",
"project",
"script",
"."
] | 431a32d595d76f1f8f993eb6ddcc79effbadff9d | https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/container-setup.py#L17-L64 | train |
nickpandolfi/Cyther | cyther/extractor.py | get_content | def get_content(pattern, string, tag='content'):
"""
Finds the 'content' tag from a 'pattern' in the provided 'string'
"""
output = []
for match in re.finditer(pattern, string):
output.append(match.group(tag))
return output | python | def get_content(pattern, string, tag='content'):
"""
Finds the 'content' tag from a 'pattern' in the provided 'string'
"""
output = []
for match in re.finditer(pattern, string):
output.append(match.group(tag))
return output | [
"def",
"get_content",
"(",
"pattern",
",",
"string",
",",
"tag",
"=",
"'content'",
")",
":",
"output",
"=",
"[",
"]",
"for",
"match",
"in",
"re",
".",
"finditer",
"(",
"pattern",
",",
"string",
")",
":",
"output",
".",
"append",
"(",
"match",
".",
... | Finds the 'content' tag from a 'pattern' in the provided 'string' | [
"Finds",
"the",
"content",
"tag",
"from",
"a",
"pattern",
"in",
"the",
"provided",
"string"
] | 9fb0bd77af594008aa6ee8af460aa8c953abf5bc | https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/extractor.py#L13-L20 | train |
nickpandolfi/Cyther | cyther/extractor.py | extract | def extract(pattern, string, *, assert_equal=False, one=False,
condense=False, default=None, default_if_multiple=True,
default_if_none=True):
"""
Used to extract a given regex pattern from a string, given several options
"""
if isinstance(pattern, str):
output = get_cont... | python | def extract(pattern, string, *, assert_equal=False, one=False,
condense=False, default=None, default_if_multiple=True,
default_if_none=True):
"""
Used to extract a given regex pattern from a string, given several options
"""
if isinstance(pattern, str):
output = get_cont... | [
"def",
"extract",
"(",
"pattern",
",",
"string",
",",
"*",
",",
"assert_equal",
"=",
"False",
",",
"one",
"=",
"False",
",",
"condense",
"=",
"False",
",",
"default",
"=",
"None",
",",
"default_if_multiple",
"=",
"True",
",",
"default_if_none",
"=",
"Tru... | Used to extract a given regex pattern from a string, given several options | [
"Used",
"to",
"extract",
"a",
"given",
"regex",
"pattern",
"from",
"a",
"string",
"given",
"several",
"options"
] | 9fb0bd77af594008aa6ee8af460aa8c953abf5bc | https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/extractor.py#L23-L46 | train |
nickpandolfi/Cyther | cyther/extractor.py | extractRuntime | def extractRuntime(runtime_dirs):
"""
Used to find the correct static lib name to pass to gcc
"""
names = [str(item) for name in runtime_dirs for item in os.listdir(name)]
string = '\n'.join(names)
result = extract(RUNTIME_PATTERN, string, condense=True)
return result | python | def extractRuntime(runtime_dirs):
"""
Used to find the correct static lib name to pass to gcc
"""
names = [str(item) for name in runtime_dirs for item in os.listdir(name)]
string = '\n'.join(names)
result = extract(RUNTIME_PATTERN, string, condense=True)
return result | [
"def",
"extractRuntime",
"(",
"runtime_dirs",
")",
":",
"names",
"=",
"[",
"str",
"(",
"item",
")",
"for",
"name",
"in",
"runtime_dirs",
"for",
"item",
"in",
"os",
".",
"listdir",
"(",
"name",
")",
"]",
"string",
"=",
"'\\n'",
".",
"join",
"(",
"name... | Used to find the correct static lib name to pass to gcc | [
"Used",
"to",
"find",
"the",
"correct",
"static",
"lib",
"name",
"to",
"pass",
"to",
"gcc"
] | 9fb0bd77af594008aa6ee8af460aa8c953abf5bc | https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/extractor.py#L52-L59 | train |
nickpandolfi/Cyther | cyther/extractor.py | extractVersion | def extractVersion(string, default='?'):
"""
Extracts a three digit standard format version number
"""
return extract(VERSION_PATTERN, string, condense=True, default=default,
one=True) | python | def extractVersion(string, default='?'):
"""
Extracts a three digit standard format version number
"""
return extract(VERSION_PATTERN, string, condense=True, default=default,
one=True) | [
"def",
"extractVersion",
"(",
"string",
",",
"default",
"=",
"'?'",
")",
":",
"return",
"extract",
"(",
"VERSION_PATTERN",
",",
"string",
",",
"condense",
"=",
"True",
",",
"default",
"=",
"default",
",",
"one",
"=",
"True",
")"
] | Extracts a three digit standard format version number | [
"Extracts",
"a",
"three",
"digit",
"standard",
"format",
"version",
"number"
] | 9fb0bd77af594008aa6ee8af460aa8c953abf5bc | https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/extractor.py#L87-L92 | train |
EVEprosper/ProsperCommon | prosper/common/prosper_config.py | render_secrets | def render_secrets(
config_path,
secret_path,
):
"""combine a jinja template with a secret .ini file
Args:
config_path (str): path to .cfg file with jinja templating
secret_path (str): path to .ini-like secrets file
Returns:
ProsperConfig: rendered configuration obj... | python | def render_secrets(
config_path,
secret_path,
):
"""combine a jinja template with a secret .ini file
Args:
config_path (str): path to .cfg file with jinja templating
secret_path (str): path to .ini-like secrets file
Returns:
ProsperConfig: rendered configuration obj... | [
"def",
"render_secrets",
"(",
"config_path",
",",
"secret_path",
",",
")",
":",
"with",
"open",
"(",
"secret_path",
",",
"'r'",
")",
"as",
"s_fh",
":",
"secret_ini",
"=",
"anyconfig",
".",
"load",
"(",
"s_fh",
",",
"ac_parser",
"=",
"'ini'",
")",
"with",... | combine a jinja template with a secret .ini file
Args:
config_path (str): path to .cfg file with jinja templating
secret_path (str): path to .ini-like secrets file
Returns:
ProsperConfig: rendered configuration object | [
"combine",
"a",
"jinja",
"template",
"with",
"a",
"secret",
".",
"ini",
"file"
] | bcada3b25420099e1f204db8d55eb268e7b4dc27 | https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_config.py#L17-L46 | train |
EVEprosper/ProsperCommon | prosper/common/prosper_config.py | check_value | def check_value(
config,
section,
option,
jinja_pattern=JINJA_PATTERN,
):
"""try to figure out if value is valid or jinja2 template value
Args:
config (:obj:`configparser.ConfigParser`): config object to read key from
section (str): name of section in configparse... | python | def check_value(
config,
section,
option,
jinja_pattern=JINJA_PATTERN,
):
"""try to figure out if value is valid or jinja2 template value
Args:
config (:obj:`configparser.ConfigParser`): config object to read key from
section (str): name of section in configparse... | [
"def",
"check_value",
"(",
"config",
",",
"section",
",",
"option",
",",
"jinja_pattern",
"=",
"JINJA_PATTERN",
",",
")",
":",
"value",
"=",
"config",
"[",
"section",
"]",
"[",
"option",
"]",
"if",
"re",
".",
"match",
"(",
"jinja_pattern",
",",
"value",
... | try to figure out if value is valid or jinja2 template value
Args:
config (:obj:`configparser.ConfigParser`): config object to read key from
section (str): name of section in configparser
option (str): name of option in configparser
jinja_pattern (:obj:`_sre.SRE_Pattern`): a `re.com... | [
"try",
"to",
"figure",
"out",
"if",
"value",
"is",
"valid",
"or",
"jinja2",
"template",
"value"
] | bcada3b25420099e1f204db8d55eb268e7b4dc27 | https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_config.py#L48-L75 | train |
EVEprosper/ProsperCommon | prosper/common/prosper_config.py | read_config | def read_config(
config_filepath,
logger=logging.getLogger('ProsperCommon'),
):
"""fetch and parse config file
Args:
config_filepath (str): path to config file. abspath > relpath
logger (:obj:`logging.Logger`): logger to catch error msgs
"""
config_parser = configparse... | python | def read_config(
config_filepath,
logger=logging.getLogger('ProsperCommon'),
):
"""fetch and parse config file
Args:
config_filepath (str): path to config file. abspath > relpath
logger (:obj:`logging.Logger`): logger to catch error msgs
"""
config_parser = configparse... | [
"def",
"read_config",
"(",
"config_filepath",
",",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"'ProsperCommon'",
")",
",",
")",
":",
"config_parser",
"=",
"configparser",
".",
"ConfigParser",
"(",
"interpolation",
"=",
"ExtendedInterpolation",
"(",
")",
",... | fetch and parse config file
Args:
config_filepath (str): path to config file. abspath > relpath
logger (:obj:`logging.Logger`): logger to catch error msgs | [
"fetch",
"and",
"parse",
"config",
"file"
] | bcada3b25420099e1f204db8d55eb268e7b4dc27 | https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_config.py#L265-L287 | train |
EVEprosper/ProsperCommon | prosper/common/prosper_config.py | get_local_config_filepath | def get_local_config_filepath(
config_filepath,
force_local=False,
):
"""helper for finding local filepath for config
Args:
config_filepath (str): path to local config abspath > relpath
force_local (bool): force return of _local.cfg version
Returns:
str: Path to loc... | python | def get_local_config_filepath(
config_filepath,
force_local=False,
):
"""helper for finding local filepath for config
Args:
config_filepath (str): path to local config abspath > relpath
force_local (bool): force return of _local.cfg version
Returns:
str: Path to loc... | [
"def",
"get_local_config_filepath",
"(",
"config_filepath",
",",
"force_local",
"=",
"False",
",",
")",
":",
"local_config_name",
"=",
"path",
".",
"basename",
"(",
"config_filepath",
")",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
"+",
"'_local.cfg'",
"l... | helper for finding local filepath for config
Args:
config_filepath (str): path to local config abspath > relpath
force_local (bool): force return of _local.cfg version
Returns:
str: Path to local config, or global if path DNE | [
"helper",
"for",
"finding",
"local",
"filepath",
"for",
"config"
] | bcada3b25420099e1f204db8d55eb268e7b4dc27 | https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_config.py#L289-L314 | train |
EVEprosper/ProsperCommon | prosper/common/prosper_config.py | ProsperConfig.get_option | def get_option(
self,
section_name,
key_name,
args_option=None,
args_default=None,
):
"""evaluates the requested option and returns the correct value
Notes:
Priority order
1. args given at runtile
2. <co... | python | def get_option(
self,
section_name,
key_name,
args_option=None,
args_default=None,
):
"""evaluates the requested option and returns the correct value
Notes:
Priority order
1. args given at runtile
2. <co... | [
"def",
"get_option",
"(",
"self",
",",
"section_name",
",",
"key_name",
",",
"args_option",
"=",
"None",
",",
"args_default",
"=",
"None",
",",
")",
":",
"if",
"args_option",
"!=",
"args_default",
"and",
"args_option",
"is",
"not",
"None",
":",
"self",
"."... | evaluates the requested option and returns the correct value
Notes:
Priority order
1. args given at runtile
2. <config_file>_local.cfg -- untracked config with #SECRETS
3. <config_file>.cfg -- tracked 'master' config without #SECRETS
4. environment va... | [
"evaluates",
"the",
"requested",
"option",
"and",
"returns",
"the",
"correct",
"value"
] | bcada3b25420099e1f204db8d55eb268e7b4dc27 | https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_config.py#L150-L207 | train |
CenturyLinkCloud/clc-python-sdk | src/clc/APIv2/__init__.py | SetCredentials | def SetCredentials(api_username,api_passwd):
"""Establish API username and password associated with APIv2 commands."""
global V2_API_USERNAME
global V2_API_PASSWD
global _V2_ENABLED
_V2_ENABLED = True
V2_API_USERNAME = api_username
V2_API_PASSWD = api_passwd | python | def SetCredentials(api_username,api_passwd):
"""Establish API username and password associated with APIv2 commands."""
global V2_API_USERNAME
global V2_API_PASSWD
global _V2_ENABLED
_V2_ENABLED = True
V2_API_USERNAME = api_username
V2_API_PASSWD = api_passwd | [
"def",
"SetCredentials",
"(",
"api_username",
",",
"api_passwd",
")",
":",
"global",
"V2_API_USERNAME",
"global",
"V2_API_PASSWD",
"global",
"_V2_ENABLED",
"_V2_ENABLED",
"=",
"True",
"V2_API_USERNAME",
"=",
"api_username",
"V2_API_PASSWD",
"=",
"api_passwd"
] | Establish API username and password associated with APIv2 commands. | [
"Establish",
"API",
"username",
"and",
"password",
"associated",
"with",
"APIv2",
"commands",
"."
] | f4dba40c627cb08dd4b7d0d277e8d67578010b05 | https://github.com/CenturyLinkCloud/clc-python-sdk/blob/f4dba40c627cb08dd4b7d0d277e8d67578010b05/src/clc/APIv2/__init__.py#L46-L53 | train |
CenturyLinkCloud/clc-python-sdk | src/clc/APIv2/__init__.py | get_session | def get_session(username, password, default_endpoints=clc.defaults, cert=None):
"""Start a session with the given parameters
Use instead of SetCredentials if you need a session object to avoid the use of global credentials.
Returns a session object accepted by many v2 objects.
"""
if cert is None:
cert = API._... | python | def get_session(username, password, default_endpoints=clc.defaults, cert=None):
"""Start a session with the given parameters
Use instead of SetCredentials if you need a session object to avoid the use of global credentials.
Returns a session object accepted by many v2 objects.
"""
if cert is None:
cert = API._... | [
"def",
"get_session",
"(",
"username",
",",
"password",
",",
"default_endpoints",
"=",
"clc",
".",
"defaults",
",",
"cert",
"=",
"None",
")",
":",
"if",
"cert",
"is",
"None",
":",
"cert",
"=",
"API",
".",
"_ResourcePath",
"(",
"'clc/cacert.pem'",
")",
"s... | Start a session with the given parameters
Use instead of SetCredentials if you need a session object to avoid the use of global credentials.
Returns a session object accepted by many v2 objects. | [
"Start",
"a",
"session",
"with",
"the",
"given",
"parameters"
] | f4dba40c627cb08dd4b7d0d277e8d67578010b05 | https://github.com/CenturyLinkCloud/clc-python-sdk/blob/f4dba40c627cb08dd4b7d0d277e8d67578010b05/src/clc/APIv2/__init__.py#L56-L91 | train |
cltl/KafNafParserPy | KafNafParserPy/features_data.py | Cproperty.set_id | def set_id(self,pid):
"""
Set the property identifier
@type pid: string
@param pid: property identifier
"""
if self.type == 'KAF':
return self.node.set('pid',pid)
elif self.type == 'NAF':
return self.node.set('id',pid) | python | def set_id(self,pid):
"""
Set the property identifier
@type pid: string
@param pid: property identifier
"""
if self.type == 'KAF':
return self.node.set('pid',pid)
elif self.type == 'NAF':
return self.node.set('id',pid) | [
"def",
"set_id",
"(",
"self",
",",
"pid",
")",
":",
"if",
"self",
".",
"type",
"==",
"'KAF'",
":",
"return",
"self",
".",
"node",
".",
"set",
"(",
"'pid'",
",",
"pid",
")",
"elif",
"self",
".",
"type",
"==",
"'NAF'",
":",
"return",
"self",
".",
... | Set the property identifier
@type pid: string
@param pid: property identifier | [
"Set",
"the",
"property",
"identifier"
] | 9bc32e803c176404b255ba317479b8780ed5f569 | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/features_data.py#L47-L56 | train |
cltl/KafNafParserPy | KafNafParserPy/features_data.py | Cfeatures.to_kaf | def to_kaf(self):
"""
Converts the element to NAF
"""
if self.type == 'NAF':
##convert all the properties
for node in self.node.findall('properties/property'):
node.set('pid',node.get('id'))
del node.attrib['id'] | python | def to_kaf(self):
"""
Converts the element to NAF
"""
if self.type == 'NAF':
##convert all the properties
for node in self.node.findall('properties/property'):
node.set('pid',node.get('id'))
del node.attrib['id'] | [
"def",
"to_kaf",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"==",
"'NAF'",
":",
"##convert all the properties",
"for",
"node",
"in",
"self",
".",
"node",
".",
"findall",
"(",
"'properties/property'",
")",
":",
"node",
".",
"set",
"(",
"'pid'",
","... | Converts the element to NAF | [
"Converts",
"the",
"element",
"to",
"NAF"
] | 9bc32e803c176404b255ba317479b8780ed5f569 | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/features_data.py#L187-L195 | train |
cltl/KafNafParserPy | KafNafParserPy/features_data.py | Cfeatures.to_naf | def to_naf(self):
"""
Converts the element to KAF
"""
if self.type == 'KAF':
##convert all the properties
for node in self.node.findall('properties/property'):
node.set('id',node.get('pid'))
del node.attrib['pid'] | python | def to_naf(self):
"""
Converts the element to KAF
"""
if self.type == 'KAF':
##convert all the properties
for node in self.node.findall('properties/property'):
node.set('id',node.get('pid'))
del node.attrib['pid'] | [
"def",
"to_naf",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"==",
"'KAF'",
":",
"##convert all the properties",
"for",
"node",
"in",
"self",
".",
"node",
".",
"findall",
"(",
"'properties/property'",
")",
":",
"node",
".",
"set",
"(",
"'id'",
",",... | Converts the element to KAF | [
"Converts",
"the",
"element",
"to",
"KAF"
] | 9bc32e803c176404b255ba317479b8780ed5f569 | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/features_data.py#L197-L205 | train |
cltl/KafNafParserPy | KafNafParserPy/features_data.py | Cfeatures.get_properties | def get_properties(self):
"""
Iterator that returns all the properties of the layuer
@rtype: L{Cproperty}
@return: list of property objects (iterator)
"""
node_prop = self.node.find('properties')
if node_prop is not None:
obj_properties = Cproperties(n... | python | def get_properties(self):
"""
Iterator that returns all the properties of the layuer
@rtype: L{Cproperty}
@return: list of property objects (iterator)
"""
node_prop = self.node.find('properties')
if node_prop is not None:
obj_properties = Cproperties(n... | [
"def",
"get_properties",
"(",
"self",
")",
":",
"node_prop",
"=",
"self",
".",
"node",
".",
"find",
"(",
"'properties'",
")",
"if",
"node_prop",
"is",
"not",
"None",
":",
"obj_properties",
"=",
"Cproperties",
"(",
"node_prop",
",",
"self",
".",
"type",
"... | Iterator that returns all the properties of the layuer
@rtype: L{Cproperty}
@return: list of property objects (iterator) | [
"Iterator",
"that",
"returns",
"all",
"the",
"properties",
"of",
"the",
"layuer"
] | 9bc32e803c176404b255ba317479b8780ed5f569 | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/features_data.py#L227-L237 | train |
cltl/KafNafParserPy | KafNafParserPy/features_data.py | Cfeatures.remove_properties | def remove_properties(self):
"""
Removes the property layer, if exists
"""
node_prop = self.node.find('properties')
if node_prop is not None:
self.node.remove(node_prop) | python | def remove_properties(self):
"""
Removes the property layer, if exists
"""
node_prop = self.node.find('properties')
if node_prop is not None:
self.node.remove(node_prop) | [
"def",
"remove_properties",
"(",
"self",
")",
":",
"node_prop",
"=",
"self",
".",
"node",
".",
"find",
"(",
"'properties'",
")",
"if",
"node_prop",
"is",
"not",
"None",
":",
"self",
".",
"node",
".",
"remove",
"(",
"node_prop",
")"
] | Removes the property layer, if exists | [
"Removes",
"the",
"property",
"layer",
"if",
"exists"
] | 9bc32e803c176404b255ba317479b8780ed5f569 | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/features_data.py#L240-L246 | train |
cltl/KafNafParserPy | KafNafParserPy/markable_data.py | Cmarkable.get_id | def get_id(self):
"""
Returns the term identifier
@rtype: string
@return: the term identifier
"""
if self.type == 'NAF':
return self.node.get('id')
elif self.type == 'KAF':
return self.node.get('mid') | python | def get_id(self):
"""
Returns the term identifier
@rtype: string
@return: the term identifier
"""
if self.type == 'NAF':
return self.node.get('id')
elif self.type == 'KAF':
return self.node.get('mid') | [
"def",
"get_id",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"==",
"'NAF'",
":",
"return",
"self",
".",
"node",
".",
"get",
"(",
"'id'",
")",
"elif",
"self",
".",
"type",
"==",
"'KAF'",
":",
"return",
"self",
".",
"node",
".",
"get",
"(",
... | Returns the term identifier
@rtype: string
@return: the term identifier | [
"Returns",
"the",
"term",
"identifier"
] | 9bc32e803c176404b255ba317479b8780ed5f569 | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/markable_data.py#L39-L48 | train |
cltl/KafNafParserPy | KafNafParserPy/markable_data.py | Cmarkable.set_id | def set_id(self,i):
"""
Sets the identifier for the term
@type i: string
@param i: lemma identifier
"""
if self.type == 'NAF':
self.node.set('id',i)
elif self.type == 'KAF':
self.node.set('mid',i) | python | def set_id(self,i):
"""
Sets the identifier for the term
@type i: string
@param i: lemma identifier
"""
if self.type == 'NAF':
self.node.set('id',i)
elif self.type == 'KAF':
self.node.set('mid',i) | [
"def",
"set_id",
"(",
"self",
",",
"i",
")",
":",
"if",
"self",
".",
"type",
"==",
"'NAF'",
":",
"self",
".",
"node",
".",
"set",
"(",
"'id'",
",",
"i",
")",
"elif",
"self",
".",
"type",
"==",
"'KAF'",
":",
"self",
".",
"node",
".",
"set",
"(... | Sets the identifier for the term
@type i: string
@param i: lemma identifier | [
"Sets",
"the",
"identifier",
"for",
"the",
"term"
] | 9bc32e803c176404b255ba317479b8780ed5f569 | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/markable_data.py#L50-L59 | train |
cltl/KafNafParserPy | KafNafParserPy/markable_data.py | Cmarkable.add_external_reference | def add_external_reference(self,ext_ref):
"""
Adds an external reference object to the markable
@type ext_ref: L{CexternalReference}
@param ext_ref: an external reference object
"""
ext_refs_node = self.node.find('externalReferences')
if ext_refs_node is None:
... | python | def add_external_reference(self,ext_ref):
"""
Adds an external reference object to the markable
@type ext_ref: L{CexternalReference}
@param ext_ref: an external reference object
"""
ext_refs_node = self.node.find('externalReferences')
if ext_refs_node is None:
... | [
"def",
"add_external_reference",
"(",
"self",
",",
"ext_ref",
")",
":",
"ext_refs_node",
"=",
"self",
".",
"node",
".",
"find",
"(",
"'externalReferences'",
")",
"if",
"ext_refs_node",
"is",
"None",
":",
"ext_refs_obj",
"=",
"CexternalReferences",
"(",
")",
"s... | Adds an external reference object to the markable
@type ext_ref: L{CexternalReference}
@param ext_ref: an external reference object | [
"Adds",
"an",
"external",
"reference",
"object",
"to",
"the",
"markable"
] | 9bc32e803c176404b255ba317479b8780ed5f569 | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/markable_data.py#L116-L129 | train |
cltl/KafNafParserPy | KafNafParserPy/markable_data.py | Cmarkable.get_external_references | def get_external_references(self):
"""
Iterator that returns all the external references of the markable
@rtype: L{CexternalReference}
@return: the external references
"""
for ext_ref_node in self.node.findall('externalReferences'):
ext_refs_obj = CexternalRef... | python | def get_external_references(self):
"""
Iterator that returns all the external references of the markable
@rtype: L{CexternalReference}
@return: the external references
"""
for ext_ref_node in self.node.findall('externalReferences'):
ext_refs_obj = CexternalRef... | [
"def",
"get_external_references",
"(",
"self",
")",
":",
"for",
"ext_ref_node",
"in",
"self",
".",
"node",
".",
"findall",
"(",
"'externalReferences'",
")",
":",
"ext_refs_obj",
"=",
"CexternalReferences",
"(",
"ext_ref_node",
")",
"for",
"ref",
"in",
"ext_refs_... | Iterator that returns all the external references of the markable
@rtype: L{CexternalReference}
@return: the external references | [
"Iterator",
"that",
"returns",
"all",
"the",
"external",
"references",
"of",
"the",
"markable"
] | 9bc32e803c176404b255ba317479b8780ed5f569 | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/markable_data.py#L132-L141 | train |
cltl/KafNafParserPy | KafNafParserPy/markable_data.py | Cmarkables.add_external_reference | def add_external_reference(self,markable_id, external_ref):
"""
Adds an external reference for the given markable
@type markable_id: string
@param markable_id: the markable identifier
@type external_ref: L{CexternalReference}
@param external_ref: the external reference ob... | python | def add_external_reference(self,markable_id, external_ref):
"""
Adds an external reference for the given markable
@type markable_id: string
@param markable_id: the markable identifier
@type external_ref: L{CexternalReference}
@param external_ref: the external reference ob... | [
"def",
"add_external_reference",
"(",
"self",
",",
"markable_id",
",",
"external_ref",
")",
":",
"if",
"markable_id",
"in",
"self",
".",
"idx",
":",
"markable_obj",
"=",
"Cterm",
"(",
"self",
".",
"idx",
"[",
"markable_id",
"]",
",",
"self",
".",
"type",
... | Adds an external reference for the given markable
@type markable_id: string
@param markable_id: the markable identifier
@type external_ref: L{CexternalReference}
@param external_ref: the external reference object | [
"Adds",
"an",
"external",
"reference",
"for",
"the",
"given",
"markable"
] | 9bc32e803c176404b255ba317479b8780ed5f569 | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/markable_data.py#L247-L259 | train |
cltl/KafNafParserPy | KafNafParserPy/markable_data.py | Cmarkables.remove_markables | def remove_markables(self,list_mark_ids):
"""
Removes a list of markables from the layer
@type list_term_ids: list
@param list_term_ids: list of markable identifiers to be removed
"""
nodes_to_remove = set()
for markable in self:
if markable.get_id()... | python | def remove_markables(self,list_mark_ids):
"""
Removes a list of markables from the layer
@type list_term_ids: list
@param list_term_ids: list of markable identifiers to be removed
"""
nodes_to_remove = set()
for markable in self:
if markable.get_id()... | [
"def",
"remove_markables",
"(",
"self",
",",
"list_mark_ids",
")",
":",
"nodes_to_remove",
"=",
"set",
"(",
")",
"for",
"markable",
"in",
"self",
":",
"if",
"markable",
".",
"get_id",
"(",
")",
"in",
"list_mark_ids",
":",
"nodes_to_remove",
".",
"add",
"("... | Removes a list of markables from the layer
@type list_term_ids: list
@param list_term_ids: list of markable identifiers to be removed | [
"Removes",
"a",
"list",
"of",
"markables",
"from",
"the",
"layer"
] | 9bc32e803c176404b255ba317479b8780ed5f569 | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/markable_data.py#L261-L277 | train |
Open-ET/openet-core-beta | openet/core/utils.py | getinfo | def getinfo(ee_obj, n=4):
"""Make an exponential back off getInfo call on an Earth Engine object"""
output = None
for i in range(1, n):
try:
output = ee_obj.getInfo()
except ee.ee_exception.EEException as e:
if 'Earth Engine memory capacity exceeded' in str(e):
... | python | def getinfo(ee_obj, n=4):
"""Make an exponential back off getInfo call on an Earth Engine object"""
output = None
for i in range(1, n):
try:
output = ee_obj.getInfo()
except ee.ee_exception.EEException as e:
if 'Earth Engine memory capacity exceeded' in str(e):
... | [
"def",
"getinfo",
"(",
"ee_obj",
",",
"n",
"=",
"4",
")",
":",
"output",
"=",
"None",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"n",
")",
":",
"try",
":",
"output",
"=",
"ee_obj",
".",
"getInfo",
"(",
")",
"except",
"ee",
".",
"ee_exception",
"... | Make an exponential back off getInfo call on an Earth Engine object | [
"Make",
"an",
"exponential",
"back",
"off",
"getInfo",
"call",
"on",
"an",
"Earth",
"Engine",
"object"
] | f2b81ccf87bf7e7fe1b9f3dd1d4081d0ec7852db | https://github.com/Open-ET/openet-core-beta/blob/f2b81ccf87bf7e7fe1b9f3dd1d4081d0ec7852db/openet/core/utils.py#L9-L27 | train |
Open-ET/openet-core-beta | openet/core/utils.py | constant_image_value | def constant_image_value(image, crs='EPSG:32613', scale=1):
"""Extract the output value from a calculation done with constant images"""
return getinfo(ee.Image(image).reduceRegion(
reducer=ee.Reducer.first(), scale=scale,
geometry=ee.Geometry.Rectangle([0, 0, 10, 10], crs, False))) | python | def constant_image_value(image, crs='EPSG:32613', scale=1):
"""Extract the output value from a calculation done with constant images"""
return getinfo(ee.Image(image).reduceRegion(
reducer=ee.Reducer.first(), scale=scale,
geometry=ee.Geometry.Rectangle([0, 0, 10, 10], crs, False))) | [
"def",
"constant_image_value",
"(",
"image",
",",
"crs",
"=",
"'EPSG:32613'",
",",
"scale",
"=",
"1",
")",
":",
"return",
"getinfo",
"(",
"ee",
".",
"Image",
"(",
"image",
")",
".",
"reduceRegion",
"(",
"reducer",
"=",
"ee",
".",
"Reducer",
".",
"first... | Extract the output value from a calculation done with constant images | [
"Extract",
"the",
"output",
"value",
"from",
"a",
"calculation",
"done",
"with",
"constant",
"images"
] | f2b81ccf87bf7e7fe1b9f3dd1d4081d0ec7852db | https://github.com/Open-ET/openet-core-beta/blob/f2b81ccf87bf7e7fe1b9f3dd1d4081d0ec7852db/openet/core/utils.py#L33-L37 | train |
Open-ET/openet-core-beta | openet/core/utils.py | date_0utc | def date_0utc(date):
"""Get the 0 UTC date for a date
Parameters
----------
date : ee.Date
Returns
-------
ee.Date
"""
return ee.Date.fromYMD(date.get('year'), date.get('month'),
date.get('day')) | python | def date_0utc(date):
"""Get the 0 UTC date for a date
Parameters
----------
date : ee.Date
Returns
-------
ee.Date
"""
return ee.Date.fromYMD(date.get('year'), date.get('month'),
date.get('day')) | [
"def",
"date_0utc",
"(",
"date",
")",
":",
"return",
"ee",
".",
"Date",
".",
"fromYMD",
"(",
"date",
".",
"get",
"(",
"'year'",
")",
",",
"date",
".",
"get",
"(",
"'month'",
")",
",",
"date",
".",
"get",
"(",
"'day'",
")",
")"
] | Get the 0 UTC date for a date
Parameters
----------
date : ee.Date
Returns
-------
ee.Date | [
"Get",
"the",
"0",
"UTC",
"date",
"for",
"a",
"date"
] | f2b81ccf87bf7e7fe1b9f3dd1d4081d0ec7852db | https://github.com/Open-ET/openet-core-beta/blob/f2b81ccf87bf7e7fe1b9f3dd1d4081d0ec7852db/openet/core/utils.py#L82-L95 | train |
EVEprosper/ProsperCommon | prosper/common/prosper_version.py | get_version | def get_version(
here_path,
default_version=DEFAULT_VERSION,
):
"""tries to resolve version number
Args:
here_path (str): path to project local dir
default_version (str): what version to return if all else fails
Returns:
str: semantic_version information for library... | python | def get_version(
here_path,
default_version=DEFAULT_VERSION,
):
"""tries to resolve version number
Args:
here_path (str): path to project local dir
default_version (str): what version to return if all else fails
Returns:
str: semantic_version information for library... | [
"def",
"get_version",
"(",
"here_path",
",",
"default_version",
"=",
"DEFAULT_VERSION",
",",
")",
":",
"if",
"'site-packages'",
"in",
"here_path",
":",
"# Running as dependency",
"return",
"_version_from_file",
"(",
"here_path",
")",
"if",
"os",
".",
"environ",
".... | tries to resolve version number
Args:
here_path (str): path to project local dir
default_version (str): what version to return if all else fails
Returns:
str: semantic_version information for library | [
"tries",
"to",
"resolve",
"version",
"number"
] | bcada3b25420099e1f204db8d55eb268e7b4dc27 | https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_version.py#L18-L57 | train |
EVEprosper/ProsperCommon | prosper/common/prosper_version.py | _read_git_tags | def _read_git_tags(
default_version=DEFAULT_VERSION,
git_command=('git', 'tag'),
):
"""tries to find current git tag
Notes:
git_command exposed for testing null case
Args:
default_version (str): what version to make
git_command (:obj:`list`): subprocess command
... | python | def _read_git_tags(
default_version=DEFAULT_VERSION,
git_command=('git', 'tag'),
):
"""tries to find current git tag
Notes:
git_command exposed for testing null case
Args:
default_version (str): what version to make
git_command (:obj:`list`): subprocess command
... | [
"def",
"_read_git_tags",
"(",
"default_version",
"=",
"DEFAULT_VERSION",
",",
"git_command",
"=",
"(",
"'git'",
",",
"'tag'",
")",
",",
")",
":",
"try",
":",
"current_tags",
"=",
"check_output",
"(",
"git_command",
")",
".",
"splitlines",
"(",
")",
"except",... | tries to find current git tag
Notes:
git_command exposed for testing null case
Args:
default_version (str): what version to make
git_command (:obj:`list`): subprocess command
Retruns:
str: latest version found, or default
Warns:
exceptions.ProsperDefaultVersio... | [
"tries",
"to",
"find",
"current",
"git",
"tag"
] | bcada3b25420099e1f204db8d55eb268e7b4dc27 | https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_version.py#L59-L101 | train |
EVEprosper/ProsperCommon | prosper/common/prosper_version.py | _version_from_file | def _version_from_file(
path_to_version,
default_version=DEFAULT_VERSION,
):
"""for PyPI installed versions, just get data from file
Args:
path_to_version (str): abspath to dir where version.txt exists
default_version (str): fallback version in case of error
Returns:
... | python | def _version_from_file(
path_to_version,
default_version=DEFAULT_VERSION,
):
"""for PyPI installed versions, just get data from file
Args:
path_to_version (str): abspath to dir where version.txt exists
default_version (str): fallback version in case of error
Returns:
... | [
"def",
"_version_from_file",
"(",
"path_to_version",
",",
"default_version",
"=",
"DEFAULT_VERSION",
",",
")",
":",
"version_filepath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path_to_version",
",",
"'version.txt'",
")",
"if",
"not",
"os",
".",
"path",
".",... | for PyPI installed versions, just get data from file
Args:
path_to_version (str): abspath to dir where version.txt exists
default_version (str): fallback version in case of error
Returns:
str: current working version | [
"for",
"PyPI",
"installed",
"versions",
"just",
"get",
"data",
"from",
"file"
] | bcada3b25420099e1f204db8d55eb268e7b4dc27 | https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_version.py#L103-L127 | train |
EVEprosper/ProsperCommon | prosper/common/prosper_logging.py | ProsperLogger._configure_common | def _configure_common(
self,
prefix,
fallback_level,
fallback_format,
handler_name,
handler,
custom_args=''
):
"""commom configuration code
Args:
prefix (str): A prefix for the `log_level` and `log_forma... | python | def _configure_common(
self,
prefix,
fallback_level,
fallback_format,
handler_name,
handler,
custom_args=''
):
"""commom configuration code
Args:
prefix (str): A prefix for the `log_level` and `log_forma... | [
"def",
"_configure_common",
"(",
"self",
",",
"prefix",
",",
"fallback_level",
",",
"fallback_format",
",",
"handler_name",
",",
"handler",
",",
"custom_args",
"=",
"''",
")",
":",
"## Retrieve settings from config ##",
"log_level",
"=",
"self",
".",
"config",
"."... | commom configuration code
Args:
prefix (str): A prefix for the `log_level` and `log_format` keys to use with the config. #FIXME: Hacky, add separate sections for each logger config?
fallback_level (str): Fallback/minimum log level, for if config does not have one.
fallback_f... | [
"commom",
"configuration",
"code"
] | bcada3b25420099e1f204db8d55eb268e7b4dc27 | https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_logging.py#L126-L168 | train |
EVEprosper/ProsperCommon | prosper/common/prosper_logging.py | ProsperLogger.configure_default_logger | def configure_default_logger(
self,
log_freq='midnight',
log_total=30,
log_level='INFO',
log_format=ReportingFormats.DEFAULT.value,
custom_args=''
):
"""default logger that every Prosper script should use!!
Args:
lo... | python | def configure_default_logger(
self,
log_freq='midnight',
log_total=30,
log_level='INFO',
log_format=ReportingFormats.DEFAULT.value,
custom_args=''
):
"""default logger that every Prosper script should use!!
Args:
lo... | [
"def",
"configure_default_logger",
"(",
"self",
",",
"log_freq",
"=",
"'midnight'",
",",
"log_total",
"=",
"30",
",",
"log_level",
"=",
"'INFO'",
",",
"log_format",
"=",
"ReportingFormats",
".",
"DEFAULT",
".",
"value",
",",
"custom_args",
"=",
"''",
")",
":... | default logger that every Prosper script should use!!
Args:
log_freq (str): TimedRotatingFileHandle_str -- https://docs.python.org/3/library/logging.handlers.html#timedrotatingfilehandler
log_total (int): how many log_freq periods between log rotations
log_level (str): minim... | [
"default",
"logger",
"that",
"every",
"Prosper",
"script",
"should",
"use!!"
] | bcada3b25420099e1f204db8d55eb268e7b4dc27 | https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_logging.py#L170-L215 | train |
EVEprosper/ProsperCommon | prosper/common/prosper_logging.py | ProsperLogger.configure_discord_logger | def configure_discord_logger(
self,
discord_webhook=None,
discord_recipient=None,
log_level='ERROR',
log_format=ReportingFormats.PRETTY_PRINT.value,
custom_args=''
):
"""logger for sending messages to Discord. Easy way to alert humans ... | python | def configure_discord_logger(
self,
discord_webhook=None,
discord_recipient=None,
log_level='ERROR',
log_format=ReportingFormats.PRETTY_PRINT.value,
custom_args=''
):
"""logger for sending messages to Discord. Easy way to alert humans ... | [
"def",
"configure_discord_logger",
"(",
"self",
",",
"discord_webhook",
"=",
"None",
",",
"discord_recipient",
"=",
"None",
",",
"log_level",
"=",
"'ERROR'",
",",
"log_format",
"=",
"ReportingFormats",
".",
"PRETTY_PRINT",
".",
"value",
",",
"custom_args",
"=",
... | logger for sending messages to Discord. Easy way to alert humans of issues
Note:
Will try to overwrite minimum log level to enable requested log_level
Will warn and not attach hipchat logger if missing webhook key
Learn more about webhooks: https://support.discordapp.com/hc... | [
"logger",
"for",
"sending",
"messages",
"to",
"Discord",
".",
"Easy",
"way",
"to",
"alert",
"humans",
"of",
"issues"
] | bcada3b25420099e1f204db8d55eb268e7b4dc27 | https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_logging.py#L243-L302 | train |
EVEprosper/ProsperCommon | prosper/common/prosper_logging.py | ProsperLogger.configure_slack_logger | def configure_slack_logger(
self,
slack_webhook=None,
log_level='ERROR',
log_format=ReportingFormats.SLACK_PRINT.value,
custom_args=''
):
"""logger for sending messages to Slack. Easy way to alert humans of issues
Note:
Will t... | python | def configure_slack_logger(
self,
slack_webhook=None,
log_level='ERROR',
log_format=ReportingFormats.SLACK_PRINT.value,
custom_args=''
):
"""logger for sending messages to Slack. Easy way to alert humans of issues
Note:
Will t... | [
"def",
"configure_slack_logger",
"(",
"self",
",",
"slack_webhook",
"=",
"None",
",",
"log_level",
"=",
"'ERROR'",
",",
"log_format",
"=",
"ReportingFormats",
".",
"SLACK_PRINT",
".",
"value",
",",
"custom_args",
"=",
"''",
")",
":",
"# Override defaults if requir... | logger for sending messages to Slack. Easy way to alert humans of issues
Note:
Will try to overwrite minimum log level to enable requested log_level
Will warn and not attach hipchat logger if missing webhook key
Learn more about webhooks: https://api.slack.com/docs/message-... | [
"logger",
"for",
"sending",
"messages",
"to",
"Slack",
".",
"Easy",
"way",
"to",
"alert",
"humans",
"of",
"issues"
] | bcada3b25420099e1f204db8d55eb268e7b4dc27 | https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_logging.py#L305-L347 | train |
EVEprosper/ProsperCommon | prosper/common/prosper_logging.py | ProsperLogger.configure_hipchat_logger | def configure_hipchat_logger(
self,
hipchat_webhook=None,
log_level='ERROR',
log_format=ReportingFormats.PRETTY_PRINT.value,
custom_args=''
):
"""logger for sending messages to HipChat. Easy way to alert humans of issues
Note:
... | python | def configure_hipchat_logger(
self,
hipchat_webhook=None,
log_level='ERROR',
log_format=ReportingFormats.PRETTY_PRINT.value,
custom_args=''
):
"""logger for sending messages to HipChat. Easy way to alert humans of issues
Note:
... | [
"def",
"configure_hipchat_logger",
"(",
"self",
",",
"hipchat_webhook",
"=",
"None",
",",
"log_level",
"=",
"'ERROR'",
",",
"log_format",
"=",
"ReportingFormats",
".",
"PRETTY_PRINT",
".",
"value",
",",
"custom_args",
"=",
"''",
")",
":",
"# Override defaults if r... | logger for sending messages to HipChat. Easy way to alert humans of issues
Note:
Will try to overwrite minimum log level to enable requested log_level
Will warn and not attach hipchat logger if missing webhook key
Learn more about webhooks: https://yak.crowdstrike.com/addon... | [
"logger",
"for",
"sending",
"messages",
"to",
"HipChat",
".",
"Easy",
"way",
"to",
"alert",
"humans",
"of",
"issues"
] | bcada3b25420099e1f204db8d55eb268e7b4dc27 | https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_logging.py#L350-L395 | train |
EVEprosper/ProsperCommon | prosper/common/prosper_logging.py | DiscordWebhook.webhook | def webhook(self, webhook_url):
"""Load object with webhook_url
Args:
webhook_url (str): full webhook url given by Discord 'create webhook' func
"""
if not webhook_url:
raise Exception('Url can not be None')
matcher = re.match(self.__webhook_url_format,... | python | def webhook(self, webhook_url):
"""Load object with webhook_url
Args:
webhook_url (str): full webhook url given by Discord 'create webhook' func
"""
if not webhook_url:
raise Exception('Url can not be None')
matcher = re.match(self.__webhook_url_format,... | [
"def",
"webhook",
"(",
"self",
",",
"webhook_url",
")",
":",
"if",
"not",
"webhook_url",
":",
"raise",
"Exception",
"(",
"'Url can not be None'",
")",
"matcher",
"=",
"re",
".",
"match",
"(",
"self",
".",
"__webhook_url_format",
",",
"webhook_url",
")",
"if"... | Load object with webhook_url
Args:
webhook_url (str): full webhook url given by Discord 'create webhook' func | [
"Load",
"object",
"with",
"webhook_url"
] | bcada3b25420099e1f204db8d55eb268e7b4dc27 | https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_logging.py#L472-L486 | train |
EVEprosper/ProsperCommon | prosper/common/prosper_logging.py | HackyDiscordHandler.emit | def emit(self, record): # pragma: no cover
"""required classmethod for logging to execute logging message"""
if record.exc_text:
record.exc_text = '```python\n{0}\n```'.format(record.exc_text) # recast to code block
log_msg = self.format(record)
if len(log_msg) + self.alert_... | python | def emit(self, record): # pragma: no cover
"""required classmethod for logging to execute logging message"""
if record.exc_text:
record.exc_text = '```python\n{0}\n```'.format(record.exc_text) # recast to code block
log_msg = self.format(record)
if len(log_msg) + self.alert_... | [
"def",
"emit",
"(",
"self",
",",
"record",
")",
":",
"# pragma: no cover",
"if",
"record",
".",
"exc_text",
":",
"record",
".",
"exc_text",
"=",
"'```python\\n{0}\\n```'",
".",
"format",
"(",
"record",
".",
"exc_text",
")",
"# recast to code block",
"log_msg",
... | required classmethod for logging to execute logging message | [
"required",
"classmethod",
"for",
"logging",
"to",
"execute",
"logging",
"message"
] | bcada3b25420099e1f204db8d55eb268e7b4dc27 | https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_logging.py#L546-L557 | train |
EVEprosper/ProsperCommon | prosper/common/prosper_logging.py | HackyDiscordHandler.send_msg_to_webhook | def send_msg_to_webhook(self, message):
"""separated Requests logic for easier testing
Args:
message (str): actual logging string to be passed to REST endpoint
Todo:
* Requests.text/json return for better testing options
"""
payload = {
'cont... | python | def send_msg_to_webhook(self, message):
"""separated Requests logic for easier testing
Args:
message (str): actual logging string to be passed to REST endpoint
Todo:
* Requests.text/json return for better testing options
"""
payload = {
'cont... | [
"def",
"send_msg_to_webhook",
"(",
"self",
",",
"message",
")",
":",
"payload",
"=",
"{",
"'content'",
":",
"message",
"}",
"header",
"=",
"{",
"'Content-Type'",
":",
"'application/json'",
"}",
"try",
":",
"request",
"=",
"requests",
".",
"post",
"(",
"sel... | separated Requests logic for easier testing
Args:
message (str): actual logging string to be passed to REST endpoint
Todo:
* Requests.text/json return for better testing options | [
"separated",
"Requests",
"logic",
"for",
"easier",
"testing"
] | bcada3b25420099e1f204db8d55eb268e7b4dc27 | https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_logging.py#L559-L592 | train |
EVEprosper/ProsperCommon | prosper/common/prosper_logging.py | HackySlackHandler.decorate | def decorate(self, record):
"""add slack-specific flourishes to responses
https://api.slack.com/docs/message-attachments
Args:
record (:obj:`logging.record`): message to log
Returns:
(:obj:`dict`): attachments object for reporting
"""
attachmen... | python | def decorate(self, record):
"""add slack-specific flourishes to responses
https://api.slack.com/docs/message-attachments
Args:
record (:obj:`logging.record`): message to log
Returns:
(:obj:`dict`): attachments object for reporting
"""
attachmen... | [
"def",
"decorate",
"(",
"self",
",",
"record",
")",
":",
"attachments",
"=",
"{",
"}",
"## Set color",
"if",
"record",
".",
"levelno",
">=",
"logging",
".",
"ERROR",
":",
"attachments",
"[",
"'color'",
"]",
"=",
"'warning'",
"#builtin",
"if",
"record",
"... | add slack-specific flourishes to responses
https://api.slack.com/docs/message-attachments
Args:
record (:obj:`logging.record`): message to log
Returns:
(:obj:`dict`): attachments object for reporting | [
"add",
"slack",
"-",
"specific",
"flourishes",
"to",
"responses"
] | bcada3b25420099e1f204db8d55eb268e7b4dc27 | https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_logging.py#L616-L645 | train |
EVEprosper/ProsperCommon | prosper/common/prosper_logging.py | HackySlackHandler.send_msg_to_webhook | def send_msg_to_webhook(self, json_payload, log_msg):
"""push message out to webhook
Args:
json_payload (:obj:`dict`): preformatted payload a la https://api.slack.com/docs/message-attachments
log_msg (str): actual log message
"""
if SILENCE_OVERRIDE: # pragma: ... | python | def send_msg_to_webhook(self, json_payload, log_msg):
"""push message out to webhook
Args:
json_payload (:obj:`dict`): preformatted payload a la https://api.slack.com/docs/message-attachments
log_msg (str): actual log message
"""
if SILENCE_OVERRIDE: # pragma: ... | [
"def",
"send_msg_to_webhook",
"(",
"self",
",",
"json_payload",
",",
"log_msg",
")",
":",
"if",
"SILENCE_OVERRIDE",
":",
"# pragma: no cover",
"return",
"payload",
"=",
"{",
"'text'",
":",
"log_msg",
",",
"'attachments'",
":",
"[",
"json_payload",
"]",
"}",
"h... | push message out to webhook
Args:
json_payload (:obj:`dict`): preformatted payload a la https://api.slack.com/docs/message-attachments
log_msg (str): actual log message | [
"push",
"message",
"out",
"to",
"webhook"
] | bcada3b25420099e1f204db8d55eb268e7b4dc27 | https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_logging.py#L647-L682 | train |
EVEprosper/ProsperCommon | prosper/common/prosper_logging.py | HackyHipChatHandler.decorate | def decorate(self, record):
"""Build up HipChat specific values for log record
Args:
record (:obj:`logging.record`): log message object
Returns:
dict: params for POST request
"""
color = 'gray'
if record.levelno == logging.WARNING:
c... | python | def decorate(self, record):
"""Build up HipChat specific values for log record
Args:
record (:obj:`logging.record`): log message object
Returns:
dict: params for POST request
"""
color = 'gray'
if record.levelno == logging.WARNING:
c... | [
"def",
"decorate",
"(",
"self",
",",
"record",
")",
":",
"color",
"=",
"'gray'",
"if",
"record",
".",
"levelno",
"==",
"logging",
".",
"WARNING",
":",
"color",
"=",
"'yellow'",
"if",
"record",
".",
"levelno",
"==",
"logging",
".",
"INFO",
":",
"color",... | Build up HipChat specific values for log record
Args:
record (:obj:`logging.record`): log message object
Returns:
dict: params for POST request | [
"Build",
"up",
"HipChat",
"specific",
"values",
"for",
"log",
"record"
] | bcada3b25420099e1f204db8d55eb268e7b4dc27 | https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_logging.py#L691-L721 | train |
CenturyLinkCloud/clc-python-sdk | src/clc/APIv1/network.py | Network.GetNetworks | def GetNetworks(alias=None,location=None):
"""Gets the list of Networks mapped to the account in the specified datacenter.
https://t3n.zendesk.com/entries/21024721-Get-Networks
:param alias: short code for a particular account. If none will use account's default alias
:param location: datacenter where group ... | python | def GetNetworks(alias=None,location=None):
"""Gets the list of Networks mapped to the account in the specified datacenter.
https://t3n.zendesk.com/entries/21024721-Get-Networks
:param alias: short code for a particular account. If none will use account's default alias
:param location: datacenter where group ... | [
"def",
"GetNetworks",
"(",
"alias",
"=",
"None",
",",
"location",
"=",
"None",
")",
":",
"if",
"alias",
"is",
"None",
":",
"alias",
"=",
"clc",
".",
"v1",
".",
"Account",
".",
"GetAlias",
"(",
")",
"if",
"location",
"is",
"None",
":",
"location",
"... | Gets the list of Networks mapped to the account in the specified datacenter.
https://t3n.zendesk.com/entries/21024721-Get-Networks
:param alias: short code for a particular account. If none will use account's default alias
:param location: datacenter where group resides. If none will use account's primary dat... | [
"Gets",
"the",
"list",
"of",
"Networks",
"mapped",
"to",
"the",
"account",
"in",
"the",
"specified",
"datacenter",
"."
] | f4dba40c627cb08dd4b7d0d277e8d67578010b05 | https://github.com/CenturyLinkCloud/clc-python-sdk/blob/f4dba40c627cb08dd4b7d0d277e8d67578010b05/src/clc/APIv1/network.py#L15-L26 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.