def parse_loc_list(loc_list): "wrangle the list of paths the user gave us. expand if they specify a directory, etc" # give the convenient user-form some structure p_loc_list = lmap(_parse_loc, loc_list) # do some post processing def expand_dirs(triple): protocol, host, path = triple if protocol in ['dir', 'file'] and not os.path.exists(path): LOG.warn("could not resolve %r, skipping", path) return [None] if protocol == 'dir': yaml_files = utils.listfiles(path, ['.yaml']) return [('file', host, ppath) for ppath in yaml_files] return [triple] # we don't want dirs, we want files p_loc_list = utils.shallow_flatten(map(expand_dirs, p_loc_list)) # remove any bogus values p_loc_list = lfilter(None, p_loc_list) # remove any duplicates. can happen when we expand dir => files p_loc_list = utils.unique(p_loc_list) return p_loc_list
def _wrapper(stackname=None, *args, **kwargs): region = utils.find_region(stackname) asl = core.active_stack_names(region) if not asl: print('\nno AWS stacks exist, cannot continue.') return def pname_startswith(stack): for pname in plist: if stack.startswith(pname): return stack asl = lfilter(pname_startswith, asl) if not stackname or stackname not in asl: stackname = utils._pick("stack", asl) return func(stackname, *args, **kwargs)
def known_formulas(): "a simple list of all known project formulas" return utils.lfilter(None, utils.unique(utils.shallow_flatten(project_formulas().values())))