text
stringlengths 0
828
|
---|
xfer_funcs = pd.Series([sp.Eq(V2 / Z2, V1 / (Z1 + Z2)),
|
sp.Eq(V2 / V1, Z2 / Z1)],
|
# Index by hardware version.
|
index=[1, 2])
|
xfer_funcs.index.name = 'Hardware version'
|
return xfer_funcs"
|
183,"def has_option(section, name):
|
""""""
|
Wrapper around ConfigParser's ``has_option`` method.
|
""""""
|
cfg = ConfigParser.SafeConfigParser({""working_dir"": ""/tmp"", ""debug"": ""0""})
|
cfg.read(CONFIG_LOCATIONS)
|
return cfg.has_option(section, name)"
|
184,"def get(section, name):
|
""""""
|
Wrapper around ConfigParser's ``get`` method.
|
""""""
|
cfg = ConfigParser.SafeConfigParser({""working_dir"": ""/tmp"", ""debug"": ""0""})
|
cfg.read(CONFIG_LOCATIONS)
|
val = cfg.get(section, name)
|
return val.strip(""'"").strip('""')"
|
185,"def run(**options):
|
""""""
|
_run_
|
Run the dockerstache process to render templates
|
based on the options provided
|
If extend_context is passed as options it will be used to
|
extend the context with the contents of the dictionary provided
|
via context.update(extend_context)
|
""""""
|
with Dotfile(options) as conf:
|
if conf['context'] is None:
|
msg = ""No context file has been provided""
|
LOGGER.error(msg)
|
raise RuntimeError(msg)
|
if not os.path.exists(conf['context_path']):
|
msg = ""Context file {} not found"".format(conf['context_path'])
|
LOGGER.error(msg)
|
raise RuntimeError(msg)
|
LOGGER.info(
|
(
|
""{{dockerstache}}: In: {}\n""
|
""{{dockerstache}}: Out: {}\n""
|
""{{dockerstache}}: Context: {}\n""
|
""{{dockerstache}}: Defaults: {}\n""
|
).format(conf['input'], conf['output'], conf['context'], conf['defaults'])
|
)
|
context = Context(conf['context'], conf['defaults'])
|
context.load()
|
if 'extend_context' in options:
|
LOGGER.info(""{{dockerstache}} Extended context provided"")
|
context.update(options['extend_context'])
|
process_templates(
|
conf['input'],
|
conf['output'],
|
context
|
)
|
if conf['inclusive']:
|
process_copies(
|
conf['input'],
|
conf['output'],
|
conf['exclude']
|
)
|
return dict(conf)"
|
186,"def make_key(table_name, objid):
|
""""""Create an object key for storage.""""""
|
key = datastore.Key()
|
path = key.path_element.add()
|
path.kind = table_name
|
path.name = str(objid)
|
return key"
|
187,"def write_rec(table_name, objid, data, index_name_values):
|
""""""Write (upsert) a record using a tran.""""""
|
with DatastoreTransaction() as tx:
|
entity = tx.get_upsert()
|
entity.key.CopyFrom(make_key(table_name, objid))
|
prop = entity.property.add()
|
prop.name = 'id'
|
prop.value.string_value = objid
|
prop = entity.property.add()
|
prop.name = 'value'
|
prop.value.string_value = data
|
for name, val in index_name_values:
|
prop = entity.property.add()
|
prop.name = name
|
prop.value.string_value = str(val)"
|
188,"def extract_entity(found):
|
""""""Copy found entity to a dict.""""""
|
obj = dict()
|
for prop in found.entity.property:
|
obj[prop.name] = prop.value.string_value
|
return obj"
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.