From d10f2e378a132e61738784ad5443ac0200962087 Mon Sep 17 00:00:00 2001 From: Victor Lei Date: Mon, 29 Aug 2016 03:41:57 +0300 Subject: [PATCH] New option --strings specifies octave or matlab string format --- smop/backend.py | 6 ++++-- smop/options.py | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/smop/backend.py b/smop/backend.py index c2517d07..aa117281 100644 --- a/smop/backend.py +++ b/smop/backend.py @@ -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) diff --git a/smop/options.py b/smop/options.py index 926f36d9..9da41e86 100644 --- a/smop/options.py +++ b/smop/options.py @@ -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