Skip to content

Commit

Permalink
Merge pull request #10 from sbrunner/rm-progress
Browse files Browse the repository at this point in the history
Remove the process folder
  • Loading branch information
sbrunner committed Apr 2, 2019
2 parents 446a050 + 7bc9c92 commit b8e542a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 7 additions & 8 deletions process
Original file line number Diff line number Diff line change
Expand Up @@ -438,15 +438,12 @@ def transform(config, config_file_name, root_folder):
if config['args']['assisted_split']:
config['assisted_split'] = []

dest_folder = os.path.join(root_folder, 'process') # TODO, pylint: disable=fixme
if not os.path.exists(dest_folder):
os.makedirs(dest_folder)
for index, img in enumerate(config['images']):
config['process_count'] = 0
image_name = os.path.basename(img)
image_path = os.path.join(dest_folder, image_name)
process_file = tempfile.NamedTemporaryFile(suffix='.png')
image_path = process_file.name
shutil.copyfile(os.path.join(root_folder, img), image_path)
context = Context(config, config_file_name, root_folder, image_name)
context = Context(config, config_file_name, root_folder, os.path.basename(img))
context.image = cv2.imread(image_path)
force_cleanup(context, config)
precrop(context)
Expand Down Expand Up @@ -558,7 +555,8 @@ def split(config, root_folder, config_file_name):
else:
value = width if vertical else height
margin = 0
img2 = os.path.join(root_folder, 'process', 'image-{}.png'.format(destination)) # TODO, pylint: disable=fixme
process_file = tempfile.NamedTemporaryFile(suffix='.png')
img2 = process_file.name
if vertical:
call(CONVERT + [
'-crop', '{}x{}+{}+0'.format(value - margin - last_pos, height, last_pos),
Expand Down Expand Up @@ -599,7 +597,8 @@ def split(config, root_folder, config_file_name):
if element['vertical'] != vertical:
raise Exception("Mix of limit type for page '{}'".format(page))

img = os.path.join(root_folder, 'process', 'image-{}.png'.format(page))
process_file = tempfile.NamedTemporaryFile(suffix='.png')
img = process_file.name
call(CONVERT + [e['name'] for e in sorted(items, key=lambda e: e['pos'])] + [
'-background', '#ffffff', '-append' if vertical else '+append', img
])
Expand Down
2 changes: 2 additions & 0 deletions tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ def test_full(progress, experimental):
os.environ['PROGRESS'] = progress
os.environ['EXPERIMENTAL'] = experimental
root_folder = '/results/full-{}-{}/'.format(progress, experimental)
if not os.path.exists(root_folder):
os.makedirs(root_folder)
config = {
'args': {
'assisted_split': False,
Expand Down

0 comments on commit b8e542a

Please sign in to comment.