Skip to content

Commit

Permalink
avoid using include_hidden glob
Browse files Browse the repository at this point in the history
  • Loading branch information
madeindjs committed Jan 23, 2025
1 parent 2c459fe commit 52cf981
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/writer/wf_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,16 +335,21 @@ def build_source_files(app_path: str) -> SourceFilesDirectory:
>>> {'type': 'directory', 'children': {'README.md': {'type': 'file', 'content': 'This app w', 'complete': False}}}
"""
files = glob.glob(os.path.join(app_path, '**', "*"), recursive=True, include_hidden=True)
def load_persisted_script(file: str) -> str:
path = os.path.join(app_path, file)
with open(path, "r", encoding='utf-8') as f:
return f.read()

# we can't use `glob`'s `include_hidden` options since it's only available on Python 3.11+
files = []
for pattern in ['**/*', '**/.*', '.**/*', '.**/.*']:
files += glob.glob(os.path.join(app_path, pattern), recursive=True)

file_tree: SourceFilesDirectory = {
"type": "directory",
"children": {}
}

def load_persisted_script(file: str) -> str:
path = os.path.join(app_path, file)
with open(path, "r", encoding='utf-8') as f:
return f.read()

for file in files:
relative_path = os.path.relpath(file, app_path)
Expand Down

0 comments on commit 52cf981

Please sign in to comment.