cldf / pycldf

python package to read and write CLDF datasets
https://cldf.clld.org
Apache License 2.0
15 stars 7 forks source link

use expanduser/abspath/normpath #163

Closed SimonGreenhill closed 1 year ago

SimonGreenhill commented 1 year ago

It would be nice to normalise paths such that ~ is expanded correctly. i.e. this fails:

db = Dataset.from_metadata('~/path/dataset/cldf/cldf-metadata.json')
xrotwang commented 1 year ago

When you use the cldf command-line, your shell would do the expansion. When you use the python API you could do expansion on caller side. So in the spirit of explicit being better than implicit, I'd rather not implement this little piece of magic. Or am I missing a use case?

Simon J Greenhill @.***> schrieb am Do., 8. Dez. 2022, 23:09:

It would be nice to normalise paths such that ~ is expanded correctly. i.e. this fails:

db = Dataset.from_metadata('~/path/dataset/cldf/cldf-metadata.json')

— Reply to this email directly, view it on GitHub https://github.com/cldf/pycldf/issues/163, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGUOKAWBEG6QF6J4YANM7DWMJMB7ANCNFSM6AAAAAASYUR36E . You are receiving this because you are subscribed to this thread.Message ID: @.***>

xrotwang commented 1 year ago

From my experience, introducing behaviour that is dependent on external context (getting current users, looking up environment variables, looking up /etc/passwd/, etc.) makes the code more fragile and harder to test/debug. I'd be ok with such code in user interfaces - but then, when run from the commandline the expected behaviour can be had anyway.