Explicit format is ignored when the map file does not have an extension
Closed this issue · 1 comments
Bug Report
- wordrow version:
v0.4.0-beta
- Operating system: Ubuntu 19.04
Description
Providing a map file without file extension but with explicit format is interpreted incorrectly and as a result the map file cannot be used with the explicit format (which is required when it doesn't have a file extension)
Actual Behaviour
On the v0.4.0-beta commit, wordrow silently fails. On the latest commit on master
(which currently is 5ff519d) wordrow produces an error saying that the map file could not be opened.
$ ./wordrow --map-file ./mapfile:csv /inputfile.txt
[Error] Could not open './mapfile:csv' (ReadOnly mode)
Expected Behaviour
The explicit format is removes from the path of the file without extension
Working Example
You can use the script above with some simple input files to reproduce this bug.
- Create the file
mapfile
with the following content
# mapfile
foo,bar
- Create the
inputfile.txt
with the following content
# inputfile.txt
foo bar
- Run wordrow
$ ./wordrow --map-file ./mapfile:csv /inputfile.txt
- Observe that the input file is unchanged (and on 5ff519d it outputs an error that
mapfile:csv
cannot be opened).
Log Output
Using the the v0.4.0-beta commit
$ ./wordrow --map-file ./mapfile:csv ./inputfile.txt --verbose
[Debug] Processing CLI specified map files...
[Debug] Parsing argument './mapfile:csv'
[Debug] Reading './mapfile:csv'
[Debug] Processing CLI specified mappings...
[Debug] Processing '/media/win/workspace/wordrow/inputfile.txt' as input file
And on 5ff519d:
$ ./wordrow --map-file ./mapfile:csv ./inputfile.txt --verbose
[Debug] Processing './mapfile:csv' as a map file
[Debug] Opening './mapfile:csv' as a '' formatted map file
[Error] Could not open './mapfile:csv' (ReadOnly mode)
For anyone interested in resolving this issue, 2605091 provides a basic test case to verify that the bug has been fixed.