Consider the following instance (saved by Problem.render - tsplib95/models.py, which uses a dictionary-like format):
NAME: example
TYPE: TSP
DIMENSION: 3
EDGE_WEIGHT_TYPE: EXACT_2D
NODE_COORD_SECTION:
1 0.8554288744926453 0.7658464312553406
2 1.0 0.4734724760055542
3 0.10046596825122833 0.5560271739959717
EOF
Although the trailing colon after _SECTION is not commonly used, several other libraries/parsers I use handle it without problems:
- Problem.parse - tsplib95/models.py: use regular expression
- ReadProblem - LKH3/SRC/ReadProblem.c: extract the key using
strtok
- CCutil_gettsplib - concorde/UTIL/getdata.c: replace the colon with a space
However, vrplib currently fails to parse this file because in parse_section, the parser checks for the colon before checking *_SECTION headers:
|
if ":" in line: |
|
specs.append(line) |
|
elif "_SECTION" in line: |
|
start = lines.index(line) |
|
end_section = start + 1 |
Would it be possible to swap the order of the corresponding elif blocks in parse_section, so that *_SECTION headers are recognized even when they contain a trailing colon?
Consider the following instance (saved by Problem.render - tsplib95/models.py, which uses a dictionary-like format):
Although the trailing colon after
_SECTIONis not commonly used, several other libraries/parsers I use handle it without problems:strtokHowever, vrplib currently fails to parse this file because in parse_section, the parser checks for the colon before checking
*_SECTIONheaders:VRPLIB/vrplib/parse/parse_vrplib.py
Lines 74 to 78 in e4d2197
Would it be possible to swap the order of the corresponding elif blocks in
parse_section, so that*_SECTIONheaders are recognized even when they contain a trailing colon?