Skip to content

Commit

Permalink
Don't scaffold pycache or pyc (#168)
Browse files Browse the repository at this point in the history
* Don't scaffold pycache or pyc

* Add note
  • Loading branch information
cidrblock authored May 2, 2024
1 parent 7ec5560 commit 97db4a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/ansible_creator/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@
"DEV_CONTAINER_IMAGE": "ghcr.io/ansible/community-ansible-dev-tools:latest",
"DEV_FILE_IMAGE": "ghcr.io/ansible/ansible-workspace-env-reference:latest",
}

# directory names that will be skipped in any resource
SKIP_DIRS = ("__pycache__",)
# file types that will be skipped in any resource
SKIP_FILES_TYPES = (".pyc",)
6 changes: 5 additions & 1 deletion src/ansible_creator/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import yaml

from ansible_creator.constants import GLOBAL_TEMPLATE_VARS
from ansible_creator.constants import GLOBAL_TEMPLATE_VARS, SKIP_DIRS, SKIP_FILES_TYPES


if TYPE_CHECKING:
Expand Down Expand Up @@ -104,6 +104,8 @@ def _recursive_copy(
dest_path = dest_path.replace(key, template_data.get(val, ""))

if obj.is_dir():
if obj.name in SKIP_DIRS:
continue
if not os.path.exists(dest_path):
os.makedirs(dest_path)

Expand All @@ -114,6 +116,8 @@ def _recursive_copy(
)

elif obj.is_file():
if obj.name.split(".")[-1] in SKIP_FILES_TYPES:
continue
if obj.name == "__meta__.yml":
continue
# remove .j2 suffix at destination
Expand Down

0 comments on commit 97db4a5

Please sign in to comment.