Skip to content

Commit

Permalink
Merge pull request #2744 from mashehu/make-filecmp-less-strict
Browse files Browse the repository at this point in the history
linting: add looser comparison when linting pipeline logos
  • Loading branch information
mashehu authored Feb 12, 2024
2 parents 201562c + 1d9839e commit d7610a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
### Linting

- make creat-lint-wf composable ([#2733](https://github.com/nf-core/tools/pull/2733))
- add looser comparison when pipeline logos ([#2744](https://github.com/nf-core/tools/pull/2744))

### Modules

Expand Down
11 changes: 10 additions & 1 deletion nf_core/lint/files_unchanged.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import filecmp
import logging
import os
import shutil
import tempfile
from pathlib import Path
Expand Down Expand Up @@ -162,7 +163,15 @@ def _tf(file_path: Union[str, Path]) -> Path:
if filecmp.cmp(_pf(f), _tf(f), shallow=True):
passed.append(f"`{f}` matches the template")
else:
if "files_unchanged" in self.fix:
if (
f.name.endswith(".png")
and os.stat(_pf(f)).st_mode == os.stat(_tf(f)).st_mode
and int(os.stat(_pf(f)).st_size / 100) == int(os.stat(_tf(f)).st_size / 100)
):
# almost the same file, good enough for the logo
log.debug(f"Files are almost the same. Will pass: {f}")
passed.append(f"`{f}` matches the template")
elif "files_unchanged" in self.fix:
# Try to fix the problem by overwriting the pipeline file
shutil.copy(_tf(f), _pf(f))
passed.append(f"`{f}` matches the template")
Expand Down

0 comments on commit d7610a1

Please sign in to comment.