Skip to content

Commit

Permalink
New option --strings specifies octave or matlab string format
Browse files Browse the repository at this point in the history
  • Loading branch information
victorlei committed Aug 29, 2016
1 parent 9f6bf43 commit d10f2e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions smop/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,10 @@ def _backend(self,level=0):
def _backend(self,level=0):
if "\n" in self.value:
fmt = '"""%s"""'
else:
fmt = '"%s"'
elif options.strings == "C":
fmt = '"%s"' % self.value.replace('"',r'\"')
elif options.strings == "F":
fmt = "'%s'" % self.value.replace("'",r"''")
return fmt % self.value

@extend(node.sub)
Expand Down
3 changes: 3 additions & 0 deletions smop/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
parser.add_argument("-R","--no-resolve", action="store_true",
help="omit name resolution")

parser.add_argument("-S","--strings", default="C",
help="""C for Octave style, F for Matlab style""")

parser.add_argument("-T","--testing-mode",action="store_true",
help= """support special "testing" percent-bang comments used to
write Octave test suite. When disabled, behaves like
Expand Down

0 comments on commit d10f2e3

Please sign in to comment.