@@ -589,10 +589,7 @@ def render_figures(code, code_path, output_dir, output_base, context,
589
589
# We didn't find the files, so build them
590
590
591
591
results = []
592
- if context :
593
- ns = plot_context
594
- else :
595
- ns = {}
592
+ ns = plot_context if context else {}
596
593
597
594
if context_reset :
598
595
clear_state (config .plot_rcparams )
@@ -717,9 +714,7 @@ def run(arguments, content, options, state_machine, state, lineno):
717
714
718
715
# determine output directory name fragment
719
716
source_rel_name = relpath (source_file_name , setup .confdir )
720
- source_rel_dir = os .path .dirname (source_rel_name )
721
- while source_rel_dir .startswith (os .path .sep ):
722
- source_rel_dir = source_rel_dir [1 :]
717
+ source_rel_dir = os .path .dirname (source_rel_name ).lstrip (os .path .sep )
723
718
724
719
# build_dir: where to place output files (temporarily)
725
720
build_dir = os .path .join (os .path .dirname (setup .app .doctreedir ),
@@ -729,15 +724,12 @@ def run(arguments, content, options, state_machine, state, lineno):
729
724
# see note in Python docs for warning about symbolic links on Windows.
730
725
# need to compare source and dest paths at end
731
726
build_dir = os .path .normpath (build_dir )
732
-
733
- if not os .path .exists (build_dir ):
734
- os .makedirs (build_dir )
727
+ os .makedirs (build_dir , exist_ok = True )
735
728
736
729
# output_dir: final location in the builder's directory
737
730
dest_dir = os .path .abspath (os .path .join (setup .app .builder .outdir ,
738
731
source_rel_dir ))
739
- if not os .path .exists (dest_dir ):
740
- os .makedirs (dest_dir ) # no problem here for me, but just use built-ins
732
+ os .makedirs (dest_dir , exist_ok = True )
741
733
742
734
# how to link to files from the RST file
743
735
dest_dir_link = os .path .join (relpath (setup .confdir , rst_dir ),
0 commit comments