Repository: comic/evalutils

Issue:
Generating the project template under windows results in windows line endings

Comments:

Patch:
diff --git a/evalutils/evalutils.py b/evalutils/evalutils.py
index b2663b0..e18b6dd 100644
--- a/evalutils/evalutils.py
+++ b/evalutils/evalutils.py
@@ -9,9 +9,9 @@ from warnings import warn
 
 from pandas import DataFrame, merge, Series, concat
 
-from evalutils.utils import score_detection
 from .exceptions import FileLoaderError, ValidationError, ConfigurationError
 from .io import first_int_in_filename_key, FileLoader, CSVLoader
+from .scorers import score_detection
 from .validators import DataFrameValidator
 
 logger = logging.getLogger(__name__)
diff --git a/evalutils/utils.py b/evalutils/scorers.py
similarity index 100%
rename from evalutils/utils.py
rename to evalutils/scorers.py
diff --git a/evalutils/template/hooks/post_gen_project.py b/evalutils/template/hooks/post_gen_project.py
index cb52c5f..bb902c3 100644
--- a/evalutils/template/hooks/post_gen_project.py
+++ b/evalutils/template/hooks/post_gen_project.py
@@ -3,12 +3,16 @@ import os
 import shutil
 from pathlib import Path
 
-templated_python_files = Path(os.getcwd()).glob('*.py.j2')
+CHALLENGE_KIND = "{{ cookiecutter.challenge_kind }}"
+
+EOL_UNIX = b"\n"
+EOL_WIN = b"\r\n"
+EOL_MAC = b"\r"
+
+templated_python_files = Path(os.getcwd()).glob("*.py.j2")
 for f in templated_python_files:
     shutil.move(f.name, f.stem)
 
-challenge_kind = "{{ cookiecutter.challenge_kind }}"
-
 
 def remove_classification_files():
     os.remove(Path("ground-truth") / "reference.csv")
@@ -29,11 +33,38 @@ def remove_detection_files():
     os.remove(Path("test") / "detection-submission.csv")
 
 
-if challenge_kind.lower() != "segmentation":
+if CHALLENGE_KIND.lower() != "segmentation":
     remove_segmentation_files()
 
-if challenge_kind.lower() != "detection":
+if CHALLENGE_KIND.lower() != "detection":
     remove_detection_files()
 
-if challenge_kind.lower() != "classification":
+if CHALLENGE_KIND.lower() != "classification":
     remove_classification_files()
+
+
+def convert_line_endings():
+    """ Enforce unix line endings for the generated files """
+    files = []
+    for ext in [
+        ".py",
+        ".sh",
+        "Dockerfile",
+        ".txt",
+        ".csv",
+        ".mhd",
+        ".gitignore",
+    ]:
+        files.extend(Path(".").glob(f"**/*{ext}"))
+
+    for file in files:
+        with open(file, "rb") as f:
+            lines = f.read()
+
+        lines = lines.replace(EOL_WIN, EOL_UNIX).replace(EOL_MAC, EOL_UNIX)
+
+        with open(file, "wb") as f:
+            f.write(lines)
+
+
+convert_line_endings()
diff --git a/evalutils/template/{{ cookiecutter.package_name }}/.gitignore b/evalutils/template/{{ cookiecutter.package_name }}/.gitignore
new file mode 100644
index 0000000..13f175c
--- /dev/null
+++ b/evalutils/template/{{ cookiecutter.package_name }}/.gitignore
@@ -0,0 +1,105 @@
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+env/
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+
+# PyInstaller
+#  Usually these files are written by a python script from a template
+#  before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*.cover
+.hypothesis/
+.pytest_cache/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+local_settings.py
+
+# Flask stuff:
+instance/
+.webassets-cache
+
+# Scrapy stuff:
+.scrapy
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+
+# Jupyter Notebook
+.ipynb_checkpoints
+
+# pyenv
+.python-version
+
+# celery beat schedule file
+celerybeat-schedule
+
+# SageMath parsed files
+*.sage.py
+
+# dotenv
+.env
+
+# virtualenv
+.venv
+venv/
+ENV/
+
+# Spyder project settings
+.spyderproject
+.spyproject
+
+# Rope project settings
+.ropeproject
+
+# mkdocs documentation
+/site
+
+# mypy
+.mypy_cache/
+
+# Pycharm
+.idea/


Test patch:
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 22791e2..ba90d2d 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -1,7 +1,7 @@
 from csv import DictReader
 from pathlib import Path
 
-from evalutils.utils import find_hits_for_targets, score_detection
+from evalutils.scorers import find_hits_for_targets, score_detection
 
 
 def load_points_csv(filepath):