diff options
author | Jan Pokorný <jpokorny@redhat.com> | 2015-06-25 18:49:57 +0200 |
---|---|---|
committer | Jan Pokorný <jpokorny@redhat.com> | 2015-07-02 23:43:45 +0200 |
commit | b3589198d0a669dd32fe6504fc0892c01bee4461 (patch) | |
tree | 563ffba61ba992f807d12dd3f91fac62f83a0b64 /formats | |
parent | c5cca9e6f1b0f97a90ad5b5e36d34f128ed9d2e4 (diff) | |
download | clufter-b3589198d0a669dd32fe6504fc0892c01bee4461.tar.gz clufter-b3589198d0a669dd32fe6504fc0892c01bee4461.tar.xz clufter-b3589198d0a669dd32fe6504fc0892c01bee4461.zip |
formats/simpleconfig: "constantify" the lexical units
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to 'formats')
-rw-r--r-- | formats/simpleconfig.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/formats/simpleconfig.py b/formats/simpleconfig.py index d9f5315..d860ec8 100644 --- a/formats/simpleconfig.py +++ b/formats/simpleconfig.py @@ -44,6 +44,13 @@ class simpleconfig(SimpleFormat): native_protocol = STRUCT = Protocol('struct') BYTESTRING = SimpleFormat.BYTESTRING + # notable lexical units for input + lbrace_i, rbrace_i, optsep_i = '{', '}', ':' + # notable lexical units for output (~ pretty-printing, hence with spaces) + lbrace_o, rbrace_o, optsep_o = ' ' + lbrace_i, rbrace_i, optsep_i + ' ' + # same for input/output + csep = '#' + @SimpleFormat.producing(BYTESTRING) def get_bytestring(self, *protodecl): """Externalize 'struct', that is basically, pretty print it @@ -78,7 +85,7 @@ class simpleconfig(SimpleFormat): # fallback struct = self.STRUCT(protect_safe=True) indent, optindent = (getenv_namespaced('COROINDENT', '\t'), ) * 2 - lbrace, rbrace, optsep = ' {', '}', ': ' # spaces intentional + lbrace, rbrace, optsep = self.lbrace_o, self.rbrace_o, self.optsep_o ret = '\n'.join( apply_aggregation_preserving_passing_depth( lambda x, d: |