Skip to content

Commit

Permalink
Ready for release (maybe)
Browse files Browse the repository at this point in the history
  • Loading branch information
nimaid committed Jul 21, 2020
1 parent ac1f74b commit 7c396fc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
Binary file modified Example PDF.pdf
Binary file not shown.
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,24 @@ $ bookdir2pdf.py --input_dir test_dir/ --table_of_contents
... [output removed] ...
test_dir - Table of Contents
----------------------------
Page #1 00. Cover Page
Page #2 --- 01. Empty Directory Example
Page #2 --- --- 01. Nested Empty Directory Level 1
Page #2 --- --- --- 01. Nested Empty Directory Level 2
Page #2 --- --- --- --- 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: 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] ...
```
13 changes: 8 additions & 5 deletions bookdir2pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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))
Expand Down
Empty file.

0 comments on commit 7c396fc

Please sign in to comment.