@@ -72,40 +72,46 @@ def verify_folders(root, config):
7272 "reports/figures" ,
7373 config ["module_name" ],
7474 }
75+ ignored_dirs = set ()
7576
7677 if config ["include_code_scaffold" ] == "Yes" :
7778 expected_dirs .add (f"{ config ['module_name' ]} /modeling" )
7879
7980 if config ["docs" ] == "mkdocs" :
8081 expected_dirs .add ("docs/docs" )
81-
82+
8283 if config ["version_control" ] in ("git (local)" , "git (github)" ):
8384 # Expected after `git init`
84- expected_dirs .update ({
85- ".git" ,
86- ".git/hooks " ,
87- ".git/info " ,
88- ".git/objects " ,
89- ".git/objects/info " ,
90- ".git/objects/pack " ,
91- ".git/refs" ,
92- ".git/refs/heads " ,
93- ".git/refs/tags" ,
94- } )
85+ expected_dirs .update (
86+ {
87+ ".git" ,
88+ ".git/hooks " ,
89+ ".git/info " ,
90+ ".git/objects" ,
91+ ".git/refs " ,
92+ ".git/refs/heads " ,
93+ ".git/refs/tags " ,
94+ }
95+ )
9596 # Expected after initial git commit
96- # expected_dirs += [
97- # ".git/logs",
98- # ".git/logs/refs",
99- # ".git/logs/refs/heads",
100- # ]
97+ expected_dirs .update (
98+ {
99+ ".git/logs" ,
100+ ".git/logs/refs" ,
101+ ".git/logs/refs/heads" ,
102+ }
103+ )
104+ ignored_dirs .update (
105+ {d .relative_to (root ) for d in root .glob (".git/objects/**/*" ) if d .is_dir ()}
106+ )
101107
102108 expected_dirs = {Path (d ) for d in expected_dirs }
103109
104110 existing_dirs = {
105111 d .resolve ().relative_to (root ) for d in root .glob ("**" ) if d .is_dir ()
106112 }
107113
108- assert sorted (existing_dirs ) == sorted (expected_dirs )
114+ assert sorted (existing_dirs - ignored_dirs ) == sorted (expected_dirs )
109115
110116
111117def verify_files (root , config ):
@@ -130,88 +136,90 @@ def verify_files(root, config):
130136 f"{ config ['module_name' ]} /__init__.py" ,
131137 }
132138
139+ ignored_files = set ()
140+
133141 # conditional files
134142 if not config ["open_source_license" ].startswith ("No license" ):
135143 expected_files .add ("LICENSE" )
136144
137145 if config ["include_code_scaffold" ] == "Yes" :
138- expected_files .update ({
139- f"{ config ['module_name' ]} /config.py" ,
140- f"{ config ['module_name' ]} /dataset.py" ,
141- f"{ config ['module_name' ]} /features.py" ,
142- f"{ config ['module_name' ]} /modeling/__init__.py" ,
143- f"{ config ['module_name' ]} /modeling/train.py" ,
144- f"{ config ['module_name' ]} /modeling/predict.py" ,
145- f"{ config ['module_name' ]} /plots.py" ,
146- })
146+ expected_files .update (
147+ {
148+ f"{ config ['module_name' ]} /config.py" ,
149+ f"{ config ['module_name' ]} /dataset.py" ,
150+ f"{ config ['module_name' ]} /features.py" ,
151+ f"{ config ['module_name' ]} /modeling/__init__.py" ,
152+ f"{ config ['module_name' ]} /modeling/train.py" ,
153+ f"{ config ['module_name' ]} /modeling/predict.py" ,
154+ f"{ config ['module_name' ]} /plots.py" ,
155+ }
156+ )
147157
148158 if config ["docs" ] == "mkdocs" :
149- expected_files .update ({
150- "docs/mkdocs.yml" ,
151- "docs/README.md" ,
152- "docs/docs/index.md" ,
153- "docs/docs/getting-started.md" ,
154- })
155-
156- if config ["version_control" ] in ("git (local)" , "git (github)" ):
157- # Expected after `git init`
158- expected_files .update ({
159- ".git/config" ,
160- ".git/description" ,
161- ".git/HEAD" ,
162- ".git/hooks/applypatch-msg.sample" ,
163- ".git/hooks/commit-msg.sample" ,
164- ".git/hooks/fsmonitor-watchman.sample" ,
165- ".git/hooks/post-update.sample" ,
166- ".git/hooks/pre-applypatch.sample" ,
167- ".git/hooks/pre-commit.sample" ,
168- ".git/hooks/pre-merge-commit.sample" ,
169- ".git/hooks/pre-push.sample" ,
170- ".git/hooks/pre-rebase.sample" ,
171- ".git/hooks/pre-receive.sample" ,
172- ".git/hooks/prepare-commit-msg.sample" ,
173- ".git/hooks/push-to-checkout.sample" ,
174- ".git/hooks/sendemail-validate.sample" ,
175- ".git/hooks/update.sample" ,
176- ".git/info/exclude" ,
177- })
178- # Expected after initial git commit
179- # expected_files += [
180- # ".git/COMMIT_EDITMSG",
181- # ".git/FETCH_HEAD",
182- # ".git/index",
183- # ".git/logs/HEAD",
184- # ".git/logs/refs/heads/main",
185- # ".git/refs/heads/main",
186- # ]
159+ expected_files .update (
160+ {
161+ "docs/mkdocs.yml" ,
162+ "docs/README.md" ,
163+ "docs/docs/index.md" ,
164+ "docs/docs/getting-started.md" ,
165+ }
166+ )
187167
188168 expected_files .add (config ["dependency_file" ])
189-
190- ignored_files = set ()
191-
169+
192170 if config ["version_control" ] in ("git (local)" , "git (github)" ):
193- ignored_files .update ({
194- f .relative_to (root )
195- for f in root .glob (".git/objects/*" )
196- if f .is_file ()
197- })
171+ # Expected after `git init`
172+ expected_files .update (
173+ {
174+ ".git/config" ,
175+ ".git/description" ,
176+ ".git/HEAD" ,
177+ ".git/hooks/applypatch-msg.sample" ,
178+ ".git/hooks/commit-msg.sample" ,
179+ ".git/hooks/fsmonitor-watchman.sample" ,
180+ ".git/hooks/post-update.sample" ,
181+ ".git/hooks/pre-applypatch.sample" ,
182+ ".git/hooks/pre-commit.sample" ,
183+ ".git/hooks/pre-merge-commit.sample" ,
184+ ".git/hooks/pre-push.sample" ,
185+ ".git/hooks/pre-rebase.sample" ,
186+ ".git/hooks/pre-receive.sample" ,
187+ ".git/hooks/prepare-commit-msg.sample" ,
188+ ".git/hooks/push-to-checkout.sample" ,
189+ ".git/hooks/sendemail-validate.sample" ,
190+ ".git/hooks/update.sample" ,
191+ ".git/info/exclude" ,
192+ }
193+ )
194+ # Expected after initial git commit
195+ expected_files .update (
196+ {
197+ ".git/COMMIT_EDITMSG" ,
198+ ".git/index" ,
199+ ".git/logs/HEAD" ,
200+ ".git/logs/refs/heads/main" ,
201+ ".git/refs/heads/main" ,
202+ }
203+ )
204+ ignored_files .update (
205+ {f .relative_to (root ) for f in root .glob (".git/objects/**/*" ) if f .is_file ()}
206+ )
198207
199208 expected_files = {Path (f ) for f in expected_files }
200209
201210 existing_files = {f .relative_to (root ) for f in root .glob ("**/*" ) if f .is_file ()}
202211
203- assert sorted (existing_files - ignored_files ) == sorted (expected_files )
204-
212+ checked_files = existing_files - ignored_files
213+
214+ assert sorted (checked_files ) == sorted (expected_files )
215+
205216 # Ignore files where curlies may exist but aren't unrendered jinja tags
206217 ignore_curly_files = {
207- ".git/hooks/fsmonitor-watchman.sample"
218+ Path (".git/hooks/fsmonitor-watchman.sample" ),
219+ Path (".git/index" ),
208220 }
209221
210- assert all (
211- no_curlies (root / f )
212- for f in existing_files
213- if str (f ) not in ignore_curly_files
214- )
222+ assert all (no_curlies (root / f ) for f in checked_files - ignore_curly_files )
215223
216224
217225def verify_makefile_commands (root , config ):
0 commit comments