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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
238,000 | Fortran-FOSS-Programmers/ford | ford/utils.py | quote_split | def quote_split(sep,string):
"""
Splits the strings into pieces divided by sep, when sep in not inside quotes.
"""
if len(sep) != 1: raise Exception("Separation string must be one character long")
retlist = []
squote = False
dquote = False
left = 0
i = 0
while i < len(string):
... | python | def quote_split(sep,string):
"""
Splits the strings into pieces divided by sep, when sep in not inside quotes.
"""
if len(sep) != 1: raise Exception("Separation string must be one character long")
retlist = []
squote = False
dquote = False
left = 0
i = 0
while i < len(string):
... | [
"def",
"quote_split",
"(",
"sep",
",",
"string",
")",
":",
"if",
"len",
"(",
"sep",
")",
"!=",
"1",
":",
"raise",
"Exception",
"(",
"\"Separation string must be one character long\"",
")",
"retlist",
"=",
"[",
"]",
"squote",
"=",
"False",
"dquote",
"=",
"F... | Splits the strings into pieces divided by sep, when sep in not inside quotes. | [
"Splits",
"the",
"strings",
"into",
"pieces",
"divided",
"by",
"sep",
"when",
"sep",
"in",
"not",
"inside",
"quotes",
"."
] | d46a44eae20d99205292c31785f936fbed47070f | https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/utils.py#L110-L140 |
238,001 | Fortran-FOSS-Programmers/ford | ford/utils.py | split_path | def split_path(path):
'''
Splits the argument into its constituent directories and returns them as
a list.
'''
def recurse_path(path,retlist):
if len(retlist) > 100:
fullpath = os.path.join(*([ path, ] + retlist))
print("Directory '{}' contains too many levels".format... | python | def split_path(path):
'''
Splits the argument into its constituent directories and returns them as
a list.
'''
def recurse_path(path,retlist):
if len(retlist) > 100:
fullpath = os.path.join(*([ path, ] + retlist))
print("Directory '{}' contains too many levels".format... | [
"def",
"split_path",
"(",
"path",
")",
":",
"def",
"recurse_path",
"(",
"path",
",",
"retlist",
")",
":",
"if",
"len",
"(",
"retlist",
")",
">",
"100",
":",
"fullpath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"*",
"(",
"[",
"path",
",",
"]",
... | Splits the argument into its constituent directories and returns them as
a list. | [
"Splits",
"the",
"argument",
"into",
"its",
"constituent",
"directories",
"and",
"returns",
"them",
"as",
"a",
"list",
"."
] | d46a44eae20d99205292c31785f936fbed47070f | https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/utils.py#L143-L167 |
238,002 | Fortran-FOSS-Programmers/ford | ford/utils.py | sub_macros | def sub_macros(string,base_url):
'''
Replaces macros in documentation with their appropriate values. These macros
are used for things like providing URLs.
'''
macros = { '|url|': base_url,
'|media|': os.path.join(base_url,'media'),
'|page|': os.path.join(base_url,'page'... | python | def sub_macros(string,base_url):
'''
Replaces macros in documentation with their appropriate values. These macros
are used for things like providing URLs.
'''
macros = { '|url|': base_url,
'|media|': os.path.join(base_url,'media'),
'|page|': os.path.join(base_url,'page'... | [
"def",
"sub_macros",
"(",
"string",
",",
"base_url",
")",
":",
"macros",
"=",
"{",
"'|url|'",
":",
"base_url",
",",
"'|media|'",
":",
"os",
".",
"path",
".",
"join",
"(",
"base_url",
",",
"'media'",
")",
",",
"'|page|'",
":",
"os",
".",
"path",
".",
... | Replaces macros in documentation with their appropriate values. These macros
are used for things like providing URLs. | [
"Replaces",
"macros",
"in",
"documentation",
"with",
"their",
"appropriate",
"values",
".",
"These",
"macros",
"are",
"used",
"for",
"things",
"like",
"providing",
"URLs",
"."
] | d46a44eae20d99205292c31785f936fbed47070f | https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/utils.py#L279-L290 |
238,003 | Fortran-FOSS-Programmers/ford | ford/output.py | copytree | def copytree(src, dst):
"""Replaces shutil.copytree to avoid problems on certain file systems.
shutil.copytree() and shutil.copystat() invoke os.setxattr(), which seems
to fail when called for directories on at least one NFS file system.
The current routine is a simple replacement, which should be good... | python | def copytree(src, dst):
"""Replaces shutil.copytree to avoid problems on certain file systems.
shutil.copytree() and shutil.copystat() invoke os.setxattr(), which seems
to fail when called for directories on at least one NFS file system.
The current routine is a simple replacement, which should be good... | [
"def",
"copytree",
"(",
"src",
",",
"dst",
")",
":",
"def",
"touch",
"(",
"path",
")",
":",
"now",
"=",
"time",
".",
"time",
"(",
")",
"try",
":",
"# assume it's there",
"os",
".",
"utime",
"(",
"path",
",",
"(",
"now",
",",
"now",
")",
")",
"e... | Replaces shutil.copytree to avoid problems on certain file systems.
shutil.copytree() and shutil.copystat() invoke os.setxattr(), which seems
to fail when called for directories on at least one NFS file system.
The current routine is a simple replacement, which should be good enough for
Ford. | [
"Replaces",
"shutil",
".",
"copytree",
"to",
"avoid",
"problems",
"on",
"certain",
"file",
"systems",
"."
] | d46a44eae20d99205292c31785f936fbed47070f | https://github.com/Fortran-FOSS-Programmers/ford/blob/d46a44eae20d99205292c31785f936fbed47070f/ford/output.py#L520-L551 |
238,004 | KelSolaar/Umbra | umbra/ui/widgets/active_QLabel.py | Active_QLabel.set_checked | def set_checked(self, state):
"""
Sets the Widget checked state.
:param state: New check state.
:type state: bool
:return: Method success.
:rtype: bool
"""
if not self.__checkable:
return False
if state:
self.__checked = ... | python | def set_checked(self, state):
"""
Sets the Widget checked state.
:param state: New check state.
:type state: bool
:return: Method success.
:rtype: bool
"""
if not self.__checkable:
return False
if state:
self.__checked = ... | [
"def",
"set_checked",
"(",
"self",
",",
"state",
")",
":",
"if",
"not",
"self",
".",
"__checkable",
":",
"return",
"False",
"if",
"state",
":",
"self",
".",
"__checked",
"=",
"True",
"self",
".",
"setPixmap",
"(",
"self",
".",
"__active_pixmap",
")",
"... | Sets the Widget checked state.
:param state: New check state.
:type state: bool
:return: Method success.
:rtype: bool | [
"Sets",
"the",
"Widget",
"checked",
"state",
"."
] | 66f45f08d9d723787f1191989f8b0dda84b412ce | https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/ui/widgets/active_QLabel.py#L386-L406 |
238,005 | KelSolaar/Umbra | umbra/ui/widgets/active_QLabel.py | Active_QLabel.set_menu | def set_menu(self, menu):
"""
Sets the Widget menu.
:param menu: Menu.
:type menu: QMenu
:return: Method success.
:rtype: bool
"""
self.__menu = menu
if not self.parent():
return False
parent = [parent for parent in umbra.ui... | python | def set_menu(self, menu):
"""
Sets the Widget menu.
:param menu: Menu.
:type menu: QMenu
:return: Method success.
:rtype: bool
"""
self.__menu = menu
if not self.parent():
return False
parent = [parent for parent in umbra.ui... | [
"def",
"set_menu",
"(",
"self",
",",
"menu",
")",
":",
"self",
".",
"__menu",
"=",
"menu",
"if",
"not",
"self",
".",
"parent",
"(",
")",
":",
"return",
"False",
"parent",
"=",
"[",
"parent",
"for",
"parent",
"in",
"umbra",
".",
"ui",
".",
"common",... | Sets the Widget menu.
:param menu: Menu.
:type menu: QMenu
:return: Method success.
:rtype: bool | [
"Sets",
"the",
"Widget",
"menu",
"."
] | 66f45f08d9d723787f1191989f8b0dda84b412ce | https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/ui/widgets/active_QLabel.py#L408-L426 |
238,006 | KelSolaar/Umbra | umbra/managers/file_system_events_manager.py | FileSystemEventsManager.get | def get(self, path, default=None):
"""
Returns given path value.
:param path: Path name.
:type path: unicode
:param default: Default value if path is not found.
:type default: object
:return: Action.
:rtype: QAction
"""
try:
r... | python | def get(self, path, default=None):
"""
Returns given path value.
:param path: Path name.
:type path: unicode
:param default: Default value if path is not found.
:type default: object
:return: Action.
:rtype: QAction
"""
try:
r... | [
"def",
"get",
"(",
"self",
",",
"path",
",",
"default",
"=",
"None",
")",
":",
"try",
":",
"return",
"self",
".",
"__getitem__",
"(",
"path",
")",
"except",
"KeyError",
"as",
"error",
":",
"return",
"default"
] | Returns given path value.
:param path: Path name.
:type path: unicode
:param default: Default value if path is not found.
:type default: object
:return: Action.
:rtype: QAction | [
"Returns",
"given",
"path",
"value",
"."
] | 66f45f08d9d723787f1191989f8b0dda84b412ce | https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/managers/file_system_events_manager.py#L289-L304 |
238,007 | KelSolaar/Umbra | umbra/managers/file_system_events_manager.py | FileSystemEventsManager.__watch_file_system | def __watch_file_system(self):
"""
Watches the file system for paths that have been changed or invalidated on disk.
"""
for path, data in self.__paths.items():
stored_modified_time, is_file = data
try:
if not foundations.common.path_exists(path):
... | python | def __watch_file_system(self):
"""
Watches the file system for paths that have been changed or invalidated on disk.
"""
for path, data in self.__paths.items():
stored_modified_time, is_file = data
try:
if not foundations.common.path_exists(path):
... | [
"def",
"__watch_file_system",
"(",
"self",
")",
":",
"for",
"path",
",",
"data",
"in",
"self",
".",
"__paths",
".",
"items",
"(",
")",
":",
"stored_modified_time",
",",
"is_file",
"=",
"data",
"try",
":",
"if",
"not",
"foundations",
".",
"common",
".",
... | Watches the file system for paths that have been changed or invalidated on disk. | [
"Watches",
"the",
"file",
"system",
"for",
"paths",
"that",
"have",
"been",
"changed",
"or",
"invalidated",
"on",
"disk",
"."
] | 66f45f08d9d723787f1191989f8b0dda84b412ce | https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/managers/file_system_events_manager.py#L319-L355 |
238,008 | KelSolaar/Umbra | umbra/managers/file_system_events_manager.py | FileSystemEventsManager.register_path | def register_path(self, path, modified_time=None):
"""
Registers given path.
:param path: Path name.
:type path: unicode
:param modified_time: Custom modified time.
:type modified_time: int or float
:return: Method success.
:rtype: bool
"""
... | python | def register_path(self, path, modified_time=None):
"""
Registers given path.
:param path: Path name.
:type path: unicode
:param modified_time: Custom modified time.
:type modified_time: int or float
:return: Method success.
:rtype: bool
"""
... | [
"def",
"register_path",
"(",
"self",
",",
"path",
",",
"modified_time",
"=",
"None",
")",
":",
"if",
"not",
"foundations",
".",
"common",
".",
"path_exists",
"(",
"path",
")",
":",
"raise",
"foundations",
".",
"exceptions",
".",
"PathExistsError",
"(",
"\"... | Registers given path.
:param path: Path name.
:type path: unicode
:param modified_time: Custom modified time.
:type modified_time: int or float
:return: Method success.
:rtype: bool | [
"Registers",
"given",
"path",
"."
] | 66f45f08d9d723787f1191989f8b0dda84b412ce | https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/managers/file_system_events_manager.py#L381-L403 |
238,009 | KelSolaar/Umbra | umbra/managers/file_system_events_manager.py | FileSystemEventsManager.unregister_path | def unregister_path(self, path):
"""
Unregisters given path.
:param path: Path name.
:type path: unicode
:return: Method success.
:rtype: bool
"""
if not path in self:
raise umbra.exceptions.PathExistsError("{0} | '{1}' path isn't registered!... | python | def unregister_path(self, path):
"""
Unregisters given path.
:param path: Path name.
:type path: unicode
:return: Method success.
:rtype: bool
"""
if not path in self:
raise umbra.exceptions.PathExistsError("{0} | '{1}' path isn't registered!... | [
"def",
"unregister_path",
"(",
"self",
",",
"path",
")",
":",
"if",
"not",
"path",
"in",
"self",
":",
"raise",
"umbra",
".",
"exceptions",
".",
"PathExistsError",
"(",
"\"{0} | '{1}' path isn't registered!\"",
".",
"format",
"(",
"self",
".",
"__class__",
".",... | Unregisters given path.
:param path: Path name.
:type path: unicode
:return: Method success.
:rtype: bool | [
"Unregisters",
"given",
"path",
"."
] | 66f45f08d9d723787f1191989f8b0dda84b412ce | https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/managers/file_system_events_manager.py#L406-L421 |
238,010 | KelSolaar/Umbra | umbra/managers/file_system_events_manager.py | FileSystemEventsManager.get_path_modified_time | def get_path_modified_time(path):
"""
Returns given path modification time.
:param path: Path.
:type path: unicode
:return: Modification time.
:rtype: int
"""
return float(foundations.common.get_first_item(str(os.path.getmtime(path)).split("."))) | python | def get_path_modified_time(path):
"""
Returns given path modification time.
:param path: Path.
:type path: unicode
:return: Modification time.
:rtype: int
"""
return float(foundations.common.get_first_item(str(os.path.getmtime(path)).split("."))) | [
"def",
"get_path_modified_time",
"(",
"path",
")",
":",
"return",
"float",
"(",
"foundations",
".",
"common",
".",
"get_first_item",
"(",
"str",
"(",
"os",
".",
"path",
".",
"getmtime",
"(",
"path",
")",
")",
".",
"split",
"(",
"\".\"",
")",
")",
")"
] | Returns given path modification time.
:param path: Path.
:type path: unicode
:return: Modification time.
:rtype: int | [
"Returns",
"given",
"path",
"modification",
"time",
"."
] | 66f45f08d9d723787f1191989f8b0dda84b412ce | https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/managers/file_system_events_manager.py#L424-L434 |
238,011 | titilambert/pyfido | pyfido/client.py | FidoClient._post_login_page | def _post_login_page(self):
"""Login to Janrain."""
# Prepare post data
data = {
"form": "signInForm",
"client_id": JANRAIN_CLIENT_ID,
"redirect_uri": "https://www.fido.ca/pages/#/",
"response_type": "token",
"locale": "en-US",
... | python | def _post_login_page(self):
"""Login to Janrain."""
# Prepare post data
data = {
"form": "signInForm",
"client_id": JANRAIN_CLIENT_ID,
"redirect_uri": "https://www.fido.ca/pages/#/",
"response_type": "token",
"locale": "en-US",
... | [
"def",
"_post_login_page",
"(",
"self",
")",
":",
"# Prepare post data",
"data",
"=",
"{",
"\"form\"",
":",
"\"signInForm\"",
",",
"\"client_id\"",
":",
"JANRAIN_CLIENT_ID",
",",
"\"redirect_uri\"",
":",
"\"https://www.fido.ca/pages/#/\"",
",",
"\"response_type\"",
":",... | Login to Janrain. | [
"Login",
"to",
"Janrain",
"."
] | 8302b76f4d9d7b05b97926c003ca02409aa23281 | https://github.com/titilambert/pyfido/blob/8302b76f4d9d7b05b97926c003ca02409aa23281/pyfido/client.py#L57-L78 |
238,012 | titilambert/pyfido | pyfido/client.py | FidoClient._get_token | def _get_token(self):
"""Get token from JanRain."""
# HTTP request
try:
raw_res = yield from self._session.get(TOKEN_URL,
headers=self._headers,
timeout=self._timeout)
except... | python | def _get_token(self):
"""Get token from JanRain."""
# HTTP request
try:
raw_res = yield from self._session.get(TOKEN_URL,
headers=self._headers,
timeout=self._timeout)
except... | [
"def",
"_get_token",
"(",
"self",
")",
":",
"# HTTP request",
"try",
":",
"raw_res",
"=",
"yield",
"from",
"self",
".",
"_session",
".",
"get",
"(",
"TOKEN_URL",
",",
"headers",
"=",
"self",
".",
"_headers",
",",
"timeout",
"=",
"self",
".",
"_timeout",
... | Get token from JanRain. | [
"Get",
"token",
"from",
"JanRain",
"."
] | 8302b76f4d9d7b05b97926c003ca02409aa23281 | https://github.com/titilambert/pyfido/blob/8302b76f4d9d7b05b97926c003ca02409aa23281/pyfido/client.py#L81-L104 |
238,013 | titilambert/pyfido | pyfido/client.py | FidoClient._get_account_number | def _get_account_number(self, token, uuid):
"""Get fido account number."""
# Data
data = {"accessToken": token,
"uuid": uuid}
# Http request
try:
raw_res = yield from self._session.post(ACCOUNT_URL,
d... | python | def _get_account_number(self, token, uuid):
"""Get fido account number."""
# Data
data = {"accessToken": token,
"uuid": uuid}
# Http request
try:
raw_res = yield from self._session.post(ACCOUNT_URL,
d... | [
"def",
"_get_account_number",
"(",
"self",
",",
"token",
",",
"uuid",
")",
":",
"# Data",
"data",
"=",
"{",
"\"accessToken\"",
":",
"token",
",",
"\"uuid\"",
":",
"uuid",
"}",
"# Http request",
"try",
":",
"raw_res",
"=",
"yield",
"from",
"self",
".",
"_... | Get fido account number. | [
"Get",
"fido",
"account",
"number",
"."
] | 8302b76f4d9d7b05b97926c003ca02409aa23281 | https://github.com/titilambert/pyfido/blob/8302b76f4d9d7b05b97926c003ca02409aa23281/pyfido/client.py#L107-L133 |
238,014 | titilambert/pyfido | pyfido/client.py | FidoClient._get_balance | def _get_balance(self, account_number):
"""Get current balance from Fido."""
# Prepare data
data = {"ctn": self.username,
"language": "en-US",
"accountNumber": account_number}
# Http request
try:
raw_res = yield from self._session.post(... | python | def _get_balance(self, account_number):
"""Get current balance from Fido."""
# Prepare data
data = {"ctn": self.username,
"language": "en-US",
"accountNumber": account_number}
# Http request
try:
raw_res = yield from self._session.post(... | [
"def",
"_get_balance",
"(",
"self",
",",
"account_number",
")",
":",
"# Prepare data",
"data",
"=",
"{",
"\"ctn\"",
":",
"self",
".",
"username",
",",
"\"language\"",
":",
"\"en-US\"",
",",
"\"accountNumber\"",
":",
"account_number",
"}",
"# Http request",
"try"... | Get current balance from Fido. | [
"Get",
"current",
"balance",
"from",
"Fido",
"."
] | 8302b76f4d9d7b05b97926c003ca02409aa23281 | https://github.com/titilambert/pyfido/blob/8302b76f4d9d7b05b97926c003ca02409aa23281/pyfido/client.py#L170-L200 |
238,015 | titilambert/pyfido | pyfido/client.py | FidoClient._get_fido_dollar | def _get_fido_dollar(self, account_number, number):
"""Get current Fido dollar balance."""
# Prepare data
data = json.dumps({"fidoDollarBalanceFormList":
[{"phoneNumber": number,
"accountNumber": account_number}]})
# Prepare headers... | python | def _get_fido_dollar(self, account_number, number):
"""Get current Fido dollar balance."""
# Prepare data
data = json.dumps({"fidoDollarBalanceFormList":
[{"phoneNumber": number,
"accountNumber": account_number}]})
# Prepare headers... | [
"def",
"_get_fido_dollar",
"(",
"self",
",",
"account_number",
",",
"number",
")",
":",
"# Prepare data",
"data",
"=",
"json",
".",
"dumps",
"(",
"{",
"\"fidoDollarBalanceFormList\"",
":",
"[",
"{",
"\"phoneNumber\"",
":",
"number",
",",
"\"accountNumber\"",
":"... | Get current Fido dollar balance. | [
"Get",
"current",
"Fido",
"dollar",
"balance",
"."
] | 8302b76f4d9d7b05b97926c003ca02409aa23281 | https://github.com/titilambert/pyfido/blob/8302b76f4d9d7b05b97926c003ca02409aa23281/pyfido/client.py#L203-L236 |
238,016 | titilambert/pyfido | pyfido/client.py | FidoClient._get_usage | def _get_usage(self, account_number, number):
"""Get Fido usage.
Get the following data
- talk
- text
- data
Roaming data is not supported yet
"""
# Prepare data
data = {"ctn": number,
"language": "en-US",
"account... | python | def _get_usage(self, account_number, number):
"""Get Fido usage.
Get the following data
- talk
- text
- data
Roaming data is not supported yet
"""
# Prepare data
data = {"ctn": number,
"language": "en-US",
"account... | [
"def",
"_get_usage",
"(",
"self",
",",
"account_number",
",",
"number",
")",
":",
"# Prepare data",
"data",
"=",
"{",
"\"ctn\"",
":",
"number",
",",
"\"language\"",
":",
"\"en-US\"",
",",
"\"accountNumber\"",
":",
"account_number",
"}",
"# Http request",
"try",
... | Get Fido usage.
Get the following data
- talk
- text
- data
Roaming data is not supported yet | [
"Get",
"Fido",
"usage",
"."
] | 8302b76f4d9d7b05b97926c003ca02409aa23281 | https://github.com/titilambert/pyfido/blob/8302b76f4d9d7b05b97926c003ca02409aa23281/pyfido/client.py#L239-L287 |
238,017 | titilambert/pyfido | pyfido/client.py | FidoClient.fetch_data | def fetch_data(self):
"""Fetch the latest data from Fido."""
# Get http session
yield from self._get_httpsession()
# Post login page
yield from self._post_login_page()
# Get token
token_uuid = yield from self._get_token()
# Get account number
accou... | python | def fetch_data(self):
"""Fetch the latest data from Fido."""
# Get http session
yield from self._get_httpsession()
# Post login page
yield from self._post_login_page()
# Get token
token_uuid = yield from self._get_token()
# Get account number
accou... | [
"def",
"fetch_data",
"(",
"self",
")",
":",
"# Get http session",
"yield",
"from",
"self",
".",
"_get_httpsession",
"(",
")",
"# Post login page",
"yield",
"from",
"self",
".",
"_post_login_page",
"(",
")",
"# Get token",
"token_uuid",
"=",
"yield",
"from",
"sel... | Fetch the latest data from Fido. | [
"Fetch",
"the",
"latest",
"data",
"from",
"Fido",
"."
] | 8302b76f4d9d7b05b97926c003ca02409aa23281 | https://github.com/titilambert/pyfido/blob/8302b76f4d9d7b05b97926c003ca02409aa23281/pyfido/client.py#L290-L313 |
238,018 | aleontiev/dj | dj/utils/system.py | execute | def execute(
command,
abort=True,
capture=False,
verbose=False,
echo=False,
stream=None,
):
"""Run a command locally.
Arguments:
command: a command to execute.
abort: If True, a non-zero return code will trigger an exception.
capture: If True, returns the output ... | python | def execute(
command,
abort=True,
capture=False,
verbose=False,
echo=False,
stream=None,
):
"""Run a command locally.
Arguments:
command: a command to execute.
abort: If True, a non-zero return code will trigger an exception.
capture: If True, returns the output ... | [
"def",
"execute",
"(",
"command",
",",
"abort",
"=",
"True",
",",
"capture",
"=",
"False",
",",
"verbose",
"=",
"False",
",",
"echo",
"=",
"False",
",",
"stream",
"=",
"None",
",",
")",
":",
"stream",
"=",
"stream",
"or",
"sys",
".",
"stdout",
"if"... | Run a command locally.
Arguments:
command: a command to execute.
abort: If True, a non-zero return code will trigger an exception.
capture: If True, returns the output of the command.
If False, returns a subprocess result.
echo: if True, prints the command before executi... | [
"Run",
"a",
"command",
"locally",
"."
] | 0612d442fdd8d472aea56466568b9857556ecb51 | https://github.com/aleontiev/dj/blob/0612d442fdd8d472aea56466568b9857556ecb51/dj/utils/system.py#L76-L148 |
238,019 | amol-/tgext.mailer | tgext/mailer/message.py | to_message | def to_message(base):
"""
Given a MailBase, this will construct a MIME part that is canonicalized for
use with the Python email API.
"""
ctype, ctparams = base.get_content_type()
if not ctype:
if base.parts:
ctype = 'multipart/mixed'
else:
ctype = 'text/p... | python | def to_message(base):
"""
Given a MailBase, this will construct a MIME part that is canonicalized for
use with the Python email API.
"""
ctype, ctparams = base.get_content_type()
if not ctype:
if base.parts:
ctype = 'multipart/mixed'
else:
ctype = 'text/p... | [
"def",
"to_message",
"(",
"base",
")",
":",
"ctype",
",",
"ctparams",
"=",
"base",
".",
"get_content_type",
"(",
")",
"if",
"not",
"ctype",
":",
"if",
"base",
".",
"parts",
":",
"ctype",
"=",
"'multipart/mixed'",
"else",
":",
"ctype",
"=",
"'text/plain'"... | Given a MailBase, this will construct a MIME part that is canonicalized for
use with the Python email API. | [
"Given",
"a",
"MailBase",
"this",
"will",
"construct",
"a",
"MIME",
"part",
"that",
"is",
"canonicalized",
"for",
"use",
"with",
"the",
"Python",
"email",
"API",
"."
] | 4c452244969b98431e57d5ebba930f365006dfbd | https://github.com/amol-/tgext.mailer/blob/4c452244969b98431e57d5ebba930f365006dfbd/tgext/mailer/message.py#L425-L490 |
238,020 | amol-/tgext.mailer | tgext/mailer/message.py | Message.to_message | def to_message(self):
"""
Returns raw email.Message instance. Validates message first.
"""
self.validate()
bodies = [(self.body, 'text/plain'), (self.html, 'text/html')]
for idx, (val, content_type) in enumerate(bodies):
if val is None:
... | python | def to_message(self):
"""
Returns raw email.Message instance. Validates message first.
"""
self.validate()
bodies = [(self.body, 'text/plain'), (self.html, 'text/html')]
for idx, (val, content_type) in enumerate(bodies):
if val is None:
... | [
"def",
"to_message",
"(",
"self",
")",
":",
"self",
".",
"validate",
"(",
")",
"bodies",
"=",
"[",
"(",
"self",
".",
"body",
",",
"'text/plain'",
")",
",",
"(",
"self",
".",
"html",
",",
"'text/html'",
")",
"]",
"for",
"idx",
",",
"(",
"val",
","... | Returns raw email.Message instance. Validates message first. | [
"Returns",
"raw",
"email",
".",
"Message",
"instance",
".",
"Validates",
"message",
"first",
"."
] | 4c452244969b98431e57d5ebba930f365006dfbd | https://github.com/amol-/tgext.mailer/blob/4c452244969b98431e57d5ebba930f365006dfbd/tgext/mailer/message.py#L189-L271 |
238,021 | amol-/tgext.mailer | tgext/mailer/message.py | Message.is_bad_headers | def is_bad_headers(self):
"""
Checks for bad headers i.e. newlines in subject, sender or recipients.
"""
headers = [self.subject, self.sender]
headers += list(self.send_to)
headers += dict(self.extra_headers).values()
for val in headers:
for c in '\r... | python | def is_bad_headers(self):
"""
Checks for bad headers i.e. newlines in subject, sender or recipients.
"""
headers = [self.subject, self.sender]
headers += list(self.send_to)
headers += dict(self.extra_headers).values()
for val in headers:
for c in '\r... | [
"def",
"is_bad_headers",
"(",
"self",
")",
":",
"headers",
"=",
"[",
"self",
".",
"subject",
",",
"self",
".",
"sender",
"]",
"headers",
"+=",
"list",
"(",
"self",
".",
"send_to",
")",
"headers",
"+=",
"dict",
"(",
"self",
".",
"extra_headers",
")",
... | Checks for bad headers i.e. newlines in subject, sender or recipients. | [
"Checks",
"for",
"bad",
"headers",
"i",
".",
"e",
".",
"newlines",
"in",
"subject",
"sender",
"or",
"recipients",
"."
] | 4c452244969b98431e57d5ebba930f365006dfbd | https://github.com/amol-/tgext.mailer/blob/4c452244969b98431e57d5ebba930f365006dfbd/tgext/mailer/message.py#L273-L286 |
238,022 | amol-/tgext.mailer | tgext/mailer/message.py | Message.validate | def validate(self):
"""
Checks if message is valid and raises appropriate exception.
"""
if not (self.recipients or self.cc or self.bcc):
raise InvalidMessage("No recipients have been added")
if not self.body and not self.html:
raise InvalidMessage("No b... | python | def validate(self):
"""
Checks if message is valid and raises appropriate exception.
"""
if not (self.recipients or self.cc or self.bcc):
raise InvalidMessage("No recipients have been added")
if not self.body and not self.html:
raise InvalidMessage("No b... | [
"def",
"validate",
"(",
"self",
")",
":",
"if",
"not",
"(",
"self",
".",
"recipients",
"or",
"self",
".",
"cc",
"or",
"self",
".",
"bcc",
")",
":",
"raise",
"InvalidMessage",
"(",
"\"No recipients have been added\"",
")",
"if",
"not",
"self",
".",
"body"... | Checks if message is valid and raises appropriate exception. | [
"Checks",
"if",
"message",
"is",
"valid",
"and",
"raises",
"appropriate",
"exception",
"."
] | 4c452244969b98431e57d5ebba930f365006dfbd | https://github.com/amol-/tgext.mailer/blob/4c452244969b98431e57d5ebba930f365006dfbd/tgext/mailer/message.py#L288-L303 |
238,023 | amol-/tgext.mailer | tgext/mailer/mailer.py | DebugMailer.from_settings | def from_settings(cls, settings, prefix='mail.'):
"""Create a new instance of 'DebugMailer' from settings dict.
:param settings: a settings dict-like
:param prefix: prefix separating 'tgext.mailer' settings
"""
settings = settings or {}
top_level_directory = settings.get... | python | def from_settings(cls, settings, prefix='mail.'):
"""Create a new instance of 'DebugMailer' from settings dict.
:param settings: a settings dict-like
:param prefix: prefix separating 'tgext.mailer' settings
"""
settings = settings or {}
top_level_directory = settings.get... | [
"def",
"from_settings",
"(",
"cls",
",",
"settings",
",",
"prefix",
"=",
"'mail.'",
")",
":",
"settings",
"=",
"settings",
"or",
"{",
"}",
"top_level_directory",
"=",
"settings",
".",
"get",
"(",
"prefix",
"+",
"'top_level_directory'",
")",
"if",
"top_level_... | Create a new instance of 'DebugMailer' from settings dict.
:param settings: a settings dict-like
:param prefix: prefix separating 'tgext.mailer' settings | [
"Create",
"a",
"new",
"instance",
"of",
"DebugMailer",
"from",
"settings",
"dict",
"."
] | 4c452244969b98431e57d5ebba930f365006dfbd | https://github.com/amol-/tgext.mailer/blob/4c452244969b98431e57d5ebba930f365006dfbd/tgext/mailer/mailer.py#L27-L38 |
238,024 | amol-/tgext.mailer | tgext/mailer/mailer.py | DebugMailer._send | def _send(self, message, fail_silently=False):
"""Save message to a file for debugging
"""
seeds = '1234567890qwertyuiopasdfghjklzxcvbnm'
file_part1 = datetime.now().strftime('%Y%m%d%H%M%S')
file_part2 = ''.join(sample(seeds, 4))
filename = join(self.tld, '%s_%s.msg' % (f... | python | def _send(self, message, fail_silently=False):
"""Save message to a file for debugging
"""
seeds = '1234567890qwertyuiopasdfghjklzxcvbnm'
file_part1 = datetime.now().strftime('%Y%m%d%H%M%S')
file_part2 = ''.join(sample(seeds, 4))
filename = join(self.tld, '%s_%s.msg' % (f... | [
"def",
"_send",
"(",
"self",
",",
"message",
",",
"fail_silently",
"=",
"False",
")",
":",
"seeds",
"=",
"'1234567890qwertyuiopasdfghjklzxcvbnm'",
"file_part1",
"=",
"datetime",
".",
"now",
"(",
")",
".",
"strftime",
"(",
"'%Y%m%d%H%M%S'",
")",
"file_part2",
"... | Save message to a file for debugging | [
"Save",
"message",
"to",
"a",
"file",
"for",
"debugging"
] | 4c452244969b98431e57d5ebba930f365006dfbd | https://github.com/amol-/tgext.mailer/blob/4c452244969b98431e57d5ebba930f365006dfbd/tgext/mailer/mailer.py#L40-L48 |
238,025 | amol-/tgext.mailer | tgext/mailer/mailer.py | Mailer.from_settings | def from_settings(cls, settings, prefix='mail.'):
"""Create a new instance of 'Mailer' from settings dict.
:param settings: a settings dict-like
:param prefix: prefix separating 'tgext.mailer' settings
"""
settings = settings or {}
kwarg_names = [prefix + k for k in (
... | python | def from_settings(cls, settings, prefix='mail.'):
"""Create a new instance of 'Mailer' from settings dict.
:param settings: a settings dict-like
:param prefix: prefix separating 'tgext.mailer' settings
"""
settings = settings or {}
kwarg_names = [prefix + k for k in (
... | [
"def",
"from_settings",
"(",
"cls",
",",
"settings",
",",
"prefix",
"=",
"'mail.'",
")",
":",
"settings",
"=",
"settings",
"or",
"{",
"}",
"kwarg_names",
"=",
"[",
"prefix",
"+",
"k",
"for",
"k",
"in",
"(",
"'host'",
",",
"'port'",
",",
"'username'",
... | Create a new instance of 'Mailer' from settings dict.
:param settings: a settings dict-like
:param prefix: prefix separating 'tgext.mailer' settings | [
"Create",
"a",
"new",
"instance",
"of",
"Mailer",
"from",
"settings",
"dict",
"."
] | 4c452244969b98431e57d5ebba930f365006dfbd | https://github.com/amol-/tgext.mailer/blob/4c452244969b98431e57d5ebba930f365006dfbd/tgext/mailer/mailer.py#L182-L205 |
238,026 | amol-/tgext.mailer | tgext/mailer/mailer.py | Mailer.send_immediately | def send_immediately(self, message, fail_silently=False):
"""Send a message immediately, outside the transaction manager.
If there is a connection error to the mail server this will have to
be handled manually. However if you pass ``fail_silently`` the error
will be swallowed.
... | python | def send_immediately(self, message, fail_silently=False):
"""Send a message immediately, outside the transaction manager.
If there is a connection error to the mail server this will have to
be handled manually. However if you pass ``fail_silently`` the error
will be swallowed.
... | [
"def",
"send_immediately",
"(",
"self",
",",
"message",
",",
"fail_silently",
"=",
"False",
")",
":",
"try",
":",
"return",
"self",
".",
"smtp_mailer",
".",
"send",
"(",
"*",
"self",
".",
"_message_args",
"(",
"message",
")",
")",
"except",
"smtplib",
".... | Send a message immediately, outside the transaction manager.
If there is a connection error to the mail server this will have to
be handled manually. However if you pass ``fail_silently`` the error
will be swallowed.
:versionadded: 0.3
:param message: a 'Message' instance.
... | [
"Send",
"a",
"message",
"immediately",
"outside",
"the",
"transaction",
"manager",
"."
] | 4c452244969b98431e57d5ebba930f365006dfbd | https://github.com/amol-/tgext.mailer/blob/4c452244969b98431e57d5ebba930f365006dfbd/tgext/mailer/mailer.py#L217-L234 |
238,027 | amol-/tgext.mailer | tgext/mailer/mailer.py | Mailer.send_to_queue | def send_to_queue(self, message):
"""Add a message to a maildir queue.
In order to handle this, the setting 'mail.queue_path' must be
provided and must point to a valid maildir.
:param message: a 'Message' instance.
"""
if not self.queue_delivery:
raise Runt... | python | def send_to_queue(self, message):
"""Add a message to a maildir queue.
In order to handle this, the setting 'mail.queue_path' must be
provided and must point to a valid maildir.
:param message: a 'Message' instance.
"""
if not self.queue_delivery:
raise Runt... | [
"def",
"send_to_queue",
"(",
"self",
",",
"message",
")",
":",
"if",
"not",
"self",
".",
"queue_delivery",
":",
"raise",
"RuntimeError",
"(",
"\"No queue_path provided\"",
")",
"return",
"self",
".",
"queue_delivery",
".",
"send",
"(",
"*",
"self",
".",
"_me... | Add a message to a maildir queue.
In order to handle this, the setting 'mail.queue_path' must be
provided and must point to a valid maildir.
:param message: a 'Message' instance. | [
"Add",
"a",
"message",
"to",
"a",
"maildir",
"queue",
"."
] | 4c452244969b98431e57d5ebba930f365006dfbd | https://github.com/amol-/tgext.mailer/blob/4c452244969b98431e57d5ebba930f365006dfbd/tgext/mailer/mailer.py#L236-L247 |
238,028 | ChrisCummins/labm8 | labtypes.py | is_seq | def is_seq(obj):
"""
Check if an object is a sequence.
"""
return (not is_str(obj) and not is_dict(obj) and
(hasattr(obj, "__getitem__") or hasattr(obj, "__iter__"))) | python | def is_seq(obj):
"""
Check if an object is a sequence.
"""
return (not is_str(obj) and not is_dict(obj) and
(hasattr(obj, "__getitem__") or hasattr(obj, "__iter__"))) | [
"def",
"is_seq",
"(",
"obj",
")",
":",
"return",
"(",
"not",
"is_str",
"(",
"obj",
")",
"and",
"not",
"is_dict",
"(",
"obj",
")",
"and",
"(",
"hasattr",
"(",
"obj",
",",
"\"__getitem__\"",
")",
"or",
"hasattr",
"(",
"obj",
",",
"\"__iter__\"",
")",
... | Check if an object is a sequence. | [
"Check",
"if",
"an",
"object",
"is",
"a",
"sequence",
"."
] | dd10d67a757aefb180cb508f86696f99440c94f5 | https://github.com/ChrisCummins/labm8/blob/dd10d67a757aefb180cb508f86696f99440c94f5/labtypes.py#L47-L52 |
238,029 | ChrisCummins/labm8 | labtypes.py | update | def update(dst, src):
"""
Recursively update values in dst from src.
Unlike the builtin dict.update() function, this method will decend into
nested dicts, updating all nested values.
Arguments:
dst (dict): Destination dict.
src (dict): Source dict.
Returns:
dict: dst u... | python | def update(dst, src):
"""
Recursively update values in dst from src.
Unlike the builtin dict.update() function, this method will decend into
nested dicts, updating all nested values.
Arguments:
dst (dict): Destination dict.
src (dict): Source dict.
Returns:
dict: dst u... | [
"def",
"update",
"(",
"dst",
",",
"src",
")",
":",
"for",
"k",
",",
"v",
"in",
"src",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"Mapping",
")",
":",
"r",
"=",
"update",
"(",
"dst",
".",
"get",
"(",
"k",
",",
"{",
"}",
... | Recursively update values in dst from src.
Unlike the builtin dict.update() function, this method will decend into
nested dicts, updating all nested values.
Arguments:
dst (dict): Destination dict.
src (dict): Source dict.
Returns:
dict: dst updated with entries from src. | [
"Recursively",
"update",
"values",
"in",
"dst",
"from",
"src",
"."
] | dd10d67a757aefb180cb508f86696f99440c94f5 | https://github.com/ChrisCummins/labm8/blob/dd10d67a757aefb180cb508f86696f99440c94f5/labtypes.py#L62-L82 |
238,030 | ChrisCummins/labm8 | labtypes.py | dict_values | def dict_values(src):
"""
Recursively get values in dict.
Unlike the builtin dict.values() function, this method will descend into
nested dicts, returning all nested values.
Arguments:
src (dict): Source dict.
Returns:
list: List of values.
"""
for v in src.values():
... | python | def dict_values(src):
"""
Recursively get values in dict.
Unlike the builtin dict.values() function, this method will descend into
nested dicts, returning all nested values.
Arguments:
src (dict): Source dict.
Returns:
list: List of values.
"""
for v in src.values():
... | [
"def",
"dict_values",
"(",
"src",
")",
":",
"for",
"v",
"in",
"src",
".",
"values",
"(",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"dict",
")",
":",
"for",
"v",
"in",
"dict_values",
"(",
"v",
")",
":",
"yield",
"v",
"else",
":",
"yield",
"v"... | Recursively get values in dict.
Unlike the builtin dict.values() function, this method will descend into
nested dicts, returning all nested values.
Arguments:
src (dict): Source dict.
Returns:
list: List of values. | [
"Recursively",
"get",
"values",
"in",
"dict",
"."
] | dd10d67a757aefb180cb508f86696f99440c94f5 | https://github.com/ChrisCummins/labm8/blob/dd10d67a757aefb180cb508f86696f99440c94f5/labtypes.py#L85-L103 |
238,031 | blazelibs/blazeutils | blazeutils/importing.py | find_path_package | def find_path_package(thepath):
"""
Takes a file system path and returns the module object of the python
package the said path belongs to. If the said path can not be
determined, it returns None.
"""
pname = find_path_package_name(thepath)
if not pname:
return None
fr... | python | def find_path_package(thepath):
"""
Takes a file system path and returns the module object of the python
package the said path belongs to. If the said path can not be
determined, it returns None.
"""
pname = find_path_package_name(thepath)
if not pname:
return None
fr... | [
"def",
"find_path_package",
"(",
"thepath",
")",
":",
"pname",
"=",
"find_path_package_name",
"(",
"thepath",
")",
"if",
"not",
"pname",
":",
"return",
"None",
"fromlist",
"=",
"b''",
"if",
"six",
".",
"PY2",
"else",
"''",
"return",
"__import__",
"(",
"pna... | Takes a file system path and returns the module object of the python
package the said path belongs to. If the said path can not be
determined, it returns None. | [
"Takes",
"a",
"file",
"system",
"path",
"and",
"returns",
"the",
"module",
"object",
"of",
"the",
"python",
"package",
"the",
"said",
"path",
"belongs",
"to",
".",
"If",
"the",
"said",
"path",
"can",
"not",
"be",
"determined",
"it",
"returns",
"None",
".... | c94476325146007553cbddeeb9ef83394756babf | https://github.com/blazelibs/blazeutils/blob/c94476325146007553cbddeeb9ef83394756babf/blazeutils/importing.py#L78-L88 |
238,032 | blazelibs/blazeutils | blazeutils/importing.py | find_path_package_name | def find_path_package_name(thepath):
"""
Takes a file system path and returns the name of the python package
the said path belongs to. If the said path can not be determined, it
returns None.
"""
module_found = False
last_module_found = None
continue_ = True
while contin... | python | def find_path_package_name(thepath):
"""
Takes a file system path and returns the name of the python package
the said path belongs to. If the said path can not be determined, it
returns None.
"""
module_found = False
last_module_found = None
continue_ = True
while contin... | [
"def",
"find_path_package_name",
"(",
"thepath",
")",
":",
"module_found",
"=",
"False",
"last_module_found",
"=",
"None",
"continue_",
"=",
"True",
"while",
"continue_",
":",
"module_found",
"=",
"is_path_python_module",
"(",
"thepath",
")",
"next_path",
"=",
"pa... | Takes a file system path and returns the name of the python package
the said path belongs to. If the said path can not be determined, it
returns None. | [
"Takes",
"a",
"file",
"system",
"path",
"and",
"returns",
"the",
"name",
"of",
"the",
"python",
"package",
"the",
"said",
"path",
"belongs",
"to",
".",
"If",
"the",
"said",
"path",
"can",
"not",
"be",
"determined",
"it",
"returns",
"None",
"."
] | c94476325146007553cbddeeb9ef83394756babf | https://github.com/blazelibs/blazeutils/blob/c94476325146007553cbddeeb9ef83394756babf/blazeutils/importing.py#L93-L116 |
238,033 | blazelibs/blazeutils | blazeutils/importing.py | is_path_python_module | def is_path_python_module(thepath):
"""
Given a path, find out of the path is a python module or is inside
a python module.
"""
thepath = path.normpath(thepath)
if path.isfile(thepath):
base, ext = path.splitext(thepath)
if ext in _py_suffixes:
return True
... | python | def is_path_python_module(thepath):
"""
Given a path, find out of the path is a python module or is inside
a python module.
"""
thepath = path.normpath(thepath)
if path.isfile(thepath):
base, ext = path.splitext(thepath)
if ext in _py_suffixes:
return True
... | [
"def",
"is_path_python_module",
"(",
"thepath",
")",
":",
"thepath",
"=",
"path",
".",
"normpath",
"(",
"thepath",
")",
"if",
"path",
".",
"isfile",
"(",
"thepath",
")",
":",
"base",
",",
"ext",
"=",
"path",
".",
"splitext",
"(",
"thepath",
")",
"if",
... | Given a path, find out of the path is a python module or is inside
a python module. | [
"Given",
"a",
"path",
"find",
"out",
"of",
"the",
"path",
"is",
"a",
"python",
"module",
"or",
"is",
"inside",
"a",
"python",
"module",
"."
] | c94476325146007553cbddeeb9ef83394756babf | https://github.com/blazelibs/blazeutils/blob/c94476325146007553cbddeeb9ef83394756babf/blazeutils/importing.py#L119-L136 |
238,034 | farzadghanei/distutilazy | distutilazy/util.py | find_files | def find_files(root, pattern):
"""Find all files matching the glob pattern recursively
:param root: string
:param pattern: string
:return: list of file paths relative to root
"""
results = []
for base, dirs, files in os.walk(root):
matched = fnmatch.filter(files, pattern)
re... | python | def find_files(root, pattern):
"""Find all files matching the glob pattern recursively
:param root: string
:param pattern: string
:return: list of file paths relative to root
"""
results = []
for base, dirs, files in os.walk(root):
matched = fnmatch.filter(files, pattern)
re... | [
"def",
"find_files",
"(",
"root",
",",
"pattern",
")",
":",
"results",
"=",
"[",
"]",
"for",
"base",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"root",
")",
":",
"matched",
"=",
"fnmatch",
".",
"filter",
"(",
"files",
",",
"pattern",
... | Find all files matching the glob pattern recursively
:param root: string
:param pattern: string
:return: list of file paths relative to root | [
"Find",
"all",
"files",
"matching",
"the",
"glob",
"pattern",
"recursively"
] | c3c7d062f7cb79abb7677cac57dd752127ff78e7 | https://github.com/farzadghanei/distutilazy/blob/c3c7d062f7cb79abb7677cac57dd752127ff78e7/distutilazy/util.py#L14-L25 |
238,035 | farzadghanei/distutilazy | distutilazy/util.py | find_directories | def find_directories(root, pattern):
"""Find all directories matching the glob pattern recursively
:param root: string
:param pattern: string
:return: list of dir paths relative to root
"""
results = []
for base, dirs, files in os.walk(root):
matched = fnmatch.filter(dirs, pattern)
... | python | def find_directories(root, pattern):
"""Find all directories matching the glob pattern recursively
:param root: string
:param pattern: string
:return: list of dir paths relative to root
"""
results = []
for base, dirs, files in os.walk(root):
matched = fnmatch.filter(dirs, pattern)
... | [
"def",
"find_directories",
"(",
"root",
",",
"pattern",
")",
":",
"results",
"=",
"[",
"]",
"for",
"base",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"root",
")",
":",
"matched",
"=",
"fnmatch",
".",
"filter",
"(",
"dirs",
",",
"patte... | Find all directories matching the glob pattern recursively
:param root: string
:param pattern: string
:return: list of dir paths relative to root | [
"Find",
"all",
"directories",
"matching",
"the",
"glob",
"pattern",
"recursively"
] | c3c7d062f7cb79abb7677cac57dd752127ff78e7 | https://github.com/farzadghanei/distutilazy/blob/c3c7d062f7cb79abb7677cac57dd752127ff78e7/distutilazy/util.py#L28-L39 |
238,036 | blazelibs/blazeutils | blazeutils/functional.py | posargs_limiter | def posargs_limiter(func, *args):
""" takes a function a positional arguments and sends only the number of
positional arguments the function is expecting
"""
posargs = inspect.getargspec(func)[0]
length = len(posargs)
if inspect.ismethod(func):
length -= 1
if length == 0:
ret... | python | def posargs_limiter(func, *args):
""" takes a function a positional arguments and sends only the number of
positional arguments the function is expecting
"""
posargs = inspect.getargspec(func)[0]
length = len(posargs)
if inspect.ismethod(func):
length -= 1
if length == 0:
ret... | [
"def",
"posargs_limiter",
"(",
"func",
",",
"*",
"args",
")",
":",
"posargs",
"=",
"inspect",
".",
"getargspec",
"(",
"func",
")",
"[",
"0",
"]",
"length",
"=",
"len",
"(",
"posargs",
")",
"if",
"inspect",
".",
"ismethod",
"(",
"func",
")",
":",
"l... | takes a function a positional arguments and sends only the number of
positional arguments the function is expecting | [
"takes",
"a",
"function",
"a",
"positional",
"arguments",
"and",
"sends",
"only",
"the",
"number",
"of",
"positional",
"arguments",
"the",
"function",
"is",
"expecting"
] | c94476325146007553cbddeeb9ef83394756babf | https://github.com/blazelibs/blazeutils/blob/c94476325146007553cbddeeb9ef83394756babf/blazeutils/functional.py#L13-L23 |
238,037 | blazelibs/blazeutils | blazeutils/functional.py | compose | def compose(*functions):
"""Function composition on a series of functions.
Remember that function composition runs right-to-left: `f . g . h = f(g(h(x)))`. As a unix
pipeline, it would be written: `h | g | f`.
From https://mathieularose.com/function-composition-in-python/.
"""
return functools... | python | def compose(*functions):
"""Function composition on a series of functions.
Remember that function composition runs right-to-left: `f . g . h = f(g(h(x)))`. As a unix
pipeline, it would be written: `h | g | f`.
From https://mathieularose.com/function-composition-in-python/.
"""
return functools... | [
"def",
"compose",
"(",
"*",
"functions",
")",
":",
"return",
"functools",
".",
"reduce",
"(",
"lambda",
"f",
",",
"g",
":",
"lambda",
"x",
":",
"f",
"(",
"g",
"(",
"x",
")",
")",
",",
"functions",
",",
"identity",
")"
] | Function composition on a series of functions.
Remember that function composition runs right-to-left: `f . g . h = f(g(h(x)))`. As a unix
pipeline, it would be written: `h | g | f`.
From https://mathieularose.com/function-composition-in-python/. | [
"Function",
"composition",
"on",
"a",
"series",
"of",
"functions",
"."
] | c94476325146007553cbddeeb9ef83394756babf | https://github.com/blazelibs/blazeutils/blob/c94476325146007553cbddeeb9ef83394756babf/blazeutils/functional.py#L58-L66 |
238,038 | blazelibs/blazeutils | blazeutils/functional.py | first_where | def first_where(pred, iterable, default=None):
"""Returns the first element in an iterable that meets the given predicate.
:param default: is the default value to use if the predicate matches none of the elements.
"""
return next(six.moves.filter(pred, iterable), default) | python | def first_where(pred, iterable, default=None):
"""Returns the first element in an iterable that meets the given predicate.
:param default: is the default value to use if the predicate matches none of the elements.
"""
return next(six.moves.filter(pred, iterable), default) | [
"def",
"first_where",
"(",
"pred",
",",
"iterable",
",",
"default",
"=",
"None",
")",
":",
"return",
"next",
"(",
"six",
".",
"moves",
".",
"filter",
"(",
"pred",
",",
"iterable",
")",
",",
"default",
")"
] | Returns the first element in an iterable that meets the given predicate.
:param default: is the default value to use if the predicate matches none of the elements. | [
"Returns",
"the",
"first",
"element",
"in",
"an",
"iterable",
"that",
"meets",
"the",
"given",
"predicate",
"."
] | c94476325146007553cbddeeb9ef83394756babf | https://github.com/blazelibs/blazeutils/blob/c94476325146007553cbddeeb9ef83394756babf/blazeutils/functional.py#L75-L80 |
238,039 | blazelibs/blazeutils | blazeutils/functional.py | partition_iter | def partition_iter(pred, iterable):
"""Partitions an iterable with a predicate into two iterables, one with elements satisfying
the predicate and one with elements that do not satisfy it.
:returns: a tuple (satisfiers, unsatisfiers).
"""
left, right = itertools.tee(iterable, 2)
return (
... | python | def partition_iter(pred, iterable):
"""Partitions an iterable with a predicate into two iterables, one with elements satisfying
the predicate and one with elements that do not satisfy it.
:returns: a tuple (satisfiers, unsatisfiers).
"""
left, right = itertools.tee(iterable, 2)
return (
... | [
"def",
"partition_iter",
"(",
"pred",
",",
"iterable",
")",
":",
"left",
",",
"right",
"=",
"itertools",
".",
"tee",
"(",
"iterable",
",",
"2",
")",
"return",
"(",
"(",
"x",
"for",
"x",
"in",
"left",
"if",
"pred",
"(",
"x",
")",
")",
",",
"(",
... | Partitions an iterable with a predicate into two iterables, one with elements satisfying
the predicate and one with elements that do not satisfy it.
:returns: a tuple (satisfiers, unsatisfiers). | [
"Partitions",
"an",
"iterable",
"with",
"a",
"predicate",
"into",
"two",
"iterables",
"one",
"with",
"elements",
"satisfying",
"the",
"predicate",
"and",
"one",
"with",
"elements",
"that",
"do",
"not",
"satisfy",
"it",
"."
] | c94476325146007553cbddeeb9ef83394756babf | https://github.com/blazelibs/blazeutils/blob/c94476325146007553cbddeeb9ef83394756babf/blazeutils/functional.py#L88-L98 |
238,040 | blazelibs/blazeutils | blazeutils/functional.py | partition_list | def partition_list(pred, iterable):
"""Partitions an iterable with a predicate into two lists, one with elements satisfying
the predicate and one with elements that do not satisfy it.
.. note: this just converts the results of partition_iter to a list for you so that you don't
have to in most cases usi... | python | def partition_list(pred, iterable):
"""Partitions an iterable with a predicate into two lists, one with elements satisfying
the predicate and one with elements that do not satisfy it.
.. note: this just converts the results of partition_iter to a list for you so that you don't
have to in most cases usi... | [
"def",
"partition_list",
"(",
"pred",
",",
"iterable",
")",
":",
"left",
",",
"right",
"=",
"partition_iter",
"(",
"pred",
",",
"iterable",
")",
"return",
"list",
"(",
"left",
")",
",",
"list",
"(",
"right",
")"
] | Partitions an iterable with a predicate into two lists, one with elements satisfying
the predicate and one with elements that do not satisfy it.
.. note: this just converts the results of partition_iter to a list for you so that you don't
have to in most cases using `partition_iter` is a better option.
... | [
"Partitions",
"an",
"iterable",
"with",
"a",
"predicate",
"into",
"two",
"lists",
"one",
"with",
"elements",
"satisfying",
"the",
"predicate",
"and",
"one",
"with",
"elements",
"that",
"do",
"not",
"satisfy",
"it",
"."
] | c94476325146007553cbddeeb9ef83394756babf | https://github.com/blazelibs/blazeutils/blob/c94476325146007553cbddeeb9ef83394756babf/blazeutils/functional.py#L101-L111 |
238,041 | blazelibs/blazeutils | blazeutils/functional.py | split_every | def split_every(n, iterable):
"""Returns a generator that spits an iteratable into n-sized chunks. The last chunk may have
less than n elements.
See http://stackoverflow.com/a/22919323/503377."""
items = iter(iterable)
return itertools.takewhile(bool, (list(itertools.islice(items, n)) for _ in iter... | python | def split_every(n, iterable):
"""Returns a generator that spits an iteratable into n-sized chunks. The last chunk may have
less than n elements.
See http://stackoverflow.com/a/22919323/503377."""
items = iter(iterable)
return itertools.takewhile(bool, (list(itertools.islice(items, n)) for _ in iter... | [
"def",
"split_every",
"(",
"n",
",",
"iterable",
")",
":",
"items",
"=",
"iter",
"(",
"iterable",
")",
"return",
"itertools",
".",
"takewhile",
"(",
"bool",
",",
"(",
"list",
"(",
"itertools",
".",
"islice",
"(",
"items",
",",
"n",
")",
")",
"for",
... | Returns a generator that spits an iteratable into n-sized chunks. The last chunk may have
less than n elements.
See http://stackoverflow.com/a/22919323/503377. | [
"Returns",
"a",
"generator",
"that",
"spits",
"an",
"iteratable",
"into",
"n",
"-",
"sized",
"chunks",
".",
"The",
"last",
"chunk",
"may",
"have",
"less",
"than",
"n",
"elements",
"."
] | c94476325146007553cbddeeb9ef83394756babf | https://github.com/blazelibs/blazeutils/blob/c94476325146007553cbddeeb9ef83394756babf/blazeutils/functional.py#L132-L138 |
238,042 | blazelibs/blazeutils | blazeutils/functional.py | unique | def unique(iterable, key=identity):
"""Yields all the unique values in an iterable maintaining order"""
seen = set()
for item in iterable:
item_key = key(item)
if item_key not in seen:
seen.add(item_key)
yield item | python | def unique(iterable, key=identity):
"""Yields all the unique values in an iterable maintaining order"""
seen = set()
for item in iterable:
item_key = key(item)
if item_key not in seen:
seen.add(item_key)
yield item | [
"def",
"unique",
"(",
"iterable",
",",
"key",
"=",
"identity",
")",
":",
"seen",
"=",
"set",
"(",
")",
"for",
"item",
"in",
"iterable",
":",
"item_key",
"=",
"key",
"(",
"item",
")",
"if",
"item_key",
"not",
"in",
"seen",
":",
"seen",
".",
"add",
... | Yields all the unique values in an iterable maintaining order | [
"Yields",
"all",
"the",
"unique",
"values",
"in",
"an",
"iterable",
"maintaining",
"order"
] | c94476325146007553cbddeeb9ef83394756babf | https://github.com/blazelibs/blazeutils/blob/c94476325146007553cbddeeb9ef83394756babf/blazeutils/functional.py#L141-L148 |
238,043 | moliware/dicts | dicts/sorteddict.py | SortedDict.iteritems | def iteritems(self):
""" Sort and then iterate the dictionary """
sorted_data = sorted(self.data.iteritems(), self.cmp, self.key,
self.reverse)
for k,v in sorted_data:
yield k,v | python | def iteritems(self):
""" Sort and then iterate the dictionary """
sorted_data = sorted(self.data.iteritems(), self.cmp, self.key,
self.reverse)
for k,v in sorted_data:
yield k,v | [
"def",
"iteritems",
"(",
"self",
")",
":",
"sorted_data",
"=",
"sorted",
"(",
"self",
".",
"data",
".",
"iteritems",
"(",
")",
",",
"self",
".",
"cmp",
",",
"self",
".",
"key",
",",
"self",
".",
"reverse",
")",
"for",
"k",
",",
"v",
"in",
"sorted... | Sort and then iterate the dictionary | [
"Sort",
"and",
"then",
"iterate",
"the",
"dictionary"
] | 0e8258cc3dc00fe929685cae9cda062222722715 | https://github.com/moliware/dicts/blob/0e8258cc3dc00fe929685cae9cda062222722715/dicts/sorteddict.py#L35-L40 |
238,044 | six8/anticipate | src/anticipate/decorators.py | anticipate_wrapper._adapt_param | def _adapt_param(self, key, val):
"""
Adapt the value if an adapter is defined.
"""
if key in self.param_adapters:
try:
return self.param_adapters[key](val)
except (AdaptError, AdaptErrors, TypeError, ValueError) as e:
if hasattr(e,... | python | def _adapt_param(self, key, val):
"""
Adapt the value if an adapter is defined.
"""
if key in self.param_adapters:
try:
return self.param_adapters[key](val)
except (AdaptError, AdaptErrors, TypeError, ValueError) as e:
if hasattr(e,... | [
"def",
"_adapt_param",
"(",
"self",
",",
"key",
",",
"val",
")",
":",
"if",
"key",
"in",
"self",
".",
"param_adapters",
":",
"try",
":",
"return",
"self",
".",
"param_adapters",
"[",
"key",
"]",
"(",
"val",
")",
"except",
"(",
"AdaptError",
",",
"Ada... | Adapt the value if an adapter is defined. | [
"Adapt",
"the",
"value",
"if",
"an",
"adapter",
"is",
"defined",
"."
] | 5c0651f9829ba0140e7cf185505da6109ef1f55c | https://github.com/six8/anticipate/blob/5c0651f9829ba0140e7cf185505da6109ef1f55c/src/anticipate/decorators.py#L64-L85 |
238,045 | six8/anticipate | src/anticipate/decorators.py | anticipate_wrapper.input | def input(self, *args, **kwargs):
"""
Adapt the input and check for errors.
Returns a tuple of adapted (args, kwargs) or raises
AnticipateErrors
"""
errors = []
if args and self.arg_names:
args = list(args)
# Replace args inline that have... | python | def input(self, *args, **kwargs):
"""
Adapt the input and check for errors.
Returns a tuple of adapted (args, kwargs) or raises
AnticipateErrors
"""
errors = []
if args and self.arg_names:
args = list(args)
# Replace args inline that have... | [
"def",
"input",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"errors",
"=",
"[",
"]",
"if",
"args",
"and",
"self",
".",
"arg_names",
":",
"args",
"=",
"list",
"(",
"args",
")",
"# Replace args inline that have adapters",
"for",
"i"... | Adapt the input and check for errors.
Returns a tuple of adapted (args, kwargs) or raises
AnticipateErrors | [
"Adapt",
"the",
"input",
"and",
"check",
"for",
"errors",
"."
] | 5c0651f9829ba0140e7cf185505da6109ef1f55c | https://github.com/six8/anticipate/blob/5c0651f9829ba0140e7cf185505da6109ef1f55c/src/anticipate/decorators.py#L95-L127 |
238,046 | six8/anticipate | src/anticipate/decorators.py | anticipate_wrapper.output | def output(self, result):
"""
Adapts the result of a function based on the returns definition.
"""
if self.returns:
errors = None
try:
return self._adapt_result(result)
except AdaptErrors as e:
errors = e.errors
... | python | def output(self, result):
"""
Adapts the result of a function based on the returns definition.
"""
if self.returns:
errors = None
try:
return self._adapt_result(result)
except AdaptErrors as e:
errors = e.errors
... | [
"def",
"output",
"(",
"self",
",",
"result",
")",
":",
"if",
"self",
".",
"returns",
":",
"errors",
"=",
"None",
"try",
":",
"return",
"self",
".",
"_adapt_result",
"(",
"result",
")",
"except",
"AdaptErrors",
"as",
"e",
":",
"errors",
"=",
"e",
".",... | Adapts the result of a function based on the returns definition. | [
"Adapts",
"the",
"result",
"of",
"a",
"function",
"based",
"on",
"the",
"returns",
"definition",
"."
] | 5c0651f9829ba0140e7cf185505da6109ef1f55c | https://github.com/six8/anticipate/blob/5c0651f9829ba0140e7cf185505da6109ef1f55c/src/anticipate/decorators.py#L129-L154 |
238,047 | jpscaletti/solution | solution/fields/file/image.py | Image.clean | def clean(self, value):
"""Passes the value to FileField and resizes the image at the path the parent
returns if needed.
"""
path = super(Image, self).clean(value)
if path and self.size:
self.resize_image(join(self.base_path, path))
return path | python | def clean(self, value):
"""Passes the value to FileField and resizes the image at the path the parent
returns if needed.
"""
path = super(Image, self).clean(value)
if path and self.size:
self.resize_image(join(self.base_path, path))
return path | [
"def",
"clean",
"(",
"self",
",",
"value",
")",
":",
"path",
"=",
"super",
"(",
"Image",
",",
"self",
")",
".",
"clean",
"(",
"value",
")",
"if",
"path",
"and",
"self",
".",
"size",
":",
"self",
".",
"resize_image",
"(",
"join",
"(",
"self",
".",... | Passes the value to FileField and resizes the image at the path the parent
returns if needed. | [
"Passes",
"the",
"value",
"to",
"FileField",
"and",
"resizes",
"the",
"image",
"at",
"the",
"path",
"the",
"parent",
"returns",
"if",
"needed",
"."
] | eabafd8e695bbb0209242e002dbcc05ffb327f43 | https://github.com/jpscaletti/solution/blob/eabafd8e695bbb0209242e002dbcc05ffb327f43/solution/fields/file/image.py#L22-L30 |
238,048 | jpscaletti/solution | solution/fields/file/image.py | Image.calculate_dimensions | def calculate_dimensions(image_size, desired_size):
"""Return the Tuple with the arguments to pass to Image.crop.
If the image is smaller than than the desired_size Don't do
anything. Otherwise, first calculate the (truncated) center and then
take half the width and height (truncated ag... | python | def calculate_dimensions(image_size, desired_size):
"""Return the Tuple with the arguments to pass to Image.crop.
If the image is smaller than than the desired_size Don't do
anything. Otherwise, first calculate the (truncated) center and then
take half the width and height (truncated ag... | [
"def",
"calculate_dimensions",
"(",
"image_size",
",",
"desired_size",
")",
":",
"current_x",
",",
"current_y",
"=",
"image_size",
"target_x",
",",
"target_y",
"=",
"desired_size",
"if",
"current_x",
"<",
"target_x",
"and",
"current_y",
"<",
"target_y",
":",
"re... | Return the Tuple with the arguments to pass to Image.crop.
If the image is smaller than than the desired_size Don't do
anything. Otherwise, first calculate the (truncated) center and then
take half the width and height (truncated again) for x and y.
x0, y0: the center coordinates | [
"Return",
"the",
"Tuple",
"with",
"the",
"arguments",
"to",
"pass",
"to",
"Image",
".",
"crop",
"."
] | eabafd8e695bbb0209242e002dbcc05ffb327f43 | https://github.com/jpscaletti/solution/blob/eabafd8e695bbb0209242e002dbcc05ffb327f43/solution/fields/file/image.py#L45-L77 |
238,049 | openpermissions/koi | koi/base.py | CorsHandler.options | def options(self, *args, **kwargs):
"""Default OPTIONS response
If the 'cors' option is True, will respond with an empty response and
set the 'Access-Control-Allow-Headers' and
'Access-Control-Allow-Methods' headers
"""
if getattr(options, 'cors', False):
sel... | python | def options(self, *args, **kwargs):
"""Default OPTIONS response
If the 'cors' option is True, will respond with an empty response and
set the 'Access-Control-Allow-Headers' and
'Access-Control-Allow-Methods' headers
"""
if getattr(options, 'cors', False):
sel... | [
"def",
"options",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"getattr",
"(",
"options",
",",
"'cors'",
",",
"False",
")",
":",
"self",
".",
"set_header",
"(",
"'Access-Control-Allow-Headers'",
",",
"'Content-Type, Authorization, ... | Default OPTIONS response
If the 'cors' option is True, will respond with an empty response and
set the 'Access-Control-Allow-Headers' and
'Access-Control-Allow-Methods' headers | [
"Default",
"OPTIONS",
"response"
] | d721f8e1dfa8f07ad265d9dec32e8aaf80a9f281 | https://github.com/openpermissions/koi/blob/d721f8e1dfa8f07ad265d9dec32e8aaf80a9f281/koi/base.py#L42-L57 |
238,050 | openpermissions/koi | koi/base.py | JsonHandler.write_error | def write_error(self, status_code, **kwargs):
"""Override `write_error` in order to output JSON errors
:param status_code: the response's status code, e.g. 500
"""
http_error = _get_http_error(kwargs)
if http_error:
self.finish(self._error_template(status_code,
... | python | def write_error(self, status_code, **kwargs):
"""Override `write_error` in order to output JSON errors
:param status_code: the response's status code, e.g. 500
"""
http_error = _get_http_error(kwargs)
if http_error:
self.finish(self._error_template(status_code,
... | [
"def",
"write_error",
"(",
"self",
",",
"status_code",
",",
"*",
"*",
"kwargs",
")",
":",
"http_error",
"=",
"_get_http_error",
"(",
"kwargs",
")",
"if",
"http_error",
":",
"self",
".",
"finish",
"(",
"self",
".",
"_error_template",
"(",
"status_code",
","... | Override `write_error` in order to output JSON errors
:param status_code: the response's status code, e.g. 500 | [
"Override",
"write_error",
"in",
"order",
"to",
"output",
"JSON",
"errors"
] | d721f8e1dfa8f07ad265d9dec32e8aaf80a9f281 | https://github.com/openpermissions/koi/blob/d721f8e1dfa8f07ad265d9dec32e8aaf80a9f281/koi/base.py#L62-L80 |
238,051 | openpermissions/koi | koi/base.py | JsonHandler._error_template | def _error_template(cls, status_code, errors, source=None):
"""Construct JSON error response
:param status_code: the http status code
:param errors: string or list of error strings
:param source: source of the error
:returns: dictionary, e.g.
{
'statu... | python | def _error_template(cls, status_code, errors, source=None):
"""Construct JSON error response
:param status_code: the http status code
:param errors: string or list of error strings
:param source: source of the error
:returns: dictionary, e.g.
{
'statu... | [
"def",
"_error_template",
"(",
"cls",
",",
"status_code",
",",
"errors",
",",
"source",
"=",
"None",
")",
":",
"# this handles unhandled exceptions",
"if",
"isinstance",
"(",
"errors",
",",
"basestring",
")",
":",
"errors_out",
"=",
"{",
"'errors'",
":",
"[",
... | Construct JSON error response
:param status_code: the http status code
:param errors: string or list of error strings
:param source: source of the error
:returns: dictionary, e.g.
{
'status': 400,
'errors': [
{
... | [
"Construct",
"JSON",
"error",
"response"
] | d721f8e1dfa8f07ad265d9dec32e8aaf80a9f281 | https://github.com/openpermissions/koi/blob/d721f8e1dfa8f07ad265d9dec32e8aaf80a9f281/koi/base.py#L83-L118 |
238,052 | openpermissions/koi | koi/base.py | JsonHandler.get_json_body | def get_json_body(self, required=None, validators=None):
"""Get JSON from the request body
:param required: optionally provide a list of keys that should be
in the JSON body (raises a 400 HTTPError if any are missing)
:param validator: optionally provide a dictionary of items that shoul... | python | def get_json_body(self, required=None, validators=None):
"""Get JSON from the request body
:param required: optionally provide a list of keys that should be
in the JSON body (raises a 400 HTTPError if any are missing)
:param validator: optionally provide a dictionary of items that shoul... | [
"def",
"get_json_body",
"(",
"self",
",",
"required",
"=",
"None",
",",
"validators",
"=",
"None",
")",
":",
"content_type",
"=",
"self",
".",
"request",
".",
"headers",
".",
"get",
"(",
"'Content-Type'",
",",
"'application/json'",
")",
"if",
"'application/j... | Get JSON from the request body
:param required: optionally provide a list of keys that should be
in the JSON body (raises a 400 HTTPError if any are missing)
:param validator: optionally provide a dictionary of items that should
be in the body with a method that validates the item.
... | [
"Get",
"JSON",
"from",
"the",
"request",
"body"
] | d721f8e1dfa8f07ad265d9dec32e8aaf80a9f281 | https://github.com/openpermissions/koi/blob/d721f8e1dfa8f07ad265d9dec32e8aaf80a9f281/koi/base.py#L120-L152 |
238,053 | openpermissions/koi | koi/base.py | AuthHandler.verify_token | def verify_token(self, token, requested_access):
"""
Check the token bearer is permitted to access the resource
:param token: Access token
:param requested_access: the access level the client has requested
:returns: boolean
"""
client = API(options.url_auth,
... | python | def verify_token(self, token, requested_access):
"""
Check the token bearer is permitted to access the resource
:param token: Access token
:param requested_access: the access level the client has requested
:returns: boolean
"""
client = API(options.url_auth,
... | [
"def",
"verify_token",
"(",
"self",
",",
"token",
",",
"requested_access",
")",
":",
"client",
"=",
"API",
"(",
"options",
".",
"url_auth",
",",
"auth_username",
"=",
"options",
".",
"service_id",
",",
"auth_password",
"=",
"options",
".",
"client_secret",
"... | Check the token bearer is permitted to access the resource
:param token: Access token
:param requested_access: the access level the client has requested
:returns: boolean | [
"Check",
"the",
"token",
"bearer",
"is",
"permitted",
"to",
"access",
"the",
"resource"
] | d721f8e1dfa8f07ad265d9dec32e8aaf80a9f281 | https://github.com/openpermissions/koi/blob/d721f8e1dfa8f07ad265d9dec32e8aaf80a9f281/koi/base.py#L188-L214 |
238,054 | openpermissions/koi | koi/base.py | AuthHandler.prepare | def prepare(self):
"""If OAuth verification is required, validate provided token
:raise: HTTPError if token does not have access
"""
requested_access = self.endpoint_access(self.request.method)
use_oauth = getattr(options, 'use_oauth', None)
if use_oauth and requested_ac... | python | def prepare(self):
"""If OAuth verification is required, validate provided token
:raise: HTTPError if token does not have access
"""
requested_access = self.endpoint_access(self.request.method)
use_oauth = getattr(options, 'use_oauth', None)
if use_oauth and requested_ac... | [
"def",
"prepare",
"(",
"self",
")",
":",
"requested_access",
"=",
"self",
".",
"endpoint_access",
"(",
"self",
".",
"request",
".",
"method",
")",
"use_oauth",
"=",
"getattr",
"(",
"options",
",",
"'use_oauth'",
",",
"None",
")",
"if",
"use_oauth",
"and",
... | If OAuth verification is required, validate provided token
:raise: HTTPError if token does not have access | [
"If",
"OAuth",
"verification",
"is",
"required",
"validate",
"provided",
"token"
] | d721f8e1dfa8f07ad265d9dec32e8aaf80a9f281 | https://github.com/openpermissions/koi/blob/d721f8e1dfa8f07ad265d9dec32e8aaf80a9f281/koi/base.py#L217-L233 |
238,055 | TrafficSenseMSD/SumoTools | sumolib/xml.py | parse_fast | def parse_fast(xmlfile, element_name, attrnames, warn=False, optional=False):
"""
Parses the given attrnames from all elements with element_name
@Note: The element must be on its own line and the attributes must appear in
the given order.
@Example: parse_fast('plain.edg.xml', 'edge', ['id', 'speed']... | python | def parse_fast(xmlfile, element_name, attrnames, warn=False, optional=False):
"""
Parses the given attrnames from all elements with element_name
@Note: The element must be on its own line and the attributes must appear in
the given order.
@Example: parse_fast('plain.edg.xml', 'edge', ['id', 'speed']... | [
"def",
"parse_fast",
"(",
"xmlfile",
",",
"element_name",
",",
"attrnames",
",",
"warn",
"=",
"False",
",",
"optional",
"=",
"False",
")",
":",
"prefixedAttrnames",
"=",
"[",
"_prefix_keyword",
"(",
"a",
",",
"warn",
")",
"for",
"a",
"in",
"attrnames",
"... | Parses the given attrnames from all elements with element_name
@Note: The element must be on its own line and the attributes must appear in
the given order.
@Example: parse_fast('plain.edg.xml', 'edge', ['id', 'speed']) | [
"Parses",
"the",
"given",
"attrnames",
"from",
"all",
"elements",
"with",
"element_name"
] | 8607b4f885f1d1798e43240be643efe6dccccdaa | https://github.com/TrafficSenseMSD/SumoTools/blob/8607b4f885f1d1798e43240be643efe6dccccdaa/sumolib/xml.py#L227-L249 |
238,056 | hchasestevens/tracing | tracing/__init__.py | tracing | def tracing(pattern=None, out=None):
"""Print executed lines to stdout."""
_trace = partial(trace_line, pattern)
if out is None:
out = sys.stdout
with redirect_stdout(out):
sys.settrace(_trace)
try:
yield
finally:
sys.settrace(None) | python | def tracing(pattern=None, out=None):
"""Print executed lines to stdout."""
_trace = partial(trace_line, pattern)
if out is None:
out = sys.stdout
with redirect_stdout(out):
sys.settrace(_trace)
try:
yield
finally:
sys.settrace(None) | [
"def",
"tracing",
"(",
"pattern",
"=",
"None",
",",
"out",
"=",
"None",
")",
":",
"_trace",
"=",
"partial",
"(",
"trace_line",
",",
"pattern",
")",
"if",
"out",
"is",
"None",
":",
"out",
"=",
"sys",
".",
"stdout",
"with",
"redirect_stdout",
"(",
"out... | Print executed lines to stdout. | [
"Print",
"executed",
"lines",
"to",
"stdout",
"."
] | 58600c8de6767dcd381064169a7bec3f5f37cbc7 | https://github.com/hchasestevens/tracing/blob/58600c8de6767dcd381064169a7bec3f5f37cbc7/tracing/__init__.py#L17-L29 |
238,057 | omederos/pyspinner | spinning/spinning.py | override_params | def override_params(opening_char='{', closing_char='}', separator_char='|'):
"""
Override some character settings
@type opening_char: str
@param opening_char: Opening character. Default: '{'
@type closing_char: str
@param closing_char: Closing character. Default: '}'
@type separator_char: s... | python | def override_params(opening_char='{', closing_char='}', separator_char='|'):
"""
Override some character settings
@type opening_char: str
@param opening_char: Opening character. Default: '{'
@type closing_char: str
@param closing_char: Closing character. Default: '}'
@type separator_char: s... | [
"def",
"override_params",
"(",
"opening_char",
"=",
"'{'",
",",
"closing_char",
"=",
"'}'",
",",
"separator_char",
"=",
"'|'",
")",
":",
"global",
"char_separator",
",",
"char_opening",
",",
"char_closing",
"char_separator",
"=",
"separator_char",
"char_opening",
... | Override some character settings
@type opening_char: str
@param opening_char: Opening character. Default: '{'
@type closing_char: str
@param closing_char: Closing character. Default: '}'
@type separator_char: str
@param separator_char: Separator char. Default: '|' | [
"Override",
"some",
"character",
"settings"
] | 4615d92e669942c48d5542a23ddf6d40b206d9d5 | https://github.com/omederos/pyspinner/blob/4615d92e669942c48d5542a23ddf6d40b206d9d5/spinning/spinning.py#L10-L24 |
238,058 | omederos/pyspinner | spinning/spinning.py | unique | def unique(text):
"""
Return an unique text
@type text: str
@param text: Text written used spin syntax.
@return: An unique text
# Generate an unique sentence
>>> unique('The {quick|fast} {brown|gray|red} fox jumped over the lazy dog.')
'The quick red fox jumped over the lazy dog'
... | python | def unique(text):
"""
Return an unique text
@type text: str
@param text: Text written used spin syntax.
@return: An unique text
# Generate an unique sentence
>>> unique('The {quick|fast} {brown|gray|red} fox jumped over the lazy dog.')
'The quick red fox jumped over the lazy dog'
... | [
"def",
"unique",
"(",
"text",
")",
":",
"# check if the text is correct",
"correct",
",",
"error",
"=",
"_is_correct",
"(",
"text",
")",
"if",
"not",
"correct",
":",
"raise",
"Exception",
"(",
"error",
")",
"s",
"=",
"[",
"]",
"_all_unique_texts",
"(",
"te... | Return an unique text
@type text: str
@param text: Text written used spin syntax.
@return: An unique text
# Generate an unique sentence
>>> unique('The {quick|fast} {brown|gray|red} fox jumped over the lazy dog.')
'The quick red fox jumped over the lazy dog' | [
"Return",
"an",
"unique",
"text"
] | 4615d92e669942c48d5542a23ddf6d40b206d9d5 | https://github.com/omederos/pyspinner/blob/4615d92e669942c48d5542a23ddf6d40b206d9d5/spinning/spinning.py#L27-L49 |
238,059 | omederos/pyspinner | spinning/spinning.py | _all_unique_texts | def _all_unique_texts(text, final):
"""
Compute all the possible unique texts
@type text: str
@param text: Text written used spin syntax
@type final: list
@param final: An empty list where all the unique texts will be stored
@return: Nothing. The result will be in the 'final' list
"""
... | python | def _all_unique_texts(text, final):
"""
Compute all the possible unique texts
@type text: str
@param text: Text written used spin syntax
@type final: list
@param final: An empty list where all the unique texts will be stored
@return: Nothing. The result will be in the 'final' list
"""
... | [
"def",
"_all_unique_texts",
"(",
"text",
",",
"final",
")",
":",
"if",
"not",
"char_opening",
"in",
"text",
":",
"if",
"not",
"text",
"in",
"final",
":",
"final",
".",
"append",
"(",
"text",
")",
"return",
"stack",
"=",
"[",
"]",
"indexes",
"=",
"[",... | Compute all the possible unique texts
@type text: str
@param text: Text written used spin syntax
@type final: list
@param final: An empty list where all the unique texts will be stored
@return: Nothing. The result will be in the 'final' list | [
"Compute",
"all",
"the",
"possible",
"unique",
"texts"
] | 4615d92e669942c48d5542a23ddf6d40b206d9d5 | https://github.com/omederos/pyspinner/blob/4615d92e669942c48d5542a23ddf6d40b206d9d5/spinning/spinning.py#L79-L109 |
238,060 | omederos/pyspinner | spinning/spinning.py | _is_correct | def _is_correct(text):
"""
Check if the specified text has a correct spin syntax
@type text: str
@param text: Text written used spin syntax
@rtype: tuple
@return: A tuple: (is_correct, error). First position contains the result, and second one the error if not correct.
"""
error = ''
... | python | def _is_correct(text):
"""
Check if the specified text has a correct spin syntax
@type text: str
@param text: Text written used spin syntax
@rtype: tuple
@return: A tuple: (is_correct, error). First position contains the result, and second one the error if not correct.
"""
error = ''
... | [
"def",
"_is_correct",
"(",
"text",
")",
":",
"error",
"=",
"''",
"stack",
"=",
"[",
"]",
"for",
"i",
",",
"c",
"in",
"enumerate",
"(",
"text",
")",
":",
"if",
"c",
"==",
"char_opening",
":",
"stack",
".",
"append",
"(",
"c",
")",
"elif",
"c",
"... | Check if the specified text has a correct spin syntax
@type text: str
@param text: Text written used spin syntax
@rtype: tuple
@return: A tuple: (is_correct, error). First position contains the result, and second one the error if not correct. | [
"Check",
"if",
"the",
"specified",
"text",
"has",
"a",
"correct",
"spin",
"syntax"
] | 4615d92e669942c48d5542a23ddf6d40b206d9d5 | https://github.com/omederos/pyspinner/blob/4615d92e669942c48d5542a23ddf6d40b206d9d5/spinning/spinning.py#L112-L137 |
238,061 | matthieugouel/gibica | gibica/interpreter.py | Interpreter.visit_FunctionBody | def visit_FunctionBody(self, node):
"""Visitor for `FunctionBody` AST node."""
for child in node.children:
return_value = self.visit(child)
if isinstance(child, ReturnStatement):
return return_value
if isinstance(child, (IfStatement, WhileStatement))... | python | def visit_FunctionBody(self, node):
"""Visitor for `FunctionBody` AST node."""
for child in node.children:
return_value = self.visit(child)
if isinstance(child, ReturnStatement):
return return_value
if isinstance(child, (IfStatement, WhileStatement))... | [
"def",
"visit_FunctionBody",
"(",
"self",
",",
"node",
")",
":",
"for",
"child",
"in",
"node",
".",
"children",
":",
"return_value",
"=",
"self",
".",
"visit",
"(",
"child",
")",
"if",
"isinstance",
"(",
"child",
",",
"ReturnStatement",
")",
":",
"return... | Visitor for `FunctionBody` AST node. | [
"Visitor",
"for",
"FunctionBody",
"AST",
"node",
"."
] | 65f937f7a6255078cc22eb7691a2897466032909 | https://github.com/matthieugouel/gibica/blob/65f937f7a6255078cc22eb7691a2897466032909/gibica/interpreter.py#L73-L85 |
238,062 | matthieugouel/gibica | gibica/interpreter.py | Interpreter.visit_WhileStatement | def visit_WhileStatement(self, node):
"""Visitor for `WhileStatement` AST node."""
while self.visit(node.condition):
result = self.visit(node.compound)
if result is not None:
return result | python | def visit_WhileStatement(self, node):
"""Visitor for `WhileStatement` AST node."""
while self.visit(node.condition):
result = self.visit(node.compound)
if result is not None:
return result | [
"def",
"visit_WhileStatement",
"(",
"self",
",",
"node",
")",
":",
"while",
"self",
".",
"visit",
"(",
"node",
".",
"condition",
")",
":",
"result",
"=",
"self",
".",
"visit",
"(",
"node",
".",
"compound",
")",
"if",
"result",
"is",
"not",
"None",
":... | Visitor for `WhileStatement` AST node. | [
"Visitor",
"for",
"WhileStatement",
"AST",
"node",
"."
] | 65f937f7a6255078cc22eb7691a2897466032909 | https://github.com/matthieugouel/gibica/blob/65f937f7a6255078cc22eb7691a2897466032909/gibica/interpreter.py#L151-L156 |
238,063 | matthieugouel/gibica | gibica/interpreter.py | Interpreter.visit_Compound | def visit_Compound(self, node):
"""Visitor for `Compound` AST node."""
self.memory.append_scope()
for child in node.children:
return_value = self.visit(child)
if isinstance(child, ReturnStatement):
return return_value
if isinstance(child, (If... | python | def visit_Compound(self, node):
"""Visitor for `Compound` AST node."""
self.memory.append_scope()
for child in node.children:
return_value = self.visit(child)
if isinstance(child, ReturnStatement):
return return_value
if isinstance(child, (If... | [
"def",
"visit_Compound",
"(",
"self",
",",
"node",
")",
":",
"self",
".",
"memory",
".",
"append_scope",
"(",
")",
"for",
"child",
"in",
"node",
".",
"children",
":",
"return_value",
"=",
"self",
".",
"visit",
"(",
"child",
")",
"if",
"isinstance",
"("... | Visitor for `Compound` AST node. | [
"Visitor",
"for",
"Compound",
"AST",
"node",
"."
] | 65f937f7a6255078cc22eb7691a2897466032909 | https://github.com/matthieugouel/gibica/blob/65f937f7a6255078cc22eb7691a2897466032909/gibica/interpreter.py#L158-L170 |
238,064 | matthieugouel/gibica | gibica/interpreter.py | Interpreter.visit_UnaryOperation | def visit_UnaryOperation(self, node):
"""Visitor for `UnaryOperation` AST node."""
if node.op.nature == Nature.PLUS:
return +self.visit(node.right)
elif node.op.nature == Nature.MINUS:
return -self.visit(node.right)
elif node.op.nature == Nature.NOT:
r... | python | def visit_UnaryOperation(self, node):
"""Visitor for `UnaryOperation` AST node."""
if node.op.nature == Nature.PLUS:
return +self.visit(node.right)
elif node.op.nature == Nature.MINUS:
return -self.visit(node.right)
elif node.op.nature == Nature.NOT:
r... | [
"def",
"visit_UnaryOperation",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
".",
"op",
".",
"nature",
"==",
"Nature",
".",
"PLUS",
":",
"return",
"+",
"self",
".",
"visit",
"(",
"node",
".",
"right",
")",
"elif",
"node",
".",
"op",
".",
"natur... | Visitor for `UnaryOperation` AST node. | [
"Visitor",
"for",
"UnaryOperation",
"AST",
"node",
"."
] | 65f937f7a6255078cc22eb7691a2897466032909 | https://github.com/matthieugouel/gibica/blob/65f937f7a6255078cc22eb7691a2897466032909/gibica/interpreter.py#L205-L212 |
238,065 | matthieugouel/gibica | gibica/interpreter.py | Interpreter.visit_Boolean | def visit_Boolean(self, node):
"""Visitor for `Boolean` AST node."""
if node.value == 'true':
return Bool(True)
elif node.value == 'false':
return Bool(False) | python | def visit_Boolean(self, node):
"""Visitor for `Boolean` AST node."""
if node.value == 'true':
return Bool(True)
elif node.value == 'false':
return Bool(False) | [
"def",
"visit_Boolean",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
".",
"value",
"==",
"'true'",
":",
"return",
"Bool",
"(",
"True",
")",
"elif",
"node",
".",
"value",
"==",
"'false'",
":",
"return",
"Bool",
"(",
"False",
")"
] | Visitor for `Boolean` AST node. | [
"Visitor",
"for",
"Boolean",
"AST",
"node",
"."
] | 65f937f7a6255078cc22eb7691a2897466032909 | https://github.com/matthieugouel/gibica/blob/65f937f7a6255078cc22eb7691a2897466032909/gibica/interpreter.py#L226-L231 |
238,066 | matthieugouel/gibica | gibica/interpreter.py | Interpreter.interpret | def interpret(self):
"""Generic entrypoint of `Interpreter` class."""
self.load_builtins()
self.load_functions(self.tree)
self.visit(self.tree) | python | def interpret(self):
"""Generic entrypoint of `Interpreter` class."""
self.load_builtins()
self.load_functions(self.tree)
self.visit(self.tree) | [
"def",
"interpret",
"(",
"self",
")",
":",
"self",
".",
"load_builtins",
"(",
")",
"self",
".",
"load_functions",
"(",
"self",
".",
"tree",
")",
"self",
".",
"visit",
"(",
"self",
".",
"tree",
")"
] | Generic entrypoint of `Interpreter` class. | [
"Generic",
"entrypoint",
"of",
"Interpreter",
"class",
"."
] | 65f937f7a6255078cc22eb7691a2897466032909 | https://github.com/matthieugouel/gibica/blob/65f937f7a6255078cc22eb7691a2897466032909/gibica/interpreter.py#L233-L237 |
238,067 | andreasjansson/head-in-the-clouds | headintheclouds/ensemble/tasks.py | up | def up(name, debug=False):
'''
Create servers and containers as required to meet the configuration
specified in _name_.
Args:
* name: The name of the yaml config file (you can omit the .yml extension for convenience)
Example:
fab ensemble.up:wordpress
'''
if debug:
... | python | def up(name, debug=False):
'''
Create servers and containers as required to meet the configuration
specified in _name_.
Args:
* name: The name of the yaml config file (you can omit the .yml extension for convenience)
Example:
fab ensemble.up:wordpress
'''
if debug:
... | [
"def",
"up",
"(",
"name",
",",
"debug",
"=",
"False",
")",
":",
"if",
"debug",
":",
"env",
".",
"ensemble_debug",
"=",
"True",
"filenames_to_try",
"=",
"[",
"name",
",",
"'%s.yml'",
"%",
"name",
",",
"'%s.yaml'",
"%",
"name",
",",
"]",
"for",
"filena... | Create servers and containers as required to meet the configuration
specified in _name_.
Args:
* name: The name of the yaml config file (you can omit the .yml extension for convenience)
Example:
fab ensemble.up:wordpress | [
"Create",
"servers",
"and",
"containers",
"as",
"required",
"to",
"meet",
"the",
"configuration",
"specified",
"in",
"_name_",
"."
] | 32c1d00d01036834dc94368e7f38b0afd3f7a82f | https://github.com/andreasjansson/head-in-the-clouds/blob/32c1d00d01036834dc94368e7f38b0afd3f7a82f/headintheclouds/ensemble/tasks.py#L15-L48 |
238,068 | ChrisCummins/labm8 | prof.py | stop | def stop(name, file=sys.stderr):
"""
Stop a profiling timer.
Arguments:
name (str): The name of the timer to stop. If no name is given, stop
the global anonymous timer.
Returns:
bool: Whether or not profiling is enabled.
Raises:
KeyError: If the named timer ... | python | def stop(name, file=sys.stderr):
"""
Stop a profiling timer.
Arguments:
name (str): The name of the timer to stop. If no name is given, stop
the global anonymous timer.
Returns:
bool: Whether or not profiling is enabled.
Raises:
KeyError: If the named timer ... | [
"def",
"stop",
"(",
"name",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
":",
"if",
"is_enabled",
"(",
")",
":",
"elapsed",
"=",
"(",
"time",
"(",
")",
"-",
"__TIMERS",
"[",
"name",
"]",
")",
"if",
"elapsed",
">",
"60",
":",
"elapsed_str",
"=",
... | Stop a profiling timer.
Arguments:
name (str): The name of the timer to stop. If no name is given, stop
the global anonymous timer.
Returns:
bool: Whether or not profiling is enabled.
Raises:
KeyError: If the named timer does not exist. | [
"Stop",
"a",
"profiling",
"timer",
"."
] | dd10d67a757aefb180cb508f86696f99440c94f5 | https://github.com/ChrisCummins/labm8/blob/dd10d67a757aefb180cb508f86696f99440c94f5/prof.py#L82-L110 |
238,069 | ChrisCummins/labm8 | prof.py | profile | def profile(fun, *args, **kwargs):
"""
Profile a function.
"""
timer_name = kwargs.pop("prof_name", None)
if not timer_name:
module = inspect.getmodule(fun)
c = [module.__name__]
parentclass = labtypes.get_class_that_defined_method(fun)
if parentclass:
c.... | python | def profile(fun, *args, **kwargs):
"""
Profile a function.
"""
timer_name = kwargs.pop("prof_name", None)
if not timer_name:
module = inspect.getmodule(fun)
c = [module.__name__]
parentclass = labtypes.get_class_that_defined_method(fun)
if parentclass:
c.... | [
"def",
"profile",
"(",
"fun",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"timer_name",
"=",
"kwargs",
".",
"pop",
"(",
"\"prof_name\"",
",",
"None",
")",
"if",
"not",
"timer_name",
":",
"module",
"=",
"inspect",
".",
"getmodule",
"(",
"fun"... | Profile a function. | [
"Profile",
"a",
"function",
"."
] | dd10d67a757aefb180cb508f86696f99440c94f5 | https://github.com/ChrisCummins/labm8/blob/dd10d67a757aefb180cb508f86696f99440c94f5/prof.py#L113-L131 |
238,070 | TrafficSenseMSD/SumoTools | sumolib/miscutils.py | geh | def geh(m, c):
"""Error function for hourly traffic flow measures after Geoffrey E. Havers"""
if m + c == 0:
return 0
else:
return math.sqrt(2 * (m - c) * (m - c) / (m + c)) | python | def geh(m, c):
"""Error function for hourly traffic flow measures after Geoffrey E. Havers"""
if m + c == 0:
return 0
else:
return math.sqrt(2 * (m - c) * (m - c) / (m + c)) | [
"def",
"geh",
"(",
"m",
",",
"c",
")",
":",
"if",
"m",
"+",
"c",
"==",
"0",
":",
"return",
"0",
"else",
":",
"return",
"math",
".",
"sqrt",
"(",
"2",
"*",
"(",
"m",
"-",
"c",
")",
"*",
"(",
"m",
"-",
"c",
")",
"/",
"(",
"m",
"+",
"c",... | Error function for hourly traffic flow measures after Geoffrey E. Havers | [
"Error",
"function",
"for",
"hourly",
"traffic",
"flow",
"measures",
"after",
"Geoffrey",
"E",
".",
"Havers"
] | 8607b4f885f1d1798e43240be643efe6dccccdaa | https://github.com/TrafficSenseMSD/SumoTools/blob/8607b4f885f1d1798e43240be643efe6dccccdaa/sumolib/miscutils.py#L225-L230 |
238,071 | TrafficSenseMSD/SumoTools | sumolib/miscutils.py | Statistics.avg | def avg(self):
"""return the mean value"""
# XXX rename this method
if len(self.values) > 0:
return sum(self.values) / float(len(self.values))
else:
return None | python | def avg(self):
"""return the mean value"""
# XXX rename this method
if len(self.values) > 0:
return sum(self.values) / float(len(self.values))
else:
return None | [
"def",
"avg",
"(",
"self",
")",
":",
"# XXX rename this method",
"if",
"len",
"(",
"self",
".",
"values",
")",
">",
"0",
":",
"return",
"sum",
"(",
"self",
".",
"values",
")",
"/",
"float",
"(",
"len",
"(",
"self",
".",
"values",
")",
")",
"else",
... | return the mean value | [
"return",
"the",
"mean",
"value"
] | 8607b4f885f1d1798e43240be643efe6dccccdaa | https://github.com/TrafficSenseMSD/SumoTools/blob/8607b4f885f1d1798e43240be643efe6dccccdaa/sumolib/miscutils.py#L124-L130 |
238,072 | TrafficSenseMSD/SumoTools | sumolib/miscutils.py | Statistics.avg_abs | def avg_abs(self):
"""return the mean of absolute values"""
# XXX rename this method
if len(self.values) > 0:
return sum(map(abs, self.values)) / float(len(self.values))
else:
return None | python | def avg_abs(self):
"""return the mean of absolute values"""
# XXX rename this method
if len(self.values) > 0:
return sum(map(abs, self.values)) / float(len(self.values))
else:
return None | [
"def",
"avg_abs",
"(",
"self",
")",
":",
"# XXX rename this method",
"if",
"len",
"(",
"self",
".",
"values",
")",
">",
"0",
":",
"return",
"sum",
"(",
"map",
"(",
"abs",
",",
"self",
".",
"values",
")",
")",
"/",
"float",
"(",
"len",
"(",
"self",
... | return the mean of absolute values | [
"return",
"the",
"mean",
"of",
"absolute",
"values"
] | 8607b4f885f1d1798e43240be643efe6dccccdaa | https://github.com/TrafficSenseMSD/SumoTools/blob/8607b4f885f1d1798e43240be643efe6dccccdaa/sumolib/miscutils.py#L132-L138 |
238,073 | TrafficSenseMSD/SumoTools | sumolib/miscutils.py | Statistics.meanAndStdDev | def meanAndStdDev(self, limit=None):
"""return the mean and the standard deviation optionally limited to the last limit values"""
if limit is None or len(self.values) < limit:
limit = len(self.values)
if limit > 0:
mean = sum(self.values[-limit:]) / float(limit)
... | python | def meanAndStdDev(self, limit=None):
"""return the mean and the standard deviation optionally limited to the last limit values"""
if limit is None or len(self.values) < limit:
limit = len(self.values)
if limit > 0:
mean = sum(self.values[-limit:]) / float(limit)
... | [
"def",
"meanAndStdDev",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"if",
"limit",
"is",
"None",
"or",
"len",
"(",
"self",
".",
"values",
")",
"<",
"limit",
":",
"limit",
"=",
"len",
"(",
"self",
".",
"values",
")",
"if",
"limit",
">",
"0",... | return the mean and the standard deviation optionally limited to the last limit values | [
"return",
"the",
"mean",
"and",
"the",
"standard",
"deviation",
"optionally",
"limited",
"to",
"the",
"last",
"limit",
"values"
] | 8607b4f885f1d1798e43240be643efe6dccccdaa | https://github.com/TrafficSenseMSD/SumoTools/blob/8607b4f885f1d1798e43240be643efe6dccccdaa/sumolib/miscutils.py#L140-L151 |
238,074 | TrafficSenseMSD/SumoTools | sumolib/miscutils.py | Statistics.relStdDev | def relStdDev(self, limit=None):
"""return the relative standard deviation optionally limited to the last limit values"""
moments = self.meanAndStdDev(limit)
if moments is None:
return None
return moments[1] / moments[0] | python | def relStdDev(self, limit=None):
"""return the relative standard deviation optionally limited to the last limit values"""
moments = self.meanAndStdDev(limit)
if moments is None:
return None
return moments[1] / moments[0] | [
"def",
"relStdDev",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"moments",
"=",
"self",
".",
"meanAndStdDev",
"(",
"limit",
")",
"if",
"moments",
"is",
"None",
":",
"return",
"None",
"return",
"moments",
"[",
"1",
"]",
"/",
"moments",
"[",
"0",... | return the relative standard deviation optionally limited to the last limit values | [
"return",
"the",
"relative",
"standard",
"deviation",
"optionally",
"limited",
"to",
"the",
"last",
"limit",
"values"
] | 8607b4f885f1d1798e43240be643efe6dccccdaa | https://github.com/TrafficSenseMSD/SumoTools/blob/8607b4f885f1d1798e43240be643efe6dccccdaa/sumolib/miscutils.py#L153-L158 |
238,075 | TrafficSenseMSD/SumoTools | sumolib/miscutils.py | Statistics.mean | def mean(self):
"""return the median value"""
# XXX rename this method
if len(self.values) > 0:
return sorted(self.values)[len(self.values) / 2]
else:
return None | python | def mean(self):
"""return the median value"""
# XXX rename this method
if len(self.values) > 0:
return sorted(self.values)[len(self.values) / 2]
else:
return None | [
"def",
"mean",
"(",
"self",
")",
":",
"# XXX rename this method",
"if",
"len",
"(",
"self",
".",
"values",
")",
">",
"0",
":",
"return",
"sorted",
"(",
"self",
".",
"values",
")",
"[",
"len",
"(",
"self",
".",
"values",
")",
"/",
"2",
"]",
"else",
... | return the median value | [
"return",
"the",
"median",
"value"
] | 8607b4f885f1d1798e43240be643efe6dccccdaa | https://github.com/TrafficSenseMSD/SumoTools/blob/8607b4f885f1d1798e43240be643efe6dccccdaa/sumolib/miscutils.py#L160-L166 |
238,076 | TrafficSenseMSD/SumoTools | sumolib/miscutils.py | Statistics.mean_abs | def mean_abs(self):
"""return the median of absolute values"""
# XXX rename this method
if len(self.values) > 0:
return sorted(map(abs, self.values))[len(self.values) / 2]
else:
return None | python | def mean_abs(self):
"""return the median of absolute values"""
# XXX rename this method
if len(self.values) > 0:
return sorted(map(abs, self.values))[len(self.values) / 2]
else:
return None | [
"def",
"mean_abs",
"(",
"self",
")",
":",
"# XXX rename this method",
"if",
"len",
"(",
"self",
".",
"values",
")",
">",
"0",
":",
"return",
"sorted",
"(",
"map",
"(",
"abs",
",",
"self",
".",
"values",
")",
")",
"[",
"len",
"(",
"self",
".",
"valu... | return the median of absolute values | [
"return",
"the",
"median",
"of",
"absolute",
"values"
] | 8607b4f885f1d1798e43240be643efe6dccccdaa | https://github.com/TrafficSenseMSD/SumoTools/blob/8607b4f885f1d1798e43240be643efe6dccccdaa/sumolib/miscutils.py#L168-L174 |
238,077 | egineering-llc/egat | egat/loggers/html_logger.py | HTMLWriter.copy_resources_to_log_dir | def copy_resources_to_log_dir(log_dir):
"""Copies the necessary static assets to the log_dir and returns the path
of the main css file."""
css_path = resource_filename(Requirement.parse("egat"), "/egat/data/default.css")
header_path = resource_filename(Requirement.parse("egat"), "/egat/... | python | def copy_resources_to_log_dir(log_dir):
"""Copies the necessary static assets to the log_dir and returns the path
of the main css file."""
css_path = resource_filename(Requirement.parse("egat"), "/egat/data/default.css")
header_path = resource_filename(Requirement.parse("egat"), "/egat/... | [
"def",
"copy_resources_to_log_dir",
"(",
"log_dir",
")",
":",
"css_path",
"=",
"resource_filename",
"(",
"Requirement",
".",
"parse",
"(",
"\"egat\"",
")",
",",
"\"/egat/data/default.css\"",
")",
"header_path",
"=",
"resource_filename",
"(",
"Requirement",
".",
"par... | Copies the necessary static assets to the log_dir and returns the path
of the main css file. | [
"Copies",
"the",
"necessary",
"static",
"assets",
"to",
"the",
"log_dir",
"and",
"returns",
"the",
"path",
"of",
"the",
"main",
"css",
"file",
"."
] | 63a172276b554ae1c7d0f13ba305881201c49d55 | https://github.com/egineering-llc/egat/blob/63a172276b554ae1c7d0f13ba305881201c49d55/egat/loggers/html_logger.py#L28-L36 |
238,078 | egineering-llc/egat | egat/loggers/html_logger.py | HTMLWriter.dump_queue | def dump_queue(queue):
"""
Empties all pending items in a queue and returns them in a list.
"""
result = []
try:
while True:
item = queue.get_nowait()
result.append(item)
except: Empty
return result | python | def dump_queue(queue):
"""
Empties all pending items in a queue and returns them in a list.
"""
result = []
try:
while True:
item = queue.get_nowait()
result.append(item)
except: Empty
return result | [
"def",
"dump_queue",
"(",
"queue",
")",
":",
"result",
"=",
"[",
"]",
"try",
":",
"while",
"True",
":",
"item",
"=",
"queue",
".",
"get_nowait",
"(",
")",
"result",
".",
"append",
"(",
"item",
")",
"except",
":",
"Empty",
"return",
"result"
] | Empties all pending items in a queue and returns them in a list. | [
"Empties",
"all",
"pending",
"items",
"in",
"a",
"queue",
"and",
"returns",
"them",
"in",
"a",
"list",
"."
] | 63a172276b554ae1c7d0f13ba305881201c49d55 | https://github.com/egineering-llc/egat/blob/63a172276b554ae1c7d0f13ba305881201c49d55/egat/loggers/html_logger.py#L267-L279 |
238,079 | jimzhan/pyx | rex/core/system.py | execute | def execute(command, cwd=os.path.curdir, **options):
"""
Run the system command with optional options.
Args:
* command: system command.
* cwd: current working directory.
* verbose: direct options for :func:`subprocess.Popen`.
Returns:
Opened process, standard output & e... | python | def execute(command, cwd=os.path.curdir, **options):
"""
Run the system command with optional options.
Args:
* command: system command.
* cwd: current working directory.
* verbose: direct options for :func:`subprocess.Popen`.
Returns:
Opened process, standard output & e... | [
"def",
"execute",
"(",
"command",
",",
"cwd",
"=",
"os",
".",
"path",
".",
"curdir",
",",
"*",
"*",
"options",
")",
":",
"process",
"=",
"subprocess",
".",
"Popen",
"(",
"shlex",
".",
"split",
"(",
"command",
")",
",",
"cwd",
"=",
"cwd",
",",
"*"... | Run the system command with optional options.
Args:
* command: system command.
* cwd: current working directory.
* verbose: direct options for :func:`subprocess.Popen`.
Returns:
Opened process, standard output & error. | [
"Run",
"the",
"system",
"command",
"with",
"optional",
"options",
"."
] | 819e8251323a7923e196c0c438aa8524f5aaee6e | https://github.com/jimzhan/pyx/blob/819e8251323a7923e196c0c438aa8524f5aaee6e/rex/core/system.py#L13-L27 |
238,080 | Nurdok/basicstruct | src/basicstruct.py | BasicStruct.to_dict | def to_dict(self, copy=False):
"""Convert the struct to a dictionary.
If `copy == True`, returns a deep copy of the values.
"""
new_dict = {}
for attr, value in self:
if copy:
value = deepcopy(value)
new_dict[attr] = value
return... | python | def to_dict(self, copy=False):
"""Convert the struct to a dictionary.
If `copy == True`, returns a deep copy of the values.
"""
new_dict = {}
for attr, value in self:
if copy:
value = deepcopy(value)
new_dict[attr] = value
return... | [
"def",
"to_dict",
"(",
"self",
",",
"copy",
"=",
"False",
")",
":",
"new_dict",
"=",
"{",
"}",
"for",
"attr",
",",
"value",
"in",
"self",
":",
"if",
"copy",
":",
"value",
"=",
"deepcopy",
"(",
"value",
")",
"new_dict",
"[",
"attr",
"]",
"=",
"val... | Convert the struct to a dictionary.
If `copy == True`, returns a deep copy of the values. | [
"Convert",
"the",
"struct",
"to",
"a",
"dictionary",
"."
] | 6f1104c06f3f0a1b63cf4ab620baceea5c4c8f55 | https://github.com/Nurdok/basicstruct/blob/6f1104c06f3f0a1b63cf4ab620baceea5c4c8f55/src/basicstruct.py#L42-L54 |
238,081 | bfrog/whizzer | whizzer/process.py | Process.start | def start(self):
"""Start the process, essentially forks and calls target function."""
logger.info("starting process")
process = os.fork()
time.sleep(0.01)
if process != 0:
logger.debug('starting child watcher')
self.loop.reset()
self.child_pi... | python | def start(self):
"""Start the process, essentially forks and calls target function."""
logger.info("starting process")
process = os.fork()
time.sleep(0.01)
if process != 0:
logger.debug('starting child watcher')
self.loop.reset()
self.child_pi... | [
"def",
"start",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"\"starting process\"",
")",
"process",
"=",
"os",
".",
"fork",
"(",
")",
"time",
".",
"sleep",
"(",
"0.01",
")",
"if",
"process",
"!=",
"0",
":",
"logger",
".",
"debug",
"(",
"'sta... | Start the process, essentially forks and calls target function. | [
"Start",
"the",
"process",
"essentially",
"forks",
"and",
"calls",
"target",
"function",
"."
] | a1e43084b3ac8c1f3fb4ada081777cdbf791fd77 | https://github.com/bfrog/whizzer/blob/a1e43084b3ac8c1f3fb4ada081777cdbf791fd77/whizzer/process.py#L45-L61 |
238,082 | baguette-io/baguette-messaging | farine/connectors/sql/__init__.py | setup | def setup(settings):
"""
Setup the database connection.
"""
connector = settings.get('db_connector')
if connector == 'postgres':
from playhouse.pool import PooledPostgresqlExtDatabase
return PooledPostgresqlExtDatabase(settings['db_name'],
user=settings['db... | python | def setup(settings):
"""
Setup the database connection.
"""
connector = settings.get('db_connector')
if connector == 'postgres':
from playhouse.pool import PooledPostgresqlExtDatabase
return PooledPostgresqlExtDatabase(settings['db_name'],
user=settings['db... | [
"def",
"setup",
"(",
"settings",
")",
":",
"connector",
"=",
"settings",
".",
"get",
"(",
"'db_connector'",
")",
"if",
"connector",
"==",
"'postgres'",
":",
"from",
"playhouse",
".",
"pool",
"import",
"PooledPostgresqlExtDatabase",
"return",
"PooledPostgresqlExtDa... | Setup the database connection. | [
"Setup",
"the",
"database",
"connection",
"."
] | 8d1c4707ea7eace8617fed2d97df2fcc9d0cdee1 | https://github.com/baguette-io/baguette-messaging/blob/8d1c4707ea7eace8617fed2d97df2fcc9d0cdee1/farine/connectors/sql/__init__.py#L31-L46 |
238,083 | baguette-io/baguette-messaging | farine/connectors/sql/__init__.py | init | def init(module, db):
"""
Initialize the models.
"""
for model in farine.discovery.import_models(module):
model._meta.database = db | python | def init(module, db):
"""
Initialize the models.
"""
for model in farine.discovery.import_models(module):
model._meta.database = db | [
"def",
"init",
"(",
"module",
",",
"db",
")",
":",
"for",
"model",
"in",
"farine",
".",
"discovery",
".",
"import_models",
"(",
"module",
")",
":",
"model",
".",
"_meta",
".",
"database",
"=",
"db"
] | Initialize the models. | [
"Initialize",
"the",
"models",
"."
] | 8d1c4707ea7eace8617fed2d97df2fcc9d0cdee1 | https://github.com/baguette-io/baguette-messaging/blob/8d1c4707ea7eace8617fed2d97df2fcc9d0cdee1/farine/connectors/sql/__init__.py#L48-L53 |
238,084 | baguette-io/baguette-messaging | farine/connectors/sql/__init__.py | Model.to_json | def to_json(self, extras=None):
"""
Convert a model into a json using the playhouse shortcut.
"""
extras = extras or {}
to_dict = model_to_dict(self)
to_dict.update(extras)
return json.dumps(to_dict, cls=sel.serializers.JsonEncoder) | python | def to_json(self, extras=None):
"""
Convert a model into a json using the playhouse shortcut.
"""
extras = extras or {}
to_dict = model_to_dict(self)
to_dict.update(extras)
return json.dumps(to_dict, cls=sel.serializers.JsonEncoder) | [
"def",
"to_json",
"(",
"self",
",",
"extras",
"=",
"None",
")",
":",
"extras",
"=",
"extras",
"or",
"{",
"}",
"to_dict",
"=",
"model_to_dict",
"(",
"self",
")",
"to_dict",
".",
"update",
"(",
"extras",
")",
"return",
"json",
".",
"dumps",
"(",
"to_di... | Convert a model into a json using the playhouse shortcut. | [
"Convert",
"a",
"model",
"into",
"a",
"json",
"using",
"the",
"playhouse",
"shortcut",
"."
] | 8d1c4707ea7eace8617fed2d97df2fcc9d0cdee1 | https://github.com/baguette-io/baguette-messaging/blob/8d1c4707ea7eace8617fed2d97df2fcc9d0cdee1/farine/connectors/sql/__init__.py#L19-L26 |
238,085 | bwesterb/sarah | src/lazy.py | lazy | def lazy(func):
""" Decorator, which can be used for lazy imports
@lazy
def yaml():
import yaml
return yaml """
try:
frame = sys._getframe(1)
except Exception:
_locals = None
else:
_locals = frame.f_locals
func_name = f... | python | def lazy(func):
""" Decorator, which can be used for lazy imports
@lazy
def yaml():
import yaml
return yaml """
try:
frame = sys._getframe(1)
except Exception:
_locals = None
else:
_locals = frame.f_locals
func_name = f... | [
"def",
"lazy",
"(",
"func",
")",
":",
"try",
":",
"frame",
"=",
"sys",
".",
"_getframe",
"(",
"1",
")",
"except",
"Exception",
":",
"_locals",
"=",
"None",
"else",
":",
"_locals",
"=",
"frame",
".",
"f_locals",
"func_name",
"=",
"func",
".",
"func_na... | Decorator, which can be used for lazy imports
@lazy
def yaml():
import yaml
return yaml | [
"Decorator",
"which",
"can",
"be",
"used",
"for",
"lazy",
"imports"
] | a9e46e875dfff1dc11255d714bb736e5eb697809 | https://github.com/bwesterb/sarah/blob/a9e46e875dfff1dc11255d714bb736e5eb697809/src/lazy.py#L8-L22 |
238,086 | JukeboxPipeline/jukebox-core | src/jukeboxcore/reftrack.py | ReftrackRoot.add_reftrack | def add_reftrack(self, reftrack):
"""Add a reftrack object to the root.
This will not handle row insertion in the model!
It is automatically done when setting the parent of the :class:`Reftrack` object.
:param reftrack: the reftrack object to add
:type reftrack: :class:`Reftrac... | python | def add_reftrack(self, reftrack):
"""Add a reftrack object to the root.
This will not handle row insertion in the model!
It is automatically done when setting the parent of the :class:`Reftrack` object.
:param reftrack: the reftrack object to add
:type reftrack: :class:`Reftrac... | [
"def",
"add_reftrack",
"(",
"self",
",",
"reftrack",
")",
":",
"self",
".",
"_reftracks",
".",
"add",
"(",
"reftrack",
")",
"refobj",
"=",
"reftrack",
".",
"get_refobj",
"(",
")",
"if",
"refobj",
":",
"self",
".",
"_parentsearchdict",
"[",
"refobj",
"]",... | Add a reftrack object to the root.
This will not handle row insertion in the model!
It is automatically done when setting the parent of the :class:`Reftrack` object.
:param reftrack: the reftrack object to add
:type reftrack: :class:`Reftrack`
:returns: None
:rtype: Non... | [
"Add",
"a",
"reftrack",
"object",
"to",
"the",
"root",
"."
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/reftrack.py#L293-L308 |
238,087 | JukeboxPipeline/jukebox-core | src/jukeboxcore/reftrack.py | ReftrackRoot.remove_reftrack | def remove_reftrack(self, reftrack):
"""Remove the reftrack from the root.
This will not handle row deletion in the model!
It is automatically done when calling :meth:`Reftrack.delete`.
:param reftrack: the reftrack object to remove
:type reftrack: :class:`Reftrack`
:re... | python | def remove_reftrack(self, reftrack):
"""Remove the reftrack from the root.
This will not handle row deletion in the model!
It is automatically done when calling :meth:`Reftrack.delete`.
:param reftrack: the reftrack object to remove
:type reftrack: :class:`Reftrack`
:re... | [
"def",
"remove_reftrack",
"(",
"self",
",",
"reftrack",
")",
":",
"self",
".",
"_reftracks",
".",
"remove",
"(",
"reftrack",
")",
"refobj",
"=",
"reftrack",
".",
"get_refobj",
"(",
")",
"if",
"refobj",
"and",
"refobj",
"in",
"self",
".",
"_parentsearchdict... | Remove the reftrack from the root.
This will not handle row deletion in the model!
It is automatically done when calling :meth:`Reftrack.delete`.
:param reftrack: the reftrack object to remove
:type reftrack: :class:`Reftrack`
:returns: None
:rtype: None
:raises... | [
"Remove",
"the",
"reftrack",
"from",
"the",
"root",
"."
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/reftrack.py#L310-L325 |
238,088 | JukeboxPipeline/jukebox-core | src/jukeboxcore/reftrack.py | ReftrackRoot.update_refobj | def update_refobj(self, old, new, reftrack):
"""Update the parent search dict so that the reftrack can be found
with the new refobj and delete the entry for the old refobj.
Old or new can also be None.
:param old: the old refobj of reftrack
:param new: the new refobj of reftrac... | python | def update_refobj(self, old, new, reftrack):
"""Update the parent search dict so that the reftrack can be found
with the new refobj and delete the entry for the old refobj.
Old or new can also be None.
:param old: the old refobj of reftrack
:param new: the new refobj of reftrac... | [
"def",
"update_refobj",
"(",
"self",
",",
"old",
",",
"new",
",",
"reftrack",
")",
":",
"if",
"old",
":",
"del",
"self",
".",
"_parentsearchdict",
"[",
"old",
"]",
"if",
"new",
":",
"self",
".",
"_parentsearchdict",
"[",
"new",
"]",
"=",
"reftrack"
] | Update the parent search dict so that the reftrack can be found
with the new refobj and delete the entry for the old refobj.
Old or new can also be None.
:param old: the old refobj of reftrack
:param new: the new refobj of reftrack
:param reftrack: The reftrack, which refobj wa... | [
"Update",
"the",
"parent",
"search",
"dict",
"so",
"that",
"the",
"reftrack",
"can",
"be",
"found",
"with",
"the",
"new",
"refobj",
"and",
"delete",
"the",
"entry",
"for",
"the",
"old",
"refobj",
"."
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/reftrack.py#L327-L344 |
238,089 | JukeboxPipeline/jukebox-core | src/jukeboxcore/reftrack.py | ReftrackRoot.get_scene_suggestions | def get_scene_suggestions(self, refobjinter):
"""Return a list of suggested Reftracks for the current scene, that are not already
in this root.
A suggestion is a combination of type and element.
:param refobjinter: a programm specific reftrack object interface
:type refobjinter... | python | def get_scene_suggestions(self, refobjinter):
"""Return a list of suggested Reftracks for the current scene, that are not already
in this root.
A suggestion is a combination of type and element.
:param refobjinter: a programm specific reftrack object interface
:type refobjinter... | [
"def",
"get_scene_suggestions",
"(",
"self",
",",
"refobjinter",
")",
":",
"sugs",
"=",
"[",
"]",
"cur",
"=",
"refobjinter",
".",
"get_current_element",
"(",
")",
"if",
"not",
"cur",
":",
"return",
"sugs",
"for",
"typ",
"in",
"refobjinter",
".",
"types",
... | Return a list of suggested Reftracks for the current scene, that are not already
in this root.
A suggestion is a combination of type and element.
:param refobjinter: a programm specific reftrack object interface
:type refobjinter: :class:`RefobjInterface`
:returns: A list of su... | [
"Return",
"a",
"list",
"of",
"suggested",
"Reftracks",
"for",
"the",
"current",
"scene",
"that",
"are",
"not",
"already",
"in",
"this",
"root",
"."
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/reftrack.py#L374-L399 |
238,090 | JukeboxPipeline/jukebox-core | src/jukeboxcore/reftrack.py | Reftrack.get_unwrapped | def get_unwrapped(self, root, refobjinter):
"""Return a set with all refobjects in the scene that are not in already
wrapped in root.
:param root: the root that groups all reftracks and makes it possible to search for parents
:type root: :class:`ReftrackRoot`
:param refobjinter:... | python | def get_unwrapped(self, root, refobjinter):
"""Return a set with all refobjects in the scene that are not in already
wrapped in root.
:param root: the root that groups all reftracks and makes it possible to search for parents
:type root: :class:`ReftrackRoot`
:param refobjinter:... | [
"def",
"get_unwrapped",
"(",
"self",
",",
"root",
",",
"refobjinter",
")",
":",
"all_refobjs",
"=",
"set",
"(",
"refobjinter",
".",
"get_all_refobjs",
"(",
")",
")",
"wrapped",
"=",
"set",
"(",
"root",
".",
"_parentsearchdict",
".",
"keys",
"(",
")",
")"... | Return a set with all refobjects in the scene that are not in already
wrapped in root.
:param root: the root that groups all reftracks and makes it possible to search for parents
:type root: :class:`ReftrackRoot`
:param refobjinter: a programm specific reftrack object interface
... | [
"Return",
"a",
"set",
"with",
"all",
"refobjects",
"in",
"the",
"scene",
"that",
"are",
"not",
"in",
"already",
"wrapped",
"in",
"root",
"."
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/reftrack.py#L592-L606 |
238,091 | JukeboxPipeline/jukebox-core | src/jukeboxcore/reftrack.py | Reftrack.set_refobj | def set_refobj(self, refobj, setParent=True):
"""Set the reftrack object.
The reftrack object interface will determine typ, element, taskfileinfo, status and parent and set these values.
If the reftrack object is None, the :class:`Reftrack` object will keep the initial typ,
element but ... | python | def set_refobj(self, refobj, setParent=True):
"""Set the reftrack object.
The reftrack object interface will determine typ, element, taskfileinfo, status and parent and set these values.
If the reftrack object is None, the :class:`Reftrack` object will keep the initial typ,
element but ... | [
"def",
"set_refobj",
"(",
"self",
",",
"refobj",
",",
"setParent",
"=",
"True",
")",
":",
"root",
"=",
"self",
".",
"get_root",
"(",
")",
"old",
"=",
"self",
".",
"_refobj",
"self",
".",
"_refobj",
"=",
"refobj",
"refobjinter",
"=",
"self",
".",
"get... | Set the reftrack object.
The reftrack object interface will determine typ, element, taskfileinfo, status and parent and set these values.
If the reftrack object is None, the :class:`Reftrack` object will keep the initial typ,
element but will loose it\'s parent, status and taskfileinfo
... | [
"Set",
"the",
"reftrack",
"object",
"."
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/reftrack.py#L627-L661 |
238,092 | JukeboxPipeline/jukebox-core | src/jukeboxcore/reftrack.py | Reftrack.set_typ | def set_typ(self, typ):
"""Set the type of the entity
Make sure the type is registered in the :class:`RefobjInterface`.
:param typ: the type of the entity
:type typ: str
:returns: None
:rtype: None
:raises: ValueError
"""
if typ not in self._refo... | python | def set_typ(self, typ):
"""Set the type of the entity
Make sure the type is registered in the :class:`RefobjInterface`.
:param typ: the type of the entity
:type typ: str
:returns: None
:rtype: None
:raises: ValueError
"""
if typ not in self._refo... | [
"def",
"set_typ",
"(",
"self",
",",
"typ",
")",
":",
"if",
"typ",
"not",
"in",
"self",
".",
"_refobjinter",
".",
"types",
":",
"raise",
"ValueError",
"(",
"\"The given typ is not supported by RefobjInterface. Given %s, supported: %s\"",
"%",
"(",
"typ",
",",
"self... | Set the type of the entity
Make sure the type is registered in the :class:`RefobjInterface`.
:param typ: the type of the entity
:type typ: str
:returns: None
:rtype: None
:raises: ValueError | [
"Set",
"the",
"type",
"of",
"the",
"entity"
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/reftrack.py#L675-L690 |
238,093 | JukeboxPipeline/jukebox-core | src/jukeboxcore/reftrack.py | Reftrack.set_parent | def set_parent(self, parent):
"""Set the parent reftrack object
If a parent gets deleted, the children will be deleted too.
.. Note:: Once the parent is set, it cannot be set again!
:param parent: the parent reftrack object
:type parent: :class:`Reftrack` | None
:retur... | python | def set_parent(self, parent):
"""Set the parent reftrack object
If a parent gets deleted, the children will be deleted too.
.. Note:: Once the parent is set, it cannot be set again!
:param parent: the parent reftrack object
:type parent: :class:`Reftrack` | None
:retur... | [
"def",
"set_parent",
"(",
"self",
",",
"parent",
")",
":",
"assert",
"self",
".",
"_parent",
"is",
"None",
"or",
"self",
".",
"_parent",
"is",
"parent",
",",
"\"Cannot change the parent. Can only set from None.\"",
"if",
"parent",
"and",
"self",
".",
"_parent",
... | Set the parent reftrack object
If a parent gets deleted, the children will be deleted too.
.. Note:: Once the parent is set, it cannot be set again!
:param parent: the parent reftrack object
:type parent: :class:`Reftrack` | None
:returns: None
:rtype: None
:ra... | [
"Set",
"the",
"parent",
"reftrack",
"object"
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/reftrack.py#L782-L814 |
238,094 | JukeboxPipeline/jukebox-core | src/jukeboxcore/reftrack.py | Reftrack.set_id | def set_id(self, identifier):
"""Set the id of the given reftrack
This will set the id on the refobject
:param identifier: the identifier number
:type identifier: int
:returns: None
:rtype: None
:raises: None
"""
self._id = identifier
ref... | python | def set_id(self, identifier):
"""Set the id of the given reftrack
This will set the id on the refobject
:param identifier: the identifier number
:type identifier: int
:returns: None
:rtype: None
:raises: None
"""
self._id = identifier
ref... | [
"def",
"set_id",
"(",
"self",
",",
"identifier",
")",
":",
"self",
".",
"_id",
"=",
"identifier",
"refobj",
"=",
"self",
".",
"get_refobj",
"(",
")",
"if",
"refobj",
":",
"self",
".",
"get_refobjinter",
"(",
")",
".",
"set_id",
"(",
"refobj",
",",
"i... | Set the id of the given reftrack
This will set the id on the refobject
:param identifier: the identifier number
:type identifier: int
:returns: None
:rtype: None
:raises: None | [
"Set",
"the",
"id",
"of",
"the",
"given",
"reftrack"
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/reftrack.py#L829-L843 |
238,095 | JukeboxPipeline/jukebox-core | src/jukeboxcore/reftrack.py | Reftrack.fetch_new_id | def fetch_new_id(self, ):
"""Return a new id for the given reftrack to be set on the refobject
The id can identify reftracks that share the same parent, type and element.
:returns: A new id
:rtype: int
:raises: None
"""
parent = self.get_parent()
if pare... | python | def fetch_new_id(self, ):
"""Return a new id for the given reftrack to be set on the refobject
The id can identify reftracks that share the same parent, type and element.
:returns: A new id
:rtype: int
:raises: None
"""
parent = self.get_parent()
if pare... | [
"def",
"fetch_new_id",
"(",
"self",
",",
")",
":",
"parent",
"=",
"self",
".",
"get_parent",
"(",
")",
"if",
"parent",
":",
"others",
"=",
"parent",
".",
"_children",
"else",
":",
"others",
"=",
"[",
"r",
"for",
"r",
"in",
"self",
".",
"get_root",
... | Return a new id for the given reftrack to be set on the refobject
The id can identify reftracks that share the same parent, type and element.
:returns: A new id
:rtype: int
:raises: None | [
"Return",
"a",
"new",
"id",
"for",
"the",
"given",
"reftrack",
"to",
"be",
"set",
"on",
"the",
"refobject"
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/reftrack.py#L845-L868 |
238,096 | JukeboxPipeline/jukebox-core | src/jukeboxcore/reftrack.py | Reftrack.create_treeitem | def create_treeitem(self, ):
"""Create a new treeitem for this reftrack instance.
.. Note:: Parent should be set, Parent should already have a treeitem.
If there is no parent, the root tree item is used as parent for the treeitem.
:returns: a new treeitem that contains a item... | python | def create_treeitem(self, ):
"""Create a new treeitem for this reftrack instance.
.. Note:: Parent should be set, Parent should already have a treeitem.
If there is no parent, the root tree item is used as parent for the treeitem.
:returns: a new treeitem that contains a item... | [
"def",
"create_treeitem",
"(",
"self",
",",
")",
":",
"p",
"=",
"self",
".",
"get_parent",
"(",
")",
"root",
"=",
"self",
".",
"get_root",
"(",
")",
"if",
"p",
":",
"pitem",
"=",
"p",
".",
"get_treeitem",
"(",
")",
"else",
":",
"pitem",
"=",
"roo... | Create a new treeitem for this reftrack instance.
.. Note:: Parent should be set, Parent should already have a treeitem.
If there is no parent, the root tree item is used as parent for the treeitem.
:returns: a new treeitem that contains a itemdata with the reftrack instanec.
... | [
"Create",
"a",
"new",
"treeitem",
"for",
"this",
"reftrack",
"instance",
"."
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/reftrack.py#L870-L888 |
238,097 | JukeboxPipeline/jukebox-core | src/jukeboxcore/reftrack.py | Reftrack.fetch_options | def fetch_options(self, ):
"""Set and return the options for possible files to
load, replace etc. The stored element will determine the options.
The refobjinterface and typinterface are responsible for providing the options
:returns: the options
:rtype: :class:`jukeboxcore.gui.... | python | def fetch_options(self, ):
"""Set and return the options for possible files to
load, replace etc. The stored element will determine the options.
The refobjinterface and typinterface are responsible for providing the options
:returns: the options
:rtype: :class:`jukeboxcore.gui.... | [
"def",
"fetch_options",
"(",
"self",
",",
")",
":",
"self",
".",
"_options",
",",
"self",
".",
"_taskfileinfo_options",
"=",
"self",
".",
"get_refobjinter",
"(",
")",
".",
"fetch_options",
"(",
"self",
".",
"get_typ",
"(",
")",
",",
"self",
".",
"get_ele... | Set and return the options for possible files to
load, replace etc. The stored element will determine the options.
The refobjinterface and typinterface are responsible for providing the options
:returns: the options
:rtype: :class:`jukeboxcore.gui.treemodel.TreeModel`
:raises: ... | [
"Set",
"and",
"return",
"the",
"options",
"for",
"possible",
"files",
"to",
"load",
"replace",
"etc",
".",
"The",
"stored",
"element",
"will",
"determine",
"the",
"options",
"."
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/reftrack.py#L946-L957 |
238,098 | JukeboxPipeline/jukebox-core | src/jukeboxcore/reftrack.py | Reftrack.fetch_uptodate | def fetch_uptodate(self, ):
"""Set and return whether the currently loaded entity is
the newest version in the department.
:returns: True, if newest version. False, if there is a newer version.
None, if there is nothing loaded yet.
:rtype: bool | None
:raises: ... | python | def fetch_uptodate(self, ):
"""Set and return whether the currently loaded entity is
the newest version in the department.
:returns: True, if newest version. False, if there is a newer version.
None, if there is nothing loaded yet.
:rtype: bool | None
:raises: ... | [
"def",
"fetch_uptodate",
"(",
"self",
",",
")",
":",
"tfi",
"=",
"self",
".",
"get_taskfileinfo",
"(",
")",
"if",
"tfi",
":",
"self",
".",
"_uptodate",
"=",
"tfi",
".",
"is_latest",
"(",
")",
"else",
":",
"self",
".",
"_uptodate",
"=",
"None",
"retur... | Set and return whether the currently loaded entity is
the newest version in the department.
:returns: True, if newest version. False, if there is a newer version.
None, if there is nothing loaded yet.
:rtype: bool | None
:raises: None | [
"Set",
"and",
"return",
"whether",
"the",
"currently",
"loaded",
"entity",
"is",
"the",
"newest",
"version",
"in",
"the",
"department",
"."
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/reftrack.py#L1008-L1022 |
238,099 | JukeboxPipeline/jukebox-core | src/jukeboxcore/reftrack.py | Reftrack.fetch_alien | def fetch_alien(self, ):
"""Set and return, if the reftrack element is linked to the current scene.
Askes the refobj interface for the current scene.
If there is no current scene then True is returned.
:returns: whether the element is linked to the current scene
:rtype: bool
... | python | def fetch_alien(self, ):
"""Set and return, if the reftrack element is linked to the current scene.
Askes the refobj interface for the current scene.
If there is no current scene then True is returned.
:returns: whether the element is linked to the current scene
:rtype: bool
... | [
"def",
"fetch_alien",
"(",
"self",
",",
")",
":",
"parent",
"=",
"self",
".",
"get_parent",
"(",
")",
"if",
"parent",
":",
"parentelement",
"=",
"parent",
".",
"get_element",
"(",
")",
"else",
":",
"parentelement",
"=",
"self",
".",
"get_refobjinter",
"(... | Set and return, if the reftrack element is linked to the current scene.
Askes the refobj interface for the current scene.
If there is no current scene then True is returned.
:returns: whether the element is linked to the current scene
:rtype: bool
:raises: None | [
"Set",
"and",
"return",
"if",
"the",
"reftrack",
"element",
"is",
"linked",
"to",
"the",
"current",
"scene",
"."
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/reftrack.py#L1033-L1066 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.