Skip to content
Snippets Groups Projects

WS-523: Make `productfetcher` not explode on null subdirectory value

Merged Nathan Hertz requested to merge productfetcher-subdirectory-null-handling into main
2 files
+ 59
11
Compare changes
  • Side-by-side
  • Inline
Files
2
""" LocationsReport conveniences """
import http
from abc import abstractmethod, ABC
import logging
from abc import ABC, abstractmethod
from enum import Enum
from pathlib import Path
from typing import NamedTuple, Optional
# pylint: disable=E0239, E0401, E0402, E1136, R0201, R0902, R0903, R0913, W0613
import requests
from marshmallow import Schema, fields, post_load
from marshmallow.decorators import validates_schema
from pycapo import CapoConfig
from .exceptions import LocatorServiceException, FetchError
from .exceptions import FetchError, LocatorServiceException
from .interfaces import LocatedFile, LocationReport, Locator
from .ngas import NgasConnection
logger = logging.getLogger("productfetcher.locations")
logger.setLevel(logging.INFO)
class Location(Enum):
"""
@@ -248,7 +252,7 @@ class NgasFileSchema(Schema):
""" One of the items in a location report's "files" list """
ngas_file_id = fields.Str()
subdirectory = fields.Str()
subdirectory = fields.Str(allow_none=True)
relative_path = fields.Str()
checksum = fields.Integer()
checksum_type = fields.Str()
@@ -258,6 +262,12 @@ class NgasFileSchema(Schema):
table = fields.Str()
archive_uid = fields.Str()
@validates_schema
def validate_subdirectory(self, data, **kwargs):
# Fill in a subdirectory value that is None with the default
if data["subdirectory"] is None:
data["subdirectory"] = "retrieved-products"
@post_load
def make_filespec(self, data, **kwargs):
if "table" in data:
Loading