-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
packageize
- Loading branch information
Showing
13 changed files
with
148 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
[flake8] | ||
max-line-length = 132 | ||
exclude = .git,__pycache__,.eggs/,doc/,docs/,build/,dist/,archive/ | ||
exclude = .git,__pycache__,.eggs/,doc/,docs/,build/,dist/,archive/ | ||
per-file-ignores = | ||
__init__.py:F401 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# These are supported funding model platforms | ||
|
||
github: [scivision] | ||
ko_fi: scivision |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: ci | ||
|
||
on: | ||
push: | ||
paths: | ||
- "**.py" | ||
- ".github/workflows/ci.yml" | ||
pull_request: | ||
paths: | ||
- "**.py" | ||
- ".github/workflows/ci.yml" | ||
|
||
jobs: | ||
|
||
linux: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions/setup-python@v1 | ||
with: | ||
python-version: '3.x' | ||
- run: pip install .[tests,lint] | ||
- run: flake8 | ||
- run: mypy . | ||
- run: pytest | ||
working-directory: tests | ||
|
||
integration: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [windows-latest, macos-latest] | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions/setup-python@v1 | ||
with: | ||
python-version: '3.x' | ||
- run: pip install .[tests] | ||
- run: pytest | ||
working-directory: tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .base import files_to_meld, meld_files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import typing | ||
from pathlib import Path | ||
import shutil | ||
import subprocess | ||
import logging | ||
import filecmp | ||
|
||
try: | ||
import ghlinguist as ghl | ||
except (ImportError, FileNotFoundError): | ||
ghl = None | ||
|
||
|
||
def files_to_meld(root: Path, ref: Path, language: str = None, strict: bool = False) -> typing.Iterator[Path]: | ||
|
||
si = 1 if strict else 2 | ||
|
||
ref = Path(ref).expanduser() | ||
if not ref.is_file(): | ||
raise FileNotFoundError(f"specify a reference file, not a directory {ref}") | ||
|
||
root = Path(root).expanduser() | ||
if not root.is_dir(): | ||
raise NotADirectoryError(f"{root} is not a directory") | ||
|
||
for new in root.rglob(ref.name): | ||
if new.samefile(ref): | ||
continue | ||
|
||
if filecmp.cmp(new, ref, shallow=False): # type: ignore # mypy .pyi needs updating | ||
logging.info(f"SAME: {new.parent}") | ||
continue | ||
|
||
if language and ghl is not None: | ||
langlist = ghl.linguist(new.parent) | ||
if langlist is None: | ||
logging.info(f"SKIP: {new.parent}") | ||
continue | ||
|
||
thislangs = [l[0] for l in langlist[:si]] | ||
if language not in thislangs: | ||
logging.info(f"SKIP: {new.parent} {thislangs}") | ||
continue | ||
|
||
yield new | ||
|
||
|
||
def meld_files(ref: Path, new: Path, rexe: str): | ||
""" | ||
run file comparison program (often meld) on file pair | ||
""" | ||
|
||
exe = shutil.which(rexe) | ||
if not exe: | ||
raise FileNotFoundError(f"{rexe} not found. Try -n option to just see which files differ.") | ||
# Not using check_call due to spurious errors | ||
new = Path(new).expanduser() | ||
ref = Path(ref).expanduser() | ||
subprocess.run([exe, str(ref), str(new)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
[build-system] | ||
requires = ["setuptools", "wheel"] | ||
requires = ["setuptools", "wheel"] | ||
|
||
[tool.black] | ||
line-length = 132 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[pytest] | ||
addopts = -ra -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters