Coverage for cli/src/xyfigure/factory.py: 100%
13 statements
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-18 01:09 +0000
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-18 01:09 +0000
1#!/usr/bin/env python
2# Client to create figures for Military Specification journal manuscript.
3# To run from command line with Python3:
4# [base_directory]: $ python ~/sibl/xyfigure/client.py input_file.json
6# https://www.python.org/dev/peps/pep-0008/#imports
7# standard library imports
9# related third-party imports
11# local application/library specific imports
12# from xyfigure.xymodel import XYModel
13# from xyfigure.code.xymodel import XYModel
14from xyfigure.xymodel import XYModel, XYModelAbaqus
16# from xyfigure.xyview import XYView
17# from xyfigure.code.xyview import XYView
18from xyfigure.xyview import XYView, XYViewAbaqus
20# Figure Factory
21FACTORY_ITEMS = {
22 "model": XYModel,
23 "view": XYView,
24 "model_abaqus": XYModelAbaqus,
25 "view_abaqus": XYViewAbaqus,
26}
29class XYFactory:
30 """The one and only (singleton) factory for XY items."""
32 @staticmethod
33 def create(item, **kwargs):
34 "Main factory method, returns XY objects."
35 instance = FACTORY_ITEMS.get(kwargs["class"], None)
36 if instance:
37 return instance(item, **kwargs)
39 # If we get here, we did not return an instance, so warn.
40 print(f"Warning: key 'class' specified 'value' of '{item}', which is unknown.")
41 print("This key will be skipped.")
42 return None
45"""
46Copyright 2023 Sandia National Laboratories
48Notice: This computer software was prepared by National Technology and Engineering Solutions of
49Sandia, LLC, hereinafter the Contractor, under Contract DE-NA0003525 with the Department of Energy
50(DOE). All rights in the computer software are reserved by DOE on behalf of the United States
51Government and the Contractor as provided in the Contract. You are authorized to use this computer
52software for Governmental purposes but it is not to be released or distributed to the public.
53NEITHER THE U.S. GOVERNMENT NOR THE CONTRACTOR MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES
54ANY LIABILITY FOR THE USE OF THIS SOFTWARE. This notice including this sentence must appear on any
55copies of this computer software. Export of this data may require a license from the United States
56Government.
57"""