from .objects.errors import ObjectFormatError from .objects.meta import Meta from .objects.stage import stage as ostage from .objects.transfer import transfer as otransfer from .scheme import Schemes from .utils import relpath from .utils.fs import path_isin if TYPE_CHECKING: from .objects.db.base import ObjectDB logger = logging.getLogger(__name__) CHECKSUM_SCHEMA = Any( None, And(str, Length(max=0), SetTo(None)), And(Any(str, And(int, Coerce(str))), Length(min=3), Lower), ) CASE_SENSITIVE_CHECKSUM_SCHEMA = Any( None, And(str, Length(max=0), SetTo(None)), And(Any(str, And(int, Coerce(str))), Length(min=3)), ) # NOTE: currently there are only 3 possible checksum names: # # 1) md5 (LOCAL, SSH); # 2) etag (S3, GS, OSS, AZURE, HTTP); # 3) checksum (HDFS); #
''' import sys from voluptuous import (ALLOW_EXTRA, REMOVE_EXTRA, All, Any, Remove, Replace, Schema, SetTo) from voluptuous.util import Strip from weathergc.utils import html_to_dict is_python3 = sys.version_info.major == 3 if is_python3: unicode = str # top level validator, ensure we're dealing with a known file format META_SCHEMA = Schema( {All('@xml:lang', SetTo('lang')): 'en-ca', Remove('@xmlns'): 'http://www.w3.org/2005/Atom', 'author': {'name': 'Environment Canada', 'uri': 'http://www.weather.gc.ca'}, 'logo': unicode, 'rights': unicode, 'title': unicode, 'updated': unicode, Remove('entry'): Any(list, dict)}, extra=REMOVE_EXTRA) # Validator for each member of the 'entry' list in the feed. # Includes some minor transformations to simplify later validations ENTRY_SCHEMA = Schema( {'category': All({'@term': Any('Weather Forecasts', 'Current Conditions', 'Warnings and Watches')}, dict.values,