File tree Expand file tree Collapse file tree 1 file changed +3
-10
lines changed Expand file tree Collapse file tree 1 file changed +3
-10
lines changed Original file line number Diff line number Diff line change 1+ from contextlib import suppress
12from datetime import datetime
23from importlib import metadata
34from urllib .parse import urljoin
4- import errno
55import os
66import urllib .request
77
@@ -30,11 +30,7 @@ def setup(app):
3030
3131 app .add_config_value ("cache_path" , "_cache" , "" )
3232
33- try :
34- os .makedirs (app .config .cache_path )
35- except OSError as error :
36- if error .errno != errno .EEXIST :
37- raise
33+ os .makedirs (app .config .cache_path , exist_ok = True )
3834
3935 path = os .path .join (app .config .cache_path , "spec.html" )
4036 spec = fetch_or_load (path )
@@ -61,13 +57,10 @@ def fetch_or_load(spec_path):
6157 ),
6258 }
6359
64- try :
60+ with suppress ( FileNotFoundError ) :
6561 modified = datetime .utcfromtimestamp (os .path .getmtime (spec_path ))
6662 date = modified .strftime ("%a, %d %b %Y %I:%M:%S UTC" )
6763 headers ["If-Modified-Since" ] = date
68- except OSError as error :
69- if error .errno != errno .ENOENT :
70- raise
7164
7265 request = urllib .request .Request (VALIDATION_SPEC , headers = headers )
7366 response = urllib .request .urlopen (request , cafile = certifi .where ())
You can’t perform that action at this time.
0 commit comments