Skip to content

Commit

Permalink
Quote connectionoptions values
Browse files Browse the repository at this point in the history
  • Loading branch information
geographika committed Jul 14, 2020
1 parent c341176 commit 5351367
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
4 changes: 2 additions & 2 deletions mappyfile/pprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def pprint(self, composites):

for composite in composites:
type_ = composite["__type__"]
if type_ in ("metadata", "validation"):
if type_ in ("metadata", "validation", "connectionoptions"):
# types are being parsed directly, and not as an attr of a parent
lines += self.process_key_dict(type_, composite, level=0)
else:
Expand Down Expand Up @@ -504,7 +504,7 @@ def _format(self, composite, level=0):
lines += self._format(v, level + 1)
elif attr == "pattern":
lines += self.format_pair_list(attr, value, level)
elif attr in ("metadata", "validation", "values"):
elif attr in ("metadata", "validation", "values", "connectionoptions"):
# metadata and values are also composites
# but will be processed here
lines += self.process_key_dict(attr, value, level)
Expand Down
21 changes: 20 additions & 1 deletion tests/test_pprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,25 @@ def test_metadata():
assert(s == "MAP METADATA 'MS_ENABLE_MODES' '!*' 'WMS_ENABLE_REQUEST' '*' END END")


def test_connectionoptions():

values = {
"FLATTEN_NESTED_ATTRIBUTES": "YES"
}

d = {
"connectionoptions": values,
"__type__": "layer"
}

d = collections.OrderedDict(sorted(d.items()))

pp = PrettyPrinter(indent=0, quote="'", newlinechar=" ")
s = pp.pprint(d)
print(s)
assert(s == "LAYER CONNECTIONOPTIONS 'FLATTEN_NESTED_ATTRIBUTES' 'YES' END END")


def test_config():

cd = {
Expand Down Expand Up @@ -418,6 +437,6 @@ def run_tests():

if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
test_join()
test_connectionoptions()
# run_tests()
print("Done!")

0 comments on commit 5351367

Please sign in to comment.