Rename unused function main() to investigate().
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Tue, 17 Dec 2019 20:19:06 +0000 (20:19 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Tue, 17 Dec 2019 20:19:06 +0000 (20:19 +0000)
git-svn-id: http://www.winterrodeln.org/svn/wrpylib/trunk@2853 7aebc617-e5e2-0310-91dc-80fb5f6d2477

wrpylib/wrintermaps.py

index 1de2befd11021eb49ff42a63fc36fcc66036d76d..9d04c2a63ac2294f2af0e8350e6886683decd573 100644 (file)
@@ -4,8 +4,8 @@ from sqlalchemy import schema, orm
 from wrpylib import mwdb, wrmwdb
 
 
-def main():
-    filename = '/home/philipp/daten/Winterrodeln/Intermaps/intermaps_winterrodeln_2019-12-06_090501.json'
+def investigate(filename: str, write_back_formatted: bool):
+    """Displays statistics about a Intermaps json file."""
     with open(filename) as fp:
         content = json.load(fp)
     regions = content['items']
@@ -15,8 +15,9 @@ def main():
     duplicates = {sledrun_id for sledrun_id in sledrun_ids_set if sum(sr_id == sledrun_id for sr_id in sledrun_ids_list) >= 2}
     print(duplicates)
     print(max(map(len, sledrun_ids_set)))  # 36
-    with open(filename, 'w') as fp:
-        json.dump(content, fp, indent='\t')
+    if write_back_formatted:
+        with open(filename, 'w') as fp:
+            json.dump(content, fp, indent='\t')
 
 
 class UpdateError(RuntimeError):