From 4d0f91fec68fb655d48f2cd903a35fd946d46282 Mon Sep 17 00:00:00 2001 From: Constantin Pape <constantin.pape@iwr.uni-heidelberg.de> Date: Thu, 14 Nov 2019 13:52:14 +0100 Subject: [PATCH] Squash the soft-links in latest nuclei table folder --- .../default.csv | 2 +- .../extrapolated_intensity_correction.csv | 2 +- .../morphology.csv | 2 +- scripts/files/copy_helper.py | 25 ++++++++++++++++--- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/data/0.6.5/tables/sbem-6dpf-1-whole-segmented-nuclei-labels/default.csv b/data/0.6.5/tables/sbem-6dpf-1-whole-segmented-nuclei-labels/default.csv index df93135..60df4ef 120000 --- a/data/0.6.5/tables/sbem-6dpf-1-whole-segmented-nuclei-labels/default.csv +++ b/data/0.6.5/tables/sbem-6dpf-1-whole-segmented-nuclei-labels/default.csv @@ -1 +1 @@ -../../../0.6.4/tables/sbem-6dpf-1-whole-segmented-nuclei-labels/default.csv \ No newline at end of file +../../../0.0.0/tables/sbem-6dpf-1-whole-segmented-nuclei-labels/default.csv \ No newline at end of file diff --git a/data/0.6.5/tables/sbem-6dpf-1-whole-segmented-nuclei-labels/extrapolated_intensity_correction.csv b/data/0.6.5/tables/sbem-6dpf-1-whole-segmented-nuclei-labels/extrapolated_intensity_correction.csv index d687ecc..e5dd2bb 120000 --- a/data/0.6.5/tables/sbem-6dpf-1-whole-segmented-nuclei-labels/extrapolated_intensity_correction.csv +++ b/data/0.6.5/tables/sbem-6dpf-1-whole-segmented-nuclei-labels/extrapolated_intensity_correction.csv @@ -1 +1 @@ -../../../0.6.4/tables/sbem-6dpf-1-whole-segmented-nuclei-labels/extrapolated_intensity_correction.csv \ No newline at end of file +../../../0.6.0/tables/sbem-6dpf-1-whole-segmented-nuclei-labels/extrapolated_intensity_correction.csv \ No newline at end of file diff --git a/data/0.6.5/tables/sbem-6dpf-1-whole-segmented-nuclei-labels/morphology.csv b/data/0.6.5/tables/sbem-6dpf-1-whole-segmented-nuclei-labels/morphology.csv index c1efe4a..7226fec 120000 --- a/data/0.6.5/tables/sbem-6dpf-1-whole-segmented-nuclei-labels/morphology.csv +++ b/data/0.6.5/tables/sbem-6dpf-1-whole-segmented-nuclei-labels/morphology.csv @@ -1 +1 @@ -../../../0.6.4/tables/sbem-6dpf-1-whole-segmented-nuclei-labels/morphology.csv \ No newline at end of file +../../../0.0.0/tables/sbem-6dpf-1-whole-segmented-nuclei-labels/morphology.csv \ No newline at end of file diff --git a/scripts/files/copy_helper.py b/scripts/files/copy_helper.py index 0ae50ae..a28229a 100644 --- a/scripts/files/copy_helper.py +++ b/scripts/files/copy_helper.py @@ -5,6 +5,23 @@ from .sources import get_image_names, get_segmentation_names, get_segmentations from ..attributes.base_attributes import write_additional_table_file +def make_squashed_link(src_file, dst_file, override=False): + + if os.path.exists(dst_file): + if override and os.path.islink(dst_file): + os.unlink(dst_file) + elif override and not os.path.islink(dst_file): + raise RuntimeError("Cannot override an actual file!") + elif not override: + return + + if os.path.islink(src_file): + src_file = os.path.realpath(src_file) + dst_folder = os.path.split(dst_file)[0] + rel_path = os.path.relpath(src_file, dst_folder) + os.symlink(rel_path, dst_file) + + def copy_file(xml_in, xml_out): h5path = get_h5_path_from_xml(xml_in, return_absolute_path=True) xml_dir = os.path.split(xml_out)[0] @@ -26,9 +43,11 @@ def copy_tables(src_folder, dst_folder, name): src_file = os.path.join(table_in, ff) dst_file = os.path.join(table_out, ff) - rel_path = os.path.relpath(src_file, table_out) - if not os.path.exists(dst_file): - os.symlink(rel_path, dst_file) + make_squashed_link(src_file, dst_file) + + # rel_path = os.path.relpath(src_file, table_out) + # if not os.path.exists(dst_file): + # os.symlink(rel_path, dst_file) # write the txt file for additional tables write_additional_table_file(table_out) -- GitLab