Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3774601
D1230.id3162.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D1230.id3162.diff
View Options
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
@@ -14,21 +14,22 @@
def extract_streets(filename_source, filename_out):
- with open(filename_out, 'w') as fd:
- for line in open(filename_source, 'r'):
+ with open(filename_out, 'w') as output, open(filename_source, 'r') as input:
+ for line in input:
# Streets and other « voies » are the record where
# the 109th position (« type de voie ») is 1.
- if len(line) < 109:
- continue
+ try:
+ if line[108] == "1":
+ fd.write(line)
+ except IndexError:
+ pass
- if line[108] == "1":
- fd.write(line)
+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)
-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])
+ extract_streets(sys.argv[1], sys.argv[2])
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 12:52 (20 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2262512
Default Alt Text
D1230.id3162.diff (1 KB)
Attached To
Mode
D1230: Make the FANTOIR code more pythonic
Attached
Detach File
Event Timeline
Log In to Comment