Skip to content

Commit

Permalink
Allow single string projections, see #63
Browse files Browse the repository at this point in the history
  • Loading branch information
geographika committed Jul 24, 2018
1 parent f4e1cf2 commit ba79d22
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mappyfile.pyproj
Expand Up @@ -11,7 +11,7 @@
<Name>mappyfile</Name>
<RootNamespace>mappyfile</RootNamespace>
<InterpreterId>MSBuild|mappyfile3|$(MSBuildProjectFullPath)</InterpreterId>
<StartupFile>tests\mapfiles\profiler.py</StartupFile>
<StartupFile>tests\test_pprint.py</StartupFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
6 changes: 5 additions & 1 deletion mappyfile/pprint.py
Expand Up @@ -211,7 +211,11 @@ def process_projection(self, key, lst, level):

lines = [self.add_start_line(key, level)]

if len(lst) == 1 and lst[0].upper() == "AUTO":
if self.quoter.is_string(lst):
val = self.quoter.add_quotes(lst)
# the value has been manually set to a single string projection
lines.append(u"{}{}".format(self.whitespace(level, 2), val))
elif len(lst) == 1 and lst[0].upper() == "AUTO":
lines.append(u"{}{}".format(self.whitespace(level, 2), "AUTO"))
else:
for v in lst:
Expand Down
17 changes: 15 additions & 2 deletions tests/test_pprint.py
Expand Up @@ -296,6 +296,19 @@ def test_auto_projection():
assert(s == "MAP PROJECTION AUTO END END")



def test_single_string_projection():
d = {
"projection": "init=epsg:4326",
"__type__": "map"
}

pp = PrettyPrinter(indent=0, quote="'", newlinechar=" ")
s = pp.pprint(d)
print(s)
assert(s == "MAP PROJECTION 'init=epsg:4326' END END")


def test_print_boolean():
d = {
"transform": True,
Expand Down Expand Up @@ -375,6 +388,6 @@ def run_tests():

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

0 comments on commit ba79d22

Please sign in to comment.