Skip to content

Commit

Permalink
fixed import problems after refactor where validation ftors expected …
Browse files Browse the repository at this point in the history
…`repo` as the first argument
  • Loading branch information
jm committed Jul 25, 2024
1 parent 4be620d commit 8e01594
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/pump/_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,14 @@ def status(self):

class differ:

def __init__(self, raw_db_dspace_5, raw_db_utilities_5, raw_db_7):
def __init__(self, raw_db_dspace_5, raw_db_utilities_5, raw_db_7, repo=None):
"""
Repo object might be needed by `"process":` to be able to compare values.
"""
self.raw_db_dspace_5 = raw_db_dspace_5
self.raw_db_utilities_5 = raw_db_utilities_5
self.raw_db_7 = raw_db_7
self._repo = repo

def _fetch_all_vals(self, db5, table_name: str, sql: str = None):
sql = sql or f"SELECT * FROM {table_name}"
Expand Down Expand Up @@ -258,7 +262,10 @@ def diff_table_sql(self, db5, table_name: str, sql5, sql7, compare, process_ftor
vals7, cols7, [compare]) if x[0] is not None]

if process_ftor is not None:
vals5_cmp, vals7_cmp = process_ftor(self, vals5_cmp, vals7_cmp)
vals5_cmp, vals7_cmp = process_ftor(self._repo, vals5_cmp, vals7_cmp)
# ignored
if vals5_cmp is None and vals7_cmp is None:
return

only_in_5 = list(set(vals5_cmp).difference(vals7_cmp))
only_in_7 = list(set(vals7_cmp).difference(vals5_cmp))
Expand Down
5 changes: 5 additions & 0 deletions src/pump/_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ def _epersongroup_process(repo, v5data: list, v7data: list):
v5: ['COLLECTION_17_DEFAULT_READ', 'COLLECTION_20_WORKFLOW_STEP_2']
v7: ['COLLECTION_f3c65f29-355e-4ca2-a05b-f3e30883e09f_BITSTREAM_DEFAULT_READ']
"""
if repo is None:
_logger.critical(
"Cannot validate using _epersongroup_process because repo is None")
return None, None

rec = re.compile("(COLLECTION|COMMUNITY)_(\d+)_(.*)")
v5data_new = []
for val in v5data:
Expand Down
4 changes: 4 additions & 0 deletions src/pump/_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ def _metadatavalue_process(repo, v5data: list, v7data: list):
v5: ['COLLECTION_17_DEFAULT_READ', 'COLLECTION_20_WORKFLOW_STEP_2']
v7: ['COLLECTION_f3c65f29-355e-4ca2-a05b-f3e30883e09f_BITSTREAM_DEFAULT_READ']
"""
if repo is None:
_logger.critical(
"Cannot validate using _metadatavalue_process because repo is None")
return None, None

def norm_lic(text):
# normalize it, not 100% because of licence-UD-2.2
Expand Down
2 changes: 1 addition & 1 deletion src/pump/_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def diff(self, to_validate=None):
return
to_validate = [to_validate.validate_table]

diff = differ(self.raw_db_dspace_5, self.raw_db_utilities_5, self.raw_db_7)
diff = differ(self.raw_db_dspace_5, self.raw_db_utilities_5, self.raw_db_7, repo)
diff.validate(to_validate)

# =====
Expand Down

0 comments on commit 8e01594

Please sign in to comment.