44# SPDX-License-Identifier: Apache-2.0
55
66import argparse
7+ import re
8+ import sys
79from dataclasses import dataclass
810from pathlib import Path , PurePath
11+
912import pykwalify .core
10- import sys
11- from typing import List
1213import yaml
13- import re
1414
1515try :
1616 from yaml import CSafeLoader as SafeLoader
1919
2020
2121SOC_SCHEMA_PATH = str (Path (__file__ ).parent / 'schemas' / 'soc-schema.yml' )
22- with open (SOC_SCHEMA_PATH , 'r' ) as f :
22+ with open (SOC_SCHEMA_PATH ) as f :
2323 soc_schema = yaml .load (f .read (), Loader = SafeLoader )
2424
2525ARCH_SCHEMA_PATH = str (Path (__file__ ).parent / 'schemas' / 'arch-schema.yml' )
26- with open (ARCH_SCHEMA_PATH , 'r' ) as f :
26+ with open (ARCH_SCHEMA_PATH ) as f :
2727 arch_schema = yaml .load (f .read (), Loader = SafeLoader )
2828
2929SOC_YML = 'soc.yml'
@@ -116,7 +116,7 @@ def from_file(socs_file):
116116 '''Load SoCs from a soc.yml file.
117117 '''
118118 try :
119- with open (socs_file , 'r' ) as f :
119+ with open (socs_file ) as f :
120120 socs_yaml = f .read ()
121121 except FileNotFoundError as e :
122122 sys .exit (f'ERROR: socs.yml file not found: { socs_file .as_posix ()} ' , e )
@@ -172,8 +172,8 @@ def get_soc(self, name):
172172@dataclass
173173class Soc :
174174 name : str
175- cpuclusters : List [str ]
176- folder : List [str ]
175+ cpuclusters : list [str ]
176+ folder : list [str ]
177177 series : str = ''
178178 family : str = ''
179179
@@ -186,17 +186,17 @@ def extend(self, soc):
186186@dataclass
187187class Series :
188188 name : str
189- folder : List [str ]
189+ folder : list [str ]
190190 family : str
191- socs : List [Soc ]
191+ socs : list [Soc ]
192192
193193
194194@dataclass
195195class Family :
196196 name : str
197- folder : List [str ]
198- series : List [Series ]
199- socs : List [Soc ]
197+ folder : list [str ]
198+ series : list [Series ]
199+ socs : list [Soc ]
200200
201201
202202def unique_paths (paths ):
@@ -216,8 +216,7 @@ def find_v2_archs(args):
216216 try :
217217 pykwalify .core .Core (source_data = archs , schema_data = arch_schema ).validate ()
218218 except pykwalify .errors .SchemaError as e :
219- sys .exit ('ERROR: Malformed "build" section in file: {}\n {}'
220- .format (archs_yml .as_posix (), e ))
219+ sys .exit (f'ERROR: Malformed "build" section in file: { archs_yml .as_posix ()} \n { e } ' )
221220
222221 if args .arch is not None :
223222 archs = {'archs' : list (filter (
0 commit comments