Skip to content

Commit a166ec9

Browse files
authored
feat: python accept passed files to exclude (#1763)
* feat: python accept passed files to exclude * fix: address Tony feedback * fix: run black * fix: actually finish docstring thought
1 parent bb17135 commit a166ec9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

synthtool/languages/python.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,12 @@ def python_notebooks_testing_pipeline() -> None:
106106
s.copy([NOTEBOOK_TEMPLATE_PATH], excludes=excludes)
107107

108108

109-
def py_samples(*, root: PathOrStr = None, skip_readmes: bool = False) -> None:
109+
def py_samples(
110+
*,
111+
root: PathOrStr = None,
112+
skip_readmes: bool = False,
113+
files_to_exclude: List[str] = [],
114+
) -> None:
110115
"""
111116
Find all samples projects and render templates.
112117
Samples projects always have a 'requirements.txt' file and may also have
@@ -115,6 +120,7 @@ def py_samples(*, root: PathOrStr = None, skip_readmes: bool = False) -> None:
115120
Args:
116121
root (Union[Path, str]): The samples directory root.
117122
skip_readmes (bool): If true, do not generate readmes.
123+
files_to_exclude(List[str]): defaults to empty, but if present, adds files to excludes list
118124
"""
119125
in_client_library = Path("samples").exists() and Path("setup.py").exists()
120126
if root is None:
@@ -123,7 +129,7 @@ def py_samples(*, root: PathOrStr = None, skip_readmes: bool = False) -> None:
123129
else:
124130
root = "."
125131

126-
excludes = []
132+
excludes = files_to_exclude
127133

128134
# todo(kolea2): temporary exclusion until samples are ready to be migrated to new format
129135
excludes.append("README.md")
@@ -142,8 +148,7 @@ def py_samples(*, root: PathOrStr = None, skip_readmes: bool = False) -> None:
142148
sample_project_dir = req.parent
143149
log.info(f"Generating templates for samples project '{sample_project_dir}'")
144150

145-
excludes = ["**/*tmpl*"] # .tmpl. files are partial templates
146-
151+
excludes.append("**/*tmpl*") # .tmpl. files are partial templates
147152
sample_readme_metadata: Dict[str, Any] = {}
148153
if not skip_readmes:
149154
sample_readme_metadata = _get_sample_readme_metadata(sample_project_dir)

0 commit comments

Comments
 (0)