repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
veltzer/pytconf | pytconf/config.py | ParamCreator.create_bool | def create_bool(help_string=NO_HELP, default=NO_DEFAULT):
# type: (str, Union[bool, NO_DEFAULT_TYPE]) -> bool
"""
Create a bool parameter
:param help_string:
:param default:
:return:
"""
# noinspection PyTypeChecker
return ParamFunctions(
... | python | def create_bool(help_string=NO_HELP, default=NO_DEFAULT):
# type: (str, Union[bool, NO_DEFAULT_TYPE]) -> bool
"""
Create a bool parameter
:param help_string:
:param default:
:return:
"""
# noinspection PyTypeChecker
return ParamFunctions(
... | [
"def",
"create_bool",
"(",
"help_string",
"=",
"NO_HELP",
",",
"default",
"=",
"NO_DEFAULT",
")",
":",
"# type: (str, Union[bool, NO_DEFAULT_TYPE]) -> bool",
"# noinspection PyTypeChecker",
"return",
"ParamFunctions",
"(",
"help_string",
"=",
"help_string",
",",
"default",
... | Create a bool parameter
:param help_string:
:param default:
:return: | [
"Create",
"a",
"bool",
"parameter",
":",
"param",
"help_string",
":",
":",
"param",
"default",
":",
":",
"return",
":"
] | train | https://github.com/veltzer/pytconf/blob/8dee43ace35d0dd2ab1105fb94057f650393360f/pytconf/config.py#L711-L726 |
veltzer/pytconf | pytconf/config.py | ParamCreator.create_new_file | def create_new_file(help_string=NO_HELP, default=NO_DEFAULT, suffixes=None):
# type: (str, Union[str, NO_DEFAULT_TYPE], Union[List[str], None]) -> str
"""
Create a new file parameter
:param help_string:
:param default:
:param suffixes:
:return:
"""
... | python | def create_new_file(help_string=NO_HELP, default=NO_DEFAULT, suffixes=None):
# type: (str, Union[str, NO_DEFAULT_TYPE], Union[List[str], None]) -> str
"""
Create a new file parameter
:param help_string:
:param default:
:param suffixes:
:return:
"""
... | [
"def",
"create_new_file",
"(",
"help_string",
"=",
"NO_HELP",
",",
"default",
"=",
"NO_DEFAULT",
",",
"suffixes",
"=",
"None",
")",
":",
"# type: (str, Union[str, NO_DEFAULT_TYPE], Union[List[str], None]) -> str",
"# noinspection PyTypeChecker",
"return",
"ParamFilename",
"("... | Create a new file parameter
:param help_string:
:param default:
:param suffixes:
:return: | [
"Create",
"a",
"new",
"file",
"parameter",
":",
"param",
"help_string",
":",
":",
"param",
"default",
":",
":",
"param",
"suffixes",
":",
":",
"return",
":"
] | train | https://github.com/veltzer/pytconf/blob/8dee43ace35d0dd2ab1105fb94057f650393360f/pytconf/config.py#L729-L744 |
veltzer/pytconf | pytconf/config.py | ParamCreator.create_existing_file | def create_existing_file(help_string=NO_HELP, default=NO_DEFAULT, suffixes=None):
# type: (str, Union[str, NO_DEFAULT_TYPE], Union[List[str], None]) -> str
"""
Create a new file parameter
:param help_string:
:param default:
:param suffixes:
:return:
"""
... | python | def create_existing_file(help_string=NO_HELP, default=NO_DEFAULT, suffixes=None):
# type: (str, Union[str, NO_DEFAULT_TYPE], Union[List[str], None]) -> str
"""
Create a new file parameter
:param help_string:
:param default:
:param suffixes:
:return:
"""
... | [
"def",
"create_existing_file",
"(",
"help_string",
"=",
"NO_HELP",
",",
"default",
"=",
"NO_DEFAULT",
",",
"suffixes",
"=",
"None",
")",
":",
"# type: (str, Union[str, NO_DEFAULT_TYPE], Union[List[str], None]) -> str",
"# noinspection PyTypeChecker",
"return",
"ParamFilename",
... | Create a new file parameter
:param help_string:
:param default:
:param suffixes:
:return: | [
"Create",
"a",
"new",
"file",
"parameter",
":",
"param",
"help_string",
":",
":",
"param",
"default",
":",
":",
"param",
"suffixes",
":",
":",
"return",
":"
] | train | https://github.com/veltzer/pytconf/blob/8dee43ace35d0dd2ab1105fb94057f650393360f/pytconf/config.py#L747-L762 |
veltzer/pytconf | pytconf/config.py | ParamCreator.create_existing_folder | def create_existing_folder(help_string=NO_HELP, default=NO_DEFAULT, suffixes=None):
# type: (str, Union[str, NO_DEFAULT_TYPE], Union[List[str], None]) -> str
"""
Create a new folder parameter
:param help_string:
:param default:
:param suffixes:
:return:
""... | python | def create_existing_folder(help_string=NO_HELP, default=NO_DEFAULT, suffixes=None):
# type: (str, Union[str, NO_DEFAULT_TYPE], Union[List[str], None]) -> str
"""
Create a new folder parameter
:param help_string:
:param default:
:param suffixes:
:return:
""... | [
"def",
"create_existing_folder",
"(",
"help_string",
"=",
"NO_HELP",
",",
"default",
"=",
"NO_DEFAULT",
",",
"suffixes",
"=",
"None",
")",
":",
"# type: (str, Union[str, NO_DEFAULT_TYPE], Union[List[str], None]) -> str",
"# noinspection PyTypeChecker",
"return",
"ParamFilename"... | Create a new folder parameter
:param help_string:
:param default:
:param suffixes:
:return: | [
"Create",
"a",
"new",
"folder",
"parameter",
":",
"param",
"help_string",
":",
":",
"param",
"default",
":",
":",
"param",
"suffixes",
":",
":",
"return",
":"
] | train | https://github.com/veltzer/pytconf/blob/8dee43ace35d0dd2ab1105fb94057f650393360f/pytconf/config.py#L765-L780 |
veltzer/pytconf | pytconf/config.py | ParamCreator.create_choice | def create_choice(choice_list, help_string=NO_HELP, default=NO_DEFAULT):
# type: (List[str], str, Union[Any, NO_DEFAULT_TYPE]) -> str
"""
Create a choice config
:param choice_list:
:param help_string:
:param default:
:return:
"""
# noinspection PyT... | python | def create_choice(choice_list, help_string=NO_HELP, default=NO_DEFAULT):
# type: (List[str], str, Union[Any, NO_DEFAULT_TYPE]) -> str
"""
Create a choice config
:param choice_list:
:param help_string:
:param default:
:return:
"""
# noinspection PyT... | [
"def",
"create_choice",
"(",
"choice_list",
",",
"help_string",
"=",
"NO_HELP",
",",
"default",
"=",
"NO_DEFAULT",
")",
":",
"# type: (List[str], str, Union[Any, NO_DEFAULT_TYPE]) -> str",
"# noinspection PyTypeChecker",
"return",
"ParamChoice",
"(",
"help_string",
"=",
"he... | Create a choice config
:param choice_list:
:param help_string:
:param default:
:return: | [
"Create",
"a",
"choice",
"config",
":",
"param",
"choice_list",
":",
":",
"param",
"help_string",
":",
":",
"param",
"default",
":",
":",
"return",
":"
] | train | https://github.com/veltzer/pytconf/blob/8dee43ace35d0dd2ab1105fb94057f650393360f/pytconf/config.py#L783-L797 |
veltzer/pytconf | pytconf/config.py | ParamCreator.create_enum | def create_enum(enum_type, help_string=NO_HELP, default=NO_DEFAULT):
# type: (Type[Enum], str, Union[Any, NO_DEFAULT_TYPE]) -> Type[Enum]
"""
Create an enum config
:param enum_type:
:param help_string:
:param default:
:return:
"""
# noinspection Py... | python | def create_enum(enum_type, help_string=NO_HELP, default=NO_DEFAULT):
# type: (Type[Enum], str, Union[Any, NO_DEFAULT_TYPE]) -> Type[Enum]
"""
Create an enum config
:param enum_type:
:param help_string:
:param default:
:return:
"""
# noinspection Py... | [
"def",
"create_enum",
"(",
"enum_type",
",",
"help_string",
"=",
"NO_HELP",
",",
"default",
"=",
"NO_DEFAULT",
")",
":",
"# type: (Type[Enum], str, Union[Any, NO_DEFAULT_TYPE]) -> Type[Enum]",
"# noinspection PyTypeChecker",
"return",
"ParamEnum",
"(",
"help_string",
"=",
"... | Create an enum config
:param enum_type:
:param help_string:
:param default:
:return: | [
"Create",
"an",
"enum",
"config",
":",
"param",
"enum_type",
":",
":",
"param",
"help_string",
":",
":",
"param",
"default",
":",
":",
"return",
":"
] | train | https://github.com/veltzer/pytconf/blob/8dee43ace35d0dd2ab1105fb94057f650393360f/pytconf/config.py#L800-L814 |
veltzer/pytconf | pytconf/config.py | ParamCreator.create_enum_subset | def create_enum_subset(enum_type, help_string=NO_HELP, default=NO_DEFAULT):
# type: (Type[Enum], str, EnumSubset) -> EnumSubset
"""
Create an enum config
:param enum_type:
:param help_string:
:param default:
:return:
"""
# noinspection PyTypeChecke... | python | def create_enum_subset(enum_type, help_string=NO_HELP, default=NO_DEFAULT):
# type: (Type[Enum], str, EnumSubset) -> EnumSubset
"""
Create an enum config
:param enum_type:
:param help_string:
:param default:
:return:
"""
# noinspection PyTypeChecke... | [
"def",
"create_enum_subset",
"(",
"enum_type",
",",
"help_string",
"=",
"NO_HELP",
",",
"default",
"=",
"NO_DEFAULT",
")",
":",
"# type: (Type[Enum], str, EnumSubset) -> EnumSubset",
"# noinspection PyTypeChecker",
"return",
"ParamEnumSubset",
"(",
"help_string",
"=",
"help... | Create an enum config
:param enum_type:
:param help_string:
:param default:
:return: | [
"Create",
"an",
"enum",
"config",
":",
"param",
"enum_type",
":",
":",
"param",
"help_string",
":",
":",
"param",
"default",
":",
":",
"return",
":"
] | train | https://github.com/veltzer/pytconf/blob/8dee43ace35d0dd2ab1105fb94057f650393360f/pytconf/config.py#L817-L831 |
edwards-lab/MVtest | scripts/mvmany.py | check_and_append | def check_and_append(args, flag, new_args):
"""Simple meta collection of arguments passed to the script to be used for each job
:param args: argument collection generated by argparse
:param flag: actual flag to be checked for. If it isn't present in args, then the flag won't be added to new_args
:param ... | python | def check_and_append(args, flag, new_args):
"""Simple meta collection of arguments passed to the script to be used for each job
:param args: argument collection generated by argparse
:param flag: actual flag to be checked for. If it isn't present in args, then the flag won't be added to new_args
:param ... | [
"def",
"check_and_append",
"(",
"args",
",",
"flag",
",",
"new_args",
")",
":",
"try",
":",
"v",
"=",
"eval",
"(",
"\"args.%s\"",
"%",
"(",
"flag",
".",
"replace",
"(",
"\"-\"",
",",
"\"_\"",
")",
")",
")",
"if",
"v",
"is",
"not",
"None",
":",
"i... | Simple meta collection of arguments passed to the script to be used for each job
:param args: argument collection generated by argparse
:param flag: actual flag to be checked for. If it isn't present in args, then the flag won't be added to new_args
:param new_args: list of argument strings that should be u... | [
"Simple",
"meta",
"collection",
"of",
"arguments",
"passed",
"to",
"the",
"script",
"to",
"be",
"used",
"for",
"each",
"job",
":",
"param",
"args",
":",
"argument",
"collection",
"generated",
"by",
"argparse",
":",
"param",
"flag",
":",
"actual",
"flag",
"... | train | https://github.com/edwards-lab/MVtest/blob/fe8cf627464ef59d68b7eda628a19840d033882f/scripts/mvmany.py#L26-L42 |
edwards-lab/MVtest | scripts/mvmany.py | generate_jobs | def generate_jobs(args, job_list, argument_string):
"""Generate actual scripts to be submitted to the cluster
:param args: argparse argument collection
:param job_list: dictionary containing each each job to be submitted
:param argument_string: string containing general arguments to be used by mvtest.p... | python | def generate_jobs(args, job_list, argument_string):
"""Generate actual scripts to be submitted to the cluster
:param args: argparse argument collection
:param job_list: dictionary containing each each job to be submitted
:param argument_string: string containing general arguments to be used by mvtest.p... | [
"def",
"generate_jobs",
"(",
"args",
",",
"job_list",
",",
"argument_string",
")",
":",
"mvtest_path",
"=",
"args",
".",
"mvpath",
"template",
"=",
"\"\"",
".",
"join",
"(",
"args",
".",
"template",
".",
"readlines",
"(",
")",
")",
"logpath",
"=",
"os",
... | Generate actual scripts to be submitted to the cluster
:param args: argparse argument collection
:param job_list: dictionary containing each each job to be submitted
:param argument_string: string containing general arguments to be used by mvtest.py during execution
:return: None | [
"Generate",
"actual",
"scripts",
"to",
"be",
"submitted",
"to",
"the",
"cluster"
] | train | https://github.com/edwards-lab/MVtest/blob/fe8cf627464ef59d68b7eda628a19840d033882f/scripts/mvmany.py#L45-L73 |
edwards-lab/MVtest | scripts/mvmany.py | get_template_file | def get_template_file(args):
"""Returns valid template file, generating the default template file if it doesn't exist and one wasn't
specified on command line.
:param args: Argument collection as generated by parseargs
:return file"""
if args.template is None:
template_filename = os.geten... | python | def get_template_file(args):
"""Returns valid template file, generating the default template file if it doesn't exist and one wasn't
specified on command line.
:param args: Argument collection as generated by parseargs
:return file"""
if args.template is None:
template_filename = os.geten... | [
"def",
"get_template_file",
"(",
"args",
")",
":",
"if",
"args",
".",
"template",
"is",
"None",
":",
"template_filename",
"=",
"os",
".",
"getenv",
"(",
"\"HOME\"",
")",
"+",
"\"/.mvmany.template\"",
"try",
":",
"template_filename",
"=",
"open",
"(",
"templa... | Returns valid template file, generating the default template file if it doesn't exist and one wasn't
specified on command line.
:param args: Argument collection as generated by parseargs
:return file | [
"Returns",
"valid",
"template",
"file",
"generating",
"the",
"default",
"template",
"file",
"if",
"it",
"doesn",
"t",
"exist",
"and",
"one",
"wasn",
"t",
"specified",
"on",
"command",
"line",
"."
] | train | https://github.com/edwards-lab/MVtest/blob/fe8cf627464ef59d68b7eda628a19840d033882f/scripts/mvmany.py#L81-L111 |
edwards-lab/MVtest | scripts/mvmany.py | split_mach_jobs | def split_mach_jobs(args, filename):
"""Parse the MACH file and generate the list of jobs.
:param args: Arguments from parseargs
:param filename: name of file containing list of mach dosage files
:return jobs to be run
"""
max_snp_count = args.snps_per_job
job_list = {}
cur = None
... | python | def split_mach_jobs(args, filename):
"""Parse the MACH file and generate the list of jobs.
:param args: Arguments from parseargs
:param filename: name of file containing list of mach dosage files
:return jobs to be run
"""
max_snp_count = args.snps_per_job
job_list = {}
cur = None
... | [
"def",
"split_mach_jobs",
"(",
"args",
",",
"filename",
")",
":",
"max_snp_count",
"=",
"args",
".",
"snps_per_job",
"job_list",
"=",
"{",
"}",
"cur",
"=",
"None",
"last_pos",
"=",
"None",
"job_string",
"=",
"\"\"",
"job_name",
"=",
"\"\"",
"mach_count",
"... | Parse the MACH file and generate the list of jobs.
:param args: Arguments from parseargs
:param filename: name of file containing list of mach dosage files
:return jobs to be run | [
"Parse",
"the",
"MACH",
"file",
"and",
"generate",
"the",
"list",
"of",
"jobs",
"."
] | train | https://github.com/edwards-lab/MVtest/blob/fe8cf627464ef59d68b7eda628a19840d033882f/scripts/mvmany.py#L113-L148 |
edwards-lab/MVtest | scripts/mvmany.py | split_impute_jobs | def split_impute_jobs(args, filename):
"""Parse the IMPUTE file and generate the list of jobs.
:param args: parsearg object containing command line arguments
:filename args: file containing the IMPUTE gen files and chromosome numbers
"""
max_snp_count = args.snps_per_job
if args.impute_coun... | python | def split_impute_jobs(args, filename):
"""Parse the IMPUTE file and generate the list of jobs.
:param args: parsearg object containing command line arguments
:filename args: file containing the IMPUTE gen files and chromosome numbers
"""
max_snp_count = args.snps_per_job
if args.impute_coun... | [
"def",
"split_impute_jobs",
"(",
"args",
",",
"filename",
")",
":",
"max_snp_count",
"=",
"args",
".",
"snps_per_job",
"if",
"args",
".",
"impute_count",
":",
"impute_count",
"=",
"args",
".",
"impute_count",
"else",
":",
"impute_count",
"=",
"1",
"ExitIf",
... | Parse the IMPUTE file and generate the list of jobs.
:param args: parsearg object containing command line arguments
:filename args: file containing the IMPUTE gen files and chromosome numbers | [
"Parse",
"the",
"IMPUTE",
"file",
"and",
"generate",
"the",
"list",
"of",
"jobs",
"."
] | train | https://github.com/edwards-lab/MVtest/blob/fe8cf627464ef59d68b7eda628a19840d033882f/scripts/mvmany.py#L150-L241 |
edwards-lab/MVtest | scripts/mvmany.py | split_chrom_jobs | def split_chrom_jobs(args, chrom_file):
"""Split up GWAS jobs based on portions of a chromosome
:param args: arguments from parseargs
:param chrom_file: marker info file
:return dictionary name=>job_details
"""
max_snp_count = args.snps_per_job
poscol = 3
if args.map3:
poscol ... | python | def split_chrom_jobs(args, chrom_file):
"""Split up GWAS jobs based on portions of a chromosome
:param args: arguments from parseargs
:param chrom_file: marker info file
:return dictionary name=>job_details
"""
max_snp_count = args.snps_per_job
poscol = 3
if args.map3:
poscol ... | [
"def",
"split_chrom_jobs",
"(",
"args",
",",
"chrom_file",
")",
":",
"max_snp_count",
"=",
"args",
".",
"snps_per_job",
"poscol",
"=",
"3",
"if",
"args",
".",
"map3",
":",
"poscol",
"=",
"2",
"job_list",
"=",
"{",
"}",
"cur",
"=",
"None",
"last_pos",
"... | Split up GWAS jobs based on portions of a chromosome
:param args: arguments from parseargs
:param chrom_file: marker info file
:return dictionary name=>job_details | [
"Split",
"up",
"GWAS",
"jobs",
"based",
"on",
"portions",
"of",
"a",
"chromosome"
] | train | https://github.com/edwards-lab/MVtest/blob/fe8cf627464ef59d68b7eda628a19840d033882f/scripts/mvmany.py#L243-L300 |
edwards-lab/MVtest | scripts/mvmany.py | main | def main(print_cfg):
"""Main function which parses user options and generate jobs accordingly"""
parser = argparse.ArgumentParser(description="mvmany.py -- MVtest helper script.", epilog="""
mvmany.py should be run with all arguments you would pass to mvtest.py, except
for those which are specific to a single n... | python | def main(print_cfg):
"""Main function which parses user options and generate jobs accordingly"""
parser = argparse.ArgumentParser(description="mvmany.py -- MVtest helper script.", epilog="""
mvmany.py should be run with all arguments you would pass to mvtest.py, except
for those which are specific to a single n... | [
"def",
"main",
"(",
"print_cfg",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"mvmany.py -- MVtest helper script.\"",
",",
"epilog",
"=",
"\"\"\"\nmvmany.py should be run with all arguments you would pass to mvtest.py, except\nfor those w... | Main function which parses user options and generate jobs accordingly | [
"Main",
"function",
"which",
"parses",
"user",
"options",
"and",
"generate",
"jobs",
"accordingly"
] | train | https://github.com/edwards-lab/MVtest/blob/fe8cf627464ef59d68b7eda628a19840d033882f/scripts/mvmany.py#L302-L452 |
CS207-Final-Project-Group-10/cs207-FinalProject | fluxions/fluxion_node.py | Fluxion.diff | def diff(self, *args):
"""Call forward_mode; discard value, only keep the derivative."""
arg_dicts = self._parse_args_forward_mode(*args)
val, diff = self._forward_mode(*arg_dicts)
return diff | python | def diff(self, *args):
"""Call forward_mode; discard value, only keep the derivative."""
arg_dicts = self._parse_args_forward_mode(*args)
val, diff = self._forward_mode(*arg_dicts)
return diff | [
"def",
"diff",
"(",
"self",
",",
"*",
"args",
")",
":",
"arg_dicts",
"=",
"self",
".",
"_parse_args_forward_mode",
"(",
"*",
"args",
")",
"val",
",",
"diff",
"=",
"self",
".",
"_forward_mode",
"(",
"*",
"arg_dicts",
")",
"return",
"diff"
] | Call forward_mode; discard value, only keep the derivative. | [
"Call",
"forward_mode",
";",
"discard",
"value",
"only",
"keep",
"the",
"derivative",
"."
] | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/fluxions/fluxion_node.py#L58-L62 |
CS207-Final-Project-Group-10/cs207-FinalProject | fluxions/fluxion_node.py | Fluxion._parse_args_forward_mode | def _parse_args_forward_mode(self, *args) -> Tuple[dict, dict]:
"""
Parse input arguments used in forward mode differentiation.
End result will be two arrays X and dX, each of shape (n) or (T, n)
Allowed input shapes are:
(1) ARRAY_N: two arrays of size n
(2) ARRAY_TxN... | python | def _parse_args_forward_mode(self, *args) -> Tuple[dict, dict]:
"""
Parse input arguments used in forward mode differentiation.
End result will be two arrays X and dX, each of shape (n) or (T, n)
Allowed input shapes are:
(1) ARRAY_N: two arrays of size n
(2) ARRAY_TxN... | [
"def",
"_parse_args_forward_mode",
"(",
"self",
",",
"*",
"args",
")",
"->",
"Tuple",
"[",
"dict",
",",
"dict",
"]",
":",
"# Types for arg_vars and arg_seed",
"arg_vars",
":",
"np",
".",
"ndarray",
"=",
"{",
"}",
"arg_seed",
":",
"np",
".",
"ndarray",
"=",... | Parse input arguments used in forward mode differentiation.
End result will be two arrays X and dX, each of shape (n) or (T, n)
Allowed input shapes are:
(1) ARRAY_N: two arrays of size n
(2) ARRAY_TxN: two arrays of size Txn
(3) DICT: two dictionaries, each mapping var... | [
"Parse",
"input",
"arguments",
"used",
"in",
"forward",
"mode",
"differentiation",
".",
"End",
"result",
"will",
"be",
"two",
"arrays",
"X",
"and",
"dX",
"each",
"of",
"shape",
"(",
"n",
")",
"or",
"(",
"T",
"n",
")",
"Allowed",
"input",
"shapes",
"are... | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/fluxions/fluxion_node.py#L82-L156 |
CS207-Final-Project-Group-10/cs207-FinalProject | fluxions/fluxion_node.py | Fluxion._default_seed | def _default_seed(self, var_tbl: dict) -> dict:
"""
Returns inferred dict of variable: val = 1 pairs
"""
var_names = {}
#for v in self.var_names:
# var_names[v]=1
for v in var_tbl:
var_names[v]=1
return var_names | python | def _default_seed(self, var_tbl: dict) -> dict:
"""
Returns inferred dict of variable: val = 1 pairs
"""
var_names = {}
#for v in self.var_names:
# var_names[v]=1
for v in var_tbl:
var_names[v]=1
return var_names | [
"def",
"_default_seed",
"(",
"self",
",",
"var_tbl",
":",
"dict",
")",
"->",
"dict",
":",
"var_names",
"=",
"{",
"}",
"#for v in self.var_names:",
"# var_names[v]=1",
"for",
"v",
"in",
"var_tbl",
":",
"var_names",
"[",
"v",
"]",
"=",
"1",
"return",
"var... | Returns inferred dict of variable: val = 1 pairs | [
"Returns",
"inferred",
"dict",
"of",
"variable",
":",
"val",
"=",
"1",
"pairs"
] | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/fluxions/fluxion_node.py#L158-L167 |
CS207-Final-Project-Group-10/cs207-FinalProject | fluxions/fluxion_node.py | Fluxion._parse_var_dict | def _parse_var_dict(self, var_tbl: dict) -> dict:
"""
Create an extended list of variable names including any pre-bound ones
Throws an error if a variable is unbound
Returns inferred dict of variable: val pairs
"""
var_names = var_tbl.copy()
# check that all of th... | python | def _parse_var_dict(self, var_tbl: dict) -> dict:
"""
Create an extended list of variable names including any pre-bound ones
Throws an error if a variable is unbound
Returns inferred dict of variable: val pairs
"""
var_names = var_tbl.copy()
# check that all of th... | [
"def",
"_parse_var_dict",
"(",
"self",
",",
"var_tbl",
":",
"dict",
")",
"->",
"dict",
":",
"var_names",
"=",
"var_tbl",
".",
"copy",
"(",
")",
"# check that all of the variables are bound",
"for",
"v",
"in",
"self",
".",
"var_names",
":",
"if",
"v",
"not",
... | Create an extended list of variable names including any pre-bound ones
Throws an error if a variable is unbound
Returns inferred dict of variable: val pairs | [
"Create",
"an",
"extended",
"list",
"of",
"variable",
"names",
"including",
"any",
"pre",
"-",
"bound",
"ones",
"Throws",
"an",
"error",
"if",
"a",
"variable",
"is",
"unbound",
"Returns",
"inferred",
"dict",
"of",
"variable",
":",
"val",
"pairs"
] | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/fluxions/fluxion_node.py#L169-L184 |
CS207-Final-Project-Group-10/cs207-FinalProject | fluxions/fluxion_node.py | Fluxion._parse_seed_dict | def _parse_seed_dict(self, var_tbl: dict) -> dict:
"""
Create an extended list of variable names including any pre-bound ones
Throws an error if a variable is unbound
Returns inferred dict of variable: val pairs
"""
var_names = var_tbl.copy()
# check that all of t... | python | def _parse_seed_dict(self, var_tbl: dict) -> dict:
"""
Create an extended list of variable names including any pre-bound ones
Throws an error if a variable is unbound
Returns inferred dict of variable: val pairs
"""
var_names = var_tbl.copy()
# check that all of t... | [
"def",
"_parse_seed_dict",
"(",
"self",
",",
"var_tbl",
":",
"dict",
")",
"->",
"dict",
":",
"var_names",
"=",
"var_tbl",
".",
"copy",
"(",
")",
"# check that all of the variables are bound",
"for",
"v",
"in",
"self",
".",
"var_names",
":",
"if",
"v",
"not",... | Create an extended list of variable names including any pre-bound ones
Throws an error if a variable is unbound
Returns inferred dict of variable: val pairs | [
"Create",
"an",
"extended",
"list",
"of",
"variable",
"names",
"including",
"any",
"pre",
"-",
"bound",
"ones",
"Throws",
"an",
"error",
"if",
"a",
"variable",
"is",
"unbound",
"Returns",
"inferred",
"dict",
"of",
"variable",
":",
"val",
"pairs"
] | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/fluxions/fluxion_node.py#L186-L198 |
CS207-Final-Project-Group-10/cs207-FinalProject | fluxions/fluxion_node.py | Fluxion._squeeze | def _squeeze(self, var_tbl: dict) -> dict:
"""
Makes sure no extra dimensions are floating around in the input arrays
Returns inferred dict of variable: val pairs
"""
var_names = var_tbl.copy()
# squeeze any numpy arrays
for v in var_tbl:
val = var_tbl... | python | def _squeeze(self, var_tbl: dict) -> dict:
"""
Makes sure no extra dimensions are floating around in the input arrays
Returns inferred dict of variable: val pairs
"""
var_names = var_tbl.copy()
# squeeze any numpy arrays
for v in var_tbl:
val = var_tbl... | [
"def",
"_squeeze",
"(",
"self",
",",
"var_tbl",
":",
"dict",
")",
"->",
"dict",
":",
"var_names",
"=",
"var_tbl",
".",
"copy",
"(",
")",
"# squeeze any numpy arrays",
"for",
"v",
"in",
"var_tbl",
":",
"val",
"=",
"var_tbl",
"[",
"v",
"]",
"if",
"isinst... | Makes sure no extra dimensions are floating around in the input arrays
Returns inferred dict of variable: val pairs | [
"Makes",
"sure",
"no",
"extra",
"dimensions",
"are",
"floating",
"around",
"in",
"the",
"input",
"arrays",
"Returns",
"inferred",
"dict",
"of",
"variable",
":",
"val",
"pairs"
] | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/fluxions/fluxion_node.py#L200-L211 |
CS207-Final-Project-Group-10/cs207-FinalProject | fluxions/fluxion_node.py | Fluxion._parse_var_scalar | def _parse_var_scalar(self, X: scalar_type) -> dict:
"""
Unpack the numpy array and bind each column to one of the variables in self.var_names
Returns inferred dict of variable: val pairs
"""
arg_vars = {}
#there is only one var name, so this will run once and no sorting ... | python | def _parse_var_scalar(self, X: scalar_type) -> dict:
"""
Unpack the numpy array and bind each column to one of the variables in self.var_names
Returns inferred dict of variable: val pairs
"""
arg_vars = {}
#there is only one var name, so this will run once and no sorting ... | [
"def",
"_parse_var_scalar",
"(",
"self",
",",
"X",
":",
"scalar_type",
")",
"->",
"dict",
":",
"arg_vars",
"=",
"{",
"}",
"#there is only one var name, so this will run once and no sorting is required",
"for",
"var_name",
"in",
"self",
".",
"var_names",
":",
"arg_vars... | Unpack the numpy array and bind each column to one of the variables in self.var_names
Returns inferred dict of variable: val pairs | [
"Unpack",
"the",
"numpy",
"array",
"and",
"bind",
"each",
"column",
"to",
"one",
"of",
"the",
"variables",
"in",
"self",
".",
"var_names",
"Returns",
"inferred",
"dict",
"of",
"variable",
":",
"val",
"pairs"
] | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/fluxions/fluxion_node.py#L213-L222 |
CS207-Final-Project-Group-10/cs207-FinalProject | fluxions/fluxion_node.py | Fluxion._parse_var_array | def _parse_var_array(self, X: np.ndarray) -> dict:
"""
Unpack the numpy array and bind each column to one of the variables in self.var_names
Returns inferred dict of variable: val pairs
"""
arg_vars = {}
# Get the shape and tensor rank
shape = X.shape
tens... | python | def _parse_var_array(self, X: np.ndarray) -> dict:
"""
Unpack the numpy array and bind each column to one of the variables in self.var_names
Returns inferred dict of variable: val pairs
"""
arg_vars = {}
# Get the shape and tensor rank
shape = X.shape
tens... | [
"def",
"_parse_var_array",
"(",
"self",
",",
"X",
":",
"np",
".",
"ndarray",
")",
"->",
"dict",
":",
"arg_vars",
"=",
"{",
"}",
"# Get the shape and tensor rank",
"shape",
"=",
"X",
".",
"shape",
"tensor_rank",
"=",
"len",
"(",
"shape",
")",
"T",
"=",
... | Unpack the numpy array and bind each column to one of the variables in self.var_names
Returns inferred dict of variable: val pairs | [
"Unpack",
"the",
"numpy",
"array",
"and",
"bind",
"each",
"column",
"to",
"one",
"of",
"the",
"variables",
"in",
"self",
".",
"var_names",
"Returns",
"inferred",
"dict",
"of",
"variable",
":",
"val",
"pairs"
] | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/fluxions/fluxion_node.py#L224-L248 |
CS207-Final-Project-Group-10/cs207-FinalProject | fluxions/fluxion_node.py | Fluxion._check_forward_mode_input_dict | def _check_forward_mode_input_dict(self, var_tbl: dict) -> int:
"""
Check whether one forward mode input dict has elements of valid shape
Returns inferred value of T
"""
T: int = 1
for var_name in var_tbl:
# The bound value to this variable name
va... | python | def _check_forward_mode_input_dict(self, var_tbl: dict) -> int:
"""
Check whether one forward mode input dict has elements of valid shape
Returns inferred value of T
"""
T: int = 1
for var_name in var_tbl:
# The bound value to this variable name
va... | [
"def",
"_check_forward_mode_input_dict",
"(",
"self",
",",
"var_tbl",
":",
"dict",
")",
"->",
"int",
":",
"T",
":",
"int",
"=",
"1",
"for",
"var_name",
"in",
"var_tbl",
":",
"# The bound value to this variable name",
"val",
"=",
"var_tbl",
"[",
"var_name",
"]"... | Check whether one forward mode input dict has elements of valid shape
Returns inferred value of T | [
"Check",
"whether",
"one",
"forward",
"mode",
"input",
"dict",
"has",
"elements",
"of",
"valid",
"shape",
"Returns",
"inferred",
"value",
"of",
"T"
] | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/fluxions/fluxion_node.py#L250-L273 |
CS207-Final-Project-Group-10/cs207-FinalProject | fluxions/fluxion_node.py | Fluxion._check_forward_mode_input_array | def _check_forward_mode_input_array(self, X: np.ndarray) -> int:
"""
Check whether one forward mode input array is of valid shape
Returns inferred value of T
"""
# Find the length of each variable to infer T
if not isinstance(X, np.ndarray):
raise ValueError('... | python | def _check_forward_mode_input_array(self, X: np.ndarray) -> int:
"""
Check whether one forward mode input array is of valid shape
Returns inferred value of T
"""
# Find the length of each variable to infer T
if not isinstance(X, np.ndarray):
raise ValueError('... | [
"def",
"_check_forward_mode_input_array",
"(",
"self",
",",
"X",
":",
"np",
".",
"ndarray",
")",
"->",
"int",
":",
"# Find the length of each variable to infer T",
"if",
"not",
"isinstance",
"(",
"X",
",",
"np",
".",
"ndarray",
")",
":",
"raise",
"ValueError",
... | Check whether one forward mode input array is of valid shape
Returns inferred value of T | [
"Check",
"whether",
"one",
"forward",
"mode",
"input",
"array",
"is",
"of",
"valid",
"shape",
"Returns",
"inferred",
"value",
"of",
"T"
] | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/fluxions/fluxion_node.py#L275-L305 |
CS207-Final-Project-Group-10/cs207-FinalProject | fluxions/fluxion_node.py | Fluxion._calc_T_var | def _calc_T_var(self,X) -> int:
"""Calculate the number of samples, T, from the shape of X"""
shape = X.shape
tensor_rank: int = len(shape)
if tensor_rank == 0:
return 1
if tensor_rank == 1:
return shape[0]
if tensor_rank == 2:
if shape... | python | def _calc_T_var(self,X) -> int:
"""Calculate the number of samples, T, from the shape of X"""
shape = X.shape
tensor_rank: int = len(shape)
if tensor_rank == 0:
return 1
if tensor_rank == 1:
return shape[0]
if tensor_rank == 2:
if shape... | [
"def",
"_calc_T_var",
"(",
"self",
",",
"X",
")",
"->",
"int",
":",
"shape",
"=",
"X",
".",
"shape",
"tensor_rank",
":",
"int",
"=",
"len",
"(",
"shape",
")",
"if",
"tensor_rank",
"==",
"0",
":",
"return",
"1",
"if",
"tensor_rank",
"==",
"1",
":",
... | Calculate the number of samples, T, from the shape of X | [
"Calculate",
"the",
"number",
"of",
"samples",
"T",
"from",
"the",
"shape",
"of",
"X"
] | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/fluxions/fluxion_node.py#L307-L318 |
CS207-Final-Project-Group-10/cs207-FinalProject | fluxions/fluxion_node.py | Const._forward_mode | def _forward_mode(self, *args):
"""Forward mode differentiation for a constant"""
# Return the bound value and a derivative of zero regardless of the argumetns passed
val: float = self.a
diff: float = 0.0
return (val, diff) | python | def _forward_mode(self, *args):
"""Forward mode differentiation for a constant"""
# Return the bound value and a derivative of zero regardless of the argumetns passed
val: float = self.a
diff: float = 0.0
return (val, diff) | [
"def",
"_forward_mode",
"(",
"self",
",",
"*",
"args",
")",
":",
"# Return the bound value and a derivative of zero regardless of the argumetns passed",
"val",
":",
"float",
"=",
"self",
".",
"a",
"diff",
":",
"float",
"=",
"0.0",
"return",
"(",
"val",
",",
"diff"... | Forward mode differentiation for a constant | [
"Forward",
"mode",
"differentiation",
"for",
"a",
"constant"
] | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/fluxions/fluxion_node.py#L391-L396 |
CS207-Final-Project-Group-10/cs207-FinalProject | fluxions/fluxion_node.py | Power._forward_mode | def _forward_mode(self, *args):
"""Forward mode differentiation for a constant"""
# Evaluate inner function self.f
X: np.ndarray
dX: np.ndarray
X, dX = self.f._forward_mode(*args)
# Alias the power to p for legibility
p: float = self.p
# The function value... | python | def _forward_mode(self, *args):
"""Forward mode differentiation for a constant"""
# Evaluate inner function self.f
X: np.ndarray
dX: np.ndarray
X, dX = self.f._forward_mode(*args)
# Alias the power to p for legibility
p: float = self.p
# The function value... | [
"def",
"_forward_mode",
"(",
"self",
",",
"*",
"args",
")",
":",
"# Evaluate inner function self.f",
"X",
":",
"np",
".",
"ndarray",
"dX",
":",
"np",
".",
"ndarray",
"X",
",",
"dX",
"=",
"self",
".",
"f",
".",
"_forward_mode",
"(",
"*",
"args",
")",
... | Forward mode differentiation for a constant | [
"Forward",
"mode",
"differentiation",
"for",
"a",
"constant"
] | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/fluxions/fluxion_node.py#L419-L431 |
CS207-Final-Project-Group-10/cs207-FinalProject | fluxions/fluxion_node.py | Addition._forward_mode | def _forward_mode(self, *args):
"""Forward mode differentiation for a sum"""
# (f+g)(x) = f(x) + g(x)
f_val, f_diff = self.f._forward_mode(*args)
g_val, g_diff = self.g._forward_mode(*args)
# The function value and derivative is the sum of f and g
val = f_val + g_val
... | python | def _forward_mode(self, *args):
"""Forward mode differentiation for a sum"""
# (f+g)(x) = f(x) + g(x)
f_val, f_diff = self.f._forward_mode(*args)
g_val, g_diff = self.g._forward_mode(*args)
# The function value and derivative is the sum of f and g
val = f_val + g_val
... | [
"def",
"_forward_mode",
"(",
"self",
",",
"*",
"args",
")",
":",
"# (f+g)(x) = f(x) + g(x)",
"f_val",
",",
"f_diff",
"=",
"self",
".",
"f",
".",
"_forward_mode",
"(",
"*",
"args",
")",
"g_val",
",",
"g_diff",
"=",
"self",
".",
"g",
".",
"_forward_mode",
... | Forward mode differentiation for a sum | [
"Forward",
"mode",
"differentiation",
"for",
"a",
"sum"
] | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/fluxions/fluxion_node.py#L473-L481 |
CS207-Final-Project-Group-10/cs207-FinalProject | fluxions/fluxion_node.py | Var._forward_mode | def _forward_mode(self, *args):
"""Forward mode differentiation for variables"""
# Parse arguments into two numpy arrays
X: np.ndarray
dX: np.ndarray
X, dX = self._parse_dicts(*args)
# The value is X
if X is not None:
val = X
else:
... | python | def _forward_mode(self, *args):
"""Forward mode differentiation for variables"""
# Parse arguments into two numpy arrays
X: np.ndarray
dX: np.ndarray
X, dX = self._parse_dicts(*args)
# The value is X
if X is not None:
val = X
else:
... | [
"def",
"_forward_mode",
"(",
"self",
",",
"*",
"args",
")",
":",
"# Parse arguments into two numpy arrays",
"X",
":",
"np",
".",
"ndarray",
"dX",
":",
"np",
".",
"ndarray",
"X",
",",
"dX",
"=",
"self",
".",
"_parse_dicts",
"(",
"*",
"args",
")",
"# The v... | Forward mode differentiation for variables | [
"Forward",
"mode",
"differentiation",
"for",
"variables"
] | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/fluxions/fluxion_node.py#L580-L597 |
CS207-Final-Project-Group-10/cs207-FinalProject | fluxions/fluxion_node.py | Var._parse_dicts | def _parse_dicts(self, *args) -> Tuple[np.ndarray, np.ndarray]:
"""
Parse input arguments used in function evaluation.
End result will be two arrays X of shape (m) or (T, m)
Allowed input shapes are:
(1) DICT: dictionary mapping variable names to values
(2) ARGS: ... | python | def _parse_dicts(self, *args) -> Tuple[np.ndarray, np.ndarray]:
"""
Parse input arguments used in function evaluation.
End result will be two arrays X of shape (m) or (T, m)
Allowed input shapes are:
(1) DICT: dictionary mapping variable names to values
(2) ARGS: ... | [
"def",
"_parse_dicts",
"(",
"self",
",",
"*",
"args",
")",
"->",
"Tuple",
"[",
"np",
".",
"ndarray",
",",
"np",
".",
"ndarray",
"]",
":",
"# initialize the X variable that will be returned",
"X",
":",
"np",
".",
"ndarray",
"dX",
":",
"np",
".",
"ndarray",
... | Parse input arguments used in function evaluation.
End result will be two arrays X of shape (m) or (T, m)
Allowed input shapes are:
(1) DICT: dictionary mapping variable names to values
(2) ARGS: 2 dictionaries mapping variable names to values | [
"Parse",
"input",
"arguments",
"used",
"in",
"function",
"evaluation",
".",
"End",
"result",
"will",
"be",
"two",
"arrays",
"X",
"of",
"shape",
"(",
"m",
")",
"or",
"(",
"T",
"m",
")",
"Allowed",
"input",
"shapes",
"are",
":",
"(",
"1",
")",
"DICT",
... | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/fluxions/fluxion_node.py#L599-L629 |
CS207-Final-Project-Group-10/cs207-FinalProject | fluxions/fluxion_node.py | Var._parse_vars_tbl | def _parse_vars_tbl(self, var_tbl):
"""Parse a table of variable bindings (dictionary with key = variable name)"""
# Find the length of each variable to infer T
T = self._check_forward_mode_input_dict(var_tbl)
# The shape of X based on T and m
shape = (T, 1)
# Initializ... | python | def _parse_vars_tbl(self, var_tbl):
"""Parse a table of variable bindings (dictionary with key = variable name)"""
# Find the length of each variable to infer T
T = self._check_forward_mode_input_dict(var_tbl)
# The shape of X based on T and m
shape = (T, 1)
# Initializ... | [
"def",
"_parse_vars_tbl",
"(",
"self",
",",
"var_tbl",
")",
":",
"# Find the length of each variable to infer T",
"T",
"=",
"self",
".",
"_check_forward_mode_input_dict",
"(",
"var_tbl",
")",
"# The shape of X based on T and m",
"shape",
"=",
"(",
"T",
",",
"1",
")",
... | Parse a table of variable bindings (dictionary with key = variable name) | [
"Parse",
"a",
"table",
"of",
"variable",
"bindings",
"(",
"dictionary",
"with",
"key",
"=",
"variable",
"name",
")"
] | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/fluxions/fluxion_node.py#L631-L642 |
CS207-Final-Project-Group-10/cs207-FinalProject | fluxions/fluxion_node.py | Var._parse_seed_tbl | def _parse_seed_tbl(self, var_tbl):
"""Parse a table of variable bindings (dictionary with key = variable name)"""
m: int = len(var_tbl)
# Find the length of each variable to infer T
T = self._check_forward_mode_input_dict(var_tbl)
# The shape of X based on T and m
shap... | python | def _parse_seed_tbl(self, var_tbl):
"""Parse a table of variable bindings (dictionary with key = variable name)"""
m: int = len(var_tbl)
# Find the length of each variable to infer T
T = self._check_forward_mode_input_dict(var_tbl)
# The shape of X based on T and m
shap... | [
"def",
"_parse_seed_tbl",
"(",
"self",
",",
"var_tbl",
")",
":",
"m",
":",
"int",
"=",
"len",
"(",
"var_tbl",
")",
"# Find the length of each variable to infer T",
"T",
"=",
"self",
".",
"_check_forward_mode_input_dict",
"(",
"var_tbl",
")",
"# The shape of X based ... | Parse a table of variable bindings (dictionary with key = variable name) | [
"Parse",
"a",
"table",
"of",
"variable",
"bindings",
"(",
"dictionary",
"with",
"key",
"=",
"variable",
"name",
")"
] | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/fluxions/fluxion_node.py#L644-L660 |
inveniosoftware-attic/invenio-upgrader | invenio_upgrader/cli.py | run | def run():
"""Command for applying upgrades."""
logfilename = os.path.join(current_app.config['CFG_LOGDIR'],
'invenio_upgrader.log')
upgrader = InvenioUpgrader()
logger = upgrader.get_logger(logfilename=logfilename)
try:
upgrades = upgrader.get_upgrades()
... | python | def run():
"""Command for applying upgrades."""
logfilename = os.path.join(current_app.config['CFG_LOGDIR'],
'invenio_upgrader.log')
upgrader = InvenioUpgrader()
logger = upgrader.get_logger(logfilename=logfilename)
try:
upgrades = upgrader.get_upgrades()
... | [
"def",
"run",
"(",
")",
":",
"logfilename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"current_app",
".",
"config",
"[",
"'CFG_LOGDIR'",
"]",
",",
"'invenio_upgrader.log'",
")",
"upgrader",
"=",
"InvenioUpgrader",
"(",
")",
"logger",
"=",
"upgrader",
".",
... | Command for applying upgrades. | [
"Command",
"for",
"applying",
"upgrades",
"."
] | train | https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/cli.py#L99-L146 |
inveniosoftware-attic/invenio-upgrader | invenio_upgrader/cli.py | check | def check():
"""Command for checking upgrades."""
upgrader = InvenioUpgrader()
logger = upgrader.get_logger()
try:
# Run upgrade pre-checks
upgrades = upgrader.get_upgrades()
# Check if there's anything to upgrade
if not upgrades:
logger.info("All upgrades h... | python | def check():
"""Command for checking upgrades."""
upgrader = InvenioUpgrader()
logger = upgrader.get_logger()
try:
# Run upgrade pre-checks
upgrades = upgrader.get_upgrades()
# Check if there's anything to upgrade
if not upgrades:
logger.info("All upgrades h... | [
"def",
"check",
"(",
")",
":",
"upgrader",
"=",
"InvenioUpgrader",
"(",
")",
"logger",
"=",
"upgrader",
".",
"get_logger",
"(",
")",
"try",
":",
"# Run upgrade pre-checks",
"upgrades",
"=",
"upgrader",
".",
"get_upgrades",
"(",
")",
"# Check if there's anything ... | Command for checking upgrades. | [
"Command",
"for",
"checking",
"upgrades",
"."
] | train | https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/cli.py#L151-L178 |
inveniosoftware-attic/invenio-upgrader | invenio_upgrader/cli.py | pending | def pending():
"""Command for showing upgrades ready to be applied."""
upgrader = InvenioUpgrader()
logger = upgrader.get_logger()
try:
upgrades = upgrader.get_upgrades()
if not upgrades:
logger.info("All upgrades have been applied.")
return
logger.info... | python | def pending():
"""Command for showing upgrades ready to be applied."""
upgrader = InvenioUpgrader()
logger = upgrader.get_logger()
try:
upgrades = upgrader.get_upgrades()
if not upgrades:
logger.info("All upgrades have been applied.")
return
logger.info... | [
"def",
"pending",
"(",
")",
":",
"upgrader",
"=",
"InvenioUpgrader",
"(",
")",
"logger",
"=",
"upgrader",
".",
"get_logger",
"(",
")",
"try",
":",
"upgrades",
"=",
"upgrader",
".",
"get_upgrades",
"(",
")",
"if",
"not",
"upgrades",
":",
"logger",
".",
... | Command for showing upgrades ready to be applied. | [
"Command",
"for",
"showing",
"upgrades",
"ready",
"to",
"be",
"applied",
"."
] | train | https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/cli.py#L183-L203 |
inveniosoftware-attic/invenio-upgrader | invenio_upgrader/cli.py | applied | def applied():
"""Command for showing all upgrades already applied."""
upgrader = InvenioUpgrader()
logger = upgrader.get_logger()
try:
upgrades = upgrader.get_history()
if not upgrades:
logger.info("No upgrades have been applied.")
return
logger.info("... | python | def applied():
"""Command for showing all upgrades already applied."""
upgrader = InvenioUpgrader()
logger = upgrader.get_logger()
try:
upgrades = upgrader.get_history()
if not upgrades:
logger.info("No upgrades have been applied.")
return
logger.info("... | [
"def",
"applied",
"(",
")",
":",
"upgrader",
"=",
"InvenioUpgrader",
"(",
")",
"logger",
"=",
"upgrader",
".",
"get_logger",
"(",
")",
"try",
":",
"upgrades",
"=",
"upgrader",
".",
"get_history",
"(",
")",
"if",
"not",
"upgrades",
":",
"logger",
".",
"... | Command for showing all upgrades already applied. | [
"Command",
"for",
"showing",
"all",
"upgrades",
"already",
"applied",
"."
] | train | https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/cli.py#L208-L227 |
inveniosoftware-attic/invenio-upgrader | invenio_upgrader/cli.py | release | def release(path, repository):
"""Create a new release upgrade recipe, for developers."""
upgrader = InvenioUpgrader()
logger = upgrader.get_logger()
try:
endpoints = upgrader.find_endpoints()
if not endpoints:
logger.error("No upgrades found.")
click.Abort()
... | python | def release(path, repository):
"""Create a new release upgrade recipe, for developers."""
upgrader = InvenioUpgrader()
logger = upgrader.get_logger()
try:
endpoints = upgrader.find_endpoints()
if not endpoints:
logger.error("No upgrades found.")
click.Abort()
... | [
"def",
"release",
"(",
"path",
",",
"repository",
")",
":",
"upgrader",
"=",
"InvenioUpgrader",
"(",
")",
"logger",
"=",
"upgrader",
".",
"get_logger",
"(",
")",
"try",
":",
"endpoints",
"=",
"upgrader",
".",
"find_endpoints",
"(",
")",
"if",
"not",
"end... | Create a new release upgrade recipe, for developers. | [
"Create",
"a",
"new",
"release",
"upgrade",
"recipe",
"for",
"developers",
"."
] | train | https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/cli.py#L234-L259 |
inveniosoftware-attic/invenio-upgrader | invenio_upgrader/cli.py | recipe | def recipe(package, repository=None, depends_on=None, release=False,
output_path=None, auto=False, overwrite=False, name=None):
"""Create a new upgrade recipe, for developers."""
upgrader = InvenioUpgrader()
logger = upgrader.get_logger()
try:
path, found_repository = _upgrade_recipe... | python | def recipe(package, repository=None, depends_on=None, release=False,
output_path=None, auto=False, overwrite=False, name=None):
"""Create a new upgrade recipe, for developers."""
upgrader = InvenioUpgrader()
logger = upgrader.get_logger()
try:
path, found_repository = _upgrade_recipe... | [
"def",
"recipe",
"(",
"package",
",",
"repository",
"=",
"None",
",",
"depends_on",
"=",
"None",
",",
"release",
"=",
"False",
",",
"output_path",
"=",
"None",
",",
"auto",
"=",
"False",
",",
"overwrite",
"=",
"False",
",",
"name",
"=",
"None",
")",
... | Create a new upgrade recipe, for developers. | [
"Create",
"a",
"new",
"upgrade",
"recipe",
"for",
"developers",
"."
] | train | https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/cli.py#L274-L335 |
inveniosoftware-attic/invenio-upgrader | invenio_upgrader/cli.py | _write_template | def _write_template(upgrade_file, name, depends_on, repository, auto=False):
"""Write template to upgrade file."""
if auto:
# Ensure all models are loaded
from invenio_db import models
list(models)
template_args = produce_upgrade_operations()
operations_str = template_arg... | python | def _write_template(upgrade_file, name, depends_on, repository, auto=False):
"""Write template to upgrade file."""
if auto:
# Ensure all models are loaded
from invenio_db import models
list(models)
template_args = produce_upgrade_operations()
operations_str = template_arg... | [
"def",
"_write_template",
"(",
"upgrade_file",
",",
"name",
",",
"depends_on",
",",
"repository",
",",
"auto",
"=",
"False",
")",
":",
"if",
"auto",
":",
"# Ensure all models are loaded",
"from",
"invenio_db",
"import",
"models",
"list",
"(",
"models",
")",
"t... | Write template to upgrade file. | [
"Write",
"template",
"to",
"upgrade",
"file",
"."
] | train | https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/cli.py#L341-L362 |
inveniosoftware-attic/invenio-upgrader | invenio_upgrader/cli.py | _upgrade_recipe_find_path | def _upgrade_recipe_find_path(import_str, create=True):
"""Determine repository name and path for new upgrade.
It is based on package import path.
"""
try:
# Import package
m = import_string(import_str)
# Check if package or module
if m.__package__ is not None and m.__p... | python | def _upgrade_recipe_find_path(import_str, create=True):
"""Determine repository name and path for new upgrade.
It is based on package import path.
"""
try:
# Import package
m = import_string(import_str)
# Check if package or module
if m.__package__ is not None and m.__p... | [
"def",
"_upgrade_recipe_find_path",
"(",
"import_str",
",",
"create",
"=",
"True",
")",
":",
"try",
":",
"# Import package",
"m",
"=",
"import_string",
"(",
"import_str",
")",
"# Check if package or module",
"if",
"m",
".",
"__package__",
"is",
"not",
"None",
"a... | Determine repository name and path for new upgrade.
It is based on package import path. | [
"Determine",
"repository",
"name",
"and",
"path",
"for",
"new",
"upgrade",
"."
] | train | https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/cli.py#L365-L396 |
narfman0/helga-youtube-metadata | helga_youtube_meta/plugin.py | youtube_meta | def youtube_meta(client, channel, nick, message, match):
""" Return meta information about a video """
if not API_KEY:
return 'You must set YOUTUBE_DATA_API_KEY in settings!'
identifier = match[0]
params = {
'id': identifier,
'key': API_KEY,
'part': 'snippet,statistics,co... | python | def youtube_meta(client, channel, nick, message, match):
""" Return meta information about a video """
if not API_KEY:
return 'You must set YOUTUBE_DATA_API_KEY in settings!'
identifier = match[0]
params = {
'id': identifier,
'key': API_KEY,
'part': 'snippet,statistics,co... | [
"def",
"youtube_meta",
"(",
"client",
",",
"channel",
",",
"nick",
",",
"message",
",",
"match",
")",
":",
"if",
"not",
"API_KEY",
":",
"return",
"'You must set YOUTUBE_DATA_API_KEY in settings!'",
"identifier",
"=",
"match",
"[",
"0",
"]",
"params",
"=",
"{",... | Return meta information about a video | [
"Return",
"meta",
"information",
"about",
"a",
"video"
] | train | https://github.com/narfman0/helga-youtube-metadata/blob/1babc2e6404864a344cb173e8a03fa5de957059a/helga_youtube_meta/plugin.py#L26-L56 |
narfman0/helga-youtube-metadata | helga_youtube_meta/plugin.py | parse_duration | def parse_duration(duration):
""" Parse and prettify duration from youtube duration format """
duration_dict = re.search(DURATION_REGEX, duration).groupdict()
converted_dict = {}
# convert all values to ints, remove nones
for a, x in duration_dict.iteritems():
if x is not None:
c... | python | def parse_duration(duration):
""" Parse and prettify duration from youtube duration format """
duration_dict = re.search(DURATION_REGEX, duration).groupdict()
converted_dict = {}
# convert all values to ints, remove nones
for a, x in duration_dict.iteritems():
if x is not None:
c... | [
"def",
"parse_duration",
"(",
"duration",
")",
":",
"duration_dict",
"=",
"re",
".",
"search",
"(",
"DURATION_REGEX",
",",
"duration",
")",
".",
"groupdict",
"(",
")",
"converted_dict",
"=",
"{",
"}",
"# convert all values to ints, remove nones",
"for",
"a",
","... | Parse and prettify duration from youtube duration format | [
"Parse",
"and",
"prettify",
"duration",
"from",
"youtube",
"duration",
"format"
] | train | https://github.com/narfman0/helga-youtube-metadata/blob/1babc2e6404864a344cb173e8a03fa5de957059a/helga_youtube_meta/plugin.py#L59-L67 |
uw-it-aca/uw-restclients-mailman | uw_mailman/course_list.py | get_course_list_name | def get_course_list_name(curriculum_abbr, course_number, section_id,
quarter, year, joint=False):
"""
Return the list address of UW course email list
"""
prefix = "multi_" if (joint is True) else ""
return COURSE_LIST_NAME.format(
prefix=prefix,
curr_abbr=_ge... | python | def get_course_list_name(curriculum_abbr, course_number, section_id,
quarter, year, joint=False):
"""
Return the list address of UW course email list
"""
prefix = "multi_" if (joint is True) else ""
return COURSE_LIST_NAME.format(
prefix=prefix,
curr_abbr=_ge... | [
"def",
"get_course_list_name",
"(",
"curriculum_abbr",
",",
"course_number",
",",
"section_id",
",",
"quarter",
",",
"year",
",",
"joint",
"=",
"False",
")",
":",
"prefix",
"=",
"\"multi_\"",
"if",
"(",
"joint",
"is",
"True",
")",
"else",
"\"\"",
"return",
... | Return the list address of UW course email list | [
"Return",
"the",
"list",
"address",
"of",
"UW",
"course",
"email",
"list"
] | train | https://github.com/uw-it-aca/uw-restclients-mailman/blob/ef077f2cc945871422fcd66391e82264e2384b2c/uw_mailman/course_list.py#L16-L29 |
uw-it-aca/uw-restclients-mailman | uw_mailman/course_list.py | exists_course_list | def exists_course_list(curriculum_abbr, course_number, section_id,
quarter, year, joint=False):
"""
Return True if the corresponding mailman list exists for the course
"""
return exists(get_course_list_name(curriculum_abbr, course_number,
sec... | python | def exists_course_list(curriculum_abbr, course_number, section_id,
quarter, year, joint=False):
"""
Return True if the corresponding mailman list exists for the course
"""
return exists(get_course_list_name(curriculum_abbr, course_number,
sec... | [
"def",
"exists_course_list",
"(",
"curriculum_abbr",
",",
"course_number",
",",
"section_id",
",",
"quarter",
",",
"year",
",",
"joint",
"=",
"False",
")",
":",
"return",
"exists",
"(",
"get_course_list_name",
"(",
"curriculum_abbr",
",",
"course_number",
",",
"... | Return True if the corresponding mailman list exists for the course | [
"Return",
"True",
"if",
"the",
"corresponding",
"mailman",
"list",
"exists",
"for",
"the",
"course"
] | train | https://github.com/uw-it-aca/uw-restclients-mailman/blob/ef077f2cc945871422fcd66391e82264e2384b2c/uw_mailman/course_list.py#L32-L38 |
ludeeus/pylaunches | pylaunches/api.py | Launches.get_launches | async def get_launches(self):
"""Get launch information."""
from .common import CommonFunctions
common = CommonFunctions(self.loop, self.session)
all_launches = []
launches = {}
data = await common.api_call(BASE_URL)
if data is None:
LOGGER.error('Erro... | python | async def get_launches(self):
"""Get launch information."""
from .common import CommonFunctions
common = CommonFunctions(self.loop, self.session)
all_launches = []
launches = {}
data = await common.api_call(BASE_URL)
if data is None:
LOGGER.error('Erro... | [
"async",
"def",
"get_launches",
"(",
"self",
")",
":",
"from",
".",
"common",
"import",
"CommonFunctions",
"common",
"=",
"CommonFunctions",
"(",
"self",
".",
"loop",
",",
"self",
".",
"session",
")",
"all_launches",
"=",
"[",
"]",
"launches",
"=",
"{",
... | Get launch information. | [
"Get",
"launch",
"information",
"."
] | train | https://github.com/ludeeus/pylaunches/blob/6cc449a9f734cbf789e561564b500a5dca93fe82/pylaunches/api.py#L20-L67 |
dossier/dossier.models | dossier/models/openquery/google.py | Google.web_search | def web_search(self, query, start=0, limit=100, max_tries=3):
'''
encapsulates urllib retrieval for fetching JSON results from
Google's Custom Search API. Returns a deserialized result set.
'''
tries = 0
if isinstance(query, unicode):
query = query.encode('ut... | python | def web_search(self, query, start=0, limit=100, max_tries=3):
'''
encapsulates urllib retrieval for fetching JSON results from
Google's Custom Search API. Returns a deserialized result set.
'''
tries = 0
if isinstance(query, unicode):
query = query.encode('ut... | [
"def",
"web_search",
"(",
"self",
",",
"query",
",",
"start",
"=",
"0",
",",
"limit",
"=",
"100",
",",
"max_tries",
"=",
"3",
")",
":",
"tries",
"=",
"0",
"if",
"isinstance",
"(",
"query",
",",
"unicode",
")",
":",
"query",
"=",
"query",
".",
"en... | encapsulates urllib retrieval for fetching JSON results from
Google's Custom Search API. Returns a deserialized result set. | [
"encapsulates",
"urllib",
"retrieval",
"for",
"fetching",
"JSON",
"results",
"from",
"Google",
"s",
"Custom",
"Search",
"API",
".",
"Returns",
"a",
"deserialized",
"result",
"set",
"."
] | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/openquery/google.py#L57-L93 |
GemHQ/round-py | round/netki.py | NetkiDomains.create | def create(self, domain_name, partner_id=None):
"""Register a domain you control with netki as a Gem-managed domain.
Note: After registering a domain, unless you have already set up its
DNSSEC/DS Records, you'll need to do so: http://docs.netki.apiary.io
The information required will be ... | python | def create(self, domain_name, partner_id=None):
"""Register a domain you control with netki as a Gem-managed domain.
Note: After registering a domain, unless you have already set up its
DNSSEC/DS Records, you'll need to do so: http://docs.netki.apiary.io
The information required will be ... | [
"def",
"create",
"(",
"self",
",",
"domain_name",
",",
"partner_id",
"=",
"None",
")",
":",
"params",
"=",
"dict",
"(",
"domain_name",
"=",
"domain_name",
")",
"if",
"partner_id",
":",
"params",
"[",
"'partner_id'",
"]",
"=",
"partner_id",
"domain",
"=",
... | Register a domain you control with netki as a Gem-managed domain.
Note: After registering a domain, unless you have already set up its
DNSSEC/DS Records, you'll need to do so: http://docs.netki.apiary.io
The information required will be an attribute of the returned NetkiDomain
object.
... | [
"Register",
"a",
"domain",
"you",
"control",
"with",
"netki",
"as",
"a",
"Gem",
"-",
"managed",
"domain",
".",
"Note",
":",
"After",
"registering",
"a",
"domain",
"unless",
"you",
"have",
"already",
"set",
"up",
"its",
"DNSSEC",
"/",
"DS",
"Records",
"yo... | train | https://github.com/GemHQ/round-py/blob/d0838f849cd260b1eb5df67ed3c6f2fe56c91c21/round/netki.py#L21-L41 |
GemHQ/round-py | round/netki.py | NetkiNames.create | def create(self, name, domain_name):
"""Register a url (e.g. wallet.gem.co) for
Args:
name (str): human-readable wallet name (e.g. wallet)
domain_name (str): the domain name to create subdomain on (e.g. gem.co)
this domain must already be registered with Gem
Ret... | python | def create(self, name, domain_name):
"""Register a url (e.g. wallet.gem.co) for
Args:
name (str): human-readable wallet name (e.g. wallet)
domain_name (str): the domain name to create subdomain on (e.g. gem.co)
this domain must already be registered with Gem
Ret... | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"domain_name",
")",
":",
"name",
"=",
"self",
".",
"wrap",
"(",
"self",
".",
"resource",
".",
"create",
"(",
"dict",
"(",
"name",
"=",
"name",
",",
"domain_name",
"=",
"domain_name",
")",
")",
")",
"s... | Register a url (e.g. wallet.gem.co) for
Args:
name (str): human-readable wallet name (e.g. wallet)
domain_name (str): the domain name to create subdomain on (e.g. gem.co)
this domain must already be registered with Gem
Returns: The new round.NetkiName | [
"Register",
"a",
"url",
"(",
"e",
".",
"g",
".",
"wallet",
".",
"gem",
".",
"co",
")",
"for"
] | train | https://github.com/GemHQ/round-py/blob/d0838f849cd260b1eb5df67ed3c6f2fe56c91c21/round/netki.py#L53-L67 |
twidi/py-dataql | dataql/solvers/filters.py | Solver.can_solve | def can_solve(cls, filter_):
"""Tells if the solver is able to resolve the given filter.
Arguments
---------
filter_ : subclass of dataql.resources.BaseFilter
The subclass or ``BaseFilter`` to check if it is solvable by the current solver class.
Returns
----... | python | def can_solve(cls, filter_):
"""Tells if the solver is able to resolve the given filter.
Arguments
---------
filter_ : subclass of dataql.resources.BaseFilter
The subclass or ``BaseFilter`` to check if it is solvable by the current solver class.
Returns
----... | [
"def",
"can_solve",
"(",
"cls",
",",
"filter_",
")",
":",
"for",
"solvable_filter",
"in",
"cls",
".",
"solvable_filters",
":",
"if",
"isinstance",
"(",
"filter_",
",",
"solvable_filter",
")",
":",
"return",
"True",
"return",
"False"
] | Tells if the solver is able to resolve the given filter.
Arguments
---------
filter_ : subclass of dataql.resources.BaseFilter
The subclass or ``BaseFilter`` to check if it is solvable by the current solver class.
Returns
-------
boolean
``True``... | [
"Tells",
"if",
"the",
"solver",
"is",
"able",
"to",
"resolve",
"the",
"given",
"filter",
"."
] | train | https://github.com/twidi/py-dataql/blob/5841a3fd559829193ed709c255166085bdde1c52/dataql/solvers/filters.py#L103-L131 |
twidi/py-dataql | dataql/solvers/filters.py | FilterSolver.solve | def solve(self, value, filter_):
"""Returns the value of an attribute of the value, or the result of a call to a function.
Arguments
---------
value : ?
A value to solve in combination with the given filter.
filter_ : dataql.resource.Filter
An instance of... | python | def solve(self, value, filter_):
"""Returns the value of an attribute of the value, or the result of a call to a function.
Arguments
---------
value : ?
A value to solve in combination with the given filter.
filter_ : dataql.resource.Filter
An instance of... | [
"def",
"solve",
"(",
"self",
",",
"value",
",",
"filter_",
")",
":",
"args",
",",
"kwargs",
"=",
"filter_",
".",
"get_args_and_kwargs",
"(",
")",
"source",
"=",
"self",
".",
"registry",
"[",
"value",
"]",
"return",
"source",
".",
"solve",
"(",
"value",... | Returns the value of an attribute of the value, or the result of a call to a function.
Arguments
---------
value : ?
A value to solve in combination with the given filter.
filter_ : dataql.resource.Filter
An instance of ``Filter`` to solve with the given value.
... | [
"Returns",
"the",
"value",
"of",
"an",
"attribute",
"of",
"the",
"value",
"or",
"the",
"result",
"of",
"a",
"call",
"to",
"a",
"function",
"."
] | train | https://github.com/twidi/py-dataql/blob/5841a3fd559829193ed709c255166085bdde1c52/dataql/solvers/filters.py#L153-L187 |
twidi/py-dataql | dataql/solvers/filters.py | SliceSolver.solve | def solve(self, value, filter_):
"""Get slice or entry defined by an index from the given value.
Arguments
---------
value : ?
A value to solve in combination with the given filter.
filter_ : dataql.resource.SliceFilter
An instance of ``SliceFilter``to so... | python | def solve(self, value, filter_):
"""Get slice or entry defined by an index from the given value.
Arguments
---------
value : ?
A value to solve in combination with the given filter.
filter_ : dataql.resource.SliceFilter
An instance of ``SliceFilter``to so... | [
"def",
"solve",
"(",
"self",
",",
"value",
",",
"filter_",
")",
":",
"try",
":",
"return",
"value",
"[",
"filter_",
".",
"slice",
"or",
"filter_",
".",
"index",
"]",
"except",
"IndexError",
":",
"return",
"None"
] | Get slice or entry defined by an index from the given value.
Arguments
---------
value : ?
A value to solve in combination with the given filter.
filter_ : dataql.resource.SliceFilter
An instance of ``SliceFilter``to solve with the given value.
Example
... | [
"Get",
"slice",
"or",
"entry",
"defined",
"by",
"an",
"index",
"from",
"the",
"given",
"value",
"."
] | train | https://github.com/twidi/py-dataql/blob/5841a3fd559829193ed709c255166085bdde1c52/dataql/solvers/filters.py#L209-L238 |
RazerM/bucketcache | bucketcache/utilities.py | get_instance_signature | def get_instance_signature(instance):
"""Get state of instance for cache signature (as part of key).
Attempts to get state will be done in this order:
- instance._getsate_bucketcache_()
- instance.__getstate__()
- instance.__dict__
"""
with suppress(AttributeError):
return instance... | python | def get_instance_signature(instance):
"""Get state of instance for cache signature (as part of key).
Attempts to get state will be done in this order:
- instance._getsate_bucketcache_()
- instance.__getstate__()
- instance.__dict__
"""
with suppress(AttributeError):
return instance... | [
"def",
"get_instance_signature",
"(",
"instance",
")",
":",
"with",
"suppress",
"(",
"AttributeError",
")",
":",
"return",
"instance",
".",
"_getsate_bucketcache_",
"(",
")",
"with",
"suppress",
"(",
"AttributeError",
")",
":",
"return",
"instance",
".",
"__gets... | Get state of instance for cache signature (as part of key).
Attempts to get state will be done in this order:
- instance._getsate_bucketcache_()
- instance.__getstate__()
- instance.__dict__ | [
"Get",
"state",
"of",
"instance",
"for",
"cache",
"signature",
"(",
"as",
"part",
"of",
"key",
")",
"."
] | train | https://github.com/RazerM/bucketcache/blob/8d9b163b73da8c498793cce2f22f6a7cbe524d94/bucketcache/utilities.py#L215-L230 |
RazerM/bucketcache | bucketcache/utilities.py | normalize_args | def normalize_args(f, *args, **kwargs):
"""Normalize call arguments into keyword form and varargs.
args can only be non-empty if there is *args in the argument specification.
"""
callargs = inspect.getcallargs(f, *args, **kwargs)
original_callargs = callargs.copy()
try:
argspec = inspec... | python | def normalize_args(f, *args, **kwargs):
"""Normalize call arguments into keyword form and varargs.
args can only be non-empty if there is *args in the argument specification.
"""
callargs = inspect.getcallargs(f, *args, **kwargs)
original_callargs = callargs.copy()
try:
argspec = inspec... | [
"def",
"normalize_args",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"callargs",
"=",
"inspect",
".",
"getcallargs",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"original_callargs",
"=",
"callargs",
".",
"copy",
"(",
... | Normalize call arguments into keyword form and varargs.
args can only be non-empty if there is *args in the argument specification. | [
"Normalize",
"call",
"arguments",
"into",
"keyword",
"form",
"and",
"varargs",
"."
] | train | https://github.com/RazerM/bucketcache/blob/8d9b163b73da8c498793cce2f22f6a7cbe524d94/bucketcache/utilities.py#L233-L261 |
RazerM/bucketcache | bucketcache/utilities.py | DecoratorFactory.add_callback | def add_callback(self, f):
"""Magic method assigned to f.callback that allows a callback to be
defined as follows:
@bucket
def fun(...):
...
@fun.callback
def fun():
...
In the event that a cached result is used, the callback is fired.
... | python | def add_callback(self, f):
"""Magic method assigned to f.callback that allows a callback to be
defined as follows:
@bucket
def fun(...):
...
@fun.callback
def fun():
...
In the event that a cached result is used, the callback is fired.
... | [
"def",
"add_callback",
"(",
"self",
",",
"f",
")",
":",
"self",
".",
"callback",
"=",
"f",
"return",
"self",
".",
"decorate",
"(",
"self",
".",
"fref",
"(",
")",
")"
] | Magic method assigned to f.callback that allows a callback to be
defined as follows:
@bucket
def fun(...):
...
@fun.callback
def fun():
...
In the event that a cached result is used, the callback is fired. | [
"Magic",
"method",
"assigned",
"to",
"f",
".",
"callback",
"that",
"allows",
"a",
"callback",
"to",
"be",
"defined",
"as",
"follows",
":"
] | train | https://github.com/RazerM/bucketcache/blob/8d9b163b73da8c498793cce2f22f6a7cbe524d94/bucketcache/utilities.py#L197-L212 |
Who8MyLunch/OrderedNamespace | ordered_namespace/core.py | convert_to_struct | def convert_to_struct(value):
"""Convert the following to Structs:
- dicts
- list elements that are dicts
- ???
This function is harmless to call on arbitrary variables.
"""
direct_converts = [dict, OrderedDict, UserDict]
if type(value) in direct_converts:
# Convert dic... | python | def convert_to_struct(value):
"""Convert the following to Structs:
- dicts
- list elements that are dicts
- ???
This function is harmless to call on arbitrary variables.
"""
direct_converts = [dict, OrderedDict, UserDict]
if type(value) in direct_converts:
# Convert dic... | [
"def",
"convert_to_struct",
"(",
"value",
")",
":",
"direct_converts",
"=",
"[",
"dict",
",",
"OrderedDict",
",",
"UserDict",
"]",
"if",
"type",
"(",
"value",
")",
"in",
"direct_converts",
":",
"# Convert dict-like things to Struct",
"value",
"=",
"Struct",
"(",... | Convert the following to Structs:
- dicts
- list elements that are dicts
- ???
This function is harmless to call on arbitrary variables. | [
"Convert",
"the",
"following",
"to",
"Structs",
":",
"-",
"dicts",
"-",
"list",
"elements",
"that",
"are",
"dicts",
"-",
"???"
] | train | https://github.com/Who8MyLunch/OrderedNamespace/blob/f14b7e76afe3379f1696c96e8d06ef6fbf923f00/ordered_namespace/core.py#L7-L24 |
Who8MyLunch/OrderedNamespace | ordered_namespace/core.py | Struct.update | def update(self, *args, **kwargs):
"""Update self with new content
"""
d = {}
d.update(*args, **kwargs)
for key, value in d.items():
self[key] = value | python | def update(self, *args, **kwargs):
"""Update self with new content
"""
d = {}
d.update(*args, **kwargs)
for key, value in d.items():
self[key] = value | [
"def",
"update",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"d",
"=",
"{",
"}",
"d",
".",
"update",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"for",
"key",
",",
"value",
"in",
"d",
".",
"items",
"(",
")",
":",
... | Update self with new content | [
"Update",
"self",
"with",
"new",
"content"
] | train | https://github.com/Who8MyLunch/OrderedNamespace/blob/f14b7e76afe3379f1696c96e8d06ef6fbf923f00/ordered_namespace/core.py#L46-L52 |
Who8MyLunch/OrderedNamespace | ordered_namespace/core.py | Struct._valid_key | def _valid_key(self, key):
"""Return True if supplied key string serves as a valid attribute name: alphanumeric strings
beginning with a letter. Leading underscore not allowed. Also test for conflict with protected
attribute names (e.g. dict class instance methods).
"""
if not ... | python | def _valid_key(self, key):
"""Return True if supplied key string serves as a valid attribute name: alphanumeric strings
beginning with a letter. Leading underscore not allowed. Also test for conflict with protected
attribute names (e.g. dict class instance methods).
"""
if not ... | [
"def",
"_valid_key",
"(",
"self",
",",
"key",
")",
":",
"if",
"not",
"isinstance",
"(",
"key",
",",
"str",
")",
":",
"return",
"False",
"elif",
"hasattr",
"(",
"{",
"}",
",",
"key",
")",
":",
"return",
"False",
"elif",
"key",
"in",
"self",
".",
"... | Return True if supplied key string serves as a valid attribute name: alphanumeric strings
beginning with a letter. Leading underscore not allowed. Also test for conflict with protected
attribute names (e.g. dict class instance methods). | [
"Return",
"True",
"if",
"supplied",
"key",
"string",
"serves",
"as",
"a",
"valid",
"attribute",
"name",
":",
"alphanumeric",
"strings",
"beginning",
"with",
"a",
"letter",
".",
"Leading",
"underscore",
"not",
"allowed",
".",
"Also",
"test",
"for",
"conflict",
... | train | https://github.com/Who8MyLunch/OrderedNamespace/blob/f14b7e76afe3379f1696c96e8d06ef6fbf923f00/ordered_namespace/core.py#L54-L66 |
Who8MyLunch/OrderedNamespace | ordered_namespace/core.py | Struct.asdict | def asdict(self):
"""Return a recursive dict representation of self
"""
d = dict(self._odict)
for k,v in d.items():
if isinstance(v, Struct):
d[k] = v.asdict()
return d | python | def asdict(self):
"""Return a recursive dict representation of self
"""
d = dict(self._odict)
for k,v in d.items():
if isinstance(v, Struct):
d[k] = v.asdict()
return d | [
"def",
"asdict",
"(",
"self",
")",
":",
"d",
"=",
"dict",
"(",
"self",
".",
"_odict",
")",
"for",
"k",
",",
"v",
"in",
"d",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"Struct",
")",
":",
"d",
"[",
"k",
"]",
"=",
"v",
... | Return a recursive dict representation of self | [
"Return",
"a",
"recursive",
"dict",
"representation",
"of",
"self"
] | train | https://github.com/Who8MyLunch/OrderedNamespace/blob/f14b7e76afe3379f1696c96e8d06ef6fbf923f00/ordered_namespace/core.py#L68-L77 |
Who8MyLunch/OrderedNamespace | ordered_namespace/core.py | Struct._repr_pretty_ | def _repr_pretty_(self, p, cycle):
"""Derived from IPython's dict and sequence pretty printer functions,
https://github.com/ipython/ipython/blob/master/IPython/lib/pretty.py
"""
if cycle:
p.text('{...}')
else:
keys = self.keys()
if keys:
... | python | def _repr_pretty_(self, p, cycle):
"""Derived from IPython's dict and sequence pretty printer functions,
https://github.com/ipython/ipython/blob/master/IPython/lib/pretty.py
"""
if cycle:
p.text('{...}')
else:
keys = self.keys()
if keys:
... | [
"def",
"_repr_pretty_",
"(",
"self",
",",
"p",
",",
"cycle",
")",
":",
"if",
"cycle",
":",
"p",
".",
"text",
"(",
"'{...}'",
")",
"else",
":",
"keys",
"=",
"self",
".",
"keys",
"(",
")",
"if",
"keys",
":",
"delim_start",
"=",
"'[{'",
"delim_end",
... | Derived from IPython's dict and sequence pretty printer functions,
https://github.com/ipython/ipython/blob/master/IPython/lib/pretty.py | [
"Derived",
"from",
"IPython",
"s",
"dict",
"and",
"sequence",
"pretty",
"printer",
"functions",
"https",
":",
"//",
"github",
".",
"com",
"/",
"ipython",
"/",
"ipython",
"/",
"blob",
"/",
"master",
"/",
"IPython",
"/",
"lib",
"/",
"pretty",
".",
"py"
] | train | https://github.com/Who8MyLunch/OrderedNamespace/blob/f14b7e76afe3379f1696c96e8d06ef6fbf923f00/ordered_namespace/core.py#L164-L192 |
lsst-sqre/BitlyOAuth2ProxySession | BitlyOAuth2ProxySession/Session.py | _extract_authenticity_token | def _extract_authenticity_token(data):
"""Don't look, I'm hideous!"""
# Super-cheap Python3 hack.
if not isinstance(data, str):
data = str(data, 'utf-8')
pos = data.find("authenticity_token")
# Super-gross.
authtok = str(data[pos + 41:pos + 41 + 88])
return authtok | python | def _extract_authenticity_token(data):
"""Don't look, I'm hideous!"""
# Super-cheap Python3 hack.
if not isinstance(data, str):
data = str(data, 'utf-8')
pos = data.find("authenticity_token")
# Super-gross.
authtok = str(data[pos + 41:pos + 41 + 88])
return authtok | [
"def",
"_extract_authenticity_token",
"(",
"data",
")",
":",
"# Super-cheap Python3 hack.",
"if",
"not",
"isinstance",
"(",
"data",
",",
"str",
")",
":",
"data",
"=",
"str",
"(",
"data",
",",
"'utf-8'",
")",
"pos",
"=",
"data",
".",
"find",
"(",
"\"authent... | Don't look, I'm hideous! | [
"Don",
"t",
"look",
"I",
"m",
"hideous!"
] | train | https://github.com/lsst-sqre/BitlyOAuth2ProxySession/blob/4d3839cfb9b897f46cffc41a5f6ff7c645a5f202/BitlyOAuth2ProxySession/Session.py#L87-L95 |
lsst-sqre/BitlyOAuth2ProxySession | BitlyOAuth2ProxySession/Session.py | Session.authenticate | def authenticate(self):
"""Authenticate the session"""
postdata = self.authentication_postdata
jar = requests.cookies.cookielib.CookieJar()
self.cookies = jar
resp = self.get(self.authentication_base_url)
authtok = _extract_authenticity_token(resp.content)
if post... | python | def authenticate(self):
"""Authenticate the session"""
postdata = self.authentication_postdata
jar = requests.cookies.cookielib.CookieJar()
self.cookies = jar
resp = self.get(self.authentication_base_url)
authtok = _extract_authenticity_token(resp.content)
if post... | [
"def",
"authenticate",
"(",
"self",
")",
":",
"postdata",
"=",
"self",
".",
"authentication_postdata",
"jar",
"=",
"requests",
".",
"cookies",
".",
"cookielib",
".",
"CookieJar",
"(",
")",
"self",
".",
"cookies",
"=",
"jar",
"resp",
"=",
"self",
".",
"ge... | Authenticate the session | [
"Authenticate",
"the",
"session"
] | train | https://github.com/lsst-sqre/BitlyOAuth2ProxySession/blob/4d3839cfb9b897f46cffc41a5f6ff7c645a5f202/BitlyOAuth2ProxySession/Session.py#L64-L84 |
radjkarl/fancyTools | fancytools/math/MaskedMovingAverage.py | MaskedMovingAverage.update | def update(self, arr, mask=None):
"""
update moving average (and variance) with new ndarray
(of the same shape as the init array) and an optional mask
"""
if mask is not None:
refI = np.logical_and(mask, self.n == 0)
else:
refI = self.n == 0
... | python | def update(self, arr, mask=None):
"""
update moving average (and variance) with new ndarray
(of the same shape as the init array) and an optional mask
"""
if mask is not None:
refI = np.logical_and(mask, self.n == 0)
else:
refI = self.n == 0
... | [
"def",
"update",
"(",
"self",
",",
"arr",
",",
"mask",
"=",
"None",
")",
":",
"if",
"mask",
"is",
"not",
"None",
":",
"refI",
"=",
"np",
".",
"logical_and",
"(",
"mask",
",",
"self",
".",
"n",
"==",
"0",
")",
"else",
":",
"refI",
"=",
"self",
... | update moving average (and variance) with new ndarray
(of the same shape as the init array) and an optional mask | [
"update",
"moving",
"average",
"(",
"and",
"variance",
")",
"with",
"new",
"ndarray",
"(",
"of",
"the",
"same",
"shape",
"as",
"the",
"init",
"array",
")",
"and",
"an",
"optional",
"mask"
] | train | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/MaskedMovingAverage.py#L34-L69 |
opieters/SnakeTeX | snaketex/stex.py | cli | def cli(ctx, config, debug):
"""SnakTeX command line interface - write LaTeX faster through templating."""
ctx.obj['config'] = config
ctx.obj['engine'] = stex.SnakeTeX(config_file=config, debug=debug) | python | def cli(ctx, config, debug):
"""SnakTeX command line interface - write LaTeX faster through templating."""
ctx.obj['config'] = config
ctx.obj['engine'] = stex.SnakeTeX(config_file=config, debug=debug) | [
"def",
"cli",
"(",
"ctx",
",",
"config",
",",
"debug",
")",
":",
"ctx",
".",
"obj",
"[",
"'config'",
"]",
"=",
"config",
"ctx",
".",
"obj",
"[",
"'engine'",
"]",
"=",
"stex",
".",
"SnakeTeX",
"(",
"config_file",
"=",
"config",
",",
"debug",
"=",
... | SnakTeX command line interface - write LaTeX faster through templating. | [
"SnakTeX",
"command",
"line",
"interface",
"-",
"write",
"LaTeX",
"faster",
"through",
"templating",
"."
] | train | https://github.com/opieters/SnakeTeX/blob/0ceba577a5bf2ff6bb686c426a6f5b1393b99471/snaketex/stex.py#L10-L13 |
etcher-be/emiz | emiz/miz.py | Miz.reorder | def reorder(
miz_file_path: typing.Union[str, Path],
target_dir: typing.Union[str, Path],
skip_options_file: bool,
):
"""
Re-orders a miz file into a folder (flattened)
Args:
miz_file_path: source miz file
target_dir: folder to fla... | python | def reorder(
miz_file_path: typing.Union[str, Path],
target_dir: typing.Union[str, Path],
skip_options_file: bool,
):
"""
Re-orders a miz file into a folder (flattened)
Args:
miz_file_path: source miz file
target_dir: folder to fla... | [
"def",
"reorder",
"(",
"miz_file_path",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"Path",
"]",
",",
"target_dir",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"Path",
"]",
",",
"skip_options_file",
":",
"bool",
",",
")",
":",
"miz_file_path",
"=",... | Re-orders a miz file into a folder (flattened)
Args:
miz_file_path: source miz file
target_dir: folder to flatten the content into
skip_options_file: do not re-order option file | [
"Re",
"-",
"orders",
"a",
"miz",
"file",
"into",
"a",
"folder",
"(",
"flattened",
")"
] | train | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/miz.py#L150-L219 |
etcher-be/emiz | emiz/miz.py | Miz.zip | def zip(self, destination: typing.Union[str, Path] = None, encode: bool = True) -> str:
"""
Write mission, dictionary etc. to a MIZ file
Args:
destination: target MIZ file (if none, defaults to source MIZ + "_EMIZ"
Returns: destination file
"""
if encode:
... | python | def zip(self, destination: typing.Union[str, Path] = None, encode: bool = True) -> str:
"""
Write mission, dictionary etc. to a MIZ file
Args:
destination: target MIZ file (if none, defaults to source MIZ + "_EMIZ"
Returns: destination file
"""
if encode:
... | [
"def",
"zip",
"(",
"self",
",",
"destination",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"Path",
"]",
"=",
"None",
",",
"encode",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"if",
"encode",
":",
"self",
".",
"_encode",
"(",
")",
"if",
... | Write mission, dictionary etc. to a MIZ file
Args:
destination: target MIZ file (if none, defaults to source MIZ + "_EMIZ"
Returns: destination file | [
"Write",
"mission",
"dictionary",
"etc",
".",
"to",
"a",
"MIZ",
"file"
] | train | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/miz.py#L334-L364 |
universalcore/springboard | springboard/utils.py | ga_context | def ga_context(context_func):
"""
A decorator for Cornice views that allows one to set extra parameters
for Google Analytics tracking::
@ga_context(lambda context: {'dt': context['category'].title, })
@view_config(route_name='page')
def view(request):
return {
... | python | def ga_context(context_func):
"""
A decorator for Cornice views that allows one to set extra parameters
for Google Analytics tracking::
@ga_context(lambda context: {'dt': context['category'].title, })
@view_config(route_name='page')
def view(request):
return {
... | [
"def",
"ga_context",
"(",
"context_func",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"context",
"=",
"func",
"(",
"self",
... | A decorator for Cornice views that allows one to set extra parameters
for Google Analytics tracking::
@ga_context(lambda context: {'dt': context['category'].title, })
@view_config(route_name='page')
def view(request):
return {
'category': self.workspace.S(Categor... | [
"A",
"decorator",
"for",
"Cornice",
"views",
"that",
"allows",
"one",
"to",
"set",
"extra",
"parameters",
"for",
"Google",
"Analytics",
"tracking",
"::"
] | train | https://github.com/universalcore/springboard/blob/9f0393d310a1d2219613e8cd30cc52c75fb4dd61/springboard/utils.py#L48-L74 |
universalcore/springboard | springboard/utils.py | config_dict | def config_dict(data):
"""
A function that takes a string of pair values, indicated by '=', separated
by newline characters and returns a dict of those value pairs
:param func context_func:
A function which takes one argument, a string of value pairs with
'= between them' separated by n... | python | def config_dict(data):
"""
A function that takes a string of pair values, indicated by '=', separated
by newline characters and returns a dict of those value pairs
:param func context_func:
A function which takes one argument, a string of value pairs with
'= between them' separated by n... | [
"def",
"config_dict",
"(",
"data",
")",
":",
"lines",
"=",
"config_list",
"(",
"data",
")",
"return",
"dict",
"(",
"re",
".",
"split",
"(",
"'\\s*=\\s*'",
",",
"value",
")",
"for",
"value",
"in",
"lines",
")"
] | A function that takes a string of pair values, indicated by '=', separated
by newline characters and returns a dict of those value pairs
:param func context_func:
A function which takes one argument, a string of value pairs with
'= between them' separated by newline characters
:returns:
... | [
"A",
"function",
"that",
"takes",
"a",
"string",
"of",
"pair",
"values",
"indicated",
"by",
"=",
"separated",
"by",
"newline",
"characters",
"and",
"returns",
"a",
"dict",
"of",
"those",
"value",
"pairs"
] | train | https://github.com/universalcore/springboard/blob/9f0393d310a1d2219613e8cd30cc52c75fb4dd61/springboard/utils.py#L94-L108 |
SeabornGames/Timestamp | seaborn_timestamp/timestamp.py | cst_now | def cst_now():
"""
This will return a datetime of utcnow - 6 hours for
Central Standard Time
:return: Datetime
"""
try:
ret = datetime.utcnow() + timedelta(hours=DEFAULT_TIMEZONE)
if DEFAULT_TIMEZONE_AWARE:
ret = ret.replace(
tzinfo=psycopg2.tz... | python | def cst_now():
"""
This will return a datetime of utcnow - 6 hours for
Central Standard Time
:return: Datetime
"""
try:
ret = datetime.utcnow() + timedelta(hours=DEFAULT_TIMEZONE)
if DEFAULT_TIMEZONE_AWARE:
ret = ret.replace(
tzinfo=psycopg2.tz... | [
"def",
"cst_now",
"(",
")",
":",
"try",
":",
"ret",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"+",
"timedelta",
"(",
"hours",
"=",
"DEFAULT_TIMEZONE",
")",
"if",
"DEFAULT_TIMEZONE_AWARE",
":",
"ret",
"=",
"ret",
".",
"replace",
"(",
"tzinfo",
"=",
"psy... | This will return a datetime of utcnow - 6 hours for
Central Standard Time
:return: Datetime | [
"This",
"will",
"return",
"a",
"datetime",
"of",
"utcnow",
"-",
"6",
"hours",
"for",
"Central",
"Standard",
"Time",
":",
"return",
":",
"Datetime"
] | train | https://github.com/SeabornGames/Timestamp/blob/2b6902ddc2a009d6f3cb4dd0f6882bf4345f3871/seaborn_timestamp/timestamp.py#L33-L47 |
SeabornGames/Timestamp | seaborn_timestamp/timestamp.py | today | def today(date_time=None):
"""
This will return a datetime of cst_now - 5 hours with only
Year, Month, and Day
:return: Datetime
"""
ret = date_time or cst_now()
try:
ret = datetime(year=ret.year, month=ret.month, day=ret.day)
if DEFAULT_TIMEZONE_AWARE:
r... | python | def today(date_time=None):
"""
This will return a datetime of cst_now - 5 hours with only
Year, Month, and Day
:return: Datetime
"""
ret = date_time or cst_now()
try:
ret = datetime(year=ret.year, month=ret.month, day=ret.day)
if DEFAULT_TIMEZONE_AWARE:
r... | [
"def",
"today",
"(",
"date_time",
"=",
"None",
")",
":",
"ret",
"=",
"date_time",
"or",
"cst_now",
"(",
")",
"try",
":",
"ret",
"=",
"datetime",
"(",
"year",
"=",
"ret",
".",
"year",
",",
"month",
"=",
"ret",
".",
"month",
",",
"day",
"=",
"ret",... | This will return a datetime of cst_now - 5 hours with only
Year, Month, and Day
:return: Datetime | [
"This",
"will",
"return",
"a",
"datetime",
"of",
"cst_now",
"-",
"5",
"hours",
"with",
"only",
"Year",
"Month",
"and",
"Day",
":",
"return",
":",
"Datetime"
] | train | https://github.com/SeabornGames/Timestamp/blob/2b6902ddc2a009d6f3cb4dd0f6882bf4345f3871/seaborn_timestamp/timestamp.py#L50-L65 |
SeabornGames/Timestamp | seaborn_timestamp/timestamp.py | now | def now(years=0, days=0, hours=0, minutes=0, seconds=0):
"""
:param years: int delta of years from now
:param days: int delta of days from now
:param hours: int delta of hours from now
:param minutes: int delta of minutes from now
:param seconds: float delta of seconds from now
:retur... | python | def now(years=0, days=0, hours=0, minutes=0, seconds=0):
"""
:param years: int delta of years from now
:param days: int delta of days from now
:param hours: int delta of hours from now
:param minutes: int delta of minutes from now
:param seconds: float delta of seconds from now
:retur... | [
"def",
"now",
"(",
"years",
"=",
"0",
",",
"days",
"=",
"0",
",",
"hours",
"=",
"0",
",",
"minutes",
"=",
"0",
",",
"seconds",
"=",
"0",
")",
":",
"date_time",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"date_time",
"+=",
"timedelta",
"(",
"days",... | :param years: int delta of years from now
:param days: int delta of days from now
:param hours: int delta of hours from now
:param minutes: int delta of minutes from now
:param seconds: float delta of seconds from now
:return: str of the now timestamp | [
":",
"param",
"years",
":",
"int",
"delta",
"of",
"years",
"from",
"now",
":",
"param",
"days",
":",
"int",
"delta",
"of",
"days",
"from",
"now",
":",
"param",
"hours",
":",
"int",
"delta",
"of",
"hours",
"from",
"now",
":",
"param",
"minutes",
":",
... | train | https://github.com/SeabornGames/Timestamp/blob/2b6902ddc2a009d6f3cb4dd0f6882bf4345f3871/seaborn_timestamp/timestamp.py#L68-L80 |
SeabornGames/Timestamp | seaborn_timestamp/timestamp.py | add_to_timestamp | def add_to_timestamp(timestamp, time_delta,
str_format='%Y-%m-%d_%H:%M:%S.fff'):
"""
This will convert the timestamp to datetime, add the timedelta
and then return it as a timestamp
:param timestamp: str of the date and time
:param time_delta: datetime.timedelta of ... | python | def add_to_timestamp(timestamp, time_delta,
str_format='%Y-%m-%d_%H:%M:%S.fff'):
"""
This will convert the timestamp to datetime, add the timedelta
and then return it as a timestamp
:param timestamp: str of the date and time
:param time_delta: datetime.timedelta of ... | [
"def",
"add_to_timestamp",
"(",
"timestamp",
",",
"time_delta",
",",
"str_format",
"=",
"'%Y-%m-%d_%H:%M:%S.fff'",
")",
":",
"date_time",
"=",
"str_to_datetime",
"(",
"timestamp",
",",
"str_format",
")",
"+",
"time_delta",
"return",
"datetime_to_str",
"(",
"timestam... | This will convert the timestamp to datetime, add the timedelta
and then return it as a timestamp
:param timestamp: str of the date and time
:param time_delta: datetime.timedelta of the time to add
:param str_format: str of the format of the timestamp
:return: str of the new ti... | [
"This",
"will",
"convert",
"the",
"timestamp",
"to",
"datetime",
"add",
"the",
"timedelta",
"and",
"then",
"return",
"it",
"as",
"a",
"timestamp",
":",
"param",
"timestamp",
":",
"str",
"of",
"the",
"date",
"and",
"time",
":",
"param",
"time_delta",
":",
... | train | https://github.com/SeabornGames/Timestamp/blob/2b6902ddc2a009d6f3cb4dd0f6882bf4345f3871/seaborn_timestamp/timestamp.py#L83-L94 |
SeabornGames/Timestamp | seaborn_timestamp/timestamp.py | datetime_to_str | def datetime_to_str(date_time=None, str_format='%Y-%m-%d_%H:%M:%S.fff'):
"""
:param date_time: datetime of the date to convert to string
:param str_format: str of the format to return the string in
:return: str of the timestamp
"""
date_time = date_time or cst_now()
if DEFAULT_TIMEZONE_A... | python | def datetime_to_str(date_time=None, str_format='%Y-%m-%d_%H:%M:%S.fff'):
"""
:param date_time: datetime of the date to convert to string
:param str_format: str of the format to return the string in
:return: str of the timestamp
"""
date_time = date_time or cst_now()
if DEFAULT_TIMEZONE_A... | [
"def",
"datetime_to_str",
"(",
"date_time",
"=",
"None",
",",
"str_format",
"=",
"'%Y-%m-%d_%H:%M:%S.fff'",
")",
":",
"date_time",
"=",
"date_time",
"or",
"cst_now",
"(",
")",
"if",
"DEFAULT_TIMEZONE_AWARE",
":",
"date_time",
"+=",
"timedelta",
"(",
"hours",
"="... | :param date_time: datetime of the date to convert to string
:param str_format: str of the format to return the string in
:return: str of the timestamp | [
":",
"param",
"date_time",
":",
"datetime",
"of",
"the",
"date",
"to",
"convert",
"to",
"string",
":",
"param",
"str_format",
":",
"str",
"of",
"the",
"format",
"to",
"return",
"the",
"string",
"in",
":",
"return",
":",
"str",
"of",
"the",
"timestamp"
] | train | https://github.com/SeabornGames/Timestamp/blob/2b6902ddc2a009d6f3cb4dd0f6882bf4345f3871/seaborn_timestamp/timestamp.py#L97-L111 |
SeabornGames/Timestamp | seaborn_timestamp/timestamp.py | str_to_datetime | def str_to_datetime(timestamp, str_format='%Y-%m-%d_%H:%M:%S.fff'):
"""
:param str_format:
:param timestamp: str of the timestamp
:return: datetime
"""
date_time = datetime.strptime(timestamp.split('.')[0],
str_format.split('.')[0])
if '.' in timest... | python | def str_to_datetime(timestamp, str_format='%Y-%m-%d_%H:%M:%S.fff'):
"""
:param str_format:
:param timestamp: str of the timestamp
:return: datetime
"""
date_time = datetime.strptime(timestamp.split('.')[0],
str_format.split('.')[0])
if '.' in timest... | [
"def",
"str_to_datetime",
"(",
"timestamp",
",",
"str_format",
"=",
"'%Y-%m-%d_%H:%M:%S.fff'",
")",
":",
"date_time",
"=",
"datetime",
".",
"strptime",
"(",
"timestamp",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
",",
"str_format",
".",
"split",
"(",
"'... | :param str_format:
:param timestamp: str of the timestamp
:return: datetime | [
":",
"param",
"str_format",
":",
":",
"param",
"timestamp",
":",
"str",
"of",
"the",
"timestamp",
":",
"return",
":",
"datetime"
] | train | https://github.com/SeabornGames/Timestamp/blob/2b6902ddc2a009d6f3cb4dd0f6882bf4345f3871/seaborn_timestamp/timestamp.py#L114-L128 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/writer.py | SoapWriter.serialize_header | def serialize_header(self, pyobj, typecode=None, **kw):
'''Serialize a Python object in SOAP-ENV:Header, make
sure everything in Header unique (no #href). Must call
serialize first to create a document.
Parameters:
pyobjs -- instances to serialize in SOAP Header
... | python | def serialize_header(self, pyobj, typecode=None, **kw):
'''Serialize a Python object in SOAP-ENV:Header, make
sure everything in Header unique (no #href). Must call
serialize first to create a document.
Parameters:
pyobjs -- instances to serialize in SOAP Header
... | [
"def",
"serialize_header",
"(",
"self",
",",
"pyobj",
",",
"typecode",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"kw",
"[",
"'unique'",
"]",
"=",
"True",
"soap_env",
"=",
"_reserved_ns",
"[",
"'SOAP-ENV'",
"]",
"#header = self.dom.getElement(soap_env, 'Heade... | Serialize a Python object in SOAP-ENV:Header, make
sure everything in Header unique (no #href). Must call
serialize first to create a document.
Parameters:
pyobjs -- instances to serialize in SOAP Header
typecode -- default typecode | [
"Serialize",
"a",
"Python",
"object",
"in",
"SOAP",
"-",
"ENV",
":",
"Header",
"make",
"sure",
"everything",
"in",
"Header",
"unique",
"(",
"no",
"#href",
")",
".",
"Must",
"call",
"serialize",
"first",
"to",
"create",
"a",
"document",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/writer.py#L59-L81 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/writer.py | SoapWriter.serialize | def serialize(self, pyobj, typecode=None, root=None, header_pyobjs=(), **kw):
'''Serialize a Python object to the output stream.
pyobj -- python instance to serialize in body.
typecode -- typecode describing body
root -- SOAP-ENC:root
header_pyobjs -- list of pyobj f... | python | def serialize(self, pyobj, typecode=None, root=None, header_pyobjs=(), **kw):
'''Serialize a Python object to the output stream.
pyobj -- python instance to serialize in body.
typecode -- typecode describing body
root -- SOAP-ENC:root
header_pyobjs -- list of pyobj f... | [
"def",
"serialize",
"(",
"self",
",",
"pyobj",
",",
"typecode",
"=",
"None",
",",
"root",
"=",
"None",
",",
"header_pyobjs",
"=",
"(",
")",
",",
"*",
"*",
"kw",
")",
":",
"self",
".",
"body",
"=",
"None",
"if",
"self",
".",
"envelope",
":",
"soap... | Serialize a Python object to the output stream.
pyobj -- python instance to serialize in body.
typecode -- typecode describing body
root -- SOAP-ENC:root
header_pyobjs -- list of pyobj for soap header inclusion, each
instance must specify the typecode attribute... | [
"Serialize",
"a",
"Python",
"object",
"to",
"the",
"output",
"stream",
".",
"pyobj",
"--",
"python",
"instance",
"to",
"serialize",
"in",
"body",
".",
"typecode",
"--",
"typecode",
"describing",
"body",
"root",
"--",
"SOAP",
"-",
"ENC",
":",
"root",
"heade... | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/writer.py#L83-L124 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/writer.py | SoapWriter.writeNSdict | def writeNSdict(self, nsdict):
'''Write a namespace dictionary, taking care to not clobber the
standard (or reserved by us) prefixes.
'''
for k,v in nsdict.items():
if (k,v) in _standard_ns: continue
rv = _reserved_ns.get(k)
if rv:
if r... | python | def writeNSdict(self, nsdict):
'''Write a namespace dictionary, taking care to not clobber the
standard (or reserved by us) prefixes.
'''
for k,v in nsdict.items():
if (k,v) in _standard_ns: continue
rv = _reserved_ns.get(k)
if rv:
if r... | [
"def",
"writeNSdict",
"(",
"self",
",",
"nsdict",
")",
":",
"for",
"k",
",",
"v",
"in",
"nsdict",
".",
"items",
"(",
")",
":",
"if",
"(",
"k",
",",
"v",
")",
"in",
"_standard_ns",
":",
"continue",
"rv",
"=",
"_reserved_ns",
".",
"get",
"(",
"k",
... | Write a namespace dictionary, taking care to not clobber the
standard (or reserved by us) prefixes. | [
"Write",
"a",
"namespace",
"dictionary",
"taking",
"care",
"to",
"not",
"clobber",
"the",
"standard",
"(",
"or",
"reserved",
"by",
"us",
")",
"prefixes",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/writer.py#L126-L140 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/writer.py | SoapWriter.Known | def Known(self, obj):
'''Seen this object (known by its id()? Return 1 if so,
otherwise add it to our memory and return 0.
'''
obj = _get_idstr(obj)
if obj in self.memo: return 1
self.memo.append(obj)
return 0 | python | def Known(self, obj):
'''Seen this object (known by its id()? Return 1 if so,
otherwise add it to our memory and return 0.
'''
obj = _get_idstr(obj)
if obj in self.memo: return 1
self.memo.append(obj)
return 0 | [
"def",
"Known",
"(",
"self",
",",
"obj",
")",
":",
"obj",
"=",
"_get_idstr",
"(",
"obj",
")",
"if",
"obj",
"in",
"self",
".",
"memo",
":",
"return",
"1",
"self",
".",
"memo",
".",
"append",
"(",
"obj",
")",
"return",
"0"
] | Seen this object (known by its id()? Return 1 if so,
otherwise add it to our memory and return 0. | [
"Seen",
"this",
"object",
"(",
"known",
"by",
"its",
"id",
"()",
"?",
"Return",
"1",
"if",
"so",
"otherwise",
"add",
"it",
"to",
"our",
"memory",
"and",
"return",
"0",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/writer.py#L154-L161 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/writer.py | SoapWriter.Forget | def Forget(self, obj):
'''Forget we've seen this object.
'''
obj = _get_idstr(obj)
try:
self.memo.remove(obj)
except ValueError:
pass | python | def Forget(self, obj):
'''Forget we've seen this object.
'''
obj = _get_idstr(obj)
try:
self.memo.remove(obj)
except ValueError:
pass | [
"def",
"Forget",
"(",
"self",
",",
"obj",
")",
":",
"obj",
"=",
"_get_idstr",
"(",
"obj",
")",
"try",
":",
"self",
".",
"memo",
".",
"remove",
"(",
"obj",
")",
"except",
"ValueError",
":",
"pass"
] | Forget we've seen this object. | [
"Forget",
"we",
"ve",
"seen",
"this",
"object",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/writer.py#L163-L170 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/writer.py | SoapWriter.close | def close(self):
'''Invoke all the callbacks, and close off the SOAP message.
'''
if self.closed: return
for func,arglist in self.callbacks:
apply(func, arglist)
self.closed = True | python | def close(self):
'''Invoke all the callbacks, and close off the SOAP message.
'''
if self.closed: return
for func,arglist in self.callbacks:
apply(func, arglist)
self.closed = True | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"closed",
":",
"return",
"for",
"func",
",",
"arglist",
"in",
"self",
".",
"callbacks",
":",
"apply",
"(",
"func",
",",
"arglist",
")",
"self",
".",
"closed",
"=",
"True"
] | Invoke all the callbacks, and close off the SOAP message. | [
"Invoke",
"all",
"the",
"callbacks",
"and",
"close",
"off",
"the",
"SOAP",
"message",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/writer.py#L178-L184 |
spotify/gordon-janitor | gordon_janitor/main.py | setup | def setup(config_root=''):
"""
Service configuration and logging setup.
Configuration defined in ``gordon-janitor-user.toml`` will overwrite
``gordon-janitor.toml``.
Args:
config_root (str): where configuration should load from,
defaults to current working directory.
Return... | python | def setup(config_root=''):
"""
Service configuration and logging setup.
Configuration defined in ``gordon-janitor-user.toml`` will overwrite
``gordon-janitor.toml``.
Args:
config_root (str): where configuration should load from,
defaults to current working directory.
Return... | [
"def",
"setup",
"(",
"config_root",
"=",
"''",
")",
":",
"config",
"=",
"_load_config",
"(",
"root",
"=",
"config_root",
")",
"logging_config",
"=",
"config",
".",
"get",
"(",
"'core'",
",",
"{",
"}",
")",
".",
"get",
"(",
"'logging'",
",",
"{",
"}",... | Service configuration and logging setup.
Configuration defined in ``gordon-janitor-user.toml`` will overwrite
``gordon-janitor.toml``.
Args:
config_root (str): where configuration should load from,
defaults to current working directory.
Returns:
A dict for Gordon service co... | [
"Service",
"configuration",
"and",
"logging",
"setup",
"."
] | train | https://github.com/spotify/gordon-janitor/blob/e0df2002caf3aac528818743d8d0717790957044/gordon_janitor/main.py#L76-L98 |
limpyd/redis-limpyd-jobs | limpyd_jobs/__init__.py | STATUSES.by_value | def by_value(self, value, default=None):
"""
Returns the key for the given value
"""
try:
return [k for k, v in self.items() if v == value][0]
except IndexError:
if default is not None:
return default
raise ValueError('%s' % val... | python | def by_value(self, value, default=None):
"""
Returns the key for the given value
"""
try:
return [k for k, v in self.items() if v == value][0]
except IndexError:
if default is not None:
return default
raise ValueError('%s' % val... | [
"def",
"by_value",
"(",
"self",
",",
"value",
",",
"default",
"=",
"None",
")",
":",
"try",
":",
"return",
"[",
"k",
"for",
"k",
",",
"v",
"in",
"self",
".",
"items",
"(",
")",
"if",
"v",
"==",
"value",
"]",
"[",
"0",
"]",
"except",
"IndexError... | Returns the key for the given value | [
"Returns",
"the",
"key",
"for",
"the",
"given",
"value"
] | train | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/__init__.py#L21-L30 |
RonenNess/Fileter | fileter/files_iterator.py | FilesIterator.add_folder | def add_folder(self, path, depth=None, source_type=DefaultSourceType):
"""
Add a folder source to scan recursively from path (string).
:param path: folder path.
:param depth: if provided will be depth limit. 0 = first level only.
:param source_type: what to return; files only, f... | python | def add_folder(self, path, depth=None, source_type=DefaultSourceType):
"""
Add a folder source to scan recursively from path (string).
:param path: folder path.
:param depth: if provided will be depth limit. 0 = first level only.
:param source_type: what to return; files only, f... | [
"def",
"add_folder",
"(",
"self",
",",
"path",
",",
"depth",
"=",
"None",
",",
"source_type",
"=",
"DefaultSourceType",
")",
":",
"self",
".",
"add_source",
"(",
"FolderSource",
"(",
"path",
",",
"depth",
",",
"*",
"*",
"source_type",
")",
")",
"return",... | Add a folder source to scan recursively from path (string).
:param path: folder path.
:param depth: if provided will be depth limit. 0 = first level only.
:param source_type: what to return; files only, folders only, or both. | [
"Add",
"a",
"folder",
"source",
"to",
"scan",
"recursively",
"from",
"path",
"(",
"string",
")",
"."
] | train | https://github.com/RonenNess/Fileter/blob/5372221b4049d5d46a9926573b91af17681c81f3/fileter/files_iterator.py#L87-L96 |
RonenNess/Fileter | fileter/files_iterator.py | FilesIterator.add_pattern | def add_pattern(self, pattern, root=".", depth=None, source_type=DefaultSourceType):
"""
Add a recursive folder scan using a linux-style patterns.
:param pattern: pattern or list of patterns to match.
:param root: root to start from (default to '.')
:param depth: if provided wil... | python | def add_pattern(self, pattern, root=".", depth=None, source_type=DefaultSourceType):
"""
Add a recursive folder scan using a linux-style patterns.
:param pattern: pattern or list of patterns to match.
:param root: root to start from (default to '.')
:param depth: if provided wil... | [
"def",
"add_pattern",
"(",
"self",
",",
"pattern",
",",
"root",
"=",
"\".\"",
",",
"depth",
"=",
"None",
",",
"source_type",
"=",
"DefaultSourceType",
")",
":",
"self",
".",
"add_source",
"(",
"PatternSource",
"(",
"pattern",
",",
"root",
",",
"depth",
"... | Add a recursive folder scan using a linux-style patterns.
:param pattern: pattern or list of patterns to match.
:param root: root to start from (default to '.')
:param depth: if provided will be depth limit. 0 = first level only.
:param source_type: what to return; files only, folders o... | [
"Add",
"a",
"recursive",
"folder",
"scan",
"using",
"a",
"linux",
"-",
"style",
"patterns",
"."
] | train | https://github.com/RonenNess/Fileter/blob/5372221b4049d5d46a9926573b91af17681c81f3/fileter/files_iterator.py#L98-L108 |
RonenNess/Fileter | fileter/files_iterator.py | FilesIterator.add_filtered_folder | def add_filtered_folder(self, path, regex, depth=None, source_type=DefaultSourceType):
"""
Add a folder source to scan recursively, with a regex filter on directories.
:param regex: regex string to filter folders by.
:param depth: if provided will be depth limit. 0 = first level only.
... | python | def add_filtered_folder(self, path, regex, depth=None, source_type=DefaultSourceType):
"""
Add a folder source to scan recursively, with a regex filter on directories.
:param regex: regex string to filter folders by.
:param depth: if provided will be depth limit. 0 = first level only.
... | [
"def",
"add_filtered_folder",
"(",
"self",
",",
"path",
",",
"regex",
",",
"depth",
"=",
"None",
",",
"source_type",
"=",
"DefaultSourceType",
")",
":",
"self",
".",
"add_source",
"(",
"FilteredFolderSource",
"(",
"path",
",",
"regex",
",",
"depth",
",",
"... | Add a folder source to scan recursively, with a regex filter on directories.
:param regex: regex string to filter folders by.
:param depth: if provided will be depth limit. 0 = first level only.
:param source_type: what to return; files only, folders only, or both. | [
"Add",
"a",
"folder",
"source",
"to",
"scan",
"recursively",
"with",
"a",
"regex",
"filter",
"on",
"directories",
"."
] | train | https://github.com/RonenNess/Fileter/blob/5372221b4049d5d46a9926573b91af17681c81f3/fileter/files_iterator.py#L110-L119 |
RonenNess/Fileter | fileter/files_iterator.py | FilesIterator.add_filter | def add_filter(self, files_filter, filter_type=DefaultFilterType):
"""
Add a files filter to this iterator.
For a file to be processed, it must match ALL filters, eg they are added with ADD, not OR.
:param files_filter: filter to apply, must be an object inheriting from filters.FilterAP... | python | def add_filter(self, files_filter, filter_type=DefaultFilterType):
"""
Add a files filter to this iterator.
For a file to be processed, it must match ALL filters, eg they are added with ADD, not OR.
:param files_filter: filter to apply, must be an object inheriting from filters.FilterAP... | [
"def",
"add_filter",
"(",
"self",
",",
"files_filter",
",",
"filter_type",
"=",
"DefaultFilterType",
")",
":",
"self",
".",
"__filters",
".",
"append",
"(",
"(",
"files_filter",
",",
"filter_type",
")",
")",
"return",
"self"
] | Add a files filter to this iterator.
For a file to be processed, it must match ALL filters, eg they are added with ADD, not OR.
:param files_filter: filter to apply, must be an object inheriting from filters.FilterAPI.
:param filter_type: filter behavior, see FilterType for details. | [
"Add",
"a",
"files",
"filter",
"to",
"this",
"iterator",
".",
"For",
"a",
"file",
"to",
"be",
"processed",
"it",
"must",
"match",
"ALL",
"filters",
"eg",
"they",
"are",
"added",
"with",
"ADD",
"not",
"OR",
"."
] | train | https://github.com/RonenNess/Fileter/blob/5372221b4049d5d46a9926573b91af17681c81f3/fileter/files_iterator.py#L121-L130 |
RonenNess/Fileter | fileter/files_iterator.py | FilesIterator.add_filter_by_pattern | def add_filter_by_pattern(self, pattern, filter_type=DefaultFilterType):
"""
Add a files filter by linux-style pattern to this iterator.
:param pattern: linux-style files pattern (or list of patterns)
"""
self.add_filter(FilterPattern(pattern), filter_type)
return self | python | def add_filter_by_pattern(self, pattern, filter_type=DefaultFilterType):
"""
Add a files filter by linux-style pattern to this iterator.
:param pattern: linux-style files pattern (or list of patterns)
"""
self.add_filter(FilterPattern(pattern), filter_type)
return self | [
"def",
"add_filter_by_pattern",
"(",
"self",
",",
"pattern",
",",
"filter_type",
"=",
"DefaultFilterType",
")",
":",
"self",
".",
"add_filter",
"(",
"FilterPattern",
"(",
"pattern",
")",
",",
"filter_type",
")",
"return",
"self"
] | Add a files filter by linux-style pattern to this iterator.
:param pattern: linux-style files pattern (or list of patterns) | [
"Add",
"a",
"files",
"filter",
"by",
"linux",
"-",
"style",
"pattern",
"to",
"this",
"iterator",
"."
] | train | https://github.com/RonenNess/Fileter/blob/5372221b4049d5d46a9926573b91af17681c81f3/fileter/files_iterator.py#L132-L139 |
RonenNess/Fileter | fileter/files_iterator.py | FilesIterator.add_filter_by_regex | def add_filter_by_regex(self, regex_expression, filter_type=DefaultFilterType):
"""
Add a files filter by regex to this iterator.
:param regex_expression: regex string to apply.
"""
self.add_filter(FilterRegex(regex_expression), filter_type)
return self | python | def add_filter_by_regex(self, regex_expression, filter_type=DefaultFilterType):
"""
Add a files filter by regex to this iterator.
:param regex_expression: regex string to apply.
"""
self.add_filter(FilterRegex(regex_expression), filter_type)
return self | [
"def",
"add_filter_by_regex",
"(",
"self",
",",
"regex_expression",
",",
"filter_type",
"=",
"DefaultFilterType",
")",
":",
"self",
".",
"add_filter",
"(",
"FilterRegex",
"(",
"regex_expression",
")",
",",
"filter_type",
")",
"return",
"self"
] | Add a files filter by regex to this iterator.
:param regex_expression: regex string to apply. | [
"Add",
"a",
"files",
"filter",
"by",
"regex",
"to",
"this",
"iterator",
"."
] | train | https://github.com/RonenNess/Fileter/blob/5372221b4049d5d46a9926573b91af17681c81f3/fileter/files_iterator.py#L141-L148 |
RonenNess/Fileter | fileter/files_iterator.py | FilesIterator.add_filter_by_extension | def add_filter_by_extension(self, extensions, filter_type=DefaultFilterType):
"""
Add a files filter by extensions to this iterator.
:param extensions: single extension or list of extensions to filter by.
for example: ["py", "js", "cpp", ...]
"""
self... | python | def add_filter_by_extension(self, extensions, filter_type=DefaultFilterType):
"""
Add a files filter by extensions to this iterator.
:param extensions: single extension or list of extensions to filter by.
for example: ["py", "js", "cpp", ...]
"""
self... | [
"def",
"add_filter_by_extension",
"(",
"self",
",",
"extensions",
",",
"filter_type",
"=",
"DefaultFilterType",
")",
":",
"self",
".",
"add_filter",
"(",
"FilterExtension",
"(",
"extensions",
")",
",",
"filter_type",
")",
"return",
"self"
] | Add a files filter by extensions to this iterator.
:param extensions: single extension or list of extensions to filter by.
for example: ["py", "js", "cpp", ...] | [
"Add",
"a",
"files",
"filter",
"by",
"extensions",
"to",
"this",
"iterator",
"."
] | train | https://github.com/RonenNess/Fileter/blob/5372221b4049d5d46a9926573b91af17681c81f3/fileter/files_iterator.py#L150-L158 |
RonenNess/Fileter | fileter/files_iterator.py | FilesIterator.next | def next(self, dryrun=False):
"""
Iterate over files in all sources.
Use this if you want to iterate files externally.
:param dryrun: if true, will only return all filenames instead of processing them, eg will not
call "process_file" at all, and just show all the... | python | def next(self, dryrun=False):
"""
Iterate over files in all sources.
Use this if you want to iterate files externally.
:param dryrun: if true, will only return all filenames instead of processing them, eg will not
call "process_file" at all, and just show all the... | [
"def",
"next",
"(",
"self",
",",
"dryrun",
"=",
"False",
")",
":",
"# call the start hook",
"self",
".",
"on_start",
"(",
"dryrun",
")",
"# store current dir",
"curr_dir",
"=",
"\"\"",
"# iterate over sources",
"for",
"src",
"in",
"self",
".",
"__sources",
":"... | Iterate over files in all sources.
Use this if you want to iterate files externally.
:param dryrun: if true, will only return all filenames instead of processing them, eg will not
call "process_file" at all, and just show all the files it will scan. | [
"Iterate",
"over",
"files",
"in",
"all",
"sources",
".",
"Use",
"this",
"if",
"you",
"want",
"to",
"iterate",
"files",
"externally",
"."
] | train | https://github.com/RonenNess/Fileter/blob/5372221b4049d5d46a9926573b91af17681c81f3/fileter/files_iterator.py#L190-L236 |
RonenNess/Fileter | fileter/files_iterator.py | FilesIterator.match_filters | def match_filters(self, path):
"""
Get filename and return True if file pass all filters and should be processed.
:param path: path to check.
:return: True if pass filters, false otherwise.
"""
# indicate if all required filters were matched
all_required_match = ... | python | def match_filters(self, path):
"""
Get filename and return True if file pass all filters and should be processed.
:param path: path to check.
:return: True if pass filters, false otherwise.
"""
# indicate if all required filters were matched
all_required_match = ... | [
"def",
"match_filters",
"(",
"self",
",",
"path",
")",
":",
"# indicate if all required filters were matched",
"all_required_match",
"=",
"True",
"# iterate over filters to match files",
"for",
"filt",
",",
"ftype",
"in",
"self",
".",
"__filters",
":",
"# handle \"Require... | Get filename and return True if file pass all filters and should be processed.
:param path: path to check.
:return: True if pass filters, false otherwise. | [
"Get",
"filename",
"and",
"return",
"True",
"if",
"file",
"pass",
"all",
"filters",
"and",
"should",
"be",
"processed",
"."
] | train | https://github.com/RonenNess/Fileter/blob/5372221b4049d5d46a9926573b91af17681c81f3/fileter/files_iterator.py#L284-L311 |
xtream1101/web-wrapper | web_wrapper/driver_selenium_phantomjs.py | DriverSeleniumPhantomJS.set_proxy | def set_proxy(self, proxy, update=True):
"""
Set proxy for requests session
"""
update_web_driver = False
if self.current_proxy != proxy:
# Did we change proxies?
update_web_driver = True
self.current_proxy = proxy
if proxy is None:
... | python | def set_proxy(self, proxy, update=True):
"""
Set proxy for requests session
"""
update_web_driver = False
if self.current_proxy != proxy:
# Did we change proxies?
update_web_driver = True
self.current_proxy = proxy
if proxy is None:
... | [
"def",
"set_proxy",
"(",
"self",
",",
"proxy",
",",
"update",
"=",
"True",
")",
":",
"update_web_driver",
"=",
"False",
"if",
"self",
".",
"current_proxy",
"!=",
"proxy",
":",
"# Did we change proxies?",
"update_web_driver",
"=",
"True",
"self",
".",
"current_... | Set proxy for requests session | [
"Set",
"proxy",
"for",
"requests",
"session"
] | train | https://github.com/xtream1101/web-wrapper/blob/2bfc63caa7d316564088951f01a490db493ea240/web_wrapper/driver_selenium_phantomjs.py#L63-L86 |
xtream1101/web-wrapper | web_wrapper/driver_selenium_phantomjs.py | DriverSeleniumPhantomJS._create_session | def _create_session(self):
"""
Creates a fresh session with no/default headers and proxies
"""
logger.debug("Create new phantomjs web driver")
self.driver = webdriver.PhantomJS(desired_capabilities=self.dcap,
**self.driver_args)
s... | python | def _create_session(self):
"""
Creates a fresh session with no/default headers and proxies
"""
logger.debug("Create new phantomjs web driver")
self.driver = webdriver.PhantomJS(desired_capabilities=self.dcap,
**self.driver_args)
s... | [
"def",
"_create_session",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Create new phantomjs web driver\"",
")",
"self",
".",
"driver",
"=",
"webdriver",
".",
"PhantomJS",
"(",
"desired_capabilities",
"=",
"self",
".",
"dcap",
",",
"*",
"*",
"self",
... | Creates a fresh session with no/default headers and proxies | [
"Creates",
"a",
"fresh",
"session",
"with",
"no",
"/",
"default",
"headers",
"and",
"proxies"
] | train | https://github.com/xtream1101/web-wrapper/blob/2bfc63caa7d316564088951f01a490db493ea240/web_wrapper/driver_selenium_phantomjs.py#L92-L100 |
xtream1101/web-wrapper | web_wrapper/driver_selenium_phantomjs.py | DriverSeleniumPhantomJS.reset | def reset(self):
"""
Kills old session and creates a new one with no proxies or headers
"""
# Kill old connection
self.quit()
# Clear proxy data
self.driver_args['service_args'] = self.default_service_args
# Clear headers
self.dcap = dict(webdriver... | python | def reset(self):
"""
Kills old session and creates a new one with no proxies or headers
"""
# Kill old connection
self.quit()
# Clear proxy data
self.driver_args['service_args'] = self.default_service_args
# Clear headers
self.dcap = dict(webdriver... | [
"def",
"reset",
"(",
"self",
")",
":",
"# Kill old connection",
"self",
".",
"quit",
"(",
")",
"# Clear proxy data",
"self",
".",
"driver_args",
"[",
"'service_args'",
"]",
"=",
"self",
".",
"default_service_args",
"# Clear headers",
"self",
".",
"dcap",
"=",
... | Kills old session and creates a new one with no proxies or headers | [
"Kills",
"old",
"session",
"and",
"creates",
"a",
"new",
"one",
"with",
"no",
"proxies",
"or",
"headers"
] | train | https://github.com/xtream1101/web-wrapper/blob/2bfc63caa7d316564088951f01a490db493ea240/web_wrapper/driver_selenium_phantomjs.py#L110-L121 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/generate/commands.py | SetPyclassMetaclass | def SetPyclassMetaclass(option, opt, value, parser, *args, **kwargs):
"""set up pyclass metaclass for complexTypes"""
from pyremotevbox.ZSI.generate.containers import ServiceHeaderContainer,\
TypecodeContainerBase, TypesHeaderContainer
TypecodeContainerBase.metaclass = kwargs['metaclass']
... | python | def SetPyclassMetaclass(option, opt, value, parser, *args, **kwargs):
"""set up pyclass metaclass for complexTypes"""
from pyremotevbox.ZSI.generate.containers import ServiceHeaderContainer,\
TypecodeContainerBase, TypesHeaderContainer
TypecodeContainerBase.metaclass = kwargs['metaclass']
... | [
"def",
"SetPyclassMetaclass",
"(",
"option",
",",
"opt",
",",
"value",
",",
"parser",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"pyremotevbox",
".",
"ZSI",
".",
"generate",
".",
"containers",
"import",
"ServiceHeaderContainer",
",",
"Typ... | set up pyclass metaclass for complexTypes | [
"set",
"up",
"pyclass",
"metaclass",
"for",
"complexTypes"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/commands.py#L27-L38 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/generate/commands.py | wsdl2py | def wsdl2py(args=None):
"""Utility for automatically generating client/service interface code from
a wsdl definition, and a set of classes representing element declarations
and type definitions. By default invoking this script produces three files,
each named after the wsdl definition name, in the cu... | python | def wsdl2py(args=None):
"""Utility for automatically generating client/service interface code from
a wsdl definition, and a set of classes representing element declarations
and type definitions. By default invoking this script produces three files,
each named after the wsdl definition name, in the cu... | [
"def",
"wsdl2py",
"(",
"args",
"=",
"None",
")",
":",
"op",
"=",
"optparse",
".",
"OptionParser",
"(",
"usage",
"=",
"\"USAGE: %wsdl2py [options] WSDL\"",
",",
"description",
"=",
"wsdl2py",
".",
"__doc__",
")",
"# Basic options",
"op",
".",
"add_option",
"(",... | Utility for automatically generating client/service interface code from
a wsdl definition, and a set of classes representing element declarations
and type definitions. By default invoking this script produces three files,
each named after the wsdl definition name, in the current working directory.
... | [
"Utility",
"for",
"automatically",
"generating",
"client",
"/",
"service",
"interface",
"code",
"from",
"a",
"wsdl",
"definition",
"and",
"a",
"set",
"of",
"classes",
"representing",
"element",
"declarations",
"and",
"type",
"definitions",
".",
"By",
"default",
... | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/commands.py#L46-L156 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/generate/commands.py | _wsdl2dispatch | def _wsdl2dispatch(options, wsdl):
"""TOOD: Remove ServiceContainer stuff, and replace with WSGI.
"""
kw = dict()
if options.twisted:
from pyremotevbox.ZSI.twisted.WSresource import WSResource
kw['base'] = WSResource
ss = ServiceDescription(**kw)
if options.address is Tru... | python | def _wsdl2dispatch(options, wsdl):
"""TOOD: Remove ServiceContainer stuff, and replace with WSGI.
"""
kw = dict()
if options.twisted:
from pyremotevbox.ZSI.twisted.WSresource import WSResource
kw['base'] = WSResource
ss = ServiceDescription(**kw)
if options.address is Tru... | [
"def",
"_wsdl2dispatch",
"(",
"options",
",",
"wsdl",
")",
":",
"kw",
"=",
"dict",
"(",
")",
"if",
"options",
".",
"twisted",
":",
"from",
"pyremotevbox",
".",
"ZSI",
".",
"twisted",
".",
"WSresource",
"import",
"WSResource",
"kw",
"[",
"'base'",
"]",
... | TOOD: Remove ServiceContainer stuff, and replace with WSGI. | [
"TOOD",
":",
"Remove",
"ServiceContainer",
"stuff",
"and",
"replace",
"with",
"WSGI",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/commands.py#L246-L269 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/generate/commands.py | _writedoc | def _writedoc(doc, thing, forceload=0):
"""Write HTML documentation to a file in the current directory.
"""
try:
object, name = pydoc.resolve(thing, forceload)
page = pydoc.html.page(pydoc.describe(object), pydoc.html.document(object, name))
fname = os.path.join(doc, name + '.html')
... | python | def _writedoc(doc, thing, forceload=0):
"""Write HTML documentation to a file in the current directory.
"""
try:
object, name = pydoc.resolve(thing, forceload)
page = pydoc.html.page(pydoc.describe(object), pydoc.html.document(object, name))
fname = os.path.join(doc, name + '.html')
... | [
"def",
"_writedoc",
"(",
"doc",
",",
"thing",
",",
"forceload",
"=",
"0",
")",
":",
"try",
":",
"object",
",",
"name",
"=",
"pydoc",
".",
"resolve",
"(",
"thing",
",",
"forceload",
")",
"page",
"=",
"pydoc",
".",
"html",
".",
"page",
"(",
"pydoc",
... | Write HTML documentation to a file in the current directory. | [
"Write",
"HTML",
"documentation",
"to",
"a",
"file",
"in",
"the",
"current",
"directory",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/commands.py#L327-L340 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/generate/commands.py | _writeclientdoc | def _writeclientdoc(doc, thing, forceload=0):
"""Write HTML documentation to a file in the current directory.
"""
docmodule = pydoc.HTMLDoc.docmodule
def strongarm(self, object, name=None, mod=None, *ignored):
result = docmodule(self, object, name, mod, *ignored)
# Grab all the aliases ... | python | def _writeclientdoc(doc, thing, forceload=0):
"""Write HTML documentation to a file in the current directory.
"""
docmodule = pydoc.HTMLDoc.docmodule
def strongarm(self, object, name=None, mod=None, *ignored):
result = docmodule(self, object, name, mod, *ignored)
# Grab all the aliases ... | [
"def",
"_writeclientdoc",
"(",
"doc",
",",
"thing",
",",
"forceload",
"=",
"0",
")",
":",
"docmodule",
"=",
"pydoc",
".",
"HTMLDoc",
".",
"docmodule",
"def",
"strongarm",
"(",
"self",
",",
"object",
",",
"name",
"=",
"None",
",",
"mod",
"=",
"None",
... | Write HTML documentation to a file in the current directory. | [
"Write",
"HTML",
"documentation",
"to",
"a",
"file",
"in",
"the",
"current",
"directory",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/commands.py#L343-L371 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/generate/commands.py | _writetypesdoc | def _writetypesdoc(doc, thing, forceload=0):
"""Write HTML documentation to a file in the current directory.
"""
try:
object, name = pydoc.resolve(thing, forceload)
name = os.path.join(doc, name + '.html')
except (ImportError, pydoc.ErrorDuringImport), value:
log.debug(str(value)... | python | def _writetypesdoc(doc, thing, forceload=0):
"""Write HTML documentation to a file in the current directory.
"""
try:
object, name = pydoc.resolve(thing, forceload)
name = os.path.join(doc, name + '.html')
except (ImportError, pydoc.ErrorDuringImport), value:
log.debug(str(value)... | [
"def",
"_writetypesdoc",
"(",
"doc",
",",
"thing",
",",
"forceload",
"=",
"0",
")",
":",
"try",
":",
"object",
",",
"name",
"=",
"pydoc",
".",
"resolve",
"(",
"thing",
",",
"forceload",
")",
"name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"doc",
... | Write HTML documentation to a file in the current directory. | [
"Write",
"HTML",
"documentation",
"to",
"a",
"file",
"in",
"the",
"current",
"directory",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/commands.py#L373-L485 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/generate/commands.py | _writepydoc | def _writepydoc(doc, *args):
"""create pydoc html pages
doc -- destination directory for documents
*args -- modules run thru pydoc
"""
ok = True
if not os.path.isdir(doc):
os.makedirs(doc)
if os.path.curdir not in sys.path:
sys.path.append(os.path.curdir)
for f in a... | python | def _writepydoc(doc, *args):
"""create pydoc html pages
doc -- destination directory for documents
*args -- modules run thru pydoc
"""
ok = True
if not os.path.isdir(doc):
os.makedirs(doc)
if os.path.curdir not in sys.path:
sys.path.append(os.path.curdir)
for f in a... | [
"def",
"_writepydoc",
"(",
"doc",
",",
"*",
"args",
")",
":",
"ok",
"=",
"True",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"doc",
")",
":",
"os",
".",
"makedirs",
"(",
"doc",
")",
"if",
"os",
".",
"path",
".",
"curdir",
"not",
"in",
... | create pydoc html pages
doc -- destination directory for documents
*args -- modules run thru pydoc | [
"create",
"pydoc",
"html",
"pages",
"doc",
"--",
"destination",
"directory",
"for",
"documents",
"*",
"args",
"--",
"modules",
"run",
"thru",
"pydoc"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/commands.py#L501-L535 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.