def get_commands():
        more_aliases = []
        for layer_name in used_layer_names:
            layer_metadata = metadata_by_layer_name[layer_name]
            layer = layer_by_target_path[layer_metadata.target_path]
            more_aliases.extend(get_aliases(layer).keys())

        return R.uniq(command_names + inferred_command_names +
                      command_aliases + more_aliases)
Example #2
0
    def get_ordered_layer_paths(self):
        root_layer_path = self.config_io.glob([self.root_layer_path])[0]

        x = R.concat(self.selected_layer_by_path.keys(),
                     self.layer_by_target_path.keys())
        x = R.uniq(x)
        x = sorted(x, key=os.path.basename)
        x = self.config_io.glob(x)

        x = R.filter(lambda x: x != root_layer_path)(x)
        x = R.concat([root_layer_path], x)

        return x
Example #3
0
def select_layers(
    config_io,
    root_layer_path,
    root_layer,
    command_line_layer_paths,
):
    all_layer_paths = layer_filename_superset(
        R.uniq([root_layer_path] + command_line_layer_paths), config_io=config_io
    )

    selected_layer_by_path = OrderedDict()
    for layer_path in all_layer_paths:
        selected_layer_by_path[layer_path] = config_io.load(layer_path)
    return dict(selected_layer_by_path=selected_layer_by_path)
Example #4
0
def get_layer_paths_from_command_prefix(
    command_prefix,
    metadata_by_layer_name,
    layer_paths_from_command_prefix,
):
    def map_to_path(layer_name):
        if layer_name not in metadata_by_layer_name:
            known_layer_names = metadata_by_layer_name.keys()
            raise CommandError(
                "Unknown layer: %s. Known layers: %s"
                % (layer_name, ", ".join(known_layer_names))
            )
        return metadata_by_layer_name[layer_name].target_path

    layer_names = R.uniq(R.filter(bool)(command_prefix.split(".")))
    return dict(
        layer_paths_from_command_prefix=R.map(map_to_path)(layer_names)
        or layer_paths_from_command_prefix
    )
 def get_inferred_commands_and_aliases(inferred_commands, inferred_aliases):
     return R.uniq(inferred_commands + inferred_aliases)
Example #6
0
 def layer_paths(self):
     return R.uniq(
         self.layer_paths_inferred_by_command_name
         + self.layer_paths_from_command_prefix
         + self.layer_paths_from_input_args
     )
Example #7
0
 def get_flat_list(list_of_lists):
     return R.uniq(R.flatten(list_of_lists))