id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
248,500 | Mollom/mollom_python | mollom/mollom.py | Mollom.verify_keys | def verify_keys(self):
"""Verify that the public and private key combination is valid; raises MollomAuthenticationError otherwise"""
verify_keys_endpoint = Template("${rest_root}/site/${public_key}")
url = verify_keys_endpoint.substitute(rest_root=self._rest_root, public_key=self._public_key)
... | python | def verify_keys(self):
"""Verify that the public and private key combination is valid; raises MollomAuthenticationError otherwise"""
verify_keys_endpoint = Template("${rest_root}/site/${public_key}")
url = verify_keys_endpoint.substitute(rest_root=self._rest_root, public_key=self._public_key)
... | [
"def",
"verify_keys",
"(",
"self",
")",
":",
"verify_keys_endpoint",
"=",
"Template",
"(",
"\"${rest_root}/site/${public_key}\"",
")",
"url",
"=",
"verify_keys_endpoint",
".",
"substitute",
"(",
"rest_root",
"=",
"self",
".",
"_rest_root",
",",
"public_key",
"=",
... | Verify that the public and private key combination is valid; raises MollomAuthenticationError otherwise | [
"Verify",
"that",
"the",
"public",
"and",
"private",
"key",
"combination",
"is",
"valid",
";",
"raises",
"MollomAuthenticationError",
"otherwise"
] | dfacb63fd79f82c0eabde76b511116df5b51d6f1 | https://github.com/Mollom/mollom_python/blob/dfacb63fd79f82c0eabde76b511116df5b51d6f1/mollom/mollom.py#L49-L62 |
248,501 | Mollom/mollom_python | mollom/mollom.py | Mollom.check_captcha | def check_captcha(self,
captcha_id,
solution,
author_name=None,
author_url=None,
author_mail=None,
author_ip=None,
author_id=None,
author_o... | python | def check_captcha(self,
captcha_id,
solution,
author_name=None,
author_url=None,
author_mail=None,
author_ip=None,
author_id=None,
author_o... | [
"def",
"check_captcha",
"(",
"self",
",",
"captcha_id",
",",
"solution",
",",
"author_name",
"=",
"None",
",",
"author_url",
"=",
"None",
",",
"author_mail",
"=",
"None",
",",
"author_ip",
"=",
"None",
",",
"author_id",
"=",
"None",
",",
"author_open_id",
... | Checks a CAPTCHA that was solved by the end-user.
Keyword arguments:
captcha_id -- Unique identifier of the CAPTCHA solved.
solution -- Solution provided by the end-user for the CAPTCHA.
author_name -- The name of the content author.
author_url -- The homepage/website URL of the... | [
"Checks",
"a",
"CAPTCHA",
"that",
"was",
"solved",
"by",
"the",
"end",
"-",
"user",
"."
] | dfacb63fd79f82c0eabde76b511116df5b51d6f1 | https://github.com/Mollom/mollom_python/blob/dfacb63fd79f82c0eabde76b511116df5b51d6f1/mollom/mollom.py#L211-L246 |
248,502 | Mollom/mollom_python | mollom/mollom.py | Mollom.get_blacklist_entries | def get_blacklist_entries(self):
"""Get a list of all blacklist entries.
"""
get_blacklist_entries_endpoint = Template("${rest_root}/blacklist/${public_key}/")
url = get_blacklist_entries_endpoint.substitute(rest_root=self._rest_root, public_key=self._public_key)
response = sel... | python | def get_blacklist_entries(self):
"""Get a list of all blacklist entries.
"""
get_blacklist_entries_endpoint = Template("${rest_root}/blacklist/${public_key}/")
url = get_blacklist_entries_endpoint.substitute(rest_root=self._rest_root, public_key=self._public_key)
response = sel... | [
"def",
"get_blacklist_entries",
"(",
"self",
")",
":",
"get_blacklist_entries_endpoint",
"=",
"Template",
"(",
"\"${rest_root}/blacklist/${public_key}/\"",
")",
"url",
"=",
"get_blacklist_entries_endpoint",
".",
"substitute",
"(",
"rest_root",
"=",
"self",
".",
"_rest_roo... | Get a list of all blacklist entries. | [
"Get",
"a",
"list",
"of",
"all",
"blacklist",
"entries",
"."
] | dfacb63fd79f82c0eabde76b511116df5b51d6f1 | https://github.com/Mollom/mollom_python/blob/dfacb63fd79f82c0eabde76b511116df5b51d6f1/mollom/mollom.py#L349-L357 |
248,503 | 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"
] | dfacb63fd79f82c0eabde76b511116df5b51d6f1 | https://github.com/Mollom/mollom_python/blob/dfacb63fd79f82c0eabde76b511116df5b51d6f1/mollom/mollom.py#L359-L369 |
248,504 | 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"
] | 65574d23f51a7bbced9bb25010d02da5ca5d906f | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/api/deployments.py#L16-L39 |
248,505 | 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"
] | 65574d23f51a7bbced9bb25010d02da5ca5d906f | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/api/deployments.py#L42-L57 |
248,506 | 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"
] | 65574d23f51a7bbced9bb25010d02da5ca5d906f | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/api/deployments.py#L60-L82 |
248,507 | 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"
] | 65574d23f51a7bbced9bb25010d02da5ca5d906f | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/api/deployments.py#L153-L170 |
248,508 | 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"
] | 65574d23f51a7bbced9bb25010d02da5ca5d906f | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/api/deployments.py#L173-L206 |
248,509 | 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"
] | 65574d23f51a7bbced9bb25010d02da5ca5d906f | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/api/deployments.py#L253-L273 |
248,510 | 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"
] | 65574d23f51a7bbced9bb25010d02da5ca5d906f | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/api/deployments.py#L276-L301 |
248,511 | 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"
] | f2c1ced33e6c211bb52a25a7d48155e39fbdc088 | https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/menu.py#L68-L74 |
248,512 | 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"
] | f2c1ced33e6c211bb52a25a7d48155e39fbdc088 | https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/menu.py#L82-L86 |
248,513 | 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"
] | f2c1ced33e6c211bb52a25a7d48155e39fbdc088 | https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/menu.py#L132-L136 |
248,514 | 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"
] | f2c1ced33e6c211bb52a25a7d48155e39fbdc088 | https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/menu.py#L138-L142 |
248,515 | 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"
] | f2c1ced33e6c211bb52a25a7d48155e39fbdc088 | https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/menu.py#L144-L148 |
248,516 | 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",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/parser/__init__.py#L15-L32 |
248,517 | 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",
"."
] | eef780ced61aae6d001aeeef7574e5e27e613583 | https://github.com/Ffisegydd/whatis/blob/eef780ced61aae6d001aeeef7574e5e27e613583/whatis/_variable.py#L4-L11 |
248,518 | 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"
] | 6d4f2920e45df827890ebe55b1c41b1f3414c0c9 | https://github.com/appointlet/span/blob/6d4f2920e45df827890ebe55b1c41b1f3414c0c9/span/__init__.py#L66-L73 |
248,519 | 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",
"."
] | 6d4f2920e45df827890ebe55b1c41b1f3414c0c9 | https://github.com/appointlet/span/blob/6d4f2920e45df827890ebe55b1c41b1f3414c0c9/span/__init__.py#L77-L84 |
248,520 | 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",
"."
] | 5acd61eb0ef813b4a2eb6bbe75d07af1e11847a4 | https://github.com/udoprog/mimeprovider/blob/5acd61eb0ef813b4a2eb6bbe75d07af1e11847a4/mimeprovider/packages/mxml.py#L34-L41 |
248,521 | 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",
"."
] | 929d3cc7c2538b0f792365c0d2b0e0d41084c2dd | https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/base/__init__.py#L125-L132 |
248,522 | 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"
] | 072cbd6f7b90f3f666dc0f2c10ab6056d86dfc72 | https://github.com/CodyKochmann/stricttuple/blob/072cbd6f7b90f3f666dc0f2c10ab6056d86dfc72/stricttuple/__init__.py#L40-L55 |
248,523 | 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"
] | 072cbd6f7b90f3f666dc0f2c10ab6056d86dfc72 | https://github.com/CodyKochmann/stricttuple/blob/072cbd6f7b90f3f666dc0f2c10ab6056d86dfc72/stricttuple/__init__.py#L57-L63 |
248,524 | 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",
"."
] | 664c12a8ccf4d27ab0e06e0969bbb6381f74789c | https://github.com/evetrivia/thanatos/blob/664c12a8ccf4d27ab0e06e0969bbb6381f74789c/thanatos/database/inventory.py#L10-L22 |
248,525 | 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",
"."
] | 664c12a8ccf4d27ab0e06e0969bbb6381f74789c | https://github.com/evetrivia/thanatos/blob/664c12a8ccf4d27ab0e06e0969bbb6381f74789c/thanatos/database/inventory.py#L44-L56 |
248,526 | 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"
] | a81a245be822d62f1a20c734ca14b42c786ae81e | https://github.com/mohamedattahri/PyXMLi/blob/a81a245be822d62f1a20c734ca14b42c786ae81e/pyxmli/xmldsig.py#L50-L62 |
248,527 | 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",
"."
] | a81a245be822d62f1a20c734ca14b42c786ae81e | https://github.com/mohamedattahri/PyXMLi/blob/a81a245be822d62f1a20c734ca14b42c786ae81e/pyxmli/xmldsig.py#L65-L86 |
248,528 | 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"
] | a81a245be822d62f1a20c734ca14b42c786ae81e | https://github.com/mohamedattahri/PyXMLi/blob/a81a245be822d62f1a20c734ca14b42c786ae81e/pyxmli/xmldsig.py#L89-L128 |
248,529 | 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",
"."
] | 1869b13f9341bfcebd931059e93de2bc38570da3 | https://github.com/devricks/soft_drf/blob/1869b13f9341bfcebd931059e93de2bc38570da3/soft_drf/routing/autodiscover.py#L7-L17 |
248,530 | 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",
"."
] | 2c7cbe0d8a6789ede48c53f263872ceac5b67ca3 | https://github.com/markpasc/pywhich/blob/2c7cbe0d8a6789ede48c53f263872ceac5b67ca3/pywhich.py#L16-L30 |
248,531 | 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",
"."
] | 2c7cbe0d8a6789ede48c53f263872ceac5b67ca3 | https://github.com/markpasc/pywhich/blob/2c7cbe0d8a6789ede48c53f263872ceac5b67ca3/pywhich.py#L83-L111 |
248,532 | 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",
"."
] | 2c7cbe0d8a6789ede48c53f263872ceac5b67ca3 | https://github.com/markpasc/pywhich/blob/2c7cbe0d8a6789ede48c53f263872ceac5b67ca3/pywhich.py#L114-L151 |
248,533 | 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",
"."
] | 2c7cbe0d8a6789ede48c53f263872ceac5b67ca3 | https://github.com/markpasc/pywhich/blob/2c7cbe0d8a6789ede48c53f263872ceac5b67ca3/pywhich.py#L154-L197 |
248,534 | 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",
"."
] | 3a4b3df7b12418c6fa8a7d9cd49656a1c031fc0e | https://github.com/vecnet/vecnet.simulation/blob/3a4b3df7b12418c6fa8a7d9cd49656a1c031fc0e/vecnet/simulation/__init__.py#L32-L39 |
248,535 | 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",
"."
] | 3a4b3df7b12418c6fa8a7d9cd49656a1c031fc0e | https://github.com/vecnet/vecnet.simulation/blob/3a4b3df7b12418c6fa8a7d9cd49656a1c031fc0e/vecnet/simulation/__init__.py#L50-L55 |
248,536 | 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",
"."
] | 6f010b4d2ef41aead2366878d0cf0b1284c0db0e | https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/pycouchbase/fields.py#L143-L153 |
248,537 | 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",
"."
] | 6f010b4d2ef41aead2366878d0cf0b1284c0db0e | https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/pycouchbase/fields.py#L189-L199 |
248,538 | 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",
"."
] | e32ad6265567d5a1891df3c3425423774dafab41 | https://github.com/fred49/argtoolbox/blob/e32ad6265567d5a1891df3c3425423774dafab41/setup.py#L46-L53 |
248,539 | 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",
"."
] | 3b58b91b41d8b9bee546eb40dc280a57500b8bed | https://github.com/malthe/pop/blob/3b58b91b41d8b9bee546eb40dc280a57500b8bed/src/pop/client.py#L12-L20 |
248,540 | 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",
"."
] | 3b58b91b41d8b9bee546eb40dc280a57500b8bed | https://github.com/malthe/pop/blob/3b58b91b41d8b9bee546eb40dc280a57500b8bed/src/pop/client.py#L23-L36 |
248,541 | 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",
"."
] | 3b58b91b41d8b9bee546eb40dc280a57500b8bed | https://github.com/malthe/pop/blob/3b58b91b41d8b9bee546eb40dc280a57500b8bed/src/pop/client.py#L39-L57 |
248,542 | 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",
"."
] | 3b58b91b41d8b9bee546eb40dc280a57500b8bed | https://github.com/malthe/pop/blob/3b58b91b41d8b9bee546eb40dc280a57500b8bed/src/pop/client.py#L59-L68 |
248,543 | 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",
"."
] | 3b58b91b41d8b9bee546eb40dc280a57500b8bed | https://github.com/malthe/pop/blob/3b58b91b41d8b9bee546eb40dc280a57500b8bed/src/pop/client.py#L71-L94 |
248,544 | 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",
"."
] | 816563a9c3feb3fa416f1c2921c6b75db34111ad | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/utils.py#L20-L70 |
248,545 | 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"
] | 816563a9c3feb3fa416f1c2921c6b75db34111ad | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/utils.py#L73-L106 |
248,546 | 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"
] | 816563a9c3feb3fa416f1c2921c6b75db34111ad | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/utils.py#L109-L146 |
248,547 | 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",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/templatetags/pages_tags.py#L138-L147 |
248,548 | 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",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/templatetags/pages_tags.py#L151-L166 |
248,549 | 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",
... | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/templatetags/pages_tags.py#L170-L203 |
248,550 | 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",
"."
] | bbbd5139744ccc6264595cc8960784e5c308c009 | https://github.com/af/turrentine/blob/bbbd5139744ccc6264595cc8960784e5c308c009/turrentine/models.py#L41-L49 |
248,551 | 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",
"."
] | bbbd5139744ccc6264595cc8960784e5c308c009 | https://github.com/af/turrentine/blob/bbbd5139744ccc6264595cc8960784e5c308c009/turrentine/models.py#L88-L101 |
248,552 | 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"
] | eabaa17ebfd31b1654ee1f27e7026f6d7b370609 | https://github.com/kshlm/gant/blob/eabaa17ebfd31b1654ee1f27e7026f6d7b370609/gant/utils/ssh.py#L10-L20 |
248,553 | 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",
"."
] | 8f25bb849b72ce95957566544a2be8445316c818 | https://github.com/cariad/py-wpconfigr/blob/8f25bb849b72ce95957566544a2be8445316c818/wpconfigr/wp_config_string.py#L29-L41 |
248,554 | 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",
"."
] | 8f25bb849b72ce95957566544a2be8445316c818 | https://github.com/cariad/py-wpconfigr/blob/8f25bb849b72ce95957566544a2be8445316c818/wpconfigr/wp_config_string.py#L43-L66 |
248,555 | 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",
"."
] | 8f25bb849b72ce95957566544a2be8445316c818 | https://github.com/cariad/py-wpconfigr/blob/8f25bb849b72ce95957566544a2be8445316c818/wpconfigr/wp_config_string.py#L68-L91 |
248,556 | 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",
"."
] | 8f25bb849b72ce95957566544a2be8445316c818 | https://github.com/cariad/py-wpconfigr/blob/8f25bb849b72ce95957566544a2be8445316c818/wpconfigr/wp_config_string.py#L93-L126 |
248,557 | 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",
"."
] | 8f25bb849b72ce95957566544a2be8445316c818 | https://github.com/cariad/py-wpconfigr/blob/8f25bb849b72ce95957566544a2be8445316c818/wpconfigr/wp_config_string.py#L128-L141 |
248,558 | 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",
"."
] | 8f25bb849b72ce95957566544a2be8445316c818 | https://github.com/cariad/py-wpconfigr/blob/8f25bb849b72ce95957566544a2be8445316c818/wpconfigr/wp_config_string.py#L143-L204 |
248,559 | 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"
] | 60ce80aee082b7a1ea9c55471c6e717c9b46710f | https://github.com/pingviini/aja/blob/60ce80aee082b7a1ea9c55471c6e717c9b46710f/src/aja/utils.py#L30-L41 |
248,560 | 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"
] | 60ce80aee082b7a1ea9c55471c6e717c9b46710f | https://github.com/pingviini/aja/blob/60ce80aee082b7a1ea9c55471c6e717c9b46710f/src/aja/utils.py#L44-L54 |
248,561 | 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"
] | 60ce80aee082b7a1ea9c55471c6e717c9b46710f | https://github.com/pingviini/aja/blob/60ce80aee082b7a1ea9c55471c6e717c9b46710f/src/aja/utils.py#L57-L67 |
248,562 | 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"
] | 60ce80aee082b7a1ea9c55471c6e717c9b46710f | https://github.com/pingviini/aja/blob/60ce80aee082b7a1ea9c55471c6e717c9b46710f/src/aja/utils.py#L70-L85 |
248,563 | 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"
] | 60ce80aee082b7a1ea9c55471c6e717c9b46710f | https://github.com/pingviini/aja/blob/60ce80aee082b7a1ea9c55471c6e717c9b46710f/src/aja/utils.py#L88-L99 |
248,564 | 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",
"."
] | c4afab71297f73003379bba4c1679be9dcf7cef8 | https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/modelrun.py#L68-L87 |
248,565 | 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",
"."
] | c4afab71297f73003379bba4c1679be9dcf7cef8 | https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/modelrun.py#L275-L308 |
248,566 | 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",
"."
] | c4afab71297f73003379bba4c1679be9dcf7cef8 | https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/modelrun.py#L311-L365 |
248,567 | 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",
"."
] | c4afab71297f73003379bba4c1679be9dcf7cef8 | https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/modelrun.py#L403-L428 |
248,568 | 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",
"."
] | c4afab71297f73003379bba4c1679be9dcf7cef8 | https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/modelrun.py#L430-L443 |
248,569 | 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",
"."
] | c4afab71297f73003379bba4c1679be9dcf7cef8 | https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/modelrun.py#L445-L467 |
248,570 | 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",
"."
] | c4afab71297f73003379bba4c1679be9dcf7cef8 | https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/modelrun.py#L469-L497 |
248,571 | 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",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/workstation.py#L60-L71 |
248,572 | 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",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/workstation.py#L78-L91 |
248,573 | 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",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/workstation.py#L116-L123 |
248,574 | 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",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/workstation.py#L487-L504 |
248,575 | 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"
] | 57212a26ce713ab7723910ee49e3d0ba1697799f | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/meta.py#L72-L108 |
248,576 | jeremylow/pyshk | pyshk/api.py | Api.get_user | def get_user(self, user_id=None, user_name=None):
""" Get a user object from the API. If no ``user_id`` or ``user_name``
is specified, it will return the User object for the currently
authenticated user.
Args:
user_id (int): User ID of the user for whom you want to get
... | python | def get_user(self, user_id=None, user_name=None):
""" Get a user object from the API. If no ``user_id`` or ``user_name``
is specified, it will return the User object for the currently
authenticated user.
Args:
user_id (int): User ID of the user for whom you want to get
... | [
"def",
"get_user",
"(",
"self",
",",
"user_id",
"=",
"None",
",",
"user_name",
"=",
"None",
")",
":",
"if",
"user_id",
":",
"endpoint",
"=",
"'/api/user_id/{0}'",
".",
"format",
"(",
"user_id",
")",
"elif",
"user_name",
":",
"endpoint",
"=",
"'/api/user_na... | Get a user object from the API. If no ``user_id`` or ``user_name``
is specified, it will return the User object for the currently
authenticated user.
Args:
user_id (int): User ID of the user for whom you want to get
information. [Optional]
user_name(str):... | [
"Get",
"a",
"user",
"object",
"from",
"the",
"API",
".",
"If",
"no",
"user_id",
"or",
"user_name",
"is",
"specified",
"it",
"will",
"return",
"the",
"User",
"object",
"for",
"the",
"currently",
"authenticated",
"user",
"."
] | 3ab92f6706397cde7a18367266eba9e0f1ada868 | https://github.com/jeremylow/pyshk/blob/3ab92f6706397cde7a18367266eba9e0f1ada868/pyshk/api.py#L267-L295 |
248,577 | jeremylow/pyshk | pyshk/api.py | Api.get_user_shakes | def get_user_shakes(self):
""" Get a list of Shake objects for the currently authenticated user.
Returns:
A list of Shake objects.
"""
endpoint = '/api/shakes'
data = self._make_request(verb="GET", endpoint=endpoint)
shakes = [Shake.NewFromJSON(shk) for shk ... | python | def get_user_shakes(self):
""" Get a list of Shake objects for the currently authenticated user.
Returns:
A list of Shake objects.
"""
endpoint = '/api/shakes'
data = self._make_request(verb="GET", endpoint=endpoint)
shakes = [Shake.NewFromJSON(shk) for shk ... | [
"def",
"get_user_shakes",
"(",
"self",
")",
":",
"endpoint",
"=",
"'/api/shakes'",
"data",
"=",
"self",
".",
"_make_request",
"(",
"verb",
"=",
"\"GET\"",
",",
"endpoint",
"=",
"endpoint",
")",
"shakes",
"=",
"[",
"Shake",
".",
"NewFromJSON",
"(",
"shk",
... | Get a list of Shake objects for the currently authenticated user.
Returns:
A list of Shake objects. | [
"Get",
"a",
"list",
"of",
"Shake",
"objects",
"for",
"the",
"currently",
"authenticated",
"user",
"."
] | 3ab92f6706397cde7a18367266eba9e0f1ada868 | https://github.com/jeremylow/pyshk/blob/3ab92f6706397cde7a18367266eba9e0f1ada868/pyshk/api.py#L297-L307 |
248,578 | jeremylow/pyshk | pyshk/api.py | Api.get_shared_files_from_shake | def get_shared_files_from_shake(self,
shake_id=None,
before=None,
after=None):
"""
Returns a list of SharedFile objects from a particular shake.
Args:
shake_id (int): Shake fr... | python | def get_shared_files_from_shake(self,
shake_id=None,
before=None,
after=None):
"""
Returns a list of SharedFile objects from a particular shake.
Args:
shake_id (int): Shake fr... | [
"def",
"get_shared_files_from_shake",
"(",
"self",
",",
"shake_id",
"=",
"None",
",",
"before",
"=",
"None",
",",
"after",
"=",
"None",
")",
":",
"if",
"before",
"and",
"after",
":",
"raise",
"Exception",
"(",
"\"You cannot specify both before and after keys\"",
... | Returns a list of SharedFile objects from a particular shake.
Args:
shake_id (int): Shake from which to get a list of SharedFiles
before (str): get 10 SharedFile objects before (but not including)
the SharedFile given by `before` for the given Shake.
after (s... | [
"Returns",
"a",
"list",
"of",
"SharedFile",
"objects",
"from",
"a",
"particular",
"shake",
"."
] | 3ab92f6706397cde7a18367266eba9e0f1ada868 | https://github.com/jeremylow/pyshk/blob/3ab92f6706397cde7a18367266eba9e0f1ada868/pyshk/api.py#L309-L340 |
248,579 | jeremylow/pyshk | pyshk/api.py | Api.get_shared_file | def get_shared_file(self, sharekey=None):
"""
Returns a SharedFile object given by the sharekey.
Args:
sharekey (str): Sharekey of the SharedFile you want to retrieve.
Returns:
SharedFile
"""
if not sharekey:
raise Exception("You must... | python | def get_shared_file(self, sharekey=None):
"""
Returns a SharedFile object given by the sharekey.
Args:
sharekey (str): Sharekey of the SharedFile you want to retrieve.
Returns:
SharedFile
"""
if not sharekey:
raise Exception("You must... | [
"def",
"get_shared_file",
"(",
"self",
",",
"sharekey",
"=",
"None",
")",
":",
"if",
"not",
"sharekey",
":",
"raise",
"Exception",
"(",
"\"You must specify a sharekey.\"",
")",
"endpoint",
"=",
"'/api/sharedfile/{0}'",
".",
"format",
"(",
"sharekey",
")",
"data"... | Returns a SharedFile object given by the sharekey.
Args:
sharekey (str): Sharekey of the SharedFile you want to retrieve.
Returns:
SharedFile | [
"Returns",
"a",
"SharedFile",
"object",
"given",
"by",
"the",
"sharekey",
"."
] | 3ab92f6706397cde7a18367266eba9e0f1ada868 | https://github.com/jeremylow/pyshk/blob/3ab92f6706397cde7a18367266eba9e0f1ada868/pyshk/api.py#L342-L356 |
248,580 | jeremylow/pyshk | pyshk/api.py | Api.like_shared_file | def like_shared_file(self, sharekey=None):
""" 'Like' a SharedFile. mlkshk doesn't allow you to unlike a
sharedfile, so this is ~~permanent~~.
Args:
sharekey (str): Sharekey for the file you want to 'like'.
Returns:
Either a SharedFile on success, or an exceptio... | python | def like_shared_file(self, sharekey=None):
""" 'Like' a SharedFile. mlkshk doesn't allow you to unlike a
sharedfile, so this is ~~permanent~~.
Args:
sharekey (str): Sharekey for the file you want to 'like'.
Returns:
Either a SharedFile on success, or an exceptio... | [
"def",
"like_shared_file",
"(",
"self",
",",
"sharekey",
"=",
"None",
")",
":",
"if",
"not",
"sharekey",
":",
"raise",
"Exception",
"(",
"\"You must specify a sharekey of the file you\"",
"\"want to 'like'.\"",
")",
"endpoint",
"=",
"'/api/sharedfile/{sharekey}/like'",
... | 'Like' a SharedFile. mlkshk doesn't allow you to unlike a
sharedfile, so this is ~~permanent~~.
Args:
sharekey (str): Sharekey for the file you want to 'like'.
Returns:
Either a SharedFile on success, or an exception on error. | [
"Like",
"a",
"SharedFile",
".",
"mlkshk",
"doesn",
"t",
"allow",
"you",
"to",
"unlike",
"a",
"sharedfile",
"so",
"this",
"is",
"~~permanent~~",
"."
] | 3ab92f6706397cde7a18367266eba9e0f1ada868 | https://github.com/jeremylow/pyshk/blob/3ab92f6706397cde7a18367266eba9e0f1ada868/pyshk/api.py#L358-L382 |
248,581 | jeremylow/pyshk | pyshk/api.py | Api.save_shared_file | def save_shared_file(self, sharekey=None):
"""
Save a SharedFile to your Shake.
Args:
sharekey (str): Sharekey for the file to save.
Returns:
SharedFile saved to your shake.
"""
endpoint = '/api/sharedfile/{sharekey}/save'.format(sharekey=shareke... | python | def save_shared_file(self, sharekey=None):
"""
Save a SharedFile to your Shake.
Args:
sharekey (str): Sharekey for the file to save.
Returns:
SharedFile saved to your shake.
"""
endpoint = '/api/sharedfile/{sharekey}/save'.format(sharekey=shareke... | [
"def",
"save_shared_file",
"(",
"self",
",",
"sharekey",
"=",
"None",
")",
":",
"endpoint",
"=",
"'/api/sharedfile/{sharekey}/save'",
".",
"format",
"(",
"sharekey",
"=",
"sharekey",
")",
"data",
"=",
"self",
".",
"_make_request",
"(",
"\"POST\"",
",",
"endpoi... | Save a SharedFile to your Shake.
Args:
sharekey (str): Sharekey for the file to save.
Returns:
SharedFile saved to your shake. | [
"Save",
"a",
"SharedFile",
"to",
"your",
"Shake",
"."
] | 3ab92f6706397cde7a18367266eba9e0f1ada868 | https://github.com/jeremylow/pyshk/blob/3ab92f6706397cde7a18367266eba9e0f1ada868/pyshk/api.py#L384-L402 |
248,582 | jeremylow/pyshk | pyshk/api.py | Api.get_friends_shake | def get_friends_shake(self, before=None, after=None):
"""
Contrary to the endpoint naming, this resource is for a list of
SharedFiles from your friends on mlkshk.
Returns:
List of SharedFiles.
"""
if before and after:
raise Exception("You cannot s... | python | def get_friends_shake(self, before=None, after=None):
"""
Contrary to the endpoint naming, this resource is for a list of
SharedFiles from your friends on mlkshk.
Returns:
List of SharedFiles.
"""
if before and after:
raise Exception("You cannot s... | [
"def",
"get_friends_shake",
"(",
"self",
",",
"before",
"=",
"None",
",",
"after",
"=",
"None",
")",
":",
"if",
"before",
"and",
"after",
":",
"raise",
"Exception",
"(",
"\"You cannot specify both before and after keys\"",
")",
"endpoint",
"=",
"'/api/friends'",
... | Contrary to the endpoint naming, this resource is for a list of
SharedFiles from your friends on mlkshk.
Returns:
List of SharedFiles. | [
"Contrary",
"to",
"the",
"endpoint",
"naming",
"this",
"resource",
"is",
"for",
"a",
"list",
"of",
"SharedFiles",
"from",
"your",
"friends",
"on",
"mlkshk",
"."
] | 3ab92f6706397cde7a18367266eba9e0f1ada868 | https://github.com/jeremylow/pyshk/blob/3ab92f6706397cde7a18367266eba9e0f1ada868/pyshk/api.py#L404-L423 |
248,583 | jeremylow/pyshk | pyshk/api.py | Api.get_comments | def get_comments(self, sharekey=None):
"""
Retrieve comments on a SharedFile
Args:
sharekey (str): Sharekey for the file from which you want to return
the set of comments.
Returns:
List of Comment objects.
"""
if not sharekey:
... | python | def get_comments(self, sharekey=None):
"""
Retrieve comments on a SharedFile
Args:
sharekey (str): Sharekey for the file from which you want to return
the set of comments.
Returns:
List of Comment objects.
"""
if not sharekey:
... | [
"def",
"get_comments",
"(",
"self",
",",
"sharekey",
"=",
"None",
")",
":",
"if",
"not",
"sharekey",
":",
"raise",
"Exception",
"(",
"\"You must specify a sharekey of the file you\"",
"\"want to 'like'.\"",
")",
"endpoint",
"=",
"'/api/sharedfile/{0}/comments'",
".",
... | Retrieve comments on a SharedFile
Args:
sharekey (str): Sharekey for the file from which you want to return
the set of comments.
Returns:
List of Comment objects. | [
"Retrieve",
"comments",
"on",
"a",
"SharedFile"
] | 3ab92f6706397cde7a18367266eba9e0f1ada868 | https://github.com/jeremylow/pyshk/blob/3ab92f6706397cde7a18367266eba9e0f1ada868/pyshk/api.py#L474-L494 |
248,584 | jeremylow/pyshk | pyshk/api.py | Api.post_comment | def post_comment(self, sharekey=None, comment=None):
"""
Post a comment on behalf of the current user to the
SharedFile with the given sharekey.
Args:
sharekey (str): Sharekey of the SharedFile to which you'd like
to post a comment.
comment (str):... | python | def post_comment(self, sharekey=None, comment=None):
"""
Post a comment on behalf of the current user to the
SharedFile with the given sharekey.
Args:
sharekey (str): Sharekey of the SharedFile to which you'd like
to post a comment.
comment (str):... | [
"def",
"post_comment",
"(",
"self",
",",
"sharekey",
"=",
"None",
",",
"comment",
"=",
"None",
")",
":",
"endpoint",
"=",
"'/api/sharedfile/{0}/comments'",
".",
"format",
"(",
"sharekey",
")",
"post_data",
"=",
"{",
"'body'",
":",
"comment",
"}",
"data",
"... | Post a comment on behalf of the current user to the
SharedFile with the given sharekey.
Args:
sharekey (str): Sharekey of the SharedFile to which you'd like
to post a comment.
comment (str): Text of the comment to post.
Returns:
Comment objec... | [
"Post",
"a",
"comment",
"on",
"behalf",
"of",
"the",
"current",
"user",
"to",
"the",
"SharedFile",
"with",
"the",
"given",
"sharekey",
"."
] | 3ab92f6706397cde7a18367266eba9e0f1ada868 | https://github.com/jeremylow/pyshk/blob/3ab92f6706397cde7a18367266eba9e0f1ada868/pyshk/api.py#L496-L514 |
248,585 | jeremylow/pyshk | pyshk/api.py | Api.post_shared_file | def post_shared_file(self,
image_file=None,
source_link=None,
shake_id=None,
title=None,
description=None):
""" Upload an image.
TODO:
Don't have a pro account to test (o... | python | def post_shared_file(self,
image_file=None,
source_link=None,
shake_id=None,
title=None,
description=None):
""" Upload an image.
TODO:
Don't have a pro account to test (o... | [
"def",
"post_shared_file",
"(",
"self",
",",
"image_file",
"=",
"None",
",",
"source_link",
"=",
"None",
",",
"shake_id",
"=",
"None",
",",
"title",
"=",
"None",
",",
"description",
"=",
"None",
")",
":",
"if",
"image_file",
"and",
"source_link",
":",
"r... | Upload an image.
TODO:
Don't have a pro account to test (or even write) code to upload a
shared filed to a particular shake.
Args:
image_file (str): path to an image (jpg/gif) on your computer.
source_link (str): URL of a source (youtube/vine/etc.)
s... | [
"Upload",
"an",
"image",
"."
] | 3ab92f6706397cde7a18367266eba9e0f1ada868 | https://github.com/jeremylow/pyshk/blob/3ab92f6706397cde7a18367266eba9e0f1ada868/pyshk/api.py#L516-L557 |
248,586 | svasilev94/GraphLibrary | graphlibrary/graph.py | Graph.add_edge | def add_edge(self, u, v, **attr):
"""
Add an edge between vertices u and v and update edge attributes
"""
if u not in self.vertices:
self.vertices[u] = []
if v not in self.vertices:
self.vertices[v] = []
vertex = (u, v)
self.edges[... | python | def add_edge(self, u, v, **attr):
"""
Add an edge between vertices u and v and update edge attributes
"""
if u not in self.vertices:
self.vertices[u] = []
if v not in self.vertices:
self.vertices[v] = []
vertex = (u, v)
self.edges[... | [
"def",
"add_edge",
"(",
"self",
",",
"u",
",",
"v",
",",
"*",
"*",
"attr",
")",
":",
"if",
"u",
"not",
"in",
"self",
".",
"vertices",
":",
"self",
".",
"vertices",
"[",
"u",
"]",
"=",
"[",
"]",
"if",
"v",
"not",
"in",
"self",
".",
"vertices",... | Add an edge between vertices u and v and update edge attributes | [
"Add",
"an",
"edge",
"between",
"vertices",
"u",
"and",
"v",
"and",
"update",
"edge",
"attributes"
] | bf979a80bdea17eeb25955f0c119ca8f711ef62b | https://github.com/svasilev94/GraphLibrary/blob/bf979a80bdea17eeb25955f0c119ca8f711ef62b/graphlibrary/graph.py#L57-L70 |
248,587 | svasilev94/GraphLibrary | graphlibrary/graph.py | Graph.remove_edge | def remove_edge(self, u, v):
"""
Remove the edge between vertices u and v
"""
try:
self.edges.pop((u, v))
except KeyError:
raise GraphInsertError("Edge %s-%s doesn't exist." % (u, v))
self.vertices[u].remove(v)
self.vertices[v].rem... | python | def remove_edge(self, u, v):
"""
Remove the edge between vertices u and v
"""
try:
self.edges.pop((u, v))
except KeyError:
raise GraphInsertError("Edge %s-%s doesn't exist." % (u, v))
self.vertices[u].remove(v)
self.vertices[v].rem... | [
"def",
"remove_edge",
"(",
"self",
",",
"u",
",",
"v",
")",
":",
"try",
":",
"self",
".",
"edges",
".",
"pop",
"(",
"(",
"u",
",",
"v",
")",
")",
"except",
"KeyError",
":",
"raise",
"GraphInsertError",
"(",
"\"Edge %s-%s doesn't exist.\"",
"%",
"(",
... | Remove the edge between vertices u and v | [
"Remove",
"the",
"edge",
"between",
"vertices",
"u",
"and",
"v"
] | bf979a80bdea17eeb25955f0c119ca8f711ef62b | https://github.com/svasilev94/GraphLibrary/blob/bf979a80bdea17eeb25955f0c119ca8f711ef62b/graphlibrary/graph.py#L92-L101 |
248,588 | svasilev94/GraphLibrary | graphlibrary/graph.py | Graph.degree | def degree(self, vertex):
"""
Return the degree of a vertex
"""
try:
return len(self.vertices[vertex])
except KeyError:
raise GraphInsertError("Vertex %s doesn't exist." % (vertex,)) | python | def degree(self, vertex):
"""
Return the degree of a vertex
"""
try:
return len(self.vertices[vertex])
except KeyError:
raise GraphInsertError("Vertex %s doesn't exist." % (vertex,)) | [
"def",
"degree",
"(",
"self",
",",
"vertex",
")",
":",
"try",
":",
"return",
"len",
"(",
"self",
".",
"vertices",
"[",
"vertex",
"]",
")",
"except",
"KeyError",
":",
"raise",
"GraphInsertError",
"(",
"\"Vertex %s doesn't exist.\"",
"%",
"(",
"vertex",
",",... | Return the degree of a vertex | [
"Return",
"the",
"degree",
"of",
"a",
"vertex"
] | bf979a80bdea17eeb25955f0c119ca8f711ef62b | https://github.com/svasilev94/GraphLibrary/blob/bf979a80bdea17eeb25955f0c119ca8f711ef62b/graphlibrary/graph.py#L112-L119 |
248,589 | sys-git/certifiable | certifiable/cli_impl/core/certify_int.py | cli_certify_core_integer | def cli_certify_core_integer(
config, min_value, max_value, value,
):
"""Console script for certify_int"""
def parser(v):
# Attempt a json/pickle decode:
try:
v = load_json_pickle(v, config)
except Exception:
pass
# Attempt a straight conversion to i... | python | def cli_certify_core_integer(
config, min_value, max_value, value,
):
"""Console script for certify_int"""
def parser(v):
# Attempt a json/pickle decode:
try:
v = load_json_pickle(v, config)
except Exception:
pass
# Attempt a straight conversion to i... | [
"def",
"cli_certify_core_integer",
"(",
"config",
",",
"min_value",
",",
"max_value",
",",
"value",
",",
")",
":",
"def",
"parser",
"(",
"v",
")",
":",
"# Attempt a json/pickle decode:",
"try",
":",
"v",
"=",
"load_json_pickle",
"(",
"v",
",",
"config",
")",... | Console script for certify_int | [
"Console",
"script",
"for",
"certify_int"
] | a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8 | https://github.com/sys-git/certifiable/blob/a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8/certifiable/cli_impl/core/certify_int.py#L22-L57 |
248,590 | ardydedase/pycouchbase | couchbase-python-cffi/couchbase_ffi/bucket.py | Bucket._warn_dupkey | def _warn_dupkey(self, k):
"""
Really odd function - used to help ensure we actually warn for duplicate
keys.
"""
if self._privflags & PYCBC_CONN_F_WARNEXPLICIT:
warnings.warn_explicit(
'Found duplicate keys! {0}'.format(k), RuntimeWarning,
... | python | def _warn_dupkey(self, k):
"""
Really odd function - used to help ensure we actually warn for duplicate
keys.
"""
if self._privflags & PYCBC_CONN_F_WARNEXPLICIT:
warnings.warn_explicit(
'Found duplicate keys! {0}'.format(k), RuntimeWarning,
... | [
"def",
"_warn_dupkey",
"(",
"self",
",",
"k",
")",
":",
"if",
"self",
".",
"_privflags",
"&",
"PYCBC_CONN_F_WARNEXPLICIT",
":",
"warnings",
".",
"warn_explicit",
"(",
"'Found duplicate keys! {0}'",
".",
"format",
"(",
"k",
")",
",",
"RuntimeWarning",
",",
"__f... | Really odd function - used to help ensure we actually warn for duplicate
keys. | [
"Really",
"odd",
"function",
"-",
"used",
"to",
"help",
"ensure",
"we",
"actually",
"warn",
"for",
"duplicate",
"keys",
"."
] | 6f010b4d2ef41aead2366878d0cf0b1284c0db0e | https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/couchbase-python-cffi/couchbase_ffi/bucket.py#L750-L760 |
248,591 | minhhoit/yacms | yacms/blog/management/commands/import_wordpress.py | Command.get_text | def get_text(self, xml, name):
"""
Gets the element's text value from the XML object provided.
"""
nodes = xml.getElementsByTagName("wp:comment_" + name)[0].childNodes
accepted_types = [Node.CDATA_SECTION_NODE, Node.TEXT_NODE]
return "".join([n.data for n in nodes if n.no... | python | def get_text(self, xml, name):
"""
Gets the element's text value from the XML object provided.
"""
nodes = xml.getElementsByTagName("wp:comment_" + name)[0].childNodes
accepted_types = [Node.CDATA_SECTION_NODE, Node.TEXT_NODE]
return "".join([n.data for n in nodes if n.no... | [
"def",
"get_text",
"(",
"self",
",",
"xml",
",",
"name",
")",
":",
"nodes",
"=",
"xml",
".",
"getElementsByTagName",
"(",
"\"wp:comment_\"",
"+",
"name",
")",
"[",
"0",
"]",
".",
"childNodes",
"accepted_types",
"=",
"[",
"Node",
".",
"CDATA_SECTION_NODE",
... | Gets the element's text value from the XML object provided. | [
"Gets",
"the",
"element",
"s",
"text",
"value",
"from",
"the",
"XML",
"object",
"provided",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/blog/management/commands/import_wordpress.py#L28-L34 |
248,592 | minhhoit/yacms | yacms/blog/management/commands/import_wordpress.py | Command.handle_import | def handle_import(self, options):
"""
Gets the posts from either the provided URL or the path if it
is local.
"""
url = options.get("url")
if url is None:
raise CommandError("Usage is import_wordpress %s" % self.args)
try:
import feedparse... | python | def handle_import(self, options):
"""
Gets the posts from either the provided URL or the path if it
is local.
"""
url = options.get("url")
if url is None:
raise CommandError("Usage is import_wordpress %s" % self.args)
try:
import feedparse... | [
"def",
"handle_import",
"(",
"self",
",",
"options",
")",
":",
"url",
"=",
"options",
".",
"get",
"(",
"\"url\"",
")",
"if",
"url",
"is",
"None",
":",
"raise",
"CommandError",
"(",
"\"Usage is import_wordpress %s\"",
"%",
"self",
".",
"args",
")",
"try",
... | Gets the posts from either the provided URL or the path if it
is local. | [
"Gets",
"the",
"posts",
"from",
"either",
"the",
"provided",
"URL",
"or",
"the",
"path",
"if",
"it",
"is",
"local",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/blog/management/commands/import_wordpress.py#L36-L100 |
248,593 | minhhoit/yacms | yacms/blog/management/commands/import_wordpress.py | Command.wp_caption | def wp_caption(self, post):
"""
Filters a Wordpress Post for Image Captions and renders to
match HTML.
"""
for match in re.finditer(r"\[caption (.*?)\](.*?)\[/caption\]", post):
meta = '<div '
caption = ''
for imatch in re.finditer(r'(\w+)="(.*... | python | def wp_caption(self, post):
"""
Filters a Wordpress Post for Image Captions and renders to
match HTML.
"""
for match in re.finditer(r"\[caption (.*?)\](.*?)\[/caption\]", post):
meta = '<div '
caption = ''
for imatch in re.finditer(r'(\w+)="(.*... | [
"def",
"wp_caption",
"(",
"self",
",",
"post",
")",
":",
"for",
"match",
"in",
"re",
".",
"finditer",
"(",
"r\"\\[caption (.*?)\\](.*?)\\[/caption\\]\"",
",",
"post",
")",
":",
"meta",
"=",
"'<div '",
"caption",
"=",
"''",
"for",
"imatch",
"in",
"re",
".",... | Filters a Wordpress Post for Image Captions and renders to
match HTML. | [
"Filters",
"a",
"Wordpress",
"Post",
"for",
"Image",
"Captions",
"and",
"renders",
"to",
"match",
"HTML",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/blog/management/commands/import_wordpress.py#L102-L123 |
248,594 | d6e/emotion | emote/emote.py | read_emote_mappings | def read_emote_mappings(json_obj_files=[]):
""" Reads the contents of a list of files of json objects and combines
them into one large json object. """
super_json = {}
for fname in json_obj_files:
with open(fname) as f:
super_json.update(json.loads(f.read().decode('utf-8')))
retu... | python | def read_emote_mappings(json_obj_files=[]):
""" Reads the contents of a list of files of json objects and combines
them into one large json object. """
super_json = {}
for fname in json_obj_files:
with open(fname) as f:
super_json.update(json.loads(f.read().decode('utf-8')))
retu... | [
"def",
"read_emote_mappings",
"(",
"json_obj_files",
"=",
"[",
"]",
")",
":",
"super_json",
"=",
"{",
"}",
"for",
"fname",
"in",
"json_obj_files",
":",
"with",
"open",
"(",
"fname",
")",
"as",
"f",
":",
"super_json",
".",
"update",
"(",
"json",
".",
"l... | Reads the contents of a list of files of json objects and combines
them into one large json object. | [
"Reads",
"the",
"contents",
"of",
"a",
"list",
"of",
"files",
"of",
"json",
"objects",
"and",
"combines",
"them",
"into",
"one",
"large",
"json",
"object",
"."
] | 8ea84935a9103c3079579b3d9b9db85e12710af2 | https://github.com/d6e/emotion/blob/8ea84935a9103c3079579b3d9b9db85e12710af2/emote/emote.py#L9-L16 |
248,595 | sternoru/goscalecms | goscale/themes/site_middleware.py | make_tls_property | def make_tls_property(default=None):
"""Creates a class-wide instance property with a thread-specific value."""
class TLSProperty(object):
def __init__(self):
from threading import local
self.local = local()
def __get__(self, instance, cls):
if not instance:
... | python | def make_tls_property(default=None):
"""Creates a class-wide instance property with a thread-specific value."""
class TLSProperty(object):
def __init__(self):
from threading import local
self.local = local()
def __get__(self, instance, cls):
if not instance:
... | [
"def",
"make_tls_property",
"(",
"default",
"=",
"None",
")",
":",
"class",
"TLSProperty",
"(",
"object",
")",
":",
"def",
"__init__",
"(",
"self",
")",
":",
"from",
"threading",
"import",
"local",
"self",
".",
"local",
"=",
"local",
"(",
")",
"def",
"... | Creates a class-wide instance property with a thread-specific value. | [
"Creates",
"a",
"class",
"-",
"wide",
"instance",
"property",
"with",
"a",
"thread",
"-",
"specific",
"value",
"."
] | 7eee50357c47ebdfe3e573a8b4be3b67892d229e | https://github.com/sternoru/goscalecms/blob/7eee50357c47ebdfe3e573a8b4be3b67892d229e/goscale/themes/site_middleware.py#L7-L28 |
248,596 | sternoru/goscalecms | goscale/themes/site_middleware.py | SiteOnFlyDetectionMiddleware.lookup | def lookup(self):
"""
The meat of this middleware.
Returns None and sets settings.SITE_ID if able to find a Site
object by domain and its subdomain is valid.
Returns an HttpResponsePermanentRedirect to the Site's default
subdomain if a site is found but the requested su... | python | def lookup(self):
"""
The meat of this middleware.
Returns None and sets settings.SITE_ID if able to find a Site
object by domain and its subdomain is valid.
Returns an HttpResponsePermanentRedirect to the Site's default
subdomain if a site is found but the requested su... | [
"def",
"lookup",
"(",
"self",
")",
":",
"# check to see if this hostname is actually a env hostname",
"if",
"self",
".",
"domain",
":",
"if",
"self",
".",
"subdomain",
":",
"self",
".",
"domain_unsplit",
"=",
"'%s.%s'",
"%",
"(",
"self",
".",
"subdomain",
",",
... | The meat of this middleware.
Returns None and sets settings.SITE_ID if able to find a Site
object by domain and its subdomain is valid.
Returns an HttpResponsePermanentRedirect to the Site's default
subdomain if a site is found but the requested subdomain
is not supported, or i... | [
"The",
"meat",
"of",
"this",
"middleware",
"."
] | 7eee50357c47ebdfe3e573a8b4be3b67892d229e | https://github.com/sternoru/goscalecms/blob/7eee50357c47ebdfe3e573a8b4be3b67892d229e/goscale/themes/site_middleware.py#L70-L118 |
248,597 | sternoru/goscalecms | goscale/themes/site_middleware.py | SiteOnFlyDetectionMiddleware.theme_lookup | def theme_lookup(self):
"""
Returns theme based on site
Returns None and sets settings.THEME if able to find a theme object by site.
Otherwise, returns False.
"""
# check cache
cache_key = 'theme:%s' % self.domain_unsplit
theme = cache.get(cache_key)
... | python | def theme_lookup(self):
"""
Returns theme based on site
Returns None and sets settings.THEME if able to find a theme object by site.
Otherwise, returns False.
"""
# check cache
cache_key = 'theme:%s' % self.domain_unsplit
theme = cache.get(cache_key)
... | [
"def",
"theme_lookup",
"(",
"self",
")",
":",
"# check cache",
"cache_key",
"=",
"'theme:%s'",
"%",
"self",
".",
"domain_unsplit",
"theme",
"=",
"cache",
".",
"get",
"(",
"cache_key",
")",
"if",
"theme",
":",
"THEME",
".",
"value",
"=",
"theme",
"return",
... | Returns theme based on site
Returns None and sets settings.THEME if able to find a theme object by site.
Otherwise, returns False. | [
"Returns",
"theme",
"based",
"on",
"site"
] | 7eee50357c47ebdfe3e573a8b4be3b67892d229e | https://github.com/sternoru/goscalecms/blob/7eee50357c47ebdfe3e573a8b4be3b67892d229e/goscale/themes/site_middleware.py#L120-L144 |
248,598 | Valuehorizon/valuehorizon-people | people/models.py | Person.age | def age(self, as_at_date=None):
"""
Compute the person's age
"""
if self.date_of_death != None or self.is_deceased == True:
return None
as_at_date = date.today() if as_at_date == None else as_at_date
if self.date_of_birth != None:
if (as_... | python | def age(self, as_at_date=None):
"""
Compute the person's age
"""
if self.date_of_death != None or self.is_deceased == True:
return None
as_at_date = date.today() if as_at_date == None else as_at_date
if self.date_of_birth != None:
if (as_... | [
"def",
"age",
"(",
"self",
",",
"as_at_date",
"=",
"None",
")",
":",
"if",
"self",
".",
"date_of_death",
"!=",
"None",
"or",
"self",
".",
"is_deceased",
"==",
"True",
":",
"return",
"None",
"as_at_date",
"=",
"date",
".",
"today",
"(",
")",
"if",
"as... | Compute the person's age | [
"Compute",
"the",
"person",
"s",
"age"
] | f32d9f1349c1a9384bae5ea61d10c1b1e0318401 | https://github.com/Valuehorizon/valuehorizon-people/blob/f32d9f1349c1a9384bae5ea61d10c1b1e0318401/people/models.py#L53-L68 |
248,599 | Valuehorizon/valuehorizon-people | people/models.py | Person.name | def name(self):
"""
Return the person's name. If we have special titles, use them, otherwise,
don't include the title.
"""
if self.title in ["DR", "SIR", "LORD"]:
return "%s %s %s" % (self.get_title_display(), self.first_name, self.last_name)
else:
... | python | def name(self):
"""
Return the person's name. If we have special titles, use them, otherwise,
don't include the title.
"""
if self.title in ["DR", "SIR", "LORD"]:
return "%s %s %s" % (self.get_title_display(), self.first_name, self.last_name)
else:
... | [
"def",
"name",
"(",
"self",
")",
":",
"if",
"self",
".",
"title",
"in",
"[",
"\"DR\"",
",",
"\"SIR\"",
",",
"\"LORD\"",
"]",
":",
"return",
"\"%s %s %s\"",
"%",
"(",
"self",
".",
"get_title_display",
"(",
")",
",",
"self",
".",
"first_name",
",",
"se... | Return the person's name. If we have special titles, use them, otherwise,
don't include the title. | [
"Return",
"the",
"person",
"s",
"name",
".",
"If",
"we",
"have",
"special",
"titles",
"use",
"them",
"otherwise",
"don",
"t",
"include",
"the",
"title",
"."
] | f32d9f1349c1a9384bae5ea61d10c1b1e0318401 | https://github.com/Valuehorizon/valuehorizon-people/blob/f32d9f1349c1a9384bae5ea61d10c1b1e0318401/people/models.py#L78-L86 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.