repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
Mollom/mollom_python
mollom/mollom.py
Mollom.get_blacklist_entry
def get_blacklist_entry(self, blacklist_entry_id): """Get a single blacklist entry Keyword arguments: blacklist_entry_id -- The unique identifier of the blacklist entry to get. """ get_blacklist_entries_endpoint = Template("${rest_root}/blacklist/${public_key}/${blacklist_entry_...
python
def get_blacklist_entry(self, blacklist_entry_id): """Get a single blacklist entry Keyword arguments: blacklist_entry_id -- The unique identifier of the blacklist entry to get. """ get_blacklist_entries_endpoint = Template("${rest_root}/blacklist/${public_key}/${blacklist_entry_...
[ "def", "get_blacklist_entry", "(", "self", ",", "blacklist_entry_id", ")", ":", "get_blacklist_entries_endpoint", "=", "Template", "(", "\"${rest_root}/blacklist/${public_key}/${blacklist_entry_id}\"", ")", "url", "=", "get_blacklist_entries_endpoint", ".", "substitute", "(", ...
Get a single blacklist entry Keyword arguments: blacklist_entry_id -- The unique identifier of the blacklist entry to get.
[ "Get", "a", "single", "blacklist", "entry" ]
train
https://github.com/Mollom/mollom_python/blob/dfacb63fd79f82c0eabde76b511116df5b51d6f1/mollom/mollom.py#L359-L369
jut-io/jut-python-tools
jut/api/deployments.py
create_deployment
def create_deployment(deployment_name, token_manager=None, app_url=defaults.APP_URL): """ create a deployment with the specified name """ headers = token_manager.get_access_token_headers() payload = { 'name': deployment_name, 'isAdmin': T...
python
def create_deployment(deployment_name, token_manager=None, app_url=defaults.APP_URL): """ create a deployment with the specified name """ headers = token_manager.get_access_token_headers() payload = { 'name': deployment_name, 'isAdmin': T...
[ "def", "create_deployment", "(", "deployment_name", ",", "token_manager", "=", "None", ",", "app_url", "=", "defaults", ".", "APP_URL", ")", ":", "headers", "=", "token_manager", ".", "get_access_token_headers", "(", ")", "payload", "=", "{", "'name'", ":", "d...
create a deployment with the specified name
[ "create", "a", "deployment", "with", "the", "specified", "name" ]
train
https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/api/deployments.py#L16-L39
jut-io/jut-python-tools
jut/api/deployments.py
get_deployments
def get_deployments(token_manager=None, app_url=defaults.APP_URL): """ return the list of deployments that the current access_token gives you access to """ headers = token_manager.get_access_token_headers() deployment_url = environment.get_deployment_url(app_url=app_url) ...
python
def get_deployments(token_manager=None, app_url=defaults.APP_URL): """ return the list of deployments that the current access_token gives you access to """ headers = token_manager.get_access_token_headers() deployment_url = environment.get_deployment_url(app_url=app_url) ...
[ "def", "get_deployments", "(", "token_manager", "=", "None", ",", "app_url", "=", "defaults", ".", "APP_URL", ")", ":", "headers", "=", "token_manager", ".", "get_access_token_headers", "(", ")", "deployment_url", "=", "environment", ".", "get_deployment_url", "("...
return the list of deployments that the current access_token gives you access to
[ "return", "the", "list", "of", "deployments", "that", "the", "current", "access_token", "gives", "you", "access", "to" ]
train
https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/api/deployments.py#L42-L57
jut-io/jut-python-tools
jut/api/deployments.py
get_deployment_id
def get_deployment_id(deployment_name, token_manager=None, app_url=defaults.APP_URL): """ return the deployment id for the deployment with the specified name """ headers = token_manager.get_access_token_headers() deployment_url = environment.get_deployme...
python
def get_deployment_id(deployment_name, token_manager=None, app_url=defaults.APP_URL): """ return the deployment id for the deployment with the specified name """ headers = token_manager.get_access_token_headers() deployment_url = environment.get_deployme...
[ "def", "get_deployment_id", "(", "deployment_name", ",", "token_manager", "=", "None", ",", "app_url", "=", "defaults", ".", "APP_URL", ")", ":", "headers", "=", "token_manager", ".", "get_access_token_headers", "(", ")", "deployment_url", "=", "environment", ".",...
return the deployment id for the deployment with the specified name
[ "return", "the", "deployment", "id", "for", "the", "deployment", "with", "the", "specified", "name" ]
train
https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/api/deployments.py#L60-L82
jut-io/jut-python-tools
jut/api/deployments.py
get_space_id
def get_space_id(deployment_name, space_name, token_manager=None, app_url=defaults.APP_URL): """ get the space id that relates to the space name provided """ spaces = get_spaces(deployment_name, token_manager=token_manager, ...
python
def get_space_id(deployment_name, space_name, token_manager=None, app_url=defaults.APP_URL): """ get the space id that relates to the space name provided """ spaces = get_spaces(deployment_name, token_manager=token_manager, ...
[ "def", "get_space_id", "(", "deployment_name", ",", "space_name", ",", "token_manager", "=", "None", ",", "app_url", "=", "defaults", ".", "APP_URL", ")", ":", "spaces", "=", "get_spaces", "(", "deployment_name", ",", "token_manager", "=", "token_manager", ",", ...
get the space id that relates to the space name provided
[ "get", "the", "space", "id", "that", "relates", "to", "the", "space", "name", "provided" ]
train
https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/api/deployments.py#L153-L170
jut-io/jut-python-tools
jut/api/deployments.py
create_space
def create_space(deployment_name, space_name, security_policy='public', events_retention_days=0, metrics_retention_days=0, token_manager=None, app_url=defaults.APP_URL): """ create a space within the deployment...
python
def create_space(deployment_name, space_name, security_policy='public', events_retention_days=0, metrics_retention_days=0, token_manager=None, app_url=defaults.APP_URL): """ create a space within the deployment...
[ "def", "create_space", "(", "deployment_name", ",", "space_name", ",", "security_policy", "=", "'public'", ",", "events_retention_days", "=", "0", ",", "metrics_retention_days", "=", "0", ",", "token_manager", "=", "None", ",", "app_url", "=", "defaults", ".", "...
create a space within the deployment specified and with the various rentention values set
[ "create", "a", "space", "within", "the", "deployment", "specified", "and", "with", "the", "various", "rentention", "values", "set" ]
train
https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/api/deployments.py#L173-L206
jut-io/jut-python-tools
jut/api/deployments.py
get_users
def get_users(deployment_name, token_manager=None, app_url=defaults.APP_URL): """ get all users in the deployment specified """ deployment_id = get_deployment_id(deployment_name, token_manager=token_manager, ...
python
def get_users(deployment_name, token_manager=None, app_url=defaults.APP_URL): """ get all users in the deployment specified """ deployment_id = get_deployment_id(deployment_name, token_manager=token_manager, ...
[ "def", "get_users", "(", "deployment_name", ",", "token_manager", "=", "None", ",", "app_url", "=", "defaults", ".", "APP_URL", ")", ":", "deployment_id", "=", "get_deployment_id", "(", "deployment_name", ",", "token_manager", "=", "token_manager", ",", "app_url",...
get all users in the deployment specified
[ "get", "all", "users", "in", "the", "deployment", "specified" ]
train
https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/api/deployments.py#L253-L273
jut-io/jut-python-tools
jut/api/deployments.py
add_user
def add_user(username, deployment_name, token_manager=None, app_url=defaults.APP_URL): """ add user to deployment """ deployment_id = get_deployment_id(deployment_name, token_manager=token_manager, ...
python
def add_user(username, deployment_name, token_manager=None, app_url=defaults.APP_URL): """ add user to deployment """ deployment_id = get_deployment_id(deployment_name, token_manager=token_manager, ...
[ "def", "add_user", "(", "username", ",", "deployment_name", ",", "token_manager", "=", "None", ",", "app_url", "=", "defaults", ".", "APP_URL", ")", ":", "deployment_id", "=", "get_deployment_id", "(", "deployment_name", ",", "token_manager", "=", "token_manager",...
add user to deployment
[ "add", "user", "to", "deployment" ]
train
https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/api/deployments.py#L276-L301
20tab/twentytab-tree
tree/menu.py
Menu.as_ul
def as_ul(self, current_linkable=False, class_current="active_link", before_1="", after_1="", before_all="", after_all=""): """ It returns menu as ul """ return self.__do_menu("as_ul", current_linkable, class_current, before_1=before_1, after_1...
python
def as_ul(self, current_linkable=False, class_current="active_link", before_1="", after_1="", before_all="", after_all=""): """ It returns menu as ul """ return self.__do_menu("as_ul", current_linkable, class_current, before_1=before_1, after_1...
[ "def", "as_ul", "(", "self", ",", "current_linkable", "=", "False", ",", "class_current", "=", "\"active_link\"", ",", "before_1", "=", "\"\"", ",", "after_1", "=", "\"\"", ",", "before_all", "=", "\"\"", ",", "after_all", "=", "\"\"", ")", ":", "return", ...
It returns menu as ul
[ "It", "returns", "menu", "as", "ul" ]
train
https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/menu.py#L68-L74
20tab/twentytab-tree
tree/menu.py
Menu.as_string
def as_string(self, chars, current_linkable=False, class_current="active_link"): """ It returns menu as string """ return self.__do_menu("as_string", current_linkable, class_current, chars)
python
def as_string(self, chars, current_linkable=False, class_current="active_link"): """ It returns menu as string """ return self.__do_menu("as_string", current_linkable, class_current, chars)
[ "def", "as_string", "(", "self", ",", "chars", ",", "current_linkable", "=", "False", ",", "class_current", "=", "\"active_link\"", ")", ":", "return", "self", ".", "__do_menu", "(", "\"as_string\"", ",", "current_linkable", ",", "class_current", ",", "chars", ...
It returns menu as string
[ "It", "returns", "menu", "as", "string" ]
train
https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/menu.py#L82-L86
20tab/twentytab-tree
tree/menu.py
Breadcrumb.as_ul
def as_ul(self, show_leaf=True, current_linkable=False, class_current="active_link"): """ It returns breadcrumb as ul """ return self.__do_menu("as_ul", show_leaf, current_linkable, class_current)
python
def as_ul(self, show_leaf=True, current_linkable=False, class_current="active_link"): """ It returns breadcrumb as ul """ return self.__do_menu("as_ul", show_leaf, current_linkable, class_current)
[ "def", "as_ul", "(", "self", ",", "show_leaf", "=", "True", ",", "current_linkable", "=", "False", ",", "class_current", "=", "\"active_link\"", ")", ":", "return", "self", ".", "__do_menu", "(", "\"as_ul\"", ",", "show_leaf", ",", "current_linkable", ",", "...
It returns breadcrumb as ul
[ "It", "returns", "breadcrumb", "as", "ul" ]
train
https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/menu.py#L132-L136
20tab/twentytab-tree
tree/menu.py
Breadcrumb.as_p
def as_p(self, show_leaf=True, current_linkable=False, class_current="active_link"): """ It returns breadcrumb as p """ return self.__do_menu("as_p", show_leaf, current_linkable, class_current)
python
def as_p(self, show_leaf=True, current_linkable=False, class_current="active_link"): """ It returns breadcrumb as p """ return self.__do_menu("as_p", show_leaf, current_linkable, class_current)
[ "def", "as_p", "(", "self", ",", "show_leaf", "=", "True", ",", "current_linkable", "=", "False", ",", "class_current", "=", "\"active_link\"", ")", ":", "return", "self", ".", "__do_menu", "(", "\"as_p\"", ",", "show_leaf", ",", "current_linkable", ",", "cl...
It returns breadcrumb as p
[ "It", "returns", "breadcrumb", "as", "p" ]
train
https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/menu.py#L138-L142
20tab/twentytab-tree
tree/menu.py
Breadcrumb.as_string
def as_string(self, chars, show_leaf=True, current_linkable=False, class_current="active_link"): """ It returns breadcrumb as string """ return self.__do_menu("as_string", show_leaf, current_linkable, class_current, chars)
python
def as_string(self, chars, show_leaf=True, current_linkable=False, class_current="active_link"): """ It returns breadcrumb as string """ return self.__do_menu("as_string", show_leaf, current_linkable, class_current, chars)
[ "def", "as_string", "(", "self", ",", "chars", ",", "show_leaf", "=", "True", ",", "current_linkable", "=", "False", ",", "class_current", "=", "\"active_link\"", ")", ":", "return", "self", ".", "__do_menu", "(", "\"as_string\"", ",", "show_leaf", ",", "cur...
It returns breadcrumb as string
[ "It", "returns", "breadcrumb", "as", "string" ]
train
https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/menu.py#L144-L148
lehins/python-wepay
wepay/calls/base.py
Call.make_call
def make_call(self, func, params, extra_kwargs): """This is a helper function that checks the validity of ``params`` dictionary by matching it with ``allowed_params`` of a ``func`` attribute, and then performs a call. Will issue a ``wepay.exceptions.WePayWarning`` in case of unrecognize...
python
def make_call(self, func, params, extra_kwargs): """This is a helper function that checks the validity of ``params`` dictionary by matching it with ``allowed_params`` of a ``func`` attribute, and then performs a call. Will issue a ``wepay.exceptions.WePayWarning`` in case of unrecognize...
[ "def", "make_call", "(", "self", ",", "func", ",", "params", ",", "extra_kwargs", ")", ":", "if", "hasattr", "(", "func", ",", "'__name__'", ")", ":", "uri", "=", "'/%s/%s'", "%", "(", "self", ".", "call_name", ",", "func", ".", "__name__", "[", "2",...
This is a helper function that checks the validity of ``params`` dictionary by matching it with ``allowed_params`` of a ``func`` attribute, and then performs a call. Will issue a ``wepay.exceptions.WePayWarning`` in case of unrecognized parameter, and raise a `WePayError` after making a...
[ "This", "is", "a", "helper", "function", "that", "checks", "the", "validity", "of", "params", "dictionary", "by", "matching", "it", "with", "allowed_params", "of", "a", "func", "attribute", "and", "then", "performs", "a", "call", ".", "Will", "issue", "a", ...
train
https://github.com/lehins/python-wepay/blob/414d25a1a8d0ecb22a3ddd1f16c60b805bb52a1f/wepay/calls/base.py#L35-L92
xtrementl/focus
focus/parser/__init__.py
parse_config
def parse_config(filename, header): """ Parses the provided filename and returns ``SettingParser`` if the parsing was successful and header matches the header defined in the file. Returns ``SettingParser`` instance. * Raises a ``ParseError`` exception if header doesn't match or par...
python
def parse_config(filename, header): """ Parses the provided filename and returns ``SettingParser`` if the parsing was successful and header matches the header defined in the file. Returns ``SettingParser`` instance. * Raises a ``ParseError`` exception if header doesn't match or par...
[ "def", "parse_config", "(", "filename", ",", "header", ")", ":", "parser", "=", "SettingParser", "(", "filename", ")", "if", "parser", ".", "header", "!=", "header", ":", "header_value", "=", "parser", ".", "header", "or", "''", "raise", "ParseError", "(",...
Parses the provided filename and returns ``SettingParser`` if the parsing was successful and header matches the header defined in the file. Returns ``SettingParser`` instance. * Raises a ``ParseError`` exception if header doesn't match or parsing fails.
[ "Parses", "the", "provided", "filename", "and", "returns", "SettingParser", "if", "the", "parsing", "was", "successful", "and", "header", "matches", "the", "header", "defined", "in", "the", "file", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/parser/__init__.py#L15-L32
Ffisegydd/whatis
whatis/_variable.py
print_variable
def print_variable(obj, **kwargs): """Print the variable out. Limit the string length to, by default, 300 characters.""" variable_print_length = kwargs.get("variable_print_length", 1000) s = str(obj) if len(s) < 300: return "Printing the object:\n" + str(obj) else: return "Printing t...
python
def print_variable(obj, **kwargs): """Print the variable out. Limit the string length to, by default, 300 characters.""" variable_print_length = kwargs.get("variable_print_length", 1000) s = str(obj) if len(s) < 300: return "Printing the object:\n" + str(obj) else: return "Printing t...
[ "def", "print_variable", "(", "obj", ",", "*", "*", "kwargs", ")", ":", "variable_print_length", "=", "kwargs", ".", "get", "(", "\"variable_print_length\"", ",", "1000", ")", "s", "=", "str", "(", "obj", ")", "if", "len", "(", "s", ")", "<", "300", ...
Print the variable out. Limit the string length to, by default, 300 characters.
[ "Print", "the", "variable", "out", ".", "Limit", "the", "string", "length", "to", "by", "default", "300", "characters", "." ]
train
https://github.com/Ffisegydd/whatis/blob/eef780ced61aae6d001aeeef7574e5e27e613583/whatis/_variable.py#L4-L11
appointlet/span
span/__init__.py
Span.lintersects
def lintersects(self, span): """ If this span intersects the left (starting) side of the given span. """ if isinstance(span, list): return [sp for sp in span if self._lintersects(sp)] return self._lintersects(span)
python
def lintersects(self, span): """ If this span intersects the left (starting) side of the given span. """ if isinstance(span, list): return [sp for sp in span if self._lintersects(sp)] return self._lintersects(span)
[ "def", "lintersects", "(", "self", ",", "span", ")", ":", "if", "isinstance", "(", "span", ",", "list", ")", ":", "return", "[", "sp", "for", "sp", "in", "span", "if", "self", ".", "_lintersects", "(", "sp", ")", "]", "return", "self", ".", "_linte...
If this span intersects the left (starting) side of the given span.
[ "If", "this", "span", "intersects", "the", "left", "(", "starting", ")", "side", "of", "the", "given", "span", "." ]
train
https://github.com/appointlet/span/blob/6d4f2920e45df827890ebe55b1c41b1f3414c0c9/span/__init__.py#L16-L23
appointlet/span
span/__init__.py
Span.rintersects
def rintersects(self, span): """ If this span intersects the right (ending) side of the given span. """ if isinstance(span, list): return [sp for sp in span if self._rintersects(sp)] return self._rintersects(span)
python
def rintersects(self, span): """ If this span intersects the right (ending) side of the given span. """ if isinstance(span, list): return [sp for sp in span if self._rintersects(sp)] return self._rintersects(span)
[ "def", "rintersects", "(", "self", ",", "span", ")", ":", "if", "isinstance", "(", "span", ",", "list", ")", ":", "return", "[", "sp", "for", "sp", "in", "span", "if", "self", ".", "_rintersects", "(", "sp", ")", "]", "return", "self", ".", "_rinte...
If this span intersects the right (ending) side of the given span.
[ "If", "this", "span", "intersects", "the", "right", "(", "ending", ")", "side", "of", "the", "given", "span", "." ]
train
https://github.com/appointlet/span/blob/6d4f2920e45df827890ebe55b1c41b1f3414c0c9/span/__init__.py#L27-L34
appointlet/span
span/__init__.py
Span.ltouches
def ltouches(self, span): """ Returns true if the end of this span touches the left (starting) side of the given span. """ if isinstance(span, list): return [sp for sp in span if self._ltouches(sp)] return self._ltouches(span)
python
def ltouches(self, span): """ Returns true if the end of this span touches the left (starting) side of the given span. """ if isinstance(span, list): return [sp for sp in span if self._ltouches(sp)] return self._ltouches(span)
[ "def", "ltouches", "(", "self", ",", "span", ")", ":", "if", "isinstance", "(", "span", ",", "list", ")", ":", "return", "[", "sp", "for", "sp", "in", "span", "if", "self", ".", "_ltouches", "(", "sp", ")", "]", "return", "self", ".", "_ltouches", ...
Returns true if the end of this span touches the left (starting) side of the given span.
[ "Returns", "true", "if", "the", "end", "of", "this", "span", "touches", "the", "left", "(", "starting", ")", "side", "of", "the", "given", "span", "." ]
train
https://github.com/appointlet/span/blob/6d4f2920e45df827890ebe55b1c41b1f3414c0c9/span/__init__.py#L44-L51
appointlet/span
span/__init__.py
Span.rtouches
def rtouches(self, span): """ Returns true if the start of this span touches the right (ending) side of the given span. """ if isinstance(span, list): return [sp for sp in span if self._rtouches(sp)] return self._rtouches(span)
python
def rtouches(self, span): """ Returns true if the start of this span touches the right (ending) side of the given span. """ if isinstance(span, list): return [sp for sp in span if self._rtouches(sp)] return self._rtouches(span)
[ "def", "rtouches", "(", "self", ",", "span", ")", ":", "if", "isinstance", "(", "span", ",", "list", ")", ":", "return", "[", "sp", "for", "sp", "in", "span", "if", "self", ".", "_rtouches", "(", "sp", ")", "]", "return", "self", ".", "_rtouches", ...
Returns true if the start of this span touches the right (ending) side of the given span.
[ "Returns", "true", "if", "the", "start", "of", "this", "span", "touches", "the", "right", "(", "ending", ")", "side", "of", "the", "given", "span", "." ]
train
https://github.com/appointlet/span/blob/6d4f2920e45df827890ebe55b1c41b1f3414c0c9/span/__init__.py#L55-L62
appointlet/span
span/__init__.py
Span.encompasses
def encompasses(self, span): """ Returns true if the given span fits inside this one """ if isinstance(span, list): return [sp for sp in span if self._encompasses(sp)] return self._encompasses(span)
python
def encompasses(self, span): """ Returns true if the given span fits inside this one """ if isinstance(span, list): return [sp for sp in span if self._encompasses(sp)] return self._encompasses(span)
[ "def", "encompasses", "(", "self", ",", "span", ")", ":", "if", "isinstance", "(", "span", ",", "list", ")", ":", "return", "[", "sp", "for", "sp", "in", "span", "if", "self", ".", "_encompasses", "(", "sp", ")", "]", "return", "self", ".", "_encom...
Returns true if the given span fits inside this one
[ "Returns", "true", "if", "the", "given", "span", "fits", "inside", "this", "one" ]
train
https://github.com/appointlet/span/blob/6d4f2920e45df827890ebe55b1c41b1f3414c0c9/span/__init__.py#L66-L73
appointlet/span
span/__init__.py
Span.encompassed_by
def encompassed_by(self, span): """ Returns true if the given span encompasses this span. """ if isinstance(span, list): return [sp for sp in span if sp.encompasses(self)] return span.encompasses(self)
python
def encompassed_by(self, span): """ Returns true if the given span encompasses this span. """ if isinstance(span, list): return [sp for sp in span if sp.encompasses(self)] return span.encompasses(self)
[ "def", "encompassed_by", "(", "self", ",", "span", ")", ":", "if", "isinstance", "(", "span", ",", "list", ")", ":", "return", "[", "sp", "for", "sp", "in", "span", "if", "sp", ".", "encompasses", "(", "self", ")", "]", "return", "span", ".", "enco...
Returns true if the given span encompasses this span.
[ "Returns", "true", "if", "the", "given", "span", "encompasses", "this", "span", "." ]
train
https://github.com/appointlet/span/blob/6d4f2920e45df827890ebe55b1c41b1f3414c0c9/span/__init__.py#L77-L84
udoprog/mimeprovider
mimeprovider/packages/mxml.py
mXml.adds
def adds(self, string): """ Add a string child. """ if isinstance(string, unicode): string = string.encode("utf-8") self.children.append((STRING, str(string)))
python
def adds(self, string): """ Add a string child. """ if isinstance(string, unicode): string = string.encode("utf-8") self.children.append((STRING, str(string)))
[ "def", "adds", "(", "self", ",", "string", ")", ":", "if", "isinstance", "(", "string", ",", "unicode", ")", ":", "string", "=", "string", ".", "encode", "(", "\"utf-8\"", ")", "self", ".", "children", ".", "append", "(", "(", "STRING", ",", "str", ...
Add a string child.
[ "Add", "a", "string", "child", "." ]
train
https://github.com/udoprog/mimeprovider/blob/5acd61eb0ef813b4a2eb6bbe75d07af1e11847a4/mimeprovider/packages/mxml.py#L34-L41
thespacedoctor/qubits
qubits/universe.py
random_redshift_array
def random_redshift_array( log, sampleNumber, lowerRedshiftLimit, upperRedshiftLimit, redshiftResolution, pathToOutputPlotDirectory, plot=False): """ *Generate a NumPy array of random distances given a sample number and distance limit* **Key Arguments...
python
def random_redshift_array( log, sampleNumber, lowerRedshiftLimit, upperRedshiftLimit, redshiftResolution, pathToOutputPlotDirectory, plot=False): """ *Generate a NumPy array of random distances given a sample number and distance limit* **Key Arguments...
[ "def", "random_redshift_array", "(", "log", ",", "sampleNumber", ",", "lowerRedshiftLimit", ",", "upperRedshiftLimit", ",", "redshiftResolution", ",", "pathToOutputPlotDirectory", ",", "plot", "=", "False", ")", ":", "################ > IMPORTS ################", "## STANDA...
*Generate a NumPy array of random distances given a sample number and distance limit* **Key Arguments:** - ``log`` -- logger - ``sampleNumber`` -- the sample number, i.e. array size - ``lowerRedshiftLimit`` -- the lower redshift limit of the volume to be included - ``upperRedshiftLi...
[ "*", "Generate", "a", "NumPy", "array", "of", "random", "distances", "given", "a", "sample", "number", "and", "distance", "limit", "*" ]
train
https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/universe.py#L36-L142
thespacedoctor/qubits
qubits/universe.py
random_sn_types_array
def random_sn_types_array( log, sampleNumber, relativeSNRates, pathToOutputPlotDirectory, plot=False): """ *Generate random supernova types from the weighted distributions set in the simulation settings file* **Key Arguments:** - ``log`` -- logger - `...
python
def random_sn_types_array( log, sampleNumber, relativeSNRates, pathToOutputPlotDirectory, plot=False): """ *Generate random supernova types from the weighted distributions set in the simulation settings file* **Key Arguments:** - ``log`` -- logger - `...
[ "def", "random_sn_types_array", "(", "log", ",", "sampleNumber", ",", "relativeSNRates", ",", "pathToOutputPlotDirectory", ",", "plot", "=", "False", ")", ":", "################ > IMPORTS ################", "## STANDARD LIB ##", "## THIRD PARTY ##", "## LOCAL APPLICATION ##", ...
*Generate random supernova types from the weighted distributions set in the simulation settings file* **Key Arguments:** - ``log`` -- logger - ``sampleNumber`` -- the sample number, i.e. array size - ``relativeSNRates`` -- dictionary of the rates - ``pathToOutputPlotDirectory`` -- p...
[ "*", "Generate", "random", "supernova", "types", "from", "the", "weighted", "distributions", "set", "in", "the", "simulation", "settings", "file", "*" ]
train
https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/universe.py#L148-L238
thespacedoctor/qubits
qubits/universe.py
random_host_extinction
def random_host_extinction( log, sampleNumber, extinctionType, extinctionConstant, hostExtinctionDistributions, plot=False): """ *Generate a Numpy array of random host extinctions* **Key Arguments:** - ``log`` -- logger - ``sampleNumber`` -- t...
python
def random_host_extinction( log, sampleNumber, extinctionType, extinctionConstant, hostExtinctionDistributions, plot=False): """ *Generate a Numpy array of random host extinctions* **Key Arguments:** - ``log`` -- logger - ``sampleNumber`` -- t...
[ "def", "random_host_extinction", "(", "log", ",", "sampleNumber", ",", "extinctionType", ",", "extinctionConstant", ",", "hostExtinctionDistributions", ",", "plot", "=", "False", ")", ":", "################ > IMPORTS ################", "## STANDARD LIB ##", "## THIRD PARTY ##...
*Generate a Numpy array of random host extinctions* **Key Arguments:** - ``log`` -- logger - ``sampleNumber`` -- the sample number, i.e. array size - ``extinctionType`` -- constant or random? - ``extinctionConstant`` -- the constant value (when extinctionType is constant) - ...
[ "*", "Generate", "a", "Numpy", "array", "of", "random", "host", "extinctions", "*" ]
train
https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/universe.py#L244-L281
thespacedoctor/qubits
qubits/universe.py
random_galactic_extinction
def random_galactic_extinction( log, sampleNumber, extinctionType, extinctionConstant, galacticExtinctionDistributions, plot=False): """ *Generate a Numpy array of random galactic extinctions* **Key Arguments:** - ``log`` -- logger - ``sampleN...
python
def random_galactic_extinction( log, sampleNumber, extinctionType, extinctionConstant, galacticExtinctionDistributions, plot=False): """ *Generate a Numpy array of random galactic extinctions* **Key Arguments:** - ``log`` -- logger - ``sampleN...
[ "def", "random_galactic_extinction", "(", "log", ",", "sampleNumber", ",", "extinctionType", ",", "extinctionConstant", ",", "galacticExtinctionDistributions", ",", "plot", "=", "False", ")", ":", "################ > IMPORTS ################", "## STANDARD LIB ##", "## THIRD ...
*Generate a Numpy array of random galactic extinctions* **Key Arguments:** - ``log`` -- logger - ``sampleNumber`` -- the sample number, i.e. array size - ``extinctionType`` -- constant or random? - ``extinctionConstant`` -- the constant value (when extinctionType is constant) ...
[ "*", "Generate", "a", "Numpy", "array", "of", "random", "galactic", "extinctions", "*" ]
train
https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/universe.py#L287-L326
thespacedoctor/qubits
qubits/universe.py
generate_numpy_polynomial_lightcurves
def generate_numpy_polynomial_lightcurves( log, snLightCurves, pathToOutputDirectory, pathToOutputPlotDirectory, plot=False): """ *Given a the yaml input of the SN Lightcurves generate a numpy polynomial of the curves.* **Key Arguments:** - ``log`` -- logger ...
python
def generate_numpy_polynomial_lightcurves( log, snLightCurves, pathToOutputDirectory, pathToOutputPlotDirectory, plot=False): """ *Given a the yaml input of the SN Lightcurves generate a numpy polynomial of the curves.* **Key Arguments:** - ``log`` -- logger ...
[ "def", "generate_numpy_polynomial_lightcurves", "(", "log", ",", "snLightCurves", ",", "pathToOutputDirectory", ",", "pathToOutputPlotDirectory", ",", "plot", "=", "False", ")", ":", "################ > IMPORTS ################", "## STANDARD LIB ##", "## THIRD PARTY ##", "impo...
*Given a the yaml input of the SN Lightcurves generate a numpy polynomial of the curves.* **Key Arguments:** - ``log`` -- logger - ``snLightCurves`` -- some info on sn LightCurves - ``pathToOutputDirectory`` -- path to the output directory (provided by the user) - ``pathToOutputPlot...
[ "*", "Given", "a", "the", "yaml", "input", "of", "the", "SN", "Lightcurves", "generate", "a", "numpy", "polynomial", "of", "the", "curves", ".", "*" ]
train
https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/universe.py#L332-L433
thespacedoctor/qubits
qubits/universe.py
random_peak_magnitudes
def random_peak_magnitudes( log, peakMagnitudeDistributions, snTypesArray, plot=True): """ *Generate a numpy array of random (distribution weighted) peak magnitudes for the given sn types.* **Key Arguments:** - ``log`` -- logger - ``peakMagnitudeDistributions...
python
def random_peak_magnitudes( log, peakMagnitudeDistributions, snTypesArray, plot=True): """ *Generate a numpy array of random (distribution weighted) peak magnitudes for the given sn types.* **Key Arguments:** - ``log`` -- logger - ``peakMagnitudeDistributions...
[ "def", "random_peak_magnitudes", "(", "log", ",", "peakMagnitudeDistributions", ",", "snTypesArray", ",", "plot", "=", "True", ")", ":", "################ > IMPORTS ################", "## STANDARD LIB ##", "## THIRD PARTY ##", "import", "matplotlib", ".", "pyplot", "as", ...
*Generate a numpy array of random (distribution weighted) peak magnitudes for the given sn types.* **Key Arguments:** - ``log`` -- logger - ``peakMagnitudeDistributions`` -- yaml style dictionary of peak magnitude distributions - ``snTypesArray`` -- the pre-generated array of random sn type...
[ "*", "Generate", "a", "numpy", "array", "of", "random", "(", "distribution", "weighted", ")", "peak", "magnitudes", "for", "the", "given", "sn", "types", ".", "*" ]
train
https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/universe.py#L439-L478
thespacedoctor/qubits
qubits/universe.py
build_kcorrection_array
def build_kcorrection_array( log, redshiftArray, snTypesArray, snLightCurves, pathToOutputDirectory, plot=True): """ *Given the random redshiftArray and snTypeArray, generate a dictionary of k-correction polynomials (one for each filter) for every object.* **...
python
def build_kcorrection_array( log, redshiftArray, snTypesArray, snLightCurves, pathToOutputDirectory, plot=True): """ *Given the random redshiftArray and snTypeArray, generate a dictionary of k-correction polynomials (one for each filter) for every object.* **...
[ "def", "build_kcorrection_array", "(", "log", ",", "redshiftArray", ",", "snTypesArray", ",", "snLightCurves", ",", "pathToOutputDirectory", ",", "plot", "=", "True", ")", ":", "################ > IMPORTS ################", "## STANDARD LIB ##", "## THIRD PARTY ##", "import...
*Given the random redshiftArray and snTypeArray, generate a dictionary of k-correction polynomials (one for each filter) for every object.* **Key Arguments:** - ``log`` -- logger - ``redshiftArray`` -- the pre-generated redshift array - ``snTypesArray`` -- the pre-generated array of random ...
[ "*", "Given", "the", "random", "redshiftArray", "and", "snTypeArray", "generate", "a", "dictionary", "of", "k", "-", "correction", "polynomials", "(", "one", "for", "each", "filter", ")", "for", "every", "object", ".", "*" ]
train
https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/universe.py#L484-L542
thespacedoctor/qubits
qubits/universe.py
convert_lightcurves_to_observered_frame
def convert_lightcurves_to_observered_frame( log, snLightCurves, rawLightCurveDict, redshiftArray, snTypesArray, peakMagnitudesArray, hostExtinctionArray, kCorrectionArray, galacticExtinctionArray, restFrameFilter, pathToOutputDirec...
python
def convert_lightcurves_to_observered_frame( log, snLightCurves, rawLightCurveDict, redshiftArray, snTypesArray, peakMagnitudesArray, hostExtinctionArray, kCorrectionArray, galacticExtinctionArray, restFrameFilter, pathToOutputDirec...
[ "def", "convert_lightcurves_to_observered_frame", "(", "log", ",", "snLightCurves", ",", "rawLightCurveDict", ",", "redshiftArray", ",", "snTypesArray", ",", "peakMagnitudesArray", ",", "hostExtinctionArray", ",", "kCorrectionArray", ",", "galacticExtinctionArray", ",", "re...
*Given all the randomly generated parameters of the survey, generate a dictionary of lightcurves for each object (one lightcurve per filter)* **Key Arguments:** - ``log`` -- logger - ``snLightCurves`` -- the sn lightcurve dictionary (with explosion / extinction dates) - ``rawLightCurveDict`...
[ "*", "Given", "all", "the", "randomly", "generated", "parameters", "of", "the", "survey", "generate", "a", "dictionary", "of", "lightcurves", "for", "each", "object", "(", "one", "lightcurve", "per", "filter", ")", "*" ]
train
https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/universe.py#L548-L883
ECESeniorDesign/lazy_record
lazy_record/base/__init__.py
Base.from_dict
def from_dict(cls, **kwargs): """ Construct an object an mass-assign its attributes using +kwargs+, ignoring all protections of id and created_at. Intended for constructing objects already present in the database (i.e for use by methods such as find or within Query). """ ...
python
def from_dict(cls, **kwargs): """ Construct an object an mass-assign its attributes using +kwargs+, ignoring all protections of id and created_at. Intended for constructing objects already present in the database (i.e for use by methods such as find or within Query). """ ...
[ "def", "from_dict", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "# Create the object", "obj", "=", "cls", "(", ")", "# By default, objects are initialized with attribute values of None", "# We need to clear those out so that we get AttributeError on access", "for", "attr", ...
Construct an object an mass-assign its attributes using +kwargs+, ignoring all protections of id and created_at. Intended for constructing objects already present in the database (i.e for use by methods such as find or within Query).
[ "Construct", "an", "object", "an", "mass", "-", "assign", "its", "attributes", "using", "+", "kwargs", "+", "ignoring", "all", "protections", "of", "id", "and", "created_at", ".", "Intended", "for", "constructing", "objects", "already", "present", "in", "the",...
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/base/__init__.py#L96-L113
ECESeniorDesign/lazy_record
lazy_record/base/__init__.py
Base.update
def update(self, **kwargs): """ Mass-assign the attributes in +kwargs+ to the object, preventing attributes not in __attributes__ from being set. """ for attr, val in kwargs.items(): if attr in (list(self.__class__.__attributes__) + \ list(asso...
python
def update(self, **kwargs): """ Mass-assign the attributes in +kwargs+ to the object, preventing attributes not in __attributes__ from being set. """ for attr, val in kwargs.items(): if attr in (list(self.__class__.__attributes__) + \ list(asso...
[ "def", "update", "(", "self", ",", "*", "*", "kwargs", ")", ":", "for", "attr", ",", "val", "in", "kwargs", ".", "items", "(", ")", ":", "if", "attr", "in", "(", "list", "(", "self", ".", "__class__", ".", "__attributes__", ")", "+", "list", "(",...
Mass-assign the attributes in +kwargs+ to the object, preventing attributes not in __attributes__ from being set.
[ "Mass", "-", "assign", "the", "attributes", "in", "+", "kwargs", "+", "to", "the", "object", "preventing", "attributes", "not", "in", "__attributes__", "from", "being", "set", "." ]
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/base/__init__.py#L115-L123
ECESeniorDesign/lazy_record
lazy_record/base/__init__.py
Base.delete
def delete(self): """ Delete this record without deleting any dependent or child records. This can orphan records, so use with care. """ if self.id: with Repo.db: Repo(self.__table).where(id=self.id).delete()
python
def delete(self): """ Delete this record without deleting any dependent or child records. This can orphan records, so use with care. """ if self.id: with Repo.db: Repo(self.__table).where(id=self.id).delete()
[ "def", "delete", "(", "self", ")", ":", "if", "self", ".", "id", ":", "with", "Repo", ".", "db", ":", "Repo", "(", "self", ".", "__table", ")", ".", "where", "(", "id", "=", "self", ".", "id", ")", ".", "delete", "(", ")" ]
Delete this record without deleting any dependent or child records. This can orphan records, so use with care.
[ "Delete", "this", "record", "without", "deleting", "any", "dependent", "or", "child", "records", ".", "This", "can", "orphan", "records", "so", "use", "with", "care", "." ]
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/base/__init__.py#L125-L132
ECESeniorDesign/lazy_record
lazy_record/base/__init__.py
Base.save
def save(self): """ Save a record to the database, creating it if needed, updating it otherwise. Also saves related records (children and dependents) as needed. """ with Repo.db: self._do_save() our_name = inflector.singularize(Repo.table_name(self...
python
def save(self): """ Save a record to the database, creating it if needed, updating it otherwise. Also saves related records (children and dependents) as needed. """ with Repo.db: self._do_save() our_name = inflector.singularize(Repo.table_name(self...
[ "def", "save", "(", "self", ")", ":", "with", "Repo", ".", "db", ":", "self", ".", "_do_save", "(", ")", "our_name", "=", "inflector", ".", "singularize", "(", "Repo", ".", "table_name", "(", "self", ".", "__class__", ")", ")", "for", "record", "in",...
Save a record to the database, creating it if needed, updating it otherwise. Also saves related records (children and dependents) as needed.
[ "Save", "a", "record", "to", "the", "database", "creating", "it", "if", "needed", "updating", "it", "otherwise", ".", "Also", "saves", "related", "records", "(", "children", "and", "dependents", ")", "as", "needed", "." ]
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/base/__init__.py#L175-L192
CodyKochmann/stricttuple
stricttuple/__init__.py
shorten
def shorten(string, max_length=80, trailing_chars=3): ''' trims the 'string' argument down to 'max_length' to make previews to long string values ''' assert type(string).__name__ in {'str', 'unicode'}, 'shorten needs string to be a string, not {}'.format(type(string)) assert type(max_length) == int, 'shorte...
python
def shorten(string, max_length=80, trailing_chars=3): ''' trims the 'string' argument down to 'max_length' to make previews to long string values ''' assert type(string).__name__ in {'str', 'unicode'}, 'shorten needs string to be a string, not {}'.format(type(string)) assert type(max_length) == int, 'shorte...
[ "def", "shorten", "(", "string", ",", "max_length", "=", "80", ",", "trailing_chars", "=", "3", ")", ":", "assert", "type", "(", "string", ")", ".", "__name__", "in", "{", "'str'", ",", "'unicode'", "}", ",", "'shorten needs string to be a string, not {}'", ...
trims the 'string' argument down to 'max_length' to make previews to long string values
[ "trims", "the", "string", "argument", "down", "to", "max_length", "to", "make", "previews", "to", "long", "string", "values" ]
train
https://github.com/CodyKochmann/stricttuple/blob/072cbd6f7b90f3f666dc0f2c10ab6056d86dfc72/stricttuple/__init__.py#L40-L55
CodyKochmann/stricttuple
stricttuple/__init__.py
is_prettytable
def is_prettytable(string): """ returns true if the input looks like a prettytable """ return type(string).__name__ in {'str','unicode'} and ( len(string.splitlines()) > 1 ) and ( all(string[i] == string[-i-1] for i in range(3)) )
python
def is_prettytable(string): """ returns true if the input looks like a prettytable """ return type(string).__name__ in {'str','unicode'} and ( len(string.splitlines()) > 1 ) and ( all(string[i] == string[-i-1] for i in range(3)) )
[ "def", "is_prettytable", "(", "string", ")", ":", "return", "type", "(", "string", ")", ".", "__name__", "in", "{", "'str'", ",", "'unicode'", "}", "and", "(", "len", "(", "string", ".", "splitlines", "(", ")", ")", ">", "1", ")", "and", "(", "all"...
returns true if the input looks like a prettytable
[ "returns", "true", "if", "the", "input", "looks", "like", "a", "prettytable" ]
train
https://github.com/CodyKochmann/stricttuple/blob/072cbd6f7b90f3f666dc0f2c10ab6056d86dfc72/stricttuple/__init__.py#L57-L63
evetrivia/thanatos
thanatos/database/inventory.py
get_all_published_ships_basic
def get_all_published_ships_basic(db_connection): """ Gets a list of all published ships and their basic information. :return: Each result has a tuple of (typeID, typeName, groupID, groupName, categoryID, and categoryName). :rtype: list """ if not hasattr(get_all_published_ships_basic, '_results')...
python
def get_all_published_ships_basic(db_connection): """ Gets a list of all published ships and their basic information. :return: Each result has a tuple of (typeID, typeName, groupID, groupName, categoryID, and categoryName). :rtype: list """ if not hasattr(get_all_published_ships_basic, '_results')...
[ "def", "get_all_published_ships_basic", "(", "db_connection", ")", ":", "if", "not", "hasattr", "(", "get_all_published_ships_basic", ",", "'_results'", ")", ":", "sql", "=", "'CALL get_all_published_ships_basic();'", "results", "=", "execute_sql", "(", "sql", ",", "d...
Gets a list of all published ships and their basic information. :return: Each result has a tuple of (typeID, typeName, groupID, groupName, categoryID, and categoryName). :rtype: list
[ "Gets", "a", "list", "of", "all", "published", "ships", "and", "their", "basic", "information", "." ]
train
https://github.com/evetrivia/thanatos/blob/664c12a8ccf4d27ab0e06e0969bbb6381f74789c/thanatos/database/inventory.py#L10-L22
evetrivia/thanatos
thanatos/database/inventory.py
get_ships_that_have_variations
def get_ships_that_have_variations(db_connection): """ Gets a list of all published ship type IDs that have at least 3 variations. :return: :rtype: list """ if not hasattr(get_ships_that_have_variations, '_results'): sql = 'CALL get_ships_that_have_variations();' results = execute_...
python
def get_ships_that_have_variations(db_connection): """ Gets a list of all published ship type IDs that have at least 3 variations. :return: :rtype: list """ if not hasattr(get_ships_that_have_variations, '_results'): sql = 'CALL get_ships_that_have_variations();' results = execute_...
[ "def", "get_ships_that_have_variations", "(", "db_connection", ")", ":", "if", "not", "hasattr", "(", "get_ships_that_have_variations", ",", "'_results'", ")", ":", "sql", "=", "'CALL get_ships_that_have_variations();'", "results", "=", "execute_sql", "(", "sql", ",", ...
Gets a list of all published ship type IDs that have at least 3 variations. :return: :rtype: list
[ "Gets", "a", "list", "of", "all", "published", "ship", "type", "IDs", "that", "have", "at", "least", "3", "variations", "." ]
train
https://github.com/evetrivia/thanatos/blob/664c12a8ccf4d27ab0e06e0969bbb6381f74789c/thanatos/database/inventory.py#L44-L56
mohamedattahri/PyXMLi
pyxmli/xmldsig.py
c14n
def c14n(xml): ''' Applies c14n to the xml input @param xml: str @return: str ''' tree = etree.parse(StringIO(xml)) output = StringIO() tree.write_c14n(output, exclusive=False, with_comments=True, compression=0) output.flush() c14nized = output.getvalue() output.close() r...
python
def c14n(xml): ''' Applies c14n to the xml input @param xml: str @return: str ''' tree = etree.parse(StringIO(xml)) output = StringIO() tree.write_c14n(output, exclusive=False, with_comments=True, compression=0) output.flush() c14nized = output.getvalue() output.close() r...
[ "def", "c14n", "(", "xml", ")", ":", "tree", "=", "etree", ".", "parse", "(", "StringIO", "(", "xml", ")", ")", "output", "=", "StringIO", "(", ")", "tree", ".", "write_c14n", "(", "output", ",", "exclusive", "=", "False", ",", "with_comments", "=", ...
Applies c14n to the xml input @param xml: str @return: str
[ "Applies", "c14n", "to", "the", "xml", "input" ]
train
https://github.com/mohamedattahri/PyXMLi/blob/a81a245be822d62f1a20c734ca14b42c786ae81e/pyxmli/xmldsig.py#L50-L62
mohamedattahri/PyXMLi
pyxmli/xmldsig.py
sign
def sign(xml, private, public): ''' Return xmldsig XML string from xml_string of XML. @param xml: str of bytestring xml to sign @param private: publicKey Private key @param public: publicKey Public key @return str: signed XML byte string ''' xml = xml.encode('utf-8', 'xmlcharrefreplace')...
python
def sign(xml, private, public): ''' Return xmldsig XML string from xml_string of XML. @param xml: str of bytestring xml to sign @param private: publicKey Private key @param public: publicKey Public key @return str: signed XML byte string ''' xml = xml.encode('utf-8', 'xmlcharrefreplace')...
[ "def", "sign", "(", "xml", ",", "private", ",", "public", ")", ":", "xml", "=", "xml", ".", "encode", "(", "'utf-8'", ",", "'xmlcharrefreplace'", ")", "signed_info_xml", "=", "_generate_signed_info", "(", "xml", ")", "signer", "=", "PKCS1_v1_5", ".", "PKCS...
Return xmldsig XML string from xml_string of XML. @param xml: str of bytestring xml to sign @param private: publicKey Private key @param public: publicKey Public key @return str: signed XML byte string
[ "Return", "xmldsig", "XML", "string", "from", "xml_string", "of", "XML", "." ]
train
https://github.com/mohamedattahri/PyXMLi/blob/a81a245be822d62f1a20c734ca14b42c786ae81e/pyxmli/xmldsig.py#L65-L86
mohamedattahri/PyXMLi
pyxmli/xmldsig.py
verify
def verify(xml): '''Verifies whether the validity of the signature contained in an XML document following the XMLDSig standard''' try: from cStringIO import cStringIO as StringIO except ImportError: from StringIO import StringIO xml = xml.encode('utf-8', 'xmlcharrefreplace') ...
python
def verify(xml): '''Verifies whether the validity of the signature contained in an XML document following the XMLDSig standard''' try: from cStringIO import cStringIO as StringIO except ImportError: from StringIO import StringIO xml = xml.encode('utf-8', 'xmlcharrefreplace') ...
[ "def", "verify", "(", "xml", ")", ":", "try", ":", "from", "cStringIO", "import", "cStringIO", "as", "StringIO", "except", "ImportError", ":", "from", "StringIO", "import", "StringIO", "xml", "=", "xml", ".", "encode", "(", "'utf-8'", ",", "'xmlcharrefreplac...
Verifies whether the validity of the signature contained in an XML document following the XMLDSig standard
[ "Verifies", "whether", "the", "validity", "of", "the", "signature", "contained", "in", "an", "XML", "document", "following", "the", "XMLDSig", "standard" ]
train
https://github.com/mohamedattahri/PyXMLi/blob/a81a245be822d62f1a20c734ca14b42c786ae81e/pyxmli/xmldsig.py#L89-L128
devricks/soft_drf
soft_drf/routing/autodiscover.py
autodiscover
def autodiscover(): """ Perform an autodiscover of an api.py file in the installed apps to generate the routes of the registered viewsets. """ for app in settings.INSTALLED_APPS: try: import_module('.'.join((app, 'api'))) except ImportError as e: if e.msg != "...
python
def autodiscover(): """ Perform an autodiscover of an api.py file in the installed apps to generate the routes of the registered viewsets. """ for app in settings.INSTALLED_APPS: try: import_module('.'.join((app, 'api'))) except ImportError as e: if e.msg != "...
[ "def", "autodiscover", "(", ")", ":", "for", "app", "in", "settings", ".", "INSTALLED_APPS", ":", "try", ":", "import_module", "(", "'.'", ".", "join", "(", "(", "app", ",", "'api'", ")", ")", ")", "except", "ImportError", "as", "e", ":", "if", "e", ...
Perform an autodiscover of an api.py file in the installed apps to generate the routes of the registered viewsets.
[ "Perform", "an", "autodiscover", "of", "an", "api", ".", "py", "file", "in", "the", "installed", "apps", "to", "generate", "the", "routes", "of", "the", "registered", "viewsets", "." ]
train
https://github.com/devricks/soft_drf/blob/1869b13f9341bfcebd931059e93de2bc38570da3/soft_drf/routing/autodiscover.py#L7-L17
markpasc/pywhich
pywhich.py
identify_module
def identify_module(arg): """Import and return the Python module named in `arg`. If the module cannot be imported, a `pywhich.ModuleNotFound` exception is raised. """ try: __import__(arg) except Exception: exc = sys.exc_info()[1] raise ModuleNotFound("%s: %s" % (type(ex...
python
def identify_module(arg): """Import and return the Python module named in `arg`. If the module cannot be imported, a `pywhich.ModuleNotFound` exception is raised. """ try: __import__(arg) except Exception: exc = sys.exc_info()[1] raise ModuleNotFound("%s: %s" % (type(ex...
[ "def", "identify_module", "(", "arg", ")", ":", "try", ":", "__import__", "(", "arg", ")", "except", "Exception", ":", "exc", "=", "sys", ".", "exc_info", "(", ")", "[", "1", "]", "raise", "ModuleNotFound", "(", "\"%s: %s\"", "%", "(", "type", "(", "...
Import and return the Python module named in `arg`. If the module cannot be imported, a `pywhich.ModuleNotFound` exception is raised.
[ "Import", "and", "return", "the", "Python", "module", "named", "in", "arg", "." ]
train
https://github.com/markpasc/pywhich/blob/2c7cbe0d8a6789ede48c53f263872ceac5b67ca3/pywhich.py#L16-L30
markpasc/pywhich
pywhich.py
identify_filepath
def identify_filepath(arg, real_path=None, show_directory=None, find_source=None, hide_init=None): """Discover and return the disk file path of the Python module named in `arg` by importing the module and returning its ``__file__`` attribute. If `find_source` is `True`, the named module is a ``pyc`` or...
python
def identify_filepath(arg, real_path=None, show_directory=None, find_source=None, hide_init=None): """Discover and return the disk file path of the Python module named in `arg` by importing the module and returning its ``__file__`` attribute. If `find_source` is `True`, the named module is a ``pyc`` or...
[ "def", "identify_filepath", "(", "arg", ",", "real_path", "=", "None", ",", "show_directory", "=", "None", ",", "find_source", "=", "None", ",", "hide_init", "=", "None", ")", ":", "mod", "=", "identify_module", "(", "arg", ")", "# raises ModuleNotFound", "t...
Discover and return the disk file path of the Python module named in `arg` by importing the module and returning its ``__file__`` attribute. If `find_source` is `True`, the named module is a ``pyc`` or ``pyo`` file, and a corresponding ``.py`` file exists on disk, the path to the ``.py`` file is return...
[ "Discover", "and", "return", "the", "disk", "file", "path", "of", "the", "Python", "module", "named", "in", "arg", "by", "importing", "the", "module", "and", "returning", "its", "__file__", "attribute", "." ]
train
https://github.com/markpasc/pywhich/blob/2c7cbe0d8a6789ede48c53f263872ceac5b67ca3/pywhich.py#L33-L80
markpasc/pywhich
pywhich.py
identify_modules
def identify_modules(*args, **kwargs): """Find the disk locations of the given named modules, printing the discovered paths to stdout and errors discovering paths to stderr. Any provided keyword arguments are passed to `identify_filepath()`. """ if len(args) == 1: path_template = "%(file)s...
python
def identify_modules(*args, **kwargs): """Find the disk locations of the given named modules, printing the discovered paths to stdout and errors discovering paths to stderr. Any provided keyword arguments are passed to `identify_filepath()`. """ if len(args) == 1: path_template = "%(file)s...
[ "def", "identify_modules", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "args", ")", "==", "1", ":", "path_template", "=", "\"%(file)s\"", "error_template", "=", "\"Module '%(mod)s' not found (%(error)s)\"", "else", ":", "path_template"...
Find the disk locations of the given named modules, printing the discovered paths to stdout and errors discovering paths to stderr. Any provided keyword arguments are passed to `identify_filepath()`.
[ "Find", "the", "disk", "locations", "of", "the", "given", "named", "modules", "printing", "the", "discovered", "paths", "to", "stdout", "and", "errors", "discovering", "paths", "to", "stderr", "." ]
train
https://github.com/markpasc/pywhich/blob/2c7cbe0d8a6789ede48c53f263872ceac5b67ca3/pywhich.py#L83-L111
markpasc/pywhich
pywhich.py
find_version
def find_version(*args): """Find the versions of the given named modules, printing the discovered versions to stdout and errors discovering versions to stderr.""" if len(args) == 1: ver_template = "%(version)s" error_template = "Distribution/module '%(mod)s' not found (%(error)s)" else: ...
python
def find_version(*args): """Find the versions of the given named modules, printing the discovered versions to stdout and errors discovering versions to stderr.""" if len(args) == 1: ver_template = "%(version)s" error_template = "Distribution/module '%(mod)s' not found (%(error)s)" else: ...
[ "def", "find_version", "(", "*", "args", ")", ":", "if", "len", "(", "args", ")", "==", "1", ":", "ver_template", "=", "\"%(version)s\"", "error_template", "=", "\"Distribution/module '%(mod)s' not found (%(error)s)\"", "else", ":", "ver_template", "=", "\"%(mod)s: ...
Find the versions of the given named modules, printing the discovered versions to stdout and errors discovering versions to stderr.
[ "Find", "the", "versions", "of", "the", "given", "named", "modules", "printing", "the", "discovered", "versions", "to", "stdout", "and", "errors", "discovering", "versions", "to", "stderr", "." ]
train
https://github.com/markpasc/pywhich/blob/2c7cbe0d8a6789ede48c53f263872ceac5b67ca3/pywhich.py#L114-L151
markpasc/pywhich
pywhich.py
main
def main(argv=None): """Run the pywhich command as if invoked with arguments `argv`. If `argv` is `None`, arguments from `sys.argv` are used. """ if argv is None: argv = sys.argv parser = OptionParser() parser.add_option('-v', '--verbose', dest="verbose", action="count", defa...
python
def main(argv=None): """Run the pywhich command as if invoked with arguments `argv`. If `argv` is `None`, arguments from `sys.argv` are used. """ if argv is None: argv = sys.argv parser = OptionParser() parser.add_option('-v', '--verbose', dest="verbose", action="count", defa...
[ "def", "main", "(", "argv", "=", "None", ")", ":", "if", "argv", "is", "None", ":", "argv", "=", "sys", ".", "argv", "parser", "=", "OptionParser", "(", ")", "parser", ".", "add_option", "(", "'-v'", ",", "'--verbose'", ",", "dest", "=", "\"verbose\"...
Run the pywhich command as if invoked with arguments `argv`. If `argv` is `None`, arguments from `sys.argv` are used.
[ "Run", "the", "pywhich", "command", "as", "if", "invoked", "with", "arguments", "argv", "." ]
train
https://github.com/markpasc/pywhich/blob/2c7cbe0d8a6789ede48c53f263872ceac5b67ca3/pywhich.py#L154-L197
vecnet/vecnet.simulation
vecnet/simulation/__init__.py
DictConvertible.from_dict
def from_dict(cls, d): """ Create an instance from a dictionary. """ assert isinstance(d, dict) init_args = dict() for key, is_required in cls.dictionary_attributes.iteritems(): try: init_args[key] = d[key] except KeyError: ...
python
def from_dict(cls, d): """ Create an instance from a dictionary. """ assert isinstance(d, dict) init_args = dict() for key, is_required in cls.dictionary_attributes.iteritems(): try: init_args[key] = d[key] except KeyError: ...
[ "def", "from_dict", "(", "cls", ",", "d", ")", ":", "assert", "isinstance", "(", "d", ",", "dict", ")", "init_args", "=", "dict", "(", ")", "for", "key", ",", "is_required", "in", "cls", ".", "dictionary_attributes", ".", "iteritems", "(", ")", ":", ...
Create an instance from a dictionary.
[ "Create", "an", "instance", "from", "a", "dictionary", "." ]
train
https://github.com/vecnet/vecnet.simulation/blob/3a4b3df7b12418c6fa8a7d9cd49656a1c031fc0e/vecnet/simulation/__init__.py#L17-L29
vecnet/vecnet.simulation
vecnet/simulation/__init__.py
DictConvertible.read_json_file
def read_json_file(cls, path): """ Read an instance from a JSON-formatted file. :return: A new instance """ with open(path, 'r') as f: return cls.from_dict(json.load(f))
python
def read_json_file(cls, path): """ Read an instance from a JSON-formatted file. :return: A new instance """ with open(path, 'r') as f: return cls.from_dict(json.load(f))
[ "def", "read_json_file", "(", "cls", ",", "path", ")", ":", "with", "open", "(", "path", ",", "'r'", ")", "as", "f", ":", "return", "cls", ".", "from_dict", "(", "json", ".", "load", "(", "f", ")", ")" ]
Read an instance from a JSON-formatted file. :return: A new instance
[ "Read", "an", "instance", "from", "a", "JSON", "-", "formatted", "file", "." ]
train
https://github.com/vecnet/vecnet.simulation/blob/3a4b3df7b12418c6fa8a7d9cd49656a1c031fc0e/vecnet/simulation/__init__.py#L32-L39
vecnet/vecnet.simulation
vecnet/simulation/__init__.py
DictConvertible.write_json_file
def write_json_file(self, path): """ Write the instance in JSON format to a file. """ with open(path, 'w') as f: json.dump(self.to_dict(), f, indent=2)
python
def write_json_file(self, path): """ Write the instance in JSON format to a file. """ with open(path, 'w') as f: json.dump(self.to_dict(), f, indent=2)
[ "def", "write_json_file", "(", "self", ",", "path", ")", ":", "with", "open", "(", "path", ",", "'w'", ")", "as", "f", ":", "json", ".", "dump", "(", "self", ".", "to_dict", "(", ")", ",", "f", ",", "indent", "=", "2", ")" ]
Write the instance in JSON format to a file.
[ "Write", "the", "instance", "in", "JSON", "format", "to", "a", "file", "." ]
train
https://github.com/vecnet/vecnet.simulation/blob/3a4b3df7b12418c6fa8a7d9cd49656a1c031fc0e/vecnet/simulation/__init__.py#L50-L55
vecnet/vecnet.simulation
vecnet/simulation/__init__.py
ExecutionRequest.from_dict
def from_dict(cls, d): """ Create an instance from a dictionary. """ execution_request = super(ExecutionRequest, cls).from_dict(d) if isinstance(execution_request.simulation_group, dict): execution_request.simulation_group = SimulationGroup.from_dict(execution_request...
python
def from_dict(cls, d): """ Create an instance from a dictionary. """ execution_request = super(ExecutionRequest, cls).from_dict(d) if isinstance(execution_request.simulation_group, dict): execution_request.simulation_group = SimulationGroup.from_dict(execution_request...
[ "def", "from_dict", "(", "cls", ",", "d", ")", ":", "execution_request", "=", "super", "(", "ExecutionRequest", ",", "cls", ")", ".", "from_dict", "(", "d", ")", "if", "isinstance", "(", "execution_request", ".", "simulation_group", ",", "dict", ")", ":", ...
Create an instance from a dictionary.
[ "Create", "an", "instance", "from", "a", "dictionary", "." ]
train
https://github.com/vecnet/vecnet.simulation/blob/3a4b3df7b12418c6fa8a7d9cd49656a1c031fc0e/vecnet/simulation/__init__.py#L83-L90
vecnet/vecnet.simulation
vecnet/simulation/__init__.py
SimulationGroup.from_dict
def from_dict(cls, d): """ Create an instance from a dictionary. """ instance = super(SimulationGroup, cls).from_dict(d) # instance.simulations is a list of dictionaries; convert each dictionary to a Simulation instance instance.simulations = [Simulation.from_dict(x) for...
python
def from_dict(cls, d): """ Create an instance from a dictionary. """ instance = super(SimulationGroup, cls).from_dict(d) # instance.simulations is a list of dictionaries; convert each dictionary to a Simulation instance instance.simulations = [Simulation.from_dict(x) for...
[ "def", "from_dict", "(", "cls", ",", "d", ")", ":", "instance", "=", "super", "(", "SimulationGroup", ",", "cls", ")", ".", "from_dict", "(", "d", ")", "# instance.simulations is a list of dictionaries; convert each dictionary to a Simulation instance", "instance", "."...
Create an instance from a dictionary.
[ "Create", "an", "instance", "from", "a", "dictionary", "." ]
train
https://github.com/vecnet/vecnet.simulation/blob/3a4b3df7b12418c6fa8a7d9cd49656a1c031fc0e/vecnet/simulation/__init__.py#L117-L124
vecnet/vecnet.simulation
vecnet/simulation/__init__.py
Simulation.from_dict
def from_dict(cls, d): """ Create an instance from a dictionary. """ instance = super(Simulation, cls).from_dict(d) # The instance's input_files and cmd_line_args members still point to data structures in the original # dictionary. Copy them to avoid surprises if they ...
python
def from_dict(cls, d): """ Create an instance from a dictionary. """ instance = super(Simulation, cls).from_dict(d) # The instance's input_files and cmd_line_args members still point to data structures in the original # dictionary. Copy them to avoid surprises if they ...
[ "def", "from_dict", "(", "cls", ",", "d", ")", ":", "instance", "=", "super", "(", "Simulation", ",", "cls", ")", ".", "from_dict", "(", "d", ")", "# The instance's input_files and cmd_line_args members still point to data structures in the original", "# dictionary. Co...
Create an instance from a dictionary.
[ "Create", "an", "instance", "from", "a", "dictionary", "." ]
train
https://github.com/vecnet/vecnet.simulation/blob/3a4b3df7b12418c6fa8a7d9cd49656a1c031fc0e/vecnet/simulation/__init__.py#L170-L179
ardydedase/pycouchbase
pycouchbase/fields.py
CustomField.value
def value(self): """Property to be used when saving a custom field into :class:`couchbasekit.document.Document` instance. :returns: The value to be saved for the field within :class:`couchbasekit.document.Document` instances. :rtype: mixed """ if self._value ...
python
def value(self): """Property to be used when saving a custom field into :class:`couchbasekit.document.Document` instance. :returns: The value to be saved for the field within :class:`couchbasekit.document.Document` instances. :rtype: mixed """ if self._value ...
[ "def", "value", "(", "self", ")", ":", "if", "self", ".", "_value", "is", "None", ":", "raise", "ValueError", "(", "\"%s's 'value' is not set.\"", "%", "type", "(", "self", ")", ".", "__name__", ")", "return", "self", ".", "_value" ]
Property to be used when saving a custom field into :class:`couchbasekit.document.Document` instance. :returns: The value to be saved for the field within :class:`couchbasekit.document.Document` instances. :rtype: mixed
[ "Property", "to", "be", "used", "when", "saving", "a", "custom", "field", "into", ":", "class", ":", "couchbasekit", ".", "document", ".", "Document", "instance", "." ]
train
https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/pycouchbase/fields.py#L49-L59
ardydedase/pycouchbase
pycouchbase/fields.py
EmailField.is_valid
def is_valid(email): """Email address validation method. :param email: Email address to be saved. :type email: basestring :returns: True if email address is correct, False otherwise. :rtype: bool """ if isinstance(email, basestring) and EMAIL_RE.match(email): ...
python
def is_valid(email): """Email address validation method. :param email: Email address to be saved. :type email: basestring :returns: True if email address is correct, False otherwise. :rtype: bool """ if isinstance(email, basestring) and EMAIL_RE.match(email): ...
[ "def", "is_valid", "(", "email", ")", ":", "if", "isinstance", "(", "email", ",", "basestring", ")", "and", "EMAIL_RE", ".", "match", "(", "email", ")", ":", "return", "True", "return", "False" ]
Email address validation method. :param email: Email address to be saved. :type email: basestring :returns: True if email address is correct, False otherwise. :rtype: bool
[ "Email", "address", "validation", "method", "." ]
train
https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/pycouchbase/fields.py#L143-L153
ardydedase/pycouchbase
pycouchbase/fields.py
PasswordField.check_password
def check_password(self, raw_password): """Validates the given raw password against the intance's encrypted one. :param raw_password: Raw password to be checked against. :type raw_password: unicode :returns: True if comparison was successful, False otherwise. :rtype: bool ...
python
def check_password(self, raw_password): """Validates the given raw password against the intance's encrypted one. :param raw_password: Raw password to be checked against. :type raw_password: unicode :returns: True if comparison was successful, False otherwise. :rtype: bool ...
[ "def", "check_password", "(", "self", ",", "raw_password", ")", ":", "bcrypt", "=", "self", ".", "get_bcrypt", "(", ")", "return", "bcrypt", ".", "hashpw", "(", "raw_password", ",", "self", ".", "value", ")", "==", "self", ".", "value" ]
Validates the given raw password against the intance's encrypted one. :param raw_password: Raw password to be checked against. :type raw_password: unicode :returns: True if comparison was successful, False otherwise. :rtype: bool :raises: :exc:`ImportError` if `py-bcrypt` was no...
[ "Validates", "the", "given", "raw", "password", "against", "the", "intance", "s", "encrypted", "one", "." ]
train
https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/pycouchbase/fields.py#L189-L199
fred49/argtoolbox
setup.py
is_archlinux
def is_archlinux(): """return True if the current distribution is running on debian like OS.""" if platform.system().lower() == 'linux': if platform.linux_distribution() == ('', '', ''): # undefined distribution. Fixed in python 3. if os.path.exists('/etc/arch-release'): ...
python
def is_archlinux(): """return True if the current distribution is running on debian like OS.""" if platform.system().lower() == 'linux': if platform.linux_distribution() == ('', '', ''): # undefined distribution. Fixed in python 3. if os.path.exists('/etc/arch-release'): ...
[ "def", "is_archlinux", "(", ")", ":", "if", "platform", ".", "system", "(", ")", ".", "lower", "(", ")", "==", "'linux'", ":", "if", "platform", ".", "linux_distribution", "(", ")", "==", "(", "''", ",", "''", ",", "''", ")", ":", "# undefined distri...
return True if the current distribution is running on debian like OS.
[ "return", "True", "if", "the", "current", "distribution", "is", "running", "on", "debian", "like", "OS", "." ]
train
https://github.com/fred49/argtoolbox/blob/e32ad6265567d5a1891df3c3425423774dafab41/setup.py#L46-L53
malthe/pop
src/pop/client.py
ZookeeperClient.create_or_clear
def create_or_clear(self, path, **kwargs): """Create path and recursively clear contents.""" try: yield self.create(path, **kwargs) except NodeExistsException: children = yield self.get_children(path) for name in children: yield self.recursive...
python
def create_or_clear(self, path, **kwargs): """Create path and recursively clear contents.""" try: yield self.create(path, **kwargs) except NodeExistsException: children = yield self.get_children(path) for name in children: yield self.recursive...
[ "def", "create_or_clear", "(", "self", ",", "path", ",", "*", "*", "kwargs", ")", ":", "try", ":", "yield", "self", ".", "create", "(", "path", ",", "*", "*", "kwargs", ")", "except", "NodeExistsException", ":", "children", "=", "yield", "self", ".", ...
Create path and recursively clear contents.
[ "Create", "path", "and", "recursively", "clear", "contents", "." ]
train
https://github.com/malthe/pop/blob/3b58b91b41d8b9bee546eb40dc280a57500b8bed/src/pop/client.py#L12-L20
malthe/pop
src/pop/client.py
ZookeeperClient.recursive_delete
def recursive_delete(self, path, **kwargs): """Recursively delete path.""" while True: try: yield self.delete(path, **kwargs) except NoNodeException: break except NotEmptyException: children = yield self.get_children(pa...
python
def recursive_delete(self, path, **kwargs): """Recursively delete path.""" while True: try: yield self.delete(path, **kwargs) except NoNodeException: break except NotEmptyException: children = yield self.get_children(pa...
[ "def", "recursive_delete", "(", "self", ",", "path", ",", "*", "*", "kwargs", ")", ":", "while", "True", ":", "try", ":", "yield", "self", ".", "delete", "(", "path", ",", "*", "*", "kwargs", ")", "except", "NoNodeException", ":", "break", "except", ...
Recursively delete path.
[ "Recursively", "delete", "path", "." ]
train
https://github.com/malthe/pop/blob/3b58b91b41d8b9bee546eb40dc280a57500b8bed/src/pop/client.py#L23-L36
malthe/pop
src/pop/client.py
ZookeeperClient.create_path
def create_path(self, path, **kwargs): """Create nodes required to complete path.""" i = 0 while i < len(path): i = path.find("/", i) if i < 0: return subpath = path[:i] if i > 0: try: yield s...
python
def create_path(self, path, **kwargs): """Create nodes required to complete path.""" i = 0 while i < len(path): i = path.find("/", i) if i < 0: return subpath = path[:i] if i > 0: try: yield s...
[ "def", "create_path", "(", "self", ",", "path", ",", "*", "*", "kwargs", ")", ":", "i", "=", "0", "while", "i", "<", "len", "(", "path", ")", ":", "i", "=", "path", ".", "find", "(", "\"/\"", ",", "i", ")", "if", "i", "<", "0", ":", "return...
Create nodes required to complete path.
[ "Create", "nodes", "required", "to", "complete", "path", "." ]
train
https://github.com/malthe/pop/blob/3b58b91b41d8b9bee546eb40dc280a57500b8bed/src/pop/client.py#L39-L57
malthe/pop
src/pop/client.py
ZookeeperClient.set_or_create
def set_or_create(self, path, *args, **kwargs): """Sets the data of a node at the given path, or creates it.""" d = self.set(path, *args, **kwargs) @d.addErrback def _error(result): return self.create(path, *args, **kwargs) return d
python
def set_or_create(self, path, *args, **kwargs): """Sets the data of a node at the given path, or creates it.""" d = self.set(path, *args, **kwargs) @d.addErrback def _error(result): return self.create(path, *args, **kwargs) return d
[ "def", "set_or_create", "(", "self", ",", "path", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "d", "=", "self", ".", "set", "(", "path", ",", "*", "args", ",", "*", "*", "kwargs", ")", "@", "d", ".", "addErrback", "def", "_error", "(",...
Sets the data of a node at the given path, or creates it.
[ "Sets", "the", "data", "of", "a", "node", "at", "the", "given", "path", "or", "creates", "it", "." ]
train
https://github.com/malthe/pop/blob/3b58b91b41d8b9bee546eb40dc280a57500b8bed/src/pop/client.py#L59-L68
malthe/pop
src/pop/client.py
ZookeeperClient.get_or_wait
def get_or_wait(self, path, name): """Get data of node under path, or wait for it.""" # First, get children and watch folder. d, watch = self.get_children_and_watch(path) deferred = Deferred() path += "/" + name @watch.addCallback def _notify(event): ...
python
def get_or_wait(self, path, name): """Get data of node under path, or wait for it.""" # First, get children and watch folder. d, watch = self.get_children_and_watch(path) deferred = Deferred() path += "/" + name @watch.addCallback def _notify(event): ...
[ "def", "get_or_wait", "(", "self", ",", "path", ",", "name", ")", ":", "# First, get children and watch folder.", "d", ",", "watch", "=", "self", ".", "get_children_and_watch", "(", "path", ")", "deferred", "=", "Deferred", "(", ")", "path", "+=", "\"/\"", "...
Get data of node under path, or wait for it.
[ "Get", "data", "of", "node", "under", "path", "or", "wait", "for", "it", "." ]
train
https://github.com/malthe/pop/blob/3b58b91b41d8b9bee546eb40dc280a57500b8bed/src/pop/client.py#L71-L94
ryanjdillon/pyotelem
pyotelem/utils.py
contiguous_regions
def contiguous_regions(condition): '''Finds contiguous True regions of the boolean array 'condition'. Args ---- condition: numpy.ndarray, dtype bool boolean mask array, but can pass the condition itself (e.g. x > 5) Returns ------- start_ind: numpy.ndarray, dtype int array ...
python
def contiguous_regions(condition): '''Finds contiguous True regions of the boolean array 'condition'. Args ---- condition: numpy.ndarray, dtype bool boolean mask array, but can pass the condition itself (e.g. x > 5) Returns ------- start_ind: numpy.ndarray, dtype int array ...
[ "def", "contiguous_regions", "(", "condition", ")", ":", "import", "numpy", "if", "condition", ".", "ndim", ">", "1", ":", "raise", "IndexError", "(", "'contiguous_regions(): condition must be 1-D'", ")", "# Find the indicies of changes in 'condition'", "idx", "=", "num...
Finds contiguous True regions of the boolean array 'condition'. Args ---- condition: numpy.ndarray, dtype bool boolean mask array, but can pass the condition itself (e.g. x > 5) Returns ------- start_ind: numpy.ndarray, dtype int array with the start indices for each contiguous...
[ "Finds", "contiguous", "True", "regions", "of", "the", "boolean", "array", "condition", "." ]
train
https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/utils.py#L20-L70
ryanjdillon/pyotelem
pyotelem/utils.py
rm_regions
def rm_regions(a, b, a_start_ind, a_stop_ind): '''Remove contiguous regions in `a` before region `b` Boolean arrays `a` and `b` should have alternating occuances of regions of `True` values. This routine removes additional contiguous regions in `a` that occur before a complimentary region in `b` has oc...
python
def rm_regions(a, b, a_start_ind, a_stop_ind): '''Remove contiguous regions in `a` before region `b` Boolean arrays `a` and `b` should have alternating occuances of regions of `True` values. This routine removes additional contiguous regions in `a` that occur before a complimentary region in `b` has oc...
[ "def", "rm_regions", "(", "a", ",", "b", ",", "a_start_ind", ",", "a_stop_ind", ")", ":", "import", "numpy", "for", "i", "in", "range", "(", "len", "(", "a_stop_ind", ")", ")", ":", "next_a_start", "=", "numpy", ".", "argmax", "(", "a", "[", "a_stop_...
Remove contiguous regions in `a` before region `b` Boolean arrays `a` and `b` should have alternating occuances of regions of `True` values. This routine removes additional contiguous regions in `a` that occur before a complimentary region in `b` has occured Args ---- a: ndarray Boolea...
[ "Remove", "contiguous", "regions", "in", "a", "before", "region", "b" ]
train
https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/utils.py#L73-L106
ryanjdillon/pyotelem
pyotelem/utils.py
recursive_input
def recursive_input(input_label, type_class): '''Recursive user input prompter with type checker Args ---- type_class: type name of python type (e.g. float, no parentheses) Returns ------- output: str value entered by user converted to type `type_class` Note ---- ...
python
def recursive_input(input_label, type_class): '''Recursive user input prompter with type checker Args ---- type_class: type name of python type (e.g. float, no parentheses) Returns ------- output: str value entered by user converted to type `type_class` Note ---- ...
[ "def", "recursive_input", "(", "input_label", ",", "type_class", ")", ":", "import", "sys", "type_str", "=", "str", "(", "type_class", ")", ".", "split", "(", "\"'\"", ")", "[", "1", "]", "msg", "=", "'Enter {} (type `{}`): '", ".", "format", "(", "input_l...
Recursive user input prompter with type checker Args ---- type_class: type name of python type (e.g. float, no parentheses) Returns ------- output: str value entered by user converted to type `type_class` Note ---- Use `ctrl-c` to exit input cycling
[ "Recursive", "user", "input", "prompter", "with", "type", "checker" ]
train
https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/utils.py#L109-L146
ryanjdillon/pyotelem
pyotelem/utils.py
get_dir_indices
def get_dir_indices(msg, dirs): '''Return path(s) indices of directory list from user input Args ---- msg: str String with message to display before pass selection input dir_list: array-like list of paths to be displayed and selected from Return ------ input_dir_indices...
python
def get_dir_indices(msg, dirs): '''Return path(s) indices of directory list from user input Args ---- msg: str String with message to display before pass selection input dir_list: array-like list of paths to be displayed and selected from Return ------ input_dir_indices...
[ "def", "get_dir_indices", "(", "msg", ",", "dirs", ")", ":", "import", "os", "# Get user input for paths to process", "usage", "=", "(", "'\\nEnter numbers preceeding paths seperated by commas (e.g. '", "'`0,2,3`).\\nTo select all paths type `all`.\\nSingle directories '", "'can also...
Return path(s) indices of directory list from user input Args ---- msg: str String with message to display before pass selection input dir_list: array-like list of paths to be displayed and selected from Return ------ input_dir_indices: array-like list of index posi...
[ "Return", "path", "(", "s", ")", "indices", "of", "directory", "list", "from", "user", "input" ]
train
https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/utils.py#L149-L190
minhhoit/yacms
yacms/pages/templatetags/pages_tags.py
page_menu
def page_menu(context, token): """ Return a list of child pages for the given parent, storing all pages in a dict in the context when first called using parents as keys for retrieval on subsequent recursive calls from the menu template. """ # First arg could be the menu template file name, or th...
python
def page_menu(context, token): """ Return a list of child pages for the given parent, storing all pages in a dict in the context when first called using parents as keys for retrieval on subsequent recursive calls from the menu template. """ # First arg could be the menu template file name, or th...
[ "def", "page_menu", "(", "context", ",", "token", ")", ":", "# First arg could be the menu template file name, or the parent page.", "# Also allow for both to be used.", "template_name", "=", "None", "parent_page", "=", "None", "parts", "=", "token", ".", "split_contents", ...
Return a list of child pages for the given parent, storing all pages in a dict in the context when first called using parents as keys for retrieval on subsequent recursive calls from the menu template.
[ "Return", "a", "list", "of", "child", "pages", "for", "the", "given", "parent", "storing", "all", "pages", "in", "a", "dict", "in", "the", "context", "when", "first", "called", "using", "parents", "as", "keys", "for", "retrieval", "on", "subsequent", "recu...
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/templatetags/pages_tags.py#L20-L134
minhhoit/yacms
yacms/pages/templatetags/pages_tags.py
models_for_pages
def models_for_pages(*args): """ Create a select list containing each of the models that subclass the ``Page`` model. """ from warnings import warn warn("template tag models_for_pages is deprectaed, use " "PageAdmin.get_content_models instead") from yacms.pages.admin import PageAdmin...
python
def models_for_pages(*args): """ Create a select list containing each of the models that subclass the ``Page`` model. """ from warnings import warn warn("template tag models_for_pages is deprectaed, use " "PageAdmin.get_content_models instead") from yacms.pages.admin import PageAdmin...
[ "def", "models_for_pages", "(", "*", "args", ")", ":", "from", "warnings", "import", "warn", "warn", "(", "\"template tag models_for_pages is deprectaed, use \"", "\"PageAdmin.get_content_models instead\"", ")", "from", "yacms", ".", "pages", ".", "admin", "import", "Pa...
Create a select list containing each of the models that subclass the ``Page`` model.
[ "Create", "a", "select", "list", "containing", "each", "of", "the", "models", "that", "subclass", "the", "Page", "model", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/templatetags/pages_tags.py#L138-L147
minhhoit/yacms
yacms/pages/templatetags/pages_tags.py
set_model_permissions
def set_model_permissions(context, token): """ Assigns a permissions dict to the given model, much like Django does with its dashboard app list. Used within the change list for pages, to implement permission checks for the navigation tree. """ model = context[token.split_contents()[1]] ...
python
def set_model_permissions(context, token): """ Assigns a permissions dict to the given model, much like Django does with its dashboard app list. Used within the change list for pages, to implement permission checks for the navigation tree. """ model = context[token.split_contents()[1]] ...
[ "def", "set_model_permissions", "(", "context", ",", "token", ")", ":", "model", "=", "context", "[", "token", ".", "split_contents", "(", ")", "[", "1", "]", "]", "opts", "=", "model", ".", "_meta", "perm_name", "=", "opts", ".", "app_label", "+", "\"...
Assigns a permissions dict to the given model, much like Django does with its dashboard app list. Used within the change list for pages, to implement permission checks for the navigation tree.
[ "Assigns", "a", "permissions", "dict", "to", "the", "given", "model", "much", "like", "Django", "does", "with", "its", "dashboard", "app", "list", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/templatetags/pages_tags.py#L151-L166
minhhoit/yacms
yacms/pages/templatetags/pages_tags.py
set_page_permissions
def set_page_permissions(context, token): """ Assigns a permissions dict to the given page instance, combining Django's permission for the page's model and a permission check against the instance itself calling the page's ``can_add``, ``can_change`` and ``can_delete`` custom methods. Used withi...
python
def set_page_permissions(context, token): """ Assigns a permissions dict to the given page instance, combining Django's permission for the page's model and a permission check against the instance itself calling the page's ``can_add``, ``can_change`` and ``can_delete`` custom methods. Used withi...
[ "def", "set_page_permissions", "(", "context", ",", "token", ")", ":", "page", "=", "context", "[", "token", ".", "split_contents", "(", ")", "[", "1", "]", "]", "model", "=", "page", ".", "get_content_model", "(", ")", "try", ":", "opts", "=", "model"...
Assigns a permissions dict to the given page instance, combining Django's permission for the page's model and a permission check against the instance itself calling the page's ``can_add``, ``can_change`` and ``can_delete`` custom methods. Used within the change list for pages, to implement permission ...
[ "Assigns", "a", "permissions", "dict", "to", "the", "given", "page", "instance", "combining", "Django", "s", "permission", "for", "the", "page", "s", "model", "and", "a", "permission", "check", "against", "the", "instance", "itself", "calling", "the", "page", ...
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/templatetags/pages_tags.py#L170-L203
af/turrentine
turrentine/models.py
CMSPageManager.create
def create(self, *args, **kwargs): """ Allow an 'author' kwarg to automatically fill in the created_by and last_modified_by fields. """ if kwargs.has_key('author'): kwargs['created_by'] = kwargs['author'] kwargs['last_modified_by'] = kwargs['author'] d...
python
def create(self, *args, **kwargs): """ Allow an 'author' kwarg to automatically fill in the created_by and last_modified_by fields. """ if kwargs.has_key('author'): kwargs['created_by'] = kwargs['author'] kwargs['last_modified_by'] = kwargs['author'] d...
[ "def", "create", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ".", "has_key", "(", "'author'", ")", ":", "kwargs", "[", "'created_by'", "]", "=", "kwargs", "[", "'author'", "]", "kwargs", "[", "'last_modified_by'", ...
Allow an 'author' kwarg to automatically fill in the created_by and last_modified_by fields.
[ "Allow", "an", "author", "kwarg", "to", "automatically", "fill", "in", "the", "created_by", "and", "last_modified_by", "fields", "." ]
train
https://github.com/af/turrentine/blob/bbbd5139744ccc6264595cc8960784e5c308c009/turrentine/models.py#L41-L49
af/turrentine
turrentine/models.py
CMSPage.get_template_options
def get_template_options(): """ Returns a list of all templates that can be used for CMS pages. The paths that are returned are relative to TURRENTINE_TEMPLATE_ROOT. """ template_root = turrentine_settings.TURRENTINE_TEMPLATE_ROOT turrentine_dir = turrentine_settings.TURR...
python
def get_template_options(): """ Returns a list of all templates that can be used for CMS pages. The paths that are returned are relative to TURRENTINE_TEMPLATE_ROOT. """ template_root = turrentine_settings.TURRENTINE_TEMPLATE_ROOT turrentine_dir = turrentine_settings.TURR...
[ "def", "get_template_options", "(", ")", ":", "template_root", "=", "turrentine_settings", ".", "TURRENTINE_TEMPLATE_ROOT", "turrentine_dir", "=", "turrentine_settings", ".", "TURRENTINE_TEMPLATE_SUBDIR", "output", "=", "[", "]", "for", "root", ",", "dirs", ",", "file...
Returns a list of all templates that can be used for CMS pages. The paths that are returned are relative to TURRENTINE_TEMPLATE_ROOT.
[ "Returns", "a", "list", "of", "all", "templates", "that", "can", "be", "used", "for", "CMS", "pages", ".", "The", "paths", "that", "are", "returned", "are", "relative", "to", "TURRENTINE_TEMPLATE_ROOT", "." ]
train
https://github.com/af/turrentine/blob/bbbd5139744ccc6264595cc8960784e5c308c009/turrentine/models.py#L88-L101
kshlm/gant
gant/utils/ssh.py
launch_shell
def launch_shell(username, hostname, password, port=22): """ Launches an ssh shell """ if not username or not hostname or not password: return False with tempfile.NamedTemporaryFile() as tmpFile: os.system(sshCmdLine.format(password, tmpFile.name, username, hostname, ...
python
def launch_shell(username, hostname, password, port=22): """ Launches an ssh shell """ if not username or not hostname or not password: return False with tempfile.NamedTemporaryFile() as tmpFile: os.system(sshCmdLine.format(password, tmpFile.name, username, hostname, ...
[ "def", "launch_shell", "(", "username", ",", "hostname", ",", "password", ",", "port", "=", "22", ")", ":", "if", "not", "username", "or", "not", "hostname", "or", "not", "password", ":", "return", "False", "with", "tempfile", ".", "NamedTemporaryFile", "(...
Launches an ssh shell
[ "Launches", "an", "ssh", "shell" ]
train
https://github.com/kshlm/gant/blob/eabaa17ebfd31b1654ee1f27e7026f6d7b370609/gant/utils/ssh.py#L10-L20
cariad/py-wpconfigr
wpconfigr/wp_config_string.py
WpConfigString._get_match
def _get_match(self, key): """ Gets a MatchObject for the given key. Args: key (str): Key of the property to look-up. Return: MatchObject: The discovered match. """ return self._get_string_match(key=key) or \ self._get_non_string_mat...
python
def _get_match(self, key): """ Gets a MatchObject for the given key. Args: key (str): Key of the property to look-up. Return: MatchObject: The discovered match. """ return self._get_string_match(key=key) or \ self._get_non_string_mat...
[ "def", "_get_match", "(", "self", ",", "key", ")", ":", "return", "self", ".", "_get_string_match", "(", "key", "=", "key", ")", "or", "self", ".", "_get_non_string_match", "(", "key", "=", "key", ")" ]
Gets a MatchObject for the given key. Args: key (str): Key of the property to look-up. Return: MatchObject: The discovered match.
[ "Gets", "a", "MatchObject", "for", "the", "given", "key", "." ]
train
https://github.com/cariad/py-wpconfigr/blob/8f25bb849b72ce95957566544a2be8445316c818/wpconfigr/wp_config_string.py#L29-L41
cariad/py-wpconfigr
wpconfigr/wp_config_string.py
WpConfigString._get_non_string_match
def _get_non_string_match(self, key): """ Gets a MatchObject for the given key, assuming a non-string value. Args: key (str): Key of the property to look-up. Return: MatchObject: The discovered match. """ expression = r'(?:\s*)'.join([ ...
python
def _get_non_string_match(self, key): """ Gets a MatchObject for the given key, assuming a non-string value. Args: key (str): Key of the property to look-up. Return: MatchObject: The discovered match. """ expression = r'(?:\s*)'.join([ ...
[ "def", "_get_non_string_match", "(", "self", ",", "key", ")", ":", "expression", "=", "r'(?:\\s*)'", ".", "join", "(", "[", "'^'", ",", "'define'", ",", "r'\\('", ",", "'\\'{}\\''", ".", "format", "(", "key", ")", ",", "','", ",", "r'(.*)'", ",", "r'\\...
Gets a MatchObject for the given key, assuming a non-string value. Args: key (str): Key of the property to look-up. Return: MatchObject: The discovered match.
[ "Gets", "a", "MatchObject", "for", "the", "given", "key", "assuming", "a", "non", "-", "string", "value", "." ]
train
https://github.com/cariad/py-wpconfigr/blob/8f25bb849b72ce95957566544a2be8445316c818/wpconfigr/wp_config_string.py#L43-L66
cariad/py-wpconfigr
wpconfigr/wp_config_string.py
WpConfigString._get_string_match
def _get_string_match(self, key): """ Gets a MatchObject for the given key, assuming a string value. Args: key (str): Key of the property to look-up. Return: MatchObject: The discovered match. """ expression = r'(?:\s*)'.join([ '^', ...
python
def _get_string_match(self, key): """ Gets a MatchObject for the given key, assuming a string value. Args: key (str): Key of the property to look-up. Return: MatchObject: The discovered match. """ expression = r'(?:\s*)'.join([ '^', ...
[ "def", "_get_string_match", "(", "self", ",", "key", ")", ":", "expression", "=", "r'(?:\\s*)'", ".", "join", "(", "[", "'^'", ",", "'define'", ",", "r'\\('", ",", "'\\'{}\\''", ".", "format", "(", "key", ")", ",", "','", ",", "r'\\'(.*)\\''", ",", "r'...
Gets a MatchObject for the given key, assuming a string value. Args: key (str): Key of the property to look-up. Return: MatchObject: The discovered match.
[ "Gets", "a", "MatchObject", "for", "the", "given", "key", "assuming", "a", "string", "value", "." ]
train
https://github.com/cariad/py-wpconfigr/blob/8f25bb849b72ce95957566544a2be8445316c818/wpconfigr/wp_config_string.py#L68-L91
cariad/py-wpconfigr
wpconfigr/wp_config_string.py
WpConfigString._get_value_from_match
def _get_value_from_match(self, key, match): """ Gets the value of the property in the given MatchObject. Args: key (str): Key of the property looked-up. match (MatchObject): The matched property. Return: The discovered value, as a string o...
python
def _get_value_from_match(self, key, match): """ Gets the value of the property in the given MatchObject. Args: key (str): Key of the property looked-up. match (MatchObject): The matched property. Return: The discovered value, as a string o...
[ "def", "_get_value_from_match", "(", "self", ",", "key", ",", "match", ")", ":", "value", "=", "match", ".", "groups", "(", "1", ")", "[", "0", "]", "clean_value", "=", "str", "(", "value", ")", ".", "lstrip", "(", ")", ".", "rstrip", "(", ")", "...
Gets the value of the property in the given MatchObject. Args: key (str): Key of the property looked-up. match (MatchObject): The matched property. Return: The discovered value, as a string or boolean.
[ "Gets", "the", "value", "of", "the", "property", "in", "the", "given", "MatchObject", "." ]
train
https://github.com/cariad/py-wpconfigr/blob/8f25bb849b72ce95957566544a2be8445316c818/wpconfigr/wp_config_string.py#L93-L126
cariad/py-wpconfigr
wpconfigr/wp_config_string.py
WpConfigString.get
def get(self, key): """ Gets the value of the property of the given key. Args: key (str): Key of the property to look-up. """ match = self._get_match(key=key) if not match: return None return self._get_value_from_match(key=key, match=ma...
python
def get(self, key): """ Gets the value of the property of the given key. Args: key (str): Key of the property to look-up. """ match = self._get_match(key=key) if not match: return None return self._get_value_from_match(key=key, match=ma...
[ "def", "get", "(", "self", ",", "key", ")", ":", "match", "=", "self", ".", "_get_match", "(", "key", "=", "key", ")", "if", "not", "match", ":", "return", "None", "return", "self", ".", "_get_value_from_match", "(", "key", "=", "key", ",", "match", ...
Gets the value of the property of the given key. Args: key (str): Key of the property to look-up.
[ "Gets", "the", "value", "of", "the", "property", "of", "the", "given", "key", "." ]
train
https://github.com/cariad/py-wpconfigr/blob/8f25bb849b72ce95957566544a2be8445316c818/wpconfigr/wp_config_string.py#L128-L141
cariad/py-wpconfigr
wpconfigr/wp_config_string.py
WpConfigString.set
def set(self, key, value): """ Updates the value of the given key in the loaded content. Args: key (str): Key of the property to update. value (str): New value of the property. Return: bool: Indicates whether or not a change was made. """ ...
python
def set(self, key, value): """ Updates the value of the given key in the loaded content. Args: key (str): Key of the property to update. value (str): New value of the property. Return: bool: Indicates whether or not a change was made. """ ...
[ "def", "set", "(", "self", ",", "key", ",", "value", ")", ":", "match", "=", "self", ".", "_get_match", "(", "key", "=", "key", ")", "if", "not", "match", ":", "self", ".", "_log", ".", "info", "(", "'\"%s\" does not exist, so it will be added.'", ",", ...
Updates the value of the given key in the loaded content. Args: key (str): Key of the property to update. value (str): New value of the property. Return: bool: Indicates whether or not a change was made.
[ "Updates", "the", "value", "of", "the", "given", "key", "in", "the", "loaded", "content", "." ]
train
https://github.com/cariad/py-wpconfigr/blob/8f25bb849b72ce95957566544a2be8445316c818/wpconfigr/wp_config_string.py#L143-L204
pingviini/aja
src/aja/utils.py
get_buildout_config
def get_buildout_config(buildout_filename): """Parse buildout config with zc.buildout ConfigParser """ print("[localhost] get_buildout_config: {0:s}".format(buildout_filename)) buildout = Buildout(buildout_filename, [('buildout', 'verbosity', '-100')]) while True: try: len(buildo...
python
def get_buildout_config(buildout_filename): """Parse buildout config with zc.buildout ConfigParser """ print("[localhost] get_buildout_config: {0:s}".format(buildout_filename)) buildout = Buildout(buildout_filename, [('buildout', 'verbosity', '-100')]) while True: try: len(buildo...
[ "def", "get_buildout_config", "(", "buildout_filename", ")", ":", "print", "(", "\"[localhost] get_buildout_config: {0:s}\"", ".", "format", "(", "buildout_filename", ")", ")", "buildout", "=", "Buildout", "(", "buildout_filename", ",", "[", "(", "'buildout'", ",", ...
Parse buildout config with zc.buildout ConfigParser
[ "Parse", "buildout", "config", "with", "zc", ".", "buildout", "ConfigParser" ]
train
https://github.com/pingviini/aja/blob/60ce80aee082b7a1ea9c55471c6e717c9b46710f/src/aja/utils.py#L30-L41
pingviini/aja
src/aja/utils.py
get_buildout_parts
def get_buildout_parts(buildout, query=None): """Return buildout parts matching the given query """ parts = names = (buildout['buildout'].get('parts') or '').split('\n') for name in names: part = buildout.get(name) or {} for key, value in (query or {}).items(): if value not i...
python
def get_buildout_parts(buildout, query=None): """Return buildout parts matching the given query """ parts = names = (buildout['buildout'].get('parts') or '').split('\n') for name in names: part = buildout.get(name) or {} for key, value in (query or {}).items(): if value not i...
[ "def", "get_buildout_parts", "(", "buildout", ",", "query", "=", "None", ")", ":", "parts", "=", "names", "=", "(", "buildout", "[", "'buildout'", "]", ".", "get", "(", "'parts'", ")", "or", "''", ")", ".", "split", "(", "'\\n'", ")", "for", "name", ...
Return buildout parts matching the given query
[ "Return", "buildout", "parts", "matching", "the", "given", "query" ]
train
https://github.com/pingviini/aja/blob/60ce80aee082b7a1ea9c55471c6e717c9b46710f/src/aja/utils.py#L44-L54
pingviini/aja
src/aja/utils.py
get_buildout_eggs
def get_buildout_eggs(buildout, query=None): """Return buildout eggs matching the parts for the given query """ eggs = set() for name in get_buildout_parts(buildout, query=query): if name == 'buildout': continue # skip eggs from the buildout script itself path = os.path.join...
python
def get_buildout_eggs(buildout, query=None): """Return buildout eggs matching the parts for the given query """ eggs = set() for name in get_buildout_parts(buildout, query=query): if name == 'buildout': continue # skip eggs from the buildout script itself path = os.path.join...
[ "def", "get_buildout_eggs", "(", "buildout", ",", "query", "=", "None", ")", ":", "eggs", "=", "set", "(", ")", "for", "name", "in", "get_buildout_parts", "(", "buildout", ",", "query", "=", "query", ")", ":", "if", "name", "==", "'buildout'", ":", "co...
Return buildout eggs matching the parts for the given query
[ "Return", "buildout", "eggs", "matching", "the", "parts", "for", "the", "given", "query" ]
train
https://github.com/pingviini/aja/blob/60ce80aee082b7a1ea9c55471c6e717c9b46710f/src/aja/utils.py#L57-L67
pingviini/aja
src/aja/utils.py
parse_eggs_list
def parse_eggs_list(path): """Parse eggs list from the script at the given path """ with open(path, 'r') as script: data = script.readlines() start = 0 end = 0 for counter, line in enumerate(data): if not start: if 'sys.path[0:0]' in line: ...
python
def parse_eggs_list(path): """Parse eggs list from the script at the given path """ with open(path, 'r') as script: data = script.readlines() start = 0 end = 0 for counter, line in enumerate(data): if not start: if 'sys.path[0:0]' in line: ...
[ "def", "parse_eggs_list", "(", "path", ")", ":", "with", "open", "(", "path", ",", "'r'", ")", "as", "script", ":", "data", "=", "script", ".", "readlines", "(", ")", "start", "=", "0", "end", "=", "0", "for", "counter", ",", "line", "in", "enumera...
Parse eggs list from the script at the given path
[ "Parse", "eggs", "list", "from", "the", "script", "at", "the", "given", "path" ]
train
https://github.com/pingviini/aja/blob/60ce80aee082b7a1ea9c55471c6e717c9b46710f/src/aja/utils.py#L70-L85
pingviini/aja
src/aja/utils.py
tidy_eggs_list
def tidy_eggs_list(eggs_list): """Tidy the given eggs list """ tmp = [] for line in eggs_list: line = line.lstrip().rstrip() line = line.replace('\'', '') line = line.replace(',', '') if line.endswith('site-packages'): continue tmp.append(line) ret...
python
def tidy_eggs_list(eggs_list): """Tidy the given eggs list """ tmp = [] for line in eggs_list: line = line.lstrip().rstrip() line = line.replace('\'', '') line = line.replace(',', '') if line.endswith('site-packages'): continue tmp.append(line) ret...
[ "def", "tidy_eggs_list", "(", "eggs_list", ")", ":", "tmp", "=", "[", "]", "for", "line", "in", "eggs_list", ":", "line", "=", "line", ".", "lstrip", "(", ")", ".", "rstrip", "(", ")", "line", "=", "line", ".", "replace", "(", "'\\''", ",", "''", ...
Tidy the given eggs list
[ "Tidy", "the", "given", "eggs", "list" ]
train
https://github.com/pingviini/aja/blob/60ce80aee082b7a1ea9c55471c6e717c9b46710f/src/aja/utils.py#L88-L99
heikomuller/sco-client
scocli/modelrun.py
Attachment.download
def download(self, filename=None): """Download an attachment. The files are currently not cached since they can be overwritten on the server. Parameters ---------- filename : string, optional Optional name for the file on local disk. Returns ------- ...
python
def download(self, filename=None): """Download an attachment. The files are currently not cached since they can be overwritten on the server. Parameters ---------- filename : string, optional Optional name for the file on local disk. Returns ------- ...
[ "def", "download", "(", "self", ",", "filename", "=", "None", ")", ":", "tmp_file", ",", "f_suffix", "=", "download_file", "(", "self", ".", "url", ")", "if", "not", "filename", "is", "None", ":", "shutil", ".", "move", "(", "tmp_file", ",", "filename"...
Download an attachment. The files are currently not cached since they can be overwritten on the server. Parameters ---------- filename : string, optional Optional name for the file on local disk. Returns ------- string Path to downloaded ...
[ "Download", "an", "attachment", ".", "The", "files", "are", "currently", "not", "cached", "since", "they", "can", "be", "overwritten", "on", "the", "server", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/modelrun.py#L68-L87
heikomuller/sco-client
scocli/modelrun.py
ModelRunHandle.attach_file
def attach_file(self, filename, resource_id=None): """Upload an attachment for the model run. Paramerers ---------- filename : string Path to uploaded file resource_id : string Identifier of the attachment. If None, the filename will be used as ...
python
def attach_file(self, filename, resource_id=None): """Upload an attachment for the model run. Paramerers ---------- filename : string Path to uploaded file resource_id : string Identifier of the attachment. If None, the filename will be used as ...
[ "def", "attach_file", "(", "self", ",", "filename", ",", "resource_id", "=", "None", ")", ":", "# Use file base name as resource identifier if none given", "if", "resource_id", "is", "None", ":", "resource_id", "=", "os", ".", "path", ".", "basename", "(", "filena...
Upload an attachment for the model run. Paramerers ---------- filename : string Path to uploaded file resource_id : string Identifier of the attachment. If None, the filename will be used as resource identifier. Returns ------- ...
[ "Upload", "an", "attachment", "for", "the", "model", "run", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/modelrun.py#L275-L308
heikomuller/sco-client
scocli/modelrun.py
ModelRunHandle.create
def create(url, model_id, name, arguments, properties=None): """Create a new model run using the given SCO-API create model run Url. Parameters ---------- url : string Url to POST model run create model run request model_id : string Unique model identifie...
python
def create(url, model_id, name, arguments, properties=None): """Create a new model run using the given SCO-API create model run Url. Parameters ---------- url : string Url to POST model run create model run request model_id : string Unique model identifie...
[ "def", "create", "(", "url", ",", "model_id", ",", "name", ",", "arguments", ",", "properties", "=", "None", ")", ":", "# Create list of model run arguments. Catch TypeErrors if arguments is", "# not a list.", "obj_args", "=", "[", "]", "try", ":", "for", "arg", "...
Create a new model run using the given SCO-API create model run Url. Parameters ---------- url : string Url to POST model run create model run request model_id : string Unique model identifier name : string User-defined name for model run ...
[ "Create", "a", "new", "model", "run", "using", "the", "given", "SCO", "-", "API", "create", "model", "run", "Url", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/modelrun.py#L311-L365
heikomuller/sco-client
scocli/modelrun.py
ModelRunHandle.update_state
def update_state(url, state_obj): """Update the state of a given model run. The state object is a Json representation of the state as created by the SCO-Server. Throws a ValueError if the resource is unknown or the update state request failed. Parameters ---------- ...
python
def update_state(url, state_obj): """Update the state of a given model run. The state object is a Json representation of the state as created by the SCO-Server. Throws a ValueError if the resource is unknown or the update state request failed. Parameters ---------- ...
[ "def", "update_state", "(", "url", ",", "state_obj", ")", ":", "# POST update run state request", "try", ":", "req", "=", "urllib2", ".", "Request", "(", "url", ")", "req", ".", "add_header", "(", "'Content-Type'", ",", "'application/json'", ")", "response", "...
Update the state of a given model run. The state object is a Json representation of the state as created by the SCO-Server. Throws a ValueError if the resource is unknown or the update state request failed. Parameters ---------- url : string Url to POST mode...
[ "Update", "the", "state", "of", "a", "given", "model", "run", ".", "The", "state", "object", "is", "a", "Json", "representation", "of", "the", "state", "as", "created", "by", "the", "SCO", "-", "Server", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/modelrun.py#L403-L428
heikomuller/sco-client
scocli/modelrun.py
ModelRunHandle.update_state_active
def update_state_active(self): """Update the state of the model run to active. Raises an exception if update fails or resource is unknown. Returns ------- ModelRunHandle Refreshed run handle. """ # Update state to active self.update_state(sel...
python
def update_state_active(self): """Update the state of the model run to active. Raises an exception if update fails or resource is unknown. Returns ------- ModelRunHandle Refreshed run handle. """ # Update state to active self.update_state(sel...
[ "def", "update_state_active", "(", "self", ")", ":", "# Update state to active", "self", ".", "update_state", "(", "self", ".", "links", "[", "REF_UPDATE_STATE_ACTIVE", "]", ",", "{", "'type'", ":", "RUN_ACTIVE", "}", ")", "# Returned refreshed verion of the handle", ...
Update the state of the model run to active. Raises an exception if update fails or resource is unknown. Returns ------- ModelRunHandle Refreshed run handle.
[ "Update", "the", "state", "of", "the", "model", "run", "to", "active", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/modelrun.py#L430-L443
heikomuller/sco-client
scocli/modelrun.py
ModelRunHandle.update_state_error
def update_state_error(self, errors): """Update the state of the model run to 'FAILED'. Expects a list of error messages. Raises an exception if update fails or resource is unknown. Parameters ---------- errors : List(string) List of error messages ...
python
def update_state_error(self, errors): """Update the state of the model run to 'FAILED'. Expects a list of error messages. Raises an exception if update fails or resource is unknown. Parameters ---------- errors : List(string) List of error messages ...
[ "def", "update_state_error", "(", "self", ",", "errors", ")", ":", "# Update state to active", "self", ".", "update_state", "(", "self", ".", "links", "[", "REF_UPDATE_STATE_ERROR", "]", ",", "{", "'type'", ":", "RUN_FAILED", ",", "'errors'", ":", "errors", "}...
Update the state of the model run to 'FAILED'. Expects a list of error messages. Raises an exception if update fails or resource is unknown. Parameters ---------- errors : List(string) List of error messages Returns ------- ModelRunHandle ...
[ "Update", "the", "state", "of", "the", "model", "run", "to", "FAILED", ".", "Expects", "a", "list", "of", "error", "messages", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/modelrun.py#L445-L467
heikomuller/sco-client
scocli/modelrun.py
ModelRunHandle.update_state_success
def update_state_success(self, model_output): """Update the state of the model run to 'SUCCESS'. Expects a model output result file. Will upload the file before changing the model run state. Raises an exception if update fails or resource is unknown. Parameters --------...
python
def update_state_success(self, model_output): """Update the state of the model run to 'SUCCESS'. Expects a model output result file. Will upload the file before changing the model run state. Raises an exception if update fails or resource is unknown. Parameters --------...
[ "def", "update_state_success", "(", "self", ",", "model_output", ")", ":", "# Upload model output", "response", "=", "requests", ".", "post", "(", "self", ".", "links", "[", "REF_UPDATE_STATE_SUCCESS", "]", ",", "files", "=", "{", "'file'", ":", "open", "(", ...
Update the state of the model run to 'SUCCESS'. Expects a model output result file. Will upload the file before changing the model run state. Raises an exception if update fails or resource is unknown. Parameters ---------- model_output : string Path to mode...
[ "Update", "the", "state", "of", "the", "model", "run", "to", "SUCCESS", ".", "Expects", "a", "model", "output", "result", "file", ".", "Will", "upload", "the", "file", "before", "changing", "the", "model", "run", "state", "." ]
train
https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/modelrun.py#L469-L497
cirruscluster/cirruscluster
cirruscluster/workstation.py
CirrusIamUserReady
def CirrusIamUserReady(iam_aws_id, iam_aws_secret): """ Returns true if provided IAM credentials are ready to use. """ is_ready = False try: s3 = core.CreateTestedS3Connection(iam_aws_id, iam_aws_secret) if s3: if core.CirrusAccessIdMetadata(s3, iam_aws_id).IsInitialized(): is_ready = True ...
python
def CirrusIamUserReady(iam_aws_id, iam_aws_secret): """ Returns true if provided IAM credentials are ready to use. """ is_ready = False try: s3 = core.CreateTestedS3Connection(iam_aws_id, iam_aws_secret) if s3: if core.CirrusAccessIdMetadata(s3, iam_aws_id).IsInitialized(): is_ready = True ...
[ "def", "CirrusIamUserReady", "(", "iam_aws_id", ",", "iam_aws_secret", ")", ":", "is_ready", "=", "False", "try", ":", "s3", "=", "core", ".", "CreateTestedS3Connection", "(", "iam_aws_id", ",", "iam_aws_secret", ")", "if", "s3", ":", "if", "core", ".", "Cir...
Returns true if provided IAM credentials are ready to use.
[ "Returns", "true", "if", "provided", "IAM", "credentials", "are", "ready", "to", "use", "." ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/workstation.py#L60-L71
cirruscluster/cirruscluster
cirruscluster/workstation.py
NoSuchEntityOk
def NoSuchEntityOk(f): """ Decorator to remove NoSuchEntity exceptions, and raises all others. """ def ExceptionFilter(*args): try: return f(*args) except boto.exception.BotoServerError as e: if e.error_code == 'NoSuchEntity': pass else: raise except: raise ...
python
def NoSuchEntityOk(f): """ Decorator to remove NoSuchEntity exceptions, and raises all others. """ def ExceptionFilter(*args): try: return f(*args) except boto.exception.BotoServerError as e: if e.error_code == 'NoSuchEntity': pass else: raise except: raise ...
[ "def", "NoSuchEntityOk", "(", "f", ")", ":", "def", "ExceptionFilter", "(", "*", "args", ")", ":", "try", ":", "return", "f", "(", "*", "args", ")", "except", "boto", ".", "exception", ".", "BotoServerError", "as", "e", ":", "if", "e", ".", "error_co...
Decorator to remove NoSuchEntity exceptions, and raises all others.
[ "Decorator", "to", "remove", "NoSuchEntity", "exceptions", "and", "raises", "all", "others", "." ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/workstation.py#L78-L91
cirruscluster/cirruscluster
cirruscluster/workstation.py
CirrusIamUserManager.__IsInitialized
def __IsInitialized(self): """ Returns true if IAM user initialization has completed. """ is_initialized = False iam_id = self.GetAccessKeyId() if iam_id: if core.CirrusAccessIdMetadata(self.s3, iam_id).IsInitialized(): is_initialized = True return is_initialized
python
def __IsInitialized(self): """ Returns true if IAM user initialization has completed. """ is_initialized = False iam_id = self.GetAccessKeyId() if iam_id: if core.CirrusAccessIdMetadata(self.s3, iam_id).IsInitialized(): is_initialized = True return is_initialized
[ "def", "__IsInitialized", "(", "self", ")", ":", "is_initialized", "=", "False", "iam_id", "=", "self", ".", "GetAccessKeyId", "(", ")", "if", "iam_id", ":", "if", "core", ".", "CirrusAccessIdMetadata", "(", "self", ".", "s3", ",", "iam_id", ")", ".", "I...
Returns true if IAM user initialization has completed.
[ "Returns", "true", "if", "IAM", "user", "initialization", "has", "completed", "." ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/workstation.py#L116-L123
cirruscluster/cirruscluster
cirruscluster/workstation.py
CirrusIamUserManager.__WaitForCredentialsLive
def __WaitForCredentialsLive(self, iam_aws_id, iam_aws_secret): """ Wait until the new credentials are accepted in all regions and for ec2 and boto services. If we don't do this, we may have a race condition where calls fail (and we can't tell if the credentials are bad (stop) or not yet valid (keep trying))...
python
def __WaitForCredentialsLive(self, iam_aws_id, iam_aws_secret): """ Wait until the new credentials are accepted in all regions and for ec2 and boto services. If we don't do this, we may have a race condition where calls fail (and we can't tell if the credentials are bad (stop) or not yet valid (keep trying))...
[ "def", "__WaitForCredentialsLive", "(", "self", ",", "iam_aws_id", ",", "iam_aws_secret", ")", ":", "print", "'waiting for credentials to go live...'", "for", "region", "in", "core", ".", "tested_region_names", ":", "core", ".", "WaitForEc2Connection", "(", "iam_aws_id"...
Wait until the new credentials are accepted in all regions and for ec2 and boto services. If we don't do this, we may have a race condition where calls fail (and we can't tell if the credentials are bad (stop) or not yet valid (keep trying))
[ "Wait", "until", "the", "new", "credentials", "are", "accepted", "in", "all", "regions", "and", "for", "ec2", "and", "boto", "services", ".", "If", "we", "don", "t", "do", "this", "we", "may", "have", "a", "race", "condition", "where", "calls", "fail", ...
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/workstation.py#L203-L213
cirruscluster/cirruscluster
cirruscluster/workstation.py
Manager.AddNewVolumeToInstance
def AddNewVolumeToInstance(self, instance_id, vol_size_gb): """ Returns the volume id added... mount point is /mnt/vol-<id>/. """ assert(vol_size_gb >= 1) if vol_size_gb > 1000: # probably spending too much if you go bigger raise RuntimeError('Adding volumes this large has not been tested.') insta...
python
def AddNewVolumeToInstance(self, instance_id, vol_size_gb): """ Returns the volume id added... mount point is /mnt/vol-<id>/. """ assert(vol_size_gb >= 1) if vol_size_gb > 1000: # probably spending too much if you go bigger raise RuntimeError('Adding volumes this large has not been tested.') insta...
[ "def", "AddNewVolumeToInstance", "(", "self", ",", "instance_id", ",", "vol_size_gb", ")", ":", "assert", "(", "vol_size_gb", ">=", "1", ")", "if", "vol_size_gb", ">", "1000", ":", "# probably spending too much if you go bigger", "raise", "RuntimeError", "(", "'Addi...
Returns the volume id added... mount point is /mnt/vol-<id>/.
[ "Returns", "the", "volume", "id", "added", "...", "mount", "point", "is", "/", "mnt", "/", "vol", "-", "<id", ">", "/", "." ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/workstation.py#L413-L453
cirruscluster/cirruscluster
cirruscluster/workstation.py
Manager.__GetInstances
def __GetInstances(self, group_name = None, state_filter=None): """ Get all the instances in a group, filtered by state. @param group_name: the name of the group @param state_filter: the state that the instance should be in (e.g. "running"), or None for all states """ all_instances = self...
python
def __GetInstances(self, group_name = None, state_filter=None): """ Get all the instances in a group, filtered by state. @param group_name: the name of the group @param state_filter: the state that the instance should be in (e.g. "running"), or None for all states """ all_instances = self...
[ "def", "__GetInstances", "(", "self", ",", "group_name", "=", "None", ",", "state_filter", "=", "None", ")", ":", "all_instances", "=", "self", ".", "ec2", ".", "get_all_instances", "(", ")", "instances", "=", "[", "]", "for", "res", "in", "all_instances",...
Get all the instances in a group, filtered by state. @param group_name: the name of the group @param state_filter: the state that the instance should be in (e.g. "running"), or None for all states
[ "Get", "all", "the", "instances", "in", "a", "group", "filtered", "by", "state", "." ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/workstation.py#L487-L504
spookey/photon
photon/meta.py
Meta.stage
def stage(self, name, clean=False): ''' Switch stage :param name: Filename of new meta file. |filelocate| * File must not already exist, will be created in 'data_dir' \ from :func:`util.locations.get_locations` * Can also be a full path to place...
python
def stage(self, name, clean=False): ''' Switch stage :param name: Filename of new meta file. |filelocate| * File must not already exist, will be created in 'data_dir' \ from :func:`util.locations.get_locations` * Can also be a full path to place...
[ "def", "stage", "(", "self", ",", "name", ",", "clean", "=", "False", ")", ":", "name", "=", "search_location", "(", "name", ",", "create_in", "=", "'data_dir'", ")", "if", "not", "clean", ":", "self", ".", "load", "(", "'stage'", ",", "name", ",", ...
Switch stage :param name: Filename of new meta file. |filelocate| * File must not already exist, will be created in 'data_dir' \ from :func:`util.locations.get_locations` * Can also be a full path to place it anywhere desired :param clean: What to do w...
[ "Switch", "stage" ]
train
https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/meta.py#L43-L70
spookey/photon
photon/meta.py
Meta.load
def load(self, mkey, mdesc, mdict=None, merge=False): ''' Loads a dictionary into current meta :param mkey: Type of data to load. Is be used to reference the data from the 'header' within meta :param mdesc: Either filename of json-file to load or furt...
python
def load(self, mkey, mdesc, mdict=None, merge=False): ''' Loads a dictionary into current meta :param mkey: Type of data to load. Is be used to reference the data from the 'header' within meta :param mdesc: Either filename of json-file to load or furt...
[ "def", "load", "(", "self", ",", "mkey", ",", "mdesc", ",", "mdict", "=", "None", ",", "merge", "=", "False", ")", ":", "j", "=", "mdict", "if", "mdict", "else", "read_json", "(", "mdesc", ")", "if", "j", "and", "isinstance", "(", "j", ",", "dict...
Loads a dictionary into current meta :param mkey: Type of data to load. Is be used to reference the data from the 'header' within meta :param mdesc: Either filename of json-file to load or further description of imported data when `mdict` is used ...
[ "Loads", "a", "dictionary", "into", "current", "meta" ]
train
https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/meta.py#L72-L108