Page MenuHomeDevCentral

D1232.diff
No OneTemporary

D1232.diff

diff --git a/roles/viperserv/fantoir/files/extract_streets.py b/roles/viperserv/fantoir/files/extract_streets.py
--- a/roles/viperserv/fantoir/files/extract_streets.py
+++ b/roles/viperserv/fantoir/files/extract_streets.py
@@ -9,28 +9,26 @@
# Data license: FANTOIR is licensed under Licence Ouverte
# -------------------------------------------------------------
+
import sys
def extract_streets(filename_source, filename_out):
- with open(filename_out, 'w') as output,\
- open(filename_source, 'r') as input:
- for line in input:
+ with open(filename_out, 'w') as fd:
+ for line in open(filename_source, 'r'):
# Streets and other « voies » are the record where
# the 109th position (« type de voie ») is 1.
- try:
- if line[108] == "1":
- output.write(line)
- except IndexError:
- pass
-
-
-if __name__ == "__main__":
- argc = len(sys.argv)
- if (argc != 3):
- print("Usage: {} <FANTOIR filename> <street filename>"
- .format(sys.argv[0]),
- file=sys.stderr)
- sys.exit(1)
-
- extract_streets(sys.argv[1], sys.argv[2])
+ if len(line) < 109:
+ continue
+
+ if line[108] == "1":
+ fd.write(line)
+
+
+argc = len(sys.argv)
+if (argc != 3):
+ print("Usage: {} <FANTOIR filename> <street filename>".format(sys.argv[0]),
+ file=sys.stderr)
+ sys.exit(1)
+
+extract_streets(sys.argv[1], sys.argv[2])

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 24, 10:32 (17 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2260009
Default Alt Text
D1232.diff (1 KB)

Event Timeline