Skip to content

Commit

Permalink
New option --no-header
Browse files Browse the repository at this point in the history
  • Loading branch information
victorlei committed Dec 6, 2016
1 parent b518faf commit 89beb89
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions smop/main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# SMOP -- Simple Matlab/Octave to Python compiler
# Copyright 2011-2016 Victor Leikehman

import py_compile
import tempfile
import fnmatch
import tarfile
import sys
import os
import traceback
from os.path import basename, splitext

Expand All @@ -17,6 +19,8 @@


def print_header(fp):
if options.no_header:
return
print >> fp, "# Autogenerated with SMOP " + version.__version__
# print >> fp, "from __future__ import division"
print >> fp, "from smop.core import *"
Expand Down Expand Up @@ -90,6 +94,11 @@ def main():
with open(f, "w") as fp:
print_header(fp)
fp.write(s)
try:
py_compile.compile(f,doraise=True)
except py_compile.PyCompileError:
os.unlink(f)
raise
else:
fp.write(s)
except KeyboardInterrupt:
Expand Down
5 changes: 5 additions & 0 deletions smop/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@

#parser.add_argument("--graphviz", action="store_true")

parser.add_argument("-H","--no-header",
action="store_true",
help="""use it if you plan to concatenate
generated files.""")

parser.add_argument("-C","--no-comments",
action="store_true",
help="""discard multiline comments""")
Expand Down

0 comments on commit 89beb89

Please sign in to comment.