From 8ba09fa5d2ae401d2a4ec5331eecf02a08cafff6 Mon Sep 17 00:00:00 2001 From: Gabriel Ramirez Date: Tue, 2 Feb 2016 10:50:34 -0500 Subject: [PATCH] removing complexity in certifications to gitbook --- src/renderers/certifications_to_gitbook.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/renderers/certifications_to_gitbook.py b/src/renderers/certifications_to_gitbook.py index 312f48e1..3395162a 100644 --- a/src/renderers/certifications_to_gitbook.py +++ b/src/renderers/certifications_to_gitbook.py @@ -23,18 +23,22 @@ def is_url(item_path): return True +def export_local_files(item_path, io_paths): + """ Export local files to the new directory """ + if io_paths: + output_path = os.path.join(io_paths['output'], 'artifacts', item_path) + input_path = os.path.join(io_paths['input'], item_path) + utils.create_dir(os.path.dirname(output_path)) + if not os.path.exists(output_path) or not filecmp.cmp(input_path, output_path): + shutil.copy(input_path, output_path) + + def prepare_locally_stored_files(element, io_paths): """ Prepare the files by moving locally stored files to the `artifacts` directory and linking filepaths to that directory """ item_path = element.get('path') if item_path and not is_url(item_path): element['path'] = os.path.join('/artifacts', item_path).replace('\\', '/') - if io_paths: - output_path = os.path.join(io_paths['output'], 'artifacts', item_path) - input_path = os.path.join(io_paths['input'], item_path) - utils.create_dir(os.path.dirname(output_path)) - if not os.path.exists(output_path) or not filecmp.cmp(input_path, output_path): - shutil.copy(input_path, output_path) def convert_element(element, io_paths=None):