Skip to content

Commit

Permalink
fix: deduplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
wdconinc committed Feb 21, 2024
1 parent c87ff9d commit e234a82
Showing 1 changed file with 1 addition and 25 deletions.
26 changes: 1 addition & 25 deletions tools/podio-vis
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import os
import sys
import argparse
import yaml
from podio_class_generator import read_upstream_edm
from podio_gen.generator_utils import DefinitionError
from podio_gen.podio_config_reader import PodioConfigReader

Expand All @@ -15,31 +16,6 @@ except ImportError:
sys.exit(1)


def read_upstream_edm(name_path):
"""Read an upstream EDM yaml definition file to make the types that are defined
in that available to the current EDM"""
if name_path is None:
return None

try:
name, path = name_path.split(":")
except ValueError as err:
raise argparse.ArgumentTypeError(
"upstream-edm argument needs to be the upstream package "
"name and the upstream edm yaml file separated by a colon"
) from err

if not os.path.isfile(path):
raise argparse.ArgumentTypeError(f"{path} needs to be an EDM yaml file")

try:
return PodioConfigReader.read(path, name)
except DefinitionError as err:
raise argparse.ArgumentTypeError(
f"{path} does not contain a valid datamodel definition"
) from err


class ModelToGraphviz:
"""Class to transform a data model description into a graphical representation"""

Expand Down

0 comments on commit e234a82

Please sign in to comment.