From 7c396fca0ce19ad2c02e6b522060b6985d1ee964 Mon Sep 17 00:00:00 2001 From: nimaid Date: Mon, 20 Jul 2020 22:15:52 -0700 Subject: [PATCH] Ready for release (maybe) --- Example PDF.pdf | Bin 16519 -> 17312 bytes README.md | 36 +++++++++++++++---------------- bookdir2pdf.py | 13 ++++++----- test_dir/00. Cover Page/03.blank | 0 4 files changed, 26 insertions(+), 23 deletions(-) create mode 100644 test_dir/00. Cover Page/03.blank diff --git a/Example PDF.pdf b/Example PDF.pdf index 7494937789f999a515f36bb1552ff5639d9335cd..1e4a04f4f1fd0294d09c989ff0022de7c6664677 100644 GIT binary patch delta 3449 zcmcInO>9(E6!uLibl%LgogskIr%yJ{Ee1FWP;khv zzOZoq>|zl5)!Ljw8HLrpZR_>~Siq^iQFtlaAL67TjtxnS&eWF{17f+Rru_QZ`Gpgw ze1hOY4#7LwyrNQz)!YsUv!zNL(<&geE3rZ0TDA-y=SBzhN;B@>?N=2Qfv>ZBc^o^Y z3A@r*G$Dx@Nx%9=5>q@JR{VS=77=rau3QF%V$Mp^tAr#D&*b)wIN@Z%YF}_H2;p)r zfQf<$FI%g*nl~Jmv|;4kaJw8wT* z@v8?L^*4ewNpX>Ehd@GcumH2TUvulLI?@ZQd%I3XRKSCv+_vmK4J5u>9OX_uQbN zlUm4bs)gA4(zv;%4lzx;4h*I0fUy==G=}Y(Go)xo;(<>wC&*pa7hcyO#@U2pBQu6v*U%2T(FaplI0j5j^_@mXtj z6c-?0zSnxR>jMwI!5W-}WtKPK&FYE=e={9q7WRvL>puP=qpq|WG4Cn)VJ%~r=hc0- ziXXH-l)riE{#ly9%}`CQeuA@sZ@wTzq}t~xjOn`}g@vJ-+Z4tlbsD5FNz|C8uqd=K znu)*|MNSY*h!X@;u6A=LA!dC>sxnPB1C5qByQZ9a>rlTO%WI@OGr+NzSao4|?NR4#-gkW06Lg1MsA&^ePR307CN zeoS1mrI4i9*%vaB4i+Kl?5RkQB%z^>RFp&zjbX%`Mq?Bi(_Ex`o2zJxo+Atr*@(M}v`m{L~^WjtL%%y8t0VN^*=31reao7Kq|CF~X(Tjoxl nt~bo@^TQ|Kss}>&)k6yl>aT=^_= delta 3084 zcmZuzO=w(I6y{EoHhG!Jzj3T>@-j`d32o=y|9e9Xwy~vXW0HcPv`V7Q!XFZeu_=m< zf)GS3DQ8*4Y@`Tc7vn};xGb%11rdu|H-hfE^!~i*y!Yk!RXpGqfbf3Q59w$~Z-Jn+t7^`I4m z6IdOJ;r^iQDb+S)oXte_<*oH=v12q>r{%>L^xsw}v7v+cvNCK;&5oxTI~rol8k%DM zOuN#oSZVANUFbRi7@US1+ zj9}9l{03YYslctd`_0crzc~QkkCfpGei@EeJ=lEmGJ+db5AGbc;4jVR$L}F{aM**D zqaIwEyo=28GK?iIVQ=oY=E~G<1UqrX5|+#^wHSN)4uTJl`Ot^cK6GOC2L!J@<-n4l z?qL7PPY_&~Nij2OCiq@`7lAtAgTFlG6@Ed!LnYy@EMZT$&AUow&9309pjg?tYpNXt zUzwLH_!YP=%gtMJKbFkue(4$9V5Tzmi8tcN{YVm`Oos{>!=?cRjB_*B1xzT@j{>Ib zelB2|`y7o-Vw|WT2_|+&=YuijW=IMc)8RQm!gEsO&NVCzRysIH5_|pgNk}4ffMFU` zkPsdiAv6hdFwzKvnGAyk#zA6{cVeXy*};fnK}(3X7uG(FcHfECLEkA=fojU^0<}*& zmU5XAW-viQKAGfWZT+d_VX&fMVigV-OGuv3@UbKm!*Dn=j3m5Kbi#-VTEb}9W5z@v znsM9#3tPejYnf|2x^_(3e=PQCmyk&vy6Z5kBC&ffA1iRH$8A1QEPrC^FH|_0lF2}f zyQn9;#8OK`Mk9OXPR>8pGgaw0%6CUgjjBzkC7?XBvBi(xD zT(Cee*1CA@FcF~`B7?\/*: and also means you can make a really long name like this without hitting the path length limit of your OS) -Page #2 02. The First Part -Page #2 --- 01. Chapter 1 -Page #4 --- 02. Chapter 2 -Page #6 03. The Middle Part -Page #6 --- 01. Chapter 3 -Page #8 --- 02. Chapter 4 -Page #10 04. The Final Part -Page #10 --- 01. Chapter 5 -Page #12 --- 02. Chapter 6 - Page count: 13 +Example PDF by https://github.com/nimaid/bookdir2pdf - Table of Contents +------------------------------------------------------------------------ +Page #0 00. Cover Page +Page #1 --- 01. Empty Directory Example +Page #1 --- --- 01. Nested Empty Directory Level 1 +Page #1 --- --- --- 01. Nested Empty Directory Level 2 +Page #1 --- --- --- --- 01. Nested Empty Directory Level 3 +Page #2 Empty Directory .name File Example (allows for forbidden characters like <>?\/*: and also means you can make a really long name like this without hitting the path length limit of your OS) +Page #2 02. The First Part +Page #2 --- 01. Chapter 1 +Page #4 --- 02. Chapter 2 +Page #6 03. The Middle Part +Page #6 --- 01. Chapter 3 +Page #8 --- 02. Chapter 4 +Page #10 04. The Final Part +Page #10 --- 01. Chapter 5 +Page #12 --- 02. Chapter 6 + Page count: 14 ... [output removed] ... ``` \ No newline at end of file diff --git a/bookdir2pdf.py b/bookdir2pdf.py index 4372902..25de240 100644 --- a/bookdir2pdf.py +++ b/bookdir2pdf.py @@ -324,16 +324,19 @@ def path_to_ext(path_in): temp_dir = os.path.join(main_dir, temp_dir_name) if not args["table_of_contents"]: - # Make temp directory - os.mkdir(temp_dir) - - # Set up exit function to clean up if exited early + # Delete temp dir if it exists def clean_temp_dir(): if os.path.exists(temp_dir): if os.path.isdir(temp_dir): shutil.rmtree(temp_dir) elif os.path.isfile(temp_dir): os.remove(temp_dir) + clean_temp_dir() + + # Make temp directory + os.mkdir(temp_dir) + + # Set up exit function to clean up if exited early def exit_clean_temp_dir(): print("Delete temporary directory: {}".format(temp_dir)) clean_temp_dir() @@ -515,7 +518,7 @@ def exit_clean_temp_dir(): else: blanks_used = False - if blanks_used: + if blanks_used and not args["table_of_contents"]: print() print("-------- BLANK PAGES --------") print("Saving blank page images to temporary directory: {}".format(final_input_dir)) diff --git a/test_dir/00. Cover Page/03.blank b/test_dir/00. Cover Page/03.blank new file mode 100644 index 0000000..e69de29