adamtornhill / maat-scripts

Scripts used to post-process the results from Code Maat
GNU General Public License v3.0
74 stars 30 forks source link

Replaced UNIX-centric file path parsing with a portable one. #5

Closed o7g8 closed 6 years ago

adamtornhill commented 6 years ago

@o7g8 thanks a lot for the patch -- looks good. Just one quick question: if someone on Windows runs cloc with the --unix flag, as I recommend, they will get /paths/unix/style/. Will os.path.split on Windows handle that correctly?

o7g8 commented 6 years ago

The fix allows to mix and match Unix- and Windows-style csv files. Let's assume we have both Unix- and Windows- editions of the structure and weights files:

struct_unix.csv
struct_win.csv
weights_unix.csv
weights_win.csv

The fix allows to run the script with all 4 combinations:

python transform/csv_as_enclosure_json.py --structure=struct_win.csv --weights=weigths_win.csv
python transform/csv_as_enclosure_json.py --structure=struct_win.csv --weights=weigths_unix.csv
python transform/csv_as_enclosure_json.py --structure=struct_unix.csv --weights=weigths_win.csv
python transform/csv_as_enclosure_json.py --structure=struct_unix.csv --weights=weigths_unix.csv

I've tested it both in Linux and Windows.

I have also noticed that code_age_csv_as_enclosure_json.py[92] and csv_main_dev_as_knowledge_json.py[49] can be improved in a similar way. Should I do it on a separate PR?

adamtornhill commented 6 years ago

Excellent - thanks a lot for the clarification. Yes, it would be great if you could do a separate PR for the other two files.