本文整理汇总了Python中easybuild.framework.easyconfig.parser.EasyConfigParser.get方法的典型用法代码示例。如果您正苦于以下问题:Python EasyConfigParser.get方法的具体用法?Python EasyConfigParser.get怎么用?Python EasyConfigParser.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类easybuild.framework.easyconfig.parser.EasyConfigParser
的用法示例。
在下文中一共展示了EasyConfigParser.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_tweak_one_version
# 需要导入模块: from easybuild.framework.easyconfig.parser import EasyConfigParser [as 别名]
# 或者: from easybuild.framework.easyconfig.parser.EasyConfigParser import get [as 别名]
def test_tweak_one_version(self):
"""Test tweak_one function"""
test_easyconfigs_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs')
toy_ec = os.path.join(test_easyconfigs_path, 't', 'toy', 'toy-0.0.eb')
# test tweaking of software version (--try-software-version)
tweaked_toy_ec = os.path.join(self.test_prefix, 'toy-tweaked.eb')
tweak_one(toy_ec, tweaked_toy_ec, {'version': '1.2.3'})
toy_ec_parsed = EasyConfigParser(toy_ec).get_config_dict()
tweaked_toy_ec_parsed = EasyConfigParser(tweaked_toy_ec).get_config_dict()
# checksums should be reset to empty list, only version should be changed, nothing else
self.assertEqual(tweaked_toy_ec_parsed['checksums'], [])
self.assertEqual(tweaked_toy_ec_parsed['version'], '1.2.3')
for key in [k for k in toy_ec_parsed.keys() if k not in ['checksums', 'version']]:
val = toy_ec_parsed[key]
self.assertTrue(key in tweaked_toy_ec_parsed, "Parameter '%s' not defined in tweaked easyconfig file" % key)
tweaked_val = tweaked_toy_ec_parsed.get(key)
self.assertEqual(val, tweaked_val, "Different value for %s parameter: %s vs %s" % (key, val, tweaked_val))
# check behaviour if target file already exists
error_pattern = "File exists, not overwriting it without --force"
self.assertErrorRegex(EasyBuildError, error_pattern, tweak_one, toy_ec, tweaked_toy_ec, {'version': '1.2.3'})
# existing file does get overwritten when --force is used
init_config(build_options={'force': True, 'silent': True})
write_file(tweaked_toy_ec, '')
tweak_one(toy_ec, tweaked_toy_ec, {'version': '1.2.3'})
tweaked_toy_ec_parsed = EasyConfigParser(tweaked_toy_ec).get_config_dict()
self.assertEqual(tweaked_toy_ec_parsed['version'], '1.2.3')
示例2: list_software
# 需要导入模块: from easybuild.framework.easyconfig.parser import EasyConfigParser [as 别名]
# 或者: from easybuild.framework.easyconfig.parser.EasyConfigParser import get [as 别名]
def list_software(output_format=FORMAT_TXT, detailed=False, only_installed=False):
"""
Show list of supported software
:param output_format: output format to use
:param detailed: whether or not to return detailed information (incl. version, versionsuffix, toolchain info)
:param only_installed: only retain software for which a corresponding module is available
:return: multi-line string presenting requested info
"""
silent = build_option('silent')
ec_paths = find_matching_easyconfigs('*', '*', build_option('robot_path') or [])
ecs = []
cnt = len(ec_paths)
for idx, ec_path in enumerate(ec_paths):
# full EasyConfig instance is only required when module name is needed
# this is significantly slower (5-10x) than a 'shallow' parse via EasyConfigParser
if only_installed:
ec = process_easyconfig(ec_path, validate=False, parse_only=True)[0]['ec']
else:
ec = EasyConfigParser(filename=ec_path).get_config_dict()
ecs.append(ec)
print_msg('\r', prefix=False, newline=False, silent=silent)
print_msg("Processed %d/%d easyconfigs..." % (idx+1, cnt), newline=False, silent=silent)
print_msg('', prefix=False, silent=silent)
software = {}
for ec in ecs:
software.setdefault(ec['name'], [])
if ec['toolchain']['name'] == DUMMY_TOOLCHAIN_NAME:
toolchain = DUMMY_TOOLCHAIN_NAME
else:
toolchain = '%s/%s' % (ec['toolchain']['name'], ec['toolchain']['version'])
keys = ['description', 'homepage', 'version', 'versionsuffix']
info = {'toolchain': toolchain}
for key in keys:
info[key] = ec.get(key, '')
# make sure values like homepage & versionsuffix get properly templated
if isinstance(ec, dict):
template_values = template_constant_dict(ec, skip_lower=False)
for key in keys:
if '%(' in info[key]:
try:
info[key] = info[key] % template_values
except (KeyError, TypeError, ValueError) as err:
_log.debug("Ignoring failure to resolve templates: %s", err)
software[ec['name']].append(info)
if only_installed:
software[ec['name']][-1].update({'mod_name': ec.full_mod_name})
print_msg("Found %d different software packages" % len(software), silent=silent)
if only_installed:
avail_mod_names = modules_tool().available()
# rebuild software, only retain entries with a corresponding available module
software, all_software = {}, software
for key in all_software:
for entry in all_software[key]:
if entry['mod_name'] in avail_mod_names:
software.setdefault(key, []).append(entry)
print_msg("Retained %d installed software packages" % len(software), silent=silent)
return generate_doc('list_software_%s' % output_format, [software, detailed])