-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use configured exclude patterns (#63)
* feat: read exclude patterns * fix: rename existing unit test * feat: add exclude patterns when copying project * bump version to 1.6.0 * refactor: use same exclude patterns for copying project and packages
- Loading branch information
1 parent
1804fcc
commit da1bab7
Showing
7 changed files
with
114 additions
and
28 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import shutil | ||
from pathlib import Path | ||
from typing import Set | ||
|
||
defaults_to_ignore = { | ||
"*.pyc", | ||
"__pycache__", | ||
".venv", | ||
".mypy_cache", | ||
"node_modules", | ||
".git", | ||
} | ||
|
||
|
||
def copy_tree(source: Path, destination: Path, exclude_patterns: Set[str]) -> str: | ||
to_ignore = defaults_to_ignore.union(exclude_patterns) | ||
|
||
return shutil.copytree( | ||
source.as_posix(), | ||
destination.as_posix(), | ||
ignore=shutil.ignore_patterns(*to_ignore), | ||
dirs_exist_ok=True, | ||
) |
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
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
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,54 @@ | ||
import tomlkit | ||
|
||
from poetry_multiproject_plugin.components.toml import read | ||
|
||
pyproject = """\ | ||
[tool.poetry] | ||
""" | ||
|
||
pyproject_with_exclude_pattern = """\ | ||
[tool.poetry] | ||
exclude = ["testing.json"] | ||
""" | ||
|
||
pyproject_with_complex_exclude_pattern = """\ | ||
[tool.poetry] | ||
exclude = [{"path" = "testing.json"}] | ||
""" | ||
|
||
pyproject_with_complex_exclude_pattern_containing_format = """\ | ||
[tool.poetry] | ||
exclude = [{"path" = "testing.json", "format" = "wheel"}] | ||
""" | ||
|
||
|
||
def test_read_exclude_pattern_should_return_empty_result(): | ||
data = tomlkit.loads(pyproject) | ||
|
||
res = read.parse_exclude_patterns(data) | ||
|
||
assert res == set() | ||
|
||
|
||
def test_read_exclude_pattern_should_return_patterns_to_exclude(): | ||
data = tomlkit.loads(pyproject_with_exclude_pattern) | ||
|
||
res = read.parse_exclude_patterns(data) | ||
|
||
assert res == {"testing.json"} | ||
|
||
|
||
def test_read_complex_exclude_pattern_should_return_patterns_to_exclude(): | ||
data = tomlkit.loads(pyproject_with_complex_exclude_pattern_containing_format) | ||
|
||
res = read.parse_exclude_patterns(data) | ||
|
||
assert res == set() | ||
|
||
|
||
def test_read_complex_exclude_pattern_with_format_should_return_empty_result(): | ||
data = tomlkit.loads(pyproject_with_complex_exclude_pattern) | ||
|
||
res = read.parse_exclude_patterns(data) | ||
|
||
assert res == {"testing.json"} |