From 7bc33979432abc3c142b3d803837fab0deab50ad Mon Sep 17 00:00:00 2001 From: Vojtech Forejt Date: Sun, 4 Mar 2012 19:13:31 +0000 Subject: [PATCH] text file filler, first version, untested git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@4776 bbc10eb1-c90d-0410-af57-cb519fbb1720 --- prism/etc/README.txt | 5 + prism/etc/scripts/prism-filler.py | 187 ++++++++++++++++++++++++++++++ 2 files changed, 192 insertions(+) create mode 100755 prism/etc/scripts/prism-filler.py diff --git a/prism/etc/README.txt b/prism/etc/README.txt index fe6df656..15476b7a 100644 --- a/prism/etc/README.txt +++ b/prism/etc/README.txt @@ -11,6 +11,11 @@ Where appropriate, comments/instructions are included in the files themselves. - prism3to4 - fixes some common problems in old (3.x and earlier) PRISM models - prism-statra - combines a PRISM .sta and .tra file into one file (these scripts run on Linux/Unix/OS X and require prism to be in your path) + - prism-filler.py - automates filling a text file (e.g. latex) with results + from log files. This script requires Python, run it without arguments for + more help. + - bash-prism-completion.sh - Bash programmable completion for PRISM, + automatically completes options for PRISM when run in Bash. * syntax-highlighters/ - Syntax highlighting configs for various tools - gnome/{Overrides.xml,prism.lang} - files for Gnome environment diff --git a/prism/etc/scripts/prism-filler.py b/prism/etc/scripts/prism-filler.py new file mode 100755 index 00000000..3b302de2 --- /dev/null +++ b/prism/etc/scripts/prism-filler.py @@ -0,0 +1,187 @@ +# coding=utf-8 +# run "python prism-filler.py" for more help + +import re +import sys +import os +from optparse import OptionParser + +list_of_files = [] +directories = [] + +def treat_file_names(file) : + global list_of_files + #first get the actual string if a number or None is provided + if file is None : + file = list_of_files[-1] + if type(file) is int : + file = list_of_files[file] + list_of_files.append(file) + + #now get a path + #first try the directories + for d in directories : + joined = os.path.join(d, file) + if (os.path.isfile(joined)) : + return joined + #otherwise just return the file itself (note: if it does not exist, an exception will be thrown anyway) + return file + +#extract total computation time +def p_time(file = None) : + file = treat_file_names(file) + log_content = open(file).read() + matched = re.search("Time for model checking:[^0-9]*(?P