@@ -74,7 +74,7 @@ def check_hierarchy_file(folder: str):
7474 hierarchy = []
7575
7676 hierarchy_file = folder / HIERARCHY_FILE
77- if not os . path . exists (hierarchy_file ):
77+ if not hierarchy_file . exists ():
7878 logging .error (f"File { hierarchy_file } does not exist" )
7979 sys .exit (1 )
8080
@@ -135,7 +135,7 @@ def extract_slug(line: str):
135135
136136
137137def sanity_check (path ):
138- if not os . path .exists (path ):
138+ if not path .exists ():
139139 return [f"File { path } does not exist" ]
140140
141141 return check_links (path )
@@ -163,7 +163,7 @@ def check_links(path):
163163 f"{ YELLOW } { len (table_matches )} tables{ RESET } "
164164 )
165165
166- current_dir = path .parent
166+ current_dir = path .resolve (). parent
167167 errors = []
168168
169169 for match in table_matches :
@@ -172,29 +172,26 @@ def check_links(path):
172172 continue
173173
174174 path_to_check = current_dir / match
175- path_to_check = os .path .normpath (path_to_check )
176- if not os .path .exists (path_to_check ):
175+ if not path_to_check .exists ():
177176 errors .append (f" CSV { match } does not exist" )
178177
179178 for match in md_link_matches :
180179 if match [1 ].startswith (("http://" , "https://" , "mailto:" )):
181180 continue
182181
183182 path_to_check = current_dir / match [1 ].split ("#" )[0 ]
184- path_to_check = os .path .normpath (path_to_check )
185183 if any (placeholder in match [1 ] for placeholder in IGNORE_DOCS ):
186184 continue
187- logging .debug (f"{ GREEN } { path_to_check .split ( '/' )[ - 1 ] } { RESET } " )
188- if not os . path . exists (path_to_check ):
185+ logging .debug (f"{ GREEN } { path_to_check .name } { RESET } " )
186+ if not path_to_check . exists ():
189187 errors .append (f" Linked { match [1 ]} does not exist" )
190188
191189 for match in image_link_matches :
192190 path_to_check = current_dir / match .split ("#" )[0 ]
193- path_to_check = os .path .normpath (path_to_check )
194191 if any (placeholder in match for placeholder in IGNORE_IMAGES ):
195192 continue
196- logging .debug (f"{ CYAN } { path_to_check .split ( '/' )[ - 1 ] } { RESET } " )
197- if not os . path . exists (path_to_check ):
193+ logging .debug (f"{ CYAN } { path_to_check .name } { RESET } " )
194+ if not path_to_check . exists ():
198195 errors .append (f" Image { path_to_check } does not exist" )
199196
200197 if errors :
0 commit comments