repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
brunato/lograptor | lograptor/matcher.py | create_matcher | def create_matcher(dispatcher, parsers, apptags, matcher='ruled', hosts=tuple(), time_range=None,
time_period=(None, None), patterns=tuple(), invert=False, count=False,
files_with_match=None, max_count=0, only_matching=False, quiet=False,
thread=False, name_cache... | python | def create_matcher(dispatcher, parsers, apptags, matcher='ruled', hosts=tuple(), time_range=None,
time_period=(None, None), patterns=tuple(), invert=False, count=False,
files_with_match=None, max_count=0, only_matching=False, quiet=False,
thread=False, name_cache... | [
"def",
"create_matcher",
"(",
"dispatcher",
",",
"parsers",
",",
"apptags",
",",
"matcher",
"=",
"'ruled'",
",",
"hosts",
"=",
"tuple",
"(",
")",
",",
"time_range",
"=",
"None",
",",
"time_period",
"=",
"(",
"None",
",",
"None",
")",
",",
"patterns",
"... | Create a matcher engine.
:return: A matcher function. | [
"Create",
"a",
"matcher",
"engine",
".",
":",
"return",
":",
"A",
"matcher",
"function",
"."
] | b1f09fe1b429ed15110610092704ef12d253f3c9 | https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/matcher.py#L175-L405 | train | Create a matcher engine. |
Kortemme-Lab/klab | klab/pymath/discrete.py | dumb_relative_half_prime | def dumb_relative_half_prime(n, divisor = None):
'''A dumb brute-force algorithm to find a relative prime for n which is approximately n/2 through n/5.
It is used for generating spaced colors.
Written on a Friday evening. Do not judge!
'''
if n < 1 or not isinstance(n, int):
raise Exce... | python | def dumb_relative_half_prime(n, divisor = None):
'''A dumb brute-force algorithm to find a relative prime for n which is approximately n/2 through n/5.
It is used for generating spaced colors.
Written on a Friday evening. Do not judge!
'''
if n < 1 or not isinstance(n, int):
raise Exce... | [
"def",
"dumb_relative_half_prime",
"(",
"n",
",",
"divisor",
"=",
"None",
")",
":",
"if",
"n",
"<",
"1",
"or",
"not",
"isinstance",
"(",
"n",
",",
"int",
")",
":",
"raise",
"Exception",
"(",
"'n must be a positive non-zero integer.'",
")",
"elif",
"n",
"<"... | A dumb brute-force algorithm to find a relative prime for n which is approximately n/2 through n/5.
It is used for generating spaced colors.
Written on a Friday evening. Do not judge! | [
"A",
"dumb",
"brute",
"-",
"force",
"algorithm",
"to",
"find",
"a",
"relative",
"prime",
"for",
"n",
"which",
"is",
"approximately",
"n",
"/",
"2",
"through",
"n",
"/",
"5",
".",
"It",
"is",
"used",
"for",
"generating",
"spaced",
"colors",
".",
"Writte... | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/pymath/discrete.py#L22-L46 | train | A dumb brute - force algorithm to find a relative prime for n which is approximately n through n / 2 through n / 5. Do not judge! |
aacanakin/glim | glim/commands.py | NewCommand.run | def run(self, app):
"""Function copies the prototype folder into os.getcwd() path."""
project_path = os.getcwd()
if self.args.name is not None:
project_path = os.path.join(project_path, self.args.name)
proto_path = paths.PROTO_PATH
try:
copytree(proto_pa... | python | def run(self, app):
"""Function copies the prototype folder into os.getcwd() path."""
project_path = os.getcwd()
if self.args.name is not None:
project_path = os.path.join(project_path, self.args.name)
proto_path = paths.PROTO_PATH
try:
copytree(proto_pa... | [
"def",
"run",
"(",
"self",
",",
"app",
")",
":",
"project_path",
"=",
"os",
".",
"getcwd",
"(",
")",
"if",
"self",
".",
"args",
".",
"name",
"is",
"not",
"None",
":",
"project_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"project_path",
",",
... | Function copies the prototype folder into os.getcwd() path. | [
"Function",
"copies",
"the",
"prototype",
"folder",
"into",
"os",
".",
"getcwd",
"()",
"path",
"."
] | 71a20ac149a1292c0d6c1dc7414985ea51854f7a | https://github.com/aacanakin/glim/blob/71a20ac149a1292c0d6c1dc7414985ea51854f7a/glim/commands.py#L39-L52 | train | Function copies the prototype folder into os. getcwd() path. |
aacanakin/glim | glim/commands.py | StartCommand.run | def run(self, app):
"""Function starts the web server given configuration."""
GlimLog.info('Glim server started on %s environment' % self.args.env)
try:
kwargs = Config.get('app.server.options')
run(app.wsgi,
host=Config.get('app.server.host'),
... | python | def run(self, app):
"""Function starts the web server given configuration."""
GlimLog.info('Glim server started on %s environment' % self.args.env)
try:
kwargs = Config.get('app.server.options')
run(app.wsgi,
host=Config.get('app.server.host'),
... | [
"def",
"run",
"(",
"self",
",",
"app",
")",
":",
"GlimLog",
".",
"info",
"(",
"'Glim server started on %s environment'",
"%",
"self",
".",
"args",
".",
"env",
")",
"try",
":",
"kwargs",
"=",
"Config",
".",
"get",
"(",
"'app.server.options'",
")",
"run",
... | Function starts the web server given configuration. | [
"Function",
"starts",
"the",
"web",
"server",
"given",
"configuration",
"."
] | 71a20ac149a1292c0d6c1dc7414985ea51854f7a | https://github.com/aacanakin/glim/blob/71a20ac149a1292c0d6c1dc7414985ea51854f7a/glim/commands.py#L66-L80 | train | Function starts the web server given configuration. |
Kortemme-Lab/klab | klab/benchmarking/analysis/ssm.py | get_symmetrical_std_dev | def get_symmetrical_std_dev(values, take_positive_values, ignore_zeros = True):
"""Computes the standard deviation of either the positive or negative subset of values.
The subset is first converted into a symmetrical set of values by unioning it with its complemented/mirrored set
along the origin i.e.... | python | def get_symmetrical_std_dev(values, take_positive_values, ignore_zeros = True):
"""Computes the standard deviation of either the positive or negative subset of values.
The subset is first converted into a symmetrical set of values by unioning it with its complemented/mirrored set
along the origin i.e.... | [
"def",
"get_symmetrical_std_dev",
"(",
"values",
",",
"take_positive_values",
",",
"ignore_zeros",
"=",
"True",
")",
":",
"if",
"take_positive_values",
":",
"if",
"ignore_zeros",
":",
"temp_pos",
"=",
"np",
".",
"array",
"(",
"[",
"value",
"for",
"value",
"in"... | Computes the standard deviation of either the positive or negative subset of values.
The subset is first converted into a symmetrical set of values by unioning it with its complemented/mirrored set
along the origin i.e. if x is a value in the subset then both x and -x are members of the symmetrical set.
... | [
"Computes",
"the",
"standard",
"deviation",
"of",
"either",
"the",
"positive",
"or",
"negative",
"subset",
"of",
"values",
".",
"The",
"subset",
"is",
"first",
"converted",
"into",
"a",
"symmetrical",
"set",
"of",
"values",
"by",
"unioning",
"it",
"with",
"i... | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/benchmarking/analysis/ssm.py#L124-L157 | train | Calculates the standard deviation of the positive or negative set of values. |
Kortemme-Lab/klab | klab/benchmarking/analysis/ssm.py | get_symmetrical_std_devs | def get_symmetrical_std_devs(values, ignore_zeros = True):
"""Takes a list of values and splits it into positive and negative values. For both of these subsets, a symmetrical
distribution is created by mirroring each value along the origin and the standard deviation for both subsets is returned.
:param ... | python | def get_symmetrical_std_devs(values, ignore_zeros = True):
"""Takes a list of values and splits it into positive and negative values. For both of these subsets, a symmetrical
distribution is created by mirroring each value along the origin and the standard deviation for both subsets is returned.
:param ... | [
"def",
"get_symmetrical_std_devs",
"(",
"values",
",",
"ignore_zeros",
"=",
"True",
")",
":",
"pos_stdeviation",
"=",
"get_symmetrical_std_dev",
"(",
"values",
",",
"True",
",",
"ignore_zeros",
"=",
"ignore_zeros",
")",
"neg_stdeviation",
"=",
"get_symmetrical_std_dev... | Takes a list of values and splits it into positive and negative values. For both of these subsets, a symmetrical
distribution is created by mirroring each value along the origin and the standard deviation for both subsets is returned.
:param values: A list of numerical values.
:param ignore_zeros: Wheth... | [
"Takes",
"a",
"list",
"of",
"values",
"and",
"splits",
"it",
"into",
"positive",
"and",
"negative",
"values",
".",
"For",
"both",
"of",
"these",
"subsets",
"a",
"symmetrical",
"distribution",
"is",
"created",
"by",
"mirroring",
"each",
"value",
"along",
"the... | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/benchmarking/analysis/ssm.py#L160-L170 | train | Takes a list of values and splits it into positive and negative values. |
Kortemme-Lab/klab | klab/benchmarking/analysis/ssm.py | parse_csv | def parse_csv(csv_lines, expect_negative_correlation = False, STDev_cutoff = 1.0, headers_start_with = 'ID', comments_start_with = None, separator = ','):
"""
Analyzes lines in CSV format.
Expects the first line to be a header line starting with headers_start_with e.g. "ID,experimental value, prediction 1 ... | python | def parse_csv(csv_lines, expect_negative_correlation = False, STDev_cutoff = 1.0, headers_start_with = 'ID', comments_start_with = None, separator = ','):
"""
Analyzes lines in CSV format.
Expects the first line to be a header line starting with headers_start_with e.g. "ID,experimental value, prediction 1 ... | [
"def",
"parse_csv",
"(",
"csv_lines",
",",
"expect_negative_correlation",
"=",
"False",
",",
"STDev_cutoff",
"=",
"1.0",
",",
"headers_start_with",
"=",
"'ID'",
",",
"comments_start_with",
"=",
"None",
",",
"separator",
"=",
"','",
")",
":",
"data",
"=",
"{",
... | Analyzes lines in CSV format.
Expects the first line to be a header line starting with headers_start_with e.g. "ID,experimental value, prediction 1 value, prediction 2 value,"
Record IDs are expected in the first column.
Experimental values are expected in the second column.
Predicted values are expect... | [
"Analyzes",
"lines",
"in",
"CSV",
"format",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/benchmarking/analysis/ssm.py#L344-L453 | train | Parses a CSV file containing experimental and predicted data. |
Kortemme-Lab/klab | klab/benchmarking/analysis/ssm.py | parse_csv_file | def parse_csv_file(csv_filepath, expect_negative_correlation = False, STDev_cutoff = 1.0, headers_start_with = 'ID', comments_start_with = None, separator = ','):
"""
Analyzes a CSV file.
Expects a CSV file with a header line starting with headers_start_with e.g. "ID,experimental value, prediction 1 value, ... | python | def parse_csv_file(csv_filepath, expect_negative_correlation = False, STDev_cutoff = 1.0, headers_start_with = 'ID', comments_start_with = None, separator = ','):
"""
Analyzes a CSV file.
Expects a CSV file with a header line starting with headers_start_with e.g. "ID,experimental value, prediction 1 value, ... | [
"def",
"parse_csv_file",
"(",
"csv_filepath",
",",
"expect_negative_correlation",
"=",
"False",
",",
"STDev_cutoff",
"=",
"1.0",
",",
"headers_start_with",
"=",
"'ID'",
",",
"comments_start_with",
"=",
"None",
",",
"separator",
"=",
"','",
")",
":",
"assert",
"(... | Analyzes a CSV file.
Expects a CSV file with a header line starting with headers_start_with e.g. "ID,experimental value, prediction 1 value, prediction 2 value,"
Record IDs are expected in the first column.
Experimental values are expected in the second column.
Predicted values are expected in the subse... | [
"Analyzes",
"a",
"CSV",
"file",
".",
"Expects",
"a",
"CSV",
"file",
"with",
"a",
"header",
"line",
"starting",
"with",
"headers_start_with",
"e",
".",
"g",
".",
"ID",
"experimental",
"value",
"prediction",
"1",
"value",
"prediction",
"2",
"value",
"Record",
... | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/benchmarking/analysis/ssm.py#L461-L479 | train | Parses a CSV file and returns a list of Record objects. |
Kortemme-Lab/klab | klab/benchmarking/analysis/ssm.py | get_std_xy_dataset_statistics | def get_std_xy_dataset_statistics(x_values, y_values, expect_negative_correlation = False, STDev_cutoff = 1.0):
'''Calls parse_csv and returns the analysis in a format similar to get_xy_dataset_statistics in klab.stats.misc.'''
assert(len(x_values) == len(y_values))
csv_lines = ['ID,X,Y'] + [','.join(map(st... | python | def get_std_xy_dataset_statistics(x_values, y_values, expect_negative_correlation = False, STDev_cutoff = 1.0):
'''Calls parse_csv and returns the analysis in a format similar to get_xy_dataset_statistics in klab.stats.misc.'''
assert(len(x_values) == len(y_values))
csv_lines = ['ID,X,Y'] + [','.join(map(st... | [
"def",
"get_std_xy_dataset_statistics",
"(",
"x_values",
",",
"y_values",
",",
"expect_negative_correlation",
"=",
"False",
",",
"STDev_cutoff",
"=",
"1.0",
")",
":",
"assert",
"(",
"len",
"(",
"x_values",
")",
"==",
"len",
"(",
"y_values",
")",
")",
"csv_line... | Calls parse_csv and returns the analysis in a format similar to get_xy_dataset_statistics in klab.stats.misc. | [
"Calls",
"parse_csv",
"and",
"returns",
"the",
"analysis",
"in",
"a",
"format",
"similar",
"to",
"get_xy_dataset_statistics",
"in",
"klab",
".",
"stats",
".",
"misc",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/benchmarking/analysis/ssm.py#L482-L500 | train | Calls parse_csv and returns the analysis in a format similar to get_xy_dataset_statistics in klab. stats. misc. |
clement-alexandre/TotemBionet | totembionet/src/discrete_model/gene.py | Gene.active_multiplex | def active_multiplex(self, state: 'State') -> Tuple['Multiplex']:
"""
Return a tuple of all the active multiplex in the given state.
"""
return tuple(multiplex for multiplex in self.multiplexes if multiplex.is_active(state)) | python | def active_multiplex(self, state: 'State') -> Tuple['Multiplex']:
"""
Return a tuple of all the active multiplex in the given state.
"""
return tuple(multiplex for multiplex in self.multiplexes if multiplex.is_active(state)) | [
"def",
"active_multiplex",
"(",
"self",
",",
"state",
":",
"'State'",
")",
"->",
"Tuple",
"[",
"'Multiplex'",
"]",
":",
"return",
"tuple",
"(",
"multiplex",
"for",
"multiplex",
"in",
"self",
".",
"multiplexes",
"if",
"multiplex",
".",
"is_active",
"(",
"st... | Return a tuple of all the active multiplex in the given state. | [
"Return",
"a",
"tuple",
"of",
"all",
"the",
"active",
"multiplex",
"in",
"the",
"given",
"state",
"."
] | f37a2f9358c1ce49f21c4a868b904da5dcd4614f | https://github.com/clement-alexandre/TotemBionet/blob/f37a2f9358c1ce49f21c4a868b904da5dcd4614f/totembionet/src/discrete_model/gene.py#L16-L20 | train | Return a tuple of all the active multiplexes in the given state. |
assamite/creamas | creamas/core/agent.py | CreativeAgent.sanitized_name | def sanitized_name(self):
"""Sanitized name of the agent, used for file and directory creation.
"""
a = re.split("[:/]", self.name)
return "_".join([i for i in a if len(i) > 0]) | python | def sanitized_name(self):
"""Sanitized name of the agent, used for file and directory creation.
"""
a = re.split("[:/]", self.name)
return "_".join([i for i in a if len(i) > 0]) | [
"def",
"sanitized_name",
"(",
"self",
")",
":",
"a",
"=",
"re",
".",
"split",
"(",
"\"[:/]\"",
",",
"self",
".",
"name",
")",
"return",
"\"_\"",
".",
"join",
"(",
"[",
"i",
"for",
"i",
"in",
"a",
"if",
"len",
"(",
"i",
")",
">",
"0",
"]",
")"... | Sanitized name of the agent, used for file and directory creation. | [
"Sanitized",
"name",
"of",
"the",
"agent",
"used",
"for",
"file",
"and",
"directory",
"creation",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/core/agent.py#L93-L97 | train | Sanitize the name of the agent used for file and directory creation. |
assamite/creamas | creamas/core/agent.py | CreativeAgent.add_artifact | def add_artifact(self, artifact):
"""Add artifact to :attr:`A`.
:raises TypeError:
If the artifact is not derived from
:class:`~creamas.core.artifact.Artifact`.
"""
if not issubclass(artifact.__class__, Artifact):
raise TypeError("Artifact to add ({})... | python | def add_artifact(self, artifact):
"""Add artifact to :attr:`A`.
:raises TypeError:
If the artifact is not derived from
:class:`~creamas.core.artifact.Artifact`.
"""
if not issubclass(artifact.__class__, Artifact):
raise TypeError("Artifact to add ({})... | [
"def",
"add_artifact",
"(",
"self",
",",
"artifact",
")",
":",
"if",
"not",
"issubclass",
"(",
"artifact",
".",
"__class__",
",",
"Artifact",
")",
":",
"raise",
"TypeError",
"(",
"\"Artifact to add ({}) is not {}.\"",
".",
"format",
"(",
"artifact",
",",
"Arti... | Add artifact to :attr:`A`.
:raises TypeError:
If the artifact is not derived from
:class:`~creamas.core.artifact.Artifact`. | [
"Add",
"artifact",
"to",
":",
"attr",
":",
"A",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/core/agent.py#L168-L178 | train | Adds an artifact to the internal list. |
assamite/creamas | creamas/core/agent.py | CreativeAgent.add_connection | def add_connection(self, addr, **kwargs):
"""Add an agent with given address to current :attr:`connections` with
given information.
Does nothing if address is already in :attr:`connections`. Given
``**kwargs`` are stored as key-value pairs to ``connections[addr]``
dictionary.
... | python | def add_connection(self, addr, **kwargs):
"""Add an agent with given address to current :attr:`connections` with
given information.
Does nothing if address is already in :attr:`connections`. Given
``**kwargs`` are stored as key-value pairs to ``connections[addr]``
dictionary.
... | [
"def",
"add_connection",
"(",
"self",
",",
"addr",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"addr",
"not",
"in",
"self",
".",
"_connections",
":",
"self",
".",
"connections",
"[",
"addr",
"]",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"kwargs",
... | Add an agent with given address to current :attr:`connections` with
given information.
Does nothing if address is already in :attr:`connections`. Given
``**kwargs`` are stored as key-value pairs to ``connections[addr]``
dictionary.
:param str addr:
Address of the ag... | [
"Add",
"an",
"agent",
"with",
"given",
"address",
"to",
"current",
":",
"attr",
":",
"connections",
"with",
"given",
"information",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/core/agent.py#L181-L199 | train | Add an agent with given address to current : attr : connections with given information. |
assamite/creamas | creamas/core/agent.py | CreativeAgent.add_connections | def add_connections(self, conns):
"""Add agents from :attr:`conns` to :attr:`connections`.
:param list conns: A list of ``(addr, kwargs)``-tuples
:returns:
A boolean list, as returned by
:meth:`~creamas.core.agent.CreativeAgent.add_connections`.
"""
rets ... | python | def add_connections(self, conns):
"""Add agents from :attr:`conns` to :attr:`connections`.
:param list conns: A list of ``(addr, kwargs)``-tuples
:returns:
A boolean list, as returned by
:meth:`~creamas.core.agent.CreativeAgent.add_connections`.
"""
rets ... | [
"def",
"add_connections",
"(",
"self",
",",
"conns",
")",
":",
"rets",
"=",
"[",
"]",
"for",
"addr",
",",
"kwargs",
"in",
"conns",
":",
"r",
"=",
"self",
".",
"add_connection",
"(",
"addr",
",",
"*",
"*",
"kwargs",
")",
"rets",
".",
"append",
"(",
... | Add agents from :attr:`conns` to :attr:`connections`.
:param list conns: A list of ``(addr, kwargs)``-tuples
:returns:
A boolean list, as returned by
:meth:`~creamas.core.agent.CreativeAgent.add_connections`. | [
"Add",
"agents",
"from",
":",
"attr",
":",
"conns",
"to",
":",
"attr",
":",
"connections",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/core/agent.py#L202-L214 | train | Adds agents from conns to self. connections. |
assamite/creamas | creamas/core/agent.py | CreativeAgent.get_connections | def get_connections(self, data=False):
"""Get agent's current connections.
:param bool data:
Also return the data dictionary for each connection.
:returns: A list of agent addresses or a dictionary
"""
if data:
return self._connections
return lis... | python | def get_connections(self, data=False):
"""Get agent's current connections.
:param bool data:
Also return the data dictionary for each connection.
:returns: A list of agent addresses or a dictionary
"""
if data:
return self._connections
return lis... | [
"def",
"get_connections",
"(",
"self",
",",
"data",
"=",
"False",
")",
":",
"if",
"data",
":",
"return",
"self",
".",
"_connections",
"return",
"list",
"(",
"self",
".",
"_connections",
".",
"keys",
"(",
")",
")"
] | Get agent's current connections.
:param bool data:
Also return the data dictionary for each connection.
:returns: A list of agent addresses or a dictionary | [
"Get",
"agent",
"s",
"current",
"connections",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/core/agent.py#L229-L239 | train | Get agent s current connections. |
assamite/creamas | creamas/core/agent.py | CreativeAgent.random_connection | async def random_connection(self):
"""Connect to random agent from current :attr:`connections`.
:returns: :class:`aiomas.Proxy` object for the connected agent.
"""
addr = choice(list(self._connections.keys()))
return await self.env.connect(addr) | python | async def random_connection(self):
"""Connect to random agent from current :attr:`connections`.
:returns: :class:`aiomas.Proxy` object for the connected agent.
"""
addr = choice(list(self._connections.keys()))
return await self.env.connect(addr) | [
"async",
"def",
"random_connection",
"(",
"self",
")",
":",
"addr",
"=",
"choice",
"(",
"list",
"(",
"self",
".",
"_connections",
".",
"keys",
"(",
")",
")",
")",
"return",
"await",
"self",
".",
"env",
".",
"connect",
"(",
"addr",
")"
] | Connect to random agent from current :attr:`connections`.
:returns: :class:`aiomas.Proxy` object for the connected agent. | [
"Connect",
"to",
"random",
"agent",
"from",
"current",
":",
"attr",
":",
"connections",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/core/agent.py#L251-L257 | train | Connect to random agent from current connections. |
assamite/creamas | creamas/core/agent.py | CreativeAgent.publish | def publish(self, artifact):
"""Publish artifact to agent's environment.
:param artifact: artifact to be published
:type artifact: :py:class:`~creamas.core.artifact.Artifact`
"""
self.env.add_artifact(artifact)
self._log(logging.DEBUG, "Published {} to domain.".format(ar... | python | def publish(self, artifact):
"""Publish artifact to agent's environment.
:param artifact: artifact to be published
:type artifact: :py:class:`~creamas.core.artifact.Artifact`
"""
self.env.add_artifact(artifact)
self._log(logging.DEBUG, "Published {} to domain.".format(ar... | [
"def",
"publish",
"(",
"self",
",",
"artifact",
")",
":",
"self",
".",
"env",
".",
"add_artifact",
"(",
"artifact",
")",
"self",
".",
"_log",
"(",
"logging",
".",
"DEBUG",
",",
"\"Published {} to domain.\"",
".",
"format",
"(",
"artifact",
")",
")"
] | Publish artifact to agent's environment.
:param artifact: artifact to be published
:type artifact: :py:class:`~creamas.core.artifact.Artifact` | [
"Publish",
"artifact",
"to",
"agent",
"s",
"environment",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/core/agent.py#L259-L266 | train | Publish an artifact to the environment. |
assamite/creamas | creamas/core/agent.py | CreativeAgent.ask_opinion | async def ask_opinion(self, addr, artifact):
"""Ask an agent's opinion about an artifact.
:param str addr: Address of the agent which opinion is asked
:type addr: :py:class:`~creamas.core.agent.CreativeAgent`
:param object artifact: artifact to be evaluated
:returns: agent's eva... | python | async def ask_opinion(self, addr, artifact):
"""Ask an agent's opinion about an artifact.
:param str addr: Address of the agent which opinion is asked
:type addr: :py:class:`~creamas.core.agent.CreativeAgent`
:param object artifact: artifact to be evaluated
:returns: agent's eva... | [
"async",
"def",
"ask_opinion",
"(",
"self",
",",
"addr",
",",
"artifact",
")",
":",
"remote_agent",
"=",
"await",
"self",
".",
"env",
".",
"connect",
"(",
"addr",
")",
"return",
"await",
"remote_agent",
".",
"evaluate",
"(",
"artifact",
")"
] | Ask an agent's opinion about an artifact.
:param str addr: Address of the agent which opinion is asked
:type addr: :py:class:`~creamas.core.agent.CreativeAgent`
:param object artifact: artifact to be evaluated
:returns: agent's evaluation of the artifact
:rtype: float
T... | [
"Ask",
"an",
"agent",
"s",
"opinion",
"about",
"an",
"artifact",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/core/agent.py#L280-L299 | train | Ask an agent s opinion about an artifact. |
projectshift/shift-boiler | boiler/feature/localization.py | localization_feature | def localization_feature(app):
"""
Localization feature
This will initialize support for translations and localization of values
such as numbers, money, dates and formatting timezones.
"""
# apply app default to babel
app.config['BABEL_DEFAULT_LOCALE'] = app.config['DEFAULT_LOCALE']
app... | python | def localization_feature(app):
"""
Localization feature
This will initialize support for translations and localization of values
such as numbers, money, dates and formatting timezones.
"""
# apply app default to babel
app.config['BABEL_DEFAULT_LOCALE'] = app.config['DEFAULT_LOCALE']
app... | [
"def",
"localization_feature",
"(",
"app",
")",
":",
"# apply app default to babel",
"app",
".",
"config",
"[",
"'BABEL_DEFAULT_LOCALE'",
"]",
"=",
"app",
".",
"config",
"[",
"'DEFAULT_LOCALE'",
"]",
"app",
".",
"config",
"[",
"'BABEL_DEFAULT_TIMEZONE'",
"]",
"=",... | Localization feature
This will initialize support for translations and localization of values
such as numbers, money, dates and formatting timezones. | [
"Localization",
"feature",
"This",
"will",
"initialize",
"support",
"for",
"translations",
"and",
"localization",
"of",
"values",
"such",
"as",
"numbers",
"money",
"dates",
"and",
"formatting",
"timezones",
"."
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/feature/localization.py#L4-L17 | train | A convenience feature for localization of values in a node. |
adaptive-learning/proso-apps | proso/django/enrichment.py | enrich_json_objects_by_object_type | def enrich_json_objects_by_object_type(request, value):
"""
Take the given value and start enrichment by object_type. The va
Args:
request (django.http.request.HttpRequest): request which is currently processed
value (dict|list|django.db.models.Model):
in case of django.db.model... | python | def enrich_json_objects_by_object_type(request, value):
"""
Take the given value and start enrichment by object_type. The va
Args:
request (django.http.request.HttpRequest): request which is currently processed
value (dict|list|django.db.models.Model):
in case of django.db.model... | [
"def",
"enrich_json_objects_by_object_type",
"(",
"request",
",",
"value",
")",
":",
"time_start_globally",
"=",
"time",
"(",
")",
"if",
"isinstance",
"(",
"value",
",",
"list",
")",
":",
"json",
"=",
"[",
"x",
".",
"to_json",
"(",
")",
"if",
"hasattr",
... | Take the given value and start enrichment by object_type. The va
Args:
request (django.http.request.HttpRequest): request which is currently processed
value (dict|list|django.db.models.Model):
in case of django.db.models.Model object (or list of these
objects), to_json metho... | [
"Take",
"the",
"given",
"value",
"and",
"start",
"enrichment",
"by",
"object_type",
".",
"The",
"va"
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso/django/enrichment.py#L70-L108 | train | Start enrichment by object_type. |
adaptive-learning/proso-apps | proso/django/enrichment.py | enrich_by_predicate | def enrich_by_predicate(request, json, fun, predicate, skip_nested=False, **kwargs):
"""
Take the JSON, find all its subparts satisfying the given condition and
them by the given function. Other key-word arguments are passed to the function.
.. testsetup::
from pprint import pprint
fro... | python | def enrich_by_predicate(request, json, fun, predicate, skip_nested=False, **kwargs):
"""
Take the JSON, find all its subparts satisfying the given condition and
them by the given function. Other key-word arguments are passed to the function.
.. testsetup::
from pprint import pprint
fro... | [
"def",
"enrich_by_predicate",
"(",
"request",
",",
"json",
",",
"fun",
",",
"predicate",
",",
"skip_nested",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"time_start",
"=",
"time",
"(",
")",
"collected",
"=",
"[",
"]",
"memory",
"=",
"{",
"'nested'... | Take the JSON, find all its subparts satisfying the given condition and
them by the given function. Other key-word arguments are passed to the function.
.. testsetup::
from pprint import pprint
from proso.django.enrichment import enrich_by_predicate
request = None
.. testcode::
... | [
"Take",
"the",
"JSON",
"find",
"all",
"its",
"subparts",
"satisfying",
"the",
"given",
"condition",
"and",
"them",
"by",
"the",
"given",
"function",
".",
"Other",
"key",
"-",
"word",
"arguments",
"are",
"passed",
"to",
"the",
"function",
"."
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso/django/enrichment.py#L139-L201 | train | Given a request and a JSON object returns the JSON object that is then applied to all the objects in the JSON object and the function applied to those objects. |
adaptive-learning/proso-apps | proso/django/enrichment.py | enrich_by_object_type | def enrich_by_object_type(request, json, fun, object_type, skip_nested=False, **kwargs):
"""
Take the JSON, find its subparts having the given object part and transform
them by the given function. Other key-word arguments are passed to the function.
.. testsetup::
from pprint import pprint
... | python | def enrich_by_object_type(request, json, fun, object_type, skip_nested=False, **kwargs):
"""
Take the JSON, find its subparts having the given object part and transform
them by the given function. Other key-word arguments are passed to the function.
.. testsetup::
from pprint import pprint
... | [
"def",
"enrich_by_object_type",
"(",
"request",
",",
"json",
",",
"fun",
",",
"object_type",
",",
"skip_nested",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"object_type",
",",
"list",
")",
":",
"object_type",
"=",
"[... | Take the JSON, find its subparts having the given object part and transform
them by the given function. Other key-word arguments are passed to the function.
.. testsetup::
from pprint import pprint
from proso.django.enrichment import enrich_by_object_type
request = None
.. testcod... | [
"Take",
"the",
"JSON",
"find",
"its",
"subparts",
"having",
"the",
"given",
"object",
"part",
"and",
"transform",
"them",
"by",
"the",
"given",
"function",
".",
"Other",
"key",
"-",
"word",
"arguments",
"are",
"passed",
"to",
"the",
"function",
"."
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso/django/enrichment.py#L204-L247 | train | Given a request and a function that returns a list of objects that are of the given object type and apply it to all the objects in the object type. |
adaptive-learning/proso-apps | proso_flashcards/models.py | change_parent | def change_parent(sender, instance, **kwargs):
"""
When the given flashcard has changed. Look at term and context and change
the corresponding item relation.
"""
if instance.id is None:
return
if len({'term', 'term_id'} & set(instance.changed_fields)) != 0:
diff = instance.diff
... | python | def change_parent(sender, instance, **kwargs):
"""
When the given flashcard has changed. Look at term and context and change
the corresponding item relation.
"""
if instance.id is None:
return
if len({'term', 'term_id'} & set(instance.changed_fields)) != 0:
diff = instance.diff
... | [
"def",
"change_parent",
"(",
"sender",
",",
"instance",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"instance",
".",
"id",
"is",
"None",
":",
"return",
"if",
"len",
"(",
"{",
"'term'",
",",
"'term_id'",
"}",
"&",
"set",
"(",
"instance",
".",
"changed_fi... | When the given flashcard has changed. Look at term and context and change
the corresponding item relation. | [
"When",
"the",
"given",
"flashcard",
"has",
"changed",
".",
"Look",
"at",
"term",
"and",
"context",
"and",
"change",
"the",
"corresponding",
"item",
"relation",
"."
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_flashcards/models.py#L367-L398 | train | When the given flashcard has changed Look at term and context and change
the corresponding item relation. |
Kortemme-Lab/klab | klab/bio/bonsai.py | example | def example():
'''This section gives examples of how to use the module.'''
# 1a8d is an example from the loops benchmark
# 1lfa contains hydrogens
b = Bonsai.retrieve('1lfa', cache_dir='/tmp')
search_radius = 10.0
atom_of_interest = b.get_atom(1095)
nearby_atoms = b.find_atoms_near_atom(at... | python | def example():
'''This section gives examples of how to use the module.'''
# 1a8d is an example from the loops benchmark
# 1lfa contains hydrogens
b = Bonsai.retrieve('1lfa', cache_dir='/tmp')
search_radius = 10.0
atom_of_interest = b.get_atom(1095)
nearby_atoms = b.find_atoms_near_atom(at... | [
"def",
"example",
"(",
")",
":",
"# 1a8d is an example from the loops benchmark",
"# 1lfa contains hydrogens",
"b",
"=",
"Bonsai",
".",
"retrieve",
"(",
"'1lfa'",
",",
"cache_dir",
"=",
"'/tmp'",
")",
"search_radius",
"=",
"10.0",
"atom_of_interest",
"=",
"b",
".",
... | This section gives examples of how to use the module. | [
"This",
"section",
"gives",
"examples",
"of",
"how",
"to",
"use",
"the",
"module",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/bonsai.py#L788-L810 | train | This section gives examples of how to use the module. |
Kortemme-Lab/klab | klab/bio/bonsai.py | PDBSection.from_non_aligned_residue_IDs | def from_non_aligned_residue_IDs(Chain, StartResidueID, EndResidueID, Sequence = None):
'''A more forgiving method that does not care about the padding of the residue IDs.'''
return PDBSection(Chain, PDB.ResidueID2String(StartResidueID), PDB.ResidueID2String(EndResidueID), Sequence = Sequence) | python | def from_non_aligned_residue_IDs(Chain, StartResidueID, EndResidueID, Sequence = None):
'''A more forgiving method that does not care about the padding of the residue IDs.'''
return PDBSection(Chain, PDB.ResidueID2String(StartResidueID), PDB.ResidueID2String(EndResidueID), Sequence = Sequence) | [
"def",
"from_non_aligned_residue_IDs",
"(",
"Chain",
",",
"StartResidueID",
",",
"EndResidueID",
",",
"Sequence",
"=",
"None",
")",
":",
"return",
"PDBSection",
"(",
"Chain",
",",
"PDB",
".",
"ResidueID2String",
"(",
"StartResidueID",
")",
",",
"PDB",
".",
"Re... | A more forgiving method that does not care about the padding of the residue IDs. | [
"A",
"more",
"forgiving",
"method",
"that",
"does",
"not",
"care",
"about",
"the",
"padding",
"of",
"the",
"residue",
"IDs",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/bonsai.py#L63-L65 | train | A more forgiving method that does not care about the padding of the residue IDs. |
Kortemme-Lab/klab | klab/bio/bonsai.py | ResidueIndexedPDBFile.from_filepath | def from_filepath(cls, filepath):
'''A function to replace the old constructor call where a filename was passed in.'''
assert(os.path.exists(filepath))
return cls(read_file(filepath)) | python | def from_filepath(cls, filepath):
'''A function to replace the old constructor call where a filename was passed in.'''
assert(os.path.exists(filepath))
return cls(read_file(filepath)) | [
"def",
"from_filepath",
"(",
"cls",
",",
"filepath",
")",
":",
"assert",
"(",
"os",
".",
"path",
".",
"exists",
"(",
"filepath",
")",
")",
"return",
"cls",
"(",
"read_file",
"(",
"filepath",
")",
")"
] | A function to replace the old constructor call where a filename was passed in. | [
"A",
"function",
"to",
"replace",
"the",
"old",
"constructor",
"call",
"where",
"a",
"filename",
"was",
"passed",
"in",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/bonsai.py#L194-L197 | train | A function to replace the old constructor call where a filename was passed in. |
Kortemme-Lab/klab | klab/bio/bonsai.py | ResidueIndexedPDBFile.retrieve | def retrieve(cls, pdb_id, cache_dir = None):
'''Creates a PDB object by using a cached copy of the file if it exists or by retrieving the file from the RCSB.'''
# Check to see whether we have a cached copy
pdb_id = pdb_id.upper()
if cache_dir:
filename = os.path.join(cache_d... | python | def retrieve(cls, pdb_id, cache_dir = None):
'''Creates a PDB object by using a cached copy of the file if it exists or by retrieving the file from the RCSB.'''
# Check to see whether we have a cached copy
pdb_id = pdb_id.upper()
if cache_dir:
filename = os.path.join(cache_d... | [
"def",
"retrieve",
"(",
"cls",
",",
"pdb_id",
",",
"cache_dir",
"=",
"None",
")",
":",
"# Check to see whether we have a cached copy",
"pdb_id",
"=",
"pdb_id",
".",
"upper",
"(",
")",
"if",
"cache_dir",
":",
"filename",
"=",
"os",
".",
"path",
".",
"join",
... | Creates a PDB object by using a cached copy of the file if it exists or by retrieving the file from the RCSB. | [
"Creates",
"a",
"PDB",
"object",
"by",
"using",
"a",
"cached",
"copy",
"of",
"the",
"file",
"if",
"it",
"exists",
"or",
"by",
"retrieving",
"the",
"file",
"from",
"the",
"RCSB",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/bonsai.py#L207-L225 | train | Creates a PDB object by using a cached copy of the file if it exists or by retrieving the file from the RCSB. |
Kortemme-Lab/klab | klab/bio/bonsai.py | ResidueIndexedPDBFile.parse | def parse(self, lines = None):
'''Parses the PDB file into a indexed representation (a tagged list of lines, see constructor docstring).
A set of Atoms is created, including x, y, z coordinates when applicable. These atoms are grouped into Residues.
Finally, the limits of the 3D space are ... | python | def parse(self, lines = None):
'''Parses the PDB file into a indexed representation (a tagged list of lines, see constructor docstring).
A set of Atoms is created, including x, y, z coordinates when applicable. These atoms are grouped into Residues.
Finally, the limits of the 3D space are ... | [
"def",
"parse",
"(",
"self",
",",
"lines",
"=",
"None",
")",
":",
"indexed_lines",
"=",
"[",
"]",
"MODEL_count",
"=",
"0",
"records_types_with_atom_serial_numbers",
"=",
"set",
"(",
"[",
"'ATOM'",
",",
"'HETATM'",
",",
"'TER'",
",",
"'ANISOU'",
"]",
")",
... | Parses the PDB file into a indexed representation (a tagged list of lines, see constructor docstring).
A set of Atoms is created, including x, y, z coordinates when applicable. These atoms are grouped into Residues.
Finally, the limits of the 3D space are calculated to be used for Atom binning.
... | [
"Parses",
"the",
"PDB",
"file",
"into",
"a",
"indexed",
"representation",
"(",
"a",
"tagged",
"list",
"of",
"lines",
"see",
"constructor",
"docstring",
")",
".",
"A",
"set",
"of",
"Atoms",
"is",
"created",
"including",
"x",
"y",
"z",
"coordinates",
"when",... | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/bonsai.py#L231-L305 | train | Parses the PDB file into an indexed representation. |
Kortemme-Lab/klab | klab/bio/bonsai.py | ResidueIndexedPDBFile.bin_atoms | def bin_atoms(self):
'''This function bins the Atoms into fixed-size sections of the protein space in 3D.'''
# Create the atom bins
low_point = numpy.array([self.min_x, self.min_y, self.min_z])
high_point = numpy.array([self.max_x, self.max_y, self.max_z])
atom_bin_dimensions = ... | python | def bin_atoms(self):
'''This function bins the Atoms into fixed-size sections of the protein space in 3D.'''
# Create the atom bins
low_point = numpy.array([self.min_x, self.min_y, self.min_z])
high_point = numpy.array([self.max_x, self.max_y, self.max_z])
atom_bin_dimensions = ... | [
"def",
"bin_atoms",
"(",
"self",
")",
":",
"# Create the atom bins",
"low_point",
"=",
"numpy",
".",
"array",
"(",
"[",
"self",
".",
"min_x",
",",
"self",
".",
"min_y",
",",
"self",
".",
"min_z",
"]",
")",
"high_point",
"=",
"numpy",
".",
"array",
"(",... | This function bins the Atoms into fixed-size sections of the protein space in 3D. | [
"This",
"function",
"bins",
"the",
"Atoms",
"into",
"fixed",
"-",
"size",
"sections",
"of",
"the",
"protein",
"space",
"in",
"3D",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/bonsai.py#L308-L348 | train | This function bins the Atoms into fixed - size sections of the protein space in 3D. |
Kortemme-Lab/klab | klab/bio/bonsai.py | ResidueIndexedPDBFile.check_residues | def check_residues(self):
'''Checks to make sure that each atom type is unique per residue.'''
for chain, residue_ids in self.residues.iteritems():
for residue_id, residue in residue_ids.iteritems():
for record_type, atoms in residue.records.iteritems():
f... | python | def check_residues(self):
'''Checks to make sure that each atom type is unique per residue.'''
for chain, residue_ids in self.residues.iteritems():
for residue_id, residue in residue_ids.iteritems():
for record_type, atoms in residue.records.iteritems():
f... | [
"def",
"check_residues",
"(",
"self",
")",
":",
"for",
"chain",
",",
"residue_ids",
"in",
"self",
".",
"residues",
".",
"iteritems",
"(",
")",
":",
"for",
"residue_id",
",",
"residue",
"in",
"residue_ids",
".",
"iteritems",
"(",
")",
":",
"for",
"record_... | Checks to make sure that each atom type is unique per residue. | [
"Checks",
"to",
"make",
"sure",
"that",
"each",
"atom",
"type",
"is",
"unique",
"per",
"residue",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/bonsai.py#L354-L366 | train | Checks to make sure that each atom type is unique per residue. |
Kortemme-Lab/klab | klab/bio/bonsai.py | ResidueIndexedPDBFile.get_atom_serial_numbers_from_pdb_residue_ids | def get_atom_serial_numbers_from_pdb_residue_ids(self, pdb_residue_ids, ignore_these_atoms = [], ignore_these_conformations = []):
'''Checks to make sure that each atom type is unique per residue.'''
atom_list = []
for pdb_residue_id in pdb_residue_ids:
chain = pdb_residue_id[0]
... | python | def get_atom_serial_numbers_from_pdb_residue_ids(self, pdb_residue_ids, ignore_these_atoms = [], ignore_these_conformations = []):
'''Checks to make sure that each atom type is unique per residue.'''
atom_list = []
for pdb_residue_id in pdb_residue_ids:
chain = pdb_residue_id[0]
... | [
"def",
"get_atom_serial_numbers_from_pdb_residue_ids",
"(",
"self",
",",
"pdb_residue_ids",
",",
"ignore_these_atoms",
"=",
"[",
"]",
",",
"ignore_these_conformations",
"=",
"[",
"]",
")",
":",
"atom_list",
"=",
"[",
"]",
"for",
"pdb_residue_id",
"in",
"pdb_residue_... | Checks to make sure that each atom type is unique per residue. | [
"Checks",
"to",
"make",
"sure",
"that",
"each",
"atom",
"type",
"is",
"unique",
"per",
"residue",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/bonsai.py#L372-L385 | train | Checks to make sure that each atom type is unique per residue. |
Kortemme-Lab/klab | klab/bio/bonsai.py | Bonsai.find_heavy_atoms_near_atom | def find_heavy_atoms_near_atom(self, source_atom, search_radius, atom_hit_cache = set(), restrict_to_CA = False):
'''atom_hit_cache is a set of atom serial numbers which have already been tested. We keep track of these to avoid recalculating the distance.
'''
#todo: Benchmark atom_hit_cache to s... | python | def find_heavy_atoms_near_atom(self, source_atom, search_radius, atom_hit_cache = set(), restrict_to_CA = False):
'''atom_hit_cache is a set of atom serial numbers which have already been tested. We keep track of these to avoid recalculating the distance.
'''
#todo: Benchmark atom_hit_cache to s... | [
"def",
"find_heavy_atoms_near_atom",
"(",
"self",
",",
"source_atom",
",",
"search_radius",
",",
"atom_hit_cache",
"=",
"set",
"(",
")",
",",
"restrict_to_CA",
"=",
"False",
")",
":",
"#todo: Benchmark atom_hit_cache to see if it actually speeds up the search",
"non_heavy_a... | atom_hit_cache is a set of atom serial numbers which have already been tested. We keep track of these to avoid recalculating the distance. | [
"atom_hit_cache",
"is",
"a",
"set",
"of",
"atom",
"serial",
"numbers",
"which",
"have",
"already",
"been",
"tested",
".",
"We",
"keep",
"track",
"of",
"these",
"to",
"avoid",
"recalculating",
"the",
"distance",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/bonsai.py#L414-L420 | train | Finds heavy atoms near a given atom. |
Kortemme-Lab/klab | klab/bio/bonsai.py | Bonsai.find_atoms_near_atom | def find_atoms_near_atom(self, source_atom, search_radius, atom_hit_cache = set(), atom_names_to_include = set(), atom_names_to_exclude = set(), restrict_to_CA = False):
'''It is advisable to set up and use an atom hit cache object. This reduces the number of distance calculations and gives better performance.
... | python | def find_atoms_near_atom(self, source_atom, search_radius, atom_hit_cache = set(), atom_names_to_include = set(), atom_names_to_exclude = set(), restrict_to_CA = False):
'''It is advisable to set up and use an atom hit cache object. This reduces the number of distance calculations and gives better performance.
... | [
"def",
"find_atoms_near_atom",
"(",
"self",
",",
"source_atom",
",",
"search_radius",
",",
"atom_hit_cache",
"=",
"set",
"(",
")",
",",
"atom_names_to_include",
"=",
"set",
"(",
")",
",",
"atom_names_to_exclude",
"=",
"set",
"(",
")",
",",
"restrict_to_CA",
"=... | It is advisable to set up and use an atom hit cache object. This reduces the number of distance calculations and gives better performance.
See find_sidechain_atoms_within_radius_of_residue_objects for an example of how to set this up e.g.
atom_hit_cache = set()
for x in some_loo... | [
"It",
"is",
"advisable",
"to",
"set",
"up",
"and",
"use",
"an",
"atom",
"hit",
"cache",
"object",
".",
"This",
"reduces",
"the",
"number",
"of",
"distance",
"calculations",
"and",
"gives",
"better",
"performance",
".",
"See",
"find_sidechain_atoms_within_radius_... | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/bonsai.py#L423-L457 | train | This method searches for atoms near a given atom. |
Kortemme-Lab/klab | klab/bio/bonsai.py | Bonsai.find_sidechain_atoms_within_radius_of_residue_objects | def find_sidechain_atoms_within_radius_of_residue_objects(self, source_residues, search_radius, find_ATOM_atoms = True, find_HETATM_atoms = False, restrict_to_CA = False):
'''for residue in source_residues:
for all heavy atoms in residue
find all heavy atoms within radius which are w... | python | def find_sidechain_atoms_within_radius_of_residue_objects(self, source_residues, search_radius, find_ATOM_atoms = True, find_HETATM_atoms = False, restrict_to_CA = False):
'''for residue in source_residues:
for all heavy atoms in residue
find all heavy atoms within radius which are w... | [
"def",
"find_sidechain_atoms_within_radius_of_residue_objects",
"(",
"self",
",",
"source_residues",
",",
"search_radius",
",",
"find_ATOM_atoms",
"=",
"True",
",",
"find_HETATM_atoms",
"=",
"False",
",",
"restrict_to_CA",
"=",
"False",
")",
":",
"atom_hit_cache",
"=",
... | for residue in source_residues:
for all heavy atoms in residue
find all heavy atoms within radius which are within residues (ATOM records)
for all heavy atoms found
determing the associated residue
for all found residues not in source_residues
... | [
"for",
"residue",
"in",
"source_residues",
":",
"for",
"all",
"heavy",
"atoms",
"in",
"residue",
"find",
"all",
"heavy",
"atoms",
"within",
"radius",
"which",
"are",
"within",
"residues",
"(",
"ATOM",
"records",
")",
"for",
"all",
"heavy",
"atoms",
"found",
... | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/bonsai.py#L506-L544 | train | Finds all sidechain atoms within a radius of a residue object. |
Kortemme-Lab/klab | klab/bio/bonsai.py | Bonsai.prune_loop_for_kic | def prune_loop_for_kic(self, loops_segments, search_radius, expected_min_loop_length = None, expected_max_loop_length = None, generate_pymol_session = False):
'''A wrapper for prune_structure_according_to_loop_definitions suitable for the Rosetta kinematic closure (KIC) loop modeling method.'''
return s... | python | def prune_loop_for_kic(self, loops_segments, search_radius, expected_min_loop_length = None, expected_max_loop_length = None, generate_pymol_session = False):
'''A wrapper for prune_structure_according_to_loop_definitions suitable for the Rosetta kinematic closure (KIC) loop modeling method.'''
return s... | [
"def",
"prune_loop_for_kic",
"(",
"self",
",",
"loops_segments",
",",
"search_radius",
",",
"expected_min_loop_length",
"=",
"None",
",",
"expected_max_loop_length",
"=",
"None",
",",
"generate_pymol_session",
"=",
"False",
")",
":",
"return",
"self",
".",
"prune_st... | A wrapper for prune_structure_according_to_loop_definitions suitable for the Rosetta kinematic closure (KIC) loop modeling method. | [
"A",
"wrapper",
"for",
"prune_structure_according_to_loop_definitions",
"suitable",
"for",
"the",
"Rosetta",
"kinematic",
"closure",
"(",
"KIC",
")",
"loop",
"modeling",
"method",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/bonsai.py#L550-L552 | train | A wrapper for prune_structure_according_to_loop_definitions suitable for the Rosetta kinematic closure loop modeling method. |
Kortemme-Lab/klab | klab/bio/bonsai.py | Bonsai.prune_structure_according_to_loop_definitions | def prune_structure_according_to_loop_definitions(self, loops_segments, search_radius, expected_min_loop_length = None, expected_max_loop_length = None, generate_pymol_session = True, check_sequence = False, keep_Ca_buttress_atoms = True):
'''Removes the loop residues identified by the residues in loops_segment... | python | def prune_structure_according_to_loop_definitions(self, loops_segments, search_radius, expected_min_loop_length = None, expected_max_loop_length = None, generate_pymol_session = True, check_sequence = False, keep_Ca_buttress_atoms = True):
'''Removes the loop residues identified by the residues in loops_segment... | [
"def",
"prune_structure_according_to_loop_definitions",
"(",
"self",
",",
"loops_segments",
",",
"search_radius",
",",
"expected_min_loop_length",
"=",
"None",
",",
"expected_max_loop_length",
"=",
"None",
",",
"generate_pymol_session",
"=",
"True",
",",
"check_sequence",
... | Removes the loop residues identified by the residues in loops_segments and all sidechains with heavy atoms
within 10A of any heavy atom of the loop.
If keep_Ca_buttress_atoms is set then the N and Ca backbone atoms of the first loop residue are kept and the
Ca and C backbone atoms of ... | [
"Removes",
"the",
"loop",
"residues",
"identified",
"by",
"the",
"residues",
"in",
"loops_segments",
"and",
"all",
"sidechains",
"with",
"heavy",
"atoms",
"within",
"10A",
"of",
"any",
"heavy",
"atom",
"of",
"the",
"loop",
".",
"If",
"keep_Ca_buttress_atoms",
... | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/bonsai.py#L555-L653 | train | Prune the structure according to the loops definitions. |
Kortemme-Lab/klab | klab/bio/bonsai.py | Bonsai.prune_structure_according_to_loops_file | def prune_structure_according_to_loops_file(self, loops_file_content, search_radius, expected_loop_length = None, generate_pymol_session = True):
'''todo: this needs to be rewritten to include the logic in prune_structure_according_to_loop_definitions.'''
lf = LoopsFile(loops_file_content)
asser... | python | def prune_structure_according_to_loops_file(self, loops_file_content, search_radius, expected_loop_length = None, generate_pymol_session = True):
'''todo: this needs to be rewritten to include the logic in prune_structure_according_to_loop_definitions.'''
lf = LoopsFile(loops_file_content)
asser... | [
"def",
"prune_structure_according_to_loops_file",
"(",
"self",
",",
"loops_file_content",
",",
"search_radius",
",",
"expected_loop_length",
"=",
"None",
",",
"generate_pymol_session",
"=",
"True",
")",
":",
"lf",
"=",
"LoopsFile",
"(",
"loops_file_content",
")",
"ass... | todo: this needs to be rewritten to include the logic in prune_structure_according_to_loop_definitions. | [
"todo",
":",
"this",
"needs",
"to",
"be",
"rewritten",
"to",
"include",
"the",
"logic",
"in",
"prune_structure_according_to_loop_definitions",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/bonsai.py#L656-L708 | train | Prune the structure according to the loops file. |
Kortemme-Lab/klab | klab/bio/bonsai.py | Bonsai.prune | def prune(self, arbitrary_atom_serial_numbers, sidechain_atom_serial_numbers = set(), atoms_serial_numbers_to_keep_in_cutting = set(), keep_CA_in_cutting = True, generate_pymol_session = True, bonsai_label = 'Bonsai', cutting_label = 'Cutting', pymol_executable = 'pymol'):
'''Returns the content of two PDB file... | python | def prune(self, arbitrary_atom_serial_numbers, sidechain_atom_serial_numbers = set(), atoms_serial_numbers_to_keep_in_cutting = set(), keep_CA_in_cutting = True, generate_pymol_session = True, bonsai_label = 'Bonsai', cutting_label = 'Cutting', pymol_executable = 'pymol'):
'''Returns the content of two PDB file... | [
"def",
"prune",
"(",
"self",
",",
"arbitrary_atom_serial_numbers",
",",
"sidechain_atom_serial_numbers",
"=",
"set",
"(",
")",
",",
"atoms_serial_numbers_to_keep_in_cutting",
"=",
"set",
"(",
")",
",",
"keep_CA_in_cutting",
"=",
"True",
",",
"generate_pymol_session",
... | Returns the content of two PDB files and (optionally) a PyMOL session and associated script.
The first returned PDB file ("bonsai") is missing the ATOM (and any related ANISOU) and HETATM records identified by atom_serial_numbers.
The second returned PDB file ("cutting") only contains ATOM, ANISOU... | [
"Returns",
"the",
"content",
"of",
"two",
"PDB",
"files",
"and",
"(",
"optionally",
")",
"a",
"PyMOL",
"session",
"and",
"associated",
"script",
".",
"The",
"first",
"returned",
"PDB",
"file",
"(",
"bonsai",
")",
"is",
"missing",
"the",
"ATOM",
"(",
"and... | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/bonsai.py#L711-L754 | train | Prune the set of atom serial numbers from the original PDB file. |
Kortemme-Lab/klab | klab/bio/bonsai.py | Bonsai.generate_pymol_session | def generate_pymol_session(self, bonsai_pdb_content, cutting_pdb_content, bonsai_label = 'Bonsai', cutting_label = 'Cutting', pymol_executable = 'pymol', settings = {}):
''' Generates the PyMOL session for the scaffold, model, and design structures.
Returns this session and the script which generate... | python | def generate_pymol_session(self, bonsai_pdb_content, cutting_pdb_content, bonsai_label = 'Bonsai', cutting_label = 'Cutting', pymol_executable = 'pymol', settings = {}):
''' Generates the PyMOL session for the scaffold, model, and design structures.
Returns this session and the script which generate... | [
"def",
"generate_pymol_session",
"(",
"self",
",",
"bonsai_pdb_content",
",",
"cutting_pdb_content",
",",
"bonsai_label",
"=",
"'Bonsai'",
",",
"cutting_label",
"=",
"'Cutting'",
",",
"pymol_executable",
"=",
"'pymol'",
",",
"settings",
"=",
"{",
"}",
")",
":",
... | Generates the PyMOL session for the scaffold, model, and design structures.
Returns this session and the script which generated it. | [
"Generates",
"the",
"PyMOL",
"session",
"for",
"the",
"scaffold",
"model",
"and",
"design",
"structures",
".",
"Returns",
"this",
"session",
"and",
"the",
"script",
"which",
"generated",
"it",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/bonsai.py#L757-L776 | train | Generates the PyMOL session for the scaffold model and design structures. |
TUNE-Archive/freight_forwarder | freight_forwarder/commercial_invoice/injector.py | Injector._generate_injection_cmd | def _generate_injection_cmd(self, meta_data):
""" example injector response:
[
{
"config_path":"/configs/cli_config.py",
"path":"/opt/cia-cli/cia_sdk/config",
"user":"injector",
"status_code":201,
"chmod":755,
... | python | def _generate_injection_cmd(self, meta_data):
""" example injector response:
[
{
"config_path":"/configs/cli_config.py",
"path":"/opt/cia-cli/cia_sdk/config",
"user":"injector",
"status_code":201,
"chmod":755,
... | [
"def",
"_generate_injection_cmd",
"(",
"self",
",",
"meta_data",
")",
":",
"cmd",
"=",
"[",
"]",
"self",
".",
"_validate_templates",
"(",
"meta_data",
")",
"for",
"i",
",",
"config_data",
"in",
"enumerate",
"(",
"meta_data",
")",
":",
"container_path",
"=",
... | example injector response:
[
{
"config_path":"/configs/cli_config.py",
"path":"/opt/cia-cli/cia_sdk/config",
"user":"injector",
"status_code":201,
"chmod":755,
"checksum":"a4bcf3939dd3a6aa4e04ee9f92131df4",
... | [
"example",
"injector",
"response",
":",
"[",
"{",
"config_path",
":",
"/",
"configs",
"/",
"cli_config",
".",
"py",
"path",
":",
"/",
"opt",
"/",
"cia",
"-",
"cli",
"/",
"cia_sdk",
"/",
"config",
"user",
":",
"injector",
"status_code",
":",
"201",
"chm... | 6ea4a49f474ec04abb8bb81b175c774a16b5312f | https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/commercial_invoice/injector.py#L220-L263 | train | generate command to inject a new entry point into the injector |
TUNE-Archive/freight_forwarder | freight_forwarder/commercial_invoice/injector.py | Injector._validate_templates | def _validate_templates(self, templates):
"""
:param templates:
:return:
"""
if templates is None:
return templates
if not isinstance(templates, list):
raise TypeError(logger.error("templates should be a list."))
for template in templates... | python | def _validate_templates(self, templates):
"""
:param templates:
:return:
"""
if templates is None:
return templates
if not isinstance(templates, list):
raise TypeError(logger.error("templates should be a list."))
for template in templates... | [
"def",
"_validate_templates",
"(",
"self",
",",
"templates",
")",
":",
"if",
"templates",
"is",
"None",
":",
"return",
"templates",
"if",
"not",
"isinstance",
"(",
"templates",
",",
"list",
")",
":",
"raise",
"TypeError",
"(",
"logger",
".",
"error",
"(",
... | :param templates:
:return: | [
":",
"param",
"templates",
":",
":",
"return",
":"
] | 6ea4a49f474ec04abb8bb81b175c774a16b5312f | https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/commercial_invoice/injector.py#L265-L293 | train | Validate the templates and return a list of the keys that are valid. |
TUNE-Archive/freight_forwarder | freight_forwarder/config.py | Config.get | def get(self, attr_name, *args):
""" Get the most retrieval attribute in the configuration file. This method
will recursively look through the configuration file for the attribute specified
and return the last found value or None. The values can be referenced by
the key name provided in... | python | def get(self, attr_name, *args):
""" Get the most retrieval attribute in the configuration file. This method
will recursively look through the configuration file for the attribute specified
and return the last found value or None. The values can be referenced by
the key name provided in... | [
"def",
"get",
"(",
"self",
",",
"attr_name",
",",
"*",
"args",
")",
":",
"if",
"not",
"isinstance",
"(",
"attr_name",
",",
"six",
".",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"'attr_name must be a str.'",
")",
"# allow retrieval of data with alias o... | Get the most retrieval attribute in the configuration file. This method
will recursively look through the configuration file for the attribute specified
and return the last found value or None. The values can be referenced by
the key name provided in the configuration file or that value normali... | [
"Get",
"the",
"most",
"retrieval",
"attribute",
"in",
"the",
"configuration",
"file",
".",
"This",
"method",
"will",
"recursively",
"look",
"through",
"the",
"configuration",
"file",
"for",
"the",
"attribute",
"specified",
"and",
"return",
"the",
"last",
"found"... | 6ea4a49f474ec04abb8bb81b175c774a16b5312f | https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/config.py#L883-L924 | train | This method will recursively look through the configuration file for the specified attribute name and return the last found value or None. |
TUNE-Archive/freight_forwarder | freight_forwarder/config.py | Config.service_references | def service_references(self):
""" returns a list of service names
"""
services_blue_print = self._scheme_references.get('services')
if services_blue_print is None:
raise LookupError('unable to find any services in the config.')
# TODO: this needs to be cleaned up and... | python | def service_references(self):
""" returns a list of service names
"""
services_blue_print = self._scheme_references.get('services')
if services_blue_print is None:
raise LookupError('unable to find any services in the config.')
# TODO: this needs to be cleaned up and... | [
"def",
"service_references",
"(",
"self",
")",
":",
"services_blue_print",
"=",
"self",
".",
"_scheme_references",
".",
"get",
"(",
"'services'",
")",
"if",
"services_blue_print",
"is",
"None",
":",
"raise",
"LookupError",
"(",
"'unable to find any services in the con... | returns a list of service names | [
"returns",
"a",
"list",
"of",
"service",
"names"
] | 6ea4a49f474ec04abb8bb81b175c774a16b5312f | https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/config.py#L928-L936 | train | returns a list of service names
|
TUNE-Archive/freight_forwarder | freight_forwarder/config.py | Config.validate | def validate(self):
""" Validate the contents of the configuration file. Will return None if validation is successful or
raise an error if not.
"""
if not isinstance(self._data, dict):
raise TypeError('freight forwarder configuration file must be a dict.')
current_lo... | python | def validate(self):
""" Validate the contents of the configuration file. Will return None if validation is successful or
raise an error if not.
"""
if not isinstance(self._data, dict):
raise TypeError('freight forwarder configuration file must be a dict.')
current_lo... | [
"def",
"validate",
"(",
"self",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"_data",
",",
"dict",
")",
":",
"raise",
"TypeError",
"(",
"'freight forwarder configuration file must be a dict.'",
")",
"current_log_level",
"=",
"logger",
".",
"get_level",
... | Validate the contents of the configuration file. Will return None if validation is successful or
raise an error if not. | [
"Validate",
"the",
"contents",
"of",
"the",
"configuration",
"file",
".",
"Will",
"return",
"None",
"if",
"validation",
"is",
"successful",
"or",
"raise",
"an",
"error",
"if",
"not",
"."
] | 6ea4a49f474ec04abb8bb81b175c774a16b5312f | https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/config.py#L965-L992 | train | Validate the contents of the configuration file. Will return None if validation is successful or raise an error if validation is not successful. |
TUNE-Archive/freight_forwarder | freight_forwarder/config.py | Config._load | def _load(self):
""" Load a configuration file. This method will be called when the Config class is instantiated. The
configuration file can be json or yaml.
"""
if os.path.isdir(self._path):
for file_ext in ('yml', 'yaml', 'json'):
test_path = os.path.join(... | python | def _load(self):
""" Load a configuration file. This method will be called when the Config class is instantiated. The
configuration file can be json or yaml.
"""
if os.path.isdir(self._path):
for file_ext in ('yml', 'yaml', 'json'):
test_path = os.path.join(... | [
"def",
"_load",
"(",
"self",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"_path",
")",
":",
"for",
"file_ext",
"in",
"(",
"'yml'",
",",
"'yaml'",
",",
"'json'",
")",
":",
"test_path",
"=",
"os",
".",
"path",
".",
"join",
... | Load a configuration file. This method will be called when the Config class is instantiated. The
configuration file can be json or yaml. | [
"Load",
"a",
"configuration",
"file",
".",
"This",
"method",
"will",
"be",
"called",
"when",
"the",
"Config",
"class",
"is",
"instantiated",
".",
"The",
"configuration",
"file",
"can",
"be",
"json",
"or",
"yaml",
"."
] | 6ea4a49f474ec04abb8bb81b175c774a16b5312f | https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/config.py#L997-L1024 | train | Loads a configuration file. |
TUNE-Archive/freight_forwarder | freight_forwarder/config.py | Config._load_yml_config | def _load_yml_config(self, config_file):
""" loads a yaml str, creates a few constructs for pyaml, serializes and normalized the config data. Then
assigns the config data to self._data.
:param config_file: A :string: loaded from a yaml file.
"""
if not isinstance(config_file, s... | python | def _load_yml_config(self, config_file):
""" loads a yaml str, creates a few constructs for pyaml, serializes and normalized the config data. Then
assigns the config data to self._data.
:param config_file: A :string: loaded from a yaml file.
"""
if not isinstance(config_file, s... | [
"def",
"_load_yml_config",
"(",
"self",
",",
"config_file",
")",
":",
"if",
"not",
"isinstance",
"(",
"config_file",
",",
"six",
".",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"'config_file must be a str.'",
")",
"try",
":",
"def",
"construct_yaml_int... | loads a yaml str, creates a few constructs for pyaml, serializes and normalized the config data. Then
assigns the config data to self._data.
:param config_file: A :string: loaded from a yaml file. | [
"loads",
"a",
"yaml",
"str",
"creates",
"a",
"few",
"constructs",
"for",
"pyaml",
"serializes",
"and",
"normalized",
"the",
"config",
"data",
".",
"Then",
"assigns",
"the",
"config",
"data",
"to",
"self",
".",
"_data",
"."
] | 6ea4a49f474ec04abb8bb81b175c774a16b5312f | https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/config.py#L1026-L1112 | train | Loads a yaml file and assigns the config data to self. _data. |
TUNE-Archive/freight_forwarder | freight_forwarder/config.py | Config._merge_config | def _merge_config(self, config_override):
""" overrides and/or adds data to the current configuration file.
** This has not been implemented yet.
:param config_override: A :string: config data to add to or override the current config.
"""
if not isinstance(config_override, dict... | python | def _merge_config(self, config_override):
""" overrides and/or adds data to the current configuration file.
** This has not been implemented yet.
:param config_override: A :string: config data to add to or override the current config.
"""
if not isinstance(config_override, dict... | [
"def",
"_merge_config",
"(",
"self",
",",
"config_override",
")",
":",
"if",
"not",
"isinstance",
"(",
"config_override",
",",
"dict",
")",
":",
"raise",
"TypeError",
"(",
"\"config override must be a dict\"",
")",
"def",
"recursion",
"(",
"config_value",
",",
"... | overrides and/or adds data to the current configuration file.
** This has not been implemented yet.
:param config_override: A :string: config data to add to or override the current config. | [
"overrides",
"and",
"/",
"or",
"adds",
"data",
"to",
"the",
"current",
"configuration",
"file",
"."
] | 6ea4a49f474ec04abb8bb81b175c774a16b5312f | https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/config.py#L1114-L1138 | train | Merges the current configuration file with the given data. |
TUNE-Archive/freight_forwarder | freight_forwarder/config.py | Config._create_attr | def _create_attr(self, property_key, data, ancestors):
""" Dynamically Creates attributes on for a Config. Also adds name and alias to each Config object.
:param property_key: A :string: configuration property name.
:param data: The adds the user supplied for this specific property.
:p... | python | def _create_attr(self, property_key, data, ancestors):
""" Dynamically Creates attributes on for a Config. Also adds name and alias to each Config object.
:param property_key: A :string: configuration property name.
:param data: The adds the user supplied for this specific property.
:p... | [
"def",
"_create_attr",
"(",
"self",
",",
"property_key",
",",
"data",
",",
"ancestors",
")",
":",
"if",
"not",
"isinstance",
"(",
"property_key",
",",
"six",
".",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"\"property_key must be a string. type: {0} was ... | Dynamically Creates attributes on for a Config. Also adds name and alias to each Config object.
:param property_key: A :string: configuration property name.
:param data: The adds the user supplied for this specific property.
:param ancestors: A :OrderedDict: that provides a history of its ance... | [
"Dynamically",
"Creates",
"attributes",
"on",
"for",
"a",
"Config",
".",
"Also",
"adds",
"name",
"and",
"alias",
"to",
"each",
"Config",
"object",
"."
] | 6ea4a49f474ec04abb8bb81b175c774a16b5312f | https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/config.py#L1140-L1185 | train | Dynamically creates attributes on for a specific configuration property. |
TUNE-Archive/freight_forwarder | freight_forwarder/config.py | Config._collect_unrecognized_values | def _collect_unrecognized_values(self, scheme, data, ancestors):
""" Looks for values that aren't defined in the scheme and returns a dict with any unrecognized values found.
:param scheme: A :dict:, The scheme defining the validations.
:param data: A :dict: user supplied for this specific prop... | python | def _collect_unrecognized_values(self, scheme, data, ancestors):
""" Looks for values that aren't defined in the scheme and returns a dict with any unrecognized values found.
:param scheme: A :dict:, The scheme defining the validations.
:param data: A :dict: user supplied for this specific prop... | [
"def",
"_collect_unrecognized_values",
"(",
"self",
",",
"scheme",
",",
"data",
",",
"ancestors",
")",
":",
"if",
"not",
"isinstance",
"(",
"ancestors",
",",
"OrderedDict",
")",
":",
"raise",
"TypeError",
"(",
"\"ancestors must be an OrderedDict. type: {0} was passed.... | Looks for values that aren't defined in the scheme and returns a dict with any unrecognized values found.
:param scheme: A :dict:, The scheme defining the validations.
:param data: A :dict: user supplied for this specific property.
:param ancestors: A :OrderedDict: that provides a history of it... | [
"Looks",
"for",
"values",
"that",
"aren",
"t",
"defined",
"in",
"the",
"scheme",
"and",
"returns",
"a",
"dict",
"with",
"any",
"unrecognized",
"values",
"found",
"."
] | 6ea4a49f474ec04abb8bb81b175c774a16b5312f | https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/config.py#L1187-L1225 | train | Collect unrecognized values from the user supplied for this specific property. |
TUNE-Archive/freight_forwarder | freight_forwarder/config.py | Config._update_scheme | def _update_scheme(self, scheme, ancestors):
""" Updates the current scheme based off special pre-defined keys and retruns a new updated scheme.
:param scheme: A :dict:, The scheme defining the validations.
:param ancestors: A :OrderedDict: that provides a history of its ancestors.
:rty... | python | def _update_scheme(self, scheme, ancestors):
""" Updates the current scheme based off special pre-defined keys and retruns a new updated scheme.
:param scheme: A :dict:, The scheme defining the validations.
:param ancestors: A :OrderedDict: that provides a history of its ancestors.
:rty... | [
"def",
"_update_scheme",
"(",
"self",
",",
"scheme",
",",
"ancestors",
")",
":",
"if",
"not",
"isinstance",
"(",
"ancestors",
",",
"OrderedDict",
")",
":",
"raise",
"TypeError",
"(",
"\"ancestors must be an OrderedDict. type: {0} was passed.\"",
".",
"format",
"(",
... | Updates the current scheme based off special pre-defined keys and retruns a new updated scheme.
:param scheme: A :dict:, The scheme defining the validations.
:param ancestors: A :OrderedDict: that provides a history of its ancestors.
:rtype: A new :dict: with updated scheme values. | [
"Updates",
"the",
"current",
"scheme",
"based",
"off",
"special",
"pre",
"-",
"defined",
"keys",
"and",
"retruns",
"a",
"new",
"updated",
"scheme",
"."
] | 6ea4a49f474ec04abb8bb81b175c774a16b5312f | https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/config.py#L1227-L1272 | train | Updates the current scheme based off special pre - defined keys and retruns a new updated scheme. |
TUNE-Archive/freight_forwarder | freight_forwarder/config.py | Config._get_cascading_attr | def _get_cascading_attr(self, attr_name, *args):
""" Will traverse the configuration data looking for attr_name provided. It will know where to look for the
attribute based on the *args that are passed to the method. It treats the args as ancestors starting with the
oldest `root -> grandparent... | python | def _get_cascading_attr(self, attr_name, *args):
""" Will traverse the configuration data looking for attr_name provided. It will know where to look for the
attribute based on the *args that are passed to the method. It treats the args as ancestors starting with the
oldest `root -> grandparent... | [
"def",
"_get_cascading_attr",
"(",
"self",
",",
"attr_name",
",",
"*",
"args",
")",
":",
"attr",
"=",
"self",
".",
"_data",
".",
"get",
"(",
"attr_name",
",",
"None",
")",
"if",
"isinstance",
"(",
"attr",
",",
"ConfigDict",
")",
":",
"attr",
"=",
"Co... | Will traverse the configuration data looking for attr_name provided. It will know where to look for the
attribute based on the *args that are passed to the method. It treats the args as ancestors starting with the
oldest `root -> grandparent -> parent -> attr_name`. The findings will be updated with ... | [
"Will",
"traverse",
"the",
"configuration",
"data",
"looking",
"for",
"attr_name",
"provided",
".",
"It",
"will",
"know",
"where",
"to",
"look",
"for",
"the",
"attribute",
"based",
"on",
"the",
"*",
"args",
"that",
"are",
"passed",
"to",
"the",
"method",
"... | 6ea4a49f474ec04abb8bb81b175c774a16b5312f | https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/config.py#L1274-L1329 | train | This method will traverse the configuration data looking for the specified attribute name and returns the value of that attribute. |
TUNE-Archive/freight_forwarder | freight_forwarder/config.py | Config._walk_tree | def _walk_tree(self, data, scheme, ancestors=None, property_name=None, prefix=None):
""" This function takes configuration data and a validation scheme
then walk the configuration tree validating the configuraton data agenst
the scheme provided. Will raise error on failure otherwise return None.... | python | def _walk_tree(self, data, scheme, ancestors=None, property_name=None, prefix=None):
""" This function takes configuration data and a validation scheme
then walk the configuration tree validating the configuraton data agenst
the scheme provided. Will raise error on failure otherwise return None.... | [
"def",
"_walk_tree",
"(",
"self",
",",
"data",
",",
"scheme",
",",
"ancestors",
"=",
"None",
",",
"property_name",
"=",
"None",
",",
"prefix",
"=",
"None",
")",
":",
"if",
"property_name",
"is",
"None",
":",
"property_name",
"=",
"'root'",
"# hack until i ... | This function takes configuration data and a validation scheme
then walk the configuration tree validating the configuraton data agenst
the scheme provided. Will raise error on failure otherwise return None.
Usage::
>>> self._walk_tree(
>>> OrderedDict([('root', confi... | [
"This",
"function",
"takes",
"configuration",
"data",
"and",
"a",
"validation",
"scheme",
"then",
"walk",
"the",
"configuration",
"tree",
"validating",
"the",
"configuraton",
"data",
"agenst",
"the",
"scheme",
"provided",
".",
"Will",
"raise",
"error",
"on",
"fa... | 6ea4a49f474ec04abb8bb81b175c774a16b5312f | https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/config.py#L1331-L1390 | train | This function walks the configuration tree validating the data and the validation scheme
then updates the data with the data that is validated. |
TUNE-Archive/freight_forwarder | freight_forwarder/config.py | Config._update_ancestors | def _update_ancestors(self, config_data, property_name, ancestors=None):
""" Update ancestors for a specific property.
:param ancestors: A :OrderedDict:, representing the ancestors of a property.
:param config_data: The data that needs to be validated agents the scheme.
:param property_... | python | def _update_ancestors(self, config_data, property_name, ancestors=None):
""" Update ancestors for a specific property.
:param ancestors: A :OrderedDict:, representing the ancestors of a property.
:param config_data: The data that needs to be validated agents the scheme.
:param property_... | [
"def",
"_update_ancestors",
"(",
"self",
",",
"config_data",
",",
"property_name",
",",
"ancestors",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"property_name",
",",
"six",
".",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"\"property_key m... | Update ancestors for a specific property.
:param ancestors: A :OrderedDict:, representing the ancestors of a property.
:param config_data: The data that needs to be validated agents the scheme.
:param property_name: A :string: of the properties name.
:rtype: A :OrderDict: that has been ... | [
"Update",
"ancestors",
"for",
"a",
"specific",
"property",
"."
] | 6ea4a49f474ec04abb8bb81b175c774a16b5312f | https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/config.py#L1392-L1424 | train | Update the ancestors of a specific property. |
TUNE-Archive/freight_forwarder | freight_forwarder/config.py | Config._reference_keys | def _reference_keys(self, reference):
""" Returns a list of all of keys for a given reference.
:param reference: a :string:
:rtype: A :list: of reference keys.
"""
if not isinstance(reference, six.string_types):
raise TypeError(
'When using ~ to refer... | python | def _reference_keys(self, reference):
""" Returns a list of all of keys for a given reference.
:param reference: a :string:
:rtype: A :list: of reference keys.
"""
if not isinstance(reference, six.string_types):
raise TypeError(
'When using ~ to refer... | [
"def",
"_reference_keys",
"(",
"self",
",",
"reference",
")",
":",
"if",
"not",
"isinstance",
"(",
"reference",
",",
"six",
".",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"'When using ~ to reference dynamic attributes ref must be a str. a {0} was provided.'",
... | Returns a list of all of keys for a given reference.
:param reference: a :string:
:rtype: A :list: of reference keys. | [
"Returns",
"a",
"list",
"of",
"all",
"of",
"keys",
"for",
"a",
"given",
"reference",
"."
] | 6ea4a49f474ec04abb8bb81b175c774a16b5312f | https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/config.py#L1426-L1450 | train | Returns a list of all of the keys for a given reference. |
TUNE-Archive/freight_forwarder | freight_forwarder/config.py | Config.__execute_validations | def __execute_validations(self, validations, data, property_name, ancestors, negation=False, prefix=None):
""" Validate the data for a specific configuration value. This method will look up all of the validations provided
and dynamically call any validation methods. If a validation fails a error will be... | python | def __execute_validations(self, validations, data, property_name, ancestors, negation=False, prefix=None):
""" Validate the data for a specific configuration value. This method will look up all of the validations provided
and dynamically call any validation methods. If a validation fails a error will be... | [
"def",
"__execute_validations",
"(",
"self",
",",
"validations",
",",
"data",
",",
"property_name",
",",
"ancestors",
",",
"negation",
"=",
"False",
",",
"prefix",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"ancestors",
",",
"OrderedDict",
")",
... | Validate the data for a specific configuration value. This method will look up all of the validations provided
and dynamically call any validation methods. If a validation fails a error will be thrown. If no errors are found
a attributes will be dynamically created on the Config object for the configur... | [
"Validate",
"the",
"data",
"for",
"a",
"specific",
"configuration",
"value",
".",
"This",
"method",
"will",
"look",
"up",
"all",
"of",
"the",
"validations",
"provided",
"and",
"dynamically",
"call",
"any",
"validation",
"methods",
".",
"If",
"a",
"validation",... | 6ea4a49f474ec04abb8bb81b175c774a16b5312f | https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/config.py#L1505-L1542 | train | Execute the validations for a specific configuration value. |
TUNE-Archive/freight_forwarder | freight_forwarder/config.py | Config._scheme_propagation | def _scheme_propagation(self, scheme, definitions):
""" Will updated a scheme based on inheritance. This is defined in a scheme objects with ``'inherit': '$definition'``.
Will also updated parent objects for nested inheritance.
Usage::
>>> SCHEME = {
>>> 'thing1': {... | python | def _scheme_propagation(self, scheme, definitions):
""" Will updated a scheme based on inheritance. This is defined in a scheme objects with ``'inherit': '$definition'``.
Will also updated parent objects for nested inheritance.
Usage::
>>> SCHEME = {
>>> 'thing1': {... | [
"def",
"_scheme_propagation",
"(",
"self",
",",
"scheme",
",",
"definitions",
")",
":",
"if",
"not",
"isinstance",
"(",
"scheme",
",",
"dict",
")",
":",
"raise",
"TypeError",
"(",
"'scheme must be a dict to propagate.'",
")",
"inherit_from",
"=",
"scheme",
".",
... | Will updated a scheme based on inheritance. This is defined in a scheme objects with ``'inherit': '$definition'``.
Will also updated parent objects for nested inheritance.
Usage::
>>> SCHEME = {
>>> 'thing1': {
>>> 'inherit': '$thing2'
>>> ... | [
"Will",
"updated",
"a",
"scheme",
"based",
"on",
"inheritance",
".",
"This",
"is",
"defined",
"in",
"a",
"scheme",
"objects",
"with",
"inherit",
":",
"$definition",
".",
"Will",
"also",
"updated",
"parent",
"objects",
"for",
"nested",
"inheritance",
"."
] | 6ea4a49f474ec04abb8bb81b175c774a16b5312f | https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/config.py#L1711-L1780 | train | This function will update a new object based on inheritance. |
ZEDGR/pychal | challonge/tournaments.py | create | def create(name, url, tournament_type="single elimination", **params):
"""Create a new tournament."""
params.update({
"name": name,
"url": url,
"tournament_type": tournament_type,
})
return api.fetch_and_parse("POST", "tournaments", "tournament", **params) | python | def create(name, url, tournament_type="single elimination", **params):
"""Create a new tournament."""
params.update({
"name": name,
"url": url,
"tournament_type": tournament_type,
})
return api.fetch_and_parse("POST", "tournaments", "tournament", **params) | [
"def",
"create",
"(",
"name",
",",
"url",
",",
"tournament_type",
"=",
"\"single elimination\"",
",",
"*",
"*",
"params",
")",
":",
"params",
".",
"update",
"(",
"{",
"\"name\"",
":",
"name",
",",
"\"url\"",
":",
"url",
",",
"\"tournament_type\"",
":",
"... | Create a new tournament. | [
"Create",
"a",
"new",
"tournament",
"."
] | 3600fa9e0557a2a14eb1ad0c0711d28dad3693d7 | https://github.com/ZEDGR/pychal/blob/3600fa9e0557a2a14eb1ad0c0711d28dad3693d7/challonge/tournaments.py#L9-L17 | train | Create a new tournament. |
AtmaHou/atma | tool.py | wrap_star_digger | def wrap_star_digger(item, type_str, data_name='Value'):
"""
code used to extract data from Bing's wrap star
:param item: wrap star obj
:param type_str: target type string
:param data_name: target data label, might be "Entities", "Properties", 'Value'
:return: list of all matched target, arrange... | python | def wrap_star_digger(item, type_str, data_name='Value'):
"""
code used to extract data from Bing's wrap star
:param item: wrap star obj
:param type_str: target type string
:param data_name: target data label, might be "Entities", "Properties", 'Value'
:return: list of all matched target, arrange... | [
"def",
"wrap_star_digger",
"(",
"item",
",",
"type_str",
",",
"data_name",
"=",
"'Value'",
")",
":",
"ret",
"=",
"[",
"]",
"if",
"type",
"(",
"item",
")",
"==",
"dict",
":",
"if",
"'Type'",
"in",
"item",
"and",
"item",
"[",
"'Type'",
"]",
"==",
"ty... | code used to extract data from Bing's wrap star
:param item: wrap star obj
:param type_str: target type string
:param data_name: target data label, might be "Entities", "Properties", 'Value'
:return: list of all matched target, arranged in occurance | [
"code",
"used",
"to",
"extract",
"data",
"from",
"Bing",
"s",
"wrap",
"star",
":",
"param",
"item",
":",
"wrap",
"star",
"obj",
":",
"param",
"type_str",
":",
"target",
"type",
"string",
":",
"param",
"data_name",
":",
"target",
"data",
"label",
"might",... | 41cd8ea9443a9c3b2dd71432f46f44a0f83093c7 | https://github.com/AtmaHou/atma/blob/41cd8ea9443a9c3b2dd71432f46f44a0f83093c7/tool.py#L39-L64 | train | This function will extract all matched target from a Bing s wrap star obj and return a list of all matched target in occurance
|
uw-it-aca/uw-restclients-sws | uw_sws/__init__.py | parse_sws_date | def parse_sws_date(date_string):
"""
Takes a date from the SWS response object
and attempts to parse it using one of the several
datetime formats used by the SWS
:param date_string:
:return: date object
"""
if date_string is None:
return None
date_formats = ["%m/%d/%Y", "%Y-%... | python | def parse_sws_date(date_string):
"""
Takes a date from the SWS response object
and attempts to parse it using one of the several
datetime formats used by the SWS
:param date_string:
:return: date object
"""
if date_string is None:
return None
date_formats = ["%m/%d/%Y", "%Y-%... | [
"def",
"parse_sws_date",
"(",
"date_string",
")",
":",
"if",
"date_string",
"is",
"None",
":",
"return",
"None",
"date_formats",
"=",
"[",
"\"%m/%d/%Y\"",
",",
"\"%Y-%m-%d\"",
",",
"\"%Y%m%d\"",
"]",
"datetime_obj",
"=",
"None",
"for",
"fmt",
"in",
"date_forma... | Takes a date from the SWS response object
and attempts to parse it using one of the several
datetime formats used by the SWS
:param date_string:
:return: date object | [
"Takes",
"a",
"date",
"from",
"the",
"SWS",
"response",
"object",
"and",
"attempts",
"to",
"parse",
"it",
"using",
"one",
"of",
"the",
"several",
"datetime",
"formats",
"used",
"by",
"the",
"SWS",
":",
"param",
"date_string",
":",
":",
"return",
":",
"da... | 4d36776dcca36855fc15c1b8fe7650ae045194cf | https://github.com/uw-it-aca/uw-restclients-sws/blob/4d36776dcca36855fc15c1b8fe7650ae045194cf/uw_sws/__init__.py#L18-L38 | train | Takes a date from the SWS response object
and attempts to parse it using one of the several date formats used by the SWS response object
. |
uw-it-aca/uw-restclients-sws | uw_sws/__init__.py | get_resource | def get_resource(url):
"""
Issue a GET request to SWS with the given url
and return a response in json format.
:returns: http response with content in json
"""
response = DAO.getURL(url, {'Accept': 'application/json',
'Connection': 'keep-alive'})
if response.s... | python | def get_resource(url):
"""
Issue a GET request to SWS with the given url
and return a response in json format.
:returns: http response with content in json
"""
response = DAO.getURL(url, {'Accept': 'application/json',
'Connection': 'keep-alive'})
if response.s... | [
"def",
"get_resource",
"(",
"url",
")",
":",
"response",
"=",
"DAO",
".",
"getURL",
"(",
"url",
",",
"{",
"'Accept'",
":",
"'application/json'",
",",
"'Connection'",
":",
"'keep-alive'",
"}",
")",
"if",
"response",
".",
"status",
"!=",
"200",
":",
"raise... | Issue a GET request to SWS with the given url
and return a response in json format.
:returns: http response with content in json | [
"Issue",
"a",
"GET",
"request",
"to",
"SWS",
"with",
"the",
"given",
"url",
"and",
"return",
"a",
"response",
"in",
"json",
"format",
".",
":",
"returns",
":",
"http",
"response",
"with",
"content",
"in",
"json"
] | 4d36776dcca36855fc15c1b8fe7650ae045194cf | https://github.com/uw-it-aca/uw-restclients-sws/blob/4d36776dcca36855fc15c1b8fe7650ae045194cf/uw_sws/__init__.py#L45-L55 | train | Issue a GET request to SWS with the given url and return a response in json format. |
projectshift/shift-boiler | boiler/feature/users.py | users_feature | def users_feature(app):
"""
Add users feature
Allows to register users and assign groups, instantiates flask login, flask principal
and oauth integration
"""
# check we have jwt secret configures
if not app.config.get('USER_JWT_SECRET', None):
raise x.JwtSecretMissing('Please set US... | python | def users_feature(app):
"""
Add users feature
Allows to register users and assign groups, instantiates flask login, flask principal
and oauth integration
"""
# check we have jwt secret configures
if not app.config.get('USER_JWT_SECRET', None):
raise x.JwtSecretMissing('Please set US... | [
"def",
"users_feature",
"(",
"app",
")",
":",
"# check we have jwt secret configures",
"if",
"not",
"app",
".",
"config",
".",
"get",
"(",
"'USER_JWT_SECRET'",
",",
"None",
")",
":",
"raise",
"x",
".",
"JwtSecretMissing",
"(",
"'Please set USER_JWT_SECRET in config'... | Add users feature
Allows to register users and assign groups, instantiates flask login, flask principal
and oauth integration | [
"Add",
"users",
"feature",
"Allows",
"to",
"register",
"users",
"and",
"assign",
"groups",
"instantiates",
"flask",
"login",
"flask",
"principal",
"and",
"oauth",
"integration"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/feature/users.py#L14-L69 | train | Add users feature to the application. |
projectshift/shift-boiler | boiler/feature/users.py | enable_request_loader | def enable_request_loader():
"""
Enable request loader
Optional user loader based on incomin request object. This is useful to
enable on top of default user loader if you want to authenticate API
requests via bearer token header.
:return:
"""
@login_manager.request_loader
def load_us... | python | def enable_request_loader():
"""
Enable request loader
Optional user loader based on incomin request object. This is useful to
enable on top of default user loader if you want to authenticate API
requests via bearer token header.
:return:
"""
@login_manager.request_loader
def load_us... | [
"def",
"enable_request_loader",
"(",
")",
":",
"@",
"login_manager",
".",
"request_loader",
"def",
"load_user_from_request",
"(",
"request",
")",
":",
"user",
"=",
"None",
"auth",
"=",
"request",
".",
"headers",
".",
"get",
"(",
"'Authorization'",
")",
"if",
... | Enable request loader
Optional user loader based on incomin request object. This is useful to
enable on top of default user loader if you want to authenticate API
requests via bearer token header.
:return: | [
"Enable",
"request",
"loader",
"Optional",
"user",
"loader",
"based",
"on",
"incomin",
"request",
"object",
".",
"This",
"is",
"useful",
"to",
"enable",
"on",
"top",
"of",
"default",
"user",
"loader",
"if",
"you",
"want",
"to",
"authenticate",
"API",
"reques... | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/feature/users.py#L72-L97 | train | Enable request loader based on incomin request object. |
ethan92429/onshapepy | onshapepy/core/client.py | Client.create_document | def create_document(self, name='Test Document', owner_type=0, public=True):
'''
Create a new document.
Args:
- name (str, default='Test Document'): The doc name
- owner_type (int, default=0): 0 for user, 1 for company, 2 for team
- public (bool, default=False... | python | def create_document(self, name='Test Document', owner_type=0, public=True):
'''
Create a new document.
Args:
- name (str, default='Test Document'): The doc name
- owner_type (int, default=0): 0 for user, 1 for company, 2 for team
- public (bool, default=False... | [
"def",
"create_document",
"(",
"self",
",",
"name",
"=",
"'Test Document'",
",",
"owner_type",
"=",
"0",
",",
"public",
"=",
"True",
")",
":",
"payload",
"=",
"{",
"'name'",
":",
"name",
",",
"'ownerType'",
":",
"owner_type",
",",
"'isPublic'",
":",
"pub... | Create a new document.
Args:
- name (str, default='Test Document'): The doc name
- owner_type (int, default=0): 0 for user, 1 for company, 2 for team
- public (bool, default=False): Whether or not to make doc public
Returns:
- requests.Response: Onshape ... | [
"Create",
"a",
"new",
"document",
"."
] | 61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df | https://github.com/ethan92429/onshapepy/blob/61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df/onshapepy/core/client.py#L77-L96 | train | Create a new document. |
ethan92429/onshapepy | onshapepy/core/client.py | Client.rename_document | def rename_document(self, did, name):
'''
Renames the specified document.
Args:
- did (str): Document ID
- name (str): New document name
Returns:
- requests.Response: Onshape response data
'''
payload = {
'name': name
... | python | def rename_document(self, did, name):
'''
Renames the specified document.
Args:
- did (str): Document ID
- name (str): New document name
Returns:
- requests.Response: Onshape response data
'''
payload = {
'name': name
... | [
"def",
"rename_document",
"(",
"self",
",",
"did",
",",
"name",
")",
":",
"payload",
"=",
"{",
"'name'",
":",
"name",
"}",
"return",
"self",
".",
"_api",
".",
"request",
"(",
"'post'",
",",
"'/api/documents/'",
"+",
"did",
",",
"body",
"=",
"payload",
... | Renames the specified document.
Args:
- did (str): Document ID
- name (str): New document name
Returns:
- requests.Response: Onshape response data | [
"Renames",
"the",
"specified",
"document",
"."
] | 61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df | https://github.com/ethan92429/onshapepy/blob/61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df/onshapepy/core/client.py#L98-L114 | train | Renames the specified document. |
ethan92429/onshapepy | onshapepy/core/client.py | Client.copy_workspace | def copy_workspace(self, uri, new_name):
'''
Copy the current workspace.
Args:
- uri (dict): the uri of the workspace being copied. Needs to have a did and wid key.
- new_name (str): the new name of the copied workspace.
Returns:
- requests.Response:... | python | def copy_workspace(self, uri, new_name):
'''
Copy the current workspace.
Args:
- uri (dict): the uri of the workspace being copied. Needs to have a did and wid key.
- new_name (str): the new name of the copied workspace.
Returns:
- requests.Response:... | [
"def",
"copy_workspace",
"(",
"self",
",",
"uri",
",",
"new_name",
")",
":",
"payload",
"=",
"{",
"'isPublic'",
":",
"True",
",",
"'newName'",
":",
"new_name",
"}",
"return",
"self",
".",
"_api",
".",
"request",
"(",
"'post'",
",",
"'/api/documents/'",
"... | Copy the current workspace.
Args:
- uri (dict): the uri of the workspace being copied. Needs to have a did and wid key.
- new_name (str): the new name of the copied workspace.
Returns:
- requests.Response: Onshape response data | [
"Copy",
"the",
"current",
"workspace",
"."
] | 61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df | https://github.com/ethan92429/onshapepy/blob/61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df/onshapepy/core/client.py#L152-L169 | train | Copy the current workspace. |
ethan92429/onshapepy | onshapepy/core/client.py | Client.create_workspace | def create_workspace(self, did, name, version_id=None):
'''
Create a workspace in the specified document.
Args:
- did (str): the document id of where to create the new workspace
- name (str): the new name of the copied workspace.
- version_id (str): the ID of... | python | def create_workspace(self, did, name, version_id=None):
'''
Create a workspace in the specified document.
Args:
- did (str): the document id of where to create the new workspace
- name (str): the new name of the copied workspace.
- version_id (str): the ID of... | [
"def",
"create_workspace",
"(",
"self",
",",
"did",
",",
"name",
",",
"version_id",
"=",
"None",
")",
":",
"payload",
"=",
"{",
"'isPublic'",
":",
"True",
",",
"'name'",
":",
"name",
",",
"}",
"if",
"version_id",
":",
"payload",
"[",
"'versionId'",
"]"... | Create a workspace in the specified document.
Args:
- did (str): the document id of where to create the new workspace
- name (str): the new name of the copied workspace.
- version_id (str): the ID of the version to be copied into a new workspace
Returns:
... | [
"Create",
"a",
"workspace",
"in",
"the",
"specified",
"document",
"."
] | 61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df | https://github.com/ethan92429/onshapepy/blob/61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df/onshapepy/core/client.py#L171-L192 | train | Create a workspace in the specified document. |
ethan92429/onshapepy | onshapepy/core/client.py | Client.create_assembly | def create_assembly(self, did, wid, name='My Assembly'):
'''
Creates a new assembly element in the specified document / workspace.
Args:
- did (str): Document ID
- wid (str): Workspace ID
- name (str, default='My Assembly')
Returns:
- req... | python | def create_assembly(self, did, wid, name='My Assembly'):
'''
Creates a new assembly element in the specified document / workspace.
Args:
- did (str): Document ID
- wid (str): Workspace ID
- name (str, default='My Assembly')
Returns:
- req... | [
"def",
"create_assembly",
"(",
"self",
",",
"did",
",",
"wid",
",",
"name",
"=",
"'My Assembly'",
")",
":",
"payload",
"=",
"{",
"'name'",
":",
"name",
"}",
"return",
"self",
".",
"_api",
".",
"request",
"(",
"'post'",
",",
"'/api/assemblies/d/'",
"+",
... | Creates a new assembly element in the specified document / workspace.
Args:
- did (str): Document ID
- wid (str): Workspace ID
- name (str, default='My Assembly')
Returns:
- requests.Response: Onshape response data | [
"Creates",
"a",
"new",
"assembly",
"element",
"in",
"the",
"specified",
"document",
"/",
"workspace",
"."
] | 61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df | https://github.com/ethan92429/onshapepy/blob/61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df/onshapepy/core/client.py#L194-L211 | train | Creates a new assembly element in the specified document / workspace. |
ethan92429/onshapepy | onshapepy/core/client.py | Client.get_features | def get_features(self, did, wid, eid):
'''
Gets the feature list for specified document / workspace / part studio.
Args:
- did (str): Document ID
- wid (str): Workspace ID
- eid (str): Element ID
Returns:
- requests.Response: Onshape resp... | python | def get_features(self, did, wid, eid):
'''
Gets the feature list for specified document / workspace / part studio.
Args:
- did (str): Document ID
- wid (str): Workspace ID
- eid (str): Element ID
Returns:
- requests.Response: Onshape resp... | [
"def",
"get_features",
"(",
"self",
",",
"did",
",",
"wid",
",",
"eid",
")",
":",
"return",
"self",
".",
"_api",
".",
"request",
"(",
"'get'",
",",
"'/api/partstudios/d/'",
"+",
"did",
"+",
"'/w/'",
"+",
"wid",
"+",
"'/e/'",
"+",
"eid",
"+",
"'/featu... | Gets the feature list for specified document / workspace / part studio.
Args:
- did (str): Document ID
- wid (str): Workspace ID
- eid (str): Element ID
Returns:
- requests.Response: Onshape response data | [
"Gets",
"the",
"feature",
"list",
"for",
"specified",
"document",
"/",
"workspace",
"/",
"part",
"studio",
"."
] | 61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df | https://github.com/ethan92429/onshapepy/blob/61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df/onshapepy/core/client.py#L213-L226 | train | Gets the feature list for a specified document workspace and element ID. |
ethan92429/onshapepy | onshapepy/core/client.py | Client.get_partstudio_tessellatededges | def get_partstudio_tessellatededges(self, did, wid, eid):
'''
Gets the tessellation of the edges of all parts in a part studio.
Args:
- did (str): Document ID
- wid (str): Workspace ID
- eid (str): Element ID
Returns:
- requests.Response:... | python | def get_partstudio_tessellatededges(self, did, wid, eid):
'''
Gets the tessellation of the edges of all parts in a part studio.
Args:
- did (str): Document ID
- wid (str): Workspace ID
- eid (str): Element ID
Returns:
- requests.Response:... | [
"def",
"get_partstudio_tessellatededges",
"(",
"self",
",",
"did",
",",
"wid",
",",
"eid",
")",
":",
"return",
"self",
".",
"_api",
".",
"request",
"(",
"'get'",
",",
"'/api/partstudios/d/'",
"+",
"did",
"+",
"'/w/'",
"+",
"wid",
"+",
"'/e/'",
"+",
"eid"... | Gets the tessellation of the edges of all parts in a part studio.
Args:
- did (str): Document ID
- wid (str): Workspace ID
- eid (str): Element ID
Returns:
- requests.Response: Onshape response data | [
"Gets",
"the",
"tessellation",
"of",
"the",
"edges",
"of",
"all",
"parts",
"in",
"a",
"part",
"studio",
"."
] | 61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df | https://github.com/ethan92429/onshapepy/blob/61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df/onshapepy/core/client.py#L228-L241 | train | Gets the tessellation of the edges of all parts in a part studio. |
ethan92429/onshapepy | onshapepy/core/client.py | Client.upload_blob | def upload_blob(self, did, wid, filepath='./blob.json'):
'''
Uploads a file to a new blob element in the specified doc.
Args:
- did (str): Document ID
- wid (str): Workspace ID
- filepath (str, default='./blob.json'): Blob element location
Returns:
... | python | def upload_blob(self, did, wid, filepath='./blob.json'):
'''
Uploads a file to a new blob element in the specified doc.
Args:
- did (str): Document ID
- wid (str): Workspace ID
- filepath (str, default='./blob.json'): Blob element location
Returns:
... | [
"def",
"upload_blob",
"(",
"self",
",",
"did",
",",
"wid",
",",
"filepath",
"=",
"'./blob.json'",
")",
":",
"chars",
"=",
"string",
".",
"ascii_letters",
"+",
"string",
".",
"digits",
"boundary_key",
"=",
"''",
".",
"join",
"(",
"random",
".",
"choice",
... | Uploads a file to a new blob element in the specified doc.
Args:
- did (str): Document ID
- wid (str): Workspace ID
- filepath (str, default='./blob.json'): Blob element location
Returns:
- requests.Response: Onshape response data | [
"Uploads",
"a",
"file",
"to",
"a",
"new",
"blob",
"element",
"in",
"the",
"specified",
"doc",
"."
] | 61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df | https://github.com/ethan92429/onshapepy/blob/61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df/onshapepy/core/client.py#L243-L276 | train | Uploads a file to a new blob element in a workspace. |
ethan92429/onshapepy | onshapepy/core/client.py | Client.part_studio_stl | def part_studio_stl(self, did, wid, eid):
'''
Exports STL export from a part studio
Args:
- did (str): Document ID
- wid (str): Workspace ID
- eid (str): Element ID
Returns:
- requests.Response: Onshape response data
'''
... | python | def part_studio_stl(self, did, wid, eid):
'''
Exports STL export from a part studio
Args:
- did (str): Document ID
- wid (str): Workspace ID
- eid (str): Element ID
Returns:
- requests.Response: Onshape response data
'''
... | [
"def",
"part_studio_stl",
"(",
"self",
",",
"did",
",",
"wid",
",",
"eid",
")",
":",
"req_headers",
"=",
"{",
"'Accept'",
":",
"'application/vnd.onshape.v1+octet-stream'",
"}",
"return",
"self",
".",
"_api",
".",
"request",
"(",
"'get'",
",",
"'/api/partstudio... | Exports STL export from a part studio
Args:
- did (str): Document ID
- wid (str): Workspace ID
- eid (str): Element ID
Returns:
- requests.Response: Onshape response data | [
"Exports",
"STL",
"export",
"from",
"a",
"part",
"studio"
] | 61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df | https://github.com/ethan92429/onshapepy/blob/61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df/onshapepy/core/client.py#L278-L294 | train | Exports STL export from a part studio |
ethan92429/onshapepy | onshapepy/core/client.py | Client.create_assembly_instance | def create_assembly_instance(self, assembly_uri, part_uri, configuration):
'''
Insert a configurable part into an assembly.
Args:
- assembly (dict): eid, wid, and did of the assembly into which will be inserted
- part (dict): eid and did of the configurable part
... | python | def create_assembly_instance(self, assembly_uri, part_uri, configuration):
'''
Insert a configurable part into an assembly.
Args:
- assembly (dict): eid, wid, and did of the assembly into which will be inserted
- part (dict): eid and did of the configurable part
... | [
"def",
"create_assembly_instance",
"(",
"self",
",",
"assembly_uri",
",",
"part_uri",
",",
"configuration",
")",
":",
"payload",
"=",
"{",
"\"documentId\"",
":",
"part_uri",
"[",
"\"did\"",
"]",
",",
"\"elementId\"",
":",
"part_uri",
"[",
"\"eid\"",
"]",
",",
... | Insert a configurable part into an assembly.
Args:
- assembly (dict): eid, wid, and did of the assembly into which will be inserted
- part (dict): eid and did of the configurable part
- configuration (dict): the configuration
Returns:
- requests.Response... | [
"Insert",
"a",
"configurable",
"part",
"into",
"an",
"assembly",
"."
] | 61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df | https://github.com/ethan92429/onshapepy/blob/61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df/onshapepy/core/client.py#L298-L325 | train | Creates an assembly instance. |
ethan92429/onshapepy | onshapepy/core/client.py | Client.encode_configuration | def encode_configuration(self, did, eid, parameters):
'''
Encode parameters as a URL-ready string
Args:
- did (str): Document ID
- eid (str): Element ID
- parameters (dict): key-value pairs of the parameters to be encoded
Returns:
- config... | python | def encode_configuration(self, did, eid, parameters):
'''
Encode parameters as a URL-ready string
Args:
- did (str): Document ID
- eid (str): Element ID
- parameters (dict): key-value pairs of the parameters to be encoded
Returns:
- config... | [
"def",
"encode_configuration",
"(",
"self",
",",
"did",
",",
"eid",
",",
"parameters",
")",
":",
"# change to the type of list the API is expecting",
"parameters",
"=",
"[",
"{",
"\"parameterId\"",
":",
"k",
",",
"\"parameterValue\"",
":",
"v",
"}",
"for",
"(",
... | Encode parameters as a URL-ready string
Args:
- did (str): Document ID
- eid (str): Element ID
- parameters (dict): key-value pairs of the parameters to be encoded
Returns:
- configuration (str): the url-ready configuration string. | [
"Encode",
"parameters",
"as",
"a",
"URL",
"-",
"ready",
"string"
] | 61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df | https://github.com/ethan92429/onshapepy/blob/61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df/onshapepy/core/client.py#L327-L352 | train | Encode parameters as a URL - ready string |
ethan92429/onshapepy | onshapepy/core/client.py | Client.get_configuration | def get_configuration(self, uri):
'''
get the configuration of a PartStudio
Args:
- uri (dict): points to a particular element
Returns:
- requests.Response: Onshape response data
'''
req_headers = {
'Accept': 'application/vnd.onshape... | python | def get_configuration(self, uri):
'''
get the configuration of a PartStudio
Args:
- uri (dict): points to a particular element
Returns:
- requests.Response: Onshape response data
'''
req_headers = {
'Accept': 'application/vnd.onshape... | [
"def",
"get_configuration",
"(",
"self",
",",
"uri",
")",
":",
"req_headers",
"=",
"{",
"'Accept'",
":",
"'application/vnd.onshape.v1+json'",
",",
"'Content-Type'",
":",
"'application/json'",
"}",
"return",
"self",
".",
"_api",
".",
"request",
"(",
"'get'",
",",... | get the configuration of a PartStudio
Args:
- uri (dict): points to a particular element
Returns:
- requests.Response: Onshape response data | [
"get",
"the",
"configuration",
"of",
"a",
"PartStudio"
] | 61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df | https://github.com/ethan92429/onshapepy/blob/61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df/onshapepy/core/client.py#L355-L370 | train | This method is used to get the configuration of a PartStudio
|
ethan92429/onshapepy | onshapepy/core/client.py | Client.update_configuration | def update_configuration(self, did, wid, eid, payload):
'''
Update the configuration specified in the payload
Args:
- did (str): Document ID
- eid (str): Element ID
- payload (json): the request body
Returns:
- configuration (str): the url... | python | def update_configuration(self, did, wid, eid, payload):
'''
Update the configuration specified in the payload
Args:
- did (str): Document ID
- eid (str): Element ID
- payload (json): the request body
Returns:
- configuration (str): the url... | [
"def",
"update_configuration",
"(",
"self",
",",
"did",
",",
"wid",
",",
"eid",
",",
"payload",
")",
":",
"req_headers",
"=",
"{",
"'Accept'",
":",
"'application/vnd.onshape.v1+json'",
",",
"'Content-Type'",
":",
"'application/json'",
"}",
"res",
"=",
"self",
... | Update the configuration specified in the payload
Args:
- did (str): Document ID
- eid (str): Element ID
- payload (json): the request body
Returns:
- configuration (str): the url-ready configuration string. | [
"Update",
"the",
"configuration",
"specified",
"in",
"the",
"payload"
] | 61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df | https://github.com/ethan92429/onshapepy/blob/61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df/onshapepy/core/client.py#L375-L394 | train | Update the configuration of the specified in the payload |
teitei-tk/Flask-REST-Controller | flask_rest_controller/routing.py | set_routing | def set_routing(app, view_data):
"""
apply the routing configuration you've described
example:
view_data = [
("/", "app.IndexController", "index"),
]
1. "/" is receive request path
2. "app.IndexController" is to process the received request controller class path... | python | def set_routing(app, view_data):
"""
apply the routing configuration you've described
example:
view_data = [
("/", "app.IndexController", "index"),
]
1. "/" is receive request path
2. "app.IndexController" is to process the received request controller class path... | [
"def",
"set_routing",
"(",
"app",
",",
"view_data",
")",
":",
"routing_modules",
"=",
"convert_routing_module",
"(",
"view_data",
")",
"for",
"module",
"in",
"routing_modules",
":",
"view",
"=",
"import_string",
"(",
"module",
".",
"import_path",
")",
"app",
"... | apply the routing configuration you've described
example:
view_data = [
("/", "app.IndexController", "index"),
]
1. "/" is receive request path
2. "app.IndexController" is to process the received request controller class path
3. "index" string To generate a URL ... | [
"apply",
"the",
"routing",
"configuration",
"you",
"ve",
"described"
] | b4386b523f3d2c6550051c95d5ba74e5ff459946 | https://github.com/teitei-tk/Flask-REST-Controller/blob/b4386b523f3d2c6550051c95d5ba74e5ff459946/flask_rest_controller/routing.py#L16-L34 | train | This function applies the routing configuration you ve described in the routing module. |
aacanakin/glim | glim/command.py | CommandAdapter.retrieve_commands | def retrieve_commands(self, module):
"""
Function smartly imports Command type classes given module
Args
----
module (module):
The module which Command classes will be extracted from
Returns
-------
commands (list):
A list of ... | python | def retrieve_commands(self, module):
"""
Function smartly imports Command type classes given module
Args
----
module (module):
The module which Command classes will be extracted from
Returns
-------
commands (list):
A list of ... | [
"def",
"retrieve_commands",
"(",
"self",
",",
"module",
")",
":",
"commands",
"=",
"[",
"]",
"for",
"name",
",",
"obj",
"in",
"inspect",
".",
"getmembers",
"(",
"module",
")",
":",
"if",
"name",
"!=",
"'Command'",
"and",
"'Command'",
"in",
"name",
":",... | Function smartly imports Command type classes given module
Args
----
module (module):
The module which Command classes will be extracted from
Returns
-------
commands (list):
A list of Command instances
Note:
This function ... | [
"Function",
"smartly",
"imports",
"Command",
"type",
"classes",
"given",
"module"
] | 71a20ac149a1292c0d6c1dc7414985ea51854f7a | https://github.com/aacanakin/glim/blob/71a20ac149a1292c0d6c1dc7414985ea51854f7a/glim/command.py#L33-L62 | train | Function smartly imports Command type classes given a module and returns a list of Command instances. |
aacanakin/glim | glim/command.py | CommandAdapter.register | def register(self, module):
"""
Function registers into self.commands from module.
Args
----
module (module): The module name.
"""
if module is not None:
cmds = self.retrieve_commands(module)
for c in cmds:
if self.valid... | python | def register(self, module):
"""
Function registers into self.commands from module.
Args
----
module (module): The module name.
"""
if module is not None:
cmds = self.retrieve_commands(module)
for c in cmds:
if self.valid... | [
"def",
"register",
"(",
"self",
",",
"module",
")",
":",
"if",
"module",
"is",
"not",
"None",
":",
"cmds",
"=",
"self",
".",
"retrieve_commands",
"(",
"module",
")",
"for",
"c",
"in",
"cmds",
":",
"if",
"self",
".",
"valid_name",
"(",
"c",
".",
"na... | Function registers into self.commands from module.
Args
----
module (module): The module name. | [
"Function",
"registers",
"into",
"self",
".",
"commands",
"from",
"module",
"."
] | 71a20ac149a1292c0d6c1dc7414985ea51854f7a | https://github.com/aacanakin/glim/blob/71a20ac149a1292c0d6c1dc7414985ea51854f7a/glim/command.py#L79-L96 | train | Function registers into self. commands from module. |
aacanakin/glim | glim/command.py | CommandAdapter.register_extension | def register_extension(self, module, extension):
"""
Function registers into self.commands from module extension.
All extension subcommands are registered using the name convention
'extension:command'
Example:
If you have a redis extension namely 'gredis', the extens... | python | def register_extension(self, module, extension):
"""
Function registers into self.commands from module extension.
All extension subcommands are registered using the name convention
'extension:command'
Example:
If you have a redis extension namely 'gredis', the extens... | [
"def",
"register_extension",
"(",
"self",
",",
"module",
",",
"extension",
")",
":",
"if",
"module",
"is",
"not",
"None",
":",
"cmds",
"=",
"self",
".",
"retrieve_commands",
"(",
"module",
")",
"commands",
"=",
"[",
"]",
"for",
"c",
"in",
"cmds",
":",
... | Function registers into self.commands from module extension.
All extension subcommands are registered using the name convention
'extension:command'
Example:
If you have a redis extension namely 'gredis', the extension
commands can be accessed by the following;
... | [
"Function",
"registers",
"into",
"self",
".",
"commands",
"from",
"module",
"extension",
".",
"All",
"extension",
"subcommands",
"are",
"registered",
"using",
"the",
"name",
"convention",
"extension",
":",
"command"
] | 71a20ac149a1292c0d6c1dc7414985ea51854f7a | https://github.com/aacanakin/glim/blob/71a20ac149a1292c0d6c1dc7414985ea51854f7a/glim/command.py#L98-L123 | train | Function registers into self. commands from module extension. |
aacanakin/glim | glim/command.py | CommandAdapter.match | def match(self, args):
"""
Function dispatches the active command line utility.
Args
----
args (argparse.parse_args()):
The parsed arguments using parser.parse_args() function.
Returns
-------
command (glim.command.Command): the active co... | python | def match(self, args):
"""
Function dispatches the active command line utility.
Args
----
args (argparse.parse_args()):
The parsed arguments using parser.parse_args() function.
Returns
-------
command (glim.command.Command): the active co... | [
"def",
"match",
"(",
"self",
",",
"args",
")",
":",
"command",
"=",
"None",
"for",
"c",
"in",
"self",
".",
"commands",
":",
"if",
"c",
".",
"name",
"==",
"args",
".",
"which",
":",
"c",
".",
"args",
"=",
"args",
"command",
"=",
"c",
"break",
"r... | Function dispatches the active command line utility.
Args
----
args (argparse.parse_args()):
The parsed arguments using parser.parse_args() function.
Returns
-------
command (glim.command.Command): the active command object. | [
"Function",
"dispatches",
"the",
"active",
"command",
"line",
"utility",
"."
] | 71a20ac149a1292c0d6c1dc7414985ea51854f7a | https://github.com/aacanakin/glim/blob/71a20ac149a1292c0d6c1dc7414985ea51854f7a/glim/command.py#L125-L144 | train | This function dispatches the active command line utility. It returns the active command object if the active command line utility is available otherwise None. |
aacanakin/glim | glim/command.py | CommandAdapter.dispatch | def dispatch(self, command, app):
"""
Function runs the active command.
Args
----
command (glim.command.Command): the command object.
app (glim.app.App): the glim app object.
Note:
Exception handling should be done in Command class
itself... | python | def dispatch(self, command, app):
"""
Function runs the active command.
Args
----
command (glim.command.Command): the command object.
app (glim.app.App): the glim app object.
Note:
Exception handling should be done in Command class
itself... | [
"def",
"dispatch",
"(",
"self",
",",
"command",
",",
"app",
")",
":",
"if",
"self",
".",
"is_glimcommand",
"(",
"command",
")",
":",
"command",
".",
"run",
"(",
"app",
")",
"else",
":",
"command",
".",
"run",
"(",
")"
] | Function runs the active command.
Args
----
command (glim.command.Command): the command object.
app (glim.app.App): the glim app object.
Note:
Exception handling should be done in Command class
itself. If not, an unhandled exception may result
... | [
"Function",
"runs",
"the",
"active",
"command",
"."
] | 71a20ac149a1292c0d6c1dc7414985ea51854f7a | https://github.com/aacanakin/glim/blob/71a20ac149a1292c0d6c1dc7414985ea51854f7a/glim/command.py#L160-L177 | train | Function runs the active command. |
Kortemme-Lab/klab | klab/bio/fasta.py | FASTA.replace_sequence | def replace_sequence(self, pdb_ID, chain_id, replacement_sequence):
'''Replaces a sequence with another. Typically not useful but I use it in the ResidueRelatrix to make sure that the FASTA and SEQRES sequences match.'''
old_sequences = self.sequences
old_unique_sequences = self.unique_sequences... | python | def replace_sequence(self, pdb_ID, chain_id, replacement_sequence):
'''Replaces a sequence with another. Typically not useful but I use it in the ResidueRelatrix to make sure that the FASTA and SEQRES sequences match.'''
old_sequences = self.sequences
old_unique_sequences = self.unique_sequences... | [
"def",
"replace_sequence",
"(",
"self",
",",
"pdb_ID",
",",
"chain_id",
",",
"replacement_sequence",
")",
":",
"old_sequences",
"=",
"self",
".",
"sequences",
"old_unique_sequences",
"=",
"self",
".",
"unique_sequences",
"self",
".",
"sequences",
"=",
"[",
"]",
... | Replaces a sequence with another. Typically not useful but I use it in the ResidueRelatrix to make sure that the FASTA and SEQRES sequences match. | [
"Replaces",
"a",
"sequence",
"with",
"another",
".",
"Typically",
"not",
"useful",
"but",
"I",
"use",
"it",
"in",
"the",
"ResidueRelatrix",
"to",
"make",
"sure",
"that",
"the",
"FASTA",
"and",
"SEQRES",
"sequences",
"match",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/fasta.py#L63-L75 | train | Replaces a sequence with another. Typically not useful but I use it in the ResidueRelatrix to make sure that the FASTA and SEQRES sequences match. |
Kortemme-Lab/klab | klab/bio/fasta.py | FASTA.retrieve | def retrieve(pdb_id, cache_dir = None, bio_cache = None):
'''Creates a FASTA object by using a cached copy of the file if it exists or by retrieving the file from the RCSB.'''
pdb_id = pdb_id.upper()
if bio_cache:
return FASTA(bio_cache.get_fasta_contents(pdb_id))
# Check ... | python | def retrieve(pdb_id, cache_dir = None, bio_cache = None):
'''Creates a FASTA object by using a cached copy of the file if it exists or by retrieving the file from the RCSB.'''
pdb_id = pdb_id.upper()
if bio_cache:
return FASTA(bio_cache.get_fasta_contents(pdb_id))
# Check ... | [
"def",
"retrieve",
"(",
"pdb_id",
",",
"cache_dir",
"=",
"None",
",",
"bio_cache",
"=",
"None",
")",
":",
"pdb_id",
"=",
"pdb_id",
".",
"upper",
"(",
")",
"if",
"bio_cache",
":",
"return",
"FASTA",
"(",
"bio_cache",
".",
"get_fasta_contents",
"(",
"pdb_i... | Creates a FASTA object by using a cached copy of the file if it exists or by retrieving the file from the RCSB. | [
"Creates",
"a",
"FASTA",
"object",
"by",
"using",
"a",
"cached",
"copy",
"of",
"the",
"file",
"if",
"it",
"exists",
"or",
"by",
"retrieving",
"the",
"file",
"from",
"the",
"RCSB",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/fasta.py#L91-L117 | train | Creates a FASTA object by using a cached copy of the file if it exists or by retrieving the file from the RCSB. |
Kortemme-Lab/klab | klab/bio/fasta.py | FASTA._add_sequence | def _add_sequence(self, pdbID, chainID, sequence):
'''This is a 'private' function. If you call it directly, call _find_identical_sequences() afterwards to update identical_sequences.'''
pdbID = pdbID.upper()
self[pdbID] = self.get(pdbID, {})
self[pdbID][chainID] = sequence
self.... | python | def _add_sequence(self, pdbID, chainID, sequence):
'''This is a 'private' function. If you call it directly, call _find_identical_sequences() afterwards to update identical_sequences.'''
pdbID = pdbID.upper()
self[pdbID] = self.get(pdbID, {})
self[pdbID][chainID] = sequence
self.... | [
"def",
"_add_sequence",
"(",
"self",
",",
"pdbID",
",",
"chainID",
",",
"sequence",
")",
":",
"pdbID",
"=",
"pdbID",
".",
"upper",
"(",
")",
"self",
"[",
"pdbID",
"]",
"=",
"self",
".",
"get",
"(",
"pdbID",
",",
"{",
"}",
")",
"self",
"[",
"pdbID... | This is a 'private' function. If you call it directly, call _find_identical_sequences() afterwards to update identical_sequences. | [
"This",
"is",
"a",
"private",
"function",
".",
"If",
"you",
"call",
"it",
"directly",
"call",
"_find_identical_sequences",
"()",
"afterwards",
"to",
"update",
"identical_sequences",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/fasta.py#L140-L148 | train | This is a private function. This is a private function. |
Kortemme-Lab/klab | klab/bio/fasta.py | FASTA._find_identical_sequences | def _find_identical_sequences(self):
''' Stores the identical sequences in a map with the structure pdb_id -> chain_id -> List(identical chains)
where the identical chains have the format 'pdb_id:chain_id'
e.g. for 1A2P, we get {'1A2P': {'A': ['1A2P:B', '1A2P:C'], 'C': ['1A2P:A', '1A2P:B... | python | def _find_identical_sequences(self):
''' Stores the identical sequences in a map with the structure pdb_id -> chain_id -> List(identical chains)
where the identical chains have the format 'pdb_id:chain_id'
e.g. for 1A2P, we get {'1A2P': {'A': ['1A2P:B', '1A2P:C'], 'C': ['1A2P:A', '1A2P:B... | [
"def",
"_find_identical_sequences",
"(",
"self",
")",
":",
"sequences",
"=",
"self",
".",
"sequences",
"identical_sequences",
"=",
"{",
"}",
"numseq",
"=",
"len",
"(",
"self",
".",
"sequences",
")",
"for",
"x",
"in",
"range",
"(",
"numseq",
")",
":",
"fo... | Stores the identical sequences in a map with the structure pdb_id -> chain_id -> List(identical chains)
where the identical chains have the format 'pdb_id:chain_id'
e.g. for 1A2P, we get {'1A2P': {'A': ['1A2P:B', '1A2P:C'], 'C': ['1A2P:A', '1A2P:B'], 'B': ['1A2P:A', '1A2P:C']}} | [
"Stores",
"the",
"identical",
"sequences",
"in",
"a",
"map",
"with",
"the",
"structure",
"pdb_id",
"-",
">",
"chain_id",
"-",
">",
"List",
"(",
"identical",
"chains",
")",
"where",
"the",
"identical",
"chains",
"have",
"the",
"format",
"pdb_id",
":",
"chai... | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/fasta.py#L150-L172 | train | Find the identical sequences in the database. |
Kortemme-Lab/klab | klab/bio/fasta.py | FASTA.get_sequences | def get_sequences(self, pdb_id = None):
'''Create Sequence objects for each FASTA sequence.'''
sequences = {}
if pdb_id:
for chain_id, sequence in self.get(pdb_id, {}).iteritems():
sequences[chain_id] = Sequence.from_sequence(chain_id, sequence)
else:
... | python | def get_sequences(self, pdb_id = None):
'''Create Sequence objects for each FASTA sequence.'''
sequences = {}
if pdb_id:
for chain_id, sequence in self.get(pdb_id, {}).iteritems():
sequences[chain_id] = Sequence.from_sequence(chain_id, sequence)
else:
... | [
"def",
"get_sequences",
"(",
"self",
",",
"pdb_id",
"=",
"None",
")",
":",
"sequences",
"=",
"{",
"}",
"if",
"pdb_id",
":",
"for",
"chain_id",
",",
"sequence",
"in",
"self",
".",
"get",
"(",
"pdb_id",
",",
"{",
"}",
")",
".",
"iteritems",
"(",
")",... | Create Sequence objects for each FASTA sequence. | [
"Create",
"Sequence",
"objects",
"for",
"each",
"FASTA",
"sequence",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/fasta.py#L175-L186 | train | Create Sequence objects for each FASTA sequence. |
Kortemme-Lab/klab | klab/bio/fasta.py | FASTA.get_chain_ids | def get_chain_ids(self, pdb_id = None, safe_call = False):
'''If the FASTA file only has one PDB ID, pdb_id does not need to be specified. Otherwise, the list of chains identifiers for pdb_id is returned.'''
if pdb_id == None and len(self.keys()) == 1:
return self[self.keys()[0]].keys()
... | python | def get_chain_ids(self, pdb_id = None, safe_call = False):
'''If the FASTA file only has one PDB ID, pdb_id does not need to be specified. Otherwise, the list of chains identifiers for pdb_id is returned.'''
if pdb_id == None and len(self.keys()) == 1:
return self[self.keys()[0]].keys()
... | [
"def",
"get_chain_ids",
"(",
"self",
",",
"pdb_id",
"=",
"None",
",",
"safe_call",
"=",
"False",
")",
":",
"if",
"pdb_id",
"==",
"None",
"and",
"len",
"(",
"self",
".",
"keys",
"(",
")",
")",
"==",
"1",
":",
"return",
"self",
"[",
"self",
".",
"k... | If the FASTA file only has one PDB ID, pdb_id does not need to be specified. Otherwise, the list of chains identifiers for pdb_id is returned. | [
"If",
"the",
"FASTA",
"file",
"only",
"has",
"one",
"PDB",
"ID",
"pdb_id",
"does",
"not",
"need",
"to",
"be",
"specified",
".",
"Otherwise",
"the",
"list",
"of",
"chains",
"identifiers",
"for",
"pdb_id",
"is",
"returned",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/fasta.py#L191-L203 | train | Returns the list of chains identifiers for the given PDB ID. If the FASTA file only has one PDB ID the list of chains identifiers for pdb_id is returned. Otherwise the list of chains identifiers for pdb_id is returned. |
Kortemme-Lab/klab | klab/bio/fasta.py | FASTA.match | def match(self, other):
''' This is a noisy terminal-printing function at present since there is no need to make it a proper API function.'''
colortext.message("FASTA Match")
for frompdbID, fromchains in sorted(self.iteritems()):
matched_pdbs = {}
matched_chains = {}
... | python | def match(self, other):
''' This is a noisy terminal-printing function at present since there is no need to make it a proper API function.'''
colortext.message("FASTA Match")
for frompdbID, fromchains in sorted(self.iteritems()):
matched_pdbs = {}
matched_chains = {}
... | [
"def",
"match",
"(",
"self",
",",
"other",
")",
":",
"colortext",
".",
"message",
"(",
"\"FASTA Match\"",
")",
"for",
"frompdbID",
",",
"fromchains",
"in",
"sorted",
"(",
"self",
".",
"iteritems",
"(",
")",
")",
":",
"matched_pdbs",
"=",
"{",
"}",
"mat... | This is a noisy terminal-printing function at present since there is no need to make it a proper API function. | [
"This",
"is",
"a",
"noisy",
"terminal",
"-",
"printing",
"function",
"at",
"present",
"since",
"there",
"is",
"no",
"need",
"to",
"make",
"it",
"a",
"proper",
"API",
"function",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/fasta.py#L205-L235 | train | This function matches the two PDBs. |
uw-it-aca/uw-restclients-sws | uw_sws/person.py | _process_json_data | def _process_json_data(person_data):
"""
Returns a uw_sws.models.SwsPerson object
"""
person = SwsPerson()
if person_data["BirthDate"]:
person.birth_date = parse(person_data["BirthDate"]).date()
person.directory_release = person_data["DirectoryRelease"]
person.email = person_data["Em... | python | def _process_json_data(person_data):
"""
Returns a uw_sws.models.SwsPerson object
"""
person = SwsPerson()
if person_data["BirthDate"]:
person.birth_date = parse(person_data["BirthDate"]).date()
person.directory_release = person_data["DirectoryRelease"]
person.email = person_data["Em... | [
"def",
"_process_json_data",
"(",
"person_data",
")",
":",
"person",
"=",
"SwsPerson",
"(",
")",
"if",
"person_data",
"[",
"\"BirthDate\"",
"]",
":",
"person",
".",
"birth_date",
"=",
"parse",
"(",
"person_data",
"[",
"\"BirthDate\"",
"]",
")",
".",
"date",
... | Returns a uw_sws.models.SwsPerson object | [
"Returns",
"a",
"uw_sws",
".",
"models",
".",
"SwsPerson",
"object"
] | 4d36776dcca36855fc15c1b8fe7650ae045194cf | https://github.com/uw-it-aca/uw-restclients-sws/blob/4d36776dcca36855fc15c1b8fe7650ae045194cf/uw_sws/person.py#L23-L78 | train | Processes the JSON data returned by the API call into a uw_sws. models. SwsPerson object. |
uw-it-aca/uw-restclients-sws | uw_sws/dao.py | SWS_DAO._make_notice_date | def _make_notice_date(self, response):
"""
Set the date attribte value in the notice mock data
"""
today = date.today()
yesterday = today - timedelta(days=1)
tomorrow = today + timedelta(days=1)
week = today + timedelta(days=2)
next_week = today + timedelt... | python | def _make_notice_date(self, response):
"""
Set the date attribte value in the notice mock data
"""
today = date.today()
yesterday = today - timedelta(days=1)
tomorrow = today + timedelta(days=1)
week = today + timedelta(days=2)
next_week = today + timedelt... | [
"def",
"_make_notice_date",
"(",
"self",
",",
"response",
")",
":",
"today",
"=",
"date",
".",
"today",
"(",
")",
"yesterday",
"=",
"today",
"-",
"timedelta",
"(",
"days",
"=",
"1",
")",
"tomorrow",
"=",
"today",
"+",
"timedelta",
"(",
"days",
"=",
"... | Set the date attribte value in the notice mock data | [
"Set",
"the",
"date",
"attribte",
"value",
"in",
"the",
"notice",
"mock",
"data"
] | 4d36776dcca36855fc15c1b8fe7650ae045194cf | https://github.com/uw-it-aca/uw-restclients-sws/blob/4d36776dcca36855fc15c1b8fe7650ae045194cf/uw_sws/dao.py#L64-L99 | train | Make the date attribte value in the notice mock data. |
Kortemme-Lab/klab | klab/fcm/fcm.py | ticks_format | def ticks_format(value, index):
"""
get the value and returns the value as:
integer: [0,99]
1 digit float: [0.1, 0.99]
n*10^m: otherwise
To have all the number of the same size they are all returned as latex strings
http://stackoverflow.com/questions/17165435/matplotlib-show-labels... | python | def ticks_format(value, index):
"""
get the value and returns the value as:
integer: [0,99]
1 digit float: [0.1, 0.99]
n*10^m: otherwise
To have all the number of the same size they are all returned as latex strings
http://stackoverflow.com/questions/17165435/matplotlib-show-labels... | [
"def",
"ticks_format",
"(",
"value",
",",
"index",
")",
":",
"exp",
"=",
"np",
".",
"floor",
"(",
"np",
".",
"log10",
"(",
"value",
")",
")",
"base",
"=",
"value",
"/",
"10",
"**",
"exp",
"if",
"exp",
"==",
"0",
"or",
"exp",
"==",
"1",
":",
"... | get the value and returns the value as:
integer: [0,99]
1 digit float: [0.1, 0.99]
n*10^m: otherwise
To have all the number of the same size they are all returned as latex strings
http://stackoverflow.com/questions/17165435/matplotlib-show-labels-for-minor-ticks-also | [
"get",
"the",
"value",
"and",
"returns",
"the",
"value",
"as",
":",
"integer",
":",
"[",
"0",
"99",
"]",
"1",
"digit",
"float",
":",
"[",
"0",
".",
"1",
"0",
".",
"99",
"]",
"n",
"*",
"10^m",
":",
"otherwise",
"To",
"have",
"all",
"the",
"numbe... | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/fcm/fcm.py#L230-L247 | train | format the value and returns the value as latex string |
Kortemme-Lab/klab | klab/scripting.py | relative_symlink | def relative_symlink(target, link_name):
"""Make a symlink to target using the shortest possible relative path."""
link_name = os.path.abspath(link_name)
abs_target = os.path.abspath(target)
rel_target = os.path.relpath(target, os.path.dirname(link_name))
if os.path.exists(link_name):
os.re... | python | def relative_symlink(target, link_name):
"""Make a symlink to target using the shortest possible relative path."""
link_name = os.path.abspath(link_name)
abs_target = os.path.abspath(target)
rel_target = os.path.relpath(target, os.path.dirname(link_name))
if os.path.exists(link_name):
os.re... | [
"def",
"relative_symlink",
"(",
"target",
",",
"link_name",
")",
":",
"link_name",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"link_name",
")",
"abs_target",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"target",
")",
"rel_target",
"=",
"os",
".",
"p... | Make a symlink to target using the shortest possible relative path. | [
"Make",
"a",
"symlink",
"to",
"target",
"using",
"the",
"shortest",
"possible",
"relative",
"path",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/scripting.py#L57-L65 | train | Make a symlink to target using the shortest possible relative path. |
trsqxyz/glitch | glitch/glitch.py | Glitch.replace | def replace(self, infile):
'''Replace: 任意の箇所のバイト列と 同サイズの任意のバイト列を入れ換える
'''
gf = infile[31:]
same_size_index = []
while len(same_size_index) <= 1:
index = random.randint(0,len(gf)-1)
index_len = len(gf[index])
same_size_index = [i for (i,g) in en... | python | def replace(self, infile):
'''Replace: 任意の箇所のバイト列と 同サイズの任意のバイト列を入れ換える
'''
gf = infile[31:]
same_size_index = []
while len(same_size_index) <= 1:
index = random.randint(0,len(gf)-1)
index_len = len(gf[index])
same_size_index = [i for (i,g) in en... | [
"def",
"replace",
"(",
"self",
",",
"infile",
")",
":",
"gf",
"=",
"infile",
"[",
"31",
":",
"]",
"same_size_index",
"=",
"[",
"]",
"while",
"len",
"(",
"same_size_index",
")",
"<=",
"1",
":",
"index",
"=",
"random",
".",
"randint",
"(",
"0",
",",
... | Replace: 任意の箇所のバイト列と 同サイズの任意のバイト列を入れ換える | [
"Replace",
":",
"任意の箇所のバイト列と",
"同サイズの任意のバイト列を入れ換える"
] | b2cef7700a09660ff8a79ae587480680bef65a88 | https://github.com/trsqxyz/glitch/blob/b2cef7700a09660ff8a79ae587480680bef65a88/glitch/glitch.py#L90-L102 | train | Replace the file with a random entry. |
trsqxyz/glitch | glitch/glitch.py | Glitch.increase | def increase(self, infile):
'''Increase: 任意の箇所のバイト列と それより大きなサイズの任意のバイト列と入れ換える
'''
gf = infile[31:]
index = gf.index(random.choice(gf))
index_len = len(gf[index])
large_size_index = random.choice([gf.index(g) for g in gf if len(g) > index_len])
gf[index], gf[large_... | python | def increase(self, infile):
'''Increase: 任意の箇所のバイト列と それより大きなサイズの任意のバイト列と入れ換える
'''
gf = infile[31:]
index = gf.index(random.choice(gf))
index_len = len(gf[index])
large_size_index = random.choice([gf.index(g) for g in gf if len(g) > index_len])
gf[index], gf[large_... | [
"def",
"increase",
"(",
"self",
",",
"infile",
")",
":",
"gf",
"=",
"infile",
"[",
"31",
":",
"]",
"index",
"=",
"gf",
".",
"index",
"(",
"random",
".",
"choice",
"(",
"gf",
")",
")",
"index_len",
"=",
"len",
"(",
"gf",
"[",
"index",
"]",
")",
... | Increase: 任意の箇所のバイト列と それより大きなサイズの任意のバイト列と入れ換える | [
"Increase",
":",
"任意の箇所のバイト列と",
"それより大きなサイズの任意のバイト列と入れ換える"
] | b2cef7700a09660ff8a79ae587480680bef65a88 | https://github.com/trsqxyz/glitch/blob/b2cef7700a09660ff8a79ae587480680bef65a88/glitch/glitch.py#L104-L112 | train | Increase the file name by one random number. |
trsqxyz/glitch | glitch/glitch.py | Glitch.decrease | def decrease(self, infile):
'''Decrease: 任意の箇所のバイト列を 削除する
'''
gf = infile[31:]
try:
index = random.randint(len(gf)-1, 31)
except ValueError:
return infile
gf = gf[:index] + gf[index+1:]
return infile[:31] + gf | python | def decrease(self, infile):
'''Decrease: 任意の箇所のバイト列を 削除する
'''
gf = infile[31:]
try:
index = random.randint(len(gf)-1, 31)
except ValueError:
return infile
gf = gf[:index] + gf[index+1:]
return infile[:31] + gf | [
"def",
"decrease",
"(",
"self",
",",
"infile",
")",
":",
"gf",
"=",
"infile",
"[",
"31",
":",
"]",
"try",
":",
"index",
"=",
"random",
".",
"randint",
"(",
"len",
"(",
"gf",
")",
"-",
"1",
",",
"31",
")",
"except",
"ValueError",
":",
"return",
... | Decrease: 任意の箇所のバイト列を 削除する | [
"Decrease",
":",
"任意の箇所のバイト列を",
"削除する"
] | b2cef7700a09660ff8a79ae587480680bef65a88 | https://github.com/trsqxyz/glitch/blob/b2cef7700a09660ff8a79ae587480680bef65a88/glitch/glitch.py#L114-L123 | train | Decrease the file name by one. |
trsqxyz/glitch | glitch/glitch.py | Glitch.swap | def swap(self, infile):
'''Swap: 任意の箇所のバイト列と 他の任意の箇所のバイト列を入れ換える
'''
gf = infile[31:]
index = gf.index(random.choice(gf))
another = gf.index(random.choice(gf))
gf[index], gf[another] = gf[another], gf[index]
return infile[:31] + gf | python | def swap(self, infile):
'''Swap: 任意の箇所のバイト列と 他の任意の箇所のバイト列を入れ換える
'''
gf = infile[31:]
index = gf.index(random.choice(gf))
another = gf.index(random.choice(gf))
gf[index], gf[another] = gf[another], gf[index]
return infile[:31] + gf | [
"def",
"swap",
"(",
"self",
",",
"infile",
")",
":",
"gf",
"=",
"infile",
"[",
"31",
":",
"]",
"index",
"=",
"gf",
".",
"index",
"(",
"random",
".",
"choice",
"(",
"gf",
")",
")",
"another",
"=",
"gf",
".",
"index",
"(",
"random",
".",
"choice"... | Swap: 任意の箇所のバイト列と 他の任意の箇所のバイト列を入れ換える | [
"Swap",
":",
"任意の箇所のバイト列と",
"他の任意の箇所のバイト列を入れ換える"
] | b2cef7700a09660ff8a79ae587480680bef65a88 | https://github.com/trsqxyz/glitch/blob/b2cef7700a09660ff8a79ae587480680bef65a88/glitch/glitch.py#L125-L132 | train | Swap file with random entry |
trsqxyz/glitch | glitch/glitch.py | Glitch.changiling | def changiling(self, infile):
'''Changiling: 任意のバイト文字を 他の任意のバイト文字に置き換える
'''
gf = infile[31:]
baby, fetch = (self.word_toaster() for _ in range(2))
gf = [g.replace(baby, fetch) for g in gf]
return infile[:31] + gf | python | def changiling(self, infile):
'''Changiling: 任意のバイト文字を 他の任意のバイト文字に置き換える
'''
gf = infile[31:]
baby, fetch = (self.word_toaster() for _ in range(2))
gf = [g.replace(baby, fetch) for g in gf]
return infile[:31] + gf | [
"def",
"changiling",
"(",
"self",
",",
"infile",
")",
":",
"gf",
"=",
"infile",
"[",
"31",
":",
"]",
"baby",
",",
"fetch",
"=",
"(",
"self",
".",
"word_toaster",
"(",
")",
"for",
"_",
"in",
"range",
"(",
"2",
")",
")",
"gf",
"=",
"[",
"g",
".... | Changiling: 任意のバイト文字を 他の任意のバイト文字に置き換える | [
"Changiling",
":",
"任意のバイト文字を",
"他の任意のバイト文字に置き換える"
] | b2cef7700a09660ff8a79ae587480680bef65a88 | https://github.com/trsqxyz/glitch/blob/b2cef7700a09660ff8a79ae587480680bef65a88/glitch/glitch.py#L134-L140 | train | Changiling 任意のバイト文字に置き換える |
ethan92429/onshapepy | onshapepy/part.py | Part.params | def params(self, dict):
"""Set configuration variables for an OnShape part."""
self._configuration.update(dict)
self._measurements.update() | python | def params(self, dict):
"""Set configuration variables for an OnShape part."""
self._configuration.update(dict)
self._measurements.update() | [
"def",
"params",
"(",
"self",
",",
"dict",
")",
":",
"self",
".",
"_configuration",
".",
"update",
"(",
"dict",
")",
"self",
".",
"_measurements",
".",
"update",
"(",
")"
] | Set configuration variables for an OnShape part. | [
"Set",
"configuration",
"variables",
"for",
"an",
"OnShape",
"part",
"."
] | 61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df | https://github.com/ethan92429/onshapepy/blob/61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df/onshapepy/part.py#L52-L55 | train | Set the configuration variables for an OnShape part. |
ethan92429/onshapepy | onshapepy/part.py | Configuration.update | def update(self, params=None, client=c):
"""Push params to OnShape and synchronize the local copy
"""
uri = self.parent.uri
if not params or not self.res:
self.get_params()
return
d = self.payload
for k, v in params.items():
m = d["curr... | python | def update(self, params=None, client=c):
"""Push params to OnShape and synchronize the local copy
"""
uri = self.parent.uri
if not params or not self.res:
self.get_params()
return
d = self.payload
for k, v in params.items():
m = d["curr... | [
"def",
"update",
"(",
"self",
",",
"params",
"=",
"None",
",",
"client",
"=",
"c",
")",
":",
"uri",
"=",
"self",
".",
"parent",
".",
"uri",
"if",
"not",
"params",
"or",
"not",
"self",
".",
"res",
":",
"self",
".",
"get_params",
"(",
")",
"return"... | Push params to OnShape and synchronize the local copy | [
"Push",
"params",
"to",
"OnShape",
"and",
"synchronize",
"the",
"local",
"copy"
] | 61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df | https://github.com/ethan92429/onshapepy/blob/61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df/onshapepy/part.py#L72-L94 | train | Push params to OnShape and synchronize the local copy |
ethan92429/onshapepy | onshapepy/part.py | Configuration.get_params | def get_params(self):
"""Manually pull params defined in config from OnShape and return a python representation of the params.
Quantities are converted to pint quantities, Bools are converted to python bools and Enums are converted
to strings. Note that Enum names are autogenerated by OnShape an... | python | def get_params(self):
"""Manually pull params defined in config from OnShape and return a python representation of the params.
Quantities are converted to pint quantities, Bools are converted to python bools and Enums are converted
to strings. Note that Enum names are autogenerated by OnShape an... | [
"def",
"get_params",
"(",
"self",
")",
":",
"self",
".",
"res",
"=",
"c",
".",
"get_configuration",
"(",
"self",
".",
"parent",
".",
"uri",
".",
"as_dict",
"(",
")",
")"
] | Manually pull params defined in config from OnShape and return a python representation of the params.
Quantities are converted to pint quantities, Bools are converted to python bools and Enums are converted
to strings. Note that Enum names are autogenerated by OnShape and do not match the name on the On... | [
"Manually",
"pull",
"params",
"defined",
"in",
"config",
"from",
"OnShape",
"and",
"return",
"a",
"python",
"representation",
"of",
"the",
"params",
".",
"Quantities",
"are",
"converted",
"to",
"pint",
"quantities",
"Bools",
"are",
"converted",
"to",
"python",
... | 61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df | https://github.com/ethan92429/onshapepy/blob/61dc7ccbdc6095fa6cc3b4a414e2f72d03d1c9df/onshapepy/part.py#L96-L100 | train | Manually pull params defined in config from OnShape and return a python representation of the params. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.