Coverage for pds_crawler/models/common.py: 93%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# -*- coding: utf-8 -*-
2# pds-crawler - ETL to index PDS data to pdssp
3# Copyright (C) 2023 - CNES (Jean-Christophe Malapert for Pôle Surfaces Planétaires)
4# This file is part of pds-crawler <https://github.com/pdssp/pds_crawler>
5# SPDX-License-Identifier: LGPL-3.0-or-later
6"""Common data model for all models."""
7from dataclasses import asdict
8from dataclasses import dataclass
9from json import dumps
12@dataclass(frozen=True)
13class AbstractModel:
14 @classmethod
15 def from_dict(cls, env):
16 return cls(**{k: v for k, v in env.items()})
18 @property
19 def __dict__(self):
20 return asdict(self)
22 @property
23 def json(self):
24 return dumps(self.__dict__, indent=None)