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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
41,700 | PonteIneptique/flask-github-proxy | flask_github_proxy/__init__.py | GithubProxy.pull_request | def pull_request(self, file):
""" Create a pull request
:param file: File to push through pull request
:return: URL of the PullRequest or Proxy Error
"""
uri = "{api}/repos/{upstream}/pulls".format(
api=self.github_api_url,
upstream=self.upstream,
... | python | def pull_request(self, file):
""" Create a pull request
:param file: File to push through pull request
:return: URL of the PullRequest or Proxy Error
"""
uri = "{api}/repos/{upstream}/pulls".format(
api=self.github_api_url,
upstream=self.upstream,
... | [
"def",
"pull_request",
"(",
"self",
",",
"file",
")",
":",
"uri",
"=",
"\"{api}/repos/{upstream}/pulls\"",
".",
"format",
"(",
"api",
"=",
"self",
".",
"github_api_url",
",",
"upstream",
"=",
"self",
".",
"upstream",
",",
"path",
"=",
"file",
".",
"path",
... | Create a pull request
:param file: File to push through pull request
:return: URL of the PullRequest or Proxy Error | [
"Create",
"a",
"pull",
"request"
] | f0a60639342f7c0834360dc12a099bfc3a06d939 | https://github.com/PonteIneptique/flask-github-proxy/blob/f0a60639342f7c0834360dc12a099bfc3a06d939/flask_github_proxy/__init__.py#L307-L336 |
41,701 | PonteIneptique/flask-github-proxy | flask_github_proxy/__init__.py | GithubProxy.get_ref | def get_ref(self, branch, origin=None):
""" Check if a reference exists
:param branch: The branch to check if it exists
:return: Sha of the branch if it exists, False if it does not exist, self.ProxyError if it went wrong
"""
if not origin:
origin = self.origin
... | python | def get_ref(self, branch, origin=None):
""" Check if a reference exists
:param branch: The branch to check if it exists
:return: Sha of the branch if it exists, False if it does not exist, self.ProxyError if it went wrong
"""
if not origin:
origin = self.origin
... | [
"def",
"get_ref",
"(",
"self",
",",
"branch",
",",
"origin",
"=",
"None",
")",
":",
"if",
"not",
"origin",
":",
"origin",
"=",
"self",
".",
"origin",
"uri",
"=",
"\"{api}/repos/{origin}/git/refs/heads/{branch}\"",
".",
"format",
"(",
"api",
"=",
"self",
".... | Check if a reference exists
:param branch: The branch to check if it exists
:return: Sha of the branch if it exists, False if it does not exist, self.ProxyError if it went wrong | [
"Check",
"if",
"a",
"reference",
"exists"
] | f0a60639342f7c0834360dc12a099bfc3a06d939 | https://github.com/PonteIneptique/flask-github-proxy/blob/f0a60639342f7c0834360dc12a099bfc3a06d939/flask_github_proxy/__init__.py#L338-L368 |
41,702 | PonteIneptique/flask-github-proxy | flask_github_proxy/__init__.py | GithubProxy.make_ref | def make_ref(self, branch):
""" Make a branch on github
:param branch: Name of the branch to create
:return: Sha of the branch or self.ProxyError
"""
master_sha = self.get_ref(self.master_upstream)
if not isinstance(master_sha, str):
return self.ProxyError(
... | python | def make_ref(self, branch):
""" Make a branch on github
:param branch: Name of the branch to create
:return: Sha of the branch or self.ProxyError
"""
master_sha = self.get_ref(self.master_upstream)
if not isinstance(master_sha, str):
return self.ProxyError(
... | [
"def",
"make_ref",
"(",
"self",
",",
"branch",
")",
":",
"master_sha",
"=",
"self",
".",
"get_ref",
"(",
"self",
".",
"master_upstream",
")",
"if",
"not",
"isinstance",
"(",
"master_sha",
",",
"str",
")",
":",
"return",
"self",
".",
"ProxyError",
"(",
... | Make a branch on github
:param branch: Name of the branch to create
:return: Sha of the branch or self.ProxyError | [
"Make",
"a",
"branch",
"on",
"github"
] | f0a60639342f7c0834360dc12a099bfc3a06d939 | https://github.com/PonteIneptique/flask-github-proxy/blob/f0a60639342f7c0834360dc12a099bfc3a06d939/flask_github_proxy/__init__.py#L370-L405 |
41,703 | PonteIneptique/flask-github-proxy | flask_github_proxy/__init__.py | GithubProxy.check_sha | def check_sha(self, sha, content):
""" Check sent sha against the salted hash of the content
:param sha: SHA sent through fproxy-secure-hash header
:param content: Base 64 encoded Content
:return: Boolean indicating equality
"""
rightful_sha = sha256(bytes("{}{}".format(... | python | def check_sha(self, sha, content):
""" Check sent sha against the salted hash of the content
:param sha: SHA sent through fproxy-secure-hash header
:param content: Base 64 encoded Content
:return: Boolean indicating equality
"""
rightful_sha = sha256(bytes("{}{}".format(... | [
"def",
"check_sha",
"(",
"self",
",",
"sha",
",",
"content",
")",
":",
"rightful_sha",
"=",
"sha256",
"(",
"bytes",
"(",
"\"{}{}\"",
".",
"format",
"(",
"content",
",",
"self",
".",
"secret",
")",
",",
"\"utf-8\"",
")",
")",
".",
"hexdigest",
"(",
")... | Check sent sha against the salted hash of the content
:param sha: SHA sent through fproxy-secure-hash header
:param content: Base 64 encoded Content
:return: Boolean indicating equality | [
"Check",
"sent",
"sha",
"against",
"the",
"salted",
"hash",
"of",
"the",
"content"
] | f0a60639342f7c0834360dc12a099bfc3a06d939 | https://github.com/PonteIneptique/flask-github-proxy/blob/f0a60639342f7c0834360dc12a099bfc3a06d939/flask_github_proxy/__init__.py#L407-L415 |
41,704 | PonteIneptique/flask-github-proxy | flask_github_proxy/__init__.py | GithubProxy.patch_ref | def patch_ref(self, sha):
""" Patch reference on the origin master branch
:param sha: Sha to use for the branch
:return: Status of success
:rtype: str or self.ProxyError
"""
uri = "{api}/repos/{origin}/git/refs/heads/{branch}".format(
api=self.github_api_url,... | python | def patch_ref(self, sha):
""" Patch reference on the origin master branch
:param sha: Sha to use for the branch
:return: Status of success
:rtype: str or self.ProxyError
"""
uri = "{api}/repos/{origin}/git/refs/heads/{branch}".format(
api=self.github_api_url,... | [
"def",
"patch_ref",
"(",
"self",
",",
"sha",
")",
":",
"uri",
"=",
"\"{api}/repos/{origin}/git/refs/heads/{branch}\"",
".",
"format",
"(",
"api",
"=",
"self",
".",
"github_api_url",
",",
"origin",
"=",
"self",
".",
"origin",
",",
"branch",
"=",
"self",
".",
... | Patch reference on the origin master branch
:param sha: Sha to use for the branch
:return: Status of success
:rtype: str or self.ProxyError | [
"Patch",
"reference",
"on",
"the",
"origin",
"master",
"branch"
] | f0a60639342f7c0834360dc12a099bfc3a06d939 | https://github.com/PonteIneptique/flask-github-proxy/blob/f0a60639342f7c0834360dc12a099bfc3a06d939/flask_github_proxy/__init__.py#L417-L451 |
41,705 | PonteIneptique/flask-github-proxy | flask_github_proxy/__init__.py | GithubProxy.r_receive | def r_receive(self, filename):
""" Function which receives the data from Perseids
- Check the branch does not exist
- Make the branch if needed
- Receive PUT from Perseids
- Check if content exist
- Update/Create content
- Open Pull Reques... | python | def r_receive(self, filename):
""" Function which receives the data from Perseids
- Check the branch does not exist
- Make the branch if needed
- Receive PUT from Perseids
- Check if content exist
- Update/Create content
- Open Pull Reques... | [
"def",
"r_receive",
"(",
"self",
",",
"filename",
")",
":",
"###########################################",
"# Retrieving data",
"###########################################",
"content",
"=",
"request",
".",
"data",
".",
"decode",
"(",
"\"utf-8\"",
")",
"# Content checking",... | Function which receives the data from Perseids
- Check the branch does not exist
- Make the branch if needed
- Receive PUT from Perseids
- Check if content exist
- Update/Create content
- Open Pull Request
- Return PR link to Perseids
... | [
"Function",
"which",
"receives",
"the",
"data",
"from",
"Perseids"
] | f0a60639342f7c0834360dc12a099bfc3a06d939 | https://github.com/PonteIneptique/flask-github-proxy/blob/f0a60639342f7c0834360dc12a099bfc3a06d939/flask_github_proxy/__init__.py#L453-L557 |
41,706 | PonteIneptique/flask-github-proxy | flask_github_proxy/__init__.py | GithubProxy.r_update | def r_update(self):
""" Updates a fork Master
- Check the ref of the origin repository
- Patch reference of fork repository
- Return status to Perseids
:return: JSON Response with status_code 201 if successful.
"""
# Getting Master Branch
up... | python | def r_update(self):
""" Updates a fork Master
- Check the ref of the origin repository
- Patch reference of fork repository
- Return status to Perseids
:return: JSON Response with status_code 201 if successful.
"""
# Getting Master Branch
up... | [
"def",
"r_update",
"(",
"self",
")",
":",
"# Getting Master Branch",
"upstream",
"=",
"self",
".",
"get_ref",
"(",
"self",
".",
"master_upstream",
",",
"origin",
"=",
"self",
".",
"upstream",
")",
"if",
"isinstance",
"(",
"upstream",
",",
"bool",
")",
":",... | Updates a fork Master
- Check the ref of the origin repository
- Patch reference of fork repository
- Return status to Perseids
:return: JSON Response with status_code 201 if successful. | [
"Updates",
"a",
"fork",
"Master"
] | f0a60639342f7c0834360dc12a099bfc3a06d939 | https://github.com/PonteIneptique/flask-github-proxy/blob/f0a60639342f7c0834360dc12a099bfc3a06d939/flask_github_proxy/__init__.py#L559-L588 |
41,707 | AtomHash/evernode | evernode/models/password_reset_model.py | PasswordResetModel.delete_where_user_id | def delete_where_user_id(cls, user_id):
""" delete by email """
result = cls.where_user_id(user_id)
if result is None:
return None
result.delete()
return True | python | def delete_where_user_id(cls, user_id):
""" delete by email """
result = cls.where_user_id(user_id)
if result is None:
return None
result.delete()
return True | [
"def",
"delete_where_user_id",
"(",
"cls",
",",
"user_id",
")",
":",
"result",
"=",
"cls",
".",
"where_user_id",
"(",
"user_id",
")",
"if",
"result",
"is",
"None",
":",
"return",
"None",
"result",
".",
"delete",
"(",
")",
"return",
"True"
] | delete by email | [
"delete",
"by",
"email"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/models/password_reset_model.py#L32-L38 |
41,708 | MacHu-GWU/crawl_zillow-project | crawl_zillow/helpers.py | int_filter | def int_filter(text):
"""Extract integer from text.
**中文文档**
摘除文本内的整数。
"""
res = list()
for char in text:
if char.isdigit():
res.append(char)
return int("".join(res)) | python | def int_filter(text):
"""Extract integer from text.
**中文文档**
摘除文本内的整数。
"""
res = list()
for char in text:
if char.isdigit():
res.append(char)
return int("".join(res)) | [
"def",
"int_filter",
"(",
"text",
")",
":",
"res",
"=",
"list",
"(",
")",
"for",
"char",
"in",
"text",
":",
"if",
"char",
".",
"isdigit",
"(",
")",
":",
"res",
".",
"append",
"(",
"char",
")",
"return",
"int",
"(",
"\"\"",
".",
"join",
"(",
"re... | Extract integer from text.
**中文文档**
摘除文本内的整数。 | [
"Extract",
"integer",
"from",
"text",
"."
] | c6d7ca8e4c80e7e7e963496433ef73df1413c16e | https://github.com/MacHu-GWU/crawl_zillow-project/blob/c6d7ca8e4c80e7e7e963496433ef73df1413c16e/crawl_zillow/helpers.py#L5-L16 |
41,709 | MacHu-GWU/crawl_zillow-project | crawl_zillow/helpers.py | float_filter | def float_filter(text):
"""Extract float from text.
**中文文档**
摘除文本内的小数。
"""
res = list()
for char in text:
if (char.isdigit() or (char == ".")):
res.append(char)
return float("".join(res)) | python | def float_filter(text):
"""Extract float from text.
**中文文档**
摘除文本内的小数。
"""
res = list()
for char in text:
if (char.isdigit() or (char == ".")):
res.append(char)
return float("".join(res)) | [
"def",
"float_filter",
"(",
"text",
")",
":",
"res",
"=",
"list",
"(",
")",
"for",
"char",
"in",
"text",
":",
"if",
"(",
"char",
".",
"isdigit",
"(",
")",
"or",
"(",
"char",
"==",
"\".\"",
")",
")",
":",
"res",
".",
"append",
"(",
"char",
")",
... | Extract float from text.
**中文文档**
摘除文本内的小数。 | [
"Extract",
"float",
"from",
"text",
"."
] | c6d7ca8e4c80e7e7e963496433ef73df1413c16e | https://github.com/MacHu-GWU/crawl_zillow-project/blob/c6d7ca8e4c80e7e7e963496433ef73df1413c16e/crawl_zillow/helpers.py#L19-L30 |
41,710 | dariusbakunas/rawdisk | rawdisk/plugins/filesystems/apple_boot/apple_boot_volume.py | AppleBootVolume.load | def load(self, filename, offset):
"""Will eventually load information for Apple_Boot volume.
Not yet implemented"""
try:
self.offset = offset
# self.fd = open(filename, 'rb')
# self.fd.close()
except IOError as e:
print(e) | python | def load(self, filename, offset):
"""Will eventually load information for Apple_Boot volume.
Not yet implemented"""
try:
self.offset = offset
# self.fd = open(filename, 'rb')
# self.fd.close()
except IOError as e:
print(e) | [
"def",
"load",
"(",
"self",
",",
"filename",
",",
"offset",
")",
":",
"try",
":",
"self",
".",
"offset",
"=",
"offset",
"# self.fd = open(filename, 'rb')",
"# self.fd.close()",
"except",
"IOError",
"as",
"e",
":",
"print",
"(",
"e",
")"
] | Will eventually load information for Apple_Boot volume.
Not yet implemented | [
"Will",
"eventually",
"load",
"information",
"for",
"Apple_Boot",
"volume",
".",
"Not",
"yet",
"implemented"
] | 1dc9d0b377fe5da3c406ccec4abc238c54167403 | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/plugins/filesystems/apple_boot/apple_boot_volume.py#L13-L21 |
41,711 | zibertscrem/hexdi | hexdi/__init__.py | resolve | def resolve(accessor: hexdi.core.clstype) -> __gentype__.T:
"""
shortcut for resolving from root container
:param accessor: accessor for resolving object
:return: resolved object of requested type
"""
return hexdi.core.get_root_container().resolve(accessor=accessor) | python | def resolve(accessor: hexdi.core.clstype) -> __gentype__.T:
"""
shortcut for resolving from root container
:param accessor: accessor for resolving object
:return: resolved object of requested type
"""
return hexdi.core.get_root_container().resolve(accessor=accessor) | [
"def",
"resolve",
"(",
"accessor",
":",
"hexdi",
".",
"core",
".",
"clstype",
")",
"->",
"__gentype__",
".",
"T",
":",
"return",
"hexdi",
".",
"core",
".",
"get_root_container",
"(",
")",
".",
"resolve",
"(",
"accessor",
"=",
"accessor",
")"
] | shortcut for resolving from root container
:param accessor: accessor for resolving object
:return: resolved object of requested type | [
"shortcut",
"for",
"resolving",
"from",
"root",
"container"
] | 4875598299c53f984f2bb1b37060fd42bb7aba84 | https://github.com/zibertscrem/hexdi/blob/4875598299c53f984f2bb1b37060fd42bb7aba84/hexdi/__init__.py#L39-L46 |
41,712 | zibertscrem/hexdi | hexdi/__init__.py | bind_type | def bind_type(type_to_bind: hexdi.core.restype, accessor: hexdi.core.clstype, lifetime_manager: hexdi.core.ltype):
"""
shortcut for bind_type on root container
:param type_to_bind: type that will be resolved by accessor
:param accessor: accessor for resolving object
:param lifetime_manager: type of... | python | def bind_type(type_to_bind: hexdi.core.restype, accessor: hexdi.core.clstype, lifetime_manager: hexdi.core.ltype):
"""
shortcut for bind_type on root container
:param type_to_bind: type that will be resolved by accessor
:param accessor: accessor for resolving object
:param lifetime_manager: type of... | [
"def",
"bind_type",
"(",
"type_to_bind",
":",
"hexdi",
".",
"core",
".",
"restype",
",",
"accessor",
":",
"hexdi",
".",
"core",
".",
"clstype",
",",
"lifetime_manager",
":",
"hexdi",
".",
"core",
".",
"ltype",
")",
":",
"hexdi",
".",
"core",
".",
"get_... | shortcut for bind_type on root container
:param type_to_bind: type that will be resolved by accessor
:param accessor: accessor for resolving object
:param lifetime_manager: type of lifetime manager for this binding | [
"shortcut",
"for",
"bind_type",
"on",
"root",
"container"
] | 4875598299c53f984f2bb1b37060fd42bb7aba84 | https://github.com/zibertscrem/hexdi/blob/4875598299c53f984f2bb1b37060fd42bb7aba84/hexdi/__init__.py#L68-L76 |
41,713 | zibertscrem/hexdi | hexdi/__init__.py | bind_permanent | def bind_permanent(type_to_bind: hexdi.core.restype, accessor: hexdi.core.clstype):
"""
shortcut for bind_type with PermanentLifeTimeManager on root container
:param type_to_bind: type that will be resolved by accessor
:param accessor: accessor for resolving object
"""
hexdi.core.get_root_conta... | python | def bind_permanent(type_to_bind: hexdi.core.restype, accessor: hexdi.core.clstype):
"""
shortcut for bind_type with PermanentLifeTimeManager on root container
:param type_to_bind: type that will be resolved by accessor
:param accessor: accessor for resolving object
"""
hexdi.core.get_root_conta... | [
"def",
"bind_permanent",
"(",
"type_to_bind",
":",
"hexdi",
".",
"core",
".",
"restype",
",",
"accessor",
":",
"hexdi",
".",
"core",
".",
"clstype",
")",
":",
"hexdi",
".",
"core",
".",
"get_root_container",
"(",
")",
".",
"bind_type",
"(",
"type_to_bind",... | shortcut for bind_type with PermanentLifeTimeManager on root container
:param type_to_bind: type that will be resolved by accessor
:param accessor: accessor for resolving object | [
"shortcut",
"for",
"bind_type",
"with",
"PermanentLifeTimeManager",
"on",
"root",
"container"
] | 4875598299c53f984f2bb1b37060fd42bb7aba84 | https://github.com/zibertscrem/hexdi/blob/4875598299c53f984f2bb1b37060fd42bb7aba84/hexdi/__init__.py#L79-L86 |
41,714 | zibertscrem/hexdi | hexdi/__init__.py | bind_transient | def bind_transient(type_to_bind: hexdi.core.restype, accessor: hexdi.core.clstype):
"""
shortcut for bind_type with PerResolveLifeTimeManager on root container
:param type_to_bind: type that will be resolved by accessor
:param accessor: accessor for resolving object
"""
hexdi.core.get_root_cont... | python | def bind_transient(type_to_bind: hexdi.core.restype, accessor: hexdi.core.clstype):
"""
shortcut for bind_type with PerResolveLifeTimeManager on root container
:param type_to_bind: type that will be resolved by accessor
:param accessor: accessor for resolving object
"""
hexdi.core.get_root_cont... | [
"def",
"bind_transient",
"(",
"type_to_bind",
":",
"hexdi",
".",
"core",
".",
"restype",
",",
"accessor",
":",
"hexdi",
".",
"core",
".",
"clstype",
")",
":",
"hexdi",
".",
"core",
".",
"get_root_container",
"(",
")",
".",
"bind_type",
"(",
"type_to_bind",... | shortcut for bind_type with PerResolveLifeTimeManager on root container
:param type_to_bind: type that will be resolved by accessor
:param accessor: accessor for resolving object | [
"shortcut",
"for",
"bind_type",
"with",
"PerResolveLifeTimeManager",
"on",
"root",
"container"
] | 4875598299c53f984f2bb1b37060fd42bb7aba84 | https://github.com/zibertscrem/hexdi/blob/4875598299c53f984f2bb1b37060fd42bb7aba84/hexdi/__init__.py#L89-L96 |
41,715 | The-Politico/politico-civic-demography | demography/management/commands/bootstrap/fetch/_series.py | GetSeries.get_series | def get_series(self, series):
"""
Returns a census series API handler.
"""
if series == "acs1":
return self.census.acs1dp
elif series == "acs5":
return self.census.acs5
elif series == "sf1":
return self.census.sf1
elif series ==... | python | def get_series(self, series):
"""
Returns a census series API handler.
"""
if series == "acs1":
return self.census.acs1dp
elif series == "acs5":
return self.census.acs5
elif series == "sf1":
return self.census.sf1
elif series ==... | [
"def",
"get_series",
"(",
"self",
",",
"series",
")",
":",
"if",
"series",
"==",
"\"acs1\"",
":",
"return",
"self",
".",
"census",
".",
"acs1dp",
"elif",
"series",
"==",
"\"acs5\"",
":",
"return",
"self",
".",
"census",
".",
"acs5",
"elif",
"series",
"... | Returns a census series API handler. | [
"Returns",
"a",
"census",
"series",
"API",
"handler",
"."
] | 080bb964b64b06db7fd04386530e893ceed1cf98 | https://github.com/The-Politico/politico-civic-demography/blob/080bb964b64b06db7fd04386530e893ceed1cf98/demography/management/commands/bootstrap/fetch/_series.py#L2-L15 |
41,716 | helixyte/everest | everest/repositories/manager.py | RepositoryManager.setup_system_repository | def setup_system_repository(self, repository_type, reset_on_start,
repository_class=None):
"""
Sets up the system repository with the given repository type.
:param str repository_type: Repository type to use for the SYSTEM
repository.
:param boo... | python | def setup_system_repository(self, repository_type, reset_on_start,
repository_class=None):
"""
Sets up the system repository with the given repository type.
:param str repository_type: Repository type to use for the SYSTEM
repository.
:param boo... | [
"def",
"setup_system_repository",
"(",
"self",
",",
"repository_type",
",",
"reset_on_start",
",",
"repository_class",
"=",
"None",
")",
":",
"# Set up the system entity repository (this does not join the",
"# transaction and is in autocommit mode).",
"cnf",
"=",
"dict",
"(",
... | Sets up the system repository with the given repository type.
:param str repository_type: Repository type to use for the SYSTEM
repository.
:param bool reset_on_start: Flag to indicate whether stored system
resources should be discarded on startup.
:param repository_class: c... | [
"Sets",
"up",
"the",
"system",
"repository",
"with",
"the",
"given",
"repository",
"type",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/manager.py#L91-L111 |
41,717 | helixyte/everest | everest/repositories/manager.py | RepositoryManager.initialize_all | def initialize_all(self):
"""
Convenience method to initialize all repositories that have not been
initialized yet.
"""
for repo in itervalues_(self.__repositories):
if not repo.is_initialized:
repo.initialize() | python | def initialize_all(self):
"""
Convenience method to initialize all repositories that have not been
initialized yet.
"""
for repo in itervalues_(self.__repositories):
if not repo.is_initialized:
repo.initialize() | [
"def",
"initialize_all",
"(",
"self",
")",
":",
"for",
"repo",
"in",
"itervalues_",
"(",
"self",
".",
"__repositories",
")",
":",
"if",
"not",
"repo",
".",
"is_initialized",
":",
"repo",
".",
"initialize",
"(",
")"
] | Convenience method to initialize all repositories that have not been
initialized yet. | [
"Convenience",
"method",
"to",
"initialize",
"all",
"repositories",
"that",
"have",
"not",
"been",
"initialized",
"yet",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/manager.py#L113-L120 |
41,718 | silver-castle/mach9 | mach9/response.py | file | async def file(location, mime_type=None, headers=None, _range=None):
'''Return a response object with file data.
:param location: Location of file on system.
:param mime_type: Specific mime_type.
:param headers: Custom Headers.
:param _range:
'''
filename = path.split(location)[-1]
asy... | python | async def file(location, mime_type=None, headers=None, _range=None):
'''Return a response object with file data.
:param location: Location of file on system.
:param mime_type: Specific mime_type.
:param headers: Custom Headers.
:param _range:
'''
filename = path.split(location)[-1]
asy... | [
"async",
"def",
"file",
"(",
"location",
",",
"mime_type",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"_range",
"=",
"None",
")",
":",
"filename",
"=",
"path",
".",
"split",
"(",
"location",
")",
"[",
"-",
"1",
"]",
"async",
"with",
"open_async",... | Return a response object with file data.
:param location: Location of file on system.
:param mime_type: Specific mime_type.
:param headers: Custom Headers.
:param _range: | [
"Return",
"a",
"response",
"object",
"with",
"file",
"data",
"."
] | 7a623aab3c70d89d36ade6901b6307e115400c5e | https://github.com/silver-castle/mach9/blob/7a623aab3c70d89d36ade6901b6307e115400c5e/mach9/response.py#L349-L373 |
41,719 | sdcooke/django_bundles | django_bundles/core.py | get_bundles | def get_bundles():
"""
Used to cache the bundle definitions rather than loading from config every time they're used
"""
global _cached_bundles
if not _cached_bundles:
_cached_bundles = BundleManager()
for bundle_conf in bundles_settings.BUNDLES:
_cached_bundles[bundle_c... | python | def get_bundles():
"""
Used to cache the bundle definitions rather than loading from config every time they're used
"""
global _cached_bundles
if not _cached_bundles:
_cached_bundles = BundleManager()
for bundle_conf in bundles_settings.BUNDLES:
_cached_bundles[bundle_c... | [
"def",
"get_bundles",
"(",
")",
":",
"global",
"_cached_bundles",
"if",
"not",
"_cached_bundles",
":",
"_cached_bundles",
"=",
"BundleManager",
"(",
")",
"for",
"bundle_conf",
"in",
"bundles_settings",
".",
"BUNDLES",
":",
"_cached_bundles",
"[",
"bundle_conf",
"[... | Used to cache the bundle definitions rather than loading from config every time they're used | [
"Used",
"to",
"cache",
"the",
"bundle",
"definitions",
"rather",
"than",
"loading",
"from",
"config",
"every",
"time",
"they",
"re",
"used"
] | 2810fc455ec7391283792c1f108f4e8340f5d12f | https://github.com/sdcooke/django_bundles/blob/2810fc455ec7391283792c1f108f4e8340f5d12f/django_bundles/core.py#L205-L217 |
41,720 | sdcooke/django_bundles | django_bundles/core.py | get_bundle_versions | def get_bundle_versions():
"""
Used to cache the bundle versions rather than loading them from the bundle versions file every time they're used
"""
global _cached_versions
if not bundles_settings.BUNDLES_VERSION_FILE:
_cached_versions = {}
if _cached_versions is None:
locs = {}
... | python | def get_bundle_versions():
"""
Used to cache the bundle versions rather than loading them from the bundle versions file every time they're used
"""
global _cached_versions
if not bundles_settings.BUNDLES_VERSION_FILE:
_cached_versions = {}
if _cached_versions is None:
locs = {}
... | [
"def",
"get_bundle_versions",
"(",
")",
":",
"global",
"_cached_versions",
"if",
"not",
"bundles_settings",
".",
"BUNDLES_VERSION_FILE",
":",
"_cached_versions",
"=",
"{",
"}",
"if",
"_cached_versions",
"is",
"None",
":",
"locs",
"=",
"{",
"}",
"try",
":",
"ex... | Used to cache the bundle versions rather than loading them from the bundle versions file every time they're used | [
"Used",
"to",
"cache",
"the",
"bundle",
"versions",
"rather",
"than",
"loading",
"them",
"from",
"the",
"bundle",
"versions",
"file",
"every",
"time",
"they",
"re",
"used"
] | 2810fc455ec7391283792c1f108f4e8340f5d12f | https://github.com/sdcooke/django_bundles/blob/2810fc455ec7391283792c1f108f4e8340f5d12f/django_bundles/core.py#L221-L235 |
41,721 | sdcooke/django_bundles | django_bundles/core.py | Bundle.get_url | def get_url(self, version=None):
"""
Return the filename of the bundled bundle
"""
if self.fixed_bundle_url:
return self.fixed_bundle_url
return '%s.%s.%s' % (os.path.join(self.bundle_url_root, self.bundle_filename), version or self.get_version(), self.bundle_type) | python | def get_url(self, version=None):
"""
Return the filename of the bundled bundle
"""
if self.fixed_bundle_url:
return self.fixed_bundle_url
return '%s.%s.%s' % (os.path.join(self.bundle_url_root, self.bundle_filename), version or self.get_version(), self.bundle_type) | [
"def",
"get_url",
"(",
"self",
",",
"version",
"=",
"None",
")",
":",
"if",
"self",
".",
"fixed_bundle_url",
":",
"return",
"self",
".",
"fixed_bundle_url",
"return",
"'%s.%s.%s'",
"%",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"bundle_url_r... | Return the filename of the bundled bundle | [
"Return",
"the",
"filename",
"of",
"the",
"bundled",
"bundle"
] | 2810fc455ec7391283792c1f108f4e8340f5d12f | https://github.com/sdcooke/django_bundles/blob/2810fc455ec7391283792c1f108f4e8340f5d12f/django_bundles/core.py#L109-L115 |
41,722 | sdcooke/django_bundles | django_bundles/core.py | Bundle.get_file_urls | def get_file_urls(self):
"""
Return a list of file urls - will return a single item if settings.USE_BUNDLES is True
"""
if self.use_bundle:
return [self.get_url()]
return [bundle_file.file_url for bundle_file in self.files] | python | def get_file_urls(self):
"""
Return a list of file urls - will return a single item if settings.USE_BUNDLES is True
"""
if self.use_bundle:
return [self.get_url()]
return [bundle_file.file_url for bundle_file in self.files] | [
"def",
"get_file_urls",
"(",
"self",
")",
":",
"if",
"self",
".",
"use_bundle",
":",
"return",
"[",
"self",
".",
"get_url",
"(",
")",
"]",
"return",
"[",
"bundle_file",
".",
"file_url",
"for",
"bundle_file",
"in",
"self",
".",
"files",
"]"
] | Return a list of file urls - will return a single item if settings.USE_BUNDLES is True | [
"Return",
"a",
"list",
"of",
"file",
"urls",
"-",
"will",
"return",
"a",
"single",
"item",
"if",
"settings",
".",
"USE_BUNDLES",
"is",
"True"
] | 2810fc455ec7391283792c1f108f4e8340f5d12f | https://github.com/sdcooke/django_bundles/blob/2810fc455ec7391283792c1f108f4e8340f5d12f/django_bundles/core.py#L122-L128 |
41,723 | erikvw/django-collect-offline-files | django_collect_offline_files/transaction/transaction_exporter.py | TransactionExporter.export_batch | def export_batch(self):
"""Returns a batch instance after exporting a batch of txs.
"""
batch = self.batch_cls(
model=self.model, history_model=self.history_model, using=self.using
)
if batch.items:
try:
json_file = self.json_file_cls(batch... | python | def export_batch(self):
"""Returns a batch instance after exporting a batch of txs.
"""
batch = self.batch_cls(
model=self.model, history_model=self.history_model, using=self.using
)
if batch.items:
try:
json_file = self.json_file_cls(batch... | [
"def",
"export_batch",
"(",
"self",
")",
":",
"batch",
"=",
"self",
".",
"batch_cls",
"(",
"model",
"=",
"self",
".",
"model",
",",
"history_model",
"=",
"self",
".",
"history_model",
",",
"using",
"=",
"self",
".",
"using",
")",
"if",
"batch",
".",
... | Returns a batch instance after exporting a batch of txs. | [
"Returns",
"a",
"batch",
"instance",
"after",
"exporting",
"a",
"batch",
"of",
"txs",
"."
] | 78f61c823ea3926eb88206b019b5dca3c36017da | https://github.com/erikvw/django-collect-offline-files/blob/78f61c823ea3926eb88206b019b5dca3c36017da/django_collect_offline_files/transaction/transaction_exporter.py#L179-L193 |
41,724 | Cadasta/django-jsonattrs | jsonattrs/fields.py | JSONAttributes._check_key | def _check_key(self, key):
"""
Ensure key is either in schema's attributes or already set on self.
"""
self.setup_schema()
if key not in self._attrs and key not in self:
raise KeyError(key) | python | def _check_key(self, key):
"""
Ensure key is either in schema's attributes or already set on self.
"""
self.setup_schema()
if key not in self._attrs and key not in self:
raise KeyError(key) | [
"def",
"_check_key",
"(",
"self",
",",
"key",
")",
":",
"self",
".",
"setup_schema",
"(",
")",
"if",
"key",
"not",
"in",
"self",
".",
"_attrs",
"and",
"key",
"not",
"in",
"self",
":",
"raise",
"KeyError",
"(",
"key",
")"
] | Ensure key is either in schema's attributes or already set on self. | [
"Ensure",
"key",
"is",
"either",
"in",
"schema",
"s",
"attributes",
"or",
"already",
"set",
"on",
"self",
"."
] | 5149e08ec84da00dd73bd3fe548bc52fd361667c | https://github.com/Cadasta/django-jsonattrs/blob/5149e08ec84da00dd73bd3fe548bc52fd361667c/jsonattrs/fields.py#L123-L129 |
41,725 | AndrewAnnex/moody | moody/moody.py | ODE.hirise_edr | def hirise_edr(self, pid, chunk_size=1024*1024):
"""
Download a HiRISE EDR set of .IMG files to the CWD
You must know the full id to specifiy the filter to use, ie:
PSP_XXXXXX_YYYY will download every EDR IMG file available
PSP_XXXXXX_YYYY_R will download every EDR... | python | def hirise_edr(self, pid, chunk_size=1024*1024):
"""
Download a HiRISE EDR set of .IMG files to the CWD
You must know the full id to specifiy the filter to use, ie:
PSP_XXXXXX_YYYY will download every EDR IMG file available
PSP_XXXXXX_YYYY_R will download every EDR... | [
"def",
"hirise_edr",
"(",
"self",
",",
"pid",
",",
"chunk_size",
"=",
"1024",
"*",
"1024",
")",
":",
"productid",
"=",
"\"{}*\"",
".",
"format",
"(",
"pid",
")",
"query",
"=",
"{",
"\"target\"",
":",
"\"mars\"",
",",
"\"query\"",
":",
"\"product\"",
",... | Download a HiRISE EDR set of .IMG files to the CWD
You must know the full id to specifiy the filter to use, ie:
PSP_XXXXXX_YYYY will download every EDR IMG file available
PSP_XXXXXX_YYYY_R will download every EDR RED filter IMG file
PSP_XXXXXX_YYYY_BG12_0 will download on... | [
"Download",
"a",
"HiRISE",
"EDR",
"set",
"of",
".",
"IMG",
"files",
"to",
"the",
"CWD"
] | 07cee4c8fe8bbe4a2b9e8f06db2bca425f618b33 | https://github.com/AndrewAnnex/moody/blob/07cee4c8fe8bbe4a2b9e8f06db2bca425f618b33/moody/moody.py#L45-L81 |
41,726 | dariusbakunas/rawdisk | rawdisk/plugins/filesystems/ntfs/ntfs.py | Ntfs.detect | def detect(self, filename, offset, standalone=False):
"""Verifies NTFS filesystem signature.
Returns:
bool: True if filesystem signature at offset 0x03 \
matches 'NTFS ', False otherwise.
"""
r = RawStruct(
filename=filename,
offset=off... | python | def detect(self, filename, offset, standalone=False):
"""Verifies NTFS filesystem signature.
Returns:
bool: True if filesystem signature at offset 0x03 \
matches 'NTFS ', False otherwise.
"""
r = RawStruct(
filename=filename,
offset=off... | [
"def",
"detect",
"(",
"self",
",",
"filename",
",",
"offset",
",",
"standalone",
"=",
"False",
")",
":",
"r",
"=",
"RawStruct",
"(",
"filename",
"=",
"filename",
",",
"offset",
"=",
"offset",
"+",
"SIG_OFFSET",
",",
"length",
"=",
"SIG_SIZE",
")",
"oem... | Verifies NTFS filesystem signature.
Returns:
bool: True if filesystem signature at offset 0x03 \
matches 'NTFS ', False otherwise. | [
"Verifies",
"NTFS",
"filesystem",
"signature",
"."
] | 1dc9d0b377fe5da3c406ccec4abc238c54167403 | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/plugins/filesystems/ntfs/ntfs.py#L27-L44 |
41,727 | barnybug/finite | finite/dfa.py | Action.load | def load(cls, v):
"""Load the action from configuration"""
if v is None:
return []
if isinstance(v, list):
return [ Action(s) for s in v ]
elif isinstance(v, str):
return [Action(v)]
else:
raise ParseError("Couldn't parse action: %r... | python | def load(cls, v):
"""Load the action from configuration"""
if v is None:
return []
if isinstance(v, list):
return [ Action(s) for s in v ]
elif isinstance(v, str):
return [Action(v)]
else:
raise ParseError("Couldn't parse action: %r... | [
"def",
"load",
"(",
"cls",
",",
"v",
")",
":",
"if",
"v",
"is",
"None",
":",
"return",
"[",
"]",
"if",
"isinstance",
"(",
"v",
",",
"list",
")",
":",
"return",
"[",
"Action",
"(",
"s",
")",
"for",
"s",
"in",
"v",
"]",
"elif",
"isinstance",
"(... | Load the action from configuration | [
"Load",
"the",
"action",
"from",
"configuration"
] | a587fef255dc90377e86ba1449a19070ce910a36 | https://github.com/barnybug/finite/blob/a587fef255dc90377e86ba1449a19070ce910a36/finite/dfa.py#L159-L168 |
41,728 | barnybug/finite | finite/dfa.py | Loader.load_stream | def load_stream(cls, st):
"""Load Automatons from a stream"""
y = yaml.load(st)
return [ Automaton(k, v) for k, v in y.iteritems() ] | python | def load_stream(cls, st):
"""Load Automatons from a stream"""
y = yaml.load(st)
return [ Automaton(k, v) for k, v in y.iteritems() ] | [
"def",
"load_stream",
"(",
"cls",
",",
"st",
")",
":",
"y",
"=",
"yaml",
".",
"load",
"(",
"st",
")",
"return",
"[",
"Automaton",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"y",
".",
"iteritems",
"(",
")",
"]"
] | Load Automatons from a stream | [
"Load",
"Automatons",
"from",
"a",
"stream"
] | a587fef255dc90377e86ba1449a19070ce910a36 | https://github.com/barnybug/finite/blob/a587fef255dc90377e86ba1449a19070ce910a36/finite/dfa.py#L184-L187 |
41,729 | barnybug/finite | finite/dfa.py | Loader.make_dot | def make_dot(self, filename_or_stream, auts):
"""Create a graphviz .dot representation of the automaton."""
if isinstance(filename_or_stream, str):
stream = file(filename_or_stream, 'w')
else:
stream = filename_or_stream
dot = DotFile(stream)
... | python | def make_dot(self, filename_or_stream, auts):
"""Create a graphviz .dot representation of the automaton."""
if isinstance(filename_or_stream, str):
stream = file(filename_or_stream, 'w')
else:
stream = filename_or_stream
dot = DotFile(stream)
... | [
"def",
"make_dot",
"(",
"self",
",",
"filename_or_stream",
",",
"auts",
")",
":",
"if",
"isinstance",
"(",
"filename_or_stream",
",",
"str",
")",
":",
"stream",
"=",
"file",
"(",
"filename_or_stream",
",",
"'w'",
")",
"else",
":",
"stream",
"=",
"filename_... | Create a graphviz .dot representation of the automaton. | [
"Create",
"a",
"graphviz",
".",
"dot",
"representation",
"of",
"the",
"automaton",
"."
] | a587fef255dc90377e86ba1449a19070ce910a36 | https://github.com/barnybug/finite/blob/a587fef255dc90377e86ba1449a19070ce910a36/finite/dfa.py#L190-L219 |
41,730 | RetailMeNotSandbox/acky | acky/s3.py | S3.create | def create(self, url):
"""Create a bucket, directory, or empty file."""
bucket, obj_key = _parse_url(url)
if not bucket:
raise InvalidURL(url,
"You must specify a bucket and (optional) path")
if obj_key:
target = "/".join((bucket, ob... | python | def create(self, url):
"""Create a bucket, directory, or empty file."""
bucket, obj_key = _parse_url(url)
if not bucket:
raise InvalidURL(url,
"You must specify a bucket and (optional) path")
if obj_key:
target = "/".join((bucket, ob... | [
"def",
"create",
"(",
"self",
",",
"url",
")",
":",
"bucket",
",",
"obj_key",
"=",
"_parse_url",
"(",
"url",
")",
"if",
"not",
"bucket",
":",
"raise",
"InvalidURL",
"(",
"url",
",",
"\"You must specify a bucket and (optional) path\"",
")",
"if",
"obj_key",
"... | Create a bucket, directory, or empty file. | [
"Create",
"a",
"bucket",
"directory",
"or",
"empty",
"file",
"."
] | fcd4d092c42892ede7c924cafc41e9cf4be3fb9f | https://github.com/RetailMeNotSandbox/acky/blob/fcd4d092c42892ede7c924cafc41e9cf4be3fb9f/acky/s3.py#L60-L73 |
41,731 | RetailMeNotSandbox/acky | acky/s3.py | S3.destroy | def destroy(self, url, recursive=False):
"""Destroy a bucket, directory, or file. Specifying recursive=True
recursively deletes all subdirectories and files."""
bucket, obj_key = _parse_url(url)
if not bucket:
raise InvalidURL(url,
"You must spec... | python | def destroy(self, url, recursive=False):
"""Destroy a bucket, directory, or file. Specifying recursive=True
recursively deletes all subdirectories and files."""
bucket, obj_key = _parse_url(url)
if not bucket:
raise InvalidURL(url,
"You must spec... | [
"def",
"destroy",
"(",
"self",
",",
"url",
",",
"recursive",
"=",
"False",
")",
":",
"bucket",
",",
"obj_key",
"=",
"_parse_url",
"(",
"url",
")",
"if",
"not",
"bucket",
":",
"raise",
"InvalidURL",
"(",
"url",
",",
"\"You must specify a bucket and (optional)... | Destroy a bucket, directory, or file. Specifying recursive=True
recursively deletes all subdirectories and files. | [
"Destroy",
"a",
"bucket",
"directory",
"or",
"file",
".",
"Specifying",
"recursive",
"=",
"True",
"recursively",
"deletes",
"all",
"subdirectories",
"and",
"files",
"."
] | fcd4d092c42892ede7c924cafc41e9cf4be3fb9f | https://github.com/RetailMeNotSandbox/acky/blob/fcd4d092c42892ede7c924cafc41e9cf4be3fb9f/acky/s3.py#L75-L93 |
41,732 | RetailMeNotSandbox/acky | acky/s3.py | S3.upload | def upload(self, local_path, remote_url):
"""Copy a local file to an S3 location."""
bucket, key = _parse_url(remote_url)
with open(local_path, 'rb') as fp:
return self.call("PutObject", bucket=bucket, key=key, body=fp) | python | def upload(self, local_path, remote_url):
"""Copy a local file to an S3 location."""
bucket, key = _parse_url(remote_url)
with open(local_path, 'rb') as fp:
return self.call("PutObject", bucket=bucket, key=key, body=fp) | [
"def",
"upload",
"(",
"self",
",",
"local_path",
",",
"remote_url",
")",
":",
"bucket",
",",
"key",
"=",
"_parse_url",
"(",
"remote_url",
")",
"with",
"open",
"(",
"local_path",
",",
"'rb'",
")",
"as",
"fp",
":",
"return",
"self",
".",
"call",
"(",
"... | Copy a local file to an S3 location. | [
"Copy",
"a",
"local",
"file",
"to",
"an",
"S3",
"location",
"."
] | fcd4d092c42892ede7c924cafc41e9cf4be3fb9f | https://github.com/RetailMeNotSandbox/acky/blob/fcd4d092c42892ede7c924cafc41e9cf4be3fb9f/acky/s3.py#L95-L100 |
41,733 | RetailMeNotSandbox/acky | acky/s3.py | S3.download | def download(self, remote_url, local_path, buffer_size=8 * 1024):
"""Copy S3 data to a local file."""
bucket, key = _parse_url(remote_url)
response_file = self.call("GetObject", bucket=bucket, key=key)['Body']
with open(local_path, 'wb') as fp:
buf = response_file.read(buffe... | python | def download(self, remote_url, local_path, buffer_size=8 * 1024):
"""Copy S3 data to a local file."""
bucket, key = _parse_url(remote_url)
response_file = self.call("GetObject", bucket=bucket, key=key)['Body']
with open(local_path, 'wb') as fp:
buf = response_file.read(buffe... | [
"def",
"download",
"(",
"self",
",",
"remote_url",
",",
"local_path",
",",
"buffer_size",
"=",
"8",
"*",
"1024",
")",
":",
"bucket",
",",
"key",
"=",
"_parse_url",
"(",
"remote_url",
")",
"response_file",
"=",
"self",
".",
"call",
"(",
"\"GetObject\"",
"... | Copy S3 data to a local file. | [
"Copy",
"S3",
"data",
"to",
"a",
"local",
"file",
"."
] | fcd4d092c42892ede7c924cafc41e9cf4be3fb9f | https://github.com/RetailMeNotSandbox/acky/blob/fcd4d092c42892ede7c924cafc41e9cf4be3fb9f/acky/s3.py#L102-L111 |
41,734 | RetailMeNotSandbox/acky | acky/s3.py | S3.copy | def copy(self, src_url, dst_url):
"""Copy an S3 object to another S3 location."""
src_bucket, src_key = _parse_url(src_url)
dst_bucket, dst_key = _parse_url(dst_url)
if not dst_bucket:
dst_bucket = src_bucket
params = {
'copy_source': '/'.join((src_bucket... | python | def copy(self, src_url, dst_url):
"""Copy an S3 object to another S3 location."""
src_bucket, src_key = _parse_url(src_url)
dst_bucket, dst_key = _parse_url(dst_url)
if not dst_bucket:
dst_bucket = src_bucket
params = {
'copy_source': '/'.join((src_bucket... | [
"def",
"copy",
"(",
"self",
",",
"src_url",
",",
"dst_url",
")",
":",
"src_bucket",
",",
"src_key",
"=",
"_parse_url",
"(",
"src_url",
")",
"dst_bucket",
",",
"dst_key",
"=",
"_parse_url",
"(",
"dst_url",
")",
"if",
"not",
"dst_bucket",
":",
"dst_bucket",
... | Copy an S3 object to another S3 location. | [
"Copy",
"an",
"S3",
"object",
"to",
"another",
"S3",
"location",
"."
] | fcd4d092c42892ede7c924cafc41e9cf4be3fb9f | https://github.com/RetailMeNotSandbox/acky/blob/fcd4d092c42892ede7c924cafc41e9cf4be3fb9f/acky/s3.py#L113-L125 |
41,735 | RetailMeNotSandbox/acky | acky/s3.py | S3.move | def move(self, src_url, dst_url):
"""Copy a single S3 object to another S3 location, then delete the
original object."""
self.copy(src_url, dst_url)
self.destroy(src_url) | python | def move(self, src_url, dst_url):
"""Copy a single S3 object to another S3 location, then delete the
original object."""
self.copy(src_url, dst_url)
self.destroy(src_url) | [
"def",
"move",
"(",
"self",
",",
"src_url",
",",
"dst_url",
")",
":",
"self",
".",
"copy",
"(",
"src_url",
",",
"dst_url",
")",
"self",
".",
"destroy",
"(",
"src_url",
")"
] | Copy a single S3 object to another S3 location, then delete the
original object. | [
"Copy",
"a",
"single",
"S3",
"object",
"to",
"another",
"S3",
"location",
"then",
"delete",
"the",
"original",
"object",
"."
] | fcd4d092c42892ede7c924cafc41e9cf4be3fb9f | https://github.com/RetailMeNotSandbox/acky/blob/fcd4d092c42892ede7c924cafc41e9cf4be3fb9f/acky/s3.py#L127-L131 |
41,736 | mishan/twemredis-py | twemredis.py | TwemRedis.get_shard_names | def get_shard_names(self):
"""
get_shard_names returns an array containing the names of the shards
in the cluster. This is determined with num_shards and
shard_name_format
"""
results = []
for shard_num in range(0, self.num_shards()):
shard_name = self... | python | def get_shard_names(self):
"""
get_shard_names returns an array containing the names of the shards
in the cluster. This is determined with num_shards and
shard_name_format
"""
results = []
for shard_num in range(0, self.num_shards()):
shard_name = self... | [
"def",
"get_shard_names",
"(",
"self",
")",
":",
"results",
"=",
"[",
"]",
"for",
"shard_num",
"in",
"range",
"(",
"0",
",",
"self",
".",
"num_shards",
"(",
")",
")",
":",
"shard_name",
"=",
"self",
".",
"get_shard_name",
"(",
"shard_num",
")",
"result... | get_shard_names returns an array containing the names of the shards
in the cluster. This is determined with num_shards and
shard_name_format | [
"get_shard_names",
"returns",
"an",
"array",
"containing",
"the",
"names",
"of",
"the",
"shards",
"in",
"the",
"cluster",
".",
"This",
"is",
"determined",
"with",
"num_shards",
"and",
"shard_name_format"
] | cfc787d90482eb6a2037cfbf4863bd144582662d | https://github.com/mishan/twemredis-py/blob/cfc787d90482eb6a2037cfbf4863bd144582662d/twemredis.py#L119-L130 |
41,737 | mishan/twemredis-py | twemredis.py | TwemRedis.get_canonical_key_id | def get_canonical_key_id(self, key_id):
"""
get_canonical_key_id is used by get_canonical_key, see the comment
for that method for more explanation.
Keyword arguments:
key_id -- the key id (e.g. '12345')
returns the canonical key id (e.g. '12')
"""
shard... | python | def get_canonical_key_id(self, key_id):
"""
get_canonical_key_id is used by get_canonical_key, see the comment
for that method for more explanation.
Keyword arguments:
key_id -- the key id (e.g. '12345')
returns the canonical key id (e.g. '12')
"""
shard... | [
"def",
"get_canonical_key_id",
"(",
"self",
",",
"key_id",
")",
":",
"shard_num",
"=",
"self",
".",
"get_shard_num_by_key_id",
"(",
"key_id",
")",
"return",
"self",
".",
"_canonical_keys",
"[",
"shard_num",
"]"
] | get_canonical_key_id is used by get_canonical_key, see the comment
for that method for more explanation.
Keyword arguments:
key_id -- the key id (e.g. '12345')
returns the canonical key id (e.g. '12') | [
"get_canonical_key_id",
"is",
"used",
"by",
"get_canonical_key",
"see",
"the",
"comment",
"for",
"that",
"method",
"for",
"more",
"explanation",
"."
] | cfc787d90482eb6a2037cfbf4863bd144582662d | https://github.com/mishan/twemredis-py/blob/cfc787d90482eb6a2037cfbf4863bd144582662d/twemredis.py#L222-L233 |
41,738 | mishan/twemredis-py | twemredis.py | TwemRedis.get_shard_by_num | def get_shard_by_num(self, shard_num):
"""
get_shard_by_num returns the shard at index shard_num.
Keyword arguments:
shard_num -- The shard index
Returns a redis.StrictRedis connection or raises a ValueError.
"""
if shard_num < 0 or shard_num >= self.num_shards(... | python | def get_shard_by_num(self, shard_num):
"""
get_shard_by_num returns the shard at index shard_num.
Keyword arguments:
shard_num -- The shard index
Returns a redis.StrictRedis connection or raises a ValueError.
"""
if shard_num < 0 or shard_num >= self.num_shards(... | [
"def",
"get_shard_by_num",
"(",
"self",
",",
"shard_num",
")",
":",
"if",
"shard_num",
"<",
"0",
"or",
"shard_num",
">=",
"self",
".",
"num_shards",
"(",
")",
":",
"raise",
"ValueError",
"(",
"\"requested invalid shard# {0}\"",
".",
"format",
"(",
"shard_num",... | get_shard_by_num returns the shard at index shard_num.
Keyword arguments:
shard_num -- The shard index
Returns a redis.StrictRedis connection or raises a ValueError. | [
"get_shard_by_num",
"returns",
"the",
"shard",
"at",
"index",
"shard_num",
"."
] | cfc787d90482eb6a2037cfbf4863bd144582662d | https://github.com/mishan/twemredis-py/blob/cfc787d90482eb6a2037cfbf4863bd144582662d/twemredis.py#L247-L259 |
41,739 | mishan/twemredis-py | twemredis.py | TwemRedis._get_key_id_from_key | def _get_key_id_from_key(self, key):
"""
_get_key_id_from_key returns the key id from a key, if found. otherwise
it just returns the key to be used as the key id.
Keyword arguments:
key -- The key to derive the ID from. If curly braces are found in the
key, then t... | python | def _get_key_id_from_key(self, key):
"""
_get_key_id_from_key returns the key id from a key, if found. otherwise
it just returns the key to be used as the key id.
Keyword arguments:
key -- The key to derive the ID from. If curly braces are found in the
key, then t... | [
"def",
"_get_key_id_from_key",
"(",
"self",
",",
"key",
")",
":",
"key_id",
"=",
"key",
"regex",
"=",
"'{0}([^{1}]*){2}'",
".",
"format",
"(",
"self",
".",
"_hash_start",
",",
"self",
".",
"_hash_stop",
",",
"self",
".",
"_hash_stop",
")",
"m",
"=",
"re"... | _get_key_id_from_key returns the key id from a key, if found. otherwise
it just returns the key to be used as the key id.
Keyword arguments:
key -- The key to derive the ID from. If curly braces are found in the
key, then the contents of the curly braces are used as the
... | [
"_get_key_id_from_key",
"returns",
"the",
"key",
"id",
"from",
"a",
"key",
"if",
"found",
".",
"otherwise",
"it",
"just",
"returns",
"the",
"key",
"to",
"be",
"used",
"as",
"the",
"key",
"id",
"."
] | cfc787d90482eb6a2037cfbf4863bd144582662d | https://github.com/mishan/twemredis-py/blob/cfc787d90482eb6a2037cfbf4863bd144582662d/twemredis.py#L261-L284 |
41,740 | mishan/twemredis-py | twemredis.py | TwemRedis.compute_canonical_key_ids | def compute_canonical_key_ids(self, search_amplifier=100):
"""
A canonical key id is the lowest integer key id that maps to
a particular shard. The mapping to canonical key ids depends on the
number of shards.
Returns a dictionary mapping from shard number to canonical key id.
... | python | def compute_canonical_key_ids(self, search_amplifier=100):
"""
A canonical key id is the lowest integer key id that maps to
a particular shard. The mapping to canonical key ids depends on the
number of shards.
Returns a dictionary mapping from shard number to canonical key id.
... | [
"def",
"compute_canonical_key_ids",
"(",
"self",
",",
"search_amplifier",
"=",
"100",
")",
":",
"canonical_keys",
"=",
"{",
"}",
"num_shards",
"=",
"self",
".",
"num_shards",
"(",
")",
"# Guarantees enough to find all keys without running forever",
"num_iterations",
"="... | A canonical key id is the lowest integer key id that maps to
a particular shard. The mapping to canonical key ids depends on the
number of shards.
Returns a dictionary mapping from shard number to canonical key id.
This method will throw an exception if it fails to compute all of
... | [
"A",
"canonical",
"key",
"id",
"is",
"the",
"lowest",
"integer",
"key",
"id",
"that",
"maps",
"to",
"a",
"particular",
"shard",
".",
"The",
"mapping",
"to",
"canonical",
"key",
"ids",
"depends",
"on",
"the",
"number",
"of",
"shards",
"."
] | cfc787d90482eb6a2037cfbf4863bd144582662d | https://github.com/mishan/twemredis-py/blob/cfc787d90482eb6a2037cfbf4863bd144582662d/twemredis.py#L286-L315 |
41,741 | mishan/twemredis-py | twemredis.py | TwemRedis.keys | def keys(self, args):
"""
keys wrapper that queries every shard. This is an expensive
operation.
This method should be invoked on a TwemRedis instance as if it
were being invoked directly on a StrictRedis instance.
"""
results = {}
# TODO: parallelize
... | python | def keys(self, args):
"""
keys wrapper that queries every shard. This is an expensive
operation.
This method should be invoked on a TwemRedis instance as if it
were being invoked directly on a StrictRedis instance.
"""
results = {}
# TODO: parallelize
... | [
"def",
"keys",
"(",
"self",
",",
"args",
")",
":",
"results",
"=",
"{",
"}",
"# TODO: parallelize",
"for",
"shard_num",
"in",
"range",
"(",
"0",
",",
"self",
".",
"num_shards",
"(",
")",
")",
":",
"shard",
"=",
"self",
".",
"get_shard_by_num",
"(",
"... | keys wrapper that queries every shard. This is an expensive
operation.
This method should be invoked on a TwemRedis instance as if it
were being invoked directly on a StrictRedis instance. | [
"keys",
"wrapper",
"that",
"queries",
"every",
"shard",
".",
"This",
"is",
"an",
"expensive",
"operation",
"."
] | cfc787d90482eb6a2037cfbf4863bd144582662d | https://github.com/mishan/twemredis-py/blob/cfc787d90482eb6a2037cfbf4863bd144582662d/twemredis.py#L336-L349 |
41,742 | mishan/twemredis-py | twemredis.py | TwemRedis.mget | def mget(self, args):
"""
mget wrapper that batches keys per shard and execute as few
mgets as necessary to fetch the keys from all the shards involved.
This method should be invoked on a TwemRedis instance as if it
were being invoked directly on a StrictRedis instance.
... | python | def mget(self, args):
"""
mget wrapper that batches keys per shard and execute as few
mgets as necessary to fetch the keys from all the shards involved.
This method should be invoked on a TwemRedis instance as if it
were being invoked directly on a StrictRedis instance.
... | [
"def",
"mget",
"(",
"self",
",",
"args",
")",
":",
"key_map",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"results",
"=",
"{",
"}",
"for",
"key",
"in",
"args",
":",
"shard_num",
"=",
"self",
".",
"get_shard_num_by_key",
"(",
"key",
")",
... | mget wrapper that batches keys per shard and execute as few
mgets as necessary to fetch the keys from all the shards involved.
This method should be invoked on a TwemRedis instance as if it
were being invoked directly on a StrictRedis instance. | [
"mget",
"wrapper",
"that",
"batches",
"keys",
"per",
"shard",
"and",
"execute",
"as",
"few",
"mgets",
"as",
"necessary",
"to",
"fetch",
"the",
"keys",
"from",
"all",
"the",
"shards",
"involved",
"."
] | cfc787d90482eb6a2037cfbf4863bd144582662d | https://github.com/mishan/twemredis-py/blob/cfc787d90482eb6a2037cfbf4863bd144582662d/twemredis.py#L351-L369 |
41,743 | mishan/twemredis-py | twemredis.py | TwemRedis.mset | def mset(self, args):
"""
mset wrapper that batches keys per shard and execute as few
msets as necessary to set the keys in all the shards involved.
This method should be invoked on a TwemRedis instance as if it
were being invoked directly on a StrictRedis instance.
"""
... | python | def mset(self, args):
"""
mset wrapper that batches keys per shard and execute as few
msets as necessary to set the keys in all the shards involved.
This method should be invoked on a TwemRedis instance as if it
were being invoked directly on a StrictRedis instance.
"""
... | [
"def",
"mset",
"(",
"self",
",",
"args",
")",
":",
"key_map",
"=",
"collections",
".",
"defaultdict",
"(",
"dict",
")",
"result_count",
"=",
"0",
"for",
"key",
"in",
"args",
".",
"keys",
"(",
")",
":",
"value",
"=",
"args",
"[",
"key",
"]",
"shard_... | mset wrapper that batches keys per shard and execute as few
msets as necessary to set the keys in all the shards involved.
This method should be invoked on a TwemRedis instance as if it
were being invoked directly on a StrictRedis instance. | [
"mset",
"wrapper",
"that",
"batches",
"keys",
"per",
"shard",
"and",
"execute",
"as",
"few",
"msets",
"as",
"necessary",
"to",
"set",
"the",
"keys",
"in",
"all",
"the",
"shards",
"involved",
"."
] | cfc787d90482eb6a2037cfbf4863bd144582662d | https://github.com/mishan/twemredis-py/blob/cfc787d90482eb6a2037cfbf4863bd144582662d/twemredis.py#L371-L391 |
41,744 | helixyte/everest | everest/utils.py | id_generator | def id_generator(start=0):
"""
Generator for sequential numeric numbers.
"""
count = start
while True:
send_value = (yield count)
if not send_value is None:
if send_value < count:
raise ValueError('Values from ID generator must increase '
... | python | def id_generator(start=0):
"""
Generator for sequential numeric numbers.
"""
count = start
while True:
send_value = (yield count)
if not send_value is None:
if send_value < count:
raise ValueError('Values from ID generator must increase '
... | [
"def",
"id_generator",
"(",
"start",
"=",
"0",
")",
":",
"count",
"=",
"start",
"while",
"True",
":",
"send_value",
"=",
"(",
"yield",
"count",
")",
"if",
"not",
"send_value",
"is",
"None",
":",
"if",
"send_value",
"<",
"count",
":",
"raise",
"ValueErr... | Generator for sequential numeric numbers. | [
"Generator",
"for",
"sequential",
"numeric",
"numbers",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/utils.py#L108-L123 |
41,745 | helixyte/everest | everest/utils.py | generative | def generative(func):
"""
Marks an instance method as generative.
"""
def wrap(inst, *args, **kw):
clone = type(inst).__new__(type(inst))
clone.__dict__ = inst.__dict__.copy()
return func(clone, *args, **kw)
return update_wrapper(wrap, func) | python | def generative(func):
"""
Marks an instance method as generative.
"""
def wrap(inst, *args, **kw):
clone = type(inst).__new__(type(inst))
clone.__dict__ = inst.__dict__.copy()
return func(clone, *args, **kw)
return update_wrapper(wrap, func) | [
"def",
"generative",
"(",
"func",
")",
":",
"def",
"wrap",
"(",
"inst",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"clone",
"=",
"type",
"(",
"inst",
")",
".",
"__new__",
"(",
"type",
"(",
"inst",
")",
")",
"clone",
".",
"__dict__",
"=",
... | Marks an instance method as generative. | [
"Marks",
"an",
"instance",
"method",
"as",
"generative",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/utils.py#L506-L514 |
41,746 | helixyte/everest | everest/utils.py | truncate | def truncate(message, limit=500):
"""
Truncates the message to the given limit length. The beginning and the
end of the message are left untouched.
"""
if len(message) > limit:
trc_msg = ''.join([message[:limit // 2 - 2],
' .. ',
message[... | python | def truncate(message, limit=500):
"""
Truncates the message to the given limit length. The beginning and the
end of the message are left untouched.
"""
if len(message) > limit:
trc_msg = ''.join([message[:limit // 2 - 2],
' .. ',
message[... | [
"def",
"truncate",
"(",
"message",
",",
"limit",
"=",
"500",
")",
":",
"if",
"len",
"(",
"message",
")",
">",
"limit",
":",
"trc_msg",
"=",
"''",
".",
"join",
"(",
"[",
"message",
"[",
":",
"limit",
"//",
"2",
"-",
"2",
"]",
",",
"' .. '",
",",... | Truncates the message to the given limit length. The beginning and the
end of the message are left untouched. | [
"Truncates",
"the",
"message",
"to",
"the",
"given",
"limit",
"length",
".",
"The",
"beginning",
"and",
"the",
"end",
"of",
"the",
"message",
"are",
"left",
"untouched",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/utils.py#L517-L528 |
41,747 | ponty/confduino | confduino/boardremove.py | remove_board | def remove_board(board_id):
"""remove board.
:param board_id: board id (e.g. 'diecimila')
:rtype: None
"""
log.debug('remove %s', board_id)
lines = boards_txt().lines()
lines = filter(lambda x: not x.strip().startswith(board_id + '.'), lines)
boards_txt().write_lines(lines) | python | def remove_board(board_id):
"""remove board.
:param board_id: board id (e.g. 'diecimila')
:rtype: None
"""
log.debug('remove %s', board_id)
lines = boards_txt().lines()
lines = filter(lambda x: not x.strip().startswith(board_id + '.'), lines)
boards_txt().write_lines(lines) | [
"def",
"remove_board",
"(",
"board_id",
")",
":",
"log",
".",
"debug",
"(",
"'remove %s'",
",",
"board_id",
")",
"lines",
"=",
"boards_txt",
"(",
")",
".",
"lines",
"(",
")",
"lines",
"=",
"filter",
"(",
"lambda",
"x",
":",
"not",
"x",
".",
"strip",
... | remove board.
:param board_id: board id (e.g. 'diecimila')
:rtype: None | [
"remove",
"board",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/boardremove.py#L9-L20 |
41,748 | AtomHash/evernode | evernode/classes/load_modules.py | LoadModules.make_route | def make_route(self, route) -> dict:
""" Construct a route to be parsed into flask App """
middleware = route['middleware'] if 'middleware' in route else None
# added to ALL requests to support xhr cross-site requests
route['methods'].append('OPTIONS')
return {
... | python | def make_route(self, route) -> dict:
""" Construct a route to be parsed into flask App """
middleware = route['middleware'] if 'middleware' in route else None
# added to ALL requests to support xhr cross-site requests
route['methods'].append('OPTIONS')
return {
... | [
"def",
"make_route",
"(",
"self",
",",
"route",
")",
"->",
"dict",
":",
"middleware",
"=",
"route",
"[",
"'middleware'",
"]",
"if",
"'middleware'",
"in",
"route",
"else",
"None",
"# added to ALL requests to support xhr cross-site requests\r",
"route",
"[",
"'methods... | Construct a route to be parsed into flask App | [
"Construct",
"a",
"route",
"to",
"be",
"parsed",
"into",
"flask",
"App"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/load_modules.py#L36-L51 |
41,749 | pbrisk/timewave | timewave/stochasticprocess/base.py | StochasticProcess.diffusion_driver | def diffusion_driver(self):
""" diffusion driver are the underlying `dW` of each process `X` in a SDE like `dX = m dt + s dW`
:return list(StochasticProcess):
"""
if self._diffusion_driver is None:
return self,
if isinstance(self._diffusion_driver, list):
... | python | def diffusion_driver(self):
""" diffusion driver are the underlying `dW` of each process `X` in a SDE like `dX = m dt + s dW`
:return list(StochasticProcess):
"""
if self._diffusion_driver is None:
return self,
if isinstance(self._diffusion_driver, list):
... | [
"def",
"diffusion_driver",
"(",
"self",
")",
":",
"if",
"self",
".",
"_diffusion_driver",
"is",
"None",
":",
"return",
"self",
",",
"if",
"isinstance",
"(",
"self",
".",
"_diffusion_driver",
",",
"list",
")",
":",
"return",
"tuple",
"(",
"self",
".",
"_d... | diffusion driver are the underlying `dW` of each process `X` in a SDE like `dX = m dt + s dW`
:return list(StochasticProcess): | [
"diffusion",
"driver",
"are",
"the",
"underlying",
"dW",
"of",
"each",
"process",
"X",
"in",
"a",
"SDE",
"like",
"dX",
"=",
"m",
"dt",
"+",
"s",
"dW"
] | cf641391d1607a424042724c8b990d43ee270ef6 | https://github.com/pbrisk/timewave/blob/cf641391d1607a424042724c8b990d43ee270ef6/timewave/stochasticprocess/base.py#L15-L27 |
41,750 | clinicedc/edc-permissions | edc_permissions/historical_permissions_updater.py | HistoricalPermissionUpdater.reset_codenames | def reset_codenames(self, dry_run=None, clear_existing=None):
"""Ensures all historical model codenames exist in Django's Permission
model.
"""
self.created_codenames = []
self.updated_names = []
actions = ["add", "change", "delete", "view"]
if django.VERSION >= (... | python | def reset_codenames(self, dry_run=None, clear_existing=None):
"""Ensures all historical model codenames exist in Django's Permission
model.
"""
self.created_codenames = []
self.updated_names = []
actions = ["add", "change", "delete", "view"]
if django.VERSION >= (... | [
"def",
"reset_codenames",
"(",
"self",
",",
"dry_run",
"=",
"None",
",",
"clear_existing",
"=",
"None",
")",
":",
"self",
".",
"created_codenames",
"=",
"[",
"]",
"self",
".",
"updated_names",
"=",
"[",
"]",
"actions",
"=",
"[",
"\"add\"",
",",
"\"change... | Ensures all historical model codenames exist in Django's Permission
model. | [
"Ensures",
"all",
"historical",
"model",
"codenames",
"exist",
"in",
"Django",
"s",
"Permission",
"model",
"."
] | d1aee39a8ddaf4b7741d9306139ddd03625d4e1a | https://github.com/clinicedc/edc-permissions/blob/d1aee39a8ddaf4b7741d9306139ddd03625d4e1a/edc_permissions/historical_permissions_updater.py#L49-L79 |
41,751 | helixyte/everest | everest/resources/attributes.py | is_resource_class_member_attribute | def is_resource_class_member_attribute(rc, attr_name):
"""
Checks if the given attribute name is a member attribute of the given
registered resource.
"""
attr = get_resource_class_attribute(rc, attr_name)
return attr.kind == RESOURCE_ATTRIBUTE_KINDS.MEMBER | python | def is_resource_class_member_attribute(rc, attr_name):
"""
Checks if the given attribute name is a member attribute of the given
registered resource.
"""
attr = get_resource_class_attribute(rc, attr_name)
return attr.kind == RESOURCE_ATTRIBUTE_KINDS.MEMBER | [
"def",
"is_resource_class_member_attribute",
"(",
"rc",
",",
"attr_name",
")",
":",
"attr",
"=",
"get_resource_class_attribute",
"(",
"rc",
",",
"attr_name",
")",
"return",
"attr",
".",
"kind",
"==",
"RESOURCE_ATTRIBUTE_KINDS",
".",
"MEMBER"
] | Checks if the given attribute name is a member attribute of the given
registered resource. | [
"Checks",
"if",
"the",
"given",
"attribute",
"name",
"is",
"a",
"member",
"attribute",
"of",
"the",
"given",
"registered",
"resource",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/attributes.py#L124-L130 |
41,752 | helixyte/everest | everest/resources/attributes.py | is_resource_class_collection_attribute | def is_resource_class_collection_attribute(rc, attr_name):
"""
Checks if the given attribute name is a collection attribute of the given
registered resource.
"""
attr = get_resource_class_attribute(rc, attr_name)
return attr.kind == RESOURCE_ATTRIBUTE_KINDS.COLLECTION | python | def is_resource_class_collection_attribute(rc, attr_name):
"""
Checks if the given attribute name is a collection attribute of the given
registered resource.
"""
attr = get_resource_class_attribute(rc, attr_name)
return attr.kind == RESOURCE_ATTRIBUTE_KINDS.COLLECTION | [
"def",
"is_resource_class_collection_attribute",
"(",
"rc",
",",
"attr_name",
")",
":",
"attr",
"=",
"get_resource_class_attribute",
"(",
"rc",
",",
"attr_name",
")",
"return",
"attr",
".",
"kind",
"==",
"RESOURCE_ATTRIBUTE_KINDS",
".",
"COLLECTION"
] | Checks if the given attribute name is a collection attribute of the given
registered resource. | [
"Checks",
"if",
"the",
"given",
"attribute",
"name",
"is",
"a",
"collection",
"attribute",
"of",
"the",
"given",
"registered",
"resource",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/attributes.py#L133-L139 |
41,753 | seancallaway/laughs | laughs/services/ronswanson.py | get_joke | def get_joke():
"""Return a Ron Swanson quote.
Returns None if unable to retrieve a quote.
"""
page = requests.get("http://ron-swanson-quotes.herokuapp.com/v2/quotes")
if page.status_code == 200:
jokes = []
jokes = json.loads(page.content.decode(page.encoding))
return ... | python | def get_joke():
"""Return a Ron Swanson quote.
Returns None if unable to retrieve a quote.
"""
page = requests.get("http://ron-swanson-quotes.herokuapp.com/v2/quotes")
if page.status_code == 200:
jokes = []
jokes = json.loads(page.content.decode(page.encoding))
return ... | [
"def",
"get_joke",
"(",
")",
":",
"page",
"=",
"requests",
".",
"get",
"(",
"\"http://ron-swanson-quotes.herokuapp.com/v2/quotes\"",
")",
"if",
"page",
".",
"status_code",
"==",
"200",
":",
"jokes",
"=",
"[",
"]",
"jokes",
"=",
"json",
".",
"loads",
"(",
"... | Return a Ron Swanson quote.
Returns None if unable to retrieve a quote. | [
"Return",
"a",
"Ron",
"Swanson",
"quote",
"."
] | e13ca6f16b12401b0384bbf1fea86c081e52143d | https://github.com/seancallaway/laughs/blob/e13ca6f16b12401b0384bbf1fea86c081e52143d/laughs/services/ronswanson.py#L13-L26 |
41,754 | childsish/lhc-python | lhc/misc/tools.py | window | def window(iterable, n=2, cast=tuple):
""" This function passes a running window along the length of the given
iterable. By default, the return value is a tuple, but the cast
parameter can be used to change the final result.
"""
it = iter(iterable)
win = deque((next(it) for _ in repeat(... | python | def window(iterable, n=2, cast=tuple):
""" This function passes a running window along the length of the given
iterable. By default, the return value is a tuple, but the cast
parameter can be used to change the final result.
"""
it = iter(iterable)
win = deque((next(it) for _ in repeat(... | [
"def",
"window",
"(",
"iterable",
",",
"n",
"=",
"2",
",",
"cast",
"=",
"tuple",
")",
":",
"it",
"=",
"iter",
"(",
"iterable",
")",
"win",
"=",
"deque",
"(",
"(",
"next",
"(",
"it",
")",
"for",
"_",
"in",
"repeat",
"(",
"None",
",",
"n",
")",... | This function passes a running window along the length of the given
iterable. By default, the return value is a tuple, but the cast
parameter can be used to change the final result. | [
"This",
"function",
"passes",
"a",
"running",
"window",
"along",
"the",
"length",
"of",
"the",
"given",
"iterable",
".",
"By",
"default",
"the",
"return",
"value",
"is",
"a",
"tuple",
"but",
"the",
"cast",
"parameter",
"can",
"be",
"used",
"to",
"change",
... | 0a669f46a40a39f24d28665e8b5b606dc7e86beb | https://github.com/childsish/lhc-python/blob/0a669f46a40a39f24d28665e8b5b606dc7e86beb/lhc/misc/tools.py#L22-L35 |
41,755 | xolox/python-update-dotdee | update_dotdee/cli.py | main | def main():
"""Command line interface for the ``update-dotdee`` program."""
# Initialize logging to the terminal and system log.
coloredlogs.install(syslog=True)
# Parse the command line arguments.
context_opts = {}
program_opts = {}
try:
options, arguments = getopt.getopt(sys.argv[1... | python | def main():
"""Command line interface for the ``update-dotdee`` program."""
# Initialize logging to the terminal and system log.
coloredlogs.install(syslog=True)
# Parse the command line arguments.
context_opts = {}
program_opts = {}
try:
options, arguments = getopt.getopt(sys.argv[1... | [
"def",
"main",
"(",
")",
":",
"# Initialize logging to the terminal and system log.",
"coloredlogs",
".",
"install",
"(",
"syslog",
"=",
"True",
")",
"# Parse the command line arguments.",
"context_opts",
"=",
"{",
"}",
"program_opts",
"=",
"{",
"}",
"try",
":",
"op... | Command line interface for the ``update-dotdee`` program. | [
"Command",
"line",
"interface",
"for",
"the",
"update",
"-",
"dotdee",
"program",
"."
] | 04d5836f0d217e32778745b533beeb8159d80c32 | https://github.com/xolox/python-update-dotdee/blob/04d5836f0d217e32778745b533beeb8159d80c32/update_dotdee/cli.py#L65-L111 |
41,756 | MisterY/pydatum | pydatum/datum.py | Datum.add_months | def add_months(self, value: int) -> datetime:
""" Add a number of months to the given date """
self.value = self.value + relativedelta(months=value)
return self.value | python | def add_months(self, value: int) -> datetime:
""" Add a number of months to the given date """
self.value = self.value + relativedelta(months=value)
return self.value | [
"def",
"add_months",
"(",
"self",
",",
"value",
":",
"int",
")",
"->",
"datetime",
":",
"self",
".",
"value",
"=",
"self",
".",
"value",
"+",
"relativedelta",
"(",
"months",
"=",
"value",
")",
"return",
"self",
".",
"value"
] | Add a number of months to the given date | [
"Add",
"a",
"number",
"of",
"months",
"to",
"the",
"given",
"date"
] | 4b39f43040e31a95bcf219603b6429078a9ba3c2 | https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L36-L39 |
41,757 | MisterY/pydatum | pydatum/datum.py | Datum.from_date | def from_date(self, value: date) -> datetime:
""" Initializes from the given date value """
assert isinstance(value, date)
#self.value = datetime.combine(value, time.min)
self.value = datetime(value.year, value.month, value.day)
return self.value | python | def from_date(self, value: date) -> datetime:
""" Initializes from the given date value """
assert isinstance(value, date)
#self.value = datetime.combine(value, time.min)
self.value = datetime(value.year, value.month, value.day)
return self.value | [
"def",
"from_date",
"(",
"self",
",",
"value",
":",
"date",
")",
"->",
"datetime",
":",
"assert",
"isinstance",
"(",
"value",
",",
"date",
")",
"#self.value = datetime.combine(value, time.min)",
"self",
".",
"value",
"=",
"datetime",
"(",
"value",
".",
"year",... | Initializes from the given date value | [
"Initializes",
"from",
"the",
"given",
"date",
"value"
] | 4b39f43040e31a95bcf219603b6429078a9ba3c2 | https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L62-L68 |
41,758 | MisterY/pydatum | pydatum/datum.py | Datum.get_day_name | def get_day_name(self) -> str:
""" Returns the day name """
weekday = self.value.isoweekday() - 1
return calendar.day_name[weekday] | python | def get_day_name(self) -> str:
""" Returns the day name """
weekday = self.value.isoweekday() - 1
return calendar.day_name[weekday] | [
"def",
"get_day_name",
"(",
"self",
")",
"->",
"str",
":",
"weekday",
"=",
"self",
".",
"value",
".",
"isoweekday",
"(",
")",
"-",
"1",
"return",
"calendar",
".",
"day_name",
"[",
"weekday",
"]"
] | Returns the day name | [
"Returns",
"the",
"day",
"name"
] | 4b39f43040e31a95bcf219603b6429078a9ba3c2 | https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L95-L98 |
41,759 | MisterY/pydatum | pydatum/datum.py | Datum.to_iso_string | def to_iso_string(self) -> str:
""" Returns full ISO string for the given date """
assert isinstance(self.value, datetime)
return datetime.isoformat(self.value) | python | def to_iso_string(self) -> str:
""" Returns full ISO string for the given date """
assert isinstance(self.value, datetime)
return datetime.isoformat(self.value) | [
"def",
"to_iso_string",
"(",
"self",
")",
"->",
"str",
":",
"assert",
"isinstance",
"(",
"self",
".",
"value",
",",
"datetime",
")",
"return",
"datetime",
".",
"isoformat",
"(",
"self",
".",
"value",
")"
] | Returns full ISO string for the given date | [
"Returns",
"full",
"ISO",
"string",
"for",
"the",
"given",
"date"
] | 4b39f43040e31a95bcf219603b6429078a9ba3c2 | https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L110-L113 |
41,760 | MisterY/pydatum | pydatum/datum.py | Datum.end_of_day | def end_of_day(self) -> datetime:
""" End of day """
self.value = datetime(self.value.year, self.value.month, self.value.day, 23, 59, 59)
return self.value | python | def end_of_day(self) -> datetime:
""" End of day """
self.value = datetime(self.value.year, self.value.month, self.value.day, 23, 59, 59)
return self.value | [
"def",
"end_of_day",
"(",
"self",
")",
"->",
"datetime",
":",
"self",
".",
"value",
"=",
"datetime",
"(",
"self",
".",
"value",
".",
"year",
",",
"self",
".",
"value",
".",
"month",
",",
"self",
".",
"value",
".",
"day",
",",
"23",
",",
"59",
","... | End of day | [
"End",
"of",
"day"
] | 4b39f43040e31a95bcf219603b6429078a9ba3c2 | https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L123-L126 |
41,761 | MisterY/pydatum | pydatum/datum.py | Datum.end_of_month | def end_of_month(self) -> datetime:
""" Provides end of the month for the given date """
# Increase month by 1,
result = self.value + relativedelta(months=1)
# take the 1st day of the (next) month,
result = result.replace(day=1)
# subtract one day
result = result ... | python | def end_of_month(self) -> datetime:
""" Provides end of the month for the given date """
# Increase month by 1,
result = self.value + relativedelta(months=1)
# take the 1st day of the (next) month,
result = result.replace(day=1)
# subtract one day
result = result ... | [
"def",
"end_of_month",
"(",
"self",
")",
"->",
"datetime",
":",
"# Increase month by 1,",
"result",
"=",
"self",
".",
"value",
"+",
"relativedelta",
"(",
"months",
"=",
"1",
")",
"# take the 1st day of the (next) month,",
"result",
"=",
"result",
".",
"replace",
... | Provides end of the month for the given date | [
"Provides",
"end",
"of",
"the",
"month",
"for",
"the",
"given",
"date"
] | 4b39f43040e31a95bcf219603b6429078a9ba3c2 | https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L128-L137 |
41,762 | MisterY/pydatum | pydatum/datum.py | Datum.is_end_of_month | def is_end_of_month(self) -> bool:
""" Checks if the date is at the end of the month """
end_of_month = Datum()
# get_end_of_month(value)
end_of_month.end_of_month()
return self.value == end_of_month.value | python | def is_end_of_month(self) -> bool:
""" Checks if the date is at the end of the month """
end_of_month = Datum()
# get_end_of_month(value)
end_of_month.end_of_month()
return self.value == end_of_month.value | [
"def",
"is_end_of_month",
"(",
"self",
")",
"->",
"bool",
":",
"end_of_month",
"=",
"Datum",
"(",
")",
"# get_end_of_month(value)",
"end_of_month",
".",
"end_of_month",
"(",
")",
"return",
"self",
".",
"value",
"==",
"end_of_month",
".",
"value"
] | Checks if the date is at the end of the month | [
"Checks",
"if",
"the",
"date",
"is",
"at",
"the",
"end",
"of",
"the",
"month"
] | 4b39f43040e31a95bcf219603b6429078a9ba3c2 | https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L139-L144 |
41,763 | MisterY/pydatum | pydatum/datum.py | Datum.set_day | def set_day(self, day: int) -> datetime:
""" Sets the day value """
self.value = self.value.replace(day=day)
return self.value | python | def set_day(self, day: int) -> datetime:
""" Sets the day value """
self.value = self.value.replace(day=day)
return self.value | [
"def",
"set_day",
"(",
"self",
",",
"day",
":",
"int",
")",
"->",
"datetime",
":",
"self",
".",
"value",
"=",
"self",
".",
"value",
".",
"replace",
"(",
"day",
"=",
"day",
")",
"return",
"self",
".",
"value"
] | Sets the day value | [
"Sets",
"the",
"day",
"value"
] | 4b39f43040e31a95bcf219603b6429078a9ba3c2 | https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L146-L149 |
41,764 | MisterY/pydatum | pydatum/datum.py | Datum.set_value | def set_value(self, value: datetime):
""" Sets the current value """
assert isinstance(value, datetime)
self.value = value | python | def set_value(self, value: datetime):
""" Sets the current value """
assert isinstance(value, datetime)
self.value = value | [
"def",
"set_value",
"(",
"self",
",",
"value",
":",
"datetime",
")",
":",
"assert",
"isinstance",
"(",
"value",
",",
"datetime",
")",
"self",
".",
"value",
"=",
"value"
] | Sets the current value | [
"Sets",
"the",
"current",
"value"
] | 4b39f43040e31a95bcf219603b6429078a9ba3c2 | https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L151-L155 |
41,765 | MisterY/pydatum | pydatum/datum.py | Datum.start_of_day | def start_of_day(self) -> datetime:
""" Returns start of day """
self.value = datetime(self.value.year, self.value.month, self.value.day)
return self.value | python | def start_of_day(self) -> datetime:
""" Returns start of day """
self.value = datetime(self.value.year, self.value.month, self.value.day)
return self.value | [
"def",
"start_of_day",
"(",
"self",
")",
"->",
"datetime",
":",
"self",
".",
"value",
"=",
"datetime",
"(",
"self",
".",
"value",
".",
"year",
",",
"self",
".",
"value",
".",
"month",
",",
"self",
".",
"value",
".",
"day",
")",
"return",
"self",
".... | Returns start of day | [
"Returns",
"start",
"of",
"day"
] | 4b39f43040e31a95bcf219603b6429078a9ba3c2 | https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L157-L160 |
41,766 | MisterY/pydatum | pydatum/datum.py | Datum.subtract_days | def subtract_days(self, days: int) -> datetime:
""" Subtracts dates from the given value """
self.value = self.value - relativedelta(days=days)
return self.value | python | def subtract_days(self, days: int) -> datetime:
""" Subtracts dates from the given value """
self.value = self.value - relativedelta(days=days)
return self.value | [
"def",
"subtract_days",
"(",
"self",
",",
"days",
":",
"int",
")",
"->",
"datetime",
":",
"self",
".",
"value",
"=",
"self",
".",
"value",
"-",
"relativedelta",
"(",
"days",
"=",
"days",
")",
"return",
"self",
".",
"value"
] | Subtracts dates from the given value | [
"Subtracts",
"dates",
"from",
"the",
"given",
"value"
] | 4b39f43040e31a95bcf219603b6429078a9ba3c2 | https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L162-L165 |
41,767 | MisterY/pydatum | pydatum/datum.py | Datum.subtract_weeks | def subtract_weeks(self, weeks: int) -> datetime:
""" Subtracts number of weeks from the current value """
self.value = self.value - timedelta(weeks=weeks)
return self.value | python | def subtract_weeks(self, weeks: int) -> datetime:
""" Subtracts number of weeks from the current value """
self.value = self.value - timedelta(weeks=weeks)
return self.value | [
"def",
"subtract_weeks",
"(",
"self",
",",
"weeks",
":",
"int",
")",
"->",
"datetime",
":",
"self",
".",
"value",
"=",
"self",
".",
"value",
"-",
"timedelta",
"(",
"weeks",
"=",
"weeks",
")",
"return",
"self",
".",
"value"
] | Subtracts number of weeks from the current value | [
"Subtracts",
"number",
"of",
"weeks",
"from",
"the",
"current",
"value"
] | 4b39f43040e31a95bcf219603b6429078a9ba3c2 | https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L167-L170 |
41,768 | MisterY/pydatum | pydatum/datum.py | Datum.subtract_months | def subtract_months(self, months: int) -> datetime:
""" Subtracts a number of months from the current value """
self.value = self.value - relativedelta(months=months)
return self.value | python | def subtract_months(self, months: int) -> datetime:
""" Subtracts a number of months from the current value """
self.value = self.value - relativedelta(months=months)
return self.value | [
"def",
"subtract_months",
"(",
"self",
",",
"months",
":",
"int",
")",
"->",
"datetime",
":",
"self",
".",
"value",
"=",
"self",
".",
"value",
"-",
"relativedelta",
"(",
"months",
"=",
"months",
")",
"return",
"self",
".",
"value"
] | Subtracts a number of months from the current value | [
"Subtracts",
"a",
"number",
"of",
"months",
"from",
"the",
"current",
"value"
] | 4b39f43040e31a95bcf219603b6429078a9ba3c2 | https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L172-L175 |
41,769 | MisterY/pydatum | pydatum/datum.py | Datum.yesterday | def yesterday(self) -> datetime:
""" Set the value to yesterday """
self.value = datetime.today() - timedelta(days=1)
return self.value | python | def yesterday(self) -> datetime:
""" Set the value to yesterday """
self.value = datetime.today() - timedelta(days=1)
return self.value | [
"def",
"yesterday",
"(",
"self",
")",
"->",
"datetime",
":",
"self",
".",
"value",
"=",
"datetime",
".",
"today",
"(",
")",
"-",
"timedelta",
"(",
"days",
"=",
"1",
")",
"return",
"self",
".",
"value"
] | Set the value to yesterday | [
"Set",
"the",
"value",
"to",
"yesterday"
] | 4b39f43040e31a95bcf219603b6429078a9ba3c2 | https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L218-L221 |
41,770 | hsdp/python-dropsonde | dropsonde/util.py | get_uuid_string | def get_uuid_string(low=None, high=None, **x):
"""This method parses a UUID protobuf message type from its component
'high' and 'low' longs into a standard formatted UUID string
Args:
x (dict): containing keys, 'low' and 'high' corresponding to the UUID
protobuf message type
Return... | python | def get_uuid_string(low=None, high=None, **x):
"""This method parses a UUID protobuf message type from its component
'high' and 'low' longs into a standard formatted UUID string
Args:
x (dict): containing keys, 'low' and 'high' corresponding to the UUID
protobuf message type
Return... | [
"def",
"get_uuid_string",
"(",
"low",
"=",
"None",
",",
"high",
"=",
"None",
",",
"*",
"*",
"x",
")",
":",
"if",
"low",
"is",
"None",
"or",
"high",
"is",
"None",
":",
"return",
"None",
"x",
"=",
"''",
".",
"join",
"(",
"[",
"parse_part",
"(",
"... | This method parses a UUID protobuf message type from its component
'high' and 'low' longs into a standard formatted UUID string
Args:
x (dict): containing keys, 'low' and 'high' corresponding to the UUID
protobuf message type
Returns:
str: UUID formatted string | [
"This",
"method",
"parses",
"a",
"UUID",
"protobuf",
"message",
"type",
"from",
"its",
"component",
"high",
"and",
"low",
"longs",
"into",
"a",
"standard",
"formatted",
"UUID",
"string"
] | e72680a3139cbb5ee4910ce1bbc2ccbaa227fb07 | https://github.com/hsdp/python-dropsonde/blob/e72680a3139cbb5ee4910ce1bbc2ccbaa227fb07/dropsonde/util.py#L25-L39 |
41,771 | Tommos0/pyzenodo | pyzenodo/zenodo.py | Zenodo.search | def search(self, search):
"""search Zenodo record for string `search`
:param search: string to search
:return: Record[] results
"""
search = search.replace('/', ' ') # zenodo can't handle '/' in search query
params = {'q': search}
return self._get_records(params... | python | def search(self, search):
"""search Zenodo record for string `search`
:param search: string to search
:return: Record[] results
"""
search = search.replace('/', ' ') # zenodo can't handle '/' in search query
params = {'q': search}
return self._get_records(params... | [
"def",
"search",
"(",
"self",
",",
"search",
")",
":",
"search",
"=",
"search",
".",
"replace",
"(",
"'/'",
",",
"' '",
")",
"# zenodo can't handle '/' in search query",
"params",
"=",
"{",
"'q'",
":",
"search",
"}",
"return",
"self",
".",
"_get_records",
... | search Zenodo record for string `search`
:param search: string to search
:return: Record[] results | [
"search",
"Zenodo",
"record",
"for",
"string",
"search"
] | 1d68a9346fc7f7558d006175cbb1fa5c928e6e66 | https://github.com/Tommos0/pyzenodo/blob/1d68a9346fc7f7558d006175cbb1fa5c928e6e66/pyzenodo/zenodo.py#L75-L83 |
41,772 | vicalloy/lbutils | lbutils/views.py | qdict_get_list | def qdict_get_list(qdict, k):
"""
get list from QueryDict and remove blank date from list.
"""
pks = qdict.getlist(k)
return [e for e in pks if e] | python | def qdict_get_list(qdict, k):
"""
get list from QueryDict and remove blank date from list.
"""
pks = qdict.getlist(k)
return [e for e in pks if e] | [
"def",
"qdict_get_list",
"(",
"qdict",
",",
"k",
")",
":",
"pks",
"=",
"qdict",
".",
"getlist",
"(",
"k",
")",
"return",
"[",
"e",
"for",
"e",
"in",
"pks",
"if",
"e",
"]"
] | get list from QueryDict and remove blank date from list. | [
"get",
"list",
"from",
"QueryDict",
"and",
"remove",
"blank",
"date",
"from",
"list",
"."
] | 66ae7e73bc939f073cdc1b91602a95e67caf4ba6 | https://github.com/vicalloy/lbutils/blob/66ae7e73bc939f073cdc1b91602a95e67caf4ba6/lbutils/views.py#L20-L25 |
41,773 | vicalloy/lbutils | lbutils/views.py | request_get_next | def request_get_next(request, default_next):
"""
get next url form request
order: POST.next GET.next HTTP_REFERER, default_next
"""
next_url = request.POST.get('next')\
or request.GET.get('next')\
or request.META.get('HTTP_REFERER')\
or default_next
return next_url | python | def request_get_next(request, default_next):
"""
get next url form request
order: POST.next GET.next HTTP_REFERER, default_next
"""
next_url = request.POST.get('next')\
or request.GET.get('next')\
or request.META.get('HTTP_REFERER')\
or default_next
return next_url | [
"def",
"request_get_next",
"(",
"request",
",",
"default_next",
")",
":",
"next_url",
"=",
"request",
".",
"POST",
".",
"get",
"(",
"'next'",
")",
"or",
"request",
".",
"GET",
".",
"get",
"(",
"'next'",
")",
"or",
"request",
".",
"META",
".",
"get",
... | get next url form request
order: POST.next GET.next HTTP_REFERER, default_next | [
"get",
"next",
"url",
"form",
"request"
] | 66ae7e73bc939f073cdc1b91602a95e67caf4ba6 | https://github.com/vicalloy/lbutils/blob/66ae7e73bc939f073cdc1b91602a95e67caf4ba6/lbutils/views.py#L28-L38 |
41,774 | foobarbecue/afterflight | afterflight/logbrowse/views.py | upload_progress | def upload_progress(request):
"""
AJAX view adapted from django-progressbarupload
Return the upload progress and total length values
"""
if 'X-Progress-ID' in request.GET:
progress_id = request.GET['X-Progress-ID']
elif 'X-Progress-ID' in request.META:
progress_id = request.META... | python | def upload_progress(request):
"""
AJAX view adapted from django-progressbarupload
Return the upload progress and total length values
"""
if 'X-Progress-ID' in request.GET:
progress_id = request.GET['X-Progress-ID']
elif 'X-Progress-ID' in request.META:
progress_id = request.META... | [
"def",
"upload_progress",
"(",
"request",
")",
":",
"if",
"'X-Progress-ID'",
"in",
"request",
".",
"GET",
":",
"progress_id",
"=",
"request",
".",
"GET",
"[",
"'X-Progress-ID'",
"]",
"elif",
"'X-Progress-ID'",
"in",
"request",
".",
"META",
":",
"progress_id",
... | AJAX view adapted from django-progressbarupload
Return the upload progress and total length values | [
"AJAX",
"view",
"adapted",
"from",
"django",
"-",
"progressbarupload"
] | 7085f719593f88999dce93f35caec5f15d2991b6 | https://github.com/foobarbecue/afterflight/blob/7085f719593f88999dce93f35caec5f15d2991b6/afterflight/logbrowse/views.py#L40-L58 |
41,775 | MisanthropicBit/colorise | colorise/BaseColorManager.py | BaseColorManager.set_color | def set_color(self, fg=None, bg=None, intensify=False, target=sys.stdout):
"""Set foreground- and background colors and intensity."""
raise NotImplementedError | python | def set_color(self, fg=None, bg=None, intensify=False, target=sys.stdout):
"""Set foreground- and background colors and intensity."""
raise NotImplementedError | [
"def",
"set_color",
"(",
"self",
",",
"fg",
"=",
"None",
",",
"bg",
"=",
"None",
",",
"intensify",
"=",
"False",
",",
"target",
"=",
"sys",
".",
"stdout",
")",
":",
"raise",
"NotImplementedError"
] | Set foreground- and background colors and intensity. | [
"Set",
"foreground",
"-",
"and",
"background",
"colors",
"and",
"intensity",
"."
] | e630df74b8b27680a43c370ddbe98766be50158c | https://github.com/MisanthropicBit/colorise/blob/e630df74b8b27680a43c370ddbe98766be50158c/colorise/BaseColorManager.py#L34-L36 |
41,776 | helixyte/everest | everest/repositories/memory/cache.py | EntityCache.add | def add(self, entity):
"""
Adds the given entity to this cache.
:param entity: Entity to add.
:type entity: Object implementing :class:`everest.interfaces.IEntity`.
:raises ValueError: If the ID of the entity to add is ``None``
(unless the `allow_none_id` constructor a... | python | def add(self, entity):
"""
Adds the given entity to this cache.
:param entity: Entity to add.
:type entity: Object implementing :class:`everest.interfaces.IEntity`.
:raises ValueError: If the ID of the entity to add is ``None``
(unless the `allow_none_id` constructor a... | [
"def",
"add",
"(",
"self",
",",
"entity",
")",
":",
"do_append",
"=",
"self",
".",
"__check_new",
"(",
"entity",
")",
"if",
"do_append",
":",
"self",
".",
"__entities",
".",
"append",
"(",
"entity",
")"
] | Adds the given entity to this cache.
:param entity: Entity to add.
:type entity: Object implementing :class:`everest.interfaces.IEntity`.
:raises ValueError: If the ID of the entity to add is ``None``
(unless the `allow_none_id` constructor argument was set). | [
"Adds",
"the",
"given",
"entity",
"to",
"this",
"cache",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/memory/cache.py#L75-L86 |
41,777 | helixyte/everest | everest/repositories/memory/cache.py | EntityCache.remove | def remove(self, entity):
"""
Removes the given entity from this cache.
:param entity: Entity to remove.
:type entity: Object implementing :class:`everest.interfaces.IEntity`.
:raises KeyError: If the given entity is not in this cache.
:raises ValueError: If the ID of th... | python | def remove(self, entity):
"""
Removes the given entity from this cache.
:param entity: Entity to remove.
:type entity: Object implementing :class:`everest.interfaces.IEntity`.
:raises KeyError: If the given entity is not in this cache.
:raises ValueError: If the ID of th... | [
"def",
"remove",
"(",
"self",
",",
"entity",
")",
":",
"self",
".",
"__id_map",
".",
"pop",
"(",
"entity",
".",
"id",
",",
"None",
")",
"self",
".",
"__slug_map",
".",
"pop",
"(",
"entity",
".",
"slug",
",",
"None",
")",
"self",
".",
"__entities",
... | Removes the given entity from this cache.
:param entity: Entity to remove.
:type entity: Object implementing :class:`everest.interfaces.IEntity`.
:raises KeyError: If the given entity is not in this cache.
:raises ValueError: If the ID of the given entity is `None`. | [
"Removes",
"the",
"given",
"entity",
"from",
"this",
"cache",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/memory/cache.py#L88-L99 |
41,778 | helixyte/everest | everest/repositories/memory/cache.py | EntityCache.retrieve | def retrieve(self, filter_expression=None,
order_expression=None, slice_key=None):
"""
Retrieve entities from this cache, possibly after filtering, ordering
and slicing.
"""
ents = iter(self.__entities)
if not filter_expression is None:
ents =... | python | def retrieve(self, filter_expression=None,
order_expression=None, slice_key=None):
"""
Retrieve entities from this cache, possibly after filtering, ordering
and slicing.
"""
ents = iter(self.__entities)
if not filter_expression is None:
ents =... | [
"def",
"retrieve",
"(",
"self",
",",
"filter_expression",
"=",
"None",
",",
"order_expression",
"=",
"None",
",",
"slice_key",
"=",
"None",
")",
":",
"ents",
"=",
"iter",
"(",
"self",
".",
"__entities",
")",
"if",
"not",
"filter_expression",
"is",
"None",
... | Retrieve entities from this cache, possibly after filtering, ordering
and slicing. | [
"Retrieve",
"entities",
"from",
"this",
"cache",
"possibly",
"after",
"filtering",
"ordering",
"and",
"slicing",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/memory/cache.py#L118-L133 |
41,779 | MKLab-ITI/reveal-user-annotation | reveal_user_annotation/twitter/user_annotate.py | extract_user_keywords_generator | def extract_user_keywords_generator(twitter_lists_gen, lemmatizing="wordnet"):
"""
Based on the user-related lists I have downloaded, annotate the users.
Inputs: - twitter_lists_gen: A python generator that yields a user Twitter id and a generator of Twitter lists.
- lemmatizing: A string conta... | python | def extract_user_keywords_generator(twitter_lists_gen, lemmatizing="wordnet"):
"""
Based on the user-related lists I have downloaded, annotate the users.
Inputs: - twitter_lists_gen: A python generator that yields a user Twitter id and a generator of Twitter lists.
- lemmatizing: A string conta... | [
"def",
"extract_user_keywords_generator",
"(",
"twitter_lists_gen",
",",
"lemmatizing",
"=",
"\"wordnet\"",
")",
":",
"####################################################################################################################",
"# Extract keywords serially.",
"#####################... | Based on the user-related lists I have downloaded, annotate the users.
Inputs: - twitter_lists_gen: A python generator that yields a user Twitter id and a generator of Twitter lists.
- lemmatizing: A string containing one of the following: "porter", "snowball" or "wordnet".
Yields: - user_twitter_... | [
"Based",
"on",
"the",
"user",
"-",
"related",
"lists",
"I",
"have",
"downloaded",
"annotate",
"the",
"users",
"."
] | ed019c031857b091e5601f53ba3f01a499a0e3ef | https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/twitter/user_annotate.py#L21-L51 |
41,780 | MKLab-ITI/reveal-user-annotation | reveal_user_annotation/twitter/user_annotate.py | form_user_label_matrix | def form_user_label_matrix(user_twitter_list_keywords_gen, id_to_node, max_number_of_labels):
"""
Forms the user-label matrix to be used in multi-label classification.
Input: - user_twitter_list_keywords_gen:
- id_to_node: A Twitter id to node map as a python dictionary.
Outputs: - use... | python | def form_user_label_matrix(user_twitter_list_keywords_gen, id_to_node, max_number_of_labels):
"""
Forms the user-label matrix to be used in multi-label classification.
Input: - user_twitter_list_keywords_gen:
- id_to_node: A Twitter id to node map as a python dictionary.
Outputs: - use... | [
"def",
"form_user_label_matrix",
"(",
"user_twitter_list_keywords_gen",
",",
"id_to_node",
",",
"max_number_of_labels",
")",
":",
"user_label_matrix",
",",
"annotated_nodes",
",",
"label_to_lemma",
",",
"node_to_lemma_tokeywordbag",
"=",
"form_user_term_matrix",
"(",
"user_tw... | Forms the user-label matrix to be used in multi-label classification.
Input: - user_twitter_list_keywords_gen:
- id_to_node: A Twitter id to node map as a python dictionary.
Outputs: - user_label_matrix: A user-to-label matrix in scipy sparse matrix format.
- annotated_nodes: A nu... | [
"Forms",
"the",
"user",
"-",
"label",
"matrix",
"to",
"be",
"used",
"in",
"multi",
"-",
"label",
"classification",
"."
] | ed019c031857b091e5601f53ba3f01a499a0e3ef | https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/twitter/user_annotate.py#L54-L81 |
41,781 | MKLab-ITI/reveal-user-annotation | reveal_user_annotation/twitter/user_annotate.py | form_user_term_matrix | def form_user_term_matrix(user_twitter_list_keywords_gen, id_to_node, lemma_set=None, keyword_to_topic_manual=None):
"""
Forms a user-term matrix.
Input: - user_twitter_list_keywords_gen: A python generator that yields a user Twitter id and a bag-of-words.
- id_to_node: A Twitter id to node... | python | def form_user_term_matrix(user_twitter_list_keywords_gen, id_to_node, lemma_set=None, keyword_to_topic_manual=None):
"""
Forms a user-term matrix.
Input: - user_twitter_list_keywords_gen: A python generator that yields a user Twitter id and a bag-of-words.
- id_to_node: A Twitter id to node... | [
"def",
"form_user_term_matrix",
"(",
"user_twitter_list_keywords_gen",
",",
"id_to_node",
",",
"lemma_set",
"=",
"None",
",",
"keyword_to_topic_manual",
"=",
"None",
")",
":",
"# Prepare for iteration.",
"term_to_attribute",
"=",
"dict",
"(",
")",
"user_term_matrix_row",
... | Forms a user-term matrix.
Input: - user_twitter_list_keywords_gen: A python generator that yields a user Twitter id and a bag-of-words.
- id_to_node: A Twitter id to node map as a python dictionary.
- lemma_set: For the labelling, we use only lemmas in this set. Default: None
Outp... | [
"Forms",
"a",
"user",
"-",
"term",
"matrix",
"."
] | ed019c031857b091e5601f53ba3f01a499a0e3ef | https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/twitter/user_annotate.py#L107-L196 |
41,782 | MKLab-ITI/reveal-user-annotation | reveal_user_annotation/twitter/user_annotate.py | fetch_twitter_lists_for_user_ids_generator | def fetch_twitter_lists_for_user_ids_generator(twitter_app_key,
twitter_app_secret,
user_id_list):
"""
Collects at most 500 Twitter lists for each user from an input list of Twitter user ids.
Inputs: - twitter_app... | python | def fetch_twitter_lists_for_user_ids_generator(twitter_app_key,
twitter_app_secret,
user_id_list):
"""
Collects at most 500 Twitter lists for each user from an input list of Twitter user ids.
Inputs: - twitter_app... | [
"def",
"fetch_twitter_lists_for_user_ids_generator",
"(",
"twitter_app_key",
",",
"twitter_app_secret",
",",
"user_id_list",
")",
":",
"####################################################################################################################",
"# Log into my application.",
"######... | Collects at most 500 Twitter lists for each user from an input list of Twitter user ids.
Inputs: - twitter_app_key: What is says on the tin.
- twitter_app_secret: Ditto.
- user_id_list: A python list of Twitter user ids.
Yields: - user_twitter_id: A Twitter user id.
- twitt... | [
"Collects",
"at",
"most",
"500",
"Twitter",
"lists",
"for",
"each",
"user",
"from",
"an",
"input",
"list",
"of",
"Twitter",
"user",
"ids",
"."
] | ed019c031857b091e5601f53ba3f01a499a0e3ef | https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/twitter/user_annotate.py#L493-L540 |
41,783 | MKLab-ITI/reveal-user-annotation | reveal_user_annotation/twitter/user_annotate.py | decide_which_users_to_annotate | def decide_which_users_to_annotate(centrality_vector,
number_to_annotate,
already_annotated,
node_to_id):
"""
Sorts a centrality vector and returns the Twitter user ids that are to be annotated.
Inputs:... | python | def decide_which_users_to_annotate(centrality_vector,
number_to_annotate,
already_annotated,
node_to_id):
"""
Sorts a centrality vector and returns the Twitter user ids that are to be annotated.
Inputs:... | [
"def",
"decide_which_users_to_annotate",
"(",
"centrality_vector",
",",
"number_to_annotate",
",",
"already_annotated",
",",
"node_to_id",
")",
":",
"# Sort the centrality vector according to decreasing centrality.",
"centrality_vector",
"=",
"np",
".",
"asarray",
"(",
"central... | Sorts a centrality vector and returns the Twitter user ids that are to be annotated.
Inputs: - centrality_vector: A numpy array vector, that contains the centrality values for all users.
- number_to_annotate: The number of users to annotate.
- already_annotated: A python set of user twitter... | [
"Sorts",
"a",
"centrality",
"vector",
"and",
"returns",
"the",
"Twitter",
"user",
"ids",
"that",
"are",
"to",
"be",
"annotated",
"."
] | ed019c031857b091e5601f53ba3f01a499a0e3ef | https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/twitter/user_annotate.py#L543-L580 |
41,784 | MKLab-ITI/reveal-user-annotation | reveal_user_annotation/twitter/user_annotate.py | on_demand_annotation | def on_demand_annotation(twitter_app_key, twitter_app_secret, user_twitter_id):
"""
A service that leverages twitter lists for on-demand annotation of popular users.
TODO: Do this.
"""
##################################################################################################################... | python | def on_demand_annotation(twitter_app_key, twitter_app_secret, user_twitter_id):
"""
A service that leverages twitter lists for on-demand annotation of popular users.
TODO: Do this.
"""
##################################################################################################################... | [
"def",
"on_demand_annotation",
"(",
"twitter_app_key",
",",
"twitter_app_secret",
",",
"user_twitter_id",
")",
":",
"####################################################################################################################",
"# Log into my application",
"##########################... | A service that leverages twitter lists for on-demand annotation of popular users.
TODO: Do this. | [
"A",
"service",
"that",
"leverages",
"twitter",
"lists",
"for",
"on",
"-",
"demand",
"annotation",
"of",
"popular",
"users",
"."
] | ed019c031857b091e5601f53ba3f01a499a0e3ef | https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/twitter/user_annotate.py#L583-L599 |
41,785 | helixyte/everest | everest/resources/utils.py | get_member_class | def get_member_class(resource):
"""
Returns the registered member class for the given resource.
:param resource: registered resource
:type resource: class implementing or instance providing or subclass of
a registered resource interface.
"""
reg = get_current_registry()
if IInterfac... | python | def get_member_class(resource):
"""
Returns the registered member class for the given resource.
:param resource: registered resource
:type resource: class implementing or instance providing or subclass of
a registered resource interface.
"""
reg = get_current_registry()
if IInterfac... | [
"def",
"get_member_class",
"(",
"resource",
")",
":",
"reg",
"=",
"get_current_registry",
"(",
")",
"if",
"IInterface",
"in",
"provided_by",
"(",
"resource",
")",
":",
"member_class",
"=",
"reg",
".",
"getUtility",
"(",
"resource",
",",
"name",
"=",
"'member... | Returns the registered member class for the given resource.
:param resource: registered resource
:type resource: class implementing or instance providing or subclass of
a registered resource interface. | [
"Returns",
"the",
"registered",
"member",
"class",
"for",
"the",
"given",
"resource",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/utils.py#L57-L71 |
41,786 | helixyte/everest | everest/resources/utils.py | get_collection_class | def get_collection_class(resource):
"""
Returns the registered collection resource class for the given marker
interface or member resource class or instance.
:param rc: registered resource
:type rc: class implementing or instance providing or subclass of
a registered resource interface.
... | python | def get_collection_class(resource):
"""
Returns the registered collection resource class for the given marker
interface or member resource class or instance.
:param rc: registered resource
:type rc: class implementing or instance providing or subclass of
a registered resource interface.
... | [
"def",
"get_collection_class",
"(",
"resource",
")",
":",
"reg",
"=",
"get_current_registry",
"(",
")",
"if",
"IInterface",
"in",
"provided_by",
"(",
"resource",
")",
":",
"coll_class",
"=",
"reg",
".",
"getUtility",
"(",
"resource",
",",
"name",
"=",
"'coll... | Returns the registered collection resource class for the given marker
interface or member resource class or instance.
:param rc: registered resource
:type rc: class implementing or instance providing or subclass of
a registered resource interface. | [
"Returns",
"the",
"registered",
"collection",
"resource",
"class",
"for",
"the",
"given",
"marker",
"interface",
"or",
"member",
"resource",
"class",
"or",
"instance",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/utils.py#L74-L89 |
41,787 | helixyte/everest | everest/resources/utils.py | as_member | def as_member(entity, parent=None):
"""
Adapts an object to a location aware member resource.
:param entity: a domain object for which a resource adapter has been
registered
:type entity: an object implementing
:class:`everest.entities.interfaces.IEntity`
:param parent: optional par... | python | def as_member(entity, parent=None):
"""
Adapts an object to a location aware member resource.
:param entity: a domain object for which a resource adapter has been
registered
:type entity: an object implementing
:class:`everest.entities.interfaces.IEntity`
:param parent: optional par... | [
"def",
"as_member",
"(",
"entity",
",",
"parent",
"=",
"None",
")",
":",
"reg",
"=",
"get_current_registry",
"(",
")",
"rc",
"=",
"reg",
".",
"getAdapter",
"(",
"entity",
",",
"IMemberResource",
")",
"if",
"not",
"parent",
"is",
"None",
":",
"rc",
".",... | Adapts an object to a location aware member resource.
:param entity: a domain object for which a resource adapter has been
registered
:type entity: an object implementing
:class:`everest.entities.interfaces.IEntity`
:param parent: optional parent collection resource to make the new member
... | [
"Adapts",
"an",
"object",
"to",
"a",
"location",
"aware",
"member",
"resource",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/utils.py#L103-L122 |
41,788 | helixyte/everest | everest/resources/utils.py | get_resource_url | def get_resource_url(resource):
"""
Returns the URL for the given resource.
"""
path = model_path(resource)
parsed = list(urlparse.urlparse(path))
parsed[1] = ""
return urlparse.urlunparse(parsed) | python | def get_resource_url(resource):
"""
Returns the URL for the given resource.
"""
path = model_path(resource)
parsed = list(urlparse.urlparse(path))
parsed[1] = ""
return urlparse.urlunparse(parsed) | [
"def",
"get_resource_url",
"(",
"resource",
")",
":",
"path",
"=",
"model_path",
"(",
"resource",
")",
"parsed",
"=",
"list",
"(",
"urlparse",
".",
"urlparse",
"(",
"path",
")",
")",
"parsed",
"[",
"1",
"]",
"=",
"\"\"",
"return",
"urlparse",
".",
"url... | Returns the URL for the given resource. | [
"Returns",
"the",
"URL",
"for",
"the",
"given",
"resource",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/utils.py#L136-L143 |
41,789 | helixyte/everest | everest/resources/utils.py | get_registered_collection_resources | def get_registered_collection_resources():
"""
Returns a list of all registered collection resource classes.
"""
reg = get_current_registry()
return [util.component
for util in reg.registeredUtilities()
if util.name == 'collection-class'] | python | def get_registered_collection_resources():
"""
Returns a list of all registered collection resource classes.
"""
reg = get_current_registry()
return [util.component
for util in reg.registeredUtilities()
if util.name == 'collection-class'] | [
"def",
"get_registered_collection_resources",
"(",
")",
":",
"reg",
"=",
"get_current_registry",
"(",
")",
"return",
"[",
"util",
".",
"component",
"for",
"util",
"in",
"reg",
".",
"registeredUtilities",
"(",
")",
"if",
"util",
".",
"name",
"==",
"'collection-... | Returns a list of all registered collection resource classes. | [
"Returns",
"a",
"list",
"of",
"all",
"registered",
"collection",
"resource",
"classes",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/utils.py#L176-L183 |
41,790 | helixyte/everest | everest/resources/utils.py | resource_to_url | def resource_to_url(resource, request=None, quote=False):
"""
Converts the given resource to a URL.
:param request: Request object (required for the host name part of the
URL). If this is not given, the current request is used.
:param bool quote: If set, the URL returned will be quoted.
"""
... | python | def resource_to_url(resource, request=None, quote=False):
"""
Converts the given resource to a URL.
:param request: Request object (required for the host name part of the
URL). If this is not given, the current request is used.
:param bool quote: If set, the URL returned will be quoted.
"""
... | [
"def",
"resource_to_url",
"(",
"resource",
",",
"request",
"=",
"None",
",",
"quote",
"=",
"False",
")",
":",
"if",
"request",
"is",
"None",
":",
"request",
"=",
"get_current_request",
"(",
")",
"# cnv = request.registry.getAdapter(request, IResourceUrlConverter)",... | Converts the given resource to a URL.
:param request: Request object (required for the host name part of the
URL). If this is not given, the current request is used.
:param bool quote: If set, the URL returned will be quoted. | [
"Converts",
"the",
"given",
"resource",
"to",
"a",
"URL",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/utils.py#L197-L210 |
41,791 | helixyte/everest | everest/resources/utils.py | url_to_resource | def url_to_resource(url, request=None):
"""
Converts the given URL to a resource.
:param request: Request object (required for the host name part of the
URL). If this is not given, the current request is used.
"""
if request is None:
request = get_current_request()
# cnv = request.... | python | def url_to_resource(url, request=None):
"""
Converts the given URL to a resource.
:param request: Request object (required for the host name part of the
URL). If this is not given, the current request is used.
"""
if request is None:
request = get_current_request()
# cnv = request.... | [
"def",
"url_to_resource",
"(",
"url",
",",
"request",
"=",
"None",
")",
":",
"if",
"request",
"is",
"None",
":",
"request",
"=",
"get_current_request",
"(",
")",
"# cnv = request.registry.getAdapter(request, IResourceUrlConverter)",
"reg",
"=",
"get_current_registry"... | Converts the given URL to a resource.
:param request: Request object (required for the host name part of the
URL). If this is not given, the current request is used. | [
"Converts",
"the",
"given",
"URL",
"to",
"a",
"resource",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/utils.py#L213-L225 |
41,792 | helixyte/everest | everest/entities/utils.py | get_entity_class | def get_entity_class(resource):
"""
Returns the entity class registered for the given registered resource.
:param resource: registered resource
:type collection: class implementing or instance providing a registered
resource interface.
:return: entity class
(class implementing `ever... | python | def get_entity_class(resource):
"""
Returns the entity class registered for the given registered resource.
:param resource: registered resource
:type collection: class implementing or instance providing a registered
resource interface.
:return: entity class
(class implementing `ever... | [
"def",
"get_entity_class",
"(",
"resource",
")",
":",
"reg",
"=",
"get_current_registry",
"(",
")",
"if",
"IInterface",
"in",
"provided_by",
"(",
"resource",
")",
":",
"ent_cls",
"=",
"reg",
".",
"getUtility",
"(",
"resource",
",",
"name",
"=",
"'entity-clas... | Returns the entity class registered for the given registered resource.
:param resource: registered resource
:type collection: class implementing or instance providing a registered
resource interface.
:return: entity class
(class implementing `everest.entities.interfaces.IEntity`) | [
"Returns",
"the",
"entity",
"class",
"registered",
"for",
"the",
"given",
"registered",
"resource",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/entities/utils.py#L37-L52 |
41,793 | ponty/confduino | confduino/examples/board.py | install_board_with_programmer | def install_board_with_programmer(mcu,
programmer,
f_cpu=16000000,
core='arduino',
replace_existing=False,
):
"""install board with programmer."""... | python | def install_board_with_programmer(mcu,
programmer,
f_cpu=16000000,
core='arduino',
replace_existing=False,
):
"""install board with programmer."""... | [
"def",
"install_board_with_programmer",
"(",
"mcu",
",",
"programmer",
",",
"f_cpu",
"=",
"16000000",
",",
"core",
"=",
"'arduino'",
",",
"replace_existing",
"=",
"False",
",",
")",
":",
"bunch",
"=",
"AutoBunch",
"(",
")",
"board_id",
"=",
"'{mcu}_{f_cpu}_{pr... | install board with programmer. | [
"install",
"board",
"with",
"programmer",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/examples/board.py#L17-L40 |
41,794 | agrc/agrc.python | agrc/logging.py | Logger.logMsg | def logMsg(self, msg, printMsg=True):
"""
logs a message and prints it to the screen
"""
time = datetime.datetime.now().strftime('%I:%M %p')
self.log = '{0}\n{1} | {2}'.format(self.log, time, msg)
if printMsg:
print msg
if self.addLogsToArcpyMessages:... | python | def logMsg(self, msg, printMsg=True):
"""
logs a message and prints it to the screen
"""
time = datetime.datetime.now().strftime('%I:%M %p')
self.log = '{0}\n{1} | {2}'.format(self.log, time, msg)
if printMsg:
print msg
if self.addLogsToArcpyMessages:... | [
"def",
"logMsg",
"(",
"self",
",",
"msg",
",",
"printMsg",
"=",
"True",
")",
":",
"time",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
".",
"strftime",
"(",
"'%I:%M %p'",
")",
"self",
".",
"log",
"=",
"'{0}\\n{1} | {2}'",
".",
"format",
"(... | logs a message and prints it to the screen | [
"logs",
"a",
"message",
"and",
"prints",
"it",
"to",
"the",
"screen"
] | be427e919bd4cdd6f19524b7f7fe18882429c25b | https://github.com/agrc/agrc.python/blob/be427e919bd4cdd6f19524b7f7fe18882429c25b/agrc/logging.py#L26-L37 |
41,795 | agrc/agrc.python | agrc/logging.py | Logger.logGPMsg | def logGPMsg(self, printMsg=True):
"""
logs the arcpy messages and prints them to the screen
"""
from arcpy import GetMessages
msgs = GetMessages()
try:
self.logMsg(msgs, printMsg)
except:
self.logMsg('error getting arcpy message', printMs... | python | def logGPMsg(self, printMsg=True):
"""
logs the arcpy messages and prints them to the screen
"""
from arcpy import GetMessages
msgs = GetMessages()
try:
self.logMsg(msgs, printMsg)
except:
self.logMsg('error getting arcpy message', printMs... | [
"def",
"logGPMsg",
"(",
"self",
",",
"printMsg",
"=",
"True",
")",
":",
"from",
"arcpy",
"import",
"GetMessages",
"msgs",
"=",
"GetMessages",
"(",
")",
"try",
":",
"self",
".",
"logMsg",
"(",
"msgs",
",",
"printMsg",
")",
"except",
":",
"self",
".",
... | logs the arcpy messages and prints them to the screen | [
"logs",
"the",
"arcpy",
"messages",
"and",
"prints",
"them",
"to",
"the",
"screen"
] | be427e919bd4cdd6f19524b7f7fe18882429c25b | https://github.com/agrc/agrc.python/blob/be427e919bd4cdd6f19524b7f7fe18882429c25b/agrc/logging.py#L39-L49 |
41,796 | agrc/agrc.python | agrc/logging.py | Logger.writeLogToFile | def writeLogToFile(self):
"""
writes the log to a
"""
if not os.path.exists(self.logFolder):
os.mkdir(self.logFolder)
with open(self.logFile, mode='a') as f:
f.write('\n\n' + self.log) | python | def writeLogToFile(self):
"""
writes the log to a
"""
if not os.path.exists(self.logFolder):
os.mkdir(self.logFolder)
with open(self.logFile, mode='a') as f:
f.write('\n\n' + self.log) | [
"def",
"writeLogToFile",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"logFolder",
")",
":",
"os",
".",
"mkdir",
"(",
"self",
".",
"logFolder",
")",
"with",
"open",
"(",
"self",
".",
"logFile",
",",
"mode"... | writes the log to a | [
"writes",
"the",
"log",
"to",
"a"
] | be427e919bd4cdd6f19524b7f7fe18882429c25b | https://github.com/agrc/agrc.python/blob/be427e919bd4cdd6f19524b7f7fe18882429c25b/agrc/logging.py#L51-L59 |
41,797 | agrc/agrc.python | agrc/logging.py | Logger.logError | def logError(self):
"""
gets traceback info and logs it
"""
# got from http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Error_handling_with_Python
import traceback
self.logMsg('ERROR!!!')
errMsg = traceback.format_exc()
self.logMsg(errMsg)
... | python | def logError(self):
"""
gets traceback info and logs it
"""
# got from http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Error_handling_with_Python
import traceback
self.logMsg('ERROR!!!')
errMsg = traceback.format_exc()
self.logMsg(errMsg)
... | [
"def",
"logError",
"(",
"self",
")",
":",
"# got from http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Error_handling_with_Python",
"import",
"traceback",
"self",
".",
"logMsg",
"(",
"'ERROR!!!'",
")",
"errMsg",
"=",
"traceback",
".",
"format_exc",
"(",
")",
... | gets traceback info and logs it | [
"gets",
"traceback",
"info",
"and",
"logs",
"it"
] | be427e919bd4cdd6f19524b7f7fe18882429c25b | https://github.com/agrc/agrc.python/blob/be427e919bd4cdd6f19524b7f7fe18882429c25b/agrc/logging.py#L61-L71 |
41,798 | kstrauser/giphycat | giphycat/giphycat.py | get_random_giphy | def get_random_giphy(phrase):
"""Return the URL of a random GIF related to the phrase, if possible"""
with warnings.catch_warnings():
warnings.simplefilter('ignore')
giphy = giphypop.Giphy()
results = giphy.search_list(phrase=phrase, limit=100)
if not results:
raise ValueError... | python | def get_random_giphy(phrase):
"""Return the URL of a random GIF related to the phrase, if possible"""
with warnings.catch_warnings():
warnings.simplefilter('ignore')
giphy = giphypop.Giphy()
results = giphy.search_list(phrase=phrase, limit=100)
if not results:
raise ValueError... | [
"def",
"get_random_giphy",
"(",
"phrase",
")",
":",
"with",
"warnings",
".",
"catch_warnings",
"(",
")",
":",
"warnings",
".",
"simplefilter",
"(",
"'ignore'",
")",
"giphy",
"=",
"giphypop",
".",
"Giphy",
"(",
")",
"results",
"=",
"giphy",
".",
"search_lis... | Return the URL of a random GIF related to the phrase, if possible | [
"Return",
"the",
"URL",
"of",
"a",
"random",
"GIF",
"related",
"to",
"the",
"phrase",
"if",
"possible"
] | c7c060dc0fc370d7253650e32ee93fde215621a8 | https://github.com/kstrauser/giphycat/blob/c7c060dc0fc370d7253650e32ee93fde215621a8/giphycat/giphycat.py#L14-L26 |
41,799 | kstrauser/giphycat | giphycat/giphycat.py | handle_command_line | def handle_command_line():
"""Display an image for the phrase in sys.argv, if possible"""
phrase = ' '.join(sys.argv[1:]) or 'random'
try:
giphy = get_random_giphy(phrase)
except ValueError:
sys.stderr.write('Unable to find any GIFs for {!r}\n'.format(phrase))
sys.exit(1)
d... | python | def handle_command_line():
"""Display an image for the phrase in sys.argv, if possible"""
phrase = ' '.join(sys.argv[1:]) or 'random'
try:
giphy = get_random_giphy(phrase)
except ValueError:
sys.stderr.write('Unable to find any GIFs for {!r}\n'.format(phrase))
sys.exit(1)
d... | [
"def",
"handle_command_line",
"(",
")",
":",
"phrase",
"=",
"' '",
".",
"join",
"(",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
")",
"or",
"'random'",
"try",
":",
"giphy",
"=",
"get_random_giphy",
"(",
"phrase",
")",
"except",
"ValueError",
":",
"sys",
... | Display an image for the phrase in sys.argv, if possible | [
"Display",
"an",
"image",
"for",
"the",
"phrase",
"in",
"sys",
".",
"argv",
"if",
"possible"
] | c7c060dc0fc370d7253650e32ee93fde215621a8 | https://github.com/kstrauser/giphycat/blob/c7c060dc0fc370d7253650e32ee93fde215621a8/giphycat/giphycat.py#L39-L49 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.