Skip to content

Commit

Permalink
Do not spam Created directory to stderr on each get_filename4code
Browse files Browse the repository at this point in the history
  • Loading branch information
Felixoid committed Jun 24, 2024
1 parent 5c6c195 commit b89f2b4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pandocfilters.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ def get_filename4code(module, content, ext=None):
else:
imagedir = module + "-images"
fn = hashlib.sha1(content.encode(sys.getfilesystemencoding())).hexdigest()
try:
os.makedirs(imagedir, exist_ok=True)
sys.stderr.write('Created directory ' + imagedir + '\n')
except OSError:
sys.stderr.write('Could not create directory "' + imagedir + '"\n')
if not os.path.isdir(imagedir):
try:
os.makedirs(imagedir)
sys.stderr.write('Created directory ' + imagedir + '\n')
except OSError:
sys.stderr.write('Could not create directory "' + imagedir + '"\n')
if ext:
fn += "." + ext
return os.path.join(imagedir, fn)
Expand Down

0 comments on commit b89f2b4

Please sign in to comment.