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

Update init values for Converter and Transformer #2344

Merged
merged 1 commit into from
Dec 17, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ESSArch_Core/WorkflowEngine/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.db.models.signals import post_save, pre_save
from django.dispatch import receiver

from ESSArch_Core.db.utils import check_db_connection
from ESSArch_Core.WorkflowEngine.models import ProcessStep, ProcessTask


Expand Down Expand Up @@ -31,6 +32,7 @@

@task_received.connect
def task_received_handler(request=None, **kwargs):
check_db_connection()

Check warning on line 35 in ESSArch_Core/WorkflowEngine/signals.py

View check run for this annotation

Codecov / codecov/patch

ESSArch_Core/WorkflowEngine/signals.py#L35

Added line #L35 was not covered by tests
logger = logging.getLogger('essarch')
try:
t = ProcessTask.objects.get(celery_id=request.task_id)
Expand All @@ -39,7 +41,6 @@
t.revoke()
except ProcessTask.DoesNotExist:
logger.debug('{} signal task_received without ProcessTask'.format(request.task_id))
pass


@task_revoked.connect
Expand Down
18 changes: 16 additions & 2 deletions ESSArch_Core/fixity/conversion/backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,24 @@
class BaseConverter:
input_formats = []
output_formats = []
file_converter = True # Does the validator operate on single files or entire directories?

Check warning on line 9 in ESSArch_Core/fixity/conversion/backends/base.py

View check run for this annotation

Codecov / codecov/patch

ESSArch_Core/fixity/conversion/backends/base.py#L9

Added line #L9 was not covered by tests

def __init__(self, ip=None, user=None):
def __init__(self, context=None, include=None, exclude=None, options=None,

Check warning on line 11 in ESSArch_Core/fixity/conversion/backends/base.py

View check run for this annotation

Codecov / codecov/patch

ESSArch_Core/fixity/conversion/backends/base.py#L11

Added line #L11 was not covered by tests
data=None, required=True, task=None, ip=None, responsible=None,
stylesheet=None):
"""
Initializes for convert of one or more files
"""
self.context = context
self.include = include or []
self.exclude = exclude or []
self.options = options or {}
self.data = data or {}
self.required = required
self.task = task

Check warning on line 23 in ESSArch_Core/fixity/conversion/backends/base.py

View check run for this annotation

Codecov / codecov/patch

ESSArch_Core/fixity/conversion/backends/base.py#L17-L23

Added lines #L17 - L23 were not covered by tests
self.ip = ip
self.user = user
self.responsible = responsible
self.stylesheet = stylesheet

Check warning on line 26 in ESSArch_Core/fixity/conversion/backends/base.py

View check run for this annotation

Codecov / codecov/patch

ESSArch_Core/fixity/conversion/backends/base.py#L25-L26

Added lines #L25 - L26 were not covered by tests

@classmethod
def validate_input_format(cls, fmt):
Expand Down
3 changes: 3 additions & 0 deletions ESSArch_Core/fixity/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@
os.chdir(rootdir)
filepath = normalize_path(filepath)
cmd = eval(self.prepare_cmd(filepath, options))
if isinstance(cmd, str):
cmd = (cmd,)

Check warning on line 125 in ESSArch_Core/fixity/models.py

View check run for this annotation

Codecov / codecov/patch

ESSArch_Core/fixity/models.py#L125

Added line #L125 was not covered by tests

try:
[module, task] = self.path.rsplit('.', 1)
p = getattr(importlib.import_module(module), task)(task=t, ip=ip, context=context)
Expand Down
19 changes: 17 additions & 2 deletions ESSArch_Core/fixity/transformation/backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,24 @@


class BaseTransformer:
def __init__(self, ip=None, user=None):
file_transformer = True # Does the validator operate on single files or entire directories?

def __init__(self, context=None, include=None, exclude=None, options=None,
data=None, required=True, task=None, ip=None, responsible=None,
stylesheet=None):
"""
Initializes for transform of one or more files
"""
self.context = context
self.include = include or []
self.exclude = exclude or []
self.options = options or {}
self.data = data or {}
self.required = required
self.task = task
self.ip = ip
self.user = user
self.responsible = responsible
self.stylesheet = stylesheet

@classmethod
def transform(cls, path):
Expand Down
Loading