Skip to content

Commit

Permalink
Added duplication structure
Browse files Browse the repository at this point in the history
  • Loading branch information
ntlhui committed Feb 12, 2023
1 parent 1d79552 commit ef8cfe4
Showing 1 changed file with 51 additions and 3 deletions.
54 changes: 51 additions & 3 deletions e4e_data_management/duplicator.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,44 @@
'''Duplication Tool main logic
'''
import argparse
from pathlib import Path
from typing import Iterable, List

from e4e_data_management.validator import Dataset


class Duplicator:
"""Duplication Tool application logic
"""
def __init__(self):
pass
def __init__(self,
source: Path,
destinations: Iterable[Path],
*,
verification_method: str = 'hash'):
self.source = source
self.destinations = destinations
self.__method = verification_method

self.__validate_args()
self.dataset = Dataset(self.source)

def duplicate(self):
"""Does the duplication
"""
self.dataset.generate_manifest()
# TODO: Duplicate

def verify(self):
"""Verifies the output
"""
reference_manifest = self.dataset.get_manifest()
for destination in self.destinations:
Dataset(destination).validate(reference_manifest, method=self.__method)

def __validate_args(self):
assert self.source.is_dir()
assert len(self.destinations) > 0
assert all(dest.is_dir() for dest in self.destinations)

def gui():
"""GUI Entry Point
Expand All @@ -19,10 +50,27 @@ def cli():
parser = argparse.ArgumentParser(
description="Expedition Data Duplication Tool"
)
parser.add_argument('source', type=Path)
parser.add_argument('destination', nargs='+', type=Path)

args = parser.parse_args()

app = Duplicator()
source: Path = args.source
if not source.is_dir():
raise RuntimeError('Source is not a directory')

destinations: List[Path] = args.destination

if not all(dest.is_dir() for dest in destinations):
raise RuntimeError('Destination is not a directory')


app = Duplicator(
source=source,
destinations=destinations
)

app.duplicate()

if __name__ == '__main__':
cli()

0 comments on commit ef8cfe4

Please sign in to comment.