Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __set_value(self, value):
try:
self._input = self._in(value)
self._output = self._out(value)
except (TypeError, ValueError) as error:
raise le.LbuildOptionInputException(self, value, error)
'CallableCollector': lbuild.collector.CallableCollector,
'StringOption': lbuild.option.StringOption,
'PathOption': lbuild.option.PathOption,
'BooleanOption': lbuild.option.BooleanOption,
'NumericOption': lbuild.option.NumericOption,
'EnumerationOption': lbuild.option.EnumerationOption,
'SetOption': lbuild.option.SetOption,
})
try:
local = lu.load_module_from_file(filename, local)
functions = lu.get_global_functions(local, required, optional)
return functions
except le.LbuildUtilsFunctionNotFoundException as error:
raise le.LbuildNodeMissingFunctionException(repository, filename, error)
def get(name, fail=True):
if isinstance(env, dict):
val = env.get(name, None)
else:
val = getattr(env, name, None)
if fail and val is None:
raise le.LbuildUtilsFunctionNotFoundException(name, required, optional)
return val
def merge_module_options(self):
# only deal with repo options that contain one `:`
resolver = self.option_resolver
for name, (value, filename) in filter(lambda i: i[0].count(":") > 1,
self.config.options.items()):
try:
option = resolver[name]
option._filename = filename
option.value = value
except le.LbuildOptionException as error:
raise le.LbuildParserOptionInvalidException(self, error, filename)
except le.LbuildResolverNoMatchException as error:
raise le.LbuildParserNodeNotFoundException(self, name, self.Type.OPTION, filename)
# Enforce that the submodules are always build before their parent modules
for group in (groups[index] for index in sorted(groups)):
for modules in (group[index] for index in sorted(group, reverse=True)):
random.shuffle(modules)
for module in modules:
yield module
# Merge config collectors values
resolver = self.collector_available_resolver
for (name, value, filename) in self.config.collectors:
try:
collector = resolver[name]
collector.add_values(value, collector.repository.fullname, filename=filename)
except le.LbuildOptionException as error:
raise le.LbuildParserOptionInvalidException(self, error, filename)
except le.LbuildResolverNoMatchException as error:
raise le.LbuildParserNodeNotFoundException(self, name, self.Type.COLLECTOR, filename)
exceptions = []
for runner in walk_modules():
try:
runner.validate()
except le.LbuildException as error:
exceptions.append(error)
if exceptions:
raise le.LbuildAggregateException(exceptions)
# Cannot build without a buildlog
if buildlog is None:
return
lbuild.environment.SIMULATE = simulate
nname = "{}.{}".format(self.name, name)
LOGGER.warning("Namespacing repository filter '{}' to '{}'!"
.format(name, nname))
name = nname
self._filters[name] = func
try:
for child in (repo._options + repo._queries):
self.add_child(child)
for (name, path, description) in repo._configurations:
path = self._relocate_relative_path(path)
if not os.path.isfile(path):
raise le.LbuildConfigAddNotFoundException(repo, path)
self.add_child(Configuration(name, path, description))
except le.LbuildNodeDuplicateChildException as error:
raise le.LbuildRepositoryDuplicateChildException(repo._parser, repo, error)
# List of module filenames which are later transfered into
# module objects
self._module_files = []
# List of programatically added modules
self._submodules = []
'StringOption': lbuild.option.StringOption,
'PathOption': lbuild.option.PathOption,
'BooleanOption': lbuild.option.BooleanOption,
'NumericOption': lbuild.option.NumericOption,
'EnumerationOption': lbuild.option.EnumerationOption,
'SetOption': lbuild.option.SetOption,
})
try:
local = lu.load_module_from_file(filename, local)
functions = lu.get_global_functions(local, required, optional)
return functions
except le.LbuildUtilsFunctionNotFoundException as error:
raise le.LbuildNodeMissingFunctionException(repository, filename, error)
def _resolve_partial_max(self, query, max_results=1, raise_on_fail=True):
nodes = self._resolve_partial(query, None)
if nodes is None:
if not raise_on_fail: return None;
raise le.LbuildResolverNoMatchException(self, query)
if len(nodes) > max_results:
if not raise_on_fail: return None;
raise le.LbuildResolverAmbiguousMatchException(self, query, nodes)
return nodes