コード例 #1
0
    def get_raw_cmd_by_id(self, cmd_id: str):
        """Get raw command by its identifier."""
        for cmd in iter_cmds(self.cmds_file):
            if cmd["id"] == cmd_id:
                return cmd

        return RuntimeError("No command with id {}".format(cmd_id))
コード例 #2
0
ファイル: pid_graph.py プロジェクト: 17451k/clade
    def parse(self, cmds_file):
        self.log("Parsing {} commands".format(
            get_last_id(cmds_file, raise_exception=True)))

        for cmd in iter_cmds(cmds_file):
            self.pid_by_id[cmd["id"]] = cmd["pid"]

        self.dump_data(self.pid_by_id, self.pid_by_id_file)

        if self.pid_by_id and self.conf.get("PidGraph.as_picture"):
            self.__print_pid_graph(cmds_file)

        self.pid_by_id.clear()
コード例 #3
0
ファイル: pid_graph.py プロジェクト: 17451k/clade
    def __print_pid_graph(self, cmds_file):
        self.debug("Preparing dot file")

        dot = Digraph(graph_attr={'rankdir': 'LR'},
                      node_attr={'shape': 'rectangle'})

        cmds = list(iter_cmds(cmds_file))

        for cmd in cmds:
            cmd_node = "[{}] {}".format(cmd["id"], cmd["which"])
            dot.node(cmd["id"], label=re.escape(cmd_node))

        for cmd in cmds:
            for parent_cmd in [x for x in cmds if x["id"] == cmd["pid"]]:
                dot.edge(parent_cmd["id"], cmd["id"])

        self.debug("Rendering dot file")
        dot.render(self.graph_dot)
コード例 #4
0
ファイル: test_cmds.py プロジェクト: mutilin/clade
def test_iter(cmds_file):
    assert len(list(iter_cmds(cmds_file))) >= number_of_cmds
コード例 #5
0
def test_get_raw_cmds(clade_api: Clade):
    assert list(clade_api.get_raw_cmds()) == list(
        iter_cmds(clade_api.cmds_file))
コード例 #6
0
 def get_raw_cmds(self):
     """Get an iterator over all unparsed commands."""
     for cmd in iter_cmds(self.cmds_file):
         yield cmd
コード例 #7
0
def test_get_all_cmds(cmds_file):
    cmds = []
    for cmd in iter_cmds(cmds_file):
        cmds.append(cmd)

    assert cmds == get_all_cmds(cmds_file)
コード例 #8
0
def test_join_cmd(cmds_file):
    with open(cmds_file, "r") as cmds_fh:
        for cmd in iter_cmds(cmds_file):
            assert join_cmd(cmd) == cmds_fh.readline().strip()