Inconsistent line ending in files
Closed this issue · 2 comments
PyShp Version
head
Python Version
Any
Your code
Two related issues:
- changelog.txt, LICENSE.TXT and shapefile.py have DOS CRLF line endings while the others do not.
- LICENSE.TXT has `Non-ISO extended-ASCII text`. The current standard for the MIT license does not have these: https://spdx.org/licenses/MIT.html
Using the unix file command:
file --version
file-5.45
magic file from /etc/magic:/usr/share/misc/magic
file *
gives
changelog.txt: ASCII text, with CRLF line terminators
LICENSE.TXT: Non-ISO extended-ASCII text, with very long lines (458), with CRLF line terminators
MANIFEST.in: ASCII text
__pycache__: directory
pyproject.toml: ASCII text
pytest.ini: ASCII text
README.md: Unicode text, UTF-8 text, with very long lines (1103)
requirements.test.txt: ASCII text
setup.cfg: ASCII text
setup.py: Python script, ASCII text executable
shapefile.py: Python script, ASCII text executable, with CRLF line terminators
shapefiles: directory
test_shapefile.py: Python script, ASCII text executable
### Full stacktrace
```shell
None
Other notes
No response
Fixed by e9a5fce, adding .gitattributes with * eol=crlf
ubuntu@Dev:/tmp$ git clone --depth=1 https://github.com/GeospatialPython/pyshp
git clone --depth=1 https://github.com/Geo
spatialPython/pyshp
Cloning into 'pyshp'...
remote: Enumerating objects: 81, done.
remote: Counting objects: 100% (81/81), done.
remote: Compressing objects: 100% (73/73), done.
remote: Total 81 (delta 17), reused 47 (delta 4), pack-reused 0 (from 0)
Receiving objects: 100% (81/81), 2.02 MiB | 11.37 MiB/s, done.
Resolving deltas: 100% (17/17), done.
ubuntu@Dev:/tmp$
ubuntu@Dev:/tmp$ file pyshp/*
f
ile pyshp/*
pyshp/LICENSE.TXT: Non-ISO extended-ASCII text, with very long lines (458), with CRLF line terminators
pyshp/MANIFEST.in: ASCII text, with CRLF line terminators
pyshp/README.md: Unicode text, UTF-8 text, with very long lines (1103), with CRLF line terminators
pyshp/changelog.txt: ASCII text, with CRLF line terminators
pyshp/pyproject.toml: ASCII text, with CRLF line terminators
pyshp/pytest.ini: ASCII text, with CRLF line terminators
pyshp/requirements.test.txt: ASCII text, with CRLF line terminators
pyshp/setup.cfg: Generic INItialization configuration [options]
pyshp/setup.py: Python script, ASCII text executable, with CRLF line terminators
pyshp/shapefile.py: Python script, ASCII text executable, with CRLF line terminators
pyshp/shapefiles: directory
pyshp/test_shapefile.py: Python script, ASCII text executable, with CRLF line terminators
(Apologies for the stdin repetition - I haven't worked out how to configure Fabric to make a nice repl yet. PRs welcome ;-) :
https://github.com/JamesParrott/ssh_from_env)
Just a heads up - I've switched from cr/lf to lf.
I was too eager when applying my quick fix, and I broke the doctests - Doh! See below the example for Python 3.11.
I'm not sure why, but historically, shapefiles have been checked in to version control in PyShp. CR/LF caused the the doctest repl sessions (defined in the Readme.md, run by the main
function) to fail. There are errors in the Github Action log mentioning .dbf corruption. I'm not sure why Git would apply * eol=crlf to the /Shapefile/*.dbf without a ** pattern, let alone binaries but it's fixed now.