Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the process folder #10

Merged
merged 1 commit into from
Apr 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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