id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
48,400 | zhanglab/psamm | psamm/datasource/sbml.py | entry_id_from_cobra_encoding | def entry_id_from_cobra_encoding(cobra_id):
"""Convert COBRA-encoded ID string to decoded ID string."""
for escape, symbol in iteritems(_COBRA_DECODE_ESCAPES):
cobra_id = cobra_id.replace(escape, symbol)
return cobra_id | python | def entry_id_from_cobra_encoding(cobra_id):
"""Convert COBRA-encoded ID string to decoded ID string."""
for escape, symbol in iteritems(_COBRA_DECODE_ESCAPES):
cobra_id = cobra_id.replace(escape, symbol)
return cobra_id | [
"def",
"entry_id_from_cobra_encoding",
"(",
"cobra_id",
")",
":",
"for",
"escape",
",",
"symbol",
"in",
"iteritems",
"(",
"_COBRA_DECODE_ESCAPES",
")",
":",
"cobra_id",
"=",
"cobra_id",
".",
"replace",
"(",
"escape",
",",
"symbol",
")",
"return",
"cobra_id"
] | Convert COBRA-encoded ID string to decoded ID string. | [
"Convert",
"COBRA",
"-",
"encoded",
"ID",
"string",
"to",
"decoded",
"ID",
"string",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/sbml.py#L1302-L1306 |
48,401 | zhanglab/psamm | psamm/datasource/sbml.py | create_convert_sbml_id_function | def create_convert_sbml_id_function(
compartment_prefix='C_', reaction_prefix='R_',
compound_prefix='M_', decode_id=entry_id_from_cobra_encoding):
"""Create function for converting SBML IDs.
The returned function will strip prefixes, decode the ID using the provided
function. These prefixes... | python | def create_convert_sbml_id_function(
compartment_prefix='C_', reaction_prefix='R_',
compound_prefix='M_', decode_id=entry_id_from_cobra_encoding):
"""Create function for converting SBML IDs.
The returned function will strip prefixes, decode the ID using the provided
function. These prefixes... | [
"def",
"create_convert_sbml_id_function",
"(",
"compartment_prefix",
"=",
"'C_'",
",",
"reaction_prefix",
"=",
"'R_'",
",",
"compound_prefix",
"=",
"'M_'",
",",
"decode_id",
"=",
"entry_id_from_cobra_encoding",
")",
":",
"def",
"convert_sbml_id",
"(",
"entry",
")",
... | Create function for converting SBML IDs.
The returned function will strip prefixes, decode the ID using the provided
function. These prefixes are common on IDs in SBML models because the IDs
live in a global namespace. | [
"Create",
"function",
"for",
"converting",
"SBML",
"IDs",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/sbml.py#L1309-L1334 |
48,402 | zhanglab/psamm | psamm/datasource/sbml.py | translate_sbml_reaction | def translate_sbml_reaction(entry, new_id, compartment_map, compound_map):
"""Translate SBML reaction entry."""
new_entry = DictReactionEntry(entry, id=new_id)
# Convert compound IDs in reaction equation
if new_entry.equation is not None:
compounds = []
for compound, value in new_entry.... | python | def translate_sbml_reaction(entry, new_id, compartment_map, compound_map):
"""Translate SBML reaction entry."""
new_entry = DictReactionEntry(entry, id=new_id)
# Convert compound IDs in reaction equation
if new_entry.equation is not None:
compounds = []
for compound, value in new_entry.... | [
"def",
"translate_sbml_reaction",
"(",
"entry",
",",
"new_id",
",",
"compartment_map",
",",
"compound_map",
")",
":",
"new_entry",
"=",
"DictReactionEntry",
"(",
"entry",
",",
"id",
"=",
"new_id",
")",
"# Convert compound IDs in reaction equation",
"if",
"new_entry",
... | Translate SBML reaction entry. | [
"Translate",
"SBML",
"reaction",
"entry",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/sbml.py#L1342-L1366 |
48,403 | zhanglab/psamm | psamm/datasource/sbml.py | translate_sbml_compound | def translate_sbml_compound(entry, new_id, compartment_map):
"""Translate SBML compound entry."""
new_entry = DictCompoundEntry(entry, id=new_id)
if 'compartment' in new_entry.properties:
old_compartment = new_entry.properties['compartment']
new_entry.properties['compartment'] = compartment... | python | def translate_sbml_compound(entry, new_id, compartment_map):
"""Translate SBML compound entry."""
new_entry = DictCompoundEntry(entry, id=new_id)
if 'compartment' in new_entry.properties:
old_compartment = new_entry.properties['compartment']
new_entry.properties['compartment'] = compartment... | [
"def",
"translate_sbml_compound",
"(",
"entry",
",",
"new_id",
",",
"compartment_map",
")",
":",
"new_entry",
"=",
"DictCompoundEntry",
"(",
"entry",
",",
"id",
"=",
"new_id",
")",
"if",
"'compartment'",
"in",
"new_entry",
".",
"properties",
":",
"old_compartmen... | Translate SBML compound entry. | [
"Translate",
"SBML",
"compound",
"entry",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/sbml.py#L1369-L1383 |
48,404 | zhanglab/psamm | psamm/datasource/sbml.py | parse_xhtml_notes | def parse_xhtml_notes(entry):
"""Yield key, value pairs parsed from the XHTML notes section.
Each key, value pair must be defined in its own text block, e.g.
``<p>key: value</p><p>key2: value2</p>``. The key and value must be
separated by a colon. Whitespace is stripped from both key and value, and
... | python | def parse_xhtml_notes(entry):
"""Yield key, value pairs parsed from the XHTML notes section.
Each key, value pair must be defined in its own text block, e.g.
``<p>key: value</p><p>key2: value2</p>``. The key and value must be
separated by a colon. Whitespace is stripped from both key and value, and
... | [
"def",
"parse_xhtml_notes",
"(",
"entry",
")",
":",
"for",
"note",
"in",
"entry",
".",
"xml_notes",
".",
"itertext",
"(",
")",
":",
"m",
"=",
"re",
".",
"match",
"(",
"r'^([^:]+):(.+)$'",
",",
"note",
")",
"if",
"m",
":",
"key",
",",
"value",
"=",
... | Yield key, value pairs parsed from the XHTML notes section.
Each key, value pair must be defined in its own text block, e.g.
``<p>key: value</p><p>key2: value2</p>``. The key and value must be
separated by a colon. Whitespace is stripped from both key and value, and
quotes are removed from values if pr... | [
"Yield",
"key",
"value",
"pairs",
"parsed",
"from",
"the",
"XHTML",
"notes",
"section",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/sbml.py#L1513-L1535 |
48,405 | zhanglab/psamm | psamm/datasource/sbml.py | parse_xhtml_species_notes | def parse_xhtml_species_notes(entry):
"""Return species properties defined in the XHTML notes.
Older SBML models often define additional properties in the XHTML notes
section because structured methods for defining properties had not been
developed. This will try to parse the following properties: ``PU... | python | def parse_xhtml_species_notes(entry):
"""Return species properties defined in the XHTML notes.
Older SBML models often define additional properties in the XHTML notes
section because structured methods for defining properties had not been
developed. This will try to parse the following properties: ``PU... | [
"def",
"parse_xhtml_species_notes",
"(",
"entry",
")",
":",
"properties",
"=",
"{",
"}",
"if",
"entry",
".",
"xml_notes",
"is",
"not",
"None",
":",
"cobra_notes",
"=",
"dict",
"(",
"parse_xhtml_notes",
"(",
"entry",
")",
")",
"for",
"key",
"in",
"(",
"'p... | Return species properties defined in the XHTML notes.
Older SBML models often define additional properties in the XHTML notes
section because structured methods for defining properties had not been
developed. This will try to parse the following properties: ``PUBCHEM ID``,
``CHEBI ID``, ``FORMULA``, ``... | [
"Return",
"species",
"properties",
"defined",
"in",
"the",
"XHTML",
"notes",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/sbml.py#L1538-L1574 |
48,406 | zhanglab/psamm | psamm/datasource/sbml.py | parse_xhtml_reaction_notes | def parse_xhtml_reaction_notes(entry):
"""Return reaction properties defined in the XHTML notes.
Older SBML models often define additional properties in the XHTML notes
section because structured methods for defining properties had not been
developed. This will try to parse the following properties: ``... | python | def parse_xhtml_reaction_notes(entry):
"""Return reaction properties defined in the XHTML notes.
Older SBML models often define additional properties in the XHTML notes
section because structured methods for defining properties had not been
developed. This will try to parse the following properties: ``... | [
"def",
"parse_xhtml_reaction_notes",
"(",
"entry",
")",
":",
"properties",
"=",
"{",
"}",
"if",
"entry",
".",
"xml_notes",
"is",
"not",
"None",
":",
"cobra_notes",
"=",
"dict",
"(",
"parse_xhtml_notes",
"(",
"entry",
")",
")",
"if",
"'subsystem'",
"in",
"c... | Return reaction properties defined in the XHTML notes.
Older SBML models often define additional properties in the XHTML notes
section because structured methods for defining properties had not been
developed. This will try to parse the following properties: ``SUBSYSTEM``,
``GENE ASSOCIATION``, ``EC NU... | [
"Return",
"reaction",
"properties",
"defined",
"in",
"the",
"XHTML",
"notes",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/sbml.py#L1577-L1616 |
48,407 | zhanglab/psamm | psamm/datasource/sbml.py | parse_objective_coefficient | def parse_objective_coefficient(entry):
"""Return objective value for reaction entry.
Detect objectives that are specified using the non-standardized
kinetic law parameters which are used by many pre-FBC SBML models. The
objective coefficient is returned for the given reaction, or None if
undefined... | python | def parse_objective_coefficient(entry):
"""Return objective value for reaction entry.
Detect objectives that are specified using the non-standardized
kinetic law parameters which are used by many pre-FBC SBML models. The
objective coefficient is returned for the given reaction, or None if
undefined... | [
"def",
"parse_objective_coefficient",
"(",
"entry",
")",
":",
"for",
"parameter",
"in",
"entry",
".",
"kinetic_law_reaction_parameters",
":",
"pid",
",",
"name",
",",
"value",
",",
"units",
"=",
"parameter",
"if",
"(",
"pid",
"==",
"'OBJECTIVE_COEFFICIENT'",
"or... | Return objective value for reaction entry.
Detect objectives that are specified using the non-standardized
kinetic law parameters which are used by many pre-FBC SBML models. The
objective coefficient is returned for the given reaction, or None if
undefined.
Args:
entry: :class:`SBMLReactio... | [
"Return",
"objective",
"value",
"for",
"reaction",
"entry",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/sbml.py#L1619-L1636 |
48,408 | zhanglab/psamm | psamm/datasource/sbml.py | parse_flux_bounds | def parse_flux_bounds(entry):
"""Return flux bounds for reaction entry.
Detect flux bounds that are specified using the non-standardized
kinetic law parameters which are used by many pre-FBC SBML models. The
flux bounds are returned as a pair of lower, upper bounds. The returned
bound is None if un... | python | def parse_flux_bounds(entry):
"""Return flux bounds for reaction entry.
Detect flux bounds that are specified using the non-standardized
kinetic law parameters which are used by many pre-FBC SBML models. The
flux bounds are returned as a pair of lower, upper bounds. The returned
bound is None if un... | [
"def",
"parse_flux_bounds",
"(",
"entry",
")",
":",
"lower_bound",
"=",
"None",
"upper_bound",
"=",
"None",
"for",
"parameter",
"in",
"entry",
".",
"kinetic_law_reaction_parameters",
":",
"pid",
",",
"name",
",",
"value",
",",
"units",
"=",
"parameter",
"if",
... | Return flux bounds for reaction entry.
Detect flux bounds that are specified using the non-standardized
kinetic law parameters which are used by many pre-FBC SBML models. The
flux bounds are returned as a pair of lower, upper bounds. The returned
bound is None if undefined.
Args:
entry: :c... | [
"Return",
"flux",
"bounds",
"for",
"reaction",
"entry",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/sbml.py#L1639-L1659 |
48,409 | zhanglab/psamm | psamm/datasource/sbml.py | detect_extracellular_compartment | def detect_extracellular_compartment(model):
"""Detect the identifier for equations with extracellular compartments.
Args:
model: :class:`NativeModel`.
"""
extracellular_key = Counter()
for reaction in model.reactions:
equation = reaction.equation
if equation is None:
... | python | def detect_extracellular_compartment(model):
"""Detect the identifier for equations with extracellular compartments.
Args:
model: :class:`NativeModel`.
"""
extracellular_key = Counter()
for reaction in model.reactions:
equation = reaction.equation
if equation is None:
... | [
"def",
"detect_extracellular_compartment",
"(",
"model",
")",
":",
"extracellular_key",
"=",
"Counter",
"(",
")",
"for",
"reaction",
"in",
"model",
".",
"reactions",
":",
"equation",
"=",
"reaction",
".",
"equation",
"if",
"equation",
"is",
"None",
":",
"conti... | Detect the identifier for equations with extracellular compartments.
Args:
model: :class:`NativeModel`. | [
"Detect",
"the",
"identifier",
"for",
"equations",
"with",
"extracellular",
"compartments",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/sbml.py#L1662-L1686 |
48,410 | zhanglab/psamm | psamm/datasource/sbml.py | convert_exchange_to_compounds | def convert_exchange_to_compounds(model):
"""Convert exchange reactions in model to exchange compounds.
Only exchange reactions in the extracellular compartment are converted.
The extracelluar compartment must be defined for the model.
Args:
model: :class:`NativeModel`.
"""
# Build set... | python | def convert_exchange_to_compounds(model):
"""Convert exchange reactions in model to exchange compounds.
Only exchange reactions in the extracellular compartment are converted.
The extracelluar compartment must be defined for the model.
Args:
model: :class:`NativeModel`.
"""
# Build set... | [
"def",
"convert_exchange_to_compounds",
"(",
"model",
")",
":",
"# Build set of exchange reactions",
"exchanges",
"=",
"set",
"(",
")",
"for",
"reaction",
"in",
"model",
".",
"reactions",
":",
"equation",
"=",
"reaction",
".",
"properties",
".",
"get",
"(",
"'eq... | Convert exchange reactions in model to exchange compounds.
Only exchange reactions in the extracellular compartment are converted.
The extracelluar compartment must be defined for the model.
Args:
model: :class:`NativeModel`. | [
"Convert",
"exchange",
"reactions",
"in",
"model",
"to",
"exchange",
"compounds",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/sbml.py#L1689-L1757 |
48,411 | zhanglab/psamm | psamm/datasource/sbml.py | _SBMLEntry._element_get_id | def _element_get_id(self, element):
"""Get id of reaction or species element.
In old levels the name is used as the id. This method returns the
correct attribute depending on the level.
"""
if self._reader._level > 1:
entry_id = element.get('id')
else:
... | python | def _element_get_id(self, element):
"""Get id of reaction or species element.
In old levels the name is used as the id. This method returns the
correct attribute depending on the level.
"""
if self._reader._level > 1:
entry_id = element.get('id')
else:
... | [
"def",
"_element_get_id",
"(",
"self",
",",
"element",
")",
":",
"if",
"self",
".",
"_reader",
".",
"_level",
">",
"1",
":",
"entry_id",
"=",
"element",
".",
"get",
"(",
"'id'",
")",
"else",
":",
"entry_id",
"=",
"element",
".",
"get",
"(",
"'name'",... | Get id of reaction or species element.
In old levels the name is used as the id. This method returns the
correct attribute depending on the level. | [
"Get",
"id",
"of",
"reaction",
"or",
"species",
"element",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/sbml.py#L109-L119 |
48,412 | zhanglab/psamm | psamm/datasource/sbml.py | SBMLSpeciesEntry.properties | def properties(self):
"""All species properties as a dict"""
properties = {'id': self._id,
'boundary': self._boundary}
if 'name' in self._root.attrib:
properties['name'] = self._root.get('name')
if 'compartment' in self._root.attrib:
properti... | python | def properties(self):
"""All species properties as a dict"""
properties = {'id': self._id,
'boundary': self._boundary}
if 'name' in self._root.attrib:
properties['name'] = self._root.get('name')
if 'compartment' in self._root.attrib:
properti... | [
"def",
"properties",
"(",
"self",
")",
":",
"properties",
"=",
"{",
"'id'",
":",
"self",
".",
"_id",
",",
"'boundary'",
":",
"self",
".",
"_boundary",
"}",
"if",
"'name'",
"in",
"self",
".",
"_root",
".",
"attrib",
":",
"properties",
"[",
"'name'",
"... | All species properties as a dict | [
"All",
"species",
"properties",
"as",
"a",
"dict"
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/sbml.py#L217-L234 |
48,413 | zhanglab/psamm | psamm/datasource/sbml.py | SBMLReactionEntry._parse_species_references | def _parse_species_references(self, name):
"""Yield species id and parsed value for a speciesReference list"""
for species in self._root.iterfind('./{}/{}'.format(
self._reader._sbml_tag(name),
self._reader._sbml_tag('speciesReference'))):
species_id = specie... | python | def _parse_species_references(self, name):
"""Yield species id and parsed value for a speciesReference list"""
for species in self._root.iterfind('./{}/{}'.format(
self._reader._sbml_tag(name),
self._reader._sbml_tag('speciesReference'))):
species_id = specie... | [
"def",
"_parse_species_references",
"(",
"self",
",",
"name",
")",
":",
"for",
"species",
"in",
"self",
".",
"_root",
".",
"iterfind",
"(",
"'./{}/{}'",
".",
"format",
"(",
"self",
".",
"_reader",
".",
"_sbml_tag",
"(",
"name",
")",
",",
"self",
".",
"... | Yield species id and parsed value for a speciesReference list | [
"Yield",
"species",
"id",
"and",
"parsed",
"value",
"for",
"a",
"speciesReference",
"list"
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/sbml.py#L312-L359 |
48,414 | zhanglab/psamm | psamm/datasource/sbml.py | SBMLReactionEntry.kinetic_law_reaction_parameters | def kinetic_law_reaction_parameters(self):
"""Iterator over the values of kinetic law reaction parameters"""
for parameter in self._root.iterfind(
'./{}/{}/{}'.format(self._reader._sbml_tag('kineticLaw'),
self._reader._sbml_tag('listOfParameters'),
... | python | def kinetic_law_reaction_parameters(self):
"""Iterator over the values of kinetic law reaction parameters"""
for parameter in self._root.iterfind(
'./{}/{}/{}'.format(self._reader._sbml_tag('kineticLaw'),
self._reader._sbml_tag('listOfParameters'),
... | [
"def",
"kinetic_law_reaction_parameters",
"(",
"self",
")",
":",
"for",
"parameter",
"in",
"self",
".",
"_root",
".",
"iterfind",
"(",
"'./{}/{}/{}'",
".",
"format",
"(",
"self",
".",
"_reader",
".",
"_sbml_tag",
"(",
"'kineticLaw'",
")",
",",
"self",
".",
... | Iterator over the values of kinetic law reaction parameters | [
"Iterator",
"over",
"the",
"values",
"of",
"kinetic",
"law",
"reaction",
"parameters"
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/sbml.py#L383-L395 |
48,415 | zhanglab/psamm | psamm/datasource/sbml.py | SBMLReactionEntry.properties | def properties(self):
"""All reaction properties as a dict"""
properties = {'id': self._id,
'reversible': self._rev,
'equation': self._equation}
if 'name' in self._root.attrib:
properties['name'] = self._root.get('name')
if self._lo... | python | def properties(self):
"""All reaction properties as a dict"""
properties = {'id': self._id,
'reversible': self._rev,
'equation': self._equation}
if 'name' in self._root.attrib:
properties['name'] = self._root.get('name')
if self._lo... | [
"def",
"properties",
"(",
"self",
")",
":",
"properties",
"=",
"{",
"'id'",
":",
"self",
".",
"_id",
",",
"'reversible'",
":",
"self",
".",
"_rev",
",",
"'equation'",
":",
"self",
".",
"_equation",
"}",
"if",
"'name'",
"in",
"self",
".",
"_root",
"."... | All reaction properties as a dict | [
"All",
"reaction",
"properties",
"as",
"a",
"dict"
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/sbml.py#L398-L410 |
48,416 | zhanglab/psamm | psamm/datasource/sbml.py | SBMLCompartmentEntry.properties | def properties(self):
"""All compartment properties as a dict."""
properties = {'id': self._id}
if self._name is not None:
properties['name'] = self._name
return properties | python | def properties(self):
"""All compartment properties as a dict."""
properties = {'id': self._id}
if self._name is not None:
properties['name'] = self._name
return properties | [
"def",
"properties",
"(",
"self",
")",
":",
"properties",
"=",
"{",
"'id'",
":",
"self",
".",
"_id",
"}",
"if",
"self",
".",
"_name",
"is",
"not",
"None",
":",
"properties",
"[",
"'name'",
"]",
"=",
"self",
".",
"_name",
"return",
"properties"
] | All compartment properties as a dict. | [
"All",
"compartment",
"properties",
"as",
"a",
"dict",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/sbml.py#L427-L433 |
48,417 | zhanglab/psamm | psamm/datasource/sbml.py | SBMLReader.create_model | def create_model(self):
"""Create model from reader.
Returns:
:class:`psamm.datasource.native.NativeModel`.
"""
properties = {
'name': self.name,
'default_flux_limit': 1000
}
# Load objective as biomass reaction
objective = se... | python | def create_model(self):
"""Create model from reader.
Returns:
:class:`psamm.datasource.native.NativeModel`.
"""
properties = {
'name': self.name,
'default_flux_limit': 1000
}
# Load objective as biomass reaction
objective = se... | [
"def",
"create_model",
"(",
"self",
")",
":",
"properties",
"=",
"{",
"'name'",
":",
"self",
".",
"name",
",",
"'default_flux_limit'",
":",
"1000",
"}",
"# Load objective as biomass reaction",
"objective",
"=",
"self",
".",
"get_active_objective",
"(",
")",
"if"... | Create model from reader.
Returns:
:class:`psamm.datasource.native.NativeModel`. | [
"Create",
"model",
"from",
"reader",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/sbml.py#L797-L880 |
48,418 | zhanglab/psamm | psamm/datasource/sbml.py | SBMLWriter._make_safe_id | def _make_safe_id(self, id):
"""Returns a modified id that has been made safe for SBML.
Replaces or deletes the ones that aren't allowed.
"""
substitutions = {
'-': '_DASH_',
'/': '_FSLASH_',
'\\': '_BSLASH_',
'(': '_LPAREN_',
... | python | def _make_safe_id(self, id):
"""Returns a modified id that has been made safe for SBML.
Replaces or deletes the ones that aren't allowed.
"""
substitutions = {
'-': '_DASH_',
'/': '_FSLASH_',
'\\': '_BSLASH_',
'(': '_LPAREN_',
... | [
"def",
"_make_safe_id",
"(",
"self",
",",
"id",
")",
":",
"substitutions",
"=",
"{",
"'-'",
":",
"'_DASH_'",
",",
"'/'",
":",
"'_FSLASH_'",
",",
"'\\\\'",
":",
"'_BSLASH_'",
",",
"'('",
":",
"'_LPAREN_'",
",",
"')'",
":",
"'_RPAREN_'",
",",
"'['",
":",... | Returns a modified id that has been made safe for SBML.
Replaces or deletes the ones that aren't allowed. | [
"Returns",
"a",
"modified",
"id",
"that",
"has",
"been",
"made",
"safe",
"for",
"SBML",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/sbml.py#L891-L914 |
48,419 | zhanglab/psamm | psamm/datasource/sbml.py | SBMLWriter._get_flux_bounds | def _get_flux_bounds(self, r_id, model, flux_limits, equation):
"""Read reaction's limits to set up strings for limits in the output file.
"""
if r_id not in flux_limits or flux_limits[r_id][0] is None:
if equation.direction == Direction.Forward:
lower = 0
... | python | def _get_flux_bounds(self, r_id, model, flux_limits, equation):
"""Read reaction's limits to set up strings for limits in the output file.
"""
if r_id not in flux_limits or flux_limits[r_id][0] is None:
if equation.direction == Direction.Forward:
lower = 0
... | [
"def",
"_get_flux_bounds",
"(",
"self",
",",
"r_id",
",",
"model",
",",
"flux_limits",
",",
"equation",
")",
":",
"if",
"r_id",
"not",
"in",
"flux_limits",
"or",
"flux_limits",
"[",
"r_id",
"]",
"[",
"0",
"]",
"is",
"None",
":",
"if",
"equation",
".",
... | Read reaction's limits to set up strings for limits in the output file. | [
"Read",
"reaction",
"s",
"limits",
"to",
"set",
"up",
"strings",
"for",
"limits",
"in",
"the",
"output",
"file",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/sbml.py#L916-L939 |
48,420 | zhanglab/psamm | psamm/datasource/sbml.py | SBMLWriter._add_gene_associations | def _add_gene_associations(self, r_id, r_genes, gene_ids, r_tag):
"""Adds all the different kinds of genes into a list."""
genes = ET.SubElement(
r_tag, _tag('geneProductAssociation', FBC_V2))
if isinstance(r_genes, list):
e = Expression(And(*(Variable(i) for i in r_genes... | python | def _add_gene_associations(self, r_id, r_genes, gene_ids, r_tag):
"""Adds all the different kinds of genes into a list."""
genes = ET.SubElement(
r_tag, _tag('geneProductAssociation', FBC_V2))
if isinstance(r_genes, list):
e = Expression(And(*(Variable(i) for i in r_genes... | [
"def",
"_add_gene_associations",
"(",
"self",
",",
"r_id",
",",
"r_genes",
",",
"gene_ids",
",",
"r_tag",
")",
":",
"genes",
"=",
"ET",
".",
"SubElement",
"(",
"r_tag",
",",
"_tag",
"(",
"'geneProductAssociation'",
",",
"FBC_V2",
")",
")",
"if",
"isinstanc... | Adds all the different kinds of genes into a list. | [
"Adds",
"all",
"the",
"different",
"kinds",
"of",
"genes",
"into",
"a",
"list",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/sbml.py#L944-L969 |
48,421 | zhanglab/psamm | psamm/datasource/sbml.py | SBMLWriter._add_gene_list | def _add_gene_list(self, parent_tag, gene_id_dict):
"""Create list of all gene products as sbml readable elements."""
list_all_genes = ET.SubElement(parent_tag, _tag(
'listOfGeneProducts', FBC_V2))
for id, label in sorted(iteritems(gene_id_dict)):
gene_tag = ET.SubElement... | python | def _add_gene_list(self, parent_tag, gene_id_dict):
"""Create list of all gene products as sbml readable elements."""
list_all_genes = ET.SubElement(parent_tag, _tag(
'listOfGeneProducts', FBC_V2))
for id, label in sorted(iteritems(gene_id_dict)):
gene_tag = ET.SubElement... | [
"def",
"_add_gene_list",
"(",
"self",
",",
"parent_tag",
",",
"gene_id_dict",
")",
":",
"list_all_genes",
"=",
"ET",
".",
"SubElement",
"(",
"parent_tag",
",",
"_tag",
"(",
"'listOfGeneProducts'",
",",
"FBC_V2",
")",
")",
"for",
"id",
",",
"label",
"in",
"... | Create list of all gene products as sbml readable elements. | [
"Create",
"list",
"of",
"all",
"gene",
"products",
"as",
"sbml",
"readable",
"elements",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/sbml.py#L987-L995 |
48,422 | hearsaycorp/normalize | normalize/record/json.py | JsonRecord.json_to_initkwargs | def json_to_initkwargs(self, json_data, kwargs):
"""Subclassing hook to specialize how JSON data is converted
to keyword arguments"""
if isinstance(json_data, basestring):
json_data = json.loads(json_data)
return json_to_initkwargs(self, json_data, kwargs) | python | def json_to_initkwargs(self, json_data, kwargs):
"""Subclassing hook to specialize how JSON data is converted
to keyword arguments"""
if isinstance(json_data, basestring):
json_data = json.loads(json_data)
return json_to_initkwargs(self, json_data, kwargs) | [
"def",
"json_to_initkwargs",
"(",
"self",
",",
"json_data",
",",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"json_data",
",",
"basestring",
")",
":",
"json_data",
"=",
"json",
".",
"loads",
"(",
"json_data",
")",
"return",
"json_to_initkwargs",
"(",
"self"... | Subclassing hook to specialize how JSON data is converted
to keyword arguments | [
"Subclassing",
"hook",
"to",
"specialize",
"how",
"JSON",
"data",
"is",
"converted",
"to",
"keyword",
"arguments"
] | 8b36522ddca6d41b434580bd848f3bdaa7a999c8 | https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/record/json.py#L291-L296 |
48,423 | merll/docker-fabric | dockerfabric/utils/users.py | get_group_id | def get_group_id(groupname):
"""
Returns the group id to a given group name. Returns ``None`` if the group does not exist.
:param groupname: Group name.
:type groupname: unicode
:return: Group id.
:rtype: int
"""
gid = single_line_stdout('id -g {0}'.format(groupname), expected_errors=(1... | python | def get_group_id(groupname):
"""
Returns the group id to a given group name. Returns ``None`` if the group does not exist.
:param groupname: Group name.
:type groupname: unicode
:return: Group id.
:rtype: int
"""
gid = single_line_stdout('id -g {0}'.format(groupname), expected_errors=(1... | [
"def",
"get_group_id",
"(",
"groupname",
")",
":",
"gid",
"=",
"single_line_stdout",
"(",
"'id -g {0}'",
".",
"format",
"(",
"groupname",
")",
",",
"expected_errors",
"=",
"(",
"1",
",",
")",
",",
"shell",
"=",
"False",
")",
"return",
"check_int",
"(",
"... | Returns the group id to a given group name. Returns ``None`` if the group does not exist.
:param groupname: Group name.
:type groupname: unicode
:return: Group id.
:rtype: int | [
"Returns",
"the",
"group",
"id",
"to",
"a",
"given",
"group",
"name",
".",
"Returns",
"None",
"if",
"the",
"group",
"does",
"not",
"exist",
"."
] | 785d84e40e17265b667d8b11a6e30d8e6b2bf8d4 | https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/utils/users.py#L11-L21 |
48,424 | merll/docker-fabric | dockerfabric/utils/users.py | get_user_id | def get_user_id(username):
"""
Returns the user id to a given user name. Returns ``None`` if the user does not exist.
:param username: User name.
:type username: unicode
:return: User id.
:rtype: int
"""
uid = single_line_stdout('id -u {0}'.format(username), expected_errors=(1,), shell=... | python | def get_user_id(username):
"""
Returns the user id to a given user name. Returns ``None`` if the user does not exist.
:param username: User name.
:type username: unicode
:return: User id.
:rtype: int
"""
uid = single_line_stdout('id -u {0}'.format(username), expected_errors=(1,), shell=... | [
"def",
"get_user_id",
"(",
"username",
")",
":",
"uid",
"=",
"single_line_stdout",
"(",
"'id -u {0}'",
".",
"format",
"(",
"username",
")",
",",
"expected_errors",
"=",
"(",
"1",
",",
")",
",",
"shell",
"=",
"False",
")",
"return",
"check_int",
"(",
"uid... | Returns the user id to a given user name. Returns ``None`` if the user does not exist.
:param username: User name.
:type username: unicode
:return: User id.
:rtype: int | [
"Returns",
"the",
"user",
"id",
"to",
"a",
"given",
"user",
"name",
".",
"Returns",
"None",
"if",
"the",
"user",
"does",
"not",
"exist",
"."
] | 785d84e40e17265b667d8b11a6e30d8e6b2bf8d4 | https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/utils/users.py#L24-L34 |
48,425 | merll/docker-fabric | dockerfabric/utils/users.py | create_group | def create_group(groupname, gid, system=True):
"""
Creates a new user group with a specific id.
:param groupname: Group name.
:type groupname: unicode
:param gid: Group id.
:type gid: int or unicode
:param system: Creates a system group.
"""
sudo(addgroup(groupname, gid, system)) | python | def create_group(groupname, gid, system=True):
"""
Creates a new user group with a specific id.
:param groupname: Group name.
:type groupname: unicode
:param gid: Group id.
:type gid: int or unicode
:param system: Creates a system group.
"""
sudo(addgroup(groupname, gid, system)) | [
"def",
"create_group",
"(",
"groupname",
",",
"gid",
",",
"system",
"=",
"True",
")",
":",
"sudo",
"(",
"addgroup",
"(",
"groupname",
",",
"gid",
",",
"system",
")",
")"
] | Creates a new user group with a specific id.
:param groupname: Group name.
:type groupname: unicode
:param gid: Group id.
:type gid: int or unicode
:param system: Creates a system group. | [
"Creates",
"a",
"new",
"user",
"group",
"with",
"a",
"specific",
"id",
"."
] | 785d84e40e17265b667d8b11a6e30d8e6b2bf8d4 | https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/utils/users.py#L53-L63 |
48,426 | merll/docker-fabric | dockerfabric/utils/users.py | create_user | def create_user(username, uid, system=False, no_login=True, no_password=False, group=False, gecos=None):
"""
Creates a new user with a specific id.
:param username: User name.
:type username: unicode
:param uid: User id.
:type uid: int or unicode
:param system: Creates a system user.
:t... | python | def create_user(username, uid, system=False, no_login=True, no_password=False, group=False, gecos=None):
"""
Creates a new user with a specific id.
:param username: User name.
:type username: unicode
:param uid: User id.
:type uid: int or unicode
:param system: Creates a system user.
:t... | [
"def",
"create_user",
"(",
"username",
",",
"uid",
",",
"system",
"=",
"False",
",",
"no_login",
"=",
"True",
",",
"no_password",
"=",
"False",
",",
"group",
"=",
"False",
",",
"gecos",
"=",
"None",
")",
":",
"sudo",
"(",
"adduser",
"(",
"username",
... | Creates a new user with a specific id.
:param username: User name.
:type username: unicode
:param uid: User id.
:type uid: int or unicode
:param system: Creates a system user.
:type system: bool
:param no_login: Disallow login of this user and group, and skip creating the home directory. De... | [
"Creates",
"a",
"new",
"user",
"with",
"a",
"specific",
"id",
"."
] | 785d84e40e17265b667d8b11a6e30d8e6b2bf8d4 | https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/utils/users.py#L66-L85 |
48,427 | merll/docker-fabric | dockerfabric/utils/users.py | get_or_create_group | def get_or_create_group(groupname, gid_preset, system=False, id_dependent=True):
"""
Returns the id for the given group, and creates it first in case it does not exist.
:param groupname: Group name.
:type groupname: unicode
:param gid_preset: Group id to set if a new group is created.
:type gid... | python | def get_or_create_group(groupname, gid_preset, system=False, id_dependent=True):
"""
Returns the id for the given group, and creates it first in case it does not exist.
:param groupname: Group name.
:type groupname: unicode
:param gid_preset: Group id to set if a new group is created.
:type gid... | [
"def",
"get_or_create_group",
"(",
"groupname",
",",
"gid_preset",
",",
"system",
"=",
"False",
",",
"id_dependent",
"=",
"True",
")",
":",
"gid",
"=",
"get_group_id",
"(",
"groupname",
")",
"if",
"gid",
"is",
"None",
":",
"create_group",
"(",
"groupname",
... | Returns the id for the given group, and creates it first in case it does not exist.
:param groupname: Group name.
:type groupname: unicode
:param gid_preset: Group id to set if a new group is created.
:type gid_preset: int or unicode
:param system: Create a system group.
:type system: bool
... | [
"Returns",
"the",
"id",
"for",
"the",
"given",
"group",
"and",
"creates",
"it",
"first",
"in",
"case",
"it",
"does",
"not",
"exist",
"."
] | 785d84e40e17265b667d8b11a6e30d8e6b2bf8d4 | https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/utils/users.py#L101-L122 |
48,428 | merll/docker-fabric | dockerfabric/utils/users.py | get_or_create_user | def get_or_create_user(username, uid_preset, groupnames=[], system=False, no_password=False, no_login=True,
gecos=None, id_dependent=True):
"""
Returns the id of the given user name, and creates it first in case it does not exist. A default group is created
as well.
:param userna... | python | def get_or_create_user(username, uid_preset, groupnames=[], system=False, no_password=False, no_login=True,
gecos=None, id_dependent=True):
"""
Returns the id of the given user name, and creates it first in case it does not exist. A default group is created
as well.
:param userna... | [
"def",
"get_or_create_user",
"(",
"username",
",",
"uid_preset",
",",
"groupnames",
"=",
"[",
"]",
",",
"system",
"=",
"False",
",",
"no_password",
"=",
"False",
",",
"no_login",
"=",
"True",
",",
"gecos",
"=",
"None",
",",
"id_dependent",
"=",
"True",
"... | Returns the id of the given user name, and creates it first in case it does not exist. A default group is created
as well.
:param username: User name.
:type username: unicode
:param uid_preset: User id to set in case a new user is created.
:type uid_preset: int or unicode
:param groupnames: Add... | [
"Returns",
"the",
"id",
"of",
"the",
"given",
"user",
"name",
"and",
"creates",
"it",
"first",
"in",
"case",
"it",
"does",
"not",
"exist",
".",
"A",
"default",
"group",
"is",
"created",
"as",
"well",
"."
] | 785d84e40e17265b667d8b11a6e30d8e6b2bf8d4 | https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/utils/users.py#L125-L168 |
48,429 | zhanglab/psamm | psamm/datasource/kegg.py | parse_kegg_entries | def parse_kegg_entries(f, context=None):
"""Iterate over entries in KEGG file."""
section_id = None
entry_line = None
properties = {}
for lineno, line in enumerate(f):
if line.strip() == '///':
# End of entry
mark = FileMark(context, entry_line, 0)
yield ... | python | def parse_kegg_entries(f, context=None):
"""Iterate over entries in KEGG file."""
section_id = None
entry_line = None
properties = {}
for lineno, line in enumerate(f):
if line.strip() == '///':
# End of entry
mark = FileMark(context, entry_line, 0)
yield ... | [
"def",
"parse_kegg_entries",
"(",
"f",
",",
"context",
"=",
"None",
")",
":",
"section_id",
"=",
"None",
"entry_line",
"=",
"None",
"properties",
"=",
"{",
"}",
"for",
"lineno",
",",
"line",
"in",
"enumerate",
"(",
"f",
")",
":",
"if",
"line",
".",
"... | Iterate over entries in KEGG file. | [
"Iterate",
"over",
"entries",
"in",
"KEGG",
"file",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/kegg.py#L281-L308 |
48,430 | zhanglab/psamm | psamm/datasource/kegg.py | parse_reaction | def parse_reaction(s):
"""Parse a KEGG reaction string"""
def parse_count(s):
m = re.match(r'^\((.+)\)$', s)
if m is not None:
s = m.group(1)
m = re.match(r'^\d+$', s)
if m is not None:
return int(m.group(0))
return Expression(s)
def parse_... | python | def parse_reaction(s):
"""Parse a KEGG reaction string"""
def parse_count(s):
m = re.match(r'^\((.+)\)$', s)
if m is not None:
s = m.group(1)
m = re.match(r'^\d+$', s)
if m is not None:
return int(m.group(0))
return Expression(s)
def parse_... | [
"def",
"parse_reaction",
"(",
"s",
")",
":",
"def",
"parse_count",
"(",
"s",
")",
":",
"m",
"=",
"re",
".",
"match",
"(",
"r'^\\((.+)\\)$'",
",",
"s",
")",
"if",
"m",
"is",
"not",
"None",
":",
"s",
"=",
"m",
".",
"group",
"(",
"1",
")",
"m",
... | Parse a KEGG reaction string | [
"Parse",
"a",
"KEGG",
"reaction",
"string"
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/kegg.py#L323-L365 |
48,431 | merll/docker-fabric | dockerfabric/utils/output.py | stdout_result | def stdout_result(cmd, expected_errors=(), shell=True, sudo=False, quiet=False):
"""
Runs a command and returns the result, that would be written to `stdout`, as a string. The output itself can
be suppressed.
:param cmd: Command to run.
:type cmd: unicode
:param expected_errors: If the return c... | python | def stdout_result(cmd, expected_errors=(), shell=True, sudo=False, quiet=False):
"""
Runs a command and returns the result, that would be written to `stdout`, as a string. The output itself can
be suppressed.
:param cmd: Command to run.
:type cmd: unicode
:param expected_errors: If the return c... | [
"def",
"stdout_result",
"(",
"cmd",
",",
"expected_errors",
"=",
"(",
")",
",",
"shell",
"=",
"True",
",",
"sudo",
"=",
"False",
",",
"quiet",
"=",
"False",
")",
":",
"which",
"=",
"operations",
".",
"sudo",
"if",
"sudo",
"else",
"operations",
".",
"... | Runs a command and returns the result, that would be written to `stdout`, as a string. The output itself can
be suppressed.
:param cmd: Command to run.
:type cmd: unicode
:param expected_errors: If the return code is non-zero, but found in this tuple, it will be ignored. ``None`` is
returned in t... | [
"Runs",
"a",
"command",
"and",
"returns",
"the",
"result",
"that",
"would",
"be",
"written",
"to",
"stdout",
"as",
"a",
"string",
".",
"The",
"output",
"itself",
"can",
"be",
"suppressed",
"."
] | 785d84e40e17265b667d8b11a6e30d8e6b2bf8d4 | https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/utils/output.py#L9-L36 |
48,432 | merll/docker-fabric | dockerfabric/utils/output.py | single_line_stdout | def single_line_stdout(cmd, expected_errors=(), shell=True, sudo=False, quiet=False):
"""
Runs a command and returns the first line of the result, that would be written to `stdout`, as a string.
The output itself can be suppressed.
:param cmd: Command to run.
:type cmd: unicode
:param expected_... | python | def single_line_stdout(cmd, expected_errors=(), shell=True, sudo=False, quiet=False):
"""
Runs a command and returns the first line of the result, that would be written to `stdout`, as a string.
The output itself can be suppressed.
:param cmd: Command to run.
:type cmd: unicode
:param expected_... | [
"def",
"single_line_stdout",
"(",
"cmd",
",",
"expected_errors",
"=",
"(",
")",
",",
"shell",
"=",
"True",
",",
"sudo",
"=",
"False",
",",
"quiet",
"=",
"False",
")",
":",
"return",
"single_line",
"(",
"stdout_result",
"(",
"cmd",
",",
"expected_errors",
... | Runs a command and returns the first line of the result, that would be written to `stdout`, as a string.
The output itself can be suppressed.
:param cmd: Command to run.
:type cmd: unicode
:param expected_errors: If the return code is non-zero, but found in this tuple, it will be ignored. ``None`` is
... | [
"Runs",
"a",
"command",
"and",
"returns",
"the",
"first",
"line",
"of",
"the",
"result",
"that",
"would",
"be",
"written",
"to",
"stdout",
"as",
"a",
"string",
".",
"The",
"output",
"itself",
"can",
"be",
"suppressed",
"."
] | 785d84e40e17265b667d8b11a6e30d8e6b2bf8d4 | https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/utils/output.py#L60-L79 |
48,433 | zhanglab/psamm | psamm/commands/fastgapfill.py | FastGapFillCommand.run | def run(self):
"""Run FastGapFill command"""
# Create solver
solver = self._get_solver()
# Load compound information
def compound_name(id):
if id not in self._model.compounds:
return id
return self._model.compounds[id].properties.get('nam... | python | def run(self):
"""Run FastGapFill command"""
# Create solver
solver = self._get_solver()
# Load compound information
def compound_name(id):
if id not in self._model.compounds:
return id
return self._model.compounds[id].properties.get('nam... | [
"def",
"run",
"(",
"self",
")",
":",
"# Create solver",
"solver",
"=",
"self",
".",
"_get_solver",
"(",
")",
"# Load compound information",
"def",
"compound_name",
"(",
"id",
")",
":",
"if",
"id",
"not",
"in",
"self",
".",
"_model",
".",
"compounds",
":",
... | Run FastGapFill command | [
"Run",
"FastGapFill",
"command"
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/commands/fastgapfill.py#L55-L118 |
48,434 | zhanglab/psamm | psamm/moma.py | ConstraintGroup.add | def add(self, *args):
"""Add constraints to the model."""
self._constrs.extend(self._moma._prob.add_linear_constraints(*args)) | python | def add(self, *args):
"""Add constraints to the model."""
self._constrs.extend(self._moma._prob.add_linear_constraints(*args)) | [
"def",
"add",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"_constrs",
".",
"extend",
"(",
"self",
".",
"_moma",
".",
"_prob",
".",
"add_linear_constraints",
"(",
"*",
"args",
")",
")"
] | Add constraints to the model. | [
"Add",
"constraints",
"to",
"the",
"model",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/moma.py#L54-L56 |
48,435 | zhanglab/psamm | psamm/moma.py | MOMAProblem._adjustment_reactions | def _adjustment_reactions(self):
"""Yield all the non exchange reactions in the model."""
for reaction_id in self._model.reactions:
if not self._model.is_exchange(reaction_id):
yield reaction_id | python | def _adjustment_reactions(self):
"""Yield all the non exchange reactions in the model."""
for reaction_id in self._model.reactions:
if not self._model.is_exchange(reaction_id):
yield reaction_id | [
"def",
"_adjustment_reactions",
"(",
"self",
")",
":",
"for",
"reaction_id",
"in",
"self",
".",
"_model",
".",
"reactions",
":",
"if",
"not",
"self",
".",
"_model",
".",
"is_exchange",
"(",
"reaction_id",
")",
":",
"yield",
"reaction_id"
] | Yield all the non exchange reactions in the model. | [
"Yield",
"all",
"the",
"non",
"exchange",
"reactions",
"in",
"the",
"model",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/moma.py#L130-L134 |
48,436 | zhanglab/psamm | psamm/moma.py | MOMAProblem._solve | def _solve(self, sense=None):
"""Remove old constraints and then solve the current problem.
Args:
sense: Minimize or maximize the objective.
(:class:`.lp.ObjectiveSense)
Returns:
The Result object for the solved LP problem
"""
# Remove th... | python | def _solve(self, sense=None):
"""Remove old constraints and then solve the current problem.
Args:
sense: Minimize or maximize the objective.
(:class:`.lp.ObjectiveSense)
Returns:
The Result object for the solved LP problem
"""
# Remove th... | [
"def",
"_solve",
"(",
"self",
",",
"sense",
"=",
"None",
")",
":",
"# Remove the constraints from the last run",
"while",
"len",
"(",
"self",
".",
"_remove_constr",
")",
">",
"0",
":",
"self",
".",
"_remove_constr",
".",
"pop",
"(",
")",
".",
"delete",
"("... | Remove old constraints and then solve the current problem.
Args:
sense: Minimize or maximize the objective.
(:class:`.lp.ObjectiveSense)
Returns:
The Result object for the solved LP problem | [
"Remove",
"old",
"constraints",
"and",
"then",
"solve",
"the",
"current",
"problem",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/moma.py#L136-L155 |
48,437 | zhanglab/psamm | psamm/moma.py | MOMAProblem.solve_fba | def solve_fba(self, objective):
"""Solve the wild type problem using FBA.
Args:
objective: The objective reaction to be maximized.
Returns:
The LP Result object for the solved FBA problem.
"""
self._prob.set_objective(self._v_wt[objective])
retur... | python | def solve_fba(self, objective):
"""Solve the wild type problem using FBA.
Args:
objective: The objective reaction to be maximized.
Returns:
The LP Result object for the solved FBA problem.
"""
self._prob.set_objective(self._v_wt[objective])
retur... | [
"def",
"solve_fba",
"(",
"self",
",",
"objective",
")",
":",
"self",
".",
"_prob",
".",
"set_objective",
"(",
"self",
".",
"_v_wt",
"[",
"objective",
"]",
")",
"return",
"self",
".",
"_solve",
"(",
"lp",
".",
"ObjectiveSense",
".",
"Maximize",
")"
] | Solve the wild type problem using FBA.
Args:
objective: The objective reaction to be maximized.
Returns:
The LP Result object for the solved FBA problem. | [
"Solve",
"the",
"wild",
"type",
"problem",
"using",
"FBA",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/moma.py#L157-L167 |
48,438 | zhanglab/psamm | psamm/moma.py | MOMAProblem.get_fba_flux | def get_fba_flux(self, objective):
"""Return a dictionary of all the fluxes solved by FBA.
Dictionary of fluxes is used in :meth:`.lin_moma` and :meth:`.moma`
to minimize changes in the flux distributions following model
perturbation.
Args:
objective: The objective ... | python | def get_fba_flux(self, objective):
"""Return a dictionary of all the fluxes solved by FBA.
Dictionary of fluxes is used in :meth:`.lin_moma` and :meth:`.moma`
to minimize changes in the flux distributions following model
perturbation.
Args:
objective: The objective ... | [
"def",
"get_fba_flux",
"(",
"self",
",",
"objective",
")",
":",
"flux_result",
"=",
"self",
".",
"solve_fba",
"(",
"objective",
")",
"fba_fluxes",
"=",
"{",
"}",
"# Place all the flux values in a dictionary",
"for",
"key",
"in",
"self",
".",
"_model",
".",
"re... | Return a dictionary of all the fluxes solved by FBA.
Dictionary of fluxes is used in :meth:`.lin_moma` and :meth:`.moma`
to minimize changes in the flux distributions following model
perturbation.
Args:
objective: The objective reaction that is maximized.
Returns:
... | [
"Return",
"a",
"dictionary",
"of",
"all",
"the",
"fluxes",
"solved",
"by",
"FBA",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/moma.py#L169-L188 |
48,439 | zhanglab/psamm | psamm/moma.py | MOMAProblem.get_minimal_fba_flux | def get_minimal_fba_flux(self, objective):
"""Find the FBA solution that minimizes all the flux values.
Maximize the objective flux then minimize all other fluxes
while keeping the objective flux at the maximum.
Args:
objective: The objective reaction that is maximized.
... | python | def get_minimal_fba_flux(self, objective):
"""Find the FBA solution that minimizes all the flux values.
Maximize the objective flux then minimize all other fluxes
while keeping the objective flux at the maximum.
Args:
objective: The objective reaction that is maximized.
... | [
"def",
"get_minimal_fba_flux",
"(",
"self",
",",
"objective",
")",
":",
"# Define constraints",
"vs_wt",
"=",
"self",
".",
"_v_wt",
".",
"set",
"(",
"self",
".",
"_model",
".",
"reactions",
")",
"zs",
"=",
"self",
".",
"_z",
".",
"set",
"(",
"self",
".... | Find the FBA solution that minimizes all the flux values.
Maximize the objective flux then minimize all other fluxes
while keeping the objective flux at the maximum.
Args:
objective: The objective reaction that is maximized.
Returns:
A dictionary of all the rea... | [
"Find",
"the",
"FBA",
"solution",
"that",
"minimizes",
"all",
"the",
"flux",
"values",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/moma.py#L190-L218 |
48,440 | zhanglab/psamm | psamm/moma.py | MOMAProblem.get_fba_obj_flux | def get_fba_obj_flux(self, objective):
"""Return the maximum objective flux solved by FBA."""
flux_result = self.solve_fba(objective)
return flux_result.get_value(self._v_wt[objective]) | python | def get_fba_obj_flux(self, objective):
"""Return the maximum objective flux solved by FBA."""
flux_result = self.solve_fba(objective)
return flux_result.get_value(self._v_wt[objective]) | [
"def",
"get_fba_obj_flux",
"(",
"self",
",",
"objective",
")",
":",
"flux_result",
"=",
"self",
".",
"solve_fba",
"(",
"objective",
")",
"return",
"flux_result",
".",
"get_value",
"(",
"self",
".",
"_v_wt",
"[",
"objective",
"]",
")"
] | Return the maximum objective flux solved by FBA. | [
"Return",
"the",
"maximum",
"objective",
"flux",
"solved",
"by",
"FBA",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/moma.py#L220-L223 |
48,441 | zhanglab/psamm | psamm/moma.py | MOMAProblem.lin_moma | def lin_moma(self, wt_fluxes):
"""Minimize the redistribution of fluxes using a linear objective.
The change in flux distribution is mimimized by minimizing the sum
of the absolute values of the differences of wild type FBA solution
and the knockout strain flux solution.
This f... | python | def lin_moma(self, wt_fluxes):
"""Minimize the redistribution of fluxes using a linear objective.
The change in flux distribution is mimimized by minimizing the sum
of the absolute values of the differences of wild type FBA solution
and the knockout strain flux solution.
This f... | [
"def",
"lin_moma",
"(",
"self",
",",
"wt_fluxes",
")",
":",
"reactions",
"=",
"set",
"(",
"self",
".",
"_adjustment_reactions",
"(",
")",
")",
"z_diff",
"=",
"self",
".",
"_z_diff",
"v",
"=",
"self",
".",
"_v",
"with",
"self",
".",
"constraints",
"(",
... | Minimize the redistribution of fluxes using a linear objective.
The change in flux distribution is mimimized by minimizing the sum
of the absolute values of the differences of wild type FBA solution
and the knockout strain flux solution.
This formulation bases the solution on the wild ... | [
"Minimize",
"the",
"redistribution",
"of",
"fluxes",
"using",
"a",
"linear",
"objective",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/moma.py#L225-L261 |
48,442 | zhanglab/psamm | psamm/moma.py | MOMAProblem.lin_moma2 | def lin_moma2(self, objective, wt_obj):
"""Find the smallest redistribution vector using a linear objective.
The change in flux distribution is mimimized by minimizing the sum
of the absolute values of the differences of wild type FBA solution
and the knockout strain flux solution.
... | python | def lin_moma2(self, objective, wt_obj):
"""Find the smallest redistribution vector using a linear objective.
The change in flux distribution is mimimized by minimizing the sum
of the absolute values of the differences of wild type FBA solution
and the knockout strain flux solution.
... | [
"def",
"lin_moma2",
"(",
"self",
",",
"objective",
",",
"wt_obj",
")",
":",
"reactions",
"=",
"set",
"(",
"self",
".",
"_adjustment_reactions",
"(",
")",
")",
"z_diff",
"=",
"self",
".",
"_z_diff",
"v",
"=",
"self",
".",
"_v",
"v_wt",
"=",
"self",
".... | Find the smallest redistribution vector using a linear objective.
The change in flux distribution is mimimized by minimizing the sum
of the absolute values of the differences of wild type FBA solution
and the knockout strain flux solution.
Creates the constraint that the we select the ... | [
"Find",
"the",
"smallest",
"redistribution",
"vector",
"using",
"a",
"linear",
"objective",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/moma.py#L263-L301 |
48,443 | zhanglab/psamm | psamm/moma.py | MOMAProblem.moma | def moma(self, wt_fluxes):
"""Minimize the redistribution of fluxes using Euclidean distance.
Minimizing the redistribution of fluxes using a quadratic objective
function. The distance is minimized by minimizing the sum of
(wild type - knockout)^2.
Args:
wt_fluxes: ... | python | def moma(self, wt_fluxes):
"""Minimize the redistribution of fluxes using Euclidean distance.
Minimizing the redistribution of fluxes using a quadratic objective
function. The distance is minimized by minimizing the sum of
(wild type - knockout)^2.
Args:
wt_fluxes: ... | [
"def",
"moma",
"(",
"self",
",",
"wt_fluxes",
")",
":",
"reactions",
"=",
"set",
"(",
"self",
".",
"_adjustment_reactions",
"(",
")",
")",
"v",
"=",
"self",
".",
"_v",
"obj_expr",
"=",
"0",
"for",
"f_reaction",
",",
"f_value",
"in",
"iteritems",
"(",
... | Minimize the redistribution of fluxes using Euclidean distance.
Minimizing the redistribution of fluxes using a quadratic objective
function. The distance is minimized by minimizing the sum of
(wild type - knockout)^2.
Args:
wt_fluxes: Dictionary of all the wild type fluxes... | [
"Minimize",
"the",
"redistribution",
"of",
"fluxes",
"using",
"Euclidean",
"distance",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/moma.py#L303-L325 |
48,444 | zhanglab/psamm | psamm/moma.py | MOMAProblem.moma2 | def moma2(self, objective, wt_obj):
"""Find the smallest redistribution vector using Euclidean distance.
Minimizing the redistribution of fluxes using a quadratic objective
function. The distance is minimized by minimizing the sum of
(wild type - knockout)^2.
Creates the constr... | python | def moma2(self, objective, wt_obj):
"""Find the smallest redistribution vector using Euclidean distance.
Minimizing the redistribution of fluxes using a quadratic objective
function. The distance is minimized by minimizing the sum of
(wild type - knockout)^2.
Creates the constr... | [
"def",
"moma2",
"(",
"self",
",",
"objective",
",",
"wt_obj",
")",
":",
"obj_expr",
"=",
"0",
"for",
"reaction",
"in",
"self",
".",
"_adjustment_reactions",
"(",
")",
":",
"v_wt",
"=",
"self",
".",
"_v_wt",
"[",
"reaction",
"]",
"v",
"=",
"self",
"."... | Find the smallest redistribution vector using Euclidean distance.
Minimizing the redistribution of fluxes using a quadratic objective
function. The distance is minimized by minimizing the sum of
(wild type - knockout)^2.
Creates the constraint that the we select the optimal flux vector... | [
"Find",
"the",
"smallest",
"redistribution",
"vector",
"using",
"Euclidean",
"distance",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/moma.py#L327-L353 |
48,445 | wrongwaycn/ssdb-py | ssdb/connection.py | Connection.connect | def connect(self):
"""
Connects to the SSDB server if not already connected
"""
if self._sock:
return
try:
sock = self._connect()
except socket.error:
e = sys.exc_info()[1]
raise ConnectionError(self._error_message(e))
... | python | def connect(self):
"""
Connects to the SSDB server if not already connected
"""
if self._sock:
return
try:
sock = self._connect()
except socket.error:
e = sys.exc_info()[1]
raise ConnectionError(self._error_message(e))
... | [
"def",
"connect",
"(",
"self",
")",
":",
"if",
"self",
".",
"_sock",
":",
"return",
"try",
":",
"sock",
"=",
"self",
".",
"_connect",
"(",
")",
"except",
"socket",
".",
"error",
":",
"e",
"=",
"sys",
".",
"exc_info",
"(",
")",
"[",
"1",
"]",
"r... | Connects to the SSDB server if not already connected | [
"Connects",
"to",
"the",
"SSDB",
"server",
"if",
"not",
"already",
"connected"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/connection.py#L274-L297 |
48,446 | wrongwaycn/ssdb-py | ssdb/connection.py | Connection._connect | def _connect(self):
"""
Create a TCP socket connection
"""
# we want to mimic what socket.create_connection does to support
# ipv4/ipv6, but we want to set options prior to calling
# socket.connect()
err = None
for res in socket.getaddrinfo(self.host, self... | python | def _connect(self):
"""
Create a TCP socket connection
"""
# we want to mimic what socket.create_connection does to support
# ipv4/ipv6, but we want to set options prior to calling
# socket.connect()
err = None
for res in socket.getaddrinfo(self.host, self... | [
"def",
"_connect",
"(",
"self",
")",
":",
"# we want to mimic what socket.create_connection does to support",
"# ipv4/ipv6, but we want to set options prior to calling",
"# socket.connect()",
"err",
"=",
"None",
"for",
"res",
"in",
"socket",
".",
"getaddrinfo",
"(",
"self",
"... | Create a TCP socket connection | [
"Create",
"a",
"TCP",
"socket",
"connection"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/connection.py#L299-L336 |
48,447 | wrongwaycn/ssdb-py | ssdb/connection.py | Connection.disconnect | def disconnect(self):
"""
Disconnects from the SSDB server
"""
self._parser.on_disconnect()
if self._sock is None:
return
try:
self._sock.shutdown(socket.SHUT_RDWR)
self._sock.close()
except socket.error:
pass
... | python | def disconnect(self):
"""
Disconnects from the SSDB server
"""
self._parser.on_disconnect()
if self._sock is None:
return
try:
self._sock.shutdown(socket.SHUT_RDWR)
self._sock.close()
except socket.error:
pass
... | [
"def",
"disconnect",
"(",
"self",
")",
":",
"self",
".",
"_parser",
".",
"on_disconnect",
"(",
")",
"if",
"self",
".",
"_sock",
"is",
"None",
":",
"return",
"try",
":",
"self",
".",
"_sock",
".",
"shutdown",
"(",
"socket",
".",
"SHUT_RDWR",
")",
"sel... | Disconnects from the SSDB server | [
"Disconnects",
"from",
"the",
"SSDB",
"server"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/connection.py#L359-L371 |
48,448 | wrongwaycn/ssdb-py | ssdb/connection.py | Connection.pack_command | def pack_command(self, *args):
"""
Pack a series of arguments into a value SSDB command
"""
# the client might have included 1 or more literal arguments in
# the command name, e.g., 'CONFIG GET'. The SSDB server expects
# these arguments to be sent separately, so split th... | python | def pack_command(self, *args):
"""
Pack a series of arguments into a value SSDB command
"""
# the client might have included 1 or more literal arguments in
# the command name, e.g., 'CONFIG GET'. The SSDB server expects
# these arguments to be sent separately, so split th... | [
"def",
"pack_command",
"(",
"self",
",",
"*",
"args",
")",
":",
"# the client might have included 1 or more literal arguments in",
"# the command name, e.g., 'CONFIG GET'. The SSDB server expects",
"# these arguments to be sent separately, so split the first",
"# argument manually. All of th... | Pack a series of arguments into a value SSDB command | [
"Pack",
"a",
"series",
"of",
"arguments",
"into",
"a",
"value",
"SSDB",
"command"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/connection.py#L447-L470 |
48,449 | merll/docker-fabric | dockerfabric/yaml.py | expand_env_lazy | def expand_env_lazy(loader, node):
"""
Substitutes a variable read from a YAML node with the value stored in Fabric's ``env`` dictionary. Creates an
object for late resolution.
:param loader: YAML loader.
:type loader: yaml.loader.SafeLoader
:param node: Document node.
:type node: ScalarNod... | python | def expand_env_lazy(loader, node):
"""
Substitutes a variable read from a YAML node with the value stored in Fabric's ``env`` dictionary. Creates an
object for late resolution.
:param loader: YAML loader.
:type loader: yaml.loader.SafeLoader
:param node: Document node.
:type node: ScalarNod... | [
"def",
"expand_env_lazy",
"(",
"loader",
",",
"node",
")",
":",
"val",
"=",
"loader",
".",
"construct_scalar",
"(",
"node",
")",
"return",
"lazy_once",
"(",
"env_get",
",",
"val",
")"
] | Substitutes a variable read from a YAML node with the value stored in Fabric's ``env`` dictionary. Creates an
object for late resolution.
:param loader: YAML loader.
:type loader: yaml.loader.SafeLoader
:param node: Document node.
:type node: ScalarNode
:return: Corresponding value stored in th... | [
"Substitutes",
"a",
"variable",
"read",
"from",
"a",
"YAML",
"node",
"with",
"the",
"value",
"stored",
"in",
"Fabric",
"s",
"env",
"dictionary",
".",
"Creates",
"an",
"object",
"for",
"late",
"resolution",
"."
] | 785d84e40e17265b667d8b11a6e30d8e6b2bf8d4 | https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/yaml.py#L16-L29 |
48,450 | hearsaycorp/normalize | normalize/diff.py | compare_record_iter | def compare_record_iter(a, b, fs_a=None, fs_b=None, options=None):
"""This generator function compares a record, slot by slot, and yields
differences found as ``DiffInfo`` objects.
args:
``a=``\ *Record*
The base object
``b=``\ *Record*\ \|\ *object*
The 'other' ob... | python | def compare_record_iter(a, b, fs_a=None, fs_b=None, options=None):
"""This generator function compares a record, slot by slot, and yields
differences found as ``DiffInfo`` objects.
args:
``a=``\ *Record*
The base object
``b=``\ *Record*\ \|\ *object*
The 'other' ob... | [
"def",
"compare_record_iter",
"(",
"a",
",",
"b",
",",
"fs_a",
"=",
"None",
",",
"fs_b",
"=",
"None",
",",
"options",
"=",
"None",
")",
":",
"if",
"not",
"options",
":",
"options",
"=",
"DiffOptions",
"(",
")",
"if",
"not",
"options",
".",
"duck_type... | This generator function compares a record, slot by slot, and yields
differences found as ``DiffInfo`` objects.
args:
``a=``\ *Record*
The base object
``b=``\ *Record*\ \|\ *object*
The 'other' object, which must be the same type as ``a``, unless
``options.d... | [
"This",
"generator",
"function",
"compares",
"a",
"record",
"slot",
"by",
"slot",
"and",
"yields",
"differences",
"found",
"as",
"DiffInfo",
"objects",
"."
] | 8b36522ddca6d41b434580bd848f3bdaa7a999c8 | https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/diff.py#L359-L484 |
48,451 | hearsaycorp/normalize | normalize/diff.py | DiffOptions.normalize_whitespace | def normalize_whitespace(self, value):
"""Normalizes whitespace; called if ``ignore_ws`` is true."""
if isinstance(value, unicode):
return u" ".join(
x for x in re.split(r'\s+', value, flags=re.UNICODE) if
len(x)
)
else:
return ... | python | def normalize_whitespace(self, value):
"""Normalizes whitespace; called if ``ignore_ws`` is true."""
if isinstance(value, unicode):
return u" ".join(
x for x in re.split(r'\s+', value, flags=re.UNICODE) if
len(x)
)
else:
return ... | [
"def",
"normalize_whitespace",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"unicode",
")",
":",
"return",
"u\" \"",
".",
"join",
"(",
"x",
"for",
"x",
"in",
"re",
".",
"split",
"(",
"r'\\s+'",
",",
"value",
",",
"flags... | Normalizes whitespace; called if ``ignore_ws`` is true. | [
"Normalizes",
"whitespace",
";",
"called",
"if",
"ignore_ws",
"is",
"true",
"."
] | 8b36522ddca6d41b434580bd848f3bdaa7a999c8 | https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/diff.py#L214-L222 |
48,452 | hearsaycorp/normalize | normalize/diff.py | DiffOptions.normalize_val | def normalize_val(self, value=_nothing):
"""Hook which is called on every value before comparison, and should
return the scrubbed value or ``self._nothing`` to indicate that the
value is not set.
"""
if isinstance(value, basestring):
value = self.normalize_text(value)... | python | def normalize_val(self, value=_nothing):
"""Hook which is called on every value before comparison, and should
return the scrubbed value or ``self._nothing`` to indicate that the
value is not set.
"""
if isinstance(value, basestring):
value = self.normalize_text(value)... | [
"def",
"normalize_val",
"(",
"self",
",",
"value",
"=",
"_nothing",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"basestring",
")",
":",
"value",
"=",
"self",
".",
"normalize_text",
"(",
"value",
")",
"if",
"self",
".",
"ignore_empty_slots",
"and",
"... | Hook which is called on every value before comparison, and should
return the scrubbed value or ``self._nothing`` to indicate that the
value is not set. | [
"Hook",
"which",
"is",
"called",
"on",
"every",
"value",
"before",
"comparison",
"and",
"should",
"return",
"the",
"scrubbed",
"value",
"or",
"self",
".",
"_nothing",
"to",
"indicate",
"that",
"the",
"value",
"is",
"not",
"set",
"."
] | 8b36522ddca6d41b434580bd848f3bdaa7a999c8 | https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/diff.py#L260-L269 |
48,453 | hearsaycorp/normalize | normalize/diff.py | DiffOptions.normalize_object_slot | def normalize_object_slot(self, value=_nothing, prop=None, obj=None):
"""This hook wraps ``normalize_slot``, and performs clean-ups which
require access to the object the slot is in as well as the value.
"""
if value is not _nothing and hasattr(prop, "compare_as"):
method, na... | python | def normalize_object_slot(self, value=_nothing, prop=None, obj=None):
"""This hook wraps ``normalize_slot``, and performs clean-ups which
require access to the object the slot is in as well as the value.
"""
if value is not _nothing and hasattr(prop, "compare_as"):
method, na... | [
"def",
"normalize_object_slot",
"(",
"self",
",",
"value",
"=",
"_nothing",
",",
"prop",
"=",
"None",
",",
"obj",
"=",
"None",
")",
":",
"if",
"value",
"is",
"not",
"_nothing",
"and",
"hasattr",
"(",
"prop",
",",
"\"compare_as\"",
")",
":",
"method",
"... | This hook wraps ``normalize_slot``, and performs clean-ups which
require access to the object the slot is in as well as the value. | [
"This",
"hook",
"wraps",
"normalize_slot",
"and",
"performs",
"clean",
"-",
"ups",
"which",
"require",
"access",
"to",
"the",
"object",
"the",
"slot",
"is",
"in",
"as",
"well",
"as",
"the",
"value",
"."
] | 8b36522ddca6d41b434580bd848f3bdaa7a999c8 | https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/diff.py#L290-L302 |
48,454 | hearsaycorp/normalize | normalize/diff.py | DiffOptions.record_id | def record_id(self, record, type_=None, selector=None):
"""Retrieve an object identifier from the given record; if it is an
alien class, and the type is provided, then use duck typing to get the
corresponding fields of the alien class."""
pk = record_id(record, type_, selector, self.norm... | python | def record_id(self, record, type_=None, selector=None):
"""Retrieve an object identifier from the given record; if it is an
alien class, and the type is provided, then use duck typing to get the
corresponding fields of the alien class."""
pk = record_id(record, type_, selector, self.norm... | [
"def",
"record_id",
"(",
"self",
",",
"record",
",",
"type_",
"=",
"None",
",",
"selector",
"=",
"None",
")",
":",
"pk",
"=",
"record_id",
"(",
"record",
",",
"type_",
",",
"selector",
",",
"self",
".",
"normalize_object_slot",
")",
"return",
"pk"
] | Retrieve an object identifier from the given record; if it is an
alien class, and the type is provided, then use duck typing to get the
corresponding fields of the alien class. | [
"Retrieve",
"an",
"object",
"identifier",
"from",
"the",
"given",
"record",
";",
"if",
"it",
"is",
"an",
"alien",
"class",
"and",
"the",
"type",
"is",
"provided",
"then",
"use",
"duck",
"typing",
"to",
"get",
"the",
"corresponding",
"fields",
"of",
"the",
... | 8b36522ddca6d41b434580bd848f3bdaa7a999c8 | https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/diff.py#L327-L332 |
48,455 | zhanglab/psamm | psamm/fastcore.py | fastcc | def fastcc(model, epsilon, solver):
"""Check consistency of model reactions.
Yield all reactions in the model that are not part of the consistent
subset.
Args:
model: :class:`MetabolicModel` to solve.
epsilon: Flux threshold value.
solver: LP solver instance to use.
"""
... | python | def fastcc(model, epsilon, solver):
"""Check consistency of model reactions.
Yield all reactions in the model that are not part of the consistent
subset.
Args:
model: :class:`MetabolicModel` to solve.
epsilon: Flux threshold value.
solver: LP solver instance to use.
"""
... | [
"def",
"fastcc",
"(",
"model",
",",
"epsilon",
",",
"solver",
")",
":",
"reaction_set",
"=",
"set",
"(",
"model",
".",
"reactions",
")",
"subset",
"=",
"set",
"(",
"reaction_id",
"for",
"reaction_id",
"in",
"reaction_set",
"if",
"model",
".",
"limits",
"... | Check consistency of model reactions.
Yield all reactions in the model that are not part of the consistent
subset.
Args:
model: :class:`MetabolicModel` to solve.
epsilon: Flux threshold value.
solver: LP solver instance to use. | [
"Check",
"consistency",
"of",
"model",
"reactions",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fastcore.py#L160-L242 |
48,456 | zhanglab/psamm | psamm/fastcore.py | fastcc_is_consistent | def fastcc_is_consistent(model, epsilon, solver):
"""Quickly check whether model is consistent
Return true if the model is consistent. If it is only necessary to know
whether a model is consistent, this function is fast as it will return
the result as soon as it finds a single inconsistent reaction.
... | python | def fastcc_is_consistent(model, epsilon, solver):
"""Quickly check whether model is consistent
Return true if the model is consistent. If it is only necessary to know
whether a model is consistent, this function is fast as it will return
the result as soon as it finds a single inconsistent reaction.
... | [
"def",
"fastcc_is_consistent",
"(",
"model",
",",
"epsilon",
",",
"solver",
")",
":",
"for",
"reaction",
"in",
"fastcc",
"(",
"model",
",",
"epsilon",
",",
"solver",
")",
":",
"return",
"False",
"return",
"True"
] | Quickly check whether model is consistent
Return true if the model is consistent. If it is only necessary to know
whether a model is consistent, this function is fast as it will return
the result as soon as it finds a single inconsistent reaction.
Args:
model: :class:`MetabolicModel` to solve.... | [
"Quickly",
"check",
"whether",
"model",
"is",
"consistent"
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fastcore.py#L245-L259 |
48,457 | zhanglab/psamm | psamm/fastcore.py | fastcc_consistent_subset | def fastcc_consistent_subset(model, epsilon, solver):
"""Return consistent subset of model.
The largest consistent subset is returned as
a set of reaction names.
Args:
model: :class:`MetabolicModel` to solve.
epsilon: Flux threshold value.
solver: LP solver instance to use.
... | python | def fastcc_consistent_subset(model, epsilon, solver):
"""Return consistent subset of model.
The largest consistent subset is returned as
a set of reaction names.
Args:
model: :class:`MetabolicModel` to solve.
epsilon: Flux threshold value.
solver: LP solver instance to use.
... | [
"def",
"fastcc_consistent_subset",
"(",
"model",
",",
"epsilon",
",",
"solver",
")",
":",
"reaction_set",
"=",
"set",
"(",
"model",
".",
"reactions",
")",
"return",
"reaction_set",
".",
"difference",
"(",
"fastcc",
"(",
"model",
",",
"epsilon",
",",
"solver"... | Return consistent subset of model.
The largest consistent subset is returned as
a set of reaction names.
Args:
model: :class:`MetabolicModel` to solve.
epsilon: Flux threshold value.
solver: LP solver instance to use.
Returns:
Set of reaction IDs in the consistent reac... | [
"Return",
"consistent",
"subset",
"of",
"model",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fastcore.py#L262-L277 |
48,458 | zhanglab/psamm | psamm/fastcore.py | fastcore | def fastcore(model, core, epsilon, solver, scaling=1e5, weights={}):
"""Find a flux consistent subnetwork containing the core subset.
The result will contain the core subset and as few of the additional
reactions as possible.
Args:
model: :class:`MetabolicModel` to solve.
core: Set of ... | python | def fastcore(model, core, epsilon, solver, scaling=1e5, weights={}):
"""Find a flux consistent subnetwork containing the core subset.
The result will contain the core subset and as few of the additional
reactions as possible.
Args:
model: :class:`MetabolicModel` to solve.
core: Set of ... | [
"def",
"fastcore",
"(",
"model",
",",
"core",
",",
"epsilon",
",",
"solver",
",",
"scaling",
"=",
"1e5",
",",
"weights",
"=",
"{",
"}",
")",
":",
"consistent_subset",
"=",
"set",
"(",
")",
"reaction_set",
"=",
"set",
"(",
"model",
".",
"reactions",
"... | Find a flux consistent subnetwork containing the core subset.
The result will contain the core subset and as few of the additional
reactions as possible.
Args:
model: :class:`MetabolicModel` to solve.
core: Set of core reaction IDs.
epsilon: Flux threshold value.
solver: LP... | [
"Find",
"a",
"flux",
"consistent",
"subnetwork",
"containing",
"the",
"core",
"subset",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fastcore.py#L280-L359 |
48,459 | zhanglab/psamm | psamm/fastcore.py | FastcoreProblem.lp7 | def lp7(self, reaction_subset):
"""Approximately maximize the number of reaction with flux.
This is similar to FBA but approximately maximizing the number of
reactions in subset with flux > epsilon, instead of just maximizing the
flux of one particular reaction. LP7 prefers "flux splitt... | python | def lp7(self, reaction_subset):
"""Approximately maximize the number of reaction with flux.
This is similar to FBA but approximately maximizing the number of
reactions in subset with flux > epsilon, instead of just maximizing the
flux of one particular reaction. LP7 prefers "flux splitt... | [
"def",
"lp7",
"(",
"self",
",",
"reaction_subset",
")",
":",
"if",
"self",
".",
"_zl",
"is",
"None",
":",
"self",
".",
"_add_maximization_vars",
"(",
")",
"positive",
"=",
"set",
"(",
"reaction_subset",
")",
"-",
"self",
".",
"_flipped",
"negative",
"=",... | Approximately maximize the number of reaction with flux.
This is similar to FBA but approximately maximizing the number of
reactions in subset with flux > epsilon, instead of just maximizing the
flux of one particular reaction. LP7 prefers "flux splitting" over
"flux concentrating". | [
"Approximately",
"maximize",
"the",
"number",
"of",
"reaction",
"with",
"flux",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fastcore.py#L60-L87 |
48,460 | zhanglab/psamm | psamm/fastcore.py | FastcoreProblem.lp10 | def lp10(self, subset_k, subset_p, weights={}):
"""Force reactions in K above epsilon while minimizing support of P.
This program forces reactions in subset K to attain flux > epsilon
while minimizing the sum of absolute flux values for reactions
in subset P (L1-regularization).
... | python | def lp10(self, subset_k, subset_p, weights={}):
"""Force reactions in K above epsilon while minimizing support of P.
This program forces reactions in subset K to attain flux > epsilon
while minimizing the sum of absolute flux values for reactions
in subset P (L1-regularization).
... | [
"def",
"lp10",
"(",
"self",
",",
"subset_k",
",",
"subset_p",
",",
"weights",
"=",
"{",
"}",
")",
":",
"if",
"self",
".",
"_z",
"is",
"None",
":",
"self",
".",
"_add_minimization_vars",
"(",
")",
"positive",
"=",
"set",
"(",
"subset_k",
")",
"-",
"... | Force reactions in K above epsilon while minimizing support of P.
This program forces reactions in subset K to attain flux > epsilon
while minimizing the sum of absolute flux values for reactions
in subset P (L1-regularization). | [
"Force",
"reactions",
"in",
"K",
"above",
"epsilon",
"while",
"minimizing",
"support",
"of",
"P",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fastcore.py#L89-L114 |
48,461 | zhanglab/psamm | psamm/fastcore.py | FastcoreProblem.find_sparse_mode | def find_sparse_mode(self, core, additional, scaling, weights={}):
"""Find a sparse mode containing reactions of the core subset.
Return an iterator of the support of a sparse mode that contains as
many reactions from core as possible, and as few reactions from
additional as possible (a... | python | def find_sparse_mode(self, core, additional, scaling, weights={}):
"""Find a sparse mode containing reactions of the core subset.
Return an iterator of the support of a sparse mode that contains as
many reactions from core as possible, and as few reactions from
additional as possible (a... | [
"def",
"find_sparse_mode",
"(",
"self",
",",
"core",
",",
"additional",
",",
"scaling",
",",
"weights",
"=",
"{",
"}",
")",
":",
"if",
"len",
"(",
"core",
")",
"==",
"0",
":",
"return",
"self",
".",
"lp7",
"(",
"core",
")",
"k",
"=",
"set",
"(",
... | Find a sparse mode containing reactions of the core subset.
Return an iterator of the support of a sparse mode that contains as
many reactions from core as possible, and as few reactions from
additional as possible (approximately). A dictionary of weights can be
supplied which gives fur... | [
"Find",
"a",
"sparse",
"mode",
"containing",
"reactions",
"of",
"the",
"core",
"subset",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fastcore.py#L116-L145 |
48,462 | zhanglab/psamm | psamm/fastcore.py | FastcoreProblem.flip | def flip(self, reactions):
"""Flip the specified reactions."""
for reaction in reactions:
if reaction in self._flipped:
self._flipped.remove(reaction)
else:
self._flipped.add(reaction) | python | def flip(self, reactions):
"""Flip the specified reactions."""
for reaction in reactions:
if reaction in self._flipped:
self._flipped.remove(reaction)
else:
self._flipped.add(reaction) | [
"def",
"flip",
"(",
"self",
",",
"reactions",
")",
":",
"for",
"reaction",
"in",
"reactions",
":",
"if",
"reaction",
"in",
"self",
".",
"_flipped",
":",
"self",
".",
"_flipped",
".",
"remove",
"(",
"reaction",
")",
"else",
":",
"self",
".",
"_flipped",... | Flip the specified reactions. | [
"Flip",
"the",
"specified",
"reactions",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fastcore.py#L147-L153 |
48,463 | zhanglab/psamm | psamm/findprimarypairs.py | _jaccard_similarity | def _jaccard_similarity(f1, f2, weight_func):
"""Calculate generalized Jaccard similarity of formulas.
Returns the weighted similarity value or None if there is no overlap
at all. If the union of the formulas has a weight of zero (i.e. the
denominator in the Jaccard similarity is zero), a value of zero... | python | def _jaccard_similarity(f1, f2, weight_func):
"""Calculate generalized Jaccard similarity of formulas.
Returns the weighted similarity value or None if there is no overlap
at all. If the union of the formulas has a weight of zero (i.e. the
denominator in the Jaccard similarity is zero), a value of zero... | [
"def",
"_jaccard_similarity",
"(",
"f1",
",",
"f2",
",",
"weight_func",
")",
":",
"elements",
"=",
"set",
"(",
"f1",
")",
"elements",
".",
"update",
"(",
"f2",
")",
"count",
",",
"w_count",
",",
"w_total",
"=",
"0",
",",
"0",
",",
"0",
"for",
"elem... | Calculate generalized Jaccard similarity of formulas.
Returns the weighted similarity value or None if there is no overlap
at all. If the union of the formulas has a weight of zero (i.e. the
denominator in the Jaccard similarity is zero), a value of zero is
returned. | [
"Calculate",
"generalized",
"Jaccard",
"similarity",
"of",
"formulas",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/findprimarypairs.py#L49-L72 |
48,464 | zhanglab/psamm | psamm/findprimarypairs.py | predict_compound_pairs_iterated | def predict_compound_pairs_iterated(
reactions, formulas, prior=(1, 43), max_iterations=None,
element_weight=element_weight):
"""Predict reaction pairs using iterated method.
Returns a tuple containing a dictionary of predictions keyed by the
reaction IDs, and the final number of iterations... | python | def predict_compound_pairs_iterated(
reactions, formulas, prior=(1, 43), max_iterations=None,
element_weight=element_weight):
"""Predict reaction pairs using iterated method.
Returns a tuple containing a dictionary of predictions keyed by the
reaction IDs, and the final number of iterations... | [
"def",
"predict_compound_pairs_iterated",
"(",
"reactions",
",",
"formulas",
",",
"prior",
"=",
"(",
"1",
",",
"43",
")",
",",
"max_iterations",
"=",
"None",
",",
"element_weight",
"=",
"element_weight",
")",
":",
"prior_alpha",
",",
"prior_beta",
"=",
"prior"... | Predict reaction pairs using iterated method.
Returns a tuple containing a dictionary of predictions keyed by the
reaction IDs, and the final number of iterations. Each reaction prediction
entry contains a tuple with a dictionary of transfers and a dictionary of
unbalanced compounds. The dictionary of ... | [
"Predict",
"reaction",
"pairs",
"using",
"iterated",
"method",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/findprimarypairs.py#L156-L247 |
48,465 | zhanglab/psamm | psamm/findprimarypairs.py | predict_compound_pairs | def predict_compound_pairs(reaction, compound_formula, pair_weights={},
weight_func=element_weight):
"""Predict compound pairs for a single reaction.
Performs greedy matching on reaction compounds using a scoring function
that uses generalized Jaccard similarity corrected by the ... | python | def predict_compound_pairs(reaction, compound_formula, pair_weights={},
weight_func=element_weight):
"""Predict compound pairs for a single reaction.
Performs greedy matching on reaction compounds using a scoring function
that uses generalized Jaccard similarity corrected by the ... | [
"def",
"predict_compound_pairs",
"(",
"reaction",
",",
"compound_formula",
",",
"pair_weights",
"=",
"{",
"}",
",",
"weight_func",
"=",
"element_weight",
")",
":",
"def",
"score_func",
"(",
"inst1",
",",
"inst2",
")",
":",
"score",
"=",
"_jaccard_similarity",
... | Predict compound pairs for a single reaction.
Performs greedy matching on reaction compounds using a scoring function
that uses generalized Jaccard similarity corrected by the weights in the
given dictionary. Returns a tuple of a transfer dictionary and a dictionary
of unbalanced compounds. The diction... | [
"Predict",
"compound",
"pairs",
"for",
"a",
"single",
"reaction",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/findprimarypairs.py#L366-L400 |
48,466 | juju-solutions/jujuresources | jujuresources/__init__.py | config_get | def config_get(option_name):
"""
Helper to access a Juju config option when charmhelpers is not available.
:param str option_name: Name of the config option to get the value of
"""
try:
raw = subprocess.check_output(['config-get', option_name, '--format=yaml'])
return yaml.load(raw.... | python | def config_get(option_name):
"""
Helper to access a Juju config option when charmhelpers is not available.
:param str option_name: Name of the config option to get the value of
"""
try:
raw = subprocess.check_output(['config-get', option_name, '--format=yaml'])
return yaml.load(raw.... | [
"def",
"config_get",
"(",
"option_name",
")",
":",
"try",
":",
"raw",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"'config-get'",
",",
"option_name",
",",
"'--format=yaml'",
"]",
")",
"return",
"yaml",
".",
"load",
"(",
"raw",
".",
"decode",
"(",
"... | Helper to access a Juju config option when charmhelpers is not available.
:param str option_name: Name of the config option to get the value of | [
"Helper",
"to",
"access",
"a",
"Juju",
"config",
"option",
"when",
"charmhelpers",
"is",
"not",
"available",
"."
] | 7d2c5f50981784cc4b5cde216b930f6d59c951a4 | https://github.com/juju-solutions/jujuresources/blob/7d2c5f50981784cc4b5cde216b930f6d59c951a4/jujuresources/__init__.py#L24-L34 |
48,467 | juju-solutions/jujuresources | jujuresources/__init__.py | fetch | def fetch(which=None, mirror_url=None, resources_yaml='resources.yaml',
force=False, reporthook=None):
"""
Attempt to fetch all resources for a charm.
:param list which: A name, or a list of one or more resource names, to
fetch. If ommitted, all non-optional resources are fetched.
... | python | def fetch(which=None, mirror_url=None, resources_yaml='resources.yaml',
force=False, reporthook=None):
"""
Attempt to fetch all resources for a charm.
:param list which: A name, or a list of one or more resource names, to
fetch. If ommitted, all non-optional resources are fetched.
... | [
"def",
"fetch",
"(",
"which",
"=",
"None",
",",
"mirror_url",
"=",
"None",
",",
"resources_yaml",
"=",
"'resources.yaml'",
",",
"force",
"=",
"False",
",",
"reporthook",
"=",
"None",
")",
":",
"resources",
"=",
"_load",
"(",
"resources_yaml",
",",
"None",
... | Attempt to fetch all resources for a charm.
:param list which: A name, or a list of one or more resource names, to
fetch. If ommitted, all non-optional resources are fetched.
You can also pass ``jujuresources.ALL`` to fetch all optional *and*
required resources.
:param str mirror_url: ... | [
"Attempt",
"to",
"fetch",
"all",
"resources",
"for",
"a",
"charm",
"."
] | 7d2c5f50981784cc4b5cde216b930f6d59c951a4 | https://github.com/juju-solutions/jujuresources/blob/7d2c5f50981784cc4b5cde216b930f6d59c951a4/jujuresources/__init__.py#L135-L167 |
48,468 | happyleavesaoc/python-limitlessled | limitlessled/group/__init__.py | rate | def rate(wait=MIN_WAIT, reps=REPS):
""" Rate limit a command function.
:param wait: How long to wait between commands.
:param reps: How many times to send a command.
:returns: Decorator.
"""
def decorator(function):
""" Decorator function.
:returns: Wrapper.
"""
... | python | def rate(wait=MIN_WAIT, reps=REPS):
""" Rate limit a command function.
:param wait: How long to wait between commands.
:param reps: How many times to send a command.
:returns: Decorator.
"""
def decorator(function):
""" Decorator function.
:returns: Wrapper.
"""
... | [
"def",
"rate",
"(",
"wait",
"=",
"MIN_WAIT",
",",
"reps",
"=",
"REPS",
")",
":",
"def",
"decorator",
"(",
"function",
")",
":",
"\"\"\" Decorator function.\n\n :returns: Wrapper.\n \"\"\"",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",... | Rate limit a command function.
:param wait: How long to wait between commands.
:param reps: How many times to send a command.
:returns: Decorator. | [
"Rate",
"limit",
"a",
"command",
"function",
"."
] | 70307c2bf8c91430a99579d2ad18b228ec7a8488 | https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/__init__.py#L13-L39 |
48,469 | happyleavesaoc/python-limitlessled | limitlessled/group/__init__.py | Group.on | def on(self, state):
""" Turn on or off.
:param state: True (on) or False (off).
"""
self._on = state
cmd = self.command_set.off()
if state:
cmd = self.command_set.on()
self.send(cmd) | python | def on(self, state):
""" Turn on or off.
:param state: True (on) or False (off).
"""
self._on = state
cmd = self.command_set.off()
if state:
cmd = self.command_set.on()
self.send(cmd) | [
"def",
"on",
"(",
"self",
",",
"state",
")",
":",
"self",
".",
"_on",
"=",
"state",
"cmd",
"=",
"self",
".",
"command_set",
".",
"off",
"(",
")",
"if",
"state",
":",
"cmd",
"=",
"self",
".",
"command_set",
".",
"on",
"(",
")",
"self",
".",
"sen... | Turn on or off.
:param state: True (on) or False (off). | [
"Turn",
"on",
"or",
"off",
"."
] | 70307c2bf8c91430a99579d2ad18b228ec7a8488 | https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/__init__.py#L77-L86 |
48,470 | happyleavesaoc/python-limitlessled | limitlessled/group/__init__.py | Group.flash | def flash(self, duration=0.0):
""" Flash a group.
:param duration: How quickly to flash (in seconds).
"""
for _ in range(2):
self.on = not self.on
time.sleep(duration) | python | def flash(self, duration=0.0):
""" Flash a group.
:param duration: How quickly to flash (in seconds).
"""
for _ in range(2):
self.on = not self.on
time.sleep(duration) | [
"def",
"flash",
"(",
"self",
",",
"duration",
"=",
"0.0",
")",
":",
"for",
"_",
"in",
"range",
"(",
"2",
")",
":",
"self",
".",
"on",
"=",
"not",
"self",
".",
"on",
"time",
".",
"sleep",
"(",
"duration",
")"
] | Flash a group.
:param duration: How quickly to flash (in seconds). | [
"Flash",
"a",
"group",
"."
] | 70307c2bf8c91430a99579d2ad18b228ec7a8488 | https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/__init__.py#L98-L105 |
48,471 | happyleavesaoc/python-limitlessled | limitlessled/group/__init__.py | Group.send | def send(self, cmd):
""" Send a command to the bridge.
:param cmd: List of command bytes.
"""
self._bridge.send(cmd, wait=self.wait, reps=self.reps) | python | def send(self, cmd):
""" Send a command to the bridge.
:param cmd: List of command bytes.
"""
self._bridge.send(cmd, wait=self.wait, reps=self.reps) | [
"def",
"send",
"(",
"self",
",",
"cmd",
")",
":",
"self",
".",
"_bridge",
".",
"send",
"(",
"cmd",
",",
"wait",
"=",
"self",
".",
"wait",
",",
"reps",
"=",
"self",
".",
"reps",
")"
] | Send a command to the bridge.
:param cmd: List of command bytes. | [
"Send",
"a",
"command",
"to",
"the",
"bridge",
"."
] | 70307c2bf8c91430a99579d2ad18b228ec7a8488 | https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/__init__.py#L107-L112 |
48,472 | happyleavesaoc/python-limitlessled | limitlessled/group/__init__.py | Group.enqueue | def enqueue(self, pipeline):
""" Start a pipeline.
:param pipeline: Start this pipeline.
"""
copied = Pipeline().append(pipeline)
copied.group = self
self._queue.put(copied) | python | def enqueue(self, pipeline):
""" Start a pipeline.
:param pipeline: Start this pipeline.
"""
copied = Pipeline().append(pipeline)
copied.group = self
self._queue.put(copied) | [
"def",
"enqueue",
"(",
"self",
",",
"pipeline",
")",
":",
"copied",
"=",
"Pipeline",
"(",
")",
".",
"append",
"(",
"pipeline",
")",
"copied",
".",
"group",
"=",
"self",
"self",
".",
"_queue",
".",
"put",
"(",
"copied",
")"
] | Start a pipeline.
:param pipeline: Start this pipeline. | [
"Start",
"a",
"pipeline",
"."
] | 70307c2bf8c91430a99579d2ad18b228ec7a8488 | https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/__init__.py#L114-L121 |
48,473 | happyleavesaoc/python-limitlessled | limitlessled/group/__init__.py | Group._wait | def _wait(self, duration, steps, commands):
""" Compute wait time.
:param duration: Total time (in seconds).
:param steps: Number of steps.
:param commands: Number of commands.
:returns: Wait in seconds.
"""
wait = ((duration - self.wait * self.reps * commands) /... | python | def _wait(self, duration, steps, commands):
""" Compute wait time.
:param duration: Total time (in seconds).
:param steps: Number of steps.
:param commands: Number of commands.
:returns: Wait in seconds.
"""
wait = ((duration - self.wait * self.reps * commands) /... | [
"def",
"_wait",
"(",
"self",
",",
"duration",
",",
"steps",
",",
"commands",
")",
":",
"wait",
"=",
"(",
"(",
"duration",
"-",
"self",
".",
"wait",
"*",
"self",
".",
"reps",
"*",
"commands",
")",
"/",
"steps",
")",
"-",
"(",
"self",
".",
"wait",
... | Compute wait time.
:param duration: Total time (in seconds).
:param steps: Number of steps.
:param commands: Number of commands.
:returns: Wait in seconds. | [
"Compute",
"wait",
"time",
"."
] | 70307c2bf8c91430a99579d2ad18b228ec7a8488 | https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/__init__.py#L127-L137 |
48,474 | juju-solutions/jujuresources | jujuresources/backend.py | Resource.get | def get(cls, name, definition, output_dir):
"""
Dispatch to the right subclass based on the definition.
"""
if 'url' in definition:
return URLResource(name, definition, output_dir)
elif 'pypi' in definition:
return PyPIResource(name, definition, output_dir... | python | def get(cls, name, definition, output_dir):
"""
Dispatch to the right subclass based on the definition.
"""
if 'url' in definition:
return URLResource(name, definition, output_dir)
elif 'pypi' in definition:
return PyPIResource(name, definition, output_dir... | [
"def",
"get",
"(",
"cls",
",",
"name",
",",
"definition",
",",
"output_dir",
")",
":",
"if",
"'url'",
"in",
"definition",
":",
"return",
"URLResource",
"(",
"name",
",",
"definition",
",",
"output_dir",
")",
"elif",
"'pypi'",
"in",
"definition",
":",
"re... | Dispatch to the right subclass based on the definition. | [
"Dispatch",
"to",
"the",
"right",
"subclass",
"based",
"on",
"the",
"definition",
"."
] | 7d2c5f50981784cc4b5cde216b930f6d59c951a4 | https://github.com/juju-solutions/jujuresources/blob/7d2c5f50981784cc4b5cde216b930f6d59c951a4/jujuresources/backend.py#L65-L74 |
48,475 | happyleavesaoc/python-limitlessled | limitlessled/pipeline.py | PipelineQueue.run | def run(self):
""" Run the pipeline queue.
The pipeline queue will run forever.
"""
while True:
self._event.clear()
self._queue.get().run(self._event) | python | def run(self):
""" Run the pipeline queue.
The pipeline queue will run forever.
"""
while True:
self._event.clear()
self._queue.get().run(self._event) | [
"def",
"run",
"(",
"self",
")",
":",
"while",
"True",
":",
"self",
".",
"_event",
".",
"clear",
"(",
")",
"self",
".",
"_queue",
".",
"get",
"(",
")",
".",
"run",
"(",
"self",
".",
"_event",
")"
] | Run the pipeline queue.
The pipeline queue will run forever. | [
"Run",
"the",
"pipeline",
"queue",
"."
] | 70307c2bf8c91430a99579d2ad18b228ec7a8488 | https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/pipeline.py#L25-L32 |
48,476 | happyleavesaoc/python-limitlessled | limitlessled/pipeline.py | Pipeline.run | def run(self, stop):
""" Run the pipeline.
:param stop: Stop event
"""
_LOGGER.info("Starting a new pipeline on group %s", self._group)
self._group.bridge.incr_active()
for i, stage in enumerate(self._pipe):
self._execute_stage(i, stage, stop)
_LOGGER... | python | def run(self, stop):
""" Run the pipeline.
:param stop: Stop event
"""
_LOGGER.info("Starting a new pipeline on group %s", self._group)
self._group.bridge.incr_active()
for i, stage in enumerate(self._pipe):
self._execute_stage(i, stage, stop)
_LOGGER... | [
"def",
"run",
"(",
"self",
",",
"stop",
")",
":",
"_LOGGER",
".",
"info",
"(",
"\"Starting a new pipeline on group %s\"",
",",
"self",
".",
"_group",
")",
"self",
".",
"_group",
".",
"bridge",
".",
"incr_active",
"(",
")",
"for",
"i",
",",
"stage",
"in",... | Run the pipeline.
:param stop: Stop event | [
"Run",
"the",
"pipeline",
"."
] | 70307c2bf8c91430a99579d2ad18b228ec7a8488 | https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/pipeline.py#L104-L114 |
48,477 | happyleavesaoc/python-limitlessled | limitlessled/pipeline.py | Pipeline.append | def append(self, pipeline):
""" Append a pipeline to this pipeline.
:param pipeline: Pipeline to append.
:returns: This pipeline.
"""
for stage in pipeline.pipe:
self._pipe.append(stage)
return self | python | def append(self, pipeline):
""" Append a pipeline to this pipeline.
:param pipeline: Pipeline to append.
:returns: This pipeline.
"""
for stage in pipeline.pipe:
self._pipe.append(stage)
return self | [
"def",
"append",
"(",
"self",
",",
"pipeline",
")",
":",
"for",
"stage",
"in",
"pipeline",
".",
"pipe",
":",
"self",
".",
"_pipe",
".",
"append",
"(",
"stage",
")",
"return",
"self"
] | Append a pipeline to this pipeline.
:param pipeline: Pipeline to append.
:returns: This pipeline. | [
"Append",
"a",
"pipeline",
"to",
"this",
"pipeline",
"."
] | 70307c2bf8c91430a99579d2ad18b228ec7a8488 | https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/pipeline.py#L116-L124 |
48,478 | happyleavesaoc/python-limitlessled | limitlessled/pipeline.py | Pipeline._add_stage | def _add_stage(self, name):
""" Add stage methods at runtime.
Stage methods all follow the same pattern.
:param name: Stage name.
"""
def stage_func(self, *args, **kwargs):
""" Stage function.
:param args: Positional arguments.
:param kwargs... | python | def _add_stage(self, name):
""" Add stage methods at runtime.
Stage methods all follow the same pattern.
:param name: Stage name.
"""
def stage_func(self, *args, **kwargs):
""" Stage function.
:param args: Positional arguments.
:param kwargs... | [
"def",
"_add_stage",
"(",
"self",
",",
"name",
")",
":",
"def",
"stage_func",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\" Stage function.\n\n :param args: Positional arguments.\n :param kwargs: Keyword arguments.\n ... | Add stage methods at runtime.
Stage methods all follow the same pattern.
:param name: Stage name. | [
"Add",
"stage",
"methods",
"at",
"runtime",
"."
] | 70307c2bf8c91430a99579d2ad18b228ec7a8488 | https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/pipeline.py#L126-L143 |
48,479 | happyleavesaoc/python-limitlessled | limitlessled/pipeline.py | Pipeline._execute_stage | def _execute_stage(self, index, stage, stop):
""" Execute a pipeline stage.
:param index: Stage index.
:param stage: Stage object.
"""
if stop.is_set():
_LOGGER.info("Stopped pipeline on group %s", self._group)
return
_LOGGER.info(" -> Running sta... | python | def _execute_stage(self, index, stage, stop):
""" Execute a pipeline stage.
:param index: Stage index.
:param stage: Stage object.
"""
if stop.is_set():
_LOGGER.info("Stopped pipeline on group %s", self._group)
return
_LOGGER.info(" -> Running sta... | [
"def",
"_execute_stage",
"(",
"self",
",",
"index",
",",
"stage",
",",
"stop",
")",
":",
"if",
"stop",
".",
"is_set",
"(",
")",
":",
"_LOGGER",
".",
"info",
"(",
"\"Stopped pipeline on group %s\"",
",",
"self",
".",
"_group",
")",
"return",
"_LOGGER",
".... | Execute a pipeline stage.
:param index: Stage index.
:param stage: Stage object. | [
"Execute",
"a",
"pipeline",
"stage",
"."
] | 70307c2bf8c91430a99579d2ad18b228ec7a8488 | https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/pipeline.py#L145-L198 |
48,480 | happyleavesaoc/python-limitlessled | limitlessled/pipeline.py | Pipeline._repeat | def _repeat(self, index, stage, stop):
""" Repeat a stage.
:param index: Stage index.
:param stage: Stage object to repeat.
:param iterations: Number of iterations (default infinite).
:param stages: Stages back to repeat (default 1).
"""
times = None
if '... | python | def _repeat(self, index, stage, stop):
""" Repeat a stage.
:param index: Stage index.
:param stage: Stage object to repeat.
:param iterations: Number of iterations (default infinite).
:param stages: Stages back to repeat (default 1).
"""
times = None
if '... | [
"def",
"_repeat",
"(",
"self",
",",
"index",
",",
"stage",
",",
"stop",
")",
":",
"times",
"=",
"None",
"if",
"'iterations'",
"in",
"stage",
".",
"kwargs",
":",
"times",
"=",
"stage",
".",
"kwargs",
"[",
"'iterations'",
"]",
"-",
"1",
"stages_back",
... | Repeat a stage.
:param index: Stage index.
:param stage: Stage object to repeat.
:param iterations: Number of iterations (default infinite).
:param stages: Stages back to repeat (default 1). | [
"Repeat",
"a",
"stage",
"."
] | 70307c2bf8c91430a99579d2ad18b228ec7a8488 | https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/pipeline.py#L200-L223 |
48,481 | happyleavesaoc/python-limitlessled | limitlessled/group/dimmer.py | DimmerGroup.brightness | def brightness(self, brightness):
""" Set the brightness.
:param brightness: Value to set (0.0-1.0).
"""
try:
cmd = self.command_set.brightness(brightness)
self.send(cmd)
self._brightness = brightness
except AttributeError:
self._s... | python | def brightness(self, brightness):
""" Set the brightness.
:param brightness: Value to set (0.0-1.0).
"""
try:
cmd = self.command_set.brightness(brightness)
self.send(cmd)
self._brightness = brightness
except AttributeError:
self._s... | [
"def",
"brightness",
"(",
"self",
",",
"brightness",
")",
":",
"try",
":",
"cmd",
"=",
"self",
".",
"command_set",
".",
"brightness",
"(",
"brightness",
")",
"self",
".",
"send",
"(",
"cmd",
")",
"self",
".",
"_brightness",
"=",
"brightness",
"except",
... | Set the brightness.
:param brightness: Value to set (0.0-1.0). | [
"Set",
"the",
"brightness",
"."
] | 70307c2bf8c91430a99579d2ad18b228ec7a8488 | https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/dimmer.py#L36-L48 |
48,482 | happyleavesaoc/python-limitlessled | limitlessled/group/dimmer.py | DimmerGroup._to_brightness | def _to_brightness(self, brightness):
""" Step to a given brightness.
:param brightness: Get to this brightness.
"""
self._to_value(self._brightness, brightness,
self.command_set.brightness_steps,
self._dimmer, self._brighter) | python | def _to_brightness(self, brightness):
""" Step to a given brightness.
:param brightness: Get to this brightness.
"""
self._to_value(self._brightness, brightness,
self.command_set.brightness_steps,
self._dimmer, self._brighter) | [
"def",
"_to_brightness",
"(",
"self",
",",
"brightness",
")",
":",
"self",
".",
"_to_value",
"(",
"self",
".",
"_brightness",
",",
"brightness",
",",
"self",
".",
"command_set",
".",
"brightness_steps",
",",
"self",
".",
"_dimmer",
",",
"self",
".",
"_brig... | Step to a given brightness.
:param brightness: Get to this brightness. | [
"Step",
"to",
"a",
"given",
"brightness",
"."
] | 70307c2bf8c91430a99579d2ad18b228ec7a8488 | https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/dimmer.py#L113-L120 |
48,483 | happyleavesaoc/python-limitlessled | limitlessled/group/dimmer.py | DimmerGroup._to_value | def _to_value(self, current, target, max_steps, step_down, step_up):
""" Step to a value
:param current: Current value.
:param target: Target value.
:param max_steps: Maximum number of steps.
:param step_down: Down function.
:param step_up: Up function.
"""
... | python | def _to_value(self, current, target, max_steps, step_down, step_up):
""" Step to a value
:param current: Current value.
:param target: Target value.
:param max_steps: Maximum number of steps.
:param step_down: Down function.
:param step_up: Up function.
"""
... | [
"def",
"_to_value",
"(",
"self",
",",
"current",
",",
"target",
",",
"max_steps",
",",
"step_down",
",",
"step_up",
")",
":",
"for",
"_",
"in",
"range",
"(",
"steps",
"(",
"current",
",",
"target",
",",
"max_steps",
")",
")",
":",
"if",
"(",
"current... | Step to a value
:param current: Current value.
:param target: Target value.
:param max_steps: Maximum number of steps.
:param step_down: Down function.
:param step_up: Up function. | [
"Step",
"to",
"a",
"value"
] | 70307c2bf8c91430a99579d2ad18b228ec7a8488 | https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/dimmer.py#L123-L136 |
48,484 | happyleavesaoc/python-limitlessled | limitlessled/group/dimmer.py | DimmerGroup._dimmest | def _dimmest(self):
""" Group brightness as dim as possible. """
for _ in range(steps(self.brightness, 0.0,
self.command_set.brightness_steps)):
self._dimmer() | python | def _dimmest(self):
""" Group brightness as dim as possible. """
for _ in range(steps(self.brightness, 0.0,
self.command_set.brightness_steps)):
self._dimmer() | [
"def",
"_dimmest",
"(",
"self",
")",
":",
"for",
"_",
"in",
"range",
"(",
"steps",
"(",
"self",
".",
"brightness",
",",
"0.0",
",",
"self",
".",
"command_set",
".",
"brightness_steps",
")",
")",
":",
"self",
".",
"_dimmer",
"(",
")"
] | Group brightness as dim as possible. | [
"Group",
"brightness",
"as",
"dim",
"as",
"possible",
"."
] | 70307c2bf8c91430a99579d2ad18b228ec7a8488 | https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/dimmer.py#L146-L150 |
48,485 | juicer/juicer | juicer/common/Cart.py | Cart.add_repo | def add_repo(self, repo_name, items):
"""
Build up repos
`name` - Name of this repo.
`items` - List of paths to rpm.
"""
juicer.utils.Log.log_debug("[CART:%s] Adding %s items to repo '%s'" % \
(self.cart_name, len(items), repo_name)... | python | def add_repo(self, repo_name, items):
"""
Build up repos
`name` - Name of this repo.
`items` - List of paths to rpm.
"""
juicer.utils.Log.log_debug("[CART:%s] Adding %s items to repo '%s'" % \
(self.cart_name, len(items), repo_name)... | [
"def",
"add_repo",
"(",
"self",
",",
"repo_name",
",",
"items",
")",
":",
"juicer",
".",
"utils",
".",
"Log",
".",
"log_debug",
"(",
"\"[CART:%s] Adding %s items to repo '%s'\"",
"%",
"(",
"self",
".",
"cart_name",
",",
"len",
"(",
"items",
")",
",",
"repo... | Build up repos
`name` - Name of this repo.
`items` - List of paths to rpm. | [
"Build",
"up",
"repos"
] | 0c9f0fd59e293d45df6b46e81f675d33221c600d | https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/common/Cart.py#L72-L91 |
48,486 | juicer/juicer | juicer/common/Cart.py | Cart.load | def load(self, json_file):
"""
Build a cart from a json file
"""
cart_file = os.path.join(CART_LOCATION, json_file)
try:
cart_body = juicer.utils.read_json_document(cart_file)
except IOError as e:
juicer.utils.Log.log_error('an error occured while ... | python | def load(self, json_file):
"""
Build a cart from a json file
"""
cart_file = os.path.join(CART_LOCATION, json_file)
try:
cart_body = juicer.utils.read_json_document(cart_file)
except IOError as e:
juicer.utils.Log.log_error('an error occured while ... | [
"def",
"load",
"(",
"self",
",",
"json_file",
")",
":",
"cart_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"CART_LOCATION",
",",
"json_file",
")",
"try",
":",
"cart_body",
"=",
"juicer",
".",
"utils",
".",
"read_json_document",
"(",
"cart_file",
")",... | Build a cart from a json file | [
"Build",
"a",
"cart",
"from",
"a",
"json",
"file"
] | 0c9f0fd59e293d45df6b46e81f675d33221c600d | https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/common/Cart.py#L99-L119 |
48,487 | juicer/juicer | juicer/common/Cart.py | Cart.sign_items | def sign_items(self, sign_with):
"""
Sign the items in the cart with a GPG key.
After everything is collected and signed all the cart items
are issued a refresh() to sync their is_signed attributes.
`sign_with` is a reference to the method that implements
juicer.common.... | python | def sign_items(self, sign_with):
"""
Sign the items in the cart with a GPG key.
After everything is collected and signed all the cart items
are issued a refresh() to sync their is_signed attributes.
`sign_with` is a reference to the method that implements
juicer.common.... | [
"def",
"sign_items",
"(",
"self",
",",
"sign_with",
")",
":",
"cart_items",
"=",
"self",
".",
"items",
"(",
")",
"item_paths",
"=",
"[",
"item",
".",
"path",
"for",
"item",
"in",
"cart_items",
"]",
"sign_with",
"(",
"item_paths",
")",
"for",
"item",
"i... | Sign the items in the cart with a GPG key.
After everything is collected and signed all the cart items
are issued a refresh() to sync their is_signed attributes.
`sign_with` is a reference to the method that implements
juicer.common.RpmSignPlugin. | [
"Sign",
"the",
"items",
"in",
"the",
"cart",
"with",
"a",
"GPG",
"key",
"."
] | 0c9f0fd59e293d45df6b46e81f675d33221c600d | https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/common/Cart.py#L138-L153 |
48,488 | juicer/juicer | juicer/common/Cart.py | Cart.sync_remotes | def sync_remotes(self, force=False):
"""
Pull down all non-local items and save them into remotes_storage.
"""
connectors = juicer.utils.get_login_info()[0]
for repo, items in self.iterrepos():
repoid = "%s-%s" % (repo, self.current_env)
for rpm in items:
... | python | def sync_remotes(self, force=False):
"""
Pull down all non-local items and save them into remotes_storage.
"""
connectors = juicer.utils.get_login_info()[0]
for repo, items in self.iterrepos():
repoid = "%s-%s" % (repo, self.current_env)
for rpm in items:
... | [
"def",
"sync_remotes",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"connectors",
"=",
"juicer",
".",
"utils",
".",
"get_login_info",
"(",
")",
"[",
"0",
"]",
"for",
"repo",
",",
"items",
"in",
"self",
".",
"iterrepos",
"(",
")",
":",
"repoid",... | Pull down all non-local items and save them into remotes_storage. | [
"Pull",
"down",
"all",
"non",
"-",
"local",
"items",
"and",
"save",
"them",
"into",
"remotes_storage",
"."
] | 0c9f0fd59e293d45df6b46e81f675d33221c600d | https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/common/Cart.py#L155-L167 |
48,489 | juicer/juicer | juicer/common/Cart.py | Cart.items | def items(self):
""" Build and return a list of all items in this cart """
cart_items = []
for repo, items in self.iterrepos():
cart_items.extend(items)
return cart_items | python | def items(self):
""" Build and return a list of all items in this cart """
cart_items = []
for repo, items in self.iterrepos():
cart_items.extend(items)
return cart_items | [
"def",
"items",
"(",
"self",
")",
":",
"cart_items",
"=",
"[",
"]",
"for",
"repo",
",",
"items",
"in",
"self",
".",
"iterrepos",
"(",
")",
":",
"cart_items",
".",
"extend",
"(",
"items",
")",
"return",
"cart_items"
] | Build and return a list of all items in this cart | [
"Build",
"and",
"return",
"a",
"list",
"of",
"all",
"items",
"in",
"this",
"cart"
] | 0c9f0fd59e293d45df6b46e81f675d33221c600d | https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/common/Cart.py#L184-L189 |
48,490 | juju-solutions/jujuresources | jujuresources/cli.py | arg | def arg(*args, **kwargs):
"""
Decorator to add args to subcommands.
"""
def _arg(f):
if not hasattr(f, '_subcommand_args'):
f._subcommand_args = []
f._subcommand_args.append((args, kwargs))
return f
return _arg | python | def arg(*args, **kwargs):
"""
Decorator to add args to subcommands.
"""
def _arg(f):
if not hasattr(f, '_subcommand_args'):
f._subcommand_args = []
f._subcommand_args.append((args, kwargs))
return f
return _arg | [
"def",
"arg",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"_arg",
"(",
"f",
")",
":",
"if",
"not",
"hasattr",
"(",
"f",
",",
"'_subcommand_args'",
")",
":",
"f",
".",
"_subcommand_args",
"=",
"[",
"]",
"f",
".",
"_subcommand_args",
... | Decorator to add args to subcommands. | [
"Decorator",
"to",
"add",
"args",
"to",
"subcommands",
"."
] | 7d2c5f50981784cc4b5cde216b930f6d59c951a4 | https://github.com/juju-solutions/jujuresources/blob/7d2c5f50981784cc4b5cde216b930f6d59c951a4/jujuresources/cli.py#L26-L35 |
48,491 | juju-solutions/jujuresources | jujuresources/cli.py | argset | def argset(name, *args, **kwargs):
"""
Decorator to add sets of required mutually exclusive args to subcommands.
"""
def _arg(f):
if not hasattr(f, '_subcommand_argsets'):
f._subcommand_argsets = {}
f._subcommand_argsets.setdefault(name, []).append((args, kwargs))
ret... | python | def argset(name, *args, **kwargs):
"""
Decorator to add sets of required mutually exclusive args to subcommands.
"""
def _arg(f):
if not hasattr(f, '_subcommand_argsets'):
f._subcommand_argsets = {}
f._subcommand_argsets.setdefault(name, []).append((args, kwargs))
ret... | [
"def",
"argset",
"(",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"_arg",
"(",
"f",
")",
":",
"if",
"not",
"hasattr",
"(",
"f",
",",
"'_subcommand_argsets'",
")",
":",
"f",
".",
"_subcommand_argsets",
"=",
"{",
"}",
"f",
"... | Decorator to add sets of required mutually exclusive args to subcommands. | [
"Decorator",
"to",
"add",
"sets",
"of",
"required",
"mutually",
"exclusive",
"args",
"to",
"subcommands",
"."
] | 7d2c5f50981784cc4b5cde216b930f6d59c951a4 | https://github.com/juju-solutions/jujuresources/blob/7d2c5f50981784cc4b5cde216b930f6d59c951a4/jujuresources/cli.py#L38-L47 |
48,492 | juju-solutions/jujuresources | jujuresources/cli.py | resources | def resources(argv=sys.argv[1:]):
"""
Juju CLI subcommand for dispatching resources subcommands.
"""
eps = iter_entry_points('jujuresources.subcommands')
ep_map = {ep.name: ep.load() for ep in eps}
parser = argparse.ArgumentParser()
if '--description' in argv:
print('Manage and mirr... | python | def resources(argv=sys.argv[1:]):
"""
Juju CLI subcommand for dispatching resources subcommands.
"""
eps = iter_entry_points('jujuresources.subcommands')
ep_map = {ep.name: ep.load() for ep in eps}
parser = argparse.ArgumentParser()
if '--description' in argv:
print('Manage and mirr... | [
"def",
"resources",
"(",
"argv",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
")",
":",
"eps",
"=",
"iter_entry_points",
"(",
"'jujuresources.subcommands'",
")",
"ep_map",
"=",
"{",
"ep",
".",
"name",
":",
"ep",
".",
"load",
"(",
")",
"for",
"ep",
... | Juju CLI subcommand for dispatching resources subcommands. | [
"Juju",
"CLI",
"subcommand",
"for",
"dispatching",
"resources",
"subcommands",
"."
] | 7d2c5f50981784cc4b5cde216b930f6d59c951a4 | https://github.com/juju-solutions/jujuresources/blob/7d2c5f50981784cc4b5cde216b930f6d59c951a4/jujuresources/cli.py#L54-L87 |
48,493 | juju-solutions/jujuresources | jujuresources/cli.py | fetch | def fetch(opts):
"""
Create a local mirror of one or more resources.
"""
resources = _load(opts.resources, opts.output_dir)
if opts.all:
opts.resource_names = ALL
reporthook = None if opts.quiet else lambda name: print('Fetching {}...'.format(name))
if opts.verbose:
backend.V... | python | def fetch(opts):
"""
Create a local mirror of one or more resources.
"""
resources = _load(opts.resources, opts.output_dir)
if opts.all:
opts.resource_names = ALL
reporthook = None if opts.quiet else lambda name: print('Fetching {}...'.format(name))
if opts.verbose:
backend.V... | [
"def",
"fetch",
"(",
"opts",
")",
":",
"resources",
"=",
"_load",
"(",
"opts",
".",
"resources",
",",
"opts",
".",
"output_dir",
")",
"if",
"opts",
".",
"all",
":",
"opts",
".",
"resource_names",
"=",
"ALL",
"reporthook",
"=",
"None",
"if",
"opts",
"... | Create a local mirror of one or more resources. | [
"Create",
"a",
"local",
"mirror",
"of",
"one",
"or",
"more",
"resources",
"."
] | 7d2c5f50981784cc4b5cde216b930f6d59c951a4 | https://github.com/juju-solutions/jujuresources/blob/7d2c5f50981784cc4b5cde216b930f6d59c951a4/jujuresources/cli.py#L107-L118 |
48,494 | juju-solutions/jujuresources | jujuresources/cli.py | verify | def verify(opts):
"""
Verify that one or more resources were downloaded successfully.
"""
resources = _load(opts.resources, opts.output_dir)
if opts.all:
opts.resource_names = ALL
invalid = _invalid(resources, opts.resource_names)
if not invalid:
if not opts.quiet:
... | python | def verify(opts):
"""
Verify that one or more resources were downloaded successfully.
"""
resources = _load(opts.resources, opts.output_dir)
if opts.all:
opts.resource_names = ALL
invalid = _invalid(resources, opts.resource_names)
if not invalid:
if not opts.quiet:
... | [
"def",
"verify",
"(",
"opts",
")",
":",
"resources",
"=",
"_load",
"(",
"opts",
".",
"resources",
",",
"opts",
".",
"output_dir",
")",
"if",
"opts",
".",
"all",
":",
"opts",
".",
"resource_names",
"=",
"ALL",
"invalid",
"=",
"_invalid",
"(",
"resources... | Verify that one or more resources were downloaded successfully. | [
"Verify",
"that",
"one",
"or",
"more",
"resources",
"were",
"downloaded",
"successfully",
"."
] | 7d2c5f50981784cc4b5cde216b930f6d59c951a4 | https://github.com/juju-solutions/jujuresources/blob/7d2c5f50981784cc4b5cde216b930f6d59c951a4/jujuresources/cli.py#L132-L147 |
48,495 | juju-solutions/jujuresources | jujuresources/cli.py | resource_path | def resource_path(opts):
"""
Return the full path to a named resource.
"""
resources = _load(opts.resources, opts.output_dir)
if opts.resource_name not in resources:
sys.stderr.write('Invalid resource name: {}\n'.format(opts.resource_name))
return 1
print(resources[opts.resource_... | python | def resource_path(opts):
"""
Return the full path to a named resource.
"""
resources = _load(opts.resources, opts.output_dir)
if opts.resource_name not in resources:
sys.stderr.write('Invalid resource name: {}\n'.format(opts.resource_name))
return 1
print(resources[opts.resource_... | [
"def",
"resource_path",
"(",
"opts",
")",
":",
"resources",
"=",
"_load",
"(",
"opts",
".",
"resources",
",",
"opts",
".",
"output_dir",
")",
"if",
"opts",
".",
"resource_name",
"not",
"in",
"resources",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"'... | Return the full path to a named resource. | [
"Return",
"the",
"full",
"path",
"to",
"a",
"named",
"resource",
"."
] | 7d2c5f50981784cc4b5cde216b930f6d59c951a4 | https://github.com/juju-solutions/jujuresources/blob/7d2c5f50981784cc4b5cde216b930f6d59c951a4/jujuresources/cli.py#L192-L200 |
48,496 | juju-solutions/jujuresources | jujuresources/cli.py | serve | def serve(opts):
"""
Run a light-weight HTTP server hosting previously mirrored resources
"""
resources = _load(opts.resources, opts.output_dir)
opts.output_dir = resources.output_dir # allow resources.yaml to set default output_dir
if not os.path.exists(opts.output_dir):
sys.stderr.wri... | python | def serve(opts):
"""
Run a light-weight HTTP server hosting previously mirrored resources
"""
resources = _load(opts.resources, opts.output_dir)
opts.output_dir = resources.output_dir # allow resources.yaml to set default output_dir
if not os.path.exists(opts.output_dir):
sys.stderr.wri... | [
"def",
"serve",
"(",
"opts",
")",
":",
"resources",
"=",
"_load",
"(",
"opts",
".",
"resources",
",",
"opts",
".",
"output_dir",
")",
"opts",
".",
"output_dir",
"=",
"resources",
".",
"output_dir",
"# allow resources.yaml to set default output_dir",
"if",
"not",... | Run a light-weight HTTP server hosting previously mirrored resources | [
"Run",
"a",
"light",
"-",
"weight",
"HTTP",
"server",
"hosting",
"previously",
"mirrored",
"resources"
] | 7d2c5f50981784cc4b5cde216b930f6d59c951a4 | https://github.com/juju-solutions/jujuresources/blob/7d2c5f50981784cc4b5cde216b930f6d59c951a4/jujuresources/cli.py#L229-L249 |
48,497 | happyleavesaoc/python-limitlessled | limitlessled/group/white.py | WhiteGroup._to_temperature | def _to_temperature(self, temperature):
""" Step to a given temperature.
:param temperature: Get to this temperature.
"""
self._to_value(self._temperature, temperature,
self.command_set.temperature_steps,
self._warmer, self._cooler) | python | def _to_temperature(self, temperature):
""" Step to a given temperature.
:param temperature: Get to this temperature.
"""
self._to_value(self._temperature, temperature,
self.command_set.temperature_steps,
self._warmer, self._cooler) | [
"def",
"_to_temperature",
"(",
"self",
",",
"temperature",
")",
":",
"self",
".",
"_to_value",
"(",
"self",
".",
"_temperature",
",",
"temperature",
",",
"self",
".",
"command_set",
".",
"temperature_steps",
",",
"self",
".",
"_warmer",
",",
"self",
".",
"... | Step to a given temperature.
:param temperature: Get to this temperature. | [
"Step",
"to",
"a",
"given",
"temperature",
"."
] | 70307c2bf8c91430a99579d2ad18b228ec7a8488 | https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/white.py#L169-L176 |
48,498 | happyleavesaoc/python-limitlessled | limitlessled/group/white.py | WhiteGroup._warmest | def _warmest(self):
""" Group temperature as warm as possible. """
for _ in range(steps(self.temperature, 0.0,
self.command_set.temperature_steps)):
self._warmer() | python | def _warmest(self):
""" Group temperature as warm as possible. """
for _ in range(steps(self.temperature, 0.0,
self.command_set.temperature_steps)):
self._warmer() | [
"def",
"_warmest",
"(",
"self",
")",
":",
"for",
"_",
"in",
"range",
"(",
"steps",
"(",
"self",
".",
"temperature",
",",
"0.0",
",",
"self",
".",
"command_set",
".",
"temperature_steps",
")",
")",
":",
"self",
".",
"_warmer",
"(",
")"
] | Group temperature as warm as possible. | [
"Group",
"temperature",
"as",
"warm",
"as",
"possible",
"."
] | 70307c2bf8c91430a99579d2ad18b228ec7a8488 | https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/white.py#L209-L213 |
48,499 | happyleavesaoc/python-limitlessled | limitlessled/group/white.py | WhiteGroup._coolest | def _coolest(self):
""" Group temperature as cool as possible. """
for _ in range(steps(self.temperature, 1.0,
self.command_set.temperature_steps)):
self._cooler() | python | def _coolest(self):
""" Group temperature as cool as possible. """
for _ in range(steps(self.temperature, 1.0,
self.command_set.temperature_steps)):
self._cooler() | [
"def",
"_coolest",
"(",
"self",
")",
":",
"for",
"_",
"in",
"range",
"(",
"steps",
"(",
"self",
".",
"temperature",
",",
"1.0",
",",
"self",
".",
"command_set",
".",
"temperature_steps",
")",
")",
":",
"self",
".",
"_cooler",
"(",
")"
] | Group temperature as cool as possible. | [
"Group",
"temperature",
"as",
"cool",
"as",
"possible",
"."
] | 70307c2bf8c91430a99579d2ad18b228ec7a8488 | https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/white.py#L216-L220 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.