Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 45ad14f

Browse files
make sure input glob is converted to a list immediately
1 parent 9782ac2 commit 45ad14f

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

‎src/snippet/config.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import toml
66

77
from snippet.logs import logger
8+
from snippet.util import ensure_list
89

910

1011
class Config:
@@ -87,6 +88,8 @@ def get_config(config_paths=None, **options):
8788
setattr(config, k, v)
8889

8990
# validate and set IO directories that are relative to project root
90-
config.input_glob = os.path.abspath(os.path.join(config.project_root, config.input_glob))
91+
config.input_glob = [
92+
os.path.abspath(os.path.join(config.project_root, pattern)) for pattern in ensure_list(config.input_glob)
93+
]
9194
config.output_dir = os.path.abspath(os.path.join(config.project_root, config.output_dir))
9295
return config

‎src/snippet/file_wrangler.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def write_example(config: Config, example_name, example_block):
2020

2121
output_file_name = pystache.render(
2222
config.output_file_name_template,
23-
name=example_name.strip().replace(' ', '')
23+
name=example_name.strip().replace(' ', '_').lower()
2424
)
2525

2626
if not os.path.exists(config.output_dir):
@@ -41,8 +41,7 @@ def load_file_lines(path):
4141

4242
def find_files(config: Config):
4343
"""Finds input file paths, according to the config"""
44-
globs = config.input_glob if isinstance(config.input_glob, list) else [config.input_glob]
4544
files = []
46-
for glob_pattern in globs:
45+
for glob_pattern in config.input_glob:
4746
files.extend(glob.glob(glob_pattern, recursive=True))
4847
return files

‎src/snippet/util.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def ensure_list(item):
2+
return item if isinstance(item, list) else [item]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /