Skip to content

Commit

Permalink
Export bugfix, convert message change.
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielbessler authored Feb 10, 2021
1 parent 3700e8a commit f9c727e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ in the docker image will put you inside the Metrinome REPL. This is how the user

The Makefile also contains other useful commands for developing. To run all of the unit tests present in `src/tests/`, use `make test` within the REPL. To execute the linters, use `make check-lint` (or `make lint` to automatically fix common linter issues and then run the linters). Note that this command also runs a typechecker which takes advantage of Python's type hinting feature, so it can help catch errors. It is _*very highly*_ recommended that the linter is executed before any commits are pushed. If pylint makes a recommendation you disagree with, it is possible to disable that pylint check within the section of code you are working in.

If you're using VSCode, the 'Remote - Containers' extension can be used to run a Python debugger while using the Metrinome REPL inside Docker.

## The Codebase

Here are the key components of the repo:
Expand Down Expand Up @@ -84,7 +86,8 @@ The recursive flag (-r) can also be used to convert all files in a given directo
Note - Language Support:

The REPL current supports C/C++ (using clang6), Java (JDK13), and Python 3.
However, only a subset of Python 3 keywords / features are supported:
C/C++ and Java code yields block-level CFGs while Python 3 results in statement level CFGs.
Keep in mind that only a subset of Python 3 keywords / features are supported:
assignment, expressions (e.g. 'a + b'), if/else/elif, return, while, and with
(NOTE: this does not include list/dictionary comprehensions, lambda expressions, or try/catch/raise).

Expand Down
2 changes: 1 addition & 1 deletion src/core/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def do_convert(self, args: str) -> None: # pylint: disable=too-many-branches
if graph == {}:
self.logger.v_msg("Converted without errors, but no graphs created.")
else:
self.logger.v_msg(f"Created {' '.join(list(graph.keys()))}")
self.logger.v_msg(f"Created graph objects {' '.join(list(graph.keys()))}")
self.data.graphs.update(graph)
elif isinstance(graph, ControlFlowGraph):
self.logger.v_msg(f"Created graph {graph.name}")
Expand Down
2 changes: 2 additions & 0 deletions src/core/command_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def export_metrics(self, name: str, new_name: str) -> None:
def export_graph(self, name: str, new_name: str) -> None:
"""Save a Graph the REPL knows about to an external file."""
if name in self.graphs:
new_name = new_name.replace("/", "_").replace(".", "_")
with open(f"/app/code/exports/{new_name}.dot", "w+") as file:
graph = self.graphs[name].graph
self.logger.d_msg(graph.dot())
Expand All @@ -88,6 +89,7 @@ def export_graph(self, name: str, new_name: str) -> None:
elif name == "*":
for graph_name in self.graphs:
f_name = os.path.split(graph_name)[1]
f_name = f_name.replace("/", "_").replace(".", "_")
with open(f"/app/code/exports/{f_name}.dot", "w+") as file:
graph = self.graphs[graph_name].graph
file.write(graph.dot())
Expand Down

0 comments on commit f9c727e

Please sign in to comment.