repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
HumanCellAtlas/dcp-cli | hca/upload/lib/api_client.py | ApiClient.validation_statuses | def validation_statuses(self, area_uuid):
"""
Get count of validation statuses for all files in upload_area
:param str area_uuid: A RFC4122-compliant ID for the upload area
:return: a dict with key for each state and value being the count of files in that state
:rtype: dict
... | python | def validation_statuses(self, area_uuid):
"""
Get count of validation statuses for all files in upload_area
:param str area_uuid: A RFC4122-compliant ID for the upload area
:return: a dict with key for each state and value being the count of files in that state
:rtype: dict
... | [
"def",
"validation_statuses",
"(",
"self",
",",
"area_uuid",
")",
":",
"path",
"=",
"\"/area/{uuid}/validations\"",
".",
"format",
"(",
"uuid",
"=",
"area_uuid",
")",
"result",
"=",
"self",
".",
"_make_request",
"(",
"'get'",
",",
"path",
")",
"return",
"res... | Get count of validation statuses for all files in upload_area
:param str area_uuid: A RFC4122-compliant ID for the upload area
:return: a dict with key for each state and value being the count of files in that state
:rtype: dict
:raises UploadApiException: if information could not be ob... | [
"Get",
"count",
"of",
"validation",
"statuses",
"for",
"all",
"files",
"in",
"upload_area"
] | cc70817bc4e50944c709eaae160de0bf7a19f0f3 | https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/upload/lib/api_client.py#L214-L225 | train |
yoeo/guesslang | guesslang/guesser.py | Guess.language_name | def language_name(self, text: str) -> str:
"""Predict the programming language name of the given source code.
:param text: source code.
:return: language name
"""
values = extract(text)
input_fn = _to_func(([values], []))
pos: int = next(self._classifier.predict_... | python | def language_name(self, text: str) -> str:
"""Predict the programming language name of the given source code.
:param text: source code.
:return: language name
"""
values = extract(text)
input_fn = _to_func(([values], []))
pos: int = next(self._classifier.predict_... | [
"def",
"language_name",
"(",
"self",
",",
"text",
":",
"str",
")",
"->",
"str",
":",
"values",
"=",
"extract",
"(",
"text",
")",
"input_fn",
"=",
"_to_func",
"(",
"(",
"[",
"values",
"]",
",",
"[",
"]",
")",
")",
"pos",
":",
"int",
"=",
"next",
... | Predict the programming language name of the given source code.
:param text: source code.
:return: language name | [
"Predict",
"the",
"programming",
"language",
"name",
"of",
"the",
"given",
"source",
"code",
"."
] | 03e33b77c73238c0fe4600147e8c926515a2887f | https://github.com/yoeo/guesslang/blob/03e33b77c73238c0fe4600147e8c926515a2887f/guesslang/guesser.py#L61-L72 | train |
yoeo/guesslang | guesslang/guesser.py | Guess.scores | def scores(self, text: str) -> Dict[str, float]:
"""A score for each language corresponding to the probability that
the text is written in the given language.
The score is a `float` value between 0.0 and 1.0
:param text: source code.
:return: language to score dictionary
... | python | def scores(self, text: str) -> Dict[str, float]:
"""A score for each language corresponding to the probability that
the text is written in the given language.
The score is a `float` value between 0.0 and 1.0
:param text: source code.
:return: language to score dictionary
... | [
"def",
"scores",
"(",
"self",
",",
"text",
":",
"str",
")",
"->",
"Dict",
"[",
"str",
",",
"float",
"]",
":",
"values",
"=",
"extract",
"(",
"text",
")",
"input_fn",
"=",
"_to_func",
"(",
"(",
"[",
"values",
"]",
",",
"[",
"]",
")",
")",
"predi... | A score for each language corresponding to the probability that
the text is written in the given language.
The score is a `float` value between 0.0 and 1.0
:param text: source code.
:return: language to score dictionary | [
"A",
"score",
"for",
"each",
"language",
"corresponding",
"to",
"the",
"probability",
"that",
"the",
"text",
"is",
"written",
"in",
"the",
"given",
"language",
".",
"The",
"score",
"is",
"a",
"float",
"value",
"between",
"0",
".",
"0",
"and",
"1",
".",
... | 03e33b77c73238c0fe4600147e8c926515a2887f | https://github.com/yoeo/guesslang/blob/03e33b77c73238c0fe4600147e8c926515a2887f/guesslang/guesser.py#L74-L87 | train |
yoeo/guesslang | guesslang/guesser.py | Guess.probable_languages | def probable_languages(
self,
text: str,
max_languages: int = 3) -> Tuple[str, ...]:
"""List of most probable programming languages,
the list is ordered from the most probable to the least probable one.
:param text: source code.
:param max_languages: ... | python | def probable_languages(
self,
text: str,
max_languages: int = 3) -> Tuple[str, ...]:
"""List of most probable programming languages,
the list is ordered from the most probable to the least probable one.
:param text: source code.
:param max_languages: ... | [
"def",
"probable_languages",
"(",
"self",
",",
"text",
":",
"str",
",",
"max_languages",
":",
"int",
"=",
"3",
")",
"->",
"Tuple",
"[",
"str",
",",
"...",
"]",
":",
"scores",
"=",
"self",
".",
"scores",
"(",
"text",
")",
"sorted_scores",
"=",
"sorted... | List of most probable programming languages,
the list is ordered from the most probable to the least probable one.
:param text: source code.
:param max_languages: maximum number of listed languages.
:return: languages list | [
"List",
"of",
"most",
"probable",
"programming",
"languages",
"the",
"list",
"is",
"ordered",
"from",
"the",
"most",
"probable",
"to",
"the",
"least",
"probable",
"one",
"."
] | 03e33b77c73238c0fe4600147e8c926515a2887f | https://github.com/yoeo/guesslang/blob/03e33b77c73238c0fe4600147e8c926515a2887f/guesslang/guesser.py#L89-L116 | train |
yoeo/guesslang | guesslang/guesser.py | Guess.learn | def learn(self, input_dir: str) -> float:
"""Learn languages features from source files.
:raise GuesslangError: when the default model is used for learning
:param input_dir: source code files directory.
:return: learning accuracy
"""
if self.is_default:
LOGGE... | python | def learn(self, input_dir: str) -> float:
"""Learn languages features from source files.
:raise GuesslangError: when the default model is used for learning
:param input_dir: source code files directory.
:return: learning accuracy
"""
if self.is_default:
LOGGE... | [
"def",
"learn",
"(",
"self",
",",
"input_dir",
":",
"str",
")",
"->",
"float",
":",
"if",
"self",
".",
"is_default",
":",
"LOGGER",
".",
"error",
"(",
"\"Cannot learn using default model\"",
")",
"raise",
"GuesslangError",
"(",
"'Cannot learn using default \"reado... | Learn languages features from source files.
:raise GuesslangError: when the default model is used for learning
:param input_dir: source code files directory.
:return: learning accuracy | [
"Learn",
"languages",
"features",
"from",
"source",
"files",
"."
] | 03e33b77c73238c0fe4600147e8c926515a2887f | https://github.com/yoeo/guesslang/blob/03e33b77c73238c0fe4600147e8c926515a2887f/guesslang/guesser.py#L118-L164 | train |
yoeo/guesslang | tools/report_graph.py | main | def main():
"""Report graph creator command line"""
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
'reportfile', type=argparse.FileType('r'),
help="test report file generated by `guesslang --test TESTDIR`")
parser.add_argument(
'-d', '--debug', defaul... | python | def main():
"""Report graph creator command line"""
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
'reportfile', type=argparse.FileType('r'),
help="test report file generated by `guesslang --test TESTDIR`")
parser.add_argument(
'-d', '--debug', defaul... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"__doc__",
")",
"parser",
".",
"add_argument",
"(",
"'reportfile'",
",",
"type",
"=",
"argparse",
".",
"FileType",
"(",
"'r'",
")",
",",
"help",
"=",... | Report graph creator command line | [
"Report",
"graph",
"creator",
"command",
"line"
] | 03e33b77c73238c0fe4600147e8c926515a2887f | https://github.com/yoeo/guesslang/blob/03e33b77c73238c0fe4600147e8c926515a2887f/tools/report_graph.py#L25-L42 | train |
yoeo/guesslang | guesslang/utils.py | search_files | def search_files(source: str, extensions: List[str]) -> List[Path]:
"""Retrieve files located the source directory and its subdirectories,
whose extension match one of the listed extensions.
:raise GuesslangError: when there is not enough files in the directory
:param source: directory name
:param ... | python | def search_files(source: str, extensions: List[str]) -> List[Path]:
"""Retrieve files located the source directory and its subdirectories,
whose extension match one of the listed extensions.
:raise GuesslangError: when there is not enough files in the directory
:param source: directory name
:param ... | [
"def",
"search_files",
"(",
"source",
":",
"str",
",",
"extensions",
":",
"List",
"[",
"str",
"]",
")",
"->",
"List",
"[",
"Path",
"]",
":",
"files",
"=",
"[",
"path",
"for",
"path",
"in",
"Path",
"(",
"source",
")",
".",
"glob",
"(",
"'**/*'",
"... | Retrieve files located the source directory and its subdirectories,
whose extension match one of the listed extensions.
:raise GuesslangError: when there is not enough files in the directory
:param source: directory name
:param extensions: list of file extensions
:return: filenames | [
"Retrieve",
"files",
"located",
"the",
"source",
"directory",
"and",
"its",
"subdirectories",
"whose",
"extension",
"match",
"one",
"of",
"the",
"listed",
"extensions",
"."
] | 03e33b77c73238c0fe4600147e8c926515a2887f | https://github.com/yoeo/guesslang/blob/03e33b77c73238c0fe4600147e8c926515a2887f/guesslang/utils.py#L30-L52 | train |
yoeo/guesslang | guesslang/utils.py | extract_from_files | def extract_from_files(
files: List[Path],
languages: Dict[str, List[str]]) -> DataSet:
"""Extract arrays of features from the given files.
:param files: list of paths
:param languages: language name =>
associated file extension list
:return: features
"""
enumerator = en... | python | def extract_from_files(
files: List[Path],
languages: Dict[str, List[str]]) -> DataSet:
"""Extract arrays of features from the given files.
:param files: list of paths
:param languages: language name =>
associated file extension list
:return: features
"""
enumerator = en... | [
"def",
"extract_from_files",
"(",
"files",
":",
"List",
"[",
"Path",
"]",
",",
"languages",
":",
"Dict",
"[",
"str",
",",
"List",
"[",
"str",
"]",
"]",
")",
"->",
"DataSet",
":",
"enumerator",
"=",
"enumerate",
"(",
"sorted",
"(",
"languages",
".",
"... | Extract arrays of features from the given files.
:param files: list of paths
:param languages: language name =>
associated file extension list
:return: features | [
"Extract",
"arrays",
"of",
"features",
"from",
"the",
"given",
"files",
"."
] | 03e33b77c73238c0fe4600147e8c926515a2887f | https://github.com/yoeo/guesslang/blob/03e33b77c73238c0fe4600147e8c926515a2887f/guesslang/utils.py#L55-L73 | train |
yoeo/guesslang | guesslang/utils.py | safe_read_file | def safe_read_file(file_path: Path) -> str:
"""Read a text file. Several text encodings are tried until
the file content is correctly decoded.
:raise GuesslangError: when the file encoding is not supported
:param file_path: path to the input file
:return: text file content
"""
for encoding ... | python | def safe_read_file(file_path: Path) -> str:
"""Read a text file. Several text encodings are tried until
the file content is correctly decoded.
:raise GuesslangError: when the file encoding is not supported
:param file_path: path to the input file
:return: text file content
"""
for encoding ... | [
"def",
"safe_read_file",
"(",
"file_path",
":",
"Path",
")",
"->",
"str",
":",
"for",
"encoding",
"in",
"FILE_ENCODINGS",
":",
"try",
":",
"return",
"file_path",
".",
"read_text",
"(",
"encoding",
"=",
"encoding",
")",
"except",
"UnicodeError",
":",
"pass",
... | Read a text file. Several text encodings are tried until
the file content is correctly decoded.
:raise GuesslangError: when the file encoding is not supported
:param file_path: path to the input file
:return: text file content | [
"Read",
"a",
"text",
"file",
".",
"Several",
"text",
"encodings",
"are",
"tried",
"until",
"the",
"file",
"content",
"is",
"correctly",
"decoded",
"."
] | 03e33b77c73238c0fe4600147e8c926515a2887f | https://github.com/yoeo/guesslang/blob/03e33b77c73238c0fe4600147e8c926515a2887f/guesslang/utils.py#L106-L120 | train |
yoeo/guesslang | guesslang/config.py | config_logging | def config_logging(debug: bool = False) -> None:
"""Set-up application and `tensorflow` logging.
:param debug: show or hide debug messages
"""
if debug:
level = 'DEBUG'
tf_level = tf.logging.INFO
else:
level = 'INFO'
tf_level = tf.logging.ERROR
logging_config = ... | python | def config_logging(debug: bool = False) -> None:
"""Set-up application and `tensorflow` logging.
:param debug: show or hide debug messages
"""
if debug:
level = 'DEBUG'
tf_level = tf.logging.INFO
else:
level = 'INFO'
tf_level = tf.logging.ERROR
logging_config = ... | [
"def",
"config_logging",
"(",
"debug",
":",
"bool",
"=",
"False",
")",
"->",
"None",
":",
"if",
"debug",
":",
"level",
"=",
"'DEBUG'",
"tf_level",
"=",
"tf",
".",
"logging",
".",
"INFO",
"else",
":",
"level",
"=",
"'INFO'",
"tf_level",
"=",
"tf",
"."... | Set-up application and `tensorflow` logging.
:param debug: show or hide debug messages | [
"Set",
"-",
"up",
"application",
"and",
"tensorflow",
"logging",
"."
] | 03e33b77c73238c0fe4600147e8c926515a2887f | https://github.com/yoeo/guesslang/blob/03e33b77c73238c0fe4600147e8c926515a2887f/guesslang/config.py#L53-L70 | train |
yoeo/guesslang | guesslang/config.py | config_dict | def config_dict(name: str) -> Dict[str, Any]:
"""Load a JSON configuration dict from Guesslang config directory.
:param name: the JSON file name.
:return: configuration
"""
try:
content = resource_string(PACKAGE, DATADIR.format(name)).decode()
except DistributionNotFound as error:
... | python | def config_dict(name: str) -> Dict[str, Any]:
"""Load a JSON configuration dict from Guesslang config directory.
:param name: the JSON file name.
:return: configuration
"""
try:
content = resource_string(PACKAGE, DATADIR.format(name)).decode()
except DistributionNotFound as error:
... | [
"def",
"config_dict",
"(",
"name",
":",
"str",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"try",
":",
"content",
"=",
"resource_string",
"(",
"PACKAGE",
",",
"DATADIR",
".",
"format",
"(",
"name",
")",
")",
".",
"decode",
"(",
")",
"excep... | Load a JSON configuration dict from Guesslang config directory.
:param name: the JSON file name.
:return: configuration | [
"Load",
"a",
"JSON",
"configuration",
"dict",
"from",
"Guesslang",
"config",
"directory",
"."
] | 03e33b77c73238c0fe4600147e8c926515a2887f | https://github.com/yoeo/guesslang/blob/03e33b77c73238c0fe4600147e8c926515a2887f/guesslang/config.py#L73-L85 | train |
yoeo/guesslang | guesslang/config.py | model_info | def model_info(model_dir: Optional[str] = None) -> Tuple[str, bool]:
"""Retrieve Guesslang model directory name,
and tells if it is the default model.
:param model_dir: model location, if `None` default model is selected
:return: selected model directory with an indication
that the model is the... | python | def model_info(model_dir: Optional[str] = None) -> Tuple[str, bool]:
"""Retrieve Guesslang model directory name,
and tells if it is the default model.
:param model_dir: model location, if `None` default model is selected
:return: selected model directory with an indication
that the model is the... | [
"def",
"model_info",
"(",
"model_dir",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"Tuple",
"[",
"str",
",",
"bool",
"]",
":",
"if",
"model_dir",
"is",
"None",
":",
"try",
":",
"model_dir",
"=",
"resource_filename",
"(",
"PACKAGE",
",",
... | Retrieve Guesslang model directory name,
and tells if it is the default model.
:param model_dir: model location, if `None` default model is selected
:return: selected model directory with an indication
that the model is the default or not | [
"Retrieve",
"Guesslang",
"model",
"directory",
"name",
"and",
"tells",
"if",
"it",
"is",
"the",
"default",
"model",
"."
] | 03e33b77c73238c0fe4600147e8c926515a2887f | https://github.com/yoeo/guesslang/blob/03e33b77c73238c0fe4600147e8c926515a2887f/guesslang/config.py#L88-L110 | train |
yoeo/guesslang | guesslang/config.py | ColorLogFormatter.format | def format(self, record: logging.LogRecord) -> str:
"""Format log records to produce colored messages.
:param record: log record
:return: log message
"""
if platform.system() != 'Linux': # Avoid funny logs on Windows & MacOS
return super().format(record)
re... | python | def format(self, record: logging.LogRecord) -> str:
"""Format log records to produce colored messages.
:param record: log record
:return: log message
"""
if platform.system() != 'Linux': # Avoid funny logs on Windows & MacOS
return super().format(record)
re... | [
"def",
"format",
"(",
"self",
",",
"record",
":",
"logging",
".",
"LogRecord",
")",
"->",
"str",
":",
"if",
"platform",
".",
"system",
"(",
")",
"!=",
"'Linux'",
":",
"return",
"super",
"(",
")",
".",
"format",
"(",
"record",
")",
"record",
".",
"m... | Format log records to produce colored messages.
:param record: log record
:return: log message | [
"Format",
"log",
"records",
"to",
"produce",
"colored",
"messages",
"."
] | 03e33b77c73238c0fe4600147e8c926515a2887f | https://github.com/yoeo/guesslang/blob/03e33b77c73238c0fe4600147e8c926515a2887f/guesslang/config.py#L37-L50 | train |
yoeo/guesslang | tools/download_github_repo.py | main | def main():
"""Github repositories downloaded command line"""
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
'githubtoken',
help="Github OAuth token, see https://developer.github.com/v3/oauth/")
parser.add_argument('destination', help="location of the downloa... | python | def main():
"""Github repositories downloaded command line"""
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
'githubtoken',
help="Github OAuth token, see https://developer.github.com/v3/oauth/")
parser.add_argument('destination', help="location of the downloa... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"__doc__",
")",
"parser",
".",
"add_argument",
"(",
"'githubtoken'",
",",
"help",
"=",
"\"Github OAuth token, see https://developer.github.com/v3/oauth/\"",
")",
... | Github repositories downloaded command line | [
"Github",
"repositories",
"downloaded",
"command",
"line"
] | 03e33b77c73238c0fe4600147e8c926515a2887f | https://github.com/yoeo/guesslang/blob/03e33b77c73238c0fe4600147e8c926515a2887f/tools/download_github_repo.py#L54-L87 | train |
yoeo/guesslang | tools/download_github_repo.py | retry | def retry(default=None):
"""Retry functions after failures"""
def decorator(func):
"""Retry decorator"""
@functools.wraps(func)
def _wrapper(*args, **kw):
for pos in range(1, MAX_RETRIES):
try:
return func(*args, **kw)
exc... | python | def retry(default=None):
"""Retry functions after failures"""
def decorator(func):
"""Retry decorator"""
@functools.wraps(func)
def _wrapper(*args, **kw):
for pos in range(1, MAX_RETRIES):
try:
return func(*args, **kw)
exc... | [
"def",
"retry",
"(",
"default",
"=",
"None",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"_wrapper",
"(",
"*",
"args",
",",
"**",
"kw",
")",
":",
"for",
"pos",
"in",
"range",
"(",
... | Retry functions after failures | [
"Retry",
"functions",
"after",
"failures"
] | 03e33b77c73238c0fe4600147e8c926515a2887f | https://github.com/yoeo/guesslang/blob/03e33b77c73238c0fe4600147e8c926515a2887f/tools/download_github_repo.py#L117-L140 | train |
yoeo/guesslang | tools/make_keywords.py | main | def main():
"""Keywords generator command line"""
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('learn', help="learning source codes directory")
parser.add_argument('keywords', help="output keywords file, JSON")
parser.add_argument(
'-n', '--nbkeywords', type=int... | python | def main():
"""Keywords generator command line"""
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('learn', help="learning source codes directory")
parser.add_argument('keywords', help="output keywords file, JSON")
parser.add_argument(
'-n', '--nbkeywords', type=int... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"__doc__",
")",
"parser",
".",
"add_argument",
"(",
"'learn'",
",",
"help",
"=",
"\"learning source codes directory\"",
")",
"parser",
".",
"add_argument",
... | Keywords generator command line | [
"Keywords",
"generator",
"command",
"line"
] | 03e33b77c73238c0fe4600147e8c926515a2887f | https://github.com/yoeo/guesslang/blob/03e33b77c73238c0fe4600147e8c926515a2887f/tools/make_keywords.py#L29-L87 | train |
yoeo/guesslang | guesslang/__main__.py | main | def main() -> None:
"""Run command line"""
try:
_real_main()
except GuesslangError as error:
LOGGER.critical("Failed: %s", error)
sys.exit(-1)
except KeyboardInterrupt:
LOGGER.critical("Cancelled!")
sys.exit(-2) | python | def main() -> None:
"""Run command line"""
try:
_real_main()
except GuesslangError as error:
LOGGER.critical("Failed: %s", error)
sys.exit(-1)
except KeyboardInterrupt:
LOGGER.critical("Cancelled!")
sys.exit(-2) | [
"def",
"main",
"(",
")",
"->",
"None",
":",
"try",
":",
"_real_main",
"(",
")",
"except",
"GuesslangError",
"as",
"error",
":",
"LOGGER",
".",
"critical",
"(",
"\"Failed: %s\"",
",",
"error",
")",
"sys",
".",
"exit",
"(",
"-",
"1",
")",
"except",
"Ke... | Run command line | [
"Run",
"command",
"line"
] | 03e33b77c73238c0fe4600147e8c926515a2887f | https://github.com/yoeo/guesslang/blob/03e33b77c73238c0fe4600147e8c926515a2887f/guesslang/__main__.py#L19-L28 | train |
yoeo/guesslang | guesslang/extractor.py | split | def split(text: str) -> List[str]:
"""Split a text into a list of tokens.
:param text: the text to split
:return: tokens
"""
return [word for word in SEPARATOR.split(text) if word.strip(' \t')] | python | def split(text: str) -> List[str]:
"""Split a text into a list of tokens.
:param text: the text to split
:return: tokens
"""
return [word for word in SEPARATOR.split(text) if word.strip(' \t')] | [
"def",
"split",
"(",
"text",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"[",
"word",
"for",
"word",
"in",
"SEPARATOR",
".",
"split",
"(",
"text",
")",
"if",
"word",
".",
"strip",
"(",
"' \\t'",
")",
"]"
] | Split a text into a list of tokens.
:param text: the text to split
:return: tokens | [
"Split",
"a",
"text",
"into",
"a",
"list",
"of",
"tokens",
"."
] | 03e33b77c73238c0fe4600147e8c926515a2887f | https://github.com/yoeo/guesslang/blob/03e33b77c73238c0fe4600147e8c926515a2887f/guesslang/extractor.py#L34-L40 | train |
yoeo/guesslang | tools/unzip_repos.py | main | def main():
"""Files extractor command line"""
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('source', help="location of the downloaded repos")
parser.add_argument('destination', help="location of the ext... | python | def main():
"""Files extractor command line"""
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('source', help="location of the downloaded repos")
parser.add_argument('destination', help="location of the ext... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"__doc__",
",",
"formatter_class",
"=",
"argparse",
".",
"RawDescriptionHelpFormatter",
")",
"parser",
".",
"add_argument",
"(",
"'source'",
",",
"help",
"... | Files extractor command line | [
"Files",
"extractor",
"command",
"line"
] | 03e33b77c73238c0fe4600147e8c926515a2887f | https://github.com/yoeo/guesslang/blob/03e33b77c73238c0fe4600147e8c926515a2887f/tools/unzip_repos.py#L30-L65 | train |
innolitics/dicom-numpy | dicom_numpy/combine_slices.py | combine_slices | def combine_slices(slice_datasets, rescale=None):
'''
Given a list of pydicom datasets for an image series, stitch them together into a
three-dimensional numpy array. Also calculate a 4x4 affine transformation
matrix that converts the ijk-pixel-indices into the xyz-coordinates in the
DICOM patient'... | python | def combine_slices(slice_datasets, rescale=None):
'''
Given a list of pydicom datasets for an image series, stitch them together into a
three-dimensional numpy array. Also calculate a 4x4 affine transformation
matrix that converts the ijk-pixel-indices into the xyz-coordinates in the
DICOM patient'... | [
"def",
"combine_slices",
"(",
"slice_datasets",
",",
"rescale",
"=",
"None",
")",
":",
"if",
"len",
"(",
"slice_datasets",
")",
"==",
"0",
":",
"raise",
"DicomImportException",
"(",
"\"Must provide at least one DICOM dataset\"",
")",
"_validate_slices_form_uniform_grid"... | Given a list of pydicom datasets for an image series, stitch them together into a
three-dimensional numpy array. Also calculate a 4x4 affine transformation
matrix that converts the ijk-pixel-indices into the xyz-coordinates in the
DICOM patient's coordinate system.
Returns a two-tuple containing the 3... | [
"Given",
"a",
"list",
"of",
"pydicom",
"datasets",
"for",
"an",
"image",
"series",
"stitch",
"them",
"together",
"into",
"a",
"three",
"-",
"dimensional",
"numpy",
"array",
".",
"Also",
"calculate",
"a",
"4x4",
"affine",
"transformation",
"matrix",
"that",
"... | c870f0302276e7eaa0b66e641bacee19fe090296 | https://github.com/innolitics/dicom-numpy/blob/c870f0302276e7eaa0b66e641bacee19fe090296/dicom_numpy/combine_slices.py#L12-L74 | train |
innolitics/dicom-numpy | dicom_numpy/combine_slices.py | _validate_slices_form_uniform_grid | def _validate_slices_form_uniform_grid(slice_datasets):
'''
Perform various data checks to ensure that the list of slices form a
evenly-spaced grid of data.
Some of these checks are probably not required if the data follows the
DICOM specification, however it seems pertinent to check anyway.
'''... | python | def _validate_slices_form_uniform_grid(slice_datasets):
'''
Perform various data checks to ensure that the list of slices form a
evenly-spaced grid of data.
Some of these checks are probably not required if the data follows the
DICOM specification, however it seems pertinent to check anyway.
'''... | [
"def",
"_validate_slices_form_uniform_grid",
"(",
"slice_datasets",
")",
":",
"invariant_properties",
"=",
"[",
"'Modality'",
",",
"'SOPClassUID'",
",",
"'SeriesInstanceUID'",
",",
"'Rows'",
",",
"'Columns'",
",",
"'PixelSpacing'",
",",
"'PixelRepresentation'",
",",
"'B... | Perform various data checks to ensure that the list of slices form a
evenly-spaced grid of data.
Some of these checks are probably not required if the data follows the
DICOM specification, however it seems pertinent to check anyway. | [
"Perform",
"various",
"data",
"checks",
"to",
"ensure",
"that",
"the",
"list",
"of",
"slices",
"form",
"a",
"evenly",
"-",
"spaced",
"grid",
"of",
"data",
".",
"Some",
"of",
"these",
"checks",
"are",
"probably",
"not",
"required",
"if",
"the",
"data",
"f... | c870f0302276e7eaa0b66e641bacee19fe090296 | https://github.com/innolitics/dicom-numpy/blob/c870f0302276e7eaa0b66e641bacee19fe090296/dicom_numpy/combine_slices.py#L126-L153 | train |
edx/opaque-keys | opaque_keys/edx/locator.py | BlockLocatorBase.parse_url | def parse_url(cls, string): # pylint: disable=redefined-outer-name
"""
If it can be parsed as a version_guid with no preceding org + offering, returns a dict
with key 'version_guid' and the value,
If it can be parsed as a org + offering, returns a dict
with key 'id' and optiona... | python | def parse_url(cls, string): # pylint: disable=redefined-outer-name
"""
If it can be parsed as a version_guid with no preceding org + offering, returns a dict
with key 'version_guid' and the value,
If it can be parsed as a org + offering, returns a dict
with key 'id' and optiona... | [
"def",
"parse_url",
"(",
"cls",
",",
"string",
")",
":",
"match",
"=",
"cls",
".",
"URL_RE",
".",
"match",
"(",
"string",
")",
"if",
"not",
"match",
":",
"raise",
"InvalidKeyError",
"(",
"cls",
",",
"string",
")",
"return",
"match",
".",
"groupdict",
... | If it can be parsed as a version_guid with no preceding org + offering, returns a dict
with key 'version_guid' and the value,
If it can be parsed as a org + offering, returns a dict
with key 'id' and optional keys 'branch' and 'version_guid'.
Raises:
InvalidKeyError: if str... | [
"If",
"it",
"can",
"be",
"parsed",
"as",
"a",
"version_guid",
"with",
"no",
"preceding",
"org",
"+",
"offering",
"returns",
"a",
"dict",
"with",
"key",
"version_guid",
"and",
"the",
"value"
] | 9807168660c12e0551c8fdd58fd1bc6b0bcb0a54 | https://github.com/edx/opaque-keys/blob/9807168660c12e0551c8fdd58fd1bc6b0bcb0a54/opaque_keys/edx/locator.py#L110-L124 | train |
edx/opaque-keys | opaque_keys/edx/locator.py | CourseLocator.offering | def offering(self):
"""
Deprecated. Use course and run independently.
"""
warnings.warn(
"Offering is no longer a supported property of Locator. Please use the course and run properties.",
DeprecationWarning,
stacklevel=2
)
if not self.... | python | def offering(self):
"""
Deprecated. Use course and run independently.
"""
warnings.warn(
"Offering is no longer a supported property of Locator. Please use the course and run properties.",
DeprecationWarning,
stacklevel=2
)
if not self.... | [
"def",
"offering",
"(",
"self",
")",
":",
"warnings",
".",
"warn",
"(",
"\"Offering is no longer a supported property of Locator. Please use the course and run properties.\"",
",",
"DeprecationWarning",
",",
"stacklevel",
"=",
"2",
")",
"if",
"not",
"self",
".",
"course",... | Deprecated. Use course and run independently. | [
"Deprecated",
".",
"Use",
"course",
"and",
"run",
"independently",
"."
] | 9807168660c12e0551c8fdd58fd1bc6b0bcb0a54 | https://github.com/edx/opaque-keys/blob/9807168660c12e0551c8fdd58fd1bc6b0bcb0a54/opaque_keys/edx/locator.py#L234-L247 | train |
edx/opaque-keys | opaque_keys/edx/locator.py | CourseLocator.make_usage_key_from_deprecated_string | def make_usage_key_from_deprecated_string(self, location_url):
"""
Deprecated mechanism for creating a UsageKey given a CourseKey and a serialized Location.
NOTE: this prejudicially takes the tag, org, and course from the url not self.
Raises:
InvalidKeyError: if the url do... | python | def make_usage_key_from_deprecated_string(self, location_url):
"""
Deprecated mechanism for creating a UsageKey given a CourseKey and a serialized Location.
NOTE: this prejudicially takes the tag, org, and course from the url not self.
Raises:
InvalidKeyError: if the url do... | [
"def",
"make_usage_key_from_deprecated_string",
"(",
"self",
",",
"location_url",
")",
":",
"warnings",
".",
"warn",
"(",
"\"make_usage_key_from_deprecated_string is deprecated! Please use make_usage_key\"",
",",
"DeprecationWarning",
",",
"stacklevel",
"=",
"2",
")",
"return... | Deprecated mechanism for creating a UsageKey given a CourseKey and a serialized Location.
NOTE: this prejudicially takes the tag, org, and course from the url not self.
Raises:
InvalidKeyError: if the url does not parse | [
"Deprecated",
"mechanism",
"for",
"creating",
"a",
"UsageKey",
"given",
"a",
"CourseKey",
"and",
"a",
"serialized",
"Location",
"."
] | 9807168660c12e0551c8fdd58fd1bc6b0bcb0a54 | https://github.com/edx/opaque-keys/blob/9807168660c12e0551c8fdd58fd1bc6b0bcb0a54/opaque_keys/edx/locator.py#L283-L297 | train |
edx/opaque-keys | opaque_keys/edx/locator.py | BlockUsageLocator._from_string | def _from_string(cls, serialized):
"""
Requests CourseLocator to deserialize its part and then adds the local deserialization of block
"""
# Allow access to _from_string protected method
course_key = CourseLocator._from_string(serialized) # pylint: disable=protected-access
... | python | def _from_string(cls, serialized):
"""
Requests CourseLocator to deserialize its part and then adds the local deserialization of block
"""
# Allow access to _from_string protected method
course_key = CourseLocator._from_string(serialized) # pylint: disable=protected-access
... | [
"def",
"_from_string",
"(",
"cls",
",",
"serialized",
")",
":",
"course_key",
"=",
"CourseLocator",
".",
"_from_string",
"(",
"serialized",
")",
"parsed_parts",
"=",
"cls",
".",
"parse_url",
"(",
"serialized",
")",
"block_id",
"=",
"parsed_parts",
".",
"get",
... | Requests CourseLocator to deserialize its part and then adds the local deserialization of block | [
"Requests",
"CourseLocator",
"to",
"deserialize",
"its",
"part",
"and",
"then",
"adds",
"the",
"local",
"deserialization",
"of",
"block"
] | 9807168660c12e0551c8fdd58fd1bc6b0bcb0a54 | https://github.com/edx/opaque-keys/blob/9807168660c12e0551c8fdd58fd1bc6b0bcb0a54/opaque_keys/edx/locator.py#L720-L730 | train |
edx/opaque-keys | opaque_keys/edx/locator.py | BlockUsageLocator._parse_block_ref | def _parse_block_ref(cls, block_ref, deprecated=False):
"""
Given `block_ref`, tries to parse it into a valid block reference.
Returns `block_ref` if it is valid.
Raises:
InvalidKeyError: if `block_ref` is invalid.
"""
if deprecated and block_ref is None:
... | python | def _parse_block_ref(cls, block_ref, deprecated=False):
"""
Given `block_ref`, tries to parse it into a valid block reference.
Returns `block_ref` if it is valid.
Raises:
InvalidKeyError: if `block_ref` is invalid.
"""
if deprecated and block_ref is None:
... | [
"def",
"_parse_block_ref",
"(",
"cls",
",",
"block_ref",
",",
"deprecated",
"=",
"False",
")",
":",
"if",
"deprecated",
"and",
"block_ref",
"is",
"None",
":",
"return",
"None",
"if",
"isinstance",
"(",
"block_ref",
",",
"LocalId",
")",
":",
"return",
"bloc... | Given `block_ref`, tries to parse it into a valid block reference.
Returns `block_ref` if it is valid.
Raises:
InvalidKeyError: if `block_ref` is invalid. | [
"Given",
"block_ref",
"tries",
"to",
"parse",
"it",
"into",
"a",
"valid",
"block",
"reference",
"."
] | 9807168660c12e0551c8fdd58fd1bc6b0bcb0a54 | https://github.com/edx/opaque-keys/blob/9807168660c12e0551c8fdd58fd1bc6b0bcb0a54/opaque_keys/edx/locator.py#L766-L788 | train |
edx/opaque-keys | opaque_keys/edx/locator.py | BlockUsageLocator.html_id | def html_id(self):
"""
Return an id which can be used on an html page as an id attr of an html element. It is currently also
persisted by some clients to identify blocks.
To make compatible with old Location object functionality. I don't believe this behavior fits at this
place... | python | def html_id(self):
"""
Return an id which can be used on an html page as an id attr of an html element. It is currently also
persisted by some clients to identify blocks.
To make compatible with old Location object functionality. I don't believe this behavior fits at this
place... | [
"def",
"html_id",
"(",
"self",
")",
":",
"if",
"self",
".",
"deprecated",
":",
"id_fields",
"=",
"[",
"self",
".",
"DEPRECATED_TAG",
",",
"self",
".",
"org",
",",
"self",
".",
"course",
",",
"self",
".",
"block_type",
",",
"self",
".",
"block_id",
",... | Return an id which can be used on an html page as an id attr of an html element. It is currently also
persisted by some clients to identify blocks.
To make compatible with old Location object functionality. I don't believe this behavior fits at this
place, but I have no way to override. We sho... | [
"Return",
"an",
"id",
"which",
"can",
"be",
"used",
"on",
"an",
"html",
"page",
"as",
"an",
"id",
"attr",
"of",
"an",
"html",
"element",
".",
"It",
"is",
"currently",
"also",
"persisted",
"by",
"some",
"clients",
"to",
"identify",
"blocks",
"."
] | 9807168660c12e0551c8fdd58fd1bc6b0bcb0a54 | https://github.com/edx/opaque-keys/blob/9807168660c12e0551c8fdd58fd1bc6b0bcb0a54/opaque_keys/edx/locator.py#L930-L944 | train |
edx/opaque-keys | opaque_keys/edx/locator.py | BlockUsageLocator.to_deprecated_son | def to_deprecated_son(self, prefix='', tag='i4x'):
"""
Returns a SON object that represents this location
"""
# This preserves the old SON keys ('tag', 'org', 'course', 'category', 'name', 'revision'),
# because that format was used to store data historically in mongo
# ... | python | def to_deprecated_son(self, prefix='', tag='i4x'):
"""
Returns a SON object that represents this location
"""
# This preserves the old SON keys ('tag', 'org', 'course', 'category', 'name', 'revision'),
# because that format was used to store data historically in mongo
# ... | [
"def",
"to_deprecated_son",
"(",
"self",
",",
"prefix",
"=",
"''",
",",
"tag",
"=",
"'i4x'",
")",
":",
"son",
"=",
"SON",
"(",
"{",
"prefix",
"+",
"'tag'",
":",
"tag",
"}",
")",
"for",
"field_name",
"in",
"(",
"'org'",
",",
"'course'",
")",
":",
... | Returns a SON object that represents this location | [
"Returns",
"a",
"SON",
"object",
"that",
"represents",
"this",
"location"
] | 9807168660c12e0551c8fdd58fd1bc6b0bcb0a54 | https://github.com/edx/opaque-keys/blob/9807168660c12e0551c8fdd58fd1bc6b0bcb0a54/opaque_keys/edx/locator.py#L996-L1012 | train |
edx/opaque-keys | opaque_keys/edx/locator.py | BlockUsageLocator._from_deprecated_son | def _from_deprecated_son(cls, id_dict, run):
"""
Return the Location decoding this id_dict and run
"""
course_key = CourseLocator(
id_dict['org'],
id_dict['course'],
run,
id_dict['revision'],
deprecated=True,
)
r... | python | def _from_deprecated_son(cls, id_dict, run):
"""
Return the Location decoding this id_dict and run
"""
course_key = CourseLocator(
id_dict['org'],
id_dict['course'],
run,
id_dict['revision'],
deprecated=True,
)
r... | [
"def",
"_from_deprecated_son",
"(",
"cls",
",",
"id_dict",
",",
"run",
")",
":",
"course_key",
"=",
"CourseLocator",
"(",
"id_dict",
"[",
"'org'",
"]",
",",
"id_dict",
"[",
"'course'",
"]",
",",
"run",
",",
"id_dict",
"[",
"'revision'",
"]",
",",
"deprec... | Return the Location decoding this id_dict and run | [
"Return",
"the",
"Location",
"decoding",
"this",
"id_dict",
"and",
"run"
] | 9807168660c12e0551c8fdd58fd1bc6b0bcb0a54 | https://github.com/edx/opaque-keys/blob/9807168660c12e0551c8fdd58fd1bc6b0bcb0a54/opaque_keys/edx/locator.py#L1015-L1026 | train |
edx/opaque-keys | opaque_keys/edx/locator.py | LibraryUsageLocator._from_string | def _from_string(cls, serialized):
"""
Requests LibraryLocator to deserialize its part and then adds the local deserialization of block
"""
# Allow access to _from_string protected method
library_key = LibraryLocator._from_string(serialized) # pylint: disable=protected-access
... | python | def _from_string(cls, serialized):
"""
Requests LibraryLocator to deserialize its part and then adds the local deserialization of block
"""
# Allow access to _from_string protected method
library_key = LibraryLocator._from_string(serialized) # pylint: disable=protected-access
... | [
"def",
"_from_string",
"(",
"cls",
",",
"serialized",
")",
":",
"library_key",
"=",
"LibraryLocator",
".",
"_from_string",
"(",
"serialized",
")",
"parsed_parts",
"=",
"LibraryLocator",
".",
"parse_url",
"(",
"serialized",
")",
"block_id",
"=",
"parsed_parts",
"... | Requests LibraryLocator to deserialize its part and then adds the local deserialization of block | [
"Requests",
"LibraryLocator",
"to",
"deserialize",
"its",
"part",
"and",
"then",
"adds",
"the",
"local",
"deserialization",
"of",
"block"
] | 9807168660c12e0551c8fdd58fd1bc6b0bcb0a54 | https://github.com/edx/opaque-keys/blob/9807168660c12e0551c8fdd58fd1bc6b0bcb0a54/opaque_keys/edx/locator.py#L1087-L1103 | train |
edx/opaque-keys | opaque_keys/edx/locator.py | LibraryUsageLocator.for_branch | def for_branch(self, branch):
"""
Return a UsageLocator for the same block in a different branch of the library.
"""
return self.replace(library_key=self.library_key.for_branch(branch)) | python | def for_branch(self, branch):
"""
Return a UsageLocator for the same block in a different branch of the library.
"""
return self.replace(library_key=self.library_key.for_branch(branch)) | [
"def",
"for_branch",
"(",
"self",
",",
"branch",
")",
":",
"return",
"self",
".",
"replace",
"(",
"library_key",
"=",
"self",
".",
"library_key",
".",
"for_branch",
"(",
"branch",
")",
")"
] | Return a UsageLocator for the same block in a different branch of the library. | [
"Return",
"a",
"UsageLocator",
"for",
"the",
"same",
"block",
"in",
"a",
"different",
"branch",
"of",
"the",
"library",
"."
] | 9807168660c12e0551c8fdd58fd1bc6b0bcb0a54 | https://github.com/edx/opaque-keys/blob/9807168660c12e0551c8fdd58fd1bc6b0bcb0a54/opaque_keys/edx/locator.py#L1116-L1120 | train |
edx/opaque-keys | opaque_keys/edx/locator.py | LibraryUsageLocator.for_version | def for_version(self, version_guid):
"""
Return a UsageLocator for the same block in a different version of the library.
"""
return self.replace(library_key=self.library_key.for_version(version_guid)) | python | def for_version(self, version_guid):
"""
Return a UsageLocator for the same block in a different version of the library.
"""
return self.replace(library_key=self.library_key.for_version(version_guid)) | [
"def",
"for_version",
"(",
"self",
",",
"version_guid",
")",
":",
"return",
"self",
".",
"replace",
"(",
"library_key",
"=",
"self",
".",
"library_key",
".",
"for_version",
"(",
"version_guid",
")",
")"
] | Return a UsageLocator for the same block in a different version of the library. | [
"Return",
"a",
"UsageLocator",
"for",
"the",
"same",
"block",
"in",
"a",
"different",
"version",
"of",
"the",
"library",
"."
] | 9807168660c12e0551c8fdd58fd1bc6b0bcb0a54 | https://github.com/edx/opaque-keys/blob/9807168660c12e0551c8fdd58fd1bc6b0bcb0a54/opaque_keys/edx/locator.py#L1122-L1126 | train |
edx/opaque-keys | opaque_keys/edx/django/models.py | _strip_object | def _strip_object(key):
"""
Strips branch and version info if the given key supports those attributes.
"""
if hasattr(key, 'version_agnostic') and hasattr(key, 'for_branch'):
return key.for_branch(None).version_agnostic()
else:
return key | python | def _strip_object(key):
"""
Strips branch and version info if the given key supports those attributes.
"""
if hasattr(key, 'version_agnostic') and hasattr(key, 'for_branch'):
return key.for_branch(None).version_agnostic()
else:
return key | [
"def",
"_strip_object",
"(",
"key",
")",
":",
"if",
"hasattr",
"(",
"key",
",",
"'version_agnostic'",
")",
"and",
"hasattr",
"(",
"key",
",",
"'for_branch'",
")",
":",
"return",
"key",
".",
"for_branch",
"(",
"None",
")",
".",
"version_agnostic",
"(",
")... | Strips branch and version info if the given key supports those attributes. | [
"Strips",
"branch",
"and",
"version",
"info",
"if",
"the",
"given",
"key",
"supports",
"those",
"attributes",
"."
] | 9807168660c12e0551c8fdd58fd1bc6b0bcb0a54 | https://github.com/edx/opaque-keys/blob/9807168660c12e0551c8fdd58fd1bc6b0bcb0a54/opaque_keys/edx/django/models.py#L58-L65 | train |
edx/opaque-keys | opaque_keys/edx/django/models.py | _strip_value | def _strip_value(value, lookup='exact'):
"""
Helper function to remove the branch and version information from the given value,
which could be a single object or a list.
"""
if lookup == 'in':
stripped_value = [_strip_object(el) for el in value]
else:
stripped_value = _strip_obje... | python | def _strip_value(value, lookup='exact'):
"""
Helper function to remove the branch and version information from the given value,
which could be a single object or a list.
"""
if lookup == 'in':
stripped_value = [_strip_object(el) for el in value]
else:
stripped_value = _strip_obje... | [
"def",
"_strip_value",
"(",
"value",
",",
"lookup",
"=",
"'exact'",
")",
":",
"if",
"lookup",
"==",
"'in'",
":",
"stripped_value",
"=",
"[",
"_strip_object",
"(",
"el",
")",
"for",
"el",
"in",
"value",
"]",
"else",
":",
"stripped_value",
"=",
"_strip_obj... | Helper function to remove the branch and version information from the given value,
which could be a single object or a list. | [
"Helper",
"function",
"to",
"remove",
"the",
"branch",
"and",
"version",
"information",
"from",
"the",
"given",
"value",
"which",
"could",
"be",
"a",
"single",
"object",
"or",
"a",
"list",
"."
] | 9807168660c12e0551c8fdd58fd1bc6b0bcb0a54 | https://github.com/edx/opaque-keys/blob/9807168660c12e0551c8fdd58fd1bc6b0bcb0a54/opaque_keys/edx/django/models.py#L68-L77 | train |
edx/opaque-keys | opaque_keys/edx/locations.py | LocationBase._deprecation_warning | def _deprecation_warning(cls):
"""Display a deprecation warning for the given cls"""
if issubclass(cls, Location):
warnings.warn(
"Location is deprecated! Please use locator.BlockUsageLocator",
DeprecationWarning,
stacklevel=3
)
... | python | def _deprecation_warning(cls):
"""Display a deprecation warning for the given cls"""
if issubclass(cls, Location):
warnings.warn(
"Location is deprecated! Please use locator.BlockUsageLocator",
DeprecationWarning,
stacklevel=3
)
... | [
"def",
"_deprecation_warning",
"(",
"cls",
")",
":",
"if",
"issubclass",
"(",
"cls",
",",
"Location",
")",
":",
"warnings",
".",
"warn",
"(",
"\"Location is deprecated! Please use locator.BlockUsageLocator\"",
",",
"DeprecationWarning",
",",
"stacklevel",
"=",
"3",
... | Display a deprecation warning for the given cls | [
"Display",
"a",
"deprecation",
"warning",
"for",
"the",
"given",
"cls"
] | 9807168660c12e0551c8fdd58fd1bc6b0bcb0a54 | https://github.com/edx/opaque-keys/blob/9807168660c12e0551c8fdd58fd1bc6b0bcb0a54/opaque_keys/edx/locations.py#L84-L103 | train |
edx/opaque-keys | opaque_keys/edx/locations.py | LocationBase._check_location_part | def _check_location_part(cls, val, regexp):
"""Deprecated. See CourseLocator._check_location_part"""
cls._deprecation_warning()
return CourseLocator._check_location_part(val, regexp) | python | def _check_location_part(cls, val, regexp):
"""Deprecated. See CourseLocator._check_location_part"""
cls._deprecation_warning()
return CourseLocator._check_location_part(val, regexp) | [
"def",
"_check_location_part",
"(",
"cls",
",",
"val",
",",
"regexp",
")",
":",
"cls",
".",
"_deprecation_warning",
"(",
")",
"return",
"CourseLocator",
".",
"_check_location_part",
"(",
"val",
",",
"regexp",
")"
] | Deprecated. See CourseLocator._check_location_part | [
"Deprecated",
".",
"See",
"CourseLocator",
".",
"_check_location_part"
] | 9807168660c12e0551c8fdd58fd1bc6b0bcb0a54 | https://github.com/edx/opaque-keys/blob/9807168660c12e0551c8fdd58fd1bc6b0bcb0a54/opaque_keys/edx/locations.py#L116-L119 | train |
edx/opaque-keys | opaque_keys/edx/locations.py | LocationBase._clean | def _clean(cls, value, invalid):
"""Deprecated. See BlockUsageLocator._clean"""
cls._deprecation_warning()
return BlockUsageLocator._clean(value, invalid) | python | def _clean(cls, value, invalid):
"""Deprecated. See BlockUsageLocator._clean"""
cls._deprecation_warning()
return BlockUsageLocator._clean(value, invalid) | [
"def",
"_clean",
"(",
"cls",
",",
"value",
",",
"invalid",
")",
":",
"cls",
".",
"_deprecation_warning",
"(",
")",
"return",
"BlockUsageLocator",
".",
"_clean",
"(",
"value",
",",
"invalid",
")"
] | Deprecated. See BlockUsageLocator._clean | [
"Deprecated",
".",
"See",
"BlockUsageLocator",
".",
"_clean"
] | 9807168660c12e0551c8fdd58fd1bc6b0bcb0a54 | https://github.com/edx/opaque-keys/blob/9807168660c12e0551c8fdd58fd1bc6b0bcb0a54/opaque_keys/edx/locations.py#L122-L125 | train |
edx/opaque-keys | opaque_keys/edx/asides.py | _join_keys_v1 | def _join_keys_v1(left, right):
"""
Join two keys into a format separable by using _split_keys_v1.
"""
if left.endswith(':') or '::' in left:
raise ValueError("Can't join a left string ending in ':' or containing '::'")
return u"{}::{}".format(_encode_v1(left), _encode_v1(right)) | python | def _join_keys_v1(left, right):
"""
Join two keys into a format separable by using _split_keys_v1.
"""
if left.endswith(':') or '::' in left:
raise ValueError("Can't join a left string ending in ':' or containing '::'")
return u"{}::{}".format(_encode_v1(left), _encode_v1(right)) | [
"def",
"_join_keys_v1",
"(",
"left",
",",
"right",
")",
":",
"if",
"left",
".",
"endswith",
"(",
"':'",
")",
"or",
"'::'",
"in",
"left",
":",
"raise",
"ValueError",
"(",
"\"Can't join a left string ending in ':' or containing '::'\"",
")",
"return",
"u\"{}::{}\"",... | Join two keys into a format separable by using _split_keys_v1. | [
"Join",
"two",
"keys",
"into",
"a",
"format",
"separable",
"by",
"using",
"_split_keys_v1",
"."
] | 9807168660c12e0551c8fdd58fd1bc6b0bcb0a54 | https://github.com/edx/opaque-keys/blob/9807168660c12e0551c8fdd58fd1bc6b0bcb0a54/opaque_keys/edx/asides.py#L49-L55 | train |
edx/opaque-keys | opaque_keys/edx/asides.py | _split_keys_v1 | def _split_keys_v1(joined):
"""
Split two keys out a string created by _join_keys_v1.
"""
left, _, right = joined.partition('::')
return _decode_v1(left), _decode_v1(right) | python | def _split_keys_v1(joined):
"""
Split two keys out a string created by _join_keys_v1.
"""
left, _, right = joined.partition('::')
return _decode_v1(left), _decode_v1(right) | [
"def",
"_split_keys_v1",
"(",
"joined",
")",
":",
"left",
",",
"_",
",",
"right",
"=",
"joined",
".",
"partition",
"(",
"'::'",
")",
"return",
"_decode_v1",
"(",
"left",
")",
",",
"_decode_v1",
"(",
"right",
")"
] | Split two keys out a string created by _join_keys_v1. | [
"Split",
"two",
"keys",
"out",
"a",
"string",
"created",
"by",
"_join_keys_v1",
"."
] | 9807168660c12e0551c8fdd58fd1bc6b0bcb0a54 | https://github.com/edx/opaque-keys/blob/9807168660c12e0551c8fdd58fd1bc6b0bcb0a54/opaque_keys/edx/asides.py#L58-L63 | train |
edx/opaque-keys | opaque_keys/edx/asides.py | _split_keys_v2 | def _split_keys_v2(joined):
"""
Split two keys out a string created by _join_keys_v2.
"""
left, _, right = joined.rpartition('::')
return _decode_v2(left), _decode_v2(right) | python | def _split_keys_v2(joined):
"""
Split two keys out a string created by _join_keys_v2.
"""
left, _, right = joined.rpartition('::')
return _decode_v2(left), _decode_v2(right) | [
"def",
"_split_keys_v2",
"(",
"joined",
")",
":",
"left",
",",
"_",
",",
"right",
"=",
"joined",
".",
"rpartition",
"(",
"'::'",
")",
"return",
"_decode_v2",
"(",
"left",
")",
",",
"_decode_v2",
"(",
"right",
")"
] | Split two keys out a string created by _join_keys_v2. | [
"Split",
"two",
"keys",
"out",
"a",
"string",
"created",
"by",
"_join_keys_v2",
"."
] | 9807168660c12e0551c8fdd58fd1bc6b0bcb0a54 | https://github.com/edx/opaque-keys/blob/9807168660c12e0551c8fdd58fd1bc6b0bcb0a54/opaque_keys/edx/asides.py#L97-L102 | train |
dbcli/athenacli | athenacli/completion_refresher.py | refresher | def refresher(name, refreshers=CompletionRefresher.refreshers):
"""Decorator to add the decorated function to the dictionary of
refreshers. Any function decorated with a @refresher will be executed as
part of the completion refresh routine."""
def wrapper(wrapped):
refreshers[name] = wrapped
... | python | def refresher(name, refreshers=CompletionRefresher.refreshers):
"""Decorator to add the decorated function to the dictionary of
refreshers. Any function decorated with a @refresher will be executed as
part of the completion refresh routine."""
def wrapper(wrapped):
refreshers[name] = wrapped
... | [
"def",
"refresher",
"(",
"name",
",",
"refreshers",
"=",
"CompletionRefresher",
".",
"refreshers",
")",
":",
"def",
"wrapper",
"(",
"wrapped",
")",
":",
"refreshers",
"[",
"name",
"]",
"=",
"wrapped",
"return",
"wrapped",
"return",
"wrapper"
] | Decorator to add the decorated function to the dictionary of
refreshers. Any function decorated with a @refresher will be executed as
part of the completion refresh routine. | [
"Decorator",
"to",
"add",
"the",
"decorated",
"function",
"to",
"the",
"dictionary",
"of",
"refreshers",
".",
"Any",
"function",
"decorated",
"with",
"a"
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/completion_refresher.py#L86-L93 | train |
dbcli/athenacli | athenacli/completion_refresher.py | CompletionRefresher.refresh | def refresh(self, executor, callbacks, completer_options=None):
"""Creates a SQLCompleter object and populates it with the relevant
completion suggestions in a background thread.
executor - SQLExecute object, used to extract the credentials to connect
to the database.
... | python | def refresh(self, executor, callbacks, completer_options=None):
"""Creates a SQLCompleter object and populates it with the relevant
completion suggestions in a background thread.
executor - SQLExecute object, used to extract the credentials to connect
to the database.
... | [
"def",
"refresh",
"(",
"self",
",",
"executor",
",",
"callbacks",
",",
"completer_options",
"=",
"None",
")",
":",
"if",
"completer_options",
"is",
"None",
":",
"completer_options",
"=",
"{",
"}",
"if",
"self",
".",
"is_refreshing",
"(",
")",
":",
"self",
... | Creates a SQLCompleter object and populates it with the relevant
completion suggestions in a background thread.
executor - SQLExecute object, used to extract the credentials to connect
to the database.
callbacks - A function or a list of functions to call after the thread
... | [
"Creates",
"a",
"SQLCompleter",
"object",
"and",
"populates",
"it",
"with",
"the",
"relevant",
"completion",
"suggestions",
"in",
"a",
"background",
"thread",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/completion_refresher.py#L20-L45 | train |
dbcli/athenacli | athenacli/packages/special/utils.py | handle_cd_command | def handle_cd_command(arg):
"""Handles a `cd` shell command by calling python's os.chdir."""
CD_CMD = 'cd'
tokens = arg.split(CD_CMD + ' ')
directory = tokens[-1] if len(tokens) > 1 else None
if not directory:
return False, "No folder name was provided."
try:
os.chdir(directory)
... | python | def handle_cd_command(arg):
"""Handles a `cd` shell command by calling python's os.chdir."""
CD_CMD = 'cd'
tokens = arg.split(CD_CMD + ' ')
directory = tokens[-1] if len(tokens) > 1 else None
if not directory:
return False, "No folder name was provided."
try:
os.chdir(directory)
... | [
"def",
"handle_cd_command",
"(",
"arg",
")",
":",
"CD_CMD",
"=",
"'cd'",
"tokens",
"=",
"arg",
".",
"split",
"(",
"CD_CMD",
"+",
"' '",
")",
"directory",
"=",
"tokens",
"[",
"-",
"1",
"]",
"if",
"len",
"(",
"tokens",
")",
">",
"1",
"else",
"None",
... | Handles a `cd` shell command by calling python's os.chdir. | [
"Handles",
"a",
"cd",
"shell",
"command",
"by",
"calling",
"python",
"s",
"os",
".",
"chdir",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/packages/special/utils.py#L5-L17 | train |
dbcli/athenacli | athenacli/packages/special/iocommands.py | get_editor_query | def get_editor_query(sql):
"""Get the query part of an editor command."""
sql = sql.strip()
# The reason we can't simply do .strip('\e') is that it strips characters,
# not a substring. So it'll strip "e" in the end of the sql also!
# Ex: "select * from style\e" -> "select * from styl".
pattern... | python | def get_editor_query(sql):
"""Get the query part of an editor command."""
sql = sql.strip()
# The reason we can't simply do .strip('\e') is that it strips characters,
# not a substring. So it'll strip "e" in the end of the sql also!
# Ex: "select * from style\e" -> "select * from styl".
pattern... | [
"def",
"get_editor_query",
"(",
"sql",
")",
":",
"sql",
"=",
"sql",
".",
"strip",
"(",
")",
"pattern",
"=",
"re",
".",
"compile",
"(",
"'(^\\\\\\e|\\\\\\e$)'",
")",
"while",
"pattern",
".",
"search",
"(",
"sql",
")",
":",
"sql",
"=",
"pattern",
".",
... | Get the query part of an editor command. | [
"Get",
"the",
"query",
"part",
"of",
"an",
"editor",
"command",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/packages/special/iocommands.py#L108-L119 | train |
dbcli/athenacli | athenacli/packages/special/iocommands.py | delete_favorite_query | def delete_favorite_query(arg, **_):
"""Delete an existing favorite query.
"""
usage = 'Syntax: \\fd name.\n\n' + favoritequeries.usage
if not arg:
return [(None, None, None, usage)]
status = favoritequeries.delete(arg)
return [(None, None, None, status)] | python | def delete_favorite_query(arg, **_):
"""Delete an existing favorite query.
"""
usage = 'Syntax: \\fd name.\n\n' + favoritequeries.usage
if not arg:
return [(None, None, None, usage)]
status = favoritequeries.delete(arg)
return [(None, None, None, status)] | [
"def",
"delete_favorite_query",
"(",
"arg",
",",
"**",
"_",
")",
":",
"usage",
"=",
"'Syntax: \\\\fd name.\\n\\n'",
"+",
"favoritequeries",
".",
"usage",
"if",
"not",
"arg",
":",
"return",
"[",
"(",
"None",
",",
"None",
",",
"None",
",",
"usage",
")",
"]... | Delete an existing favorite query. | [
"Delete",
"an",
"existing",
"favorite",
"query",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/packages/special/iocommands.py#L239-L248 | train |
dbcli/athenacli | athenacli/packages/special/iocommands.py | execute_system_command | def execute_system_command(arg, **_):
"""Execute a system shell command."""
usage = "Syntax: system [command].\n"
if not arg:
return [(None, None, None, usage)]
try:
command = arg.strip()
if command.startswith('cd'):
ok, error_message = handle_cd_command(arg)
... | python | def execute_system_command(arg, **_):
"""Execute a system shell command."""
usage = "Syntax: system [command].\n"
if not arg:
return [(None, None, None, usage)]
try:
command = arg.strip()
if command.startswith('cd'):
ok, error_message = handle_cd_command(arg)
... | [
"def",
"execute_system_command",
"(",
"arg",
",",
"**",
"_",
")",
":",
"usage",
"=",
"\"Syntax: system [command].\\n\"",
"if",
"not",
"arg",
":",
"return",
"[",
"(",
"None",
",",
"None",
",",
"None",
",",
"usage",
")",
"]",
"try",
":",
"command",
"=",
... | Execute a system shell command. | [
"Execute",
"a",
"system",
"shell",
"command",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/packages/special/iocommands.py#L253-L280 | train |
dbcli/athenacli | athenacli/main.py | need_completion_refresh | def need_completion_refresh(queries):
"""Determines if the completion needs a refresh by checking if the sql
statement is an alter, create, drop or change db."""
tokens = {
'use', '\\u',
'create',
'drop'
}
for query in sqlparse.split(queries):
try:
first_... | python | def need_completion_refresh(queries):
"""Determines if the completion needs a refresh by checking if the sql
statement is an alter, create, drop or change db."""
tokens = {
'use', '\\u',
'create',
'drop'
}
for query in sqlparse.split(queries):
try:
first_... | [
"def",
"need_completion_refresh",
"(",
"queries",
")",
":",
"tokens",
"=",
"{",
"'use'",
",",
"'\\\\u'",
",",
"'create'",
",",
"'drop'",
"}",
"for",
"query",
"in",
"sqlparse",
".",
"split",
"(",
"queries",
")",
":",
"try",
":",
"first_token",
"=",
"query... | Determines if the completion needs a refresh by checking if the sql
statement is an alter, create, drop or change db. | [
"Determines",
"if",
"the",
"completion",
"needs",
"a",
"refresh",
"by",
"checking",
"if",
"the",
"sql",
"statement",
"is",
"an",
"alter",
"create",
"drop",
"or",
"change",
"db",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/main.py#L607-L622 | train |
dbcli/athenacli | athenacli/main.py | is_mutating | def is_mutating(status):
"""Determines if the statement is mutating based on the status."""
if not status:
return False
mutating = set(['insert', 'update', 'delete', 'alter', 'create', 'drop',
'replace', 'truncate', 'load'])
return status.split(None, 1)[0].lower() in mutatin... | python | def is_mutating(status):
"""Determines if the statement is mutating based on the status."""
if not status:
return False
mutating = set(['insert', 'update', 'delete', 'alter', 'create', 'drop',
'replace', 'truncate', 'load'])
return status.split(None, 1)[0].lower() in mutatin... | [
"def",
"is_mutating",
"(",
"status",
")",
":",
"if",
"not",
"status",
":",
"return",
"False",
"mutating",
"=",
"set",
"(",
"[",
"'insert'",
",",
"'update'",
",",
"'delete'",
",",
"'alter'",
",",
"'create'",
",",
"'drop'",
",",
"'replace'",
",",
"'truncat... | Determines if the statement is mutating based on the status. | [
"Determines",
"if",
"the",
"statement",
"is",
"mutating",
"based",
"on",
"the",
"status",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/main.py#L625-L632 | train |
dbcli/athenacli | athenacli/main.py | AthenaCli.change_prompt_format | def change_prompt_format(self, arg, **_):
"""
Change the prompt format.
"""
if not arg:
message = 'Missing required argument, format.'
return [(None, None, None, message)]
self.prompt = self.get_prompt(arg)
return [(None, None, None, "Changed prom... | python | def change_prompt_format(self, arg, **_):
"""
Change the prompt format.
"""
if not arg:
message = 'Missing required argument, format.'
return [(None, None, None, message)]
self.prompt = self.get_prompt(arg)
return [(None, None, None, "Changed prom... | [
"def",
"change_prompt_format",
"(",
"self",
",",
"arg",
",",
"**",
"_",
")",
":",
"if",
"not",
"arg",
":",
"message",
"=",
"'Missing required argument, format.'",
"return",
"[",
"(",
"None",
",",
"None",
",",
"None",
",",
"message",
")",
"]",
"self",
"."... | Change the prompt format. | [
"Change",
"the",
"prompt",
"format",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/main.py#L184-L193 | train |
dbcli/athenacli | athenacli/main.py | AthenaCli.get_output_margin | def get_output_margin(self, status=None):
"""Get the output margin (number of rows for the prompt, footer and
timing message."""
margin = self.get_reserved_space() + self.get_prompt(self.prompt).count('\n') + 1
if special.is_timing_enabled():
margin += 1
if status:
... | python | def get_output_margin(self, status=None):
"""Get the output margin (number of rows for the prompt, footer and
timing message."""
margin = self.get_reserved_space() + self.get_prompt(self.prompt).count('\n') + 1
if special.is_timing_enabled():
margin += 1
if status:
... | [
"def",
"get_output_margin",
"(",
"self",
",",
"status",
"=",
"None",
")",
":",
"margin",
"=",
"self",
".",
"get_reserved_space",
"(",
")",
"+",
"self",
".",
"get_prompt",
"(",
"self",
".",
"prompt",
")",
".",
"count",
"(",
"'\\n'",
")",
"+",
"1",
"if... | Get the output margin (number of rows for the prompt, footer and
timing message. | [
"Get",
"the",
"output",
"margin",
"(",
"number",
"of",
"rows",
"for",
"the",
"prompt",
"footer",
"and",
"timing",
"message",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/main.py#L362-L371 | train |
dbcli/athenacli | athenacli/main.py | AthenaCli.output | def output(self, output, status=None):
"""Output text to stdout or a pager command.
The status text is not outputted to pager or files.
The message will be logged in the audit log, if enabled. The
message will be written to the tee file, if enabled. The
message will be written to... | python | def output(self, output, status=None):
"""Output text to stdout or a pager command.
The status text is not outputted to pager or files.
The message will be logged in the audit log, if enabled. The
message will be written to the tee file, if enabled. The
message will be written to... | [
"def",
"output",
"(",
"self",
",",
"output",
",",
"status",
"=",
"None",
")",
":",
"if",
"output",
":",
"size",
"=",
"self",
".",
"cli",
".",
"output",
".",
"get_size",
"(",
")",
"margin",
"=",
"self",
".",
"get_output_margin",
"(",
"status",
")",
... | Output text to stdout or a pager command.
The status text is not outputted to pager or files.
The message will be logged in the audit log, if enabled. The
message will be written to the tee file, if enabled. The
message will be written to the output file, if enabled. | [
"Output",
"text",
"to",
"stdout",
"or",
"a",
"pager",
"command",
".",
"The",
"status",
"text",
"is",
"not",
"outputted",
"to",
"pager",
"or",
"files",
".",
"The",
"message",
"will",
"be",
"logged",
"in",
"the",
"audit",
"log",
"if",
"enabled",
".",
"Th... | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/main.py#L373-L418 | train |
dbcli/athenacli | athenacli/main.py | AthenaCli._on_completions_refreshed | def _on_completions_refreshed(self, new_completer):
"""Swap the completer object in cli with the newly created completer.
"""
with self._completer_lock:
self.completer = new_completer
# When cli is first launched we call refresh_completions before
# instantiat... | python | def _on_completions_refreshed(self, new_completer):
"""Swap the completer object in cli with the newly created completer.
"""
with self._completer_lock:
self.completer = new_completer
# When cli is first launched we call refresh_completions before
# instantiat... | [
"def",
"_on_completions_refreshed",
"(",
"self",
",",
"new_completer",
")",
":",
"with",
"self",
".",
"_completer_lock",
":",
"self",
".",
"completer",
"=",
"new_completer",
"if",
"self",
".",
"cli",
":",
"self",
".",
"cli",
".",
"current_buffer",
".",
"comp... | Swap the completer object in cli with the newly created completer. | [
"Swap",
"the",
"completer",
"object",
"in",
"cli",
"with",
"the",
"newly",
"created",
"completer",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/main.py#L497-L511 | train |
dbcli/athenacli | athenacli/main.py | AthenaCli.get_reserved_space | def get_reserved_space(self):
"""Get the number of lines to reserve for the completion menu."""
reserved_space_ratio = .45
max_reserved_space = 8
_, height = click.get_terminal_size()
return min(int(round(height * reserved_space_ratio)), max_reserved_space) | python | def get_reserved_space(self):
"""Get the number of lines to reserve for the completion menu."""
reserved_space_ratio = .45
max_reserved_space = 8
_, height = click.get_terminal_size()
return min(int(round(height * reserved_space_ratio)), max_reserved_space) | [
"def",
"get_reserved_space",
"(",
"self",
")",
":",
"reserved_space_ratio",
"=",
".45",
"max_reserved_space",
"=",
"8",
"_",
",",
"height",
"=",
"click",
".",
"get_terminal_size",
"(",
")",
"return",
"min",
"(",
"int",
"(",
"round",
"(",
"height",
"*",
"re... | Get the number of lines to reserve for the completion menu. | [
"Get",
"the",
"number",
"of",
"lines",
"to",
"reserve",
"for",
"the",
"completion",
"menu",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/main.py#L595-L600 | train |
dbcli/athenacli | athenacli/completer.py | AthenaCompleter.find_matches | def find_matches(text, collection, start_only=False, fuzzy=True, casing=None):
"""Find completion matches for the given text.
Given the user's input text and a collection of available
completions, find completions matching the last word of the
text.
If `start_only` is True, the t... | python | def find_matches(text, collection, start_only=False, fuzzy=True, casing=None):
"""Find completion matches for the given text.
Given the user's input text and a collection of available
completions, find completions matching the last word of the
text.
If `start_only` is True, the t... | [
"def",
"find_matches",
"(",
"text",
",",
"collection",
",",
"start_only",
"=",
"False",
",",
"fuzzy",
"=",
"True",
",",
"casing",
"=",
"None",
")",
":",
"last",
"=",
"last_word",
"(",
"text",
",",
"include",
"=",
"'most_punctuations'",
")",
"text",
"=",
... | Find completion matches for the given text.
Given the user's input text and a collection of available
completions, find completions matching the last word of the
text.
If `start_only` is True, the text will match an available
completion only at the beginning. Otherwise, a complet... | [
"Find",
"completion",
"matches",
"for",
"the",
"given",
"text",
".",
"Given",
"the",
"user",
"s",
"input",
"text",
"and",
"a",
"collection",
"of",
"available",
"completions",
"find",
"completions",
"matching",
"the",
"last",
"word",
"of",
"the",
"text",
".",... | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/completer.py#L157-L196 | train |
dbcli/athenacli | athenacli/config.py | log | def log(logger, level, message):
"""Logs message to stderr if logging isn't initialized."""
if logger.parent.name != 'root':
logger.log(level, message)
else:
print(message, file=sys.stderr) | python | def log(logger, level, message):
"""Logs message to stderr if logging isn't initialized."""
if logger.parent.name != 'root':
logger.log(level, message)
else:
print(message, file=sys.stderr) | [
"def",
"log",
"(",
"logger",
",",
"level",
",",
"message",
")",
":",
"if",
"logger",
".",
"parent",
".",
"name",
"!=",
"'root'",
":",
"logger",
".",
"log",
"(",
"level",
",",
"message",
")",
"else",
":",
"print",
"(",
"message",
",",
"file",
"=",
... | Logs message to stderr if logging isn't initialized. | [
"Logs",
"message",
"to",
"stderr",
"if",
"logging",
"isn",
"t",
"initialized",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/config.py#L42-L48 | train |
dbcli/athenacli | athenacli/config.py | read_config_file | def read_config_file(f):
"""Read a config file."""
if isinstance(f, basestring):
f = os.path.expanduser(f)
try:
config = ConfigObj(f, interpolation=False, encoding='utf8')
except ConfigObjError as e:
log(LOGGER, logging.ERROR, "Unable to parse line {0} of config file "
... | python | def read_config_file(f):
"""Read a config file."""
if isinstance(f, basestring):
f = os.path.expanduser(f)
try:
config = ConfigObj(f, interpolation=False, encoding='utf8')
except ConfigObjError as e:
log(LOGGER, logging.ERROR, "Unable to parse line {0} of config file "
... | [
"def",
"read_config_file",
"(",
"f",
")",
":",
"if",
"isinstance",
"(",
"f",
",",
"basestring",
")",
":",
"f",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"f",
")",
"try",
":",
"config",
"=",
"ConfigObj",
"(",
"f",
",",
"interpolation",
"=",
"F... | Read a config file. | [
"Read",
"a",
"config",
"file",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/config.py#L51-L69 | train |
dbcli/athenacli | athenacli/config.py | read_config_files | def read_config_files(files):
"""Read and merge a list of config files."""
config = ConfigObj()
for _file in files:
_config = read_config_file(_file)
if bool(_config) is True:
config.merge(_config)
config.filename = _config.filename
return config | python | def read_config_files(files):
"""Read and merge a list of config files."""
config = ConfigObj()
for _file in files:
_config = read_config_file(_file)
if bool(_config) is True:
config.merge(_config)
config.filename = _config.filename
return config | [
"def",
"read_config_files",
"(",
"files",
")",
":",
"config",
"=",
"ConfigObj",
"(",
")",
"for",
"_file",
"in",
"files",
":",
"_config",
"=",
"read_config_file",
"(",
"_file",
")",
"if",
"bool",
"(",
"_config",
")",
"is",
"True",
":",
"config",
".",
"m... | Read and merge a list of config files. | [
"Read",
"and",
"merge",
"a",
"list",
"of",
"config",
"files",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/config.py#L72-L83 | train |
dbcli/athenacli | athenacli/key_bindings.py | cli_bindings | def cli_bindings():
"""
Custom key bindings for cli.
"""
key_binding_manager = KeyBindingManager(
enable_open_in_editor=True,
enable_system_bindings=True,
enable_auto_suggest_bindings=True,
enable_search=True,
enable_abort_and_exit_bindings=True)
@key_binding... | python | def cli_bindings():
"""
Custom key bindings for cli.
"""
key_binding_manager = KeyBindingManager(
enable_open_in_editor=True,
enable_system_bindings=True,
enable_auto_suggest_bindings=True,
enable_search=True,
enable_abort_and_exit_bindings=True)
@key_binding... | [
"def",
"cli_bindings",
"(",
")",
":",
"key_binding_manager",
"=",
"KeyBindingManager",
"(",
"enable_open_in_editor",
"=",
"True",
",",
"enable_system_bindings",
"=",
"True",
",",
"enable_auto_suggest_bindings",
"=",
"True",
",",
"enable_search",
"=",
"True",
",",
"e... | Custom key bindings for cli. | [
"Custom",
"key",
"bindings",
"for",
"cli",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/key_bindings.py#L10-L89 | train |
dbcli/athenacli | athenacli/packages/prompt_utils.py | prompt | def prompt(*args, **kwargs):
"""Prompt the user for input and handle any abort exceptions."""
try:
return click.prompt(*args, **kwargs)
except click.Abort:
return False | python | def prompt(*args, **kwargs):
"""Prompt the user for input and handle any abort exceptions."""
try:
return click.prompt(*args, **kwargs)
except click.Abort:
return False | [
"def",
"prompt",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"try",
":",
"return",
"click",
".",
"prompt",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"except",
"click",
".",
"Abort",
":",
"return",
"False"
] | Prompt the user for input and handle any abort exceptions. | [
"Prompt",
"the",
"user",
"for",
"input",
"and",
"handle",
"any",
"abort",
"exceptions",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/packages/prompt_utils.py#L30-L35 | train |
dbcli/athenacli | athenacli/sqlexecute.py | SQLExecute.run | def run(self, statement):
'''Execute the sql in the database and return the results.
The results are a list of tuples. Each tuple has 4 values
(title, rows, headers, status).
'''
# Remove spaces and EOL
statement = statement.strip()
if not statement: # Empty str... | python | def run(self, statement):
'''Execute the sql in the database and return the results.
The results are a list of tuples. Each tuple has 4 values
(title, rows, headers, status).
'''
# Remove spaces and EOL
statement = statement.strip()
if not statement: # Empty str... | [
"def",
"run",
"(",
"self",
",",
"statement",
")",
":",
"statement",
"=",
"statement",
".",
"strip",
"(",
")",
"if",
"not",
"statement",
":",
"yield",
"(",
"None",
",",
"None",
",",
"None",
",",
"None",
")",
"components",
"=",
"sqlparse",
".",
"split"... | Execute the sql in the database and return the results.
The results are a list of tuples. Each tuple has 4 values
(title, rows, headers, status). | [
"Execute",
"the",
"sql",
"in",
"the",
"database",
"and",
"return",
"the",
"results",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/sqlexecute.py#L52-L82 | train |
dbcli/athenacli | athenacli/sqlexecute.py | SQLExecute.get_result | def get_result(self, cursor):
'''Get the current result's data from the cursor.'''
title = headers = None
# cursor.description is not None for queries that return result sets,
# e.g. SELECT or SHOW.
if cursor.description is not None:
headers = [x[0] for x in cursor.d... | python | def get_result(self, cursor):
'''Get the current result's data from the cursor.'''
title = headers = None
# cursor.description is not None for queries that return result sets,
# e.g. SELECT or SHOW.
if cursor.description is not None:
headers = [x[0] for x in cursor.d... | [
"def",
"get_result",
"(",
"self",
",",
"cursor",
")",
":",
"title",
"=",
"headers",
"=",
"None",
"if",
"cursor",
".",
"description",
"is",
"not",
"None",
":",
"headers",
"=",
"[",
"x",
"[",
"0",
"]",
"for",
"x",
"in",
"cursor",
".",
"description",
... | Get the current result's data from the cursor. | [
"Get",
"the",
"current",
"result",
"s",
"data",
"from",
"the",
"cursor",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/sqlexecute.py#L84-L98 | train |
dbcli/athenacli | athenacli/sqlexecute.py | SQLExecute.tables | def tables(self):
'''Yields table names.'''
with self.conn.cursor() as cur:
cur.execute(self.TABLES_QUERY)
for row in cur:
yield row | python | def tables(self):
'''Yields table names.'''
with self.conn.cursor() as cur:
cur.execute(self.TABLES_QUERY)
for row in cur:
yield row | [
"def",
"tables",
"(",
"self",
")",
":",
"with",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"as",
"cur",
":",
"cur",
".",
"execute",
"(",
"self",
".",
"TABLES_QUERY",
")",
"for",
"row",
"in",
"cur",
":",
"yield",
"row"
] | Yields table names. | [
"Yields",
"table",
"names",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/sqlexecute.py#L100-L105 | train |
dbcli/athenacli | athenacli/sqlexecute.py | SQLExecute.table_columns | def table_columns(self):
'''Yields column names.'''
with self.conn.cursor() as cur:
cur.execute(self.TABLE_COLUMNS_QUERY % self.database)
for row in cur:
yield row | python | def table_columns(self):
'''Yields column names.'''
with self.conn.cursor() as cur:
cur.execute(self.TABLE_COLUMNS_QUERY % self.database)
for row in cur:
yield row | [
"def",
"table_columns",
"(",
"self",
")",
":",
"with",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"as",
"cur",
":",
"cur",
".",
"execute",
"(",
"self",
".",
"TABLE_COLUMNS_QUERY",
"%",
"self",
".",
"database",
")",
"for",
"row",
"in",
"cur",
":",
... | Yields column names. | [
"Yields",
"column",
"names",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/sqlexecute.py#L107-L112 | train |
dbcli/athenacli | athenacli/clitoolbar.py | create_toolbar_tokens_func | def create_toolbar_tokens_func(get_is_refreshing, show_fish_help):
"""
Return a function that generates the toolbar tokens.
"""
token = Token.Toolbar
def get_toolbar_tokens(cli):
result = []
result.append((token, ' '))
if cli.buffers[DEFAULT_BUFFER].always_multiline:
... | python | def create_toolbar_tokens_func(get_is_refreshing, show_fish_help):
"""
Return a function that generates the toolbar tokens.
"""
token = Token.Toolbar
def get_toolbar_tokens(cli):
result = []
result.append((token, ' '))
if cli.buffers[DEFAULT_BUFFER].always_multiline:
... | [
"def",
"create_toolbar_tokens_func",
"(",
"get_is_refreshing",
",",
"show_fish_help",
")",
":",
"token",
"=",
"Token",
".",
"Toolbar",
"def",
"get_toolbar_tokens",
"(",
"cli",
")",
":",
"result",
"=",
"[",
"]",
"result",
".",
"append",
"(",
"(",
"token",
","... | Return a function that generates the toolbar tokens. | [
"Return",
"a",
"function",
"that",
"generates",
"the",
"toolbar",
"tokens",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/clitoolbar.py#L6-L38 | train |
dbcli/athenacli | athenacli/clitoolbar.py | _get_vi_mode | def _get_vi_mode(cli):
"""Get the current vi mode for display."""
return {
InputMode.INSERT: 'I',
InputMode.NAVIGATION: 'N',
InputMode.REPLACE: 'R',
InputMode.INSERT_MULTIPLE: 'M'
}[cli.vi_state.input_mode] | python | def _get_vi_mode(cli):
"""Get the current vi mode for display."""
return {
InputMode.INSERT: 'I',
InputMode.NAVIGATION: 'N',
InputMode.REPLACE: 'R',
InputMode.INSERT_MULTIPLE: 'M'
}[cli.vi_state.input_mode] | [
"def",
"_get_vi_mode",
"(",
"cli",
")",
":",
"return",
"{",
"InputMode",
".",
"INSERT",
":",
"'I'",
",",
"InputMode",
".",
"NAVIGATION",
":",
"'N'",
",",
"InputMode",
".",
"REPLACE",
":",
"'R'",
",",
"InputMode",
".",
"INSERT_MULTIPLE",
":",
"'M'",
"}",
... | Get the current vi mode for display. | [
"Get",
"the",
"current",
"vi",
"mode",
"for",
"display",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/clitoolbar.py#L41-L48 | train |
dbcli/athenacli | athenacli/packages/special/__init__.py | export | def export(defn):
"""Decorator to explicitly mark functions that are exposed in a lib."""
globals()[defn.__name__] = defn
__all__.append(defn.__name__)
return defn | python | def export(defn):
"""Decorator to explicitly mark functions that are exposed in a lib."""
globals()[defn.__name__] = defn
__all__.append(defn.__name__)
return defn | [
"def",
"export",
"(",
"defn",
")",
":",
"globals",
"(",
")",
"[",
"defn",
".",
"__name__",
"]",
"=",
"defn",
"__all__",
".",
"append",
"(",
"defn",
".",
"__name__",
")",
"return",
"defn"
] | Decorator to explicitly mark functions that are exposed in a lib. | [
"Decorator",
"to",
"explicitly",
"mark",
"functions",
"that",
"are",
"exposed",
"in",
"a",
"lib",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/packages/special/__init__.py#L5-L9 | train |
dbcli/athenacli | athenacli/packages/special/main.py | execute | def execute(cur, sql):
"""Execute a special command and return the results. If the special command
is not supported a KeyError will be raised.
"""
command, verbose, arg = parse_special_command(sql)
if (command not in COMMANDS) and (command.lower() not in COMMANDS):
raise CommandNotFound
... | python | def execute(cur, sql):
"""Execute a special command and return the results. If the special command
is not supported a KeyError will be raised.
"""
command, verbose, arg = parse_special_command(sql)
if (command not in COMMANDS) and (command.lower() not in COMMANDS):
raise CommandNotFound
... | [
"def",
"execute",
"(",
"cur",
",",
"sql",
")",
":",
"command",
",",
"verbose",
",",
"arg",
"=",
"parse_special_command",
"(",
"sql",
")",
"if",
"(",
"command",
"not",
"in",
"COMMANDS",
")",
"and",
"(",
"command",
".",
"lower",
"(",
")",
"not",
"in",
... | Execute a special command and return the results. If the special command
is not supported a KeyError will be raised. | [
"Execute",
"a",
"special",
"command",
"and",
"return",
"the",
"results",
".",
"If",
"the",
"special",
"command",
"is",
"not",
"supported",
"a",
"KeyError",
"will",
"be",
"raised",
"."
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/packages/special/main.py#L51-L76 | train |
dbcli/athenacli | athenacli/packages/parseutils.py | find_prev_keyword | def find_prev_keyword(sql):
""" Find the last sql keyword in an SQL statement
Returns the value of the last keyword, and the text of the query with
everything after the last keyword stripped
"""
if not sql.strip():
return None, ''
parsed = sqlparse.parse(sql)[0]
flattened = list(par... | python | def find_prev_keyword(sql):
""" Find the last sql keyword in an SQL statement
Returns the value of the last keyword, and the text of the query with
everything after the last keyword stripped
"""
if not sql.strip():
return None, ''
parsed = sqlparse.parse(sql)[0]
flattened = list(par... | [
"def",
"find_prev_keyword",
"(",
"sql",
")",
":",
"if",
"not",
"sql",
".",
"strip",
"(",
")",
":",
"return",
"None",
",",
"''",
"parsed",
"=",
"sqlparse",
".",
"parse",
"(",
"sql",
")",
"[",
"0",
"]",
"flattened",
"=",
"list",
"(",
"parsed",
".",
... | Find the last sql keyword in an SQL statement
Returns the value of the last keyword, and the text of the query with
everything after the last keyword stripped | [
"Find",
"the",
"last",
"sql",
"keyword",
"in",
"an",
"SQL",
"statement",
"Returns",
"the",
"value",
"of",
"the",
"last",
"keyword",
"and",
"the",
"text",
"of",
"the",
"query",
"with",
"everything",
"after",
"the",
"last",
"keyword",
"stripped"
] | bcab59e4953145866430083e902ed4d042d4ebba | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/packages/parseutils.py#L153-L184 | train |
divio/cmsplugin-filer | cmsplugin_filer_teaser/cms_plugins.py | FilerTeaserPlugin._get_thumbnail_options | def _get_thumbnail_options(self, context, instance):
"""
Return the size and options of the thumbnail that should be inserted
"""
width, height = None, None
subject_location = False
placeholder_width = context.get('width', None)
placeholder_height = context.get('h... | python | def _get_thumbnail_options(self, context, instance):
"""
Return the size and options of the thumbnail that should be inserted
"""
width, height = None, None
subject_location = False
placeholder_width = context.get('width', None)
placeholder_height = context.get('h... | [
"def",
"_get_thumbnail_options",
"(",
"self",
",",
"context",
",",
"instance",
")",
":",
"width",
",",
"height",
"=",
"None",
",",
"None",
"subject_location",
"=",
"False",
"placeholder_width",
"=",
"context",
".",
"get",
"(",
"'width'",
",",
"None",
")",
... | Return the size and options of the thumbnail that should be inserted | [
"Return",
"the",
"size",
"and",
"options",
"of",
"the",
"thumbnail",
"that",
"should",
"be",
"inserted"
] | 4f9b0307dd768852ead64e651b743a165b3efccb | https://github.com/divio/cmsplugin-filer/blob/4f9b0307dd768852ead64e651b743a165b3efccb/cmsplugin_filer_teaser/cms_plugins.py#L42-L75 | train |
divio/cmsplugin-filer | cmsplugin_filer_image/integrations/ckeditor.py | create_image_plugin | def create_image_plugin(filename, image, parent_plugin, **kwargs):
"""
Used for drag-n-drop image insertion with djangocms-text-ckeditor.
Set TEXT_SAVE_IMAGE_FUNCTION='cmsplugin_filer_image.integrations.ckeditor.create_image_plugin' to enable.
"""
from cmsplugin_filer_image.models import FilerImage
... | python | def create_image_plugin(filename, image, parent_plugin, **kwargs):
"""
Used for drag-n-drop image insertion with djangocms-text-ckeditor.
Set TEXT_SAVE_IMAGE_FUNCTION='cmsplugin_filer_image.integrations.ckeditor.create_image_plugin' to enable.
"""
from cmsplugin_filer_image.models import FilerImage
... | [
"def",
"create_image_plugin",
"(",
"filename",
",",
"image",
",",
"parent_plugin",
",",
"**",
"kwargs",
")",
":",
"from",
"cmsplugin_filer_image",
".",
"models",
"import",
"FilerImage",
"from",
"filer",
".",
"models",
"import",
"Image",
"image_plugin",
"=",
"Fil... | Used for drag-n-drop image insertion with djangocms-text-ckeditor.
Set TEXT_SAVE_IMAGE_FUNCTION='cmsplugin_filer_image.integrations.ckeditor.create_image_plugin' to enable. | [
"Used",
"for",
"drag",
"-",
"n",
"-",
"drop",
"image",
"insertion",
"with",
"djangocms",
"-",
"text",
"-",
"ckeditor",
".",
"Set",
"TEXT_SAVE_IMAGE_FUNCTION",
"=",
"cmsplugin_filer_image",
".",
"integrations",
".",
"ckeditor",
".",
"create_image_plugin",
"to",
"... | 4f9b0307dd768852ead64e651b743a165b3efccb | https://github.com/divio/cmsplugin-filer/blob/4f9b0307dd768852ead64e651b743a165b3efccb/cmsplugin_filer_image/integrations/ckeditor.py#L6-L23 | train |
divio/cmsplugin-filer | cmsplugin_filer_utils/migration.py | rename_tables | def rename_tables(db, table_mapping, reverse=False):
"""
renames tables from source to destination name, if the source exists and the destination does
not exist yet.
"""
from django.db import connection
if reverse:
table_mapping = [(dst, src) for src, dst in table_mapping]
table_name... | python | def rename_tables(db, table_mapping, reverse=False):
"""
renames tables from source to destination name, if the source exists and the destination does
not exist yet.
"""
from django.db import connection
if reverse:
table_mapping = [(dst, src) for src, dst in table_mapping]
table_name... | [
"def",
"rename_tables",
"(",
"db",
",",
"table_mapping",
",",
"reverse",
"=",
"False",
")",
":",
"from",
"django",
".",
"db",
"import",
"connection",
"if",
"reverse",
":",
"table_mapping",
"=",
"[",
"(",
"dst",
",",
"src",
")",
"for",
"src",
",",
"dst"... | renames tables from source to destination name, if the source exists and the destination does
not exist yet. | [
"renames",
"tables",
"from",
"source",
"to",
"destination",
"name",
"if",
"the",
"source",
"exists",
"and",
"the",
"destination",
"does",
"not",
"exist",
"yet",
"."
] | 4f9b0307dd768852ead64e651b743a165b3efccb | https://github.com/divio/cmsplugin-filer/blob/4f9b0307dd768852ead64e651b743a165b3efccb/cmsplugin_filer_utils/migration.py#L4-L18 | train |
sorgerlab/indra | indra/util/statement_presentation.py | group_and_sort_statements | def group_and_sort_statements(stmt_list, ev_totals=None):
"""Group statements by type and arguments, and sort by prevalence.
Parameters
----------
stmt_list : list[Statement]
A list of INDRA statements.
ev_totals : dict{int: int}
A dictionary, keyed by statement hash (shallow) with ... | python | def group_and_sort_statements(stmt_list, ev_totals=None):
"""Group statements by type and arguments, and sort by prevalence.
Parameters
----------
stmt_list : list[Statement]
A list of INDRA statements.
ev_totals : dict{int: int}
A dictionary, keyed by statement hash (shallow) with ... | [
"def",
"group_and_sort_statements",
"(",
"stmt_list",
",",
"ev_totals",
"=",
"None",
")",
":",
"def",
"_count",
"(",
"stmt",
")",
":",
"if",
"ev_totals",
"is",
"None",
":",
"return",
"len",
"(",
"stmt",
".",
"evidence",
")",
"else",
":",
"return",
"ev_to... | Group statements by type and arguments, and sort by prevalence.
Parameters
----------
stmt_list : list[Statement]
A list of INDRA statements.
ev_totals : dict{int: int}
A dictionary, keyed by statement hash (shallow) with counts of total
evidence as the values. Including this wi... | [
"Group",
"statements",
"by",
"type",
"and",
"arguments",
"and",
"sort",
"by",
"prevalence",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/statement_presentation.py#L40-L109 | train |
sorgerlab/indra | indra/util/statement_presentation.py | make_stmt_from_sort_key | def make_stmt_from_sort_key(key, verb):
"""Make a Statement from the sort key.
Specifically, the sort key used by `group_and_sort_statements`.
"""
def make_agent(name):
if name == 'None' or name is None:
return None
return Agent(name)
StmtClass = get_statement_by_name(v... | python | def make_stmt_from_sort_key(key, verb):
"""Make a Statement from the sort key.
Specifically, the sort key used by `group_and_sort_statements`.
"""
def make_agent(name):
if name == 'None' or name is None:
return None
return Agent(name)
StmtClass = get_statement_by_name(v... | [
"def",
"make_stmt_from_sort_key",
"(",
"key",
",",
"verb",
")",
":",
"def",
"make_agent",
"(",
"name",
")",
":",
"if",
"name",
"==",
"'None'",
"or",
"name",
"is",
"None",
":",
"return",
"None",
"return",
"Agent",
"(",
"name",
")",
"StmtClass",
"=",
"ge... | Make a Statement from the sort key.
Specifically, the sort key used by `group_and_sort_statements`. | [
"Make",
"a",
"Statement",
"from",
"the",
"sort",
"key",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/statement_presentation.py#L112-L134 | train |
sorgerlab/indra | indra/tools/reading/submit_reading_pipeline.py | get_ecs_cluster_for_queue | def get_ecs_cluster_for_queue(queue_name, batch_client=None):
"""Get the name of the ecs cluster using the batch client."""
if batch_client is None:
batch_client = boto3.client('batch')
queue_resp = batch_client.describe_job_queues(jobQueues=[queue_name])
if len(queue_resp['jobQueues']) == 1:
... | python | def get_ecs_cluster_for_queue(queue_name, batch_client=None):
"""Get the name of the ecs cluster using the batch client."""
if batch_client is None:
batch_client = boto3.client('batch')
queue_resp = batch_client.describe_job_queues(jobQueues=[queue_name])
if len(queue_resp['jobQueues']) == 1:
... | [
"def",
"get_ecs_cluster_for_queue",
"(",
"queue_name",
",",
"batch_client",
"=",
"None",
")",
":",
"if",
"batch_client",
"is",
"None",
":",
"batch_client",
"=",
"boto3",
".",
"client",
"(",
"'batch'",
")",
"queue_resp",
"=",
"batch_client",
".",
"describe_job_qu... | Get the name of the ecs cluster using the batch client. | [
"Get",
"the",
"name",
"of",
"the",
"ecs",
"cluster",
"using",
"the",
"batch",
"client",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/submit_reading_pipeline.py#L275-L306 | train |
sorgerlab/indra | indra/tools/reading/submit_reading_pipeline.py | tag_instances_on_cluster | def tag_instances_on_cluster(cluster_name, project='cwc'):
"""Adds project tag to untagged instances in a given cluster.
Parameters
----------
cluster_name : str
The name of the AWS ECS cluster in which running instances
should be tagged.
project : str
The name of the projec... | python | def tag_instances_on_cluster(cluster_name, project='cwc'):
"""Adds project tag to untagged instances in a given cluster.
Parameters
----------
cluster_name : str
The name of the AWS ECS cluster in which running instances
should be tagged.
project : str
The name of the projec... | [
"def",
"tag_instances_on_cluster",
"(",
"cluster_name",
",",
"project",
"=",
"'cwc'",
")",
":",
"ecs",
"=",
"boto3",
".",
"client",
"(",
"'ecs'",
")",
"task_arns",
"=",
"ecs",
".",
"list_tasks",
"(",
"cluster",
"=",
"cluster_name",
")",
"[",
"'taskArns'",
... | Adds project tag to untagged instances in a given cluster.
Parameters
----------
cluster_name : str
The name of the AWS ECS cluster in which running instances
should be tagged.
project : str
The name of the project to tag instances with. | [
"Adds",
"project",
"tag",
"to",
"untagged",
"instances",
"in",
"a",
"given",
"cluster",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/submit_reading_pipeline.py#L309-L335 | train |
sorgerlab/indra | indra/tools/reading/submit_reading_pipeline.py | submit_reading | def submit_reading(basename, pmid_list_filename, readers, start_ix=None,
end_ix=None, pmids_per_job=3000, num_tries=2,
force_read=False, force_fulltext=False, project_name=None):
"""Submit an old-style pmid-centered no-database s3 only reading job.
This function is provide... | python | def submit_reading(basename, pmid_list_filename, readers, start_ix=None,
end_ix=None, pmids_per_job=3000, num_tries=2,
force_read=False, force_fulltext=False, project_name=None):
"""Submit an old-style pmid-centered no-database s3 only reading job.
This function is provide... | [
"def",
"submit_reading",
"(",
"basename",
",",
"pmid_list_filename",
",",
"readers",
",",
"start_ix",
"=",
"None",
",",
"end_ix",
"=",
"None",
",",
"pmids_per_job",
"=",
"3000",
",",
"num_tries",
"=",
"2",
",",
"force_read",
"=",
"False",
",",
"force_fulltex... | Submit an old-style pmid-centered no-database s3 only reading job.
This function is provided for the sake of backward compatibility. It is
preferred that you use the object-oriented PmidSubmitter and the
submit_reading job going forward. | [
"Submit",
"an",
"old",
"-",
"style",
"pmid",
"-",
"centered",
"no",
"-",
"database",
"s3",
"only",
"reading",
"job",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/submit_reading_pipeline.py#L555-L568 | train |
sorgerlab/indra | indra/tools/reading/submit_reading_pipeline.py | submit_combine | def submit_combine(basename, readers, job_ids=None, project_name=None):
"""Submit a batch job to combine the outputs of a reading job.
This function is provided for backwards compatibility. You should use the
PmidSubmitter and submit_combine methods.
"""
sub = PmidSubmitter(basename, readers, proje... | python | def submit_combine(basename, readers, job_ids=None, project_name=None):
"""Submit a batch job to combine the outputs of a reading job.
This function is provided for backwards compatibility. You should use the
PmidSubmitter and submit_combine methods.
"""
sub = PmidSubmitter(basename, readers, proje... | [
"def",
"submit_combine",
"(",
"basename",
",",
"readers",
",",
"job_ids",
"=",
"None",
",",
"project_name",
"=",
"None",
")",
":",
"sub",
"=",
"PmidSubmitter",
"(",
"basename",
",",
"readers",
",",
"project_name",
")",
"sub",
".",
"job_list",
"=",
"job_ids... | Submit a batch job to combine the outputs of a reading job.
This function is provided for backwards compatibility. You should use the
PmidSubmitter and submit_combine methods. | [
"Submit",
"a",
"batch",
"job",
"to",
"combine",
"the",
"outputs",
"of",
"a",
"reading",
"job",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/submit_reading_pipeline.py#L571-L580 | train |
sorgerlab/indra | indra/tools/reading/submit_reading_pipeline.py | Submitter.submit_reading | def submit_reading(self, input_fname, start_ix, end_ix, ids_per_job,
num_tries=1, stagger=0):
"""Submit a batch of reading jobs
Parameters
----------
input_fname : str
The name of the file containing the ids to be read.
start_ix : int
... | python | def submit_reading(self, input_fname, start_ix, end_ix, ids_per_job,
num_tries=1, stagger=0):
"""Submit a batch of reading jobs
Parameters
----------
input_fname : str
The name of the file containing the ids to be read.
start_ix : int
... | [
"def",
"submit_reading",
"(",
"self",
",",
"input_fname",
",",
"start_ix",
",",
"end_ix",
",",
"ids_per_job",
",",
"num_tries",
"=",
"1",
",",
"stagger",
"=",
"0",
")",
":",
"self",
".",
"ids_per_job",
"=",
"ids_per_job",
"id_list_key",
"=",
"'reading_result... | Submit a batch of reading jobs
Parameters
----------
input_fname : str
The name of the file containing the ids to be read.
start_ix : int
The line index of the first item in the list to read.
end_ix : int
The line index of the last item in the... | [
"Submit",
"a",
"batch",
"of",
"reading",
"jobs"
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/submit_reading_pipeline.py#L397-L466 | train |
sorgerlab/indra | indra/tools/reading/submit_reading_pipeline.py | Submitter.watch_and_wait | def watch_and_wait(self, poll_interval=10, idle_log_timeout=None,
kill_on_timeout=False, stash_log_method=None,
tag_instances=False, **kwargs):
"""This provides shortcut access to the wait_for_complete_function."""
return wait_for_complete(self._job_queue, j... | python | def watch_and_wait(self, poll_interval=10, idle_log_timeout=None,
kill_on_timeout=False, stash_log_method=None,
tag_instances=False, **kwargs):
"""This provides shortcut access to the wait_for_complete_function."""
return wait_for_complete(self._job_queue, j... | [
"def",
"watch_and_wait",
"(",
"self",
",",
"poll_interval",
"=",
"10",
",",
"idle_log_timeout",
"=",
"None",
",",
"kill_on_timeout",
"=",
"False",
",",
"stash_log_method",
"=",
"None",
",",
"tag_instances",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"retur... | This provides shortcut access to the wait_for_complete_function. | [
"This",
"provides",
"shortcut",
"access",
"to",
"the",
"wait_for_complete_function",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/submit_reading_pipeline.py#L468-L478 | train |
sorgerlab/indra | indra/tools/reading/submit_reading_pipeline.py | Submitter.run | def run(self, input_fname, ids_per_job, stagger=0, **wait_params):
"""Run this submission all the way.
This method will run both `submit_reading` and `watch_and_wait`,
blocking on the latter.
"""
submit_thread = Thread(target=self.submit_reading,
a... | python | def run(self, input_fname, ids_per_job, stagger=0, **wait_params):
"""Run this submission all the way.
This method will run both `submit_reading` and `watch_and_wait`,
blocking on the latter.
"""
submit_thread = Thread(target=self.submit_reading,
a... | [
"def",
"run",
"(",
"self",
",",
"input_fname",
",",
"ids_per_job",
",",
"stagger",
"=",
"0",
",",
"**",
"wait_params",
")",
":",
"submit_thread",
"=",
"Thread",
"(",
"target",
"=",
"self",
".",
"submit_reading",
",",
"args",
"=",
"(",
"input_fname",
",",... | Run this submission all the way.
This method will run both `submit_reading` and `watch_and_wait`,
blocking on the latter. | [
"Run",
"this",
"submission",
"all",
"the",
"way",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/submit_reading_pipeline.py#L480-L496 | train |
sorgerlab/indra | indra/tools/reading/submit_reading_pipeline.py | PmidSubmitter.set_options | def set_options(self, force_read=False, force_fulltext=False):
"""Set the options for this run."""
self.options['force_read'] = force_read
self.options['force_fulltext'] = force_fulltext
return | python | def set_options(self, force_read=False, force_fulltext=False):
"""Set the options for this run."""
self.options['force_read'] = force_read
self.options['force_fulltext'] = force_fulltext
return | [
"def",
"set_options",
"(",
"self",
",",
"force_read",
"=",
"False",
",",
"force_fulltext",
"=",
"False",
")",
":",
"self",
".",
"options",
"[",
"'force_read'",
"]",
"=",
"force_read",
"self",
".",
"options",
"[",
"'force_fulltext'",
"]",
"=",
"force_fulltext... | Set the options for this run. | [
"Set",
"the",
"options",
"for",
"this",
"run",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/submit_reading_pipeline.py#L517-L521 | train |
sorgerlab/indra | indra/databases/chebi_client.py | get_chebi_name_from_id | def get_chebi_name_from_id(chebi_id, offline=False):
"""Return a ChEBI name corresponding to the given ChEBI ID.
Parameters
----------
chebi_id : str
The ChEBI ID whose name is to be returned.
offline : Optional[bool]
Choose whether to allow an online lookup if the local lookup fail... | python | def get_chebi_name_from_id(chebi_id, offline=False):
"""Return a ChEBI name corresponding to the given ChEBI ID.
Parameters
----------
chebi_id : str
The ChEBI ID whose name is to be returned.
offline : Optional[bool]
Choose whether to allow an online lookup if the local lookup fail... | [
"def",
"get_chebi_name_from_id",
"(",
"chebi_id",
",",
"offline",
"=",
"False",
")",
":",
"chebi_name",
"=",
"chebi_id_to_name",
".",
"get",
"(",
"chebi_id",
")",
"if",
"chebi_name",
"is",
"None",
"and",
"not",
"offline",
":",
"chebi_name",
"=",
"get_chebi_nam... | Return a ChEBI name corresponding to the given ChEBI ID.
Parameters
----------
chebi_id : str
The ChEBI ID whose name is to be returned.
offline : Optional[bool]
Choose whether to allow an online lookup if the local lookup fails. If
True, the online lookup is not attempted. Defa... | [
"Return",
"a",
"ChEBI",
"name",
"corresponding",
"to",
"the",
"given",
"ChEBI",
"ID",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/chebi_client.py#L86-L106 | train |
sorgerlab/indra | indra/databases/chebi_client.py | get_chebi_name_from_id_web | def get_chebi_name_from_id_web(chebi_id):
"""Return a ChEBI mame corresponding to a given ChEBI ID using a REST API.
Parameters
----------
chebi_id : str
The ChEBI ID whose name is to be returned.
Returns
-------
chebi_name : str
The name corresponding to the given ChEBI ID... | python | def get_chebi_name_from_id_web(chebi_id):
"""Return a ChEBI mame corresponding to a given ChEBI ID using a REST API.
Parameters
----------
chebi_id : str
The ChEBI ID whose name is to be returned.
Returns
-------
chebi_name : str
The name corresponding to the given ChEBI ID... | [
"def",
"get_chebi_name_from_id_web",
"(",
"chebi_id",
")",
":",
"url_base",
"=",
"'http://www.ebi.ac.uk/webservices/chebi/2.0/test/'",
"url_fmt",
"=",
"url_base",
"+",
"'getCompleteEntity?chebiId=%s'",
"resp",
"=",
"requests",
".",
"get",
"(",
"url_fmt",
"%",
"chebi_id",
... | Return a ChEBI mame corresponding to a given ChEBI ID using a REST API.
Parameters
----------
chebi_id : str
The ChEBI ID whose name is to be returned.
Returns
-------
chebi_name : str
The name corresponding to the given ChEBI ID. If the lookup
fails, None is returned. | [
"Return",
"a",
"ChEBI",
"mame",
"corresponding",
"to",
"a",
"given",
"ChEBI",
"ID",
"using",
"a",
"REST",
"API",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/chebi_client.py#L179-L214 | train |
sorgerlab/indra | indra/tools/executable_subnetwork.py | get_subnetwork | def get_subnetwork(statements, nodes, relevance_network=None,
relevance_node_lim=10):
"""Return a PySB model based on a subset of given INDRA Statements.
Statements are first filtered for nodes in the given list and other nodes
are optionally added based on relevance in a given network. ... | python | def get_subnetwork(statements, nodes, relevance_network=None,
relevance_node_lim=10):
"""Return a PySB model based on a subset of given INDRA Statements.
Statements are first filtered for nodes in the given list and other nodes
are optionally added based on relevance in a given network. ... | [
"def",
"get_subnetwork",
"(",
"statements",
",",
"nodes",
",",
"relevance_network",
"=",
"None",
",",
"relevance_node_lim",
"=",
"10",
")",
":",
"if",
"relevance_network",
"is",
"not",
"None",
":",
"relevant_nodes",
"=",
"_find_relevant_nodes",
"(",
"nodes",
","... | Return a PySB model based on a subset of given INDRA Statements.
Statements are first filtered for nodes in the given list and other nodes
are optionally added based on relevance in a given network. The filtered
statements are then assembled into an executable model using INDRA's
PySB Assembler.
P... | [
"Return",
"a",
"PySB",
"model",
"based",
"on",
"a",
"subset",
"of",
"given",
"INDRA",
"Statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/executable_subnetwork.py#L7-L45 | train |
sorgerlab/indra | indra/tools/executable_subnetwork.py | _filter_statements | def _filter_statements(statements, agents):
"""Return INDRA Statements which have Agents in the given list.
Only statements are returned in which all appearing Agents as in the
agents list.
Parameters
----------
statements : list[indra.statements.Statement]
A list of INDRA Statements t... | python | def _filter_statements(statements, agents):
"""Return INDRA Statements which have Agents in the given list.
Only statements are returned in which all appearing Agents as in the
agents list.
Parameters
----------
statements : list[indra.statements.Statement]
A list of INDRA Statements t... | [
"def",
"_filter_statements",
"(",
"statements",
",",
"agents",
")",
":",
"filtered_statements",
"=",
"[",
"]",
"for",
"s",
"in",
"stmts",
":",
"if",
"all",
"(",
"[",
"a",
"is",
"not",
"None",
"for",
"a",
"in",
"s",
".",
"agent_list",
"(",
")",
"]",
... | Return INDRA Statements which have Agents in the given list.
Only statements are returned in which all appearing Agents as in the
agents list.
Parameters
----------
statements : list[indra.statements.Statement]
A list of INDRA Statements to filter.
agents : list[str]
A list of ... | [
"Return",
"INDRA",
"Statements",
"which",
"have",
"Agents",
"in",
"the",
"given",
"list",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/executable_subnetwork.py#L47-L70 | train |
sorgerlab/indra | indra/tools/executable_subnetwork.py | _find_relevant_nodes | def _find_relevant_nodes(query_nodes, relevance_network, relevance_node_lim):
"""Return a list of nodes that are relevant for the query.
Parameters
----------
query_nodes : list[str]
A list of node names to query for.
relevance_network : str
The UUID of the NDEx network to query rel... | python | def _find_relevant_nodes(query_nodes, relevance_network, relevance_node_lim):
"""Return a list of nodes that are relevant for the query.
Parameters
----------
query_nodes : list[str]
A list of node names to query for.
relevance_network : str
The UUID of the NDEx network to query rel... | [
"def",
"_find_relevant_nodes",
"(",
"query_nodes",
",",
"relevance_network",
",",
"relevance_node_lim",
")",
":",
"all_nodes",
"=",
"relevance_client",
".",
"get_relevant_nodes",
"(",
"relevance_network",
",",
"query_nodes",
")",
"nodes",
"=",
"[",
"n",
"[",
"0",
... | Return a list of nodes that are relevant for the query.
Parameters
----------
query_nodes : list[str]
A list of node names to query for.
relevance_network : str
The UUID of the NDEx network to query relevance in.
relevance_node_lim : int
The number of top relevant nodes to r... | [
"Return",
"a",
"list",
"of",
"nodes",
"that",
"are",
"relevant",
"for",
"the",
"query",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/executable_subnetwork.py#L72-L92 | train |
sorgerlab/indra | indra/sources/hume/api.py | process_jsonld_file | def process_jsonld_file(fname):
"""Process a JSON-LD file in the new format to extract Statements.
Parameters
----------
fname : str
The path to the JSON-LD file to be processed.
Returns
-------
indra.sources.hume.HumeProcessor
A HumeProcessor instance, which contains a lis... | python | def process_jsonld_file(fname):
"""Process a JSON-LD file in the new format to extract Statements.
Parameters
----------
fname : str
The path to the JSON-LD file to be processed.
Returns
-------
indra.sources.hume.HumeProcessor
A HumeProcessor instance, which contains a lis... | [
"def",
"process_jsonld_file",
"(",
"fname",
")",
":",
"with",
"open",
"(",
"fname",
",",
"'r'",
")",
"as",
"fh",
":",
"json_dict",
"=",
"json",
".",
"load",
"(",
"fh",
")",
"return",
"process_jsonld",
"(",
"json_dict",
")"
] | Process a JSON-LD file in the new format to extract Statements.
Parameters
----------
fname : str
The path to the JSON-LD file to be processed.
Returns
-------
indra.sources.hume.HumeProcessor
A HumeProcessor instance, which contains a list of INDRA Statements
as its st... | [
"Process",
"a",
"JSON",
"-",
"LD",
"file",
"in",
"the",
"new",
"format",
"to",
"extract",
"Statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/hume/api.py#L10-L26 | train |
sorgerlab/indra | indra/util/aws.py | tag_instance | def tag_instance(instance_id, **tags):
"""Tag a single ec2 instance."""
logger.debug("Got request to add tags %s to instance %s."
% (str(tags), instance_id))
ec2 = boto3.resource('ec2')
instance = ec2.Instance(instance_id)
# Remove None's from `tags`
filtered_tags = {k: v for k... | python | def tag_instance(instance_id, **tags):
"""Tag a single ec2 instance."""
logger.debug("Got request to add tags %s to instance %s."
% (str(tags), instance_id))
ec2 = boto3.resource('ec2')
instance = ec2.Instance(instance_id)
# Remove None's from `tags`
filtered_tags = {k: v for k... | [
"def",
"tag_instance",
"(",
"instance_id",
",",
"**",
"tags",
")",
":",
"logger",
".",
"debug",
"(",
"\"Got request to add tags %s to instance %s.\"",
"%",
"(",
"str",
"(",
"tags",
")",
",",
"instance_id",
")",
")",
"ec2",
"=",
"boto3",
".",
"resource",
"(",... | Tag a single ec2 instance. | [
"Tag",
"a",
"single",
"ec2",
"instance",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/aws.py#L36-L62 | train |
sorgerlab/indra | indra/util/aws.py | tag_myself | def tag_myself(project='cwc', **other_tags):
"""Function run when indra is used in an EC2 instance to apply tags."""
base_url = "http://169.254.169.254"
try:
resp = requests.get(base_url + "/latest/meta-data/instance-id")
except requests.exceptions.ConnectionError:
logger.warning("Could ... | python | def tag_myself(project='cwc', **other_tags):
"""Function run when indra is used in an EC2 instance to apply tags."""
base_url = "http://169.254.169.254"
try:
resp = requests.get(base_url + "/latest/meta-data/instance-id")
except requests.exceptions.ConnectionError:
logger.warning("Could ... | [
"def",
"tag_myself",
"(",
"project",
"=",
"'cwc'",
",",
"**",
"other_tags",
")",
":",
"base_url",
"=",
"\"http://169.254.169.254\"",
"try",
":",
"resp",
"=",
"requests",
".",
"get",
"(",
"base_url",
"+",
"\"/latest/meta-data/instance-id\"",
")",
"except",
"reque... | Function run when indra is used in an EC2 instance to apply tags. | [
"Function",
"run",
"when",
"indra",
"is",
"used",
"in",
"an",
"EC2",
"instance",
"to",
"apply",
"tags",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/aws.py#L65-L76 | train |
sorgerlab/indra | indra/util/aws.py | get_batch_command | def get_batch_command(command_list, project=None, purpose=None):
"""Get the command appropriate for running something on batch."""
command_str = ' '.join(command_list)
ret = ['python', '-m', 'indra.util.aws', 'run_in_batch', command_str]
if not project and has_config('DEFAULT_AWS_PROJECT'):
proj... | python | def get_batch_command(command_list, project=None, purpose=None):
"""Get the command appropriate for running something on batch."""
command_str = ' '.join(command_list)
ret = ['python', '-m', 'indra.util.aws', 'run_in_batch', command_str]
if not project and has_config('DEFAULT_AWS_PROJECT'):
proj... | [
"def",
"get_batch_command",
"(",
"command_list",
",",
"project",
"=",
"None",
",",
"purpose",
"=",
"None",
")",
":",
"command_str",
"=",
"' '",
".",
"join",
"(",
"command_list",
")",
"ret",
"=",
"[",
"'python'",
",",
"'-m'",
",",
"'indra.util.aws'",
",",
... | Get the command appropriate for running something on batch. | [
"Get",
"the",
"command",
"appropriate",
"for",
"running",
"something",
"on",
"batch",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/aws.py#L79-L89 | train |
sorgerlab/indra | indra/util/aws.py | get_jobs | def get_jobs(job_queue='run_reach_queue', job_status='RUNNING'):
"""Returns a list of dicts with jobName and jobId for each job with the
given status."""
batch = boto3.client('batch')
jobs = batch.list_jobs(jobQueue=job_queue, jobStatus=job_status)
return jobs.get('jobSummaryList') | python | def get_jobs(job_queue='run_reach_queue', job_status='RUNNING'):
"""Returns a list of dicts with jobName and jobId for each job with the
given status."""
batch = boto3.client('batch')
jobs = batch.list_jobs(jobQueue=job_queue, jobStatus=job_status)
return jobs.get('jobSummaryList') | [
"def",
"get_jobs",
"(",
"job_queue",
"=",
"'run_reach_queue'",
",",
"job_status",
"=",
"'RUNNING'",
")",
":",
"batch",
"=",
"boto3",
".",
"client",
"(",
"'batch'",
")",
"jobs",
"=",
"batch",
".",
"list_jobs",
"(",
"jobQueue",
"=",
"job_queue",
",",
"jobSta... | Returns a list of dicts with jobName and jobId for each job with the
given status. | [
"Returns",
"a",
"list",
"of",
"dicts",
"with",
"jobName",
"and",
"jobId",
"for",
"each",
"job",
"with",
"the",
"given",
"status",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/aws.py#L101-L106 | train |
sorgerlab/indra | indra/util/aws.py | get_job_log | def get_job_log(job_info, log_group_name='/aws/batch/job',
write_file=True, verbose=False):
"""Gets the Cloudwatch log associated with the given job.
Parameters
----------
job_info : dict
dict containing entries for 'jobName' and 'jobId', e.g., as returned
by get_jobs()
... | python | def get_job_log(job_info, log_group_name='/aws/batch/job',
write_file=True, verbose=False):
"""Gets the Cloudwatch log associated with the given job.
Parameters
----------
job_info : dict
dict containing entries for 'jobName' and 'jobId', e.g., as returned
by get_jobs()
... | [
"def",
"get_job_log",
"(",
"job_info",
",",
"log_group_name",
"=",
"'/aws/batch/job'",
",",
"write_file",
"=",
"True",
",",
"verbose",
"=",
"False",
")",
":",
"job_name",
"=",
"job_info",
"[",
"'jobName'",
"]",
"job_id",
"=",
"job_info",
"[",
"'jobId'",
"]",... | Gets the Cloudwatch log associated with the given job.
Parameters
----------
job_info : dict
dict containing entries for 'jobName' and 'jobId', e.g., as returned
by get_jobs()
log_group_name : string
Name of the log group; defaults to '/aws/batch/job'
write_file : boolean
... | [
"Gets",
"the",
"Cloudwatch",
"log",
"associated",
"with",
"the",
"given",
"job",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/aws.py#L109-L153 | train |
sorgerlab/indra | indra/util/aws.py | get_log_by_name | def get_log_by_name(log_group_name, log_stream_name, out_file=None,
verbose=True):
"""Download a log given the log's group and stream name.
Parameters
----------
log_group_name : str
The name of the log group, e.g. /aws/batch/job.
log_stream_name : str
The name ... | python | def get_log_by_name(log_group_name, log_stream_name, out_file=None,
verbose=True):
"""Download a log given the log's group and stream name.
Parameters
----------
log_group_name : str
The name of the log group, e.g. /aws/batch/job.
log_stream_name : str
The name ... | [
"def",
"get_log_by_name",
"(",
"log_group_name",
",",
"log_stream_name",
",",
"out_file",
"=",
"None",
",",
"verbose",
"=",
"True",
")",
":",
"logs",
"=",
"boto3",
".",
"client",
"(",
"'logs'",
")",
"kwargs",
"=",
"{",
"'logGroupName'",
":",
"log_group_name"... | Download a log given the log's group and stream name.
Parameters
----------
log_group_name : str
The name of the log group, e.g. /aws/batch/job.
log_stream_name : str
The name of the log stream, e.g. run_reach_jobdef/default/<UUID>
Returns
-------
lines : list[str]
... | [
"Download",
"a",
"log",
"given",
"the",
"log",
"s",
"group",
"and",
"stream",
"name",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/aws.py#L156-L196 | train |
sorgerlab/indra | indra/util/aws.py | dump_logs | def dump_logs(job_queue='run_reach_queue', job_status='RUNNING'):
"""Write logs for all jobs with given the status to files."""
jobs = get_jobs(job_queue, job_status)
for job in jobs:
get_job_log(job, write_file=True) | python | def dump_logs(job_queue='run_reach_queue', job_status='RUNNING'):
"""Write logs for all jobs with given the status to files."""
jobs = get_jobs(job_queue, job_status)
for job in jobs:
get_job_log(job, write_file=True) | [
"def",
"dump_logs",
"(",
"job_queue",
"=",
"'run_reach_queue'",
",",
"job_status",
"=",
"'RUNNING'",
")",
":",
"jobs",
"=",
"get_jobs",
"(",
"job_queue",
",",
"job_status",
")",
"for",
"job",
"in",
"jobs",
":",
"get_job_log",
"(",
"job",
",",
"write_file",
... | Write logs for all jobs with given the status to files. | [
"Write",
"logs",
"for",
"all",
"jobs",
"with",
"given",
"the",
"status",
"to",
"files",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/aws.py#L199-L203 | train |
sorgerlab/indra | indra/util/aws.py | get_s3_file_tree | def get_s3_file_tree(s3, bucket, prefix):
"""Overcome s3 response limit and return NestedDict tree of paths.
The NestedDict object also allows the user to search by the ends of a path.
The tree mimics a file directory structure, with the leave nodes being the
full unbroken key. For example, 'path/to/f... | python | def get_s3_file_tree(s3, bucket, prefix):
"""Overcome s3 response limit and return NestedDict tree of paths.
The NestedDict object also allows the user to search by the ends of a path.
The tree mimics a file directory structure, with the leave nodes being the
full unbroken key. For example, 'path/to/f... | [
"def",
"get_s3_file_tree",
"(",
"s3",
",",
"bucket",
",",
"prefix",
")",
":",
"def",
"get_some_keys",
"(",
"keys",
",",
"marker",
"=",
"None",
")",
":",
"if",
"marker",
":",
"relevant_files",
"=",
"s3",
".",
"list_objects",
"(",
"Bucket",
"=",
"bucket",
... | Overcome s3 response limit and return NestedDict tree of paths.
The NestedDict object also allows the user to search by the ends of a path.
The tree mimics a file directory structure, with the leave nodes being the
full unbroken key. For example, 'path/to/file.txt' would be retrieved by
ret['path... | [
"Overcome",
"s3",
"response",
"limit",
"and",
"return",
"NestedDict",
"tree",
"of",
"paths",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/aws.py#L206-L248 | train |
sorgerlab/indra | indra/assemblers/sif/assembler.py | SifAssembler.print_model | def print_model(self, include_unsigned_edges=False):
"""Return a SIF string of the assembled model.
Parameters
----------
include_unsigned_edges : bool
If True, includes edges with an unknown activating/inactivating
relationship (e.g., most PTMs). Default is Fals... | python | def print_model(self, include_unsigned_edges=False):
"""Return a SIF string of the assembled model.
Parameters
----------
include_unsigned_edges : bool
If True, includes edges with an unknown activating/inactivating
relationship (e.g., most PTMs). Default is Fals... | [
"def",
"print_model",
"(",
"self",
",",
"include_unsigned_edges",
"=",
"False",
")",
":",
"sif_str",
"=",
"''",
"for",
"edge",
"in",
"self",
".",
"graph",
".",
"edges",
"(",
"data",
"=",
"True",
")",
":",
"n1",
"=",
"edge",
"[",
"0",
"]",
"n2",
"="... | Return a SIF string of the assembled model.
Parameters
----------
include_unsigned_edges : bool
If True, includes edges with an unknown activating/inactivating
relationship (e.g., most PTMs). Default is False. | [
"Return",
"a",
"SIF",
"string",
"of",
"the",
"assembled",
"model",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/sif/assembler.py#L98-L122 | train |
sorgerlab/indra | indra/assemblers/sif/assembler.py | SifAssembler.save_model | def save_model(self, fname, include_unsigned_edges=False):
"""Save the assembled model's SIF string into a file.
Parameters
----------
fname : str
The name of the file to save the SIF into.
include_unsigned_edges : bool
If True, includes edges with an unk... | python | def save_model(self, fname, include_unsigned_edges=False):
"""Save the assembled model's SIF string into a file.
Parameters
----------
fname : str
The name of the file to save the SIF into.
include_unsigned_edges : bool
If True, includes edges with an unk... | [
"def",
"save_model",
"(",
"self",
",",
"fname",
",",
"include_unsigned_edges",
"=",
"False",
")",
":",
"sif_str",
"=",
"self",
".",
"print_model",
"(",
"include_unsigned_edges",
")",
"with",
"open",
"(",
"fname",
",",
"'wb'",
")",
"as",
"fh",
":",
"fh",
... | Save the assembled model's SIF string into a file.
Parameters
----------
fname : str
The name of the file to save the SIF into.
include_unsigned_edges : bool
If True, includes edges with an unknown activating/inactivating
relationship (e.g., most PTMs... | [
"Save",
"the",
"assembled",
"model",
"s",
"SIF",
"string",
"into",
"a",
"file",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/sif/assembler.py#L124-L137 | train |
sorgerlab/indra | indra/assemblers/sif/assembler.py | SifAssembler.print_boolean_net | def print_boolean_net(self, out_file=None):
"""Return a Boolean network from the assembled graph.
See https://github.com/ialbert/booleannet for details about
the format used to encode the Boolean rules.
Parameters
----------
out_file : Optional[str]
A file n... | python | def print_boolean_net(self, out_file=None):
"""Return a Boolean network from the assembled graph.
See https://github.com/ialbert/booleannet for details about
the format used to encode the Boolean rules.
Parameters
----------
out_file : Optional[str]
A file n... | [
"def",
"print_boolean_net",
"(",
"self",
",",
"out_file",
"=",
"None",
")",
":",
"init_str",
"=",
"''",
"for",
"node_key",
"in",
"self",
".",
"graph",
".",
"nodes",
"(",
")",
":",
"node_name",
"=",
"self",
".",
"graph",
".",
"node",
"[",
"node_key",
... | Return a Boolean network from the assembled graph.
See https://github.com/ialbert/booleannet for details about
the format used to encode the Boolean rules.
Parameters
----------
out_file : Optional[str]
A file name in which the Boolean network is saved.
Ret... | [
"Return",
"a",
"Boolean",
"network",
"from",
"the",
"assembled",
"graph",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/sif/assembler.py#L183-L242 | train |
sorgerlab/indra | indra/literature/elsevier_client.py | _ensure_api_keys | def _ensure_api_keys(task_desc, failure_ret=None):
"""Wrap Elsevier methods which directly use the API keys.
Ensure that the keys are retrieved from the environment or config file when
first called, and store global scope. Subsequently use globally stashed
results and check for required ids.
"""
... | python | def _ensure_api_keys(task_desc, failure_ret=None):
"""Wrap Elsevier methods which directly use the API keys.
Ensure that the keys are retrieved from the environment or config file when
first called, and store global scope. Subsequently use globally stashed
results and check for required ids.
"""
... | [
"def",
"_ensure_api_keys",
"(",
"task_desc",
",",
"failure_ret",
"=",
"None",
")",
":",
"def",
"check_func_wrapper",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"check_api_keys",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"global"... | Wrap Elsevier methods which directly use the API keys.
Ensure that the keys are retrieved from the environment or config file when
first called, and store global scope. Subsequently use globally stashed
results and check for required ids. | [
"Wrap",
"Elsevier",
"methods",
"which",
"directly",
"use",
"the",
"API",
"keys",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/literature/elsevier_client.py#L51-L85 | train |
sorgerlab/indra | indra/literature/elsevier_client.py | check_entitlement | def check_entitlement(doi):
"""Check whether IP and credentials enable access to content for a doi.
This function uses the entitlement endpoint of the Elsevier API to check
whether an article is available to a given institution. Note that this
feature of the API is itself not available for all institut... | python | def check_entitlement(doi):
"""Check whether IP and credentials enable access to content for a doi.
This function uses the entitlement endpoint of the Elsevier API to check
whether an article is available to a given institution. Note that this
feature of the API is itself not available for all institut... | [
"def",
"check_entitlement",
"(",
"doi",
")",
":",
"if",
"doi",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"'doi:'",
")",
":",
"doi",
"=",
"doi",
"[",
"4",
":",
"]",
"url",
"=",
"'%s/%s'",
"%",
"(",
"elsevier_entitlement_url",
",",
"doi",
")",
... | Check whether IP and credentials enable access to content for a doi.
This function uses the entitlement endpoint of the Elsevier API to check
whether an article is available to a given institution. Note that this
feature of the API is itself not available for all institution keys. | [
"Check",
"whether",
"IP",
"and",
"credentials",
"enable",
"access",
"to",
"content",
"for",
"a",
"doi",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/literature/elsevier_client.py#L89-L106 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.