repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
MonashBI/arcana | arcana/processor/base.py | Processor._to_process | def _to_process(self, pipeline, required_outputs, prqs_to_process_array,
to_skip_array, filter_array, subject_inds, visit_inds,
force):
"""
Check whether the outputs of the pipeline are present in all sessions
in the project repository and were generated w... | python | def _to_process(self, pipeline, required_outputs, prqs_to_process_array,
to_skip_array, filter_array, subject_inds, visit_inds,
force):
"""
Check whether the outputs of the pipeline are present in all sessions
in the project repository and were generated w... | [
"def",
"_to_process",
"(",
"self",
",",
"pipeline",
",",
"required_outputs",
",",
"prqs_to_process_array",
",",
"to_skip_array",
",",
"filter_array",
",",
"subject_inds",
",",
"visit_inds",
",",
"force",
")",
":",
"# Reference the study tree in local variable for convenie... | Check whether the outputs of the pipeline are present in all sessions
in the project repository and were generated with matching provenance.
Return an 2D boolean array (subjects: rows, visits: cols) with the
sessions to process marked True.
Parameters
----------
pipeline... | [
"Check",
"whether",
"the",
"outputs",
"of",
"the",
"pipeline",
"are",
"present",
"in",
"all",
"sessions",
"in",
"the",
"project",
"repository",
"and",
"were",
"generated",
"with",
"matching",
"provenance",
".",
"Return",
"an",
"2D",
"boolean",
"array",
"(",
... | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/processor/base.py#L660-L933 |
MonashBI/arcana | arcana/processor/base.py | Processor._dialate_array | def _dialate_array(self, array, iterators):
"""
'Dialates' a to_process/to_protect array to include all subject and/or
visits if the pipeline contains any joins over the corresponding
iterators.
Parameters
----------
array : np.array[M, N]
The array t... | python | def _dialate_array(self, array, iterators):
"""
'Dialates' a to_process/to_protect array to include all subject and/or
visits if the pipeline contains any joins over the corresponding
iterators.
Parameters
----------
array : np.array[M, N]
The array t... | [
"def",
"_dialate_array",
"(",
"self",
",",
"array",
",",
"iterators",
")",
":",
"if",
"not",
"iterators",
":",
"return",
"array",
"dialated",
"=",
"np",
".",
"copy",
"(",
"array",
")",
"if",
"self",
".",
"study",
".",
"SUBJECT_ID",
"in",
"iterators",
"... | 'Dialates' a to_process/to_protect array to include all subject and/or
visits if the pipeline contains any joins over the corresponding
iterators.
Parameters
----------
array : np.array[M, N]
The array to potentially dialate
iterators : set[str]
T... | [
"Dialates",
"a",
"to_process",
"/",
"to_protect",
"array",
"to",
"include",
"all",
"subject",
"and",
"/",
"or",
"visits",
"if",
"the",
"pipeline",
"contains",
"any",
"joins",
"over",
"the",
"corresponding",
"iterators",
"."
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/processor/base.py#L935-L964 |
MonashBI/arcana | arcana/processor/slurm.py | ArcanaSlurmGraphPlugin._get_args | def _get_args(self, node, keywords):
"""
Intercept calls to get template and return our own node-specific
template
"""
args = super(ArcanaSlurmGraphPlugin, self)._get_args(
node, keywords)
# Substitute the template arg with the node-specific one
new_ar... | python | def _get_args(self, node, keywords):
"""
Intercept calls to get template and return our own node-specific
template
"""
args = super(ArcanaSlurmGraphPlugin, self)._get_args(
node, keywords)
# Substitute the template arg with the node-specific one
new_ar... | [
"def",
"_get_args",
"(",
"self",
",",
"node",
",",
"keywords",
")",
":",
"args",
"=",
"super",
"(",
"ArcanaSlurmGraphPlugin",
",",
"self",
")",
".",
"_get_args",
"(",
"node",
",",
"keywords",
")",
"# Substitute the template arg with the node-specific one",
"new_ar... | Intercept calls to get template and return our own node-specific
template | [
"Intercept",
"calls",
"to",
"get",
"template",
"and",
"return",
"our",
"own",
"node",
"-",
"specific",
"template"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/processor/slurm.py#L16-L30 |
MonashBI/arcana | arcana/processor/slurm.py | SlurmProc.wall_time_str | def wall_time_str(self, wall_time):
"""
Returns the wall time in the format required for the sbatch script
"""
days = int(wall_time // 1440)
hours = int((wall_time - days * 1440) // 60)
minutes = int(math.floor(wall_time - days * 1440 - hours * 60))
seconds = int(... | python | def wall_time_str(self, wall_time):
"""
Returns the wall time in the format required for the sbatch script
"""
days = int(wall_time // 1440)
hours = int((wall_time - days * 1440) // 60)
minutes = int(math.floor(wall_time - days * 1440 - hours * 60))
seconds = int(... | [
"def",
"wall_time_str",
"(",
"self",
",",
"wall_time",
")",
":",
"days",
"=",
"int",
"(",
"wall_time",
"//",
"1440",
")",
"hours",
"=",
"int",
"(",
"(",
"wall_time",
"-",
"days",
"*",
"1440",
")",
"//",
"60",
")",
"minutes",
"=",
"int",
"(",
"math"... | Returns the wall time in the format required for the sbatch script | [
"Returns",
"the",
"wall",
"time",
"in",
"the",
"format",
"required",
"for",
"the",
"sbatch",
"script"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/processor/slurm.py#L139-L147 |
gwww/elkm1 | elkm1_lib/panel.py | Panel.sync | def sync(self):
"""Retrieve panel information from ElkM1"""
self._elk.add_handler('VN', self._vn_handler)
self._elk.add_handler('XK', self._xk_handler)
self._elk.add_handler('RP', self._rp_handler)
self._elk.add_handler('IE', self._elk.call_sync_handlers)
self._elk.add_ha... | python | def sync(self):
"""Retrieve panel information from ElkM1"""
self._elk.add_handler('VN', self._vn_handler)
self._elk.add_handler('XK', self._xk_handler)
self._elk.add_handler('RP', self._rp_handler)
self._elk.add_handler('IE', self._elk.call_sync_handlers)
self._elk.add_ha... | [
"def",
"sync",
"(",
"self",
")",
":",
"self",
".",
"_elk",
".",
"add_handler",
"(",
"'VN'",
",",
"self",
".",
"_vn_handler",
")",
"self",
".",
"_elk",
".",
"add_handler",
"(",
"'XK'",
",",
"self",
".",
"_xk_handler",
")",
"self",
".",
"_elk",
".",
... | Retrieve panel information from ElkM1 | [
"Retrieve",
"panel",
"information",
"from",
"ElkM1"
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/panel.py#L19-L28 |
gwww/elkm1 | elkm1_lib/thermostats.py | Thermostat.set | def set(self, element_to_set, value):
"""(Helper) Set thermostat"""
self._elk.send(ts_encode(self.index, value, element_to_set)) | python | def set(self, element_to_set, value):
"""(Helper) Set thermostat"""
self._elk.send(ts_encode(self.index, value, element_to_set)) | [
"def",
"set",
"(",
"self",
",",
"element_to_set",
",",
"value",
")",
":",
"self",
".",
"_elk",
".",
"send",
"(",
"ts_encode",
"(",
"self",
".",
"index",
",",
"value",
",",
"element_to_set",
")",
")"
] | (Helper) Set thermostat | [
"(",
"Helper",
")",
"Set",
"thermostat"
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/thermostats.py#L19-L21 |
MonashBI/arcana | arcana/data/base.py | BaseData.renamed | def renamed(self, name):
"""
Duplicate the datum and rename it
"""
duplicate = copy(self)
duplicate._name = name
return duplicate | python | def renamed(self, name):
"""
Duplicate the datum and rename it
"""
duplicate = copy(self)
duplicate._name = name
return duplicate | [
"def",
"renamed",
"(",
"self",
",",
"name",
")",
":",
"duplicate",
"=",
"copy",
"(",
"self",
")",
"duplicate",
".",
"_name",
"=",
"name",
"return",
"duplicate"
] | Duplicate the datum and rename it | [
"Duplicate",
"the",
"datum",
"and",
"rename",
"it"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/data/base.py#L72-L78 |
MonashBI/arcana | arcana/environment/requirement/base.py | Version.compare | def compare(self, other):
"""
Compares the version with another
Parameters
----------
other : Version
The version to compare to
"""
if self._req != other._req:
raise ArcanaUsageError(
"Can't compare versions of different re... | python | def compare(self, other):
"""
Compares the version with another
Parameters
----------
other : Version
The version to compare to
"""
if self._req != other._req:
raise ArcanaUsageError(
"Can't compare versions of different re... | [
"def",
"compare",
"(",
"self",
",",
"other",
")",
":",
"if",
"self",
".",
"_req",
"!=",
"other",
".",
"_req",
":",
"raise",
"ArcanaUsageError",
"(",
"\"Can't compare versions of different requirements {} and {}\"",
".",
"format",
"(",
"self",
".",
"_req",
",",
... | Compares the version with another
Parameters
----------
other : Version
The version to compare to | [
"Compares",
"the",
"version",
"with",
"another"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/environment/requirement/base.py#L108-L151 |
MonashBI/arcana | arcana/environment/requirement/base.py | Version.parse | def parse(self, version):
"""
Splits a typical version string (e.g. <MAJOR>.<MINOR>.<MICRO>)
into a tuple that can be sorted properly. Ignores all leading
and trailing characters by using a regex search (instead of match) so
as to pick the version string out of a block of text.
... | python | def parse(self, version):
"""
Splits a typical version string (e.g. <MAJOR>.<MINOR>.<MICRO>)
into a tuple that can be sorted properly. Ignores all leading
and trailing characters by using a regex search (instead of match) so
as to pick the version string out of a block of text.
... | [
"def",
"parse",
"(",
"self",
",",
"version",
")",
":",
"# Check to see if version is not a string but rather another type",
"# that can be interpreted as a version",
"if",
"isinstance",
"(",
"version",
",",
"int",
")",
":",
"return",
"(",
"version",
",",
")",
",",
"No... | Splits a typical version string (e.g. <MAJOR>.<MINOR>.<MICRO>)
into a tuple that can be sorted properly. Ignores all leading
and trailing characters by using a regex search (instead of match) so
as to pick the version string out of a block of text.
Parameters
----------
... | [
"Splits",
"a",
"typical",
"version",
"string",
"(",
"e",
".",
"g",
".",
"<MAJOR",
">",
".",
"<MINOR",
">",
".",
"<MICRO",
">",
")",
"into",
"a",
"tuple",
"that",
"can",
"be",
"sorted",
"properly",
".",
"Ignores",
"all",
"leading",
"and",
"trailing",
... | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/environment/requirement/base.py#L175-L265 |
MonashBI/arcana | arcana/environment/requirement/base.py | Version.within | def within(self, version):
"""
A single version can also be interpreted as an open range (i.e. no
maximum version)
"""
if not isinstance(version, Version):
version = type(self._min_ver)(self._req, version)
return version >= self | python | def within(self, version):
"""
A single version can also be interpreted as an open range (i.e. no
maximum version)
"""
if not isinstance(version, Version):
version = type(self._min_ver)(self._req, version)
return version >= self | [
"def",
"within",
"(",
"self",
",",
"version",
")",
":",
"if",
"not",
"isinstance",
"(",
"version",
",",
"Version",
")",
":",
"version",
"=",
"type",
"(",
"self",
".",
"_min_ver",
")",
"(",
"self",
".",
"_req",
",",
"version",
")",
"return",
"version"... | A single version can also be interpreted as an open range (i.e. no
maximum version) | [
"A",
"single",
"version",
"can",
"also",
"be",
"interpreted",
"as",
"an",
"open",
"range",
"(",
"i",
".",
"e",
".",
"no",
"maximum",
"version",
")"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/environment/requirement/base.py#L267-L274 |
MonashBI/arcana | arcana/environment/requirement/base.py | BaseRequirement.v | def v(self, version, max_version=None, **kwargs):
"""
Returns either a single requirement version or a requirement version
range depending on whether two arguments are supplied or one
Parameters
----------
version : str | Version
Either a version of the requi... | python | def v(self, version, max_version=None, **kwargs):
"""
Returns either a single requirement version or a requirement version
range depending on whether two arguments are supplied or one
Parameters
----------
version : str | Version
Either a version of the requi... | [
"def",
"v",
"(",
"self",
",",
"version",
",",
"max_version",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"version",
",",
"Version",
")",
":",
"version",
"=",
"self",
".",
"version_cls",
"(",
"self",
",",
"version",... | Returns either a single requirement version or a requirement version
range depending on whether two arguments are supplied or one
Parameters
----------
version : str | Version
Either a version of the requirement, or the first version in a
range of acceptable vers... | [
"Returns",
"either",
"a",
"single",
"requirement",
"version",
"or",
"a",
"requirement",
"version",
"range",
"depending",
"on",
"whether",
"two",
"arguments",
"are",
"supplied",
"or",
"one"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/environment/requirement/base.py#L393-L411 |
vedvyas/doxytag2zealdb | doxytag2zealdb/zealdb.py | ZealDB.open | def open(self):
'''Open a connection to the database.
If a connection appears to be open already, transactions are committed
and it is closed before proceeding. After establishing the connection,
the searchIndex table is prepared (and dropped if it already exists).
'''
i... | python | def open(self):
'''Open a connection to the database.
If a connection appears to be open already, transactions are committed
and it is closed before proceeding. After establishing the connection,
the searchIndex table is prepared (and dropped if it already exists).
'''
i... | [
"def",
"open",
"(",
"self",
")",
":",
"if",
"self",
".",
"conn",
"is",
"not",
"None",
":",
"self",
".",
"close",
"(",
")",
"self",
".",
"conn",
"=",
"sqlite3",
".",
"connect",
"(",
"self",
".",
"filename",
")",
"self",
".",
"cursor",
"=",
"self",... | Open a connection to the database.
If a connection appears to be open already, transactions are committed
and it is closed before proceeding. After establishing the connection,
the searchIndex table is prepared (and dropped if it already exists). | [
"Open",
"a",
"connection",
"to",
"the",
"database",
"."
] | train | https://github.com/vedvyas/doxytag2zealdb/blob/8b07a88af6794248f8cfdabb0fda9dd61c777127/doxytag2zealdb/zealdb.py#L77-L105 |
vedvyas/doxytag2zealdb | doxytag2zealdb/zealdb.py | ZealDB.insert | def insert(self, name, entry_type, filename):
'''Insert an entry into the Zeal database.
Args:
name: A string representing the name of the entry.
entry_type: A string representing the entry type.
filename: A string representing the filename of the documentation
... | python | def insert(self, name, entry_type, filename):
'''Insert an entry into the Zeal database.
Args:
name: A string representing the name of the entry.
entry_type: A string representing the entry type.
filename: A string representing the filename of the documentation
... | [
"def",
"insert",
"(",
"self",
",",
"name",
",",
"entry_type",
",",
"filename",
")",
":",
"if",
"self",
".",
"cursor",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"'Open DB connection before attempting to call insert!'",
")",
"db_entry",
"=",
"(",
"name",
... | Insert an entry into the Zeal database.
Args:
name: A string representing the name of the entry.
entry_type: A string representing the entry type.
filename: A string representing the filename of the documentation
for the entry.
Raises:
Ru... | [
"Insert",
"an",
"entry",
"into",
"the",
"Zeal",
"database",
"."
] | train | https://github.com/vedvyas/doxytag2zealdb/blob/8b07a88af6794248f8cfdabb0fda9dd61c777127/doxytag2zealdb/zealdb.py#L131-L155 |
erikvw/django-collect-offline | django_collect_offline/transaction/serialize.py | serialize | def serialize(objects=None):
"""A simple wrapper of Django's serializer with defaults
for JSON and natural keys.
Note: use_natural_primary_keys is False as once
a pk is set, it should not be changed throughout the
distributed data.
"""
return serializers.serialize(
"json",
... | python | def serialize(objects=None):
"""A simple wrapper of Django's serializer with defaults
for JSON and natural keys.
Note: use_natural_primary_keys is False as once
a pk is set, it should not be changed throughout the
distributed data.
"""
return serializers.serialize(
"json",
... | [
"def",
"serialize",
"(",
"objects",
"=",
"None",
")",
":",
"return",
"serializers",
".",
"serialize",
"(",
"\"json\"",
",",
"objects",
",",
"ensure_ascii",
"=",
"True",
",",
"use_natural_foreign_keys",
"=",
"True",
",",
"use_natural_primary_keys",
"=",
"False",
... | A simple wrapper of Django's serializer with defaults
for JSON and natural keys.
Note: use_natural_primary_keys is False as once
a pk is set, it should not be changed throughout the
distributed data. | [
"A",
"simple",
"wrapper",
"of",
"Django",
"s",
"serializer",
"with",
"defaults",
"for",
"JSON",
"and",
"natural",
"keys",
"."
] | train | https://github.com/erikvw/django-collect-offline/blob/3d5efd66c68e2db4b060a82b070ae490dc399ca7/django_collect_offline/transaction/serialize.py#L4-L19 |
MonashBI/arcana | arcana/study/base.py | Study.data | def data(self, name, subject_ids=None, visit_ids=None, session_ids=None,
**kwargs):
"""
Returns the Fileset(s) or Field(s) associated with the provided spec
name(s), generating derived filesets as required. Multiple names in a
list can be provided, to allow their workflows t... | python | def data(self, name, subject_ids=None, visit_ids=None, session_ids=None,
**kwargs):
"""
Returns the Fileset(s) or Field(s) associated with the provided spec
name(s), generating derived filesets as required. Multiple names in a
list can be provided, to allow their workflows t... | [
"def",
"data",
"(",
"self",
",",
"name",
",",
"subject_ids",
"=",
"None",
",",
"visit_ids",
"=",
"None",
",",
"session_ids",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"name",
",",
"basestring",
")",
":",
"single_name",
... | Returns the Fileset(s) or Field(s) associated with the provided spec
name(s), generating derived filesets as required. Multiple names in a
list can be provided, to allow their workflows to be combined into a
single workflow.
Parameters
----------
name : str | List[str]
... | [
"Returns",
"the",
"Fileset",
"(",
"s",
")",
"or",
"Field",
"(",
"s",
")",
"associated",
"with",
"the",
"provided",
"spec",
"name",
"(",
"s",
")",
"generating",
"derived",
"filesets",
"as",
"required",
".",
"Multiple",
"names",
"in",
"a",
"list",
"can",
... | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/study/base.py#L244-L376 |
MonashBI/arcana | arcana/study/base.py | Study.branch | def branch(self, name, values=None): # @UnusedVariable @IgnorePep8
"""
Checks whether the given switch matches the value provided
Parameters
----------
name : str
The name of the parameter to retrieve
value : str | None
The value(s) of the switch... | python | def branch(self, name, values=None): # @UnusedVariable @IgnorePep8
"""
Checks whether the given switch matches the value provided
Parameters
----------
name : str
The name of the parameter to retrieve
value : str | None
The value(s) of the switch... | [
"def",
"branch",
"(",
"self",
",",
"name",
",",
"values",
"=",
"None",
")",
":",
"# @UnusedVariable @IgnorePep8",
"if",
"isinstance",
"(",
"values",
",",
"basestring",
")",
":",
"values",
"=",
"[",
"values",
"]",
"spec",
"=",
"self",
".",
"parameter_spec",... | Checks whether the given switch matches the value provided
Parameters
----------
name : str
The name of the parameter to retrieve
value : str | None
The value(s) of the switch to match if a non-boolean switch | [
"Checks",
"whether",
"the",
"given",
"switch",
"matches",
"the",
"value",
"provided"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/study/base.py#L593-L634 |
MonashBI/arcana | arcana/study/base.py | Study.unhandled_branch | def unhandled_branch(self, name):
"""
Convenient method for raising exception if a pipeline doesn't
handle a particular switch value
Parameters
----------
name : str
Name of the switch
value : str
Value of the switch which hasn't been hand... | python | def unhandled_branch(self, name):
"""
Convenient method for raising exception if a pipeline doesn't
handle a particular switch value
Parameters
----------
name : str
Name of the switch
value : str
Value of the switch which hasn't been hand... | [
"def",
"unhandled_branch",
"(",
"self",
",",
"name",
")",
":",
"raise",
"ArcanaDesignError",
"(",
"\"'{}' value of '{}' switch in {} is not handled\"",
".",
"format",
"(",
"self",
".",
"_get_parameter",
"(",
"name",
")",
",",
"name",
",",
"self",
".",
"_param_erro... | Convenient method for raising exception if a pipeline doesn't
handle a particular switch value
Parameters
----------
name : str
Name of the switch
value : str
Value of the switch which hasn't been handled | [
"Convenient",
"method",
"for",
"raising",
"exception",
"if",
"a",
"pipeline",
"doesn",
"t",
"handle",
"a",
"particular",
"switch",
"value"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/study/base.py#L636-L651 |
MonashBI/arcana | arcana/study/base.py | Study.save_workflow_graph_for | def save_workflow_graph_for(self, spec_name, fname, full=False,
style='flat', **kwargs):
"""
Saves a graph of the workflow to generate the requested spec_name
Parameters
----------
spec_name : str
Name of the spec to generate the graph... | python | def save_workflow_graph_for(self, spec_name, fname, full=False,
style='flat', **kwargs):
"""
Saves a graph of the workflow to generate the requested spec_name
Parameters
----------
spec_name : str
Name of the spec to generate the graph... | [
"def",
"save_workflow_graph_for",
"(",
"self",
",",
"spec_name",
",",
"fname",
",",
"full",
"=",
"False",
",",
"style",
"=",
"'flat'",
",",
"*",
"*",
"kwargs",
")",
":",
"pipeline",
"=",
"self",
".",
"spec",
"(",
"spec_name",
")",
".",
"pipeline",
"if"... | Saves a graph of the workflow to generate the requested spec_name
Parameters
----------
spec_name : str
Name of the spec to generate the graph for
fname : str
The filename for the saved graph
style : str
The style of the graph, can be one of c... | [
"Saves",
"a",
"graph",
"of",
"the",
"workflow",
"to",
"generate",
"the",
"requested",
"spec_name"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/study/base.py#L669-L697 |
MonashBI/arcana | arcana/study/base.py | Study.spec | def spec(self, name):
"""
Returns either the input corresponding to a fileset or field
field spec or a spec or parameter that has either
been passed to the study as an input or can be derived.
Parameters
----------
name : Str | BaseData | Parameter
A ... | python | def spec(self, name):
"""
Returns either the input corresponding to a fileset or field
field spec or a spec or parameter that has either
been passed to the study as an input or can be derived.
Parameters
----------
name : Str | BaseData | Parameter
A ... | [
"def",
"spec",
"(",
"self",
",",
"name",
")",
":",
"# If the provided \"name\" is actually a data item or parameter then",
"# replace it with its name.",
"if",
"isinstance",
"(",
"name",
",",
"(",
"BaseData",
",",
"Parameter",
")",
")",
":",
"name",
"=",
"name",
"."... | Returns either the input corresponding to a fileset or field
field spec or a spec or parameter that has either
been passed to the study as an input or can be derived.
Parameters
----------
name : Str | BaseData | Parameter
A parameter, fileset or field or name of one | [
"Returns",
"either",
"the",
"input",
"corresponding",
"to",
"a",
"fileset",
"or",
"field",
"field",
"spec",
"or",
"a",
"spec",
"or",
"parameter",
"that",
"has",
"either",
"been",
"passed",
"to",
"the",
"study",
"as",
"an",
"input",
"or",
"can",
"be",
"de... | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/study/base.py#L699-L718 |
MonashBI/arcana | arcana/study/base.py | Study.bound_spec | def bound_spec(self, name):
"""
Returns an input selector or derived spec bound to the study, i.e.
where the repository tree is checked for existing outputs
Parameters
----------
name : Str
A name of a fileset or field
"""
# If the provided "n... | python | def bound_spec(self, name):
"""
Returns an input selector or derived spec bound to the study, i.e.
where the repository tree is checked for existing outputs
Parameters
----------
name : Str
A name of a fileset or field
"""
# If the provided "n... | [
"def",
"bound_spec",
"(",
"self",
",",
"name",
")",
":",
"# If the provided \"name\" is actually a data item or parameter then",
"# replace it with its name.",
"if",
"isinstance",
"(",
"name",
",",
"BaseData",
")",
":",
"name",
"=",
"name",
".",
"name",
"# Get the spec ... | Returns an input selector or derived spec bound to the study, i.e.
where the repository tree is checked for existing outputs
Parameters
----------
name : Str
A name of a fileset or field | [
"Returns",
"an",
"input",
"selector",
"or",
"derived",
"spec",
"bound",
"to",
"the",
"study",
"i",
".",
"e",
".",
"where",
"the",
"repository",
"tree",
"is",
"checked",
"for",
"existing",
"outputs"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/study/base.py#L720-L749 |
MonashBI/arcana | arcana/study/base.py | Study.data_spec | def data_spec(cls, name):
"""
Return the fileset_spec, i.e. the template of the fileset expected to
be supplied or generated corresponding to the fileset_spec name.
Parameters
----------
name : Str
Name of the fileset_spec to return
"""
# If t... | python | def data_spec(cls, name):
"""
Return the fileset_spec, i.e. the template of the fileset expected to
be supplied or generated corresponding to the fileset_spec name.
Parameters
----------
name : Str
Name of the fileset_spec to return
"""
# If t... | [
"def",
"data_spec",
"(",
"cls",
",",
"name",
")",
":",
"# If the provided \"name\" is actually a data item or parameter then",
"# replace it with its name.",
"if",
"isinstance",
"(",
"name",
",",
"BaseData",
")",
":",
"name",
"=",
"name",
".",
"name",
"try",
":",
"r... | Return the fileset_spec, i.e. the template of the fileset expected to
be supplied or generated corresponding to the fileset_spec name.
Parameters
----------
name : Str
Name of the fileset_spec to return | [
"Return",
"the",
"fileset_spec",
"i",
".",
"e",
".",
"the",
"template",
"of",
"the",
"fileset",
"expected",
"to",
"be",
"supplied",
"or",
"generated",
"corresponding",
"to",
"the",
"fileset_spec",
"name",
"."
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/study/base.py#L752-L773 |
MonashBI/arcana | arcana/study/base.py | Study.cache_inputs | def cache_inputs(self):
"""
Runs the Study's repository source node for each of the inputs
of the study, thereby caching any data required from remote
repositorys. Useful when launching many parallel jobs that will
all try to concurrently access the remote repository, and probabl... | python | def cache_inputs(self):
"""
Runs the Study's repository source node for each of the inputs
of the study, thereby caching any data required from remote
repositorys. Useful when launching many parallel jobs that will
all try to concurrently access the remote repository, and probabl... | [
"def",
"cache_inputs",
"(",
"self",
")",
":",
"workflow",
"=",
"pe",
".",
"Workflow",
"(",
"name",
"=",
"'cache_download'",
",",
"base_dir",
"=",
"self",
".",
"processor",
".",
"work_dir",
")",
"subjects",
"=",
"pe",
".",
"Node",
"(",
"IdentityInterface",
... | Runs the Study's repository source node for each of the inputs
of the study, thereby caching any data required from remote
repositorys. Useful when launching many parallel jobs that will
all try to concurrently access the remote repository, and probably
lead to timeout errors. | [
"Runs",
"the",
"Study",
"s",
"repository",
"source",
"node",
"for",
"each",
"of",
"the",
"inputs",
"of",
"the",
"study",
"thereby",
"caching",
"any",
"data",
"required",
"from",
"remote",
"repositorys",
".",
"Useful",
"when",
"launching",
"many",
"parallel",
... | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/study/base.py#L837-L858 |
MonashBI/arcana | arcana/study/base.py | Study.provided | def provided(self, spec_name, default_okay=True):
"""
Checks to see whether the corresponding data spec was provided an
explicit input, as opposed to derivatives or missing optional inputs
Parameters
----------
spec_name : str
Name of a data spec
"""
... | python | def provided(self, spec_name, default_okay=True):
"""
Checks to see whether the corresponding data spec was provided an
explicit input, as opposed to derivatives or missing optional inputs
Parameters
----------
spec_name : str
Name of a data spec
"""
... | [
"def",
"provided",
"(",
"self",
",",
"spec_name",
",",
"default_okay",
"=",
"True",
")",
":",
"try",
":",
"spec",
"=",
"self",
".",
"bound_spec",
"(",
"spec_name",
")",
"except",
"ArcanaMissingDataException",
":",
"return",
"False",
"if",
"isinstance",
"(",
... | Checks to see whether the corresponding data spec was provided an
explicit input, as opposed to derivatives or missing optional inputs
Parameters
----------
spec_name : str
Name of a data spec | [
"Checks",
"to",
"see",
"whether",
"the",
"corresponding",
"data",
"spec",
"was",
"provided",
"an",
"explicit",
"input",
"as",
"opposed",
"to",
"derivatives",
"or",
"missing",
"optional",
"inputs"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/study/base.py#L869-L886 |
MonashBI/arcana | arcana/study/base.py | Study.freq_from_iterators | def freq_from_iterators(cls, iterators):
"""
Returns the frequency corresponding to the given iterators
"""
return {
set(it): f for f, it in cls.FREQUENCIES.items()}[set(iterators)] | python | def freq_from_iterators(cls, iterators):
"""
Returns the frequency corresponding to the given iterators
"""
return {
set(it): f for f, it in cls.FREQUENCIES.items()}[set(iterators)] | [
"def",
"freq_from_iterators",
"(",
"cls",
",",
"iterators",
")",
":",
"return",
"{",
"set",
"(",
"it",
")",
":",
"f",
"for",
"f",
",",
"it",
"in",
"cls",
".",
"FREQUENCIES",
".",
"items",
"(",
")",
"}",
"[",
"set",
"(",
"iterators",
")",
"]"
] | Returns the frequency corresponding to the given iterators | [
"Returns",
"the",
"frequency",
"corresponding",
"to",
"the",
"given",
"iterators"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/study/base.py#L889-L894 |
MonashBI/arcana | arcana/study/base.py | Study.prov | def prov(self):
"""
Extracts provenance information from the study for storage alongside
generated derivatives. Typically for reference purposes only as only
the pipeline workflow, inputs and outputs are checked by default when
determining which sessions require reprocessing.
... | python | def prov(self):
"""
Extracts provenance information from the study for storage alongside
generated derivatives. Typically for reference purposes only as only
the pipeline workflow, inputs and outputs are checked by default when
determining which sessions require reprocessing.
... | [
"def",
"prov",
"(",
"self",
")",
":",
"# Get list of repositories where inputs to the study are stored",
"input_repos",
"=",
"list",
"(",
"set",
"(",
"(",
"i",
".",
"repository",
"for",
"i",
"in",
"self",
".",
"inputs",
")",
")",
")",
"inputs",
"=",
"{",
"}"... | Extracts provenance information from the study for storage alongside
generated derivatives. Typically for reference purposes only as only
the pipeline workflow, inputs and outputs are checked by default when
determining which sessions require reprocessing.
Returns
-------
... | [
"Extracts",
"provenance",
"information",
"from",
"the",
"study",
"for",
"storage",
"alongside",
"generated",
"derivatives",
".",
"Typically",
"for",
"reference",
"purposes",
"only",
"as",
"only",
"the",
"pipeline",
"workflow",
"inputs",
"and",
"outputs",
"are",
"c... | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/study/base.py#L897-L939 |
gwww/elkm1 | elkm1_lib/areas.py | Area.arm | def arm(self, level, code):
"""(Helper) Arm system at specified level (away, vacation, etc)"""
self._elk.send(al_encode(level, self._index, code)) | python | def arm(self, level, code):
"""(Helper) Arm system at specified level (away, vacation, etc)"""
self._elk.send(al_encode(level, self._index, code)) | [
"def",
"arm",
"(",
"self",
",",
"level",
",",
"code",
")",
":",
"self",
".",
"_elk",
".",
"send",
"(",
"al_encode",
"(",
"level",
",",
"self",
".",
"_index",
",",
"code",
")",
")"
] | (Helper) Arm system at specified level (away, vacation, etc) | [
"(",
"Helper",
")",
"Arm",
"system",
"at",
"specified",
"level",
"(",
"away",
"vacation",
"etc",
")"
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/areas.py#L20-L22 |
gwww/elkm1 | elkm1_lib/areas.py | Area.display_message | def display_message(self, clear, beep, timeout, line1, line2):
"""Display a message on all of the keypads in this area."""
self._elk.send(
dm_encode(self._index, clear, beep, timeout, line1, line2)
) | python | def display_message(self, clear, beep, timeout, line1, line2):
"""Display a message on all of the keypads in this area."""
self._elk.send(
dm_encode(self._index, clear, beep, timeout, line1, line2)
) | [
"def",
"display_message",
"(",
"self",
",",
"clear",
",",
"beep",
",",
"timeout",
",",
"line1",
",",
"line2",
")",
":",
"self",
".",
"_elk",
".",
"send",
"(",
"dm_encode",
"(",
"self",
".",
"_index",
",",
"clear",
",",
"beep",
",",
"timeout",
",",
... | Display a message on all of the keypads in this area. | [
"Display",
"a",
"message",
"on",
"all",
"of",
"the",
"keypads",
"in",
"this",
"area",
"."
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/areas.py#L28-L32 |
gwww/elkm1 | elkm1_lib/areas.py | Areas.sync | def sync(self):
"""Retrieve areas from ElkM1"""
self.elk.send(as_encode())
self.get_descriptions(TextDescriptions.AREA.value) | python | def sync(self):
"""Retrieve areas from ElkM1"""
self.elk.send(as_encode())
self.get_descriptions(TextDescriptions.AREA.value) | [
"def",
"sync",
"(",
"self",
")",
":",
"self",
".",
"elk",
".",
"send",
"(",
"as_encode",
"(",
")",
")",
"self",
".",
"get_descriptions",
"(",
"TextDescriptions",
".",
"AREA",
".",
"value",
")"
] | Retrieve areas from ElkM1 | [
"Retrieve",
"areas",
"from",
"ElkM1"
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/areas.py#L43-L46 |
gwww/elkm1 | elkm1_lib/lights.py | Light.level | def level(self, level, time=0):
"""(Helper) Set light to specified level"""
if level <= 0:
self._elk.send(pf_encode(self._index))
elif level >= 98:
self._elk.send(pn_encode(self._index))
else:
self._elk.send(pc_encode(self._index, 9, level, time)) | python | def level(self, level, time=0):
"""(Helper) Set light to specified level"""
if level <= 0:
self._elk.send(pf_encode(self._index))
elif level >= 98:
self._elk.send(pn_encode(self._index))
else:
self._elk.send(pc_encode(self._index, 9, level, time)) | [
"def",
"level",
"(",
"self",
",",
"level",
",",
"time",
"=",
"0",
")",
":",
"if",
"level",
"<=",
"0",
":",
"self",
".",
"_elk",
".",
"send",
"(",
"pf_encode",
"(",
"self",
".",
"_index",
")",
")",
"elif",
"level",
">=",
"98",
":",
"self",
".",
... | (Helper) Set light to specified level | [
"(",
"Helper",
")",
"Set",
"light",
"to",
"specified",
"level"
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/lights.py#L14-L21 |
gwww/elkm1 | elkm1_lib/lights.py | Lights.sync | def sync(self):
"""Retrieve lights from ElkM1"""
for i in range(4):
self.elk.send(ps_encode(i))
self.get_descriptions(TextDescriptions.LIGHT.value) | python | def sync(self):
"""Retrieve lights from ElkM1"""
for i in range(4):
self.elk.send(ps_encode(i))
self.get_descriptions(TextDescriptions.LIGHT.value) | [
"def",
"sync",
"(",
"self",
")",
":",
"for",
"i",
"in",
"range",
"(",
"4",
")",
":",
"self",
".",
"elk",
".",
"send",
"(",
"ps_encode",
"(",
"i",
")",
")",
"self",
".",
"get_descriptions",
"(",
"TextDescriptions",
".",
"LIGHT",
".",
"value",
")"
] | Retrieve lights from ElkM1 | [
"Retrieve",
"lights",
"from",
"ElkM1"
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/lights.py#L35-L39 |
MonashBI/arcana | arcana/utils/base.py | dir_modtime | def dir_modtime(dpath):
"""
Returns the latest modification time of all files/subdirectories in a
directory
"""
return max(os.path.getmtime(d) for d, _, _ in os.walk(dpath)) | python | def dir_modtime(dpath):
"""
Returns the latest modification time of all files/subdirectories in a
directory
"""
return max(os.path.getmtime(d) for d, _, _ in os.walk(dpath)) | [
"def",
"dir_modtime",
"(",
"dpath",
")",
":",
"return",
"max",
"(",
"os",
".",
"path",
".",
"getmtime",
"(",
"d",
")",
"for",
"d",
",",
"_",
",",
"_",
"in",
"os",
".",
"walk",
"(",
"dpath",
")",
")"
] | Returns the latest modification time of all files/subdirectories in a
directory | [
"Returns",
"the",
"latest",
"modification",
"time",
"of",
"all",
"files",
"/",
"subdirectories",
"in",
"a",
"directory"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/utils/base.py#L34-L39 |
MonashBI/arcana | arcana/utils/base.py | split_extension | def split_extension(path):
"""
A extension splitter that checks for compound extensions such as
'file.nii.gz'
Parameters
----------
filename : str
A filename to split into base and extension
Returns
-------
base : str
The base part of the string, i.e. 'file' of 'fil... | python | def split_extension(path):
"""
A extension splitter that checks for compound extensions such as
'file.nii.gz'
Parameters
----------
filename : str
A filename to split into base and extension
Returns
-------
base : str
The base part of the string, i.e. 'file' of 'fil... | [
"def",
"split_extension",
"(",
"path",
")",
":",
"for",
"double_ext",
"in",
"double_exts",
":",
"if",
"path",
".",
"endswith",
"(",
"double_ext",
")",
":",
"return",
"path",
"[",
":",
"-",
"len",
"(",
"double_ext",
")",
"]",
",",
"double_ext",
"dirname",... | A extension splitter that checks for compound extensions such as
'file.nii.gz'
Parameters
----------
filename : str
A filename to split into base and extension
Returns
-------
base : str
The base part of the string, i.e. 'file' of 'file.nii.gz'
ext : str
The ext... | [
"A",
"extension",
"splitter",
"that",
"checks",
"for",
"compound",
"extensions",
"such",
"as",
"file",
".",
"nii",
".",
"gz"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/utils/base.py#L45-L74 |
MonashBI/arcana | arcana/utils/base.py | parse_single_value | def parse_single_value(value):
"""
Tries to convert to int, float and then gives up and assumes the value
is of type string. Useful when excepting values that may be string
representations of numerical values
"""
if isinstance(value, basestring):
try:
if value.startswith('"')... | python | def parse_single_value(value):
"""
Tries to convert to int, float and then gives up and assumes the value
is of type string. Useful when excepting values that may be string
representations of numerical values
"""
if isinstance(value, basestring):
try:
if value.startswith('"')... | [
"def",
"parse_single_value",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"basestring",
")",
":",
"try",
":",
"if",
"value",
".",
"startswith",
"(",
"'\"'",
")",
"and",
"value",
".",
"endswith",
"(",
"'\"'",
")",
":",
"value",
"=",
... | Tries to convert to int, float and then gives up and assumes the value
is of type string. Useful when excepting values that may be string
representations of numerical values | [
"Tries",
"to",
"convert",
"to",
"int",
"float",
"and",
"then",
"gives",
"up",
"and",
"assumes",
"the",
"value",
"is",
"of",
"type",
"string",
".",
"Useful",
"when",
"excepting",
"values",
"that",
"may",
"be",
"string",
"representations",
"of",
"numerical",
... | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/utils/base.py#L103-L122 |
MonashBI/arcana | arcana/utils/base.py | iscontainer | def iscontainer(*items):
"""
Checks whether all the provided items are containers (i.e of class list,
dict, tuple, etc...)
"""
return all(isinstance(i, Iterable) and not isinstance(i, basestring)
for i in items) | python | def iscontainer(*items):
"""
Checks whether all the provided items are containers (i.e of class list,
dict, tuple, etc...)
"""
return all(isinstance(i, Iterable) and not isinstance(i, basestring)
for i in items) | [
"def",
"iscontainer",
"(",
"*",
"items",
")",
":",
"return",
"all",
"(",
"isinstance",
"(",
"i",
",",
"Iterable",
")",
"and",
"not",
"isinstance",
"(",
"i",
",",
"basestring",
")",
"for",
"i",
"in",
"items",
")"
] | Checks whether all the provided items are containers (i.e of class list,
dict, tuple, etc...) | [
"Checks",
"whether",
"all",
"the",
"provided",
"items",
"are",
"containers",
"(",
"i",
".",
"e",
"of",
"class",
"list",
"dict",
"tuple",
"etc",
"...",
")"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/utils/base.py#L161-L167 |
MonashBI/arcana | arcana/utils/base.py | find_mismatch | def find_mismatch(first, second, indent=''):
"""
Finds where two objects differ, iterating down into nested containers
(i.e. dicts, lists and tuples) They can be nested containers
any combination of primary dtypes, str, int, float, dict and lists
Parameters
----------
first : dict | list | ... | python | def find_mismatch(first, second, indent=''):
"""
Finds where two objects differ, iterating down into nested containers
(i.e. dicts, lists and tuples) They can be nested containers
any combination of primary dtypes, str, int, float, dict and lists
Parameters
----------
first : dict | list | ... | [
"def",
"find_mismatch",
"(",
"first",
",",
"second",
",",
"indent",
"=",
"''",
")",
":",
"# Basic case where we are dealing with non-containers",
"if",
"not",
"(",
"isinstance",
"(",
"first",
",",
"type",
"(",
"second",
")",
")",
"or",
"isinstance",
"(",
"seco... | Finds where two objects differ, iterating down into nested containers
(i.e. dicts, lists and tuples) They can be nested containers
any combination of primary dtypes, str, int, float, dict and lists
Parameters
----------
first : dict | list | tuple | str | int | float
The first object to com... | [
"Finds",
"where",
"two",
"objects",
"differ",
"iterating",
"down",
"into",
"nested",
"containers",
"(",
"i",
".",
"e",
".",
"dicts",
"lists",
"and",
"tuples",
")",
"They",
"can",
"be",
"nested",
"containers",
"any",
"combination",
"of",
"primary",
"dtypes",
... | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/utils/base.py#L170-L225 |
erikvw/django-collect-offline | django_collect_offline/transaction/deserialize.py | deserialize | def deserialize(json_text=None):
"""Returns a generator of deserialized objects.
Wraps django deserialize with defaults for JSON
and natural keys.
See https://docs.djangoproject.com/en/2.1/topics/serialization/
"""
return serializers.deserialize(
"json",
json_text,
ens... | python | def deserialize(json_text=None):
"""Returns a generator of deserialized objects.
Wraps django deserialize with defaults for JSON
and natural keys.
See https://docs.djangoproject.com/en/2.1/topics/serialization/
"""
return serializers.deserialize(
"json",
json_text,
ens... | [
"def",
"deserialize",
"(",
"json_text",
"=",
"None",
")",
":",
"return",
"serializers",
".",
"deserialize",
"(",
"\"json\"",
",",
"json_text",
",",
"ensure_ascii",
"=",
"True",
",",
"use_natural_foreign_keys",
"=",
"True",
",",
"use_natural_primary_keys",
"=",
"... | Returns a generator of deserialized objects.
Wraps django deserialize with defaults for JSON
and natural keys.
See https://docs.djangoproject.com/en/2.1/topics/serialization/ | [
"Returns",
"a",
"generator",
"of",
"deserialized",
"objects",
"."
] | train | https://github.com/erikvw/django-collect-offline/blob/3d5efd66c68e2db4b060a82b070ae490dc399ca7/django_collect_offline/transaction/deserialize.py#L4-L19 |
erikvw/django-collect-offline | django_collect_offline/signals.py | create_auth_token | def create_auth_token(sender, instance, raw, created, **kwargs):
"""Create token when a user is created (from rest_framework).
"""
if not raw:
if created:
sender.objects.create(user=instance) | python | def create_auth_token(sender, instance, raw, created, **kwargs):
"""Create token when a user is created (from rest_framework).
"""
if not raw:
if created:
sender.objects.create(user=instance) | [
"def",
"create_auth_token",
"(",
"sender",
",",
"instance",
",",
"raw",
",",
"created",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"raw",
":",
"if",
"created",
":",
"sender",
".",
"objects",
".",
"create",
"(",
"user",
"=",
"instance",
")"
] | Create token when a user is created (from rest_framework). | [
"Create",
"token",
"when",
"a",
"user",
"is",
"created",
"(",
"from",
"rest_framework",
")",
"."
] | train | https://github.com/erikvw/django-collect-offline/blob/3d5efd66c68e2db4b060a82b070ae490dc399ca7/django_collect_offline/signals.py#L10-L15 |
erikvw/django-collect-offline | django_collect_offline/signals.py | serialize_m2m_on_save | def serialize_m2m_on_save(sender, action, instance, using, **kwargs):
""" Part of the serialize transaction process that ensures m2m are
serialized correctly.
Skip those not registered.
"""
if action == "post_add":
try:
wrapped_instance = site_offline_models.get_wrapped_instance... | python | def serialize_m2m_on_save(sender, action, instance, using, **kwargs):
""" Part of the serialize transaction process that ensures m2m are
serialized correctly.
Skip those not registered.
"""
if action == "post_add":
try:
wrapped_instance = site_offline_models.get_wrapped_instance... | [
"def",
"serialize_m2m_on_save",
"(",
"sender",
",",
"action",
",",
"instance",
",",
"using",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"action",
"==",
"\"post_add\"",
":",
"try",
":",
"wrapped_instance",
"=",
"site_offline_models",
".",
"get_wrapped_instance",
... | Part of the serialize transaction process that ensures m2m are
serialized correctly.
Skip those not registered. | [
"Part",
"of",
"the",
"serialize",
"transaction",
"process",
"that",
"ensures",
"m2m",
"are",
"serialized",
"correctly",
"."
] | train | https://github.com/erikvw/django-collect-offline/blob/3d5efd66c68e2db4b060a82b070ae490dc399ca7/django_collect_offline/signals.py#L19-L31 |
erikvw/django-collect-offline | django_collect_offline/signals.py | serialize_on_save | def serialize_on_save(sender, instance, raw, created, using, **kwargs):
""" Serialize the model instance as an OutgoingTransaction.
Skip those not registered.
"""
if not raw:
if "historical" not in instance._meta.label_lower:
try:
wrapped_instance = site_offline_mode... | python | def serialize_on_save(sender, instance, raw, created, using, **kwargs):
""" Serialize the model instance as an OutgoingTransaction.
Skip those not registered.
"""
if not raw:
if "historical" not in instance._meta.label_lower:
try:
wrapped_instance = site_offline_mode... | [
"def",
"serialize_on_save",
"(",
"sender",
",",
"instance",
",",
"raw",
",",
"created",
",",
"using",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"raw",
":",
"if",
"\"historical\"",
"not",
"in",
"instance",
".",
"_meta",
".",
"label_lower",
":",
"t... | Serialize the model instance as an OutgoingTransaction.
Skip those not registered. | [
"Serialize",
"the",
"model",
"instance",
"as",
"an",
"OutgoingTransaction",
"."
] | train | https://github.com/erikvw/django-collect-offline/blob/3d5efd66c68e2db4b060a82b070ae490dc399ca7/django_collect_offline/signals.py#L35-L47 |
erikvw/django-collect-offline | django_collect_offline/signals.py | serialize_history_on_post_create | def serialize_history_on_post_create(history_instance, using, **kwargs):
""" Serialize the history instance as an OutgoingTransaction.
Skip those not registered.
"""
try:
wrapped_instance = site_offline_models.get_wrapped_instance(history_instance)
except ModelNotRegistered:
pass
... | python | def serialize_history_on_post_create(history_instance, using, **kwargs):
""" Serialize the history instance as an OutgoingTransaction.
Skip those not registered.
"""
try:
wrapped_instance = site_offline_models.get_wrapped_instance(history_instance)
except ModelNotRegistered:
pass
... | [
"def",
"serialize_history_on_post_create",
"(",
"history_instance",
",",
"using",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"wrapped_instance",
"=",
"site_offline_models",
".",
"get_wrapped_instance",
"(",
"history_instance",
")",
"except",
"ModelNotRegistered",
... | Serialize the history instance as an OutgoingTransaction.
Skip those not registered. | [
"Serialize",
"the",
"history",
"instance",
"as",
"an",
"OutgoingTransaction",
"."
] | train | https://github.com/erikvw/django-collect-offline/blob/3d5efd66c68e2db4b060a82b070ae490dc399ca7/django_collect_offline/signals.py#L55-L65 |
erikvw/django-collect-offline | django_collect_offline/signals.py | serialize_on_post_delete | def serialize_on_post_delete(sender, instance, using, **kwargs):
"""Creates a serialized OutgoingTransaction when
a model instance is deleted.
Skip those not registered.
"""
try:
wrapped_instance = site_offline_models.get_wrapped_instance(instance)
except ModelNotRegistered:
pas... | python | def serialize_on_post_delete(sender, instance, using, **kwargs):
"""Creates a serialized OutgoingTransaction when
a model instance is deleted.
Skip those not registered.
"""
try:
wrapped_instance = site_offline_models.get_wrapped_instance(instance)
except ModelNotRegistered:
pas... | [
"def",
"serialize_on_post_delete",
"(",
"sender",
",",
"instance",
",",
"using",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"wrapped_instance",
"=",
"site_offline_models",
".",
"get_wrapped_instance",
"(",
"instance",
")",
"except",
"ModelNotRegistered",
":",
... | Creates a serialized OutgoingTransaction when
a model instance is deleted.
Skip those not registered. | [
"Creates",
"a",
"serialized",
"OutgoingTransaction",
"when",
"a",
"model",
"instance",
"is",
"deleted",
"."
] | train | https://github.com/erikvw/django-collect-offline/blob/3d5efd66c68e2db4b060a82b070ae490dc399ca7/django_collect_offline/signals.py#L69-L80 |
gwww/elkm1 | elkm1_lib/settings.py | Setting.set | def set(self, value):
"""(Helper) Set custom value."""
self._elk.send(cw_encode(self._index, value, self.value_format)) | python | def set(self, value):
"""(Helper) Set custom value."""
self._elk.send(cw_encode(self._index, value, self.value_format)) | [
"def",
"set",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_elk",
".",
"send",
"(",
"cw_encode",
"(",
"self",
".",
"_index",
",",
"value",
",",
"self",
".",
"value_format",
")",
")"
] | (Helper) Set custom value. | [
"(",
"Helper",
")",
"Set",
"custom",
"value",
"."
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/settings.py#L14-L16 |
gwww/elkm1 | elkm1_lib/settings.py | Settings.sync | def sync(self):
"""Retrieve custom values from ElkM1"""
self.elk.send(cp_encode())
self.get_descriptions(TextDescriptions.SETTING.value) | python | def sync(self):
"""Retrieve custom values from ElkM1"""
self.elk.send(cp_encode())
self.get_descriptions(TextDescriptions.SETTING.value) | [
"def",
"sync",
"(",
"self",
")",
":",
"self",
".",
"elk",
".",
"send",
"(",
"cp_encode",
"(",
")",
")",
"self",
".",
"get_descriptions",
"(",
"TextDescriptions",
".",
"SETTING",
".",
"value",
")"
] | Retrieve custom values from ElkM1 | [
"Retrieve",
"custom",
"values",
"from",
"ElkM1"
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/settings.py#L25-L28 |
MonashBI/arcana | arcana/data/item.py | Fileset.paths | def paths(self):
"""Iterates through all files in the set"""
if self.format is None:
raise ArcanaFileFormatError(
"Cannot get paths of fileset ({}) that hasn't had its format "
"set".format(self))
if self.format.directory:
return chain(*((o... | python | def paths(self):
"""Iterates through all files in the set"""
if self.format is None:
raise ArcanaFileFormatError(
"Cannot get paths of fileset ({}) that hasn't had its format "
"set".format(self))
if self.format.directory:
return chain(*((o... | [
"def",
"paths",
"(",
"self",
")",
":",
"if",
"self",
".",
"format",
"is",
"None",
":",
"raise",
"ArcanaFileFormatError",
"(",
"\"Cannot get paths of fileset ({}) that hasn't had its format \"",
"\"set\"",
".",
"format",
"(",
"self",
")",
")",
"if",
"self",
".",
... | Iterates through all files in the set | [
"Iterates",
"through",
"all",
"files",
"in",
"the",
"set"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/data/item.py#L371-L381 |
MonashBI/arcana | arcana/data/item.py | Fileset.detect_format | def detect_format(self, candidates):
"""
Detects the format of the fileset from a list of possible
candidates. If multiple candidates match the potential files, e.g.
NiFTI-X (see dcm2niix) and NiFTI, then the first matching candidate is
selected.
If a 'format_name' was s... | python | def detect_format(self, candidates):
"""
Detects the format of the fileset from a list of possible
candidates. If multiple candidates match the potential files, e.g.
NiFTI-X (see dcm2niix) and NiFTI, then the first matching candidate is
selected.
If a 'format_name' was s... | [
"def",
"detect_format",
"(",
"self",
",",
"candidates",
")",
":",
"if",
"self",
".",
"_format",
"is",
"not",
"None",
":",
"raise",
"ArcanaFileFormatError",
"(",
"\"Format has already been set for {}\"",
".",
"format",
"(",
"self",
")",
")",
"matches",
"=",
"["... | Detects the format of the fileset from a list of possible
candidates. If multiple candidates match the potential files, e.g.
NiFTI-X (see dcm2niix) and NiFTI, then the first matching candidate is
selected.
If a 'format_name' was specified when the fileset was
created then that i... | [
"Detects",
"the",
"format",
"of",
"the",
"fileset",
"from",
"a",
"list",
"of",
"possible",
"candidates",
".",
"If",
"multiple",
"candidates",
"match",
"the",
"potential",
"files",
"e",
".",
"g",
".",
"NiFTI",
"-",
"X",
"(",
"see",
"dcm2niix",
")",
"and",... | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/data/item.py#L493-L519 |
MonashBI/arcana | arcana/data/item.py | Fileset.contents_equal | def contents_equal(self, other, **kwargs):
"""
Test the equality of the fileset contents with another fileset. If the
fileset's format implements a 'contents_equal' method than that is used
to determine the equality, otherwise a straight comparison of the
checksums is used.
... | python | def contents_equal(self, other, **kwargs):
"""
Test the equality of the fileset contents with another fileset. If the
fileset's format implements a 'contents_equal' method than that is used
to determine the equality, otherwise a straight comparison of the
checksums is used.
... | [
"def",
"contents_equal",
"(",
"self",
",",
"other",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"format",
",",
"'contents_equal'",
")",
":",
"equal",
"=",
"self",
".",
"format",
".",
"contents_equal",
"(",
"self",
",",
"other"... | Test the equality of the fileset contents with another fileset. If the
fileset's format implements a 'contents_equal' method than that is used
to determine the equality, otherwise a straight comparison of the
checksums is used.
Parameters
----------
other : Fileset
... | [
"Test",
"the",
"equality",
"of",
"the",
"fileset",
"contents",
"with",
"another",
"fileset",
".",
"If",
"the",
"fileset",
"s",
"format",
"implements",
"a",
"contents_equal",
"method",
"than",
"that",
"is",
"used",
"to",
"determine",
"the",
"equality",
"otherwi... | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/data/item.py#L542-L558 |
MonashBI/arcana | arcana/data/spec.py | BaseInputSpec.bind | def bind(self, study, **kwargs): # @UnusedVariable
"""
Returns a copy of the AcquiredSpec bound to the given study
Parameters
----------
study : Study
A study to bind the fileset spec to (should happen in the
study __init__)
"""
if self.d... | python | def bind(self, study, **kwargs): # @UnusedVariable
"""
Returns a copy of the AcquiredSpec bound to the given study
Parameters
----------
study : Study
A study to bind the fileset spec to (should happen in the
study __init__)
"""
if self.d... | [
"def",
"bind",
"(",
"self",
",",
"study",
",",
"*",
"*",
"kwargs",
")",
":",
"# @UnusedVariable",
"if",
"self",
".",
"default",
"is",
"None",
":",
"raise",
"ArcanaError",
"(",
"\"Attempted to bind '{}' to {} but only acquired specs with \"",
"\"a default value should ... | Returns a copy of the AcquiredSpec bound to the given study
Parameters
----------
study : Study
A study to bind the fileset spec to (should happen in the
study __init__) | [
"Returns",
"a",
"copy",
"of",
"the",
"AcquiredSpec",
"bound",
"to",
"the",
"given",
"study"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/data/spec.py#L73-L96 |
MonashBI/arcana | arcana/data/spec.py | BaseSpec.bind | def bind(self, study, **kwargs): # @UnusedVariable
"""
Returns a copy of the Spec bound to the given study
Parameters
----------
study : Study
A study to bind the fileset spec to (should happen in the
study __init__)
"""
if self._study is... | python | def bind(self, study, **kwargs): # @UnusedVariable
"""
Returns a copy of the Spec bound to the given study
Parameters
----------
study : Study
A study to bind the fileset spec to (should happen in the
study __init__)
"""
if self._study is... | [
"def",
"bind",
"(",
"self",
",",
"study",
",",
"*",
"*",
"kwargs",
")",
":",
"# @UnusedVariable",
"if",
"self",
".",
"_study",
"is",
"not",
"None",
":",
"# Avoid rebinding specs in sub-studies that have already",
"# been bound to MultiStudy",
"bound",
"=",
"self",
... | Returns a copy of the Spec bound to the given study
Parameters
----------
study : Study
A study to bind the fileset spec to (should happen in the
study __init__) | [
"Returns",
"a",
"copy",
"of",
"the",
"Spec",
"bound",
"to",
"the",
"given",
"study"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/data/spec.py#L179-L202 |
MonashBI/arcana | arcana/data/spec.py | BaseSpec.nodes | def nodes(self, tree):
"""
Returns the relevant nodes for the spec's frequency
"""
# Run the match against the tree
if self.frequency == 'per_session':
nodes = []
for subject in tree.subjects:
for sess in subject.sessions:
... | python | def nodes(self, tree):
"""
Returns the relevant nodes for the spec's frequency
"""
# Run the match against the tree
if self.frequency == 'per_session':
nodes = []
for subject in tree.subjects:
for sess in subject.sessions:
... | [
"def",
"nodes",
"(",
"self",
",",
"tree",
")",
":",
"# Run the match against the tree",
"if",
"self",
".",
"frequency",
"==",
"'per_session'",
":",
"nodes",
"=",
"[",
"]",
"for",
"subject",
"in",
"tree",
".",
"subjects",
":",
"for",
"sess",
"in",
"subject"... | Returns the relevant nodes for the spec's frequency | [
"Returns",
"the",
"relevant",
"nodes",
"for",
"the",
"spec",
"s",
"frequency"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/data/spec.py#L212-L231 |
MonashBI/arcana | arcana/data/spec.py | BaseSpec.derivable | def derivable(self):
"""
Whether the spec (only valid for derived specs) can be derived
given the inputs and switches provided to the study
"""
try:
# Just need to iterate all study inputs and catch relevant
# exceptions
list(self.pipeline.stud... | python | def derivable(self):
"""
Whether the spec (only valid for derived specs) can be derived
given the inputs and switches provided to the study
"""
try:
# Just need to iterate all study inputs and catch relevant
# exceptions
list(self.pipeline.stud... | [
"def",
"derivable",
"(",
"self",
")",
":",
"try",
":",
"# Just need to iterate all study inputs and catch relevant",
"# exceptions",
"list",
"(",
"self",
".",
"pipeline",
".",
"study_inputs",
")",
"except",
"(",
"ArcanaOutputNotProducedException",
",",
"ArcanaMissingDataE... | Whether the spec (only valid for derived specs) can be derived
given the inputs and switches provided to the study | [
"Whether",
"the",
"spec",
"(",
"only",
"valid",
"for",
"derived",
"specs",
")",
"can",
"be",
"derived",
"given",
"the",
"inputs",
"and",
"switches",
"provided",
"to",
"the",
"study"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/data/spec.py#L234-L246 |
RedHatQE/python-stitches | stitches/structure.py | Structure.reconnect_all | def reconnect_all(self):
"""
Re-establish connection to all instances
"""
for role in self.Instances.keys():
for connection in self.Instances[role]:
connection.reconnect() | python | def reconnect_all(self):
"""
Re-establish connection to all instances
"""
for role in self.Instances.keys():
for connection in self.Instances[role]:
connection.reconnect() | [
"def",
"reconnect_all",
"(",
"self",
")",
":",
"for",
"role",
"in",
"self",
".",
"Instances",
".",
"keys",
"(",
")",
":",
"for",
"connection",
"in",
"self",
".",
"Instances",
"[",
"role",
"]",
":",
"connection",
".",
"reconnect",
"(",
")"
] | Re-establish connection to all instances | [
"Re",
"-",
"establish",
"connection",
"to",
"all",
"instances"
] | train | https://github.com/RedHatQE/python-stitches/blob/957e9895e64ffd3b8157b38b9cce414969509288/stitches/structure.py#L30-L36 |
RedHatQE/python-stitches | stitches/structure.py | Structure.add_instance | def add_instance(self,
role,
instance,
username='root',
key_filename=None,
output_shell=False):
"""
Add instance to the setup
@param role: instance's role
@type role: str
@param ... | python | def add_instance(self,
role,
instance,
username='root',
key_filename=None,
output_shell=False):
"""
Add instance to the setup
@param role: instance's role
@type role: str
@param ... | [
"def",
"add_instance",
"(",
"self",
",",
"role",
",",
"instance",
",",
"username",
"=",
"'root'",
",",
"key_filename",
"=",
"None",
",",
"output_shell",
"=",
"False",
")",
":",
"if",
"not",
"role",
"in",
"self",
".",
"Instances",
".",
"keys",
"(",
")",... | Add instance to the setup
@param role: instance's role
@type role: str
@param instance: host parameters we would like to establish connection
to
@type instance: dict
@param username: user name for creating ssh connection
@type username: str
... | [
"Add",
"instance",
"to",
"the",
"setup"
] | train | https://github.com/RedHatQE/python-stitches/blob/957e9895e64ffd3b8157b38b9cce414969509288/stitches/structure.py#L38-L72 |
RedHatQE/python-stitches | stitches/structure.py | Structure.setup_from_yamlfile | def setup_from_yamlfile(self, yamlfile, output_shell=False):
"""
Setup from yaml config
@param yamlfile: path to yaml config file
@type yamlfile: str
@param output_shell: write output from this connection to standard
output
@type output_shel... | python | def setup_from_yamlfile(self, yamlfile, output_shell=False):
"""
Setup from yaml config
@param yamlfile: path to yaml config file
@type yamlfile: str
@param output_shell: write output from this connection to standard
output
@type output_shel... | [
"def",
"setup_from_yamlfile",
"(",
"self",
",",
"yamlfile",
",",
"output_shell",
"=",
"False",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'Loading config from '",
"+",
"yamlfile",
")",
"with",
"open",
"(",
"yamlfile",
",",
"'r'",
")",
"as",
"yaml... | Setup from yaml config
@param yamlfile: path to yaml config file
@type yamlfile: str
@param output_shell: write output from this connection to standard
output
@type output_shell: bool | [
"Setup",
"from",
"yaml",
"config"
] | train | https://github.com/RedHatQE/python-stitches/blob/957e9895e64ffd3b8157b38b9cce414969509288/stitches/structure.py#L74-L94 |
brentp/toolshed | toolshed/files.py | process_iter | def process_iter(proc, cmd=""):
"""
helper function to iterate over a process stdout
and report error messages when done
"""
try:
for l in proc.stdout:
yield l
finally:
if proc.poll() is None:
# there was an exception
return
else:
... | python | def process_iter(proc, cmd=""):
"""
helper function to iterate over a process stdout
and report error messages when done
"""
try:
for l in proc.stdout:
yield l
finally:
if proc.poll() is None:
# there was an exception
return
else:
... | [
"def",
"process_iter",
"(",
"proc",
",",
"cmd",
"=",
"\"\"",
")",
":",
"try",
":",
"for",
"l",
"in",
"proc",
".",
"stdout",
":",
"yield",
"l",
"finally",
":",
"if",
"proc",
".",
"poll",
"(",
")",
"is",
"None",
":",
"# there was an exception",
"return... | helper function to iterate over a process stdout
and report error messages when done | [
"helper",
"function",
"to",
"iterate",
"over",
"a",
"process",
"stdout",
"and",
"report",
"error",
"messages",
"when",
"done"
] | train | https://github.com/brentp/toolshed/blob/c9529d6872bf28207642896c3b416f68e79b1269/toolshed/files.py#L44-L61 |
brentp/toolshed | toolshed/files.py | header | def header(fname, sep="\t"):
"""
just grab the header from a given file
"""
fh = iter(nopen(fname))
h = tokens(next(fh), sep)
h[0] = h[0].lstrip("#")
return h | python | def header(fname, sep="\t"):
"""
just grab the header from a given file
"""
fh = iter(nopen(fname))
h = tokens(next(fh), sep)
h[0] = h[0].lstrip("#")
return h | [
"def",
"header",
"(",
"fname",
",",
"sep",
"=",
"\"\\t\"",
")",
":",
"fh",
"=",
"iter",
"(",
"nopen",
"(",
"fname",
")",
")",
"h",
"=",
"tokens",
"(",
"next",
"(",
"fh",
")",
",",
"sep",
")",
"h",
"[",
"0",
"]",
"=",
"h",
"[",
"0",
"]",
"... | just grab the header from a given file | [
"just",
"grab",
"the",
"header",
"from",
"a",
"given",
"file"
] | train | https://github.com/brentp/toolshed/blob/c9529d6872bf28207642896c3b416f68e79b1269/toolshed/files.py#L164-L171 |
brentp/toolshed | toolshed/files.py | reader | def reader(fname, header=True, sep="\t", skip_while=None,
quotechar='"'):
r"""
for each row in the file `fname` generate dicts If `header` is True
or lists if `header` is False. The dict keys are drawn from the first
line.
If `header` is a list of names, those will be used as the dict keys.
... | python | def reader(fname, header=True, sep="\t", skip_while=None,
quotechar='"'):
r"""
for each row in the file `fname` generate dicts If `header` is True
or lists if `header` is False. The dict keys are drawn from the first
line.
If `header` is a list of names, those will be used as the dict keys.
... | [
"def",
"reader",
"(",
"fname",
",",
"header",
"=",
"True",
",",
"sep",
"=",
"\"\\t\"",
",",
"skip_while",
"=",
"None",
",",
"quotechar",
"=",
"'\"'",
")",
":",
"if",
"isinstance",
"(",
"fname",
",",
"int_types",
")",
":",
"fname",
"=",
"sys",
".",
... | r"""
for each row in the file `fname` generate dicts If `header` is True
or lists if `header` is False. The dict keys are drawn from the first
line.
If `header` is a list of names, those will be used as the dict keys.
If `header` is 'ordered', the function will yield ordered dicts.
If `header` i... | [
"r",
"for",
"each",
"row",
"in",
"the",
"file",
"fname",
"generate",
"dicts",
"If",
"header",
"is",
"True",
"or",
"lists",
"if",
"header",
"is",
"False",
".",
"The",
"dict",
"keys",
"are",
"drawn",
"from",
"the",
"first",
"line",
".",
"If",
"header",
... | train | https://github.com/brentp/toolshed/blob/c9529d6872bf28207642896c3b416f68e79b1269/toolshed/files.py#L180-L282 |
brentp/toolshed | toolshed/files.py | is_newer_b | def is_newer_b(a, bfiles):
"""
check that all b files have been modified more recently than a
"""
if isinstance(bfiles, basestring):
bfiles = [bfiles]
if not op.exists(a): return False
if not all(op.exists(b) for b in bfiles): return False
atime = os.stat(a).st_mtime # modification... | python | def is_newer_b(a, bfiles):
"""
check that all b files have been modified more recently than a
"""
if isinstance(bfiles, basestring):
bfiles = [bfiles]
if not op.exists(a): return False
if not all(op.exists(b) for b in bfiles): return False
atime = os.stat(a).st_mtime # modification... | [
"def",
"is_newer_b",
"(",
"a",
",",
"bfiles",
")",
":",
"if",
"isinstance",
"(",
"bfiles",
",",
"basestring",
")",
":",
"bfiles",
"=",
"[",
"bfiles",
"]",
"if",
"not",
"op",
".",
"exists",
"(",
"a",
")",
":",
"return",
"False",
"if",
"not",
"all",
... | check that all b files have been modified more recently than a | [
"check",
"that",
"all",
"b",
"files",
"have",
"been",
"modified",
"more",
"recently",
"than",
"a"
] | train | https://github.com/brentp/toolshed/blob/c9529d6872bf28207642896c3b416f68e79b1269/toolshed/files.py#L284-L299 |
RedHatQE/python-stitches | stitches/expect.py | Expect.expect_list | def expect_list(connection, regexp_list, timeout=10):
'''
Expect a list of expressions
@param connection: Connection to the host
@type connection: L{Connection}
@param regexp_list: regular expressions and associated return values
@type regexp_list: list of (regexp, retu... | python | def expect_list(connection, regexp_list, timeout=10):
'''
Expect a list of expressions
@param connection: Connection to the host
@type connection: L{Connection}
@param regexp_list: regular expressions and associated return values
@type regexp_list: list of (regexp, retu... | [
"def",
"expect_list",
"(",
"connection",
",",
"regexp_list",
",",
"timeout",
"=",
"10",
")",
":",
"result",
"=",
"\"\"",
"count",
"=",
"0",
"while",
"count",
"<",
"timeout",
":",
"try",
":",
"recv_part",
"=",
"connection",
".",
"channel",
".",
"recv",
... | Expect a list of expressions
@param connection: Connection to the host
@type connection: L{Connection}
@param regexp_list: regular expressions and associated return values
@type regexp_list: list of (regexp, return value)
@param timeout: timeout for performing expect operation... | [
"Expect",
"a",
"list",
"of",
"expressions"
] | train | https://github.com/RedHatQE/python-stitches/blob/957e9895e64ffd3b8157b38b9cce414969509288/stitches/expect.py#L26-L63 |
RedHatQE/python-stitches | stitches/expect.py | Expect.expect | def expect(connection, strexp, timeout=10):
'''
Expect one expression
@param connection: Connection to the host
@type connection: L{Connection}
@param strexp: string to convert to expression (.*string.*)
@type strexp: str
@param timeout: timeout for performing ... | python | def expect(connection, strexp, timeout=10):
'''
Expect one expression
@param connection: Connection to the host
@type connection: L{Connection}
@param strexp: string to convert to expression (.*string.*)
@type strexp: str
@param timeout: timeout for performing ... | [
"def",
"expect",
"(",
"connection",
",",
"strexp",
",",
"timeout",
"=",
"10",
")",
":",
"return",
"Expect",
".",
"expect_list",
"(",
"connection",
",",
"[",
"(",
"re",
".",
"compile",
"(",
"\".*\"",
"+",
"strexp",
"+",
"\".*\"",
",",
"re",
".",
"DOTA... | Expect one expression
@param connection: Connection to the host
@type connection: L{Connection}
@param strexp: string to convert to expression (.*string.*)
@type strexp: str
@param timeout: timeout for performing expect operation
@type timeout: int
@return: Tr... | [
"Expect",
"one",
"expression"
] | train | https://github.com/RedHatQE/python-stitches/blob/957e9895e64ffd3b8157b38b9cce414969509288/stitches/expect.py#L66-L87 |
RedHatQE/python-stitches | stitches/expect.py | Expect.match | def match(connection, regexp, grouplist=[1], timeout=10):
'''
Match against an expression
@param connection: Connection to the host
@type connection: L{Connection}
@param regexp: compiled regular expression
@type regexp: L{SRE_Pattern}
@param grouplist: list of... | python | def match(connection, regexp, grouplist=[1], timeout=10):
'''
Match against an expression
@param connection: Connection to the host
@type connection: L{Connection}
@param regexp: compiled regular expression
@type regexp: L{SRE_Pattern}
@param grouplist: list of... | [
"def",
"match",
"(",
"connection",
",",
"regexp",
",",
"grouplist",
"=",
"[",
"1",
"]",
",",
"timeout",
"=",
"10",
")",
":",
"logging",
".",
"getLogger",
"(",
"'stitches.expect'",
")",
".",
"debug",
"(",
"\"MATCHING: \"",
"+",
"regexp",
".",
"pattern",
... | Match against an expression
@param connection: Connection to the host
@type connection: L{Connection}
@param regexp: compiled regular expression
@type regexp: L{SRE_Pattern}
@param grouplist: list of groups to return
@type group: list of int
@param timeout: ti... | [
"Match",
"against",
"an",
"expression"
] | train | https://github.com/RedHatQE/python-stitches/blob/957e9895e64ffd3b8157b38b9cce414969509288/stitches/expect.py#L90-L134 |
RedHatQE/python-stitches | stitches/expect.py | Expect.ping_pong | def ping_pong(connection, command, strexp, timeout=10):
'''
Enter a command and wait for something to happen (enter + expect
combined)
@param connection: connection to the host
@type connection: L{Connection}
@param command: command to execute
@type command: str... | python | def ping_pong(connection, command, strexp, timeout=10):
'''
Enter a command and wait for something to happen (enter + expect
combined)
@param connection: connection to the host
@type connection: L{Connection}
@param command: command to execute
@type command: str... | [
"def",
"ping_pong",
"(",
"connection",
",",
"command",
",",
"strexp",
",",
"timeout",
"=",
"10",
")",
":",
"Expect",
".",
"enter",
"(",
"connection",
",",
"command",
")",
"return",
"Expect",
".",
"expect",
"(",
"connection",
",",
"strexp",
",",
"timeout"... | Enter a command and wait for something to happen (enter + expect
combined)
@param connection: connection to the host
@type connection: L{Connection}
@param command: command to execute
@type command: str
@param strexp: string to convert to expression (.*string.*)
... | [
"Enter",
"a",
"command",
"and",
"wait",
"for",
"something",
"to",
"happen",
"(",
"enter",
"+",
"expect",
"combined",
")"
] | train | https://github.com/RedHatQE/python-stitches/blob/957e9895e64ffd3b8157b38b9cce414969509288/stitches/expect.py#L153-L176 |
RedHatQE/python-stitches | stitches/expect.py | Expect.expect_retval | def expect_retval(connection, command, expected_status=0, timeout=10):
'''
Run command and expect specified return valud
@param connection: connection to the host
@type connection: L{Connection}
@param command: command to execute
@type command: str
@param expec... | python | def expect_retval(connection, command, expected_status=0, timeout=10):
'''
Run command and expect specified return valud
@param connection: connection to the host
@type connection: L{Connection}
@param command: command to execute
@type command: str
@param expec... | [
"def",
"expect_retval",
"(",
"connection",
",",
"command",
",",
"expected_status",
"=",
"0",
",",
"timeout",
"=",
"10",
")",
":",
"retval",
"=",
"connection",
".",
"recv_exit_status",
"(",
"command",
",",
"timeout",
")",
"if",
"retval",
"is",
"None",
":",
... | Run command and expect specified return valud
@param connection: connection to the host
@type connection: L{Connection}
@param command: command to execute
@type command: str
@param expected_status: expected return value
@type expected_status: int
@param timeou... | [
"Run",
"command",
"and",
"expect",
"specified",
"return",
"valud"
] | train | https://github.com/RedHatQE/python-stitches/blob/957e9895e64ffd3b8157b38b9cce414969509288/stitches/expect.py#L179-L211 |
gwww/elkm1 | elkm1_lib/keypads.py | Keypads.sync | def sync(self):
"""Retrieve areas from ElkM1"""
self.elk.send(ka_encode())
self.get_descriptions(TextDescriptions.KEYPAD.value) | python | def sync(self):
"""Retrieve areas from ElkM1"""
self.elk.send(ka_encode())
self.get_descriptions(TextDescriptions.KEYPAD.value) | [
"def",
"sync",
"(",
"self",
")",
":",
"self",
".",
"elk",
".",
"send",
"(",
"ka_encode",
"(",
")",
")",
"self",
".",
"get_descriptions",
"(",
"TextDescriptions",
".",
"KEYPAD",
".",
"value",
")"
] | Retrieve areas from ElkM1 | [
"Retrieve",
"areas",
"from",
"ElkM1"
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/keypads.py#L32-L35 |
vedvyas/doxytag2zealdb | doxytag2zealdb/doxytag.py | TagProcessor.find | def find(self, soup):
'''Yield tags matching the tag criterion from a soup.
There is no need to override this if you are satisfied with finding
tags that match match_criterion.
Args:
soup: A BeautifulSoup to search through.
Yields:
BeautifulSoup Tags th... | python | def find(self, soup):
'''Yield tags matching the tag criterion from a soup.
There is no need to override this if you are satisfied with finding
tags that match match_criterion.
Args:
soup: A BeautifulSoup to search through.
Yields:
BeautifulSoup Tags th... | [
"def",
"find",
"(",
"self",
",",
"soup",
")",
":",
"for",
"tag",
"in",
"soup",
".",
"recursiveChildGenerator",
"(",
")",
":",
"if",
"self",
".",
"match_criterion",
"(",
"tag",
")",
":",
"yield",
"tag"
] | Yield tags matching the tag criterion from a soup.
There is no need to override this if you are satisfied with finding
tags that match match_criterion.
Args:
soup: A BeautifulSoup to search through.
Yields:
BeautifulSoup Tags that match the criterion. | [
"Yield",
"tags",
"matching",
"the",
"tag",
"criterion",
"from",
"a",
"soup",
"."
] | train | https://github.com/vedvyas/doxytag2zealdb/blob/8b07a88af6794248f8cfdabb0fda9dd61c777127/doxytag2zealdb/doxytag.py#L68-L82 |
vedvyas/doxytag2zealdb | doxytag2zealdb/doxytag.py | TagProcessor.get_name | def get_name(self, tag):
'''Extract and return a representative "name" from a tag.
Override as necessary. get_name's output can be controlled through
keyword arguments that are provided when initializing a
TagProcessor. For instance, a member of a class or namespace can have
its... | python | def get_name(self, tag):
'''Extract and return a representative "name" from a tag.
Override as necessary. get_name's output can be controlled through
keyword arguments that are provided when initializing a
TagProcessor. For instance, a member of a class or namespace can have
its... | [
"def",
"get_name",
"(",
"self",
",",
"tag",
")",
":",
"name",
"=",
"tag",
".",
"findChild",
"(",
"'name'",
")",
".",
"contents",
"[",
"0",
"]",
"if",
"self",
".",
"include_parent_scopes",
":",
"# Include parent scope in returned name",
"parent_tag",
"=",
"ta... | Extract and return a representative "name" from a tag.
Override as necessary. get_name's output can be controlled through
keyword arguments that are provided when initializing a
TagProcessor. For instance, a member of a class or namespace can have
its parent scope included in the name b... | [
"Extract",
"and",
"return",
"a",
"representative",
"name",
"from",
"a",
"tag",
"."
] | train | https://github.com/vedvyas/doxytag2zealdb/blob/8b07a88af6794248f8cfdabb0fda9dd61c777127/doxytag2zealdb/doxytag.py#L84-L108 |
vedvyas/doxytag2zealdb | doxytag2zealdb/doxytag.py | TagProcessor.get_filename | def get_filename(self, tag):
'''Extract and return a documentation filename from a tag.
Override as necessary, though this default implementation probably
covers all the cases of interest.
Args:
tag: A BeautifulSoup Tag that satisfies match_criterion.
Returns:
... | python | def get_filename(self, tag):
'''Extract and return a documentation filename from a tag.
Override as necessary, though this default implementation probably
covers all the cases of interest.
Args:
tag: A BeautifulSoup Tag that satisfies match_criterion.
Returns:
... | [
"def",
"get_filename",
"(",
"self",
",",
"tag",
")",
":",
"if",
"tag",
".",
"find",
"(",
"'filename'",
",",
"recursive",
"=",
"False",
")",
"is",
"not",
"None",
":",
"return",
"tag",
".",
"filename",
".",
"contents",
"[",
"0",
"]",
"elif",
"tag",
"... | Extract and return a documentation filename from a tag.
Override as necessary, though this default implementation probably
covers all the cases of interest.
Args:
tag: A BeautifulSoup Tag that satisfies match_criterion.
Returns:
A string that would be appropria... | [
"Extract",
"and",
"return",
"a",
"documentation",
"filename",
"from",
"a",
"tag",
"."
] | train | https://github.com/vedvyas/doxytag2zealdb/blob/8b07a88af6794248f8cfdabb0fda9dd61c777127/doxytag2zealdb/doxytag.py#L124-L140 |
vedvyas/doxytag2zealdb | doxytag2zealdb/doxytag.py | TagProcessorWithEntryTypeAndFindByNamePlusKind.match_criterion | def match_criterion(self, tag):
'''Override. Determine if a tag has the desired name and kind attribute
value.
Args:
tag: A BeautifulSoup Tag.
Returns:
True if tag has the desired name and kind, otherwise False.
'''
return tag.name == self.refere... | python | def match_criterion(self, tag):
'''Override. Determine if a tag has the desired name and kind attribute
value.
Args:
tag: A BeautifulSoup Tag.
Returns:
True if tag has the desired name and kind, otherwise False.
'''
return tag.name == self.refere... | [
"def",
"match_criterion",
"(",
"self",
",",
"tag",
")",
":",
"return",
"tag",
".",
"name",
"==",
"self",
".",
"reference_tag_name",
"and",
"tag",
".",
"attrs",
".",
"get",
"(",
"'kind'",
",",
"''",
")",
"==",
"self",
".",
"reference_tag_kind"
] | Override. Determine if a tag has the desired name and kind attribute
value.
Args:
tag: A BeautifulSoup Tag.
Returns:
True if tag has the desired name and kind, otherwise False. | [
"Override",
".",
"Determine",
"if",
"a",
"tag",
"has",
"the",
"desired",
"name",
"and",
"kind",
"attribute",
"value",
"."
] | train | https://github.com/vedvyas/doxytag2zealdb/blob/8b07a88af6794248f8cfdabb0fda9dd61c777127/doxytag2zealdb/doxytag.py#L169-L180 |
vedvyas/doxytag2zealdb | doxytag2zealdb/doxytag.py | functionTagProcessor.get_name | def get_name(self, tag):
'''Override. Extract a representative "name" from a function tag.
get_name's output can be controlled through keyword arguments that are
provided when initializing a functionTagProcessor. For instance,
function arguments and return types can be included by passi... | python | def get_name(self, tag):
'''Override. Extract a representative "name" from a function tag.
get_name's output can be controlled through keyword arguments that are
provided when initializing a functionTagProcessor. For instance,
function arguments and return types can be included by passi... | [
"def",
"get_name",
"(",
"self",
",",
"tag",
")",
":",
"name",
"=",
"super",
"(",
"functionTagProcessor",
",",
"self",
")",
".",
"get_name",
"(",
"tag",
")",
"if",
"self",
".",
"include_function_signatures",
":",
"# Include complete function signature in returned n... | Override. Extract a representative "name" from a function tag.
get_name's output can be controlled through keyword arguments that are
provided when initializing a functionTagProcessor. For instance,
function arguments and return types can be included by passing
include_function_signatur... | [
"Override",
".",
"Extract",
"a",
"representative",
"name",
"from",
"a",
"function",
"tag",
"."
] | train | https://github.com/vedvyas/doxytag2zealdb/blob/8b07a88af6794248f8cfdabb0fda9dd61c777127/doxytag2zealdb/doxytag.py#L298-L325 |
vedvyas/doxytag2zealdb | doxytag2zealdb/doxytag.py | functionTagProcessor.get_entry_type | def get_entry_type(self, tag):
'''Override that returns u'Method' for class/struct methods.
Override as necessary.
Args:
tag: A BeautifulSoup Tag for a function.
Returns:
If this is a class/struct method, returns u'Method', otherwise
returns the val... | python | def get_entry_type(self, tag):
'''Override that returns u'Method' for class/struct methods.
Override as necessary.
Args:
tag: A BeautifulSoup Tag for a function.
Returns:
If this is a class/struct method, returns u'Method', otherwise
returns the val... | [
"def",
"get_entry_type",
"(",
"self",
",",
"tag",
")",
":",
"if",
"tag",
".",
"findParent",
"(",
")",
".",
"get",
"(",
"'kind'",
")",
"in",
"[",
"'class'",
",",
"'struct'",
"]",
":",
"return",
"u'Method'",
"return",
"super",
"(",
"functionTagProcessor",
... | Override that returns u'Method' for class/struct methods.
Override as necessary.
Args:
tag: A BeautifulSoup Tag for a function.
Returns:
If this is a class/struct method, returns u'Method', otherwise
returns the value from the inherited implementation of
... | [
"Override",
"that",
"returns",
"u",
"Method",
"for",
"class",
"/",
"struct",
"methods",
"."
] | train | https://github.com/vedvyas/doxytag2zealdb/blob/8b07a88af6794248f8cfdabb0fda9dd61c777127/doxytag2zealdb/doxytag.py#L327-L344 |
brentp/toolshed | toolshed/pool.py | pool | def pool(n=None, dummy=False):
"""
create a multiprocessing pool that responds to interrupts.
"""
if dummy:
from multiprocessing.dummy import Pool
else:
from multiprocessing import Pool
if n is None:
import multiprocessing
n = multiprocessing.cpu_count() - 1
... | python | def pool(n=None, dummy=False):
"""
create a multiprocessing pool that responds to interrupts.
"""
if dummy:
from multiprocessing.dummy import Pool
else:
from multiprocessing import Pool
if n is None:
import multiprocessing
n = multiprocessing.cpu_count() - 1
... | [
"def",
"pool",
"(",
"n",
"=",
"None",
",",
"dummy",
"=",
"False",
")",
":",
"if",
"dummy",
":",
"from",
"multiprocessing",
".",
"dummy",
"import",
"Pool",
"else",
":",
"from",
"multiprocessing",
"import",
"Pool",
"if",
"n",
"is",
"None",
":",
"import",... | create a multiprocessing pool that responds to interrupts. | [
"create",
"a",
"multiprocessing",
"pool",
"that",
"responds",
"to",
"interrupts",
"."
] | train | https://github.com/brentp/toolshed/blob/c9529d6872bf28207642896c3b416f68e79b1269/toolshed/pool.py#L70-L83 |
brentp/toolshed | toolshed/pool.py | pmap | def pmap(f, iterable, n=None, dummy=False, p=None):
"""
parallel map of a function to an iterable
if each item in iterable is itself an iterable, then
automatically call f(*item) instead of f(item)
Arguments:
f: function
iterable: any iterable where each item is sent to f
n: numbe... | python | def pmap(f, iterable, n=None, dummy=False, p=None):
"""
parallel map of a function to an iterable
if each item in iterable is itself an iterable, then
automatically call f(*item) instead of f(item)
Arguments:
f: function
iterable: any iterable where each item is sent to f
n: numbe... | [
"def",
"pmap",
"(",
"f",
",",
"iterable",
",",
"n",
"=",
"None",
",",
"dummy",
"=",
"False",
",",
"p",
"=",
"None",
")",
":",
"# make it easier to debug.",
"if",
"n",
"==",
"1",
":",
"for",
"r",
"in",
"it",
".",
"starmap",
"(",
"f",
",",
"iterabl... | parallel map of a function to an iterable
if each item in iterable is itself an iterable, then
automatically call f(*item) instead of f(item)
Arguments:
f: function
iterable: any iterable where each item is sent to f
n: number of cpus (default is number on machine)
dummy: use dummy ... | [
"parallel",
"map",
"of",
"a",
"function",
"to",
"an",
"iterable",
"if",
"each",
"item",
"in",
"iterable",
"is",
"itself",
"an",
"iterable",
"then",
"automatically",
"call",
"f",
"(",
"*",
"item",
")",
"instead",
"of",
"f",
"(",
"item",
")"
] | train | https://github.com/brentp/toolshed/blob/c9529d6872bf28207642896c3b416f68e79b1269/toolshed/pool.py#L99-L138 |
gwww/elkm1 | elkm1_lib/elements.py | Element._call_callbacks | def _call_callbacks(self):
"""Callbacks when attribute of element changes"""
for callback in self._callbacks:
callback(self, self._changeset)
self._changeset = {} | python | def _call_callbacks(self):
"""Callbacks when attribute of element changes"""
for callback in self._callbacks:
callback(self, self._changeset)
self._changeset = {} | [
"def",
"_call_callbacks",
"(",
"self",
")",
":",
"for",
"callback",
"in",
"self",
".",
"_callbacks",
":",
"callback",
"(",
"self",
",",
"self",
".",
"_changeset",
")",
"self",
".",
"_changeset",
"=",
"{",
"}"
] | Callbacks when attribute of element changes | [
"Callbacks",
"when",
"attribute",
"of",
"element",
"changes"
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/elements.py#L31-L35 |
gwww/elkm1 | elkm1_lib/elements.py | Element.setattr | def setattr(self, attr, new_value, close_the_changeset=True):
"""If attribute value has changed then set it and call the callbacks"""
existing_value = getattr(self, attr, None)
if existing_value != new_value:
setattr(self, attr, new_value)
self._changeset[attr] = new_valu... | python | def setattr(self, attr, new_value, close_the_changeset=True):
"""If attribute value has changed then set it and call the callbacks"""
existing_value = getattr(self, attr, None)
if existing_value != new_value:
setattr(self, attr, new_value)
self._changeset[attr] = new_valu... | [
"def",
"setattr",
"(",
"self",
",",
"attr",
",",
"new_value",
",",
"close_the_changeset",
"=",
"True",
")",
":",
"existing_value",
"=",
"getattr",
"(",
"self",
",",
"attr",
",",
"None",
")",
"if",
"existing_value",
"!=",
"new_value",
":",
"setattr",
"(",
... | If attribute value has changed then set it and call the callbacks | [
"If",
"attribute",
"value",
"has",
"changed",
"then",
"set",
"it",
"and",
"call",
"the",
"callbacks"
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/elements.py#L37-L45 |
gwww/elkm1 | elkm1_lib/elements.py | Element.default_name | def default_name(self, separator='-'):
"""Return a default name for based on class and index of element"""
return self.__class__.__name__ + '{}{:03d}'.format(
separator, self._index+1) | python | def default_name(self, separator='-'):
"""Return a default name for based on class and index of element"""
return self.__class__.__name__ + '{}{:03d}'.format(
separator, self._index+1) | [
"def",
"default_name",
"(",
"self",
",",
"separator",
"=",
"'-'",
")",
":",
"return",
"self",
".",
"__class__",
".",
"__name__",
"+",
"'{}{:03d}'",
".",
"format",
"(",
"separator",
",",
"self",
".",
"_index",
"+",
"1",
")"
] | Return a default name for based on class and index of element | [
"Return",
"a",
"default",
"name",
"for",
"based",
"on",
"class",
"and",
"index",
"of",
"element"
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/elements.py#L47-L50 |
gwww/elkm1 | elkm1_lib/elements.py | Element.as_dict | def as_dict(self):
"""Package up the public attributes as a dict."""
attrs = vars(self)
return {key: attrs[key] for key in attrs if not key.startswith('_')} | python | def as_dict(self):
"""Package up the public attributes as a dict."""
attrs = vars(self)
return {key: attrs[key] for key in attrs if not key.startswith('_')} | [
"def",
"as_dict",
"(",
"self",
")",
":",
"attrs",
"=",
"vars",
"(",
"self",
")",
"return",
"{",
"key",
":",
"attrs",
"[",
"key",
"]",
"for",
"key",
"in",
"attrs",
"if",
"not",
"key",
".",
"startswith",
"(",
"'_'",
")",
"}"
] | Package up the public attributes as a dict. | [
"Package",
"up",
"the",
"public",
"attributes",
"as",
"a",
"dict",
"."
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/elements.py#L62-L65 |
gwww/elkm1 | elkm1_lib/elements.py | Elements.get_descriptions | def get_descriptions(self, description_type):
"""
Gets the descriptions for specified type.
When complete the callback is called with a list of descriptions
"""
(desc_type, max_units) = description_type
results = [None] * max_units
self.elk._descriptions_in_progre... | python | def get_descriptions(self, description_type):
"""
Gets the descriptions for specified type.
When complete the callback is called with a list of descriptions
"""
(desc_type, max_units) = description_type
results = [None] * max_units
self.elk._descriptions_in_progre... | [
"def",
"get_descriptions",
"(",
"self",
",",
"description_type",
")",
":",
"(",
"desc_type",
",",
"max_units",
")",
"=",
"description_type",
"results",
"=",
"[",
"None",
"]",
"*",
"max_units",
"self",
".",
"elk",
".",
"_descriptions_in_progress",
"[",
"desc_ty... | Gets the descriptions for specified type.
When complete the callback is called with a list of descriptions | [
"Gets",
"the",
"descriptions",
"for",
"specified",
"type",
".",
"When",
"complete",
"the",
"callback",
"is",
"called",
"with",
"a",
"list",
"of",
"descriptions"
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/elements.py#L90-L100 |
dahlia/wikidata | wikidata/commonsmedia.py | File.page_url | def page_url(self) -> str:
"""(:class:`str`) The canonical url of the page."""
url = self.attributes['canonicalurl']
assert isinstance(url, str)
return url | python | def page_url(self) -> str:
"""(:class:`str`) The canonical url of the page."""
url = self.attributes['canonicalurl']
assert isinstance(url, str)
return url | [
"def",
"page_url",
"(",
"self",
")",
"->",
"str",
":",
"url",
"=",
"self",
".",
"attributes",
"[",
"'canonicalurl'",
"]",
"assert",
"isinstance",
"(",
"url",
",",
"str",
")",
"return",
"url"
] | (:class:`str`) The canonical url of the page. | [
"(",
":",
"class",
":",
"str",
")",
"The",
"canonical",
"url",
"of",
"the",
"page",
"."
] | train | https://github.com/dahlia/wikidata/blob/b07c9f8fffc59b088ec9dd428d0ec4d989c82db4/wikidata/commonsmedia.py#L29-L33 |
dahlia/wikidata | wikidata/commonsmedia.py | File.image_url | def image_url(self) -> Optional[str]:
r"""(:class:`~typing.Optional`\ [:class:`str`]) The image url.
It may be :const:`None` if it's not an image.
"""
images = self.attributes.get('imageinfo', [])
if images and isinstance(images, collections.abc.Sequence):
return ima... | python | def image_url(self) -> Optional[str]:
r"""(:class:`~typing.Optional`\ [:class:`str`]) The image url.
It may be :const:`None` if it's not an image.
"""
images = self.attributes.get('imageinfo', [])
if images and isinstance(images, collections.abc.Sequence):
return ima... | [
"def",
"image_url",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"images",
"=",
"self",
".",
"attributes",
".",
"get",
"(",
"'imageinfo'",
",",
"[",
"]",
")",
"if",
"images",
"and",
"isinstance",
"(",
"images",
",",
"collections",
".",
"... | r"""(:class:`~typing.Optional`\ [:class:`str`]) The image url.
It may be :const:`None` if it's not an image. | [
"r",
"(",
":",
"class",
":",
"~typing",
".",
"Optional",
"\\",
"[",
":",
"class",
":",
"str",
"]",
")",
"The",
"image",
"url",
".",
"It",
"may",
"be",
":",
"const",
":",
"None",
"if",
"it",
"s",
"not",
"an",
"image",
"."
] | train | https://github.com/dahlia/wikidata/blob/b07c9f8fffc59b088ec9dd428d0ec4d989c82db4/wikidata/commonsmedia.py#L36-L44 |
dahlia/wikidata | wikidata/commonsmedia.py | File.image_resolution | def image_resolution(self) -> Optional[Tuple[int, int]]:
r"""(:class:`~typing.Optional`\ [:class:`~typing.Tuple`\ [:class:`int`,
:class:`int`]]) The (width, height) pair of the image.
It may be :const:`None` if it's not an image.
"""
images = self.attributes.get('imageinfo', [])... | python | def image_resolution(self) -> Optional[Tuple[int, int]]:
r"""(:class:`~typing.Optional`\ [:class:`~typing.Tuple`\ [:class:`int`,
:class:`int`]]) The (width, height) pair of the image.
It may be :const:`None` if it's not an image.
"""
images = self.attributes.get('imageinfo', [])... | [
"def",
"image_resolution",
"(",
"self",
")",
"->",
"Optional",
"[",
"Tuple",
"[",
"int",
",",
"int",
"]",
"]",
":",
"images",
"=",
"self",
".",
"attributes",
".",
"get",
"(",
"'imageinfo'",
",",
"[",
"]",
")",
"if",
"images",
"and",
"isinstance",
"("... | r"""(:class:`~typing.Optional`\ [:class:`~typing.Tuple`\ [:class:`int`,
:class:`int`]]) The (width, height) pair of the image.
It may be :const:`None` if it's not an image. | [
"r",
"(",
":",
"class",
":",
"~typing",
".",
"Optional",
"\\",
"[",
":",
"class",
":",
"~typing",
".",
"Tuple",
"\\",
"[",
":",
"class",
":",
"int",
":",
"class",
":",
"int",
"]]",
")",
"The",
"(",
"width",
"height",
")",
"pair",
"of",
"the",
"... | train | https://github.com/dahlia/wikidata/blob/b07c9f8fffc59b088ec9dd428d0ec4d989c82db4/wikidata/commonsmedia.py#L58-L68 |
dahlia/wikidata | wikidata/commonsmedia.py | File.image_size | def image_size(self) -> Optional[int]:
r"""(:class:`~typing.Optional`\ [:class:`int`]) The size of the image
in bytes. It may be :const:`None` if it's not an image.
"""
images = self.attributes.get('imageinfo', [])
if images and isinstance(images, collections.abc.Sequence):
... | python | def image_size(self) -> Optional[int]:
r"""(:class:`~typing.Optional`\ [:class:`int`]) The size of the image
in bytes. It may be :const:`None` if it's not an image.
"""
images = self.attributes.get('imageinfo', [])
if images and isinstance(images, collections.abc.Sequence):
... | [
"def",
"image_size",
"(",
"self",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"images",
"=",
"self",
".",
"attributes",
".",
"get",
"(",
"'imageinfo'",
",",
"[",
"]",
")",
"if",
"images",
"and",
"isinstance",
"(",
"images",
",",
"collections",
".",
... | r"""(:class:`~typing.Optional`\ [:class:`int`]) The size of the image
in bytes. It may be :const:`None` if it's not an image. | [
"r",
"(",
":",
"class",
":",
"~typing",
".",
"Optional",
"\\",
"[",
":",
"class",
":",
"int",
"]",
")",
"The",
"size",
"of",
"the",
"image",
"in",
"bytes",
".",
"It",
"may",
"be",
":",
"const",
":",
"None",
"if",
"it",
"s",
"not",
"an",
"image"... | train | https://github.com/dahlia/wikidata/blob/b07c9f8fffc59b088ec9dd428d0ec4d989c82db4/wikidata/commonsmedia.py#L71-L79 |
dahlia/wikidata | wikidata/multilingual.py | normalize_locale_code | def normalize_locale_code(locale: Union[Locale, str]) -> str:
"""Determine the normalized locale code string.
>>> normalize_locale_code('ko-kr')
'ko_KR'
>>> normalize_locale_code('zh_TW')
'zh_Hant_TW'
>>> normalize_locale_code(Locale.parse('en_US'))
'en_US'
"""
if not isinstance(lo... | python | def normalize_locale_code(locale: Union[Locale, str]) -> str:
"""Determine the normalized locale code string.
>>> normalize_locale_code('ko-kr')
'ko_KR'
>>> normalize_locale_code('zh_TW')
'zh_Hant_TW'
>>> normalize_locale_code(Locale.parse('en_US'))
'en_US'
"""
if not isinstance(lo... | [
"def",
"normalize_locale_code",
"(",
"locale",
":",
"Union",
"[",
"Locale",
",",
"str",
"]",
")",
"->",
"str",
":",
"if",
"not",
"isinstance",
"(",
"locale",
",",
"Locale",
")",
":",
"locale",
"=",
"Locale",
".",
"parse",
"(",
"locale",
".",
"replace",... | Determine the normalized locale code string.
>>> normalize_locale_code('ko-kr')
'ko_KR'
>>> normalize_locale_code('zh_TW')
'zh_Hant_TW'
>>> normalize_locale_code(Locale.parse('en_US'))
'en_US' | [
"Determine",
"the",
"normalized",
"locale",
"code",
"string",
"."
] | train | https://github.com/dahlia/wikidata/blob/b07c9f8fffc59b088ec9dd428d0ec4d989c82db4/wikidata/multilingual.py#L83-L96 |
dahlia/wikidata | wikidata/client.py | Client.get | def get(self, entity_id: EntityId, load: bool = False) -> Entity:
"""Get a Wikidata entity by its :class:`~.entity.EntityId`.
:param entity_id: The :attr:`~.entity.Entity.id` of
the :class:`~.entity.Entity` to find.
:type eneity_id: :class:`~.entity.EntityId`
:... | python | def get(self, entity_id: EntityId, load: bool = False) -> Entity:
"""Get a Wikidata entity by its :class:`~.entity.EntityId`.
:param entity_id: The :attr:`~.entity.Entity.id` of
the :class:`~.entity.Entity` to find.
:type eneity_id: :class:`~.entity.EntityId`
:... | [
"def",
"get",
"(",
"self",
",",
"entity_id",
":",
"EntityId",
",",
"load",
":",
"bool",
"=",
"False",
")",
"->",
"Entity",
":",
"try",
":",
"entity",
"=",
"self",
".",
"identity_map",
"[",
"entity_id",
"]",
"except",
"KeyError",
":",
"entity",
"=",
"... | Get a Wikidata entity by its :class:`~.entity.EntityId`.
:param entity_id: The :attr:`~.entity.Entity.id` of
the :class:`~.entity.Entity` to find.
:type eneity_id: :class:`~.entity.EntityId`
:param load: Eager loading on :const:`True`.
Lazy loading... | [
"Get",
"a",
"Wikidata",
"entity",
"by",
"its",
":",
"class",
":",
"~",
".",
"entity",
".",
"EntityId",
"."
] | train | https://github.com/dahlia/wikidata/blob/b07c9f8fffc59b088ec9dd428d0ec4d989c82db4/wikidata/client.py#L117-L140 |
dahlia/wikidata | wikidata/client.py | Client.guess_entity_type | def guess_entity_type(self, entity_id: EntityId) -> Optional[EntityType]:
r"""Guess :class:`~.entity.EntityType` from the given
:class:`~.entity.EntityId`. It could return :const:`None` when it
fails to guess.
.. note::
It always fails to guess when :attr:`entity_type_guess... | python | def guess_entity_type(self, entity_id: EntityId) -> Optional[EntityType]:
r"""Guess :class:`~.entity.EntityType` from the given
:class:`~.entity.EntityId`. It could return :const:`None` when it
fails to guess.
.. note::
It always fails to guess when :attr:`entity_type_guess... | [
"def",
"guess_entity_type",
"(",
"self",
",",
"entity_id",
":",
"EntityId",
")",
"->",
"Optional",
"[",
"EntityType",
"]",
":",
"if",
"not",
"self",
".",
"entity_type_guess",
":",
"return",
"None",
"if",
"entity_id",
"[",
"0",
"]",
"==",
"'Q'",
":",
"ret... | r"""Guess :class:`~.entity.EntityType` from the given
:class:`~.entity.EntityId`. It could return :const:`None` when it
fails to guess.
.. note::
It always fails to guess when :attr:`entity_type_guess`
is configued to :const:`False`.
:return: The guessed :class:... | [
"r",
"Guess",
":",
"class",
":",
"~",
".",
"entity",
".",
"EntityType",
"from",
"the",
"given",
":",
"class",
":",
"~",
".",
"entity",
".",
"EntityId",
".",
"It",
"could",
"return",
":",
"const",
":",
"None",
"when",
"it",
"fails",
"to",
"guess",
"... | train | https://github.com/dahlia/wikidata/blob/b07c9f8fffc59b088ec9dd428d0ec4d989c82db4/wikidata/client.py#L142-L165 |
dahlia/wikidata | wikidata/client.py | Client.decode_datavalue | def decode_datavalue(self,
datatype: str,
datavalue: Mapping[str, object]) -> object:
"""Decode the given ``datavalue`` using the configured
:attr:`datavalue_decoder`.
.. versionadded:: 0.3.0
"""
decode = cast(Callable[[Client, ... | python | def decode_datavalue(self,
datatype: str,
datavalue: Mapping[str, object]) -> object:
"""Decode the given ``datavalue`` using the configured
:attr:`datavalue_decoder`.
.. versionadded:: 0.3.0
"""
decode = cast(Callable[[Client, ... | [
"def",
"decode_datavalue",
"(",
"self",
",",
"datatype",
":",
"str",
",",
"datavalue",
":",
"Mapping",
"[",
"str",
",",
"object",
"]",
")",
"->",
"object",
":",
"decode",
"=",
"cast",
"(",
"Callable",
"[",
"[",
"Client",
",",
"str",
",",
"Mapping",
"... | Decode the given ``datavalue`` using the configured
:attr:`datavalue_decoder`.
.. versionadded:: 0.3.0 | [
"Decode",
"the",
"given",
"datavalue",
"using",
"the",
"configured",
":",
"attr",
":",
"datavalue_decoder",
"."
] | train | https://github.com/dahlia/wikidata/blob/b07c9f8fffc59b088ec9dd428d0ec4d989c82db4/wikidata/client.py#L167-L178 |
dahlia/wikidata | wikidata/cache.py | CachePolicy.set | def set(self, key: CacheKey, value: Optional[CacheValue]) -> None:
r"""Create or update a cache.
:param key: A key string to create or update.
:type key: :const:`CacheKey`
:param value: A value to cache. :const:`None` to remove cache.
:type value: :class:`~typing.Optional`\ [:c... | python | def set(self, key: CacheKey, value: Optional[CacheValue]) -> None:
r"""Create or update a cache.
:param key: A key string to create or update.
:type key: :const:`CacheKey`
:param value: A value to cache. :const:`None` to remove cache.
:type value: :class:`~typing.Optional`\ [:c... | [
"def",
"set",
"(",
"self",
",",
"key",
":",
"CacheKey",
",",
"value",
":",
"Optional",
"[",
"CacheValue",
"]",
")",
"->",
"None",
":",
"raise",
"NotImplementedError",
"(",
"'Concreate subclasses of {0.__module__}.{0.__qualname__} have to '",
"'override .set() method'",
... | r"""Create or update a cache.
:param key: A key string to create or update.
:type key: :const:`CacheKey`
:param value: A value to cache. :const:`None` to remove cache.
:type value: :class:`~typing.Optional`\ [:const:`CacheValue`] | [
"r",
"Create",
"or",
"update",
"a",
"cache",
"."
] | train | https://github.com/dahlia/wikidata/blob/b07c9f8fffc59b088ec9dd428d0ec4d989c82db4/wikidata/cache.py#L43-L55 |
dahlia/wikidata | wikidata/entity.py | Entity.getlist | def getlist(self, key: 'Entity') -> Sequence[object]:
r"""Return all values associated to the given ``key`` property
in sequence.
:param key: The property entity.
:type key: :class:`Entity`
:return: A sequence of all values associated to the given ``key``
proper... | python | def getlist(self, key: 'Entity') -> Sequence[object]:
r"""Return all values associated to the given ``key`` property
in sequence.
:param key: The property entity.
:type key: :class:`Entity`
:return: A sequence of all values associated to the given ``key``
proper... | [
"def",
"getlist",
"(",
"self",
",",
"key",
":",
"'Entity'",
")",
"->",
"Sequence",
"[",
"object",
"]",
":",
"if",
"not",
"(",
"isinstance",
"(",
"key",
",",
"type",
"(",
"self",
")",
")",
"and",
"key",
".",
"type",
"is",
"EntityType",
".",
"propert... | r"""Return all values associated to the given ``key`` property
in sequence.
:param key: The property entity.
:type key: :class:`Entity`
:return: A sequence of all values associated to the given ``key``
property. It can be empty if nothing is associated to
... | [
"r",
"Return",
"all",
"values",
"associated",
"to",
"the",
"given",
"key",
"property",
"in",
"sequence",
"."
] | train | https://github.com/dahlia/wikidata/blob/b07c9f8fffc59b088ec9dd428d0ec4d989c82db4/wikidata/entity.py#L165-L191 |
dahlia/wikidata | wikidata/entity.py | Entity.type | def type(self) -> EntityType:
"""(:class:`EntityType`) The type of entity, :attr:`~EntityType.item`
or :attr:`~EntityType.property`.
.. versionadded:: 0.2.0
"""
if self.data is None:
guessed_type = self.client.guess_entity_type(self.id)
if guessed_type i... | python | def type(self) -> EntityType:
"""(:class:`EntityType`) The type of entity, :attr:`~EntityType.item`
or :attr:`~EntityType.property`.
.. versionadded:: 0.2.0
"""
if self.data is None:
guessed_type = self.client.guess_entity_type(self.id)
if guessed_type i... | [
"def",
"type",
"(",
"self",
")",
"->",
"EntityType",
":",
"if",
"self",
".",
"data",
"is",
"None",
":",
"guessed_type",
"=",
"self",
".",
"client",
".",
"guess_entity_type",
"(",
"self",
".",
"id",
")",
"if",
"guessed_type",
"is",
"not",
"None",
":",
... | (:class:`EntityType`) The type of entity, :attr:`~EntityType.item`
or :attr:`~EntityType.property`.
.. versionadded:: 0.2.0 | [
"(",
":",
"class",
":",
"EntityType",
")",
"The",
"type",
"of",
"entity",
":",
"attr",
":",
"~EntityType",
".",
"item",
"or",
":",
"attr",
":",
"~EntityType",
".",
"property",
"."
] | train | https://github.com/dahlia/wikidata/blob/b07c9f8fffc59b088ec9dd428d0ec4d989c82db4/wikidata/entity.py#L216-L228 |
raddevon/flask-permissions | flask_permissions/models.py | make_user_role_table | def make_user_role_table(table_name='user', id_column_name='id'):
"""
Create the user-role association table so that
it correctly references your own UserMixin subclass.
"""
return db.Table('fp_user_role',
db.Column(
'user_id', db.Integer, ... | python | def make_user_role_table(table_name='user', id_column_name='id'):
"""
Create the user-role association table so that
it correctly references your own UserMixin subclass.
"""
return db.Table('fp_user_role',
db.Column(
'user_id', db.Integer, ... | [
"def",
"make_user_role_table",
"(",
"table_name",
"=",
"'user'",
",",
"id_column_name",
"=",
"'id'",
")",
":",
"return",
"db",
".",
"Table",
"(",
"'fp_user_role'",
",",
"db",
".",
"Column",
"(",
"'user_id'",
",",
"db",
".",
"Integer",
",",
"db",
".",
"Fo... | Create the user-role association table so that
it correctly references your own UserMixin subclass. | [
"Create",
"the",
"user",
"-",
"role",
"association",
"table",
"so",
"that",
"it",
"correctly",
"references",
"your",
"own",
"UserMixin",
"subclass",
"."
] | train | https://github.com/raddevon/flask-permissions/blob/a2f64c8e26b6b4807019794a68bad21b12ceeb71/flask_permissions/models.py#L23-L36 |
raddevon/flask-permissions | flask_permissions/decorators.py | user_has | def user_has(ability, get_user=import_user):
"""
Takes an ability (a string name of either a role or an ability) and returns the function if the user has that ability
"""
def wrapper(func):
@wraps(func)
def inner(*args, **kwargs):
from .models import Ability
desir... | python | def user_has(ability, get_user=import_user):
"""
Takes an ability (a string name of either a role or an ability) and returns the function if the user has that ability
"""
def wrapper(func):
@wraps(func)
def inner(*args, **kwargs):
from .models import Ability
desir... | [
"def",
"user_has",
"(",
"ability",
",",
"get_user",
"=",
"import_user",
")",
":",
"def",
"wrapper",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"inner",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"models",
... | Takes an ability (a string name of either a role or an ability) and returns the function if the user has that ability | [
"Takes",
"an",
"ability",
"(",
"a",
"string",
"name",
"of",
"either",
"a",
"role",
"or",
"an",
"ability",
")",
"and",
"returns",
"the",
"function",
"if",
"the",
"user",
"has",
"that",
"ability"
] | train | https://github.com/raddevon/flask-permissions/blob/a2f64c8e26b6b4807019794a68bad21b12ceeb71/flask_permissions/decorators.py#L14-L33 |
raddevon/flask-permissions | flask_permissions/decorators.py | user_is | def user_is(role, get_user=import_user):
"""
Takes an role (a string name of either a role or an ability) and returns the function if the user has that role
"""
def wrapper(func):
@wraps(func)
def inner(*args, **kwargs):
from .models import Role
current_user = get... | python | def user_is(role, get_user=import_user):
"""
Takes an role (a string name of either a role or an ability) and returns the function if the user has that role
"""
def wrapper(func):
@wraps(func)
def inner(*args, **kwargs):
from .models import Role
current_user = get... | [
"def",
"user_is",
"(",
"role",
",",
"get_user",
"=",
"import_user",
")",
":",
"def",
"wrapper",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"inner",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"models",
"im... | Takes an role (a string name of either a role or an ability) and returns the function if the user has that role | [
"Takes",
"an",
"role",
"(",
"a",
"string",
"name",
"of",
"either",
"a",
"role",
"or",
"an",
"ability",
")",
"and",
"returns",
"the",
"function",
"if",
"the",
"user",
"has",
"that",
"role"
] | train | https://github.com/raddevon/flask-permissions/blob/a2f64c8e26b6b4807019794a68bad21b12ceeb71/flask_permissions/decorators.py#L36-L49 |
sunlightlabs/django-mediasync | mediasync/views.py | combo_serve | def combo_serve(request, path, client):
"""
Handles generating a 'combo' file for the given path. This is similar to
what happens when we upload to S3. Processors are applied, and we get
the value that we would if we were serving from S3. This is a good way
to make sure combo files work as intended ... | python | def combo_serve(request, path, client):
"""
Handles generating a 'combo' file for the given path. This is similar to
what happens when we upload to S3. Processors are applied, and we get
the value that we would if we were serving from S3. This is a good way
to make sure combo files work as intended ... | [
"def",
"combo_serve",
"(",
"request",
",",
"path",
",",
"client",
")",
":",
"joinfile",
"=",
"path",
"sourcefiles",
"=",
"msettings",
"[",
"'JOINED'",
"]",
"[",
"path",
"]",
"# Generate the combo file as a string.",
"combo_data",
",",
"dirname",
"=",
"combine_fi... | Handles generating a 'combo' file for the given path. This is similar to
what happens when we upload to S3. Processors are applied, and we get
the value that we would if we were serving from S3. This is a good way
to make sure combo files work as intended before rolling out
to production. | [
"Handles",
"generating",
"a",
"combo",
"file",
"for",
"the",
"given",
"path",
".",
"This",
"is",
"similar",
"to",
"what",
"happens",
"when",
"we",
"upload",
"to",
"S3",
".",
"Processors",
"are",
"applied",
"and",
"we",
"get",
"the",
"value",
"that",
"we"... | train | https://github.com/sunlightlabs/django-mediasync/blob/aa8ce4cfff757bbdb488463c64c0863cca6a1932/mediasync/views.py#L14-L32 |
sunlightlabs/django-mediasync | mediasync/views.py | _form_key_str | def _form_key_str(path):
"""
Given a URL path, massage it into a key we can perform a lookup on the
MEDIASYNC['JOINED'] dict with.
This mostly involves figuring into account the CSS_PATH and JS_PATH
settings, if they have been set.
"""
if path.endswith('.css'):
media_path_prefix... | python | def _form_key_str(path):
"""
Given a URL path, massage it into a key we can perform a lookup on the
MEDIASYNC['JOINED'] dict with.
This mostly involves figuring into account the CSS_PATH and JS_PATH
settings, if they have been set.
"""
if path.endswith('.css'):
media_path_prefix... | [
"def",
"_form_key_str",
"(",
"path",
")",
":",
"if",
"path",
".",
"endswith",
"(",
"'.css'",
")",
":",
"media_path_prefix",
"=",
"msettings",
"[",
"'CSS_PATH'",
"]",
"elif",
"path",
".",
"endswith",
"(",
"'.js'",
")",
":",
"media_path_prefix",
"=",
"msetti... | Given a URL path, massage it into a key we can perform a lookup on the
MEDIASYNC['JOINED'] dict with.
This mostly involves figuring into account the CSS_PATH and JS_PATH
settings, if they have been set. | [
"Given",
"a",
"URL",
"path",
"massage",
"it",
"into",
"a",
"key",
"we",
"can",
"perform",
"a",
"lookup",
"on",
"the",
"MEDIASYNC",
"[",
"JOINED",
"]",
"dict",
"with",
".",
"This",
"mostly",
"involves",
"figuring",
"into",
"account",
"the",
"CSS_PATH",
"a... | train | https://github.com/sunlightlabs/django-mediasync/blob/aa8ce4cfff757bbdb488463c64c0863cca6a1932/mediasync/views.py#L34-L66 |
sunlightlabs/django-mediasync | mediasync/views.py | _find_combo_match | def _find_combo_match(path):
"""
Calculate the key to check the MEDIASYNC['JOINED'] dict for, perform the
lookup, and return the matching key string if a match is found. If no
match is found, return None instead.
"""
key_str = _form_key_str(path)
if not key_str:
# _form_key_str() say... | python | def _find_combo_match(path):
"""
Calculate the key to check the MEDIASYNC['JOINED'] dict for, perform the
lookup, and return the matching key string if a match is found. If no
match is found, return None instead.
"""
key_str = _form_key_str(path)
if not key_str:
# _form_key_str() say... | [
"def",
"_find_combo_match",
"(",
"path",
")",
":",
"key_str",
"=",
"_form_key_str",
"(",
"path",
")",
"if",
"not",
"key_str",
":",
"# _form_key_str() says this isn't even a CSS/JS file.",
"return",
"None",
"if",
"not",
"msettings",
"[",
"'JOINED'",
"]",
".",
"has_... | Calculate the key to check the MEDIASYNC['JOINED'] dict for, perform the
lookup, and return the matching key string if a match is found. If no
match is found, return None instead. | [
"Calculate",
"the",
"key",
"to",
"check",
"the",
"MEDIASYNC",
"[",
"JOINED",
"]",
"dict",
"for",
"perform",
"the",
"lookup",
"and",
"return",
"the",
"matching",
"key",
"string",
"if",
"a",
"match",
"is",
"found",
".",
"If",
"no",
"match",
"is",
"found",
... | train | https://github.com/sunlightlabs/django-mediasync/blob/aa8ce4cfff757bbdb488463c64c0863cca6a1932/mediasync/views.py#L68-L84 |
sunlightlabs/django-mediasync | mediasync/views.py | static_serve | def static_serve(request, path, client):
"""
Given a request for a media asset, this view does the necessary wrangling
to get the correct thing delivered to the user. This can also emulate the
combo behavior seen when SERVE_REMOTE == False and EMULATE_COMBO == True.
"""
if msettings['SERVE_... | python | def static_serve(request, path, client):
"""
Given a request for a media asset, this view does the necessary wrangling
to get the correct thing delivered to the user. This can also emulate the
combo behavior seen when SERVE_REMOTE == False and EMULATE_COMBO == True.
"""
if msettings['SERVE_... | [
"def",
"static_serve",
"(",
"request",
",",
"path",
",",
"client",
")",
":",
"if",
"msettings",
"[",
"'SERVE_REMOTE'",
"]",
":",
"# We're serving from S3, redirect there.",
"url",
"=",
"client",
".",
"remote_media_url",
"(",
")",
".",
"strip",
"(",
"'/'",
")",... | Given a request for a media asset, this view does the necessary wrangling
to get the correct thing delivered to the user. This can also emulate the
combo behavior seen when SERVE_REMOTE == False and EMULATE_COMBO == True. | [
"Given",
"a",
"request",
"for",
"a",
"media",
"asset",
"this",
"view",
"does",
"the",
"necessary",
"wrangling",
"to",
"get",
"the",
"correct",
"thing",
"delivered",
"to",
"the",
"user",
".",
"This",
"can",
"also",
"emulate",
"the",
"combo",
"behavior",
"se... | train | https://github.com/sunlightlabs/django-mediasync/blob/aa8ce4cfff757bbdb488463c64c0863cca6a1932/mediasync/views.py#L86-L116 |
sprockets/sprockets.http | sprockets/http/runner.py | Runner.start_server | def start_server(self, port_number, number_of_procs=0):
"""
Create a HTTP server and start it.
:param int port_number: the port number to bind the server to
:param int number_of_procs: number of processes to pass to
Tornado's ``httpserver.HTTPServer.start``.
If the ... | python | def start_server(self, port_number, number_of_procs=0):
"""
Create a HTTP server and start it.
:param int port_number: the port number to bind the server to
:param int number_of_procs: number of processes to pass to
Tornado's ``httpserver.HTTPServer.start``.
If the ... | [
"def",
"start_server",
"(",
"self",
",",
"port_number",
",",
"number_of_procs",
"=",
"0",
")",
":",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGTERM",
",",
"self",
".",
"_on_signal",
")",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGINT",
",",
... | Create a HTTP server and start it.
:param int port_number: the port number to bind the server to
:param int number_of_procs: number of processes to pass to
Tornado's ``httpserver.HTTPServer.start``.
If the application's ``debug`` setting is ``True``, then we are
going to ru... | [
"Create",
"a",
"HTTP",
"server",
"and",
"start",
"it",
"."
] | train | https://github.com/sprockets/sprockets.http/blob/8baa4cdc1fa35a162ee226fd6cc4170a0ca0ecd3/sprockets/http/runner.py#L59-L94 |
sprockets/sprockets.http | sprockets/http/runner.py | Runner.run | def run(self, port_number, number_of_procs=0):
"""
Create the server and run the IOLoop.
:param int port_number: the port number to bind the server to
:param int number_of_procs: number of processes to pass to
Tornado's ``httpserver.HTTPServer.start``.
If the applic... | python | def run(self, port_number, number_of_procs=0):
"""
Create the server and run the IOLoop.
:param int port_number: the port number to bind the server to
:param int number_of_procs: number of processes to pass to
Tornado's ``httpserver.HTTPServer.start``.
If the applic... | [
"def",
"run",
"(",
"self",
",",
"port_number",
",",
"number_of_procs",
"=",
"0",
")",
":",
"self",
".",
"start_server",
"(",
"port_number",
",",
"number_of_procs",
")",
"iol",
"=",
"ioloop",
".",
"IOLoop",
".",
"instance",
"(",
")",
"try",
":",
"self",
... | Create the server and run the IOLoop.
:param int port_number: the port number to bind the server to
:param int number_of_procs: number of processes to pass to
Tornado's ``httpserver.HTTPServer.start``.
If the application's ``debug`` setting is ``True``, then we are
going to... | [
"Create",
"the",
"server",
"and",
"run",
"the",
"IOLoop",
"."
] | train | https://github.com/sprockets/sprockets.http/blob/8baa4cdc1fa35a162ee226fd6cc4170a0ca0ecd3/sprockets/http/runner.py#L100-L133 |
matllubos/django-is-core | is_core/utils/decorators.py | short_description | def short_description(description):
"""
Sets 'short_description' attribute (this attribute is in exports to generate header name).
"""
def decorator(func):
if isinstance(func, property):
func = func.fget
func.short_description = description
return func
return deco... | python | def short_description(description):
"""
Sets 'short_description' attribute (this attribute is in exports to generate header name).
"""
def decorator(func):
if isinstance(func, property):
func = func.fget
func.short_description = description
return func
return deco... | [
"def",
"short_description",
"(",
"description",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"if",
"isinstance",
"(",
"func",
",",
"property",
")",
":",
"func",
"=",
"func",
".",
"fget",
"func",
".",
"short_description",
"=",
"description",
"return... | Sets 'short_description' attribute (this attribute is in exports to generate header name). | [
"Sets",
"short_description",
"attribute",
"(",
"this",
"attribute",
"is",
"in",
"exports",
"to",
"generate",
"header",
"name",
")",
"."
] | train | https://github.com/matllubos/django-is-core/blob/3f87ec56a814738683c732dce5f07e0328c2300d/is_core/utils/decorators.py#L1-L10 |
confirm/ansibleci | ansibleci/config.py | Config.add_module | def add_module(self, module):
'''
Adds configuration parameters from a Python module.
'''
for key, value in module.__dict__.iteritems():
if key[0:2] != '__':
self.__setattr__(attr=key, value=value) | python | def add_module(self, module):
'''
Adds configuration parameters from a Python module.
'''
for key, value in module.__dict__.iteritems():
if key[0:2] != '__':
self.__setattr__(attr=key, value=value) | [
"def",
"add_module",
"(",
"self",
",",
"module",
")",
":",
"for",
"key",
",",
"value",
"in",
"module",
".",
"__dict__",
".",
"iteritems",
"(",
")",
":",
"if",
"key",
"[",
"0",
":",
"2",
"]",
"!=",
"'__'",
":",
"self",
".",
"__setattr__",
"(",
"at... | Adds configuration parameters from a Python module. | [
"Adds",
"configuration",
"parameters",
"from",
"a",
"Python",
"module",
"."
] | train | https://github.com/confirm/ansibleci/blob/6a53ae8c4a4653624977e146092422857f661b8f/ansibleci/config.py#L61-L67 |
matllubos/django-is-core | is_core/generic_views/__init__.py | redirect_to_login | def redirect_to_login(next, redirect_field_name=REDIRECT_FIELD_NAME):
"""
Redirects the user to the login page, passing the given 'next' page
"""
resolved_url = reverse('IS:login')
login_url_parts = list(urlparse(resolved_url))
if redirect_field_name:
querystring = QueryDict(login_url_p... | python | def redirect_to_login(next, redirect_field_name=REDIRECT_FIELD_NAME):
"""
Redirects the user to the login page, passing the given 'next' page
"""
resolved_url = reverse('IS:login')
login_url_parts = list(urlparse(resolved_url))
if redirect_field_name:
querystring = QueryDict(login_url_p... | [
"def",
"redirect_to_login",
"(",
"next",
",",
"redirect_field_name",
"=",
"REDIRECT_FIELD_NAME",
")",
":",
"resolved_url",
"=",
"reverse",
"(",
"'IS:login'",
")",
"login_url_parts",
"=",
"list",
"(",
"urlparse",
"(",
"resolved_url",
")",
")",
"if",
"redirect_field... | Redirects the user to the login page, passing the given 'next' page | [
"Redirects",
"the",
"user",
"to",
"the",
"login",
"page",
"passing",
"the",
"given",
"next",
"page"
] | train | https://github.com/matllubos/django-is-core/blob/3f87ec56a814738683c732dce5f07e0328c2300d/is_core/generic_views/__init__.py#L23-L35 |
matllubos/django-is-core | is_core/generic_views/__init__.py | PermissionsViewMixin._check_permission | def _check_permission(self, name, obj=None):
"""
If customer is not authorized he should not get information that object is exists.
Therefore 403 is returned if object was not found or is redirected to the login page.
If custmer is authorized and object was not found is returned 404.
... | python | def _check_permission(self, name, obj=None):
"""
If customer is not authorized he should not get information that object is exists.
Therefore 403 is returned if object was not found or is redirected to the login page.
If custmer is authorized and object was not found is returned 404.
... | [
"def",
"_check_permission",
"(",
"self",
",",
"name",
",",
"obj",
"=",
"None",
")",
":",
"def",
"redirect_or_exception",
"(",
"ex",
")",
":",
"if",
"not",
"self",
".",
"request",
".",
"user",
"or",
"not",
"self",
".",
"request",
".",
"user",
".",
"is... | If customer is not authorized he should not get information that object is exists.
Therefore 403 is returned if object was not found or is redirected to the login page.
If custmer is authorized and object was not found is returned 404.
If object was found and user is not authorized is returned 4... | [
"If",
"customer",
"is",
"not",
"authorized",
"he",
"should",
"not",
"get",
"information",
"that",
"object",
"is",
"exists",
".",
"Therefore",
"403",
"is",
"returned",
"if",
"object",
"was",
"not",
"found",
"or",
"is",
"redirected",
"to",
"the",
"login",
"p... | train | https://github.com/matllubos/django-is-core/blob/3f87ec56a814738683c732dce5f07e0328c2300d/is_core/generic_views/__init__.py#L67-L88 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.