From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web11.2181.1586541487913105596 for ; Fri, 10 Apr 2020 10:58:08 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: nathaniel.l.desimone@intel.com) IronPort-SDR: kQW/iDJwnFEYwtyRYU22guxEnIUioMm5x2i2F1HeLwqQHnStgQ5OH2l1kc/sZYzba3ofOEu1eW 2NQQayjkfBAw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2020 10:58:06 -0700 IronPort-SDR: A9jS00CFi8vKKu0fDXOBRIFSkopXBh7TWVYaD3af3CgJr5U+YIQNkipGuJX7I4rq6rSYCZ8Zb3 MU7F8EYTmeSQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,367,1580803200"; d="scan'208";a="276247758" Received: from orsmsx104.amr.corp.intel.com ([10.22.225.131]) by fmsmga004.fm.intel.com with ESMTP; 10 Apr 2020 10:58:06 -0700 Received: from orsmsx114.amr.corp.intel.com ([169.254.8.205]) by ORSMSX104.amr.corp.intel.com ([169.254.4.140]) with mapi id 14.03.0439.000; Fri, 10 Apr 2020 10:58:05 -0700 From: "Nate DeSimone" To: "Desimone, Ashley E" , "devel@edk2.groups.io" CC: "Pandya, Puja" , "Bjorge, Erik C" , Bret Barkelew , "Agyeman, Prince" Subject: Re: [edk2-staging/EdkRepo] [PATCH] EdkRepo: Config_factory string clean up Thread-Topic: [edk2-staging/EdkRepo] [PATCH] EdkRepo: Config_factory string clean up Thread-Index: AQHWDr7PuN1K8AtogEKxMoK9RyEUX6hypVkQ Date: Fri, 10 Apr 2020 17:58:05 +0000 Message-ID: <02A34F284D1DA44BB705E61F7180EF0AB5E7E5C4@ORSMSX114.amr.corp.intel.com> References: <20200409223249.29104-1-ashley.e.desimone@intel.com> In-Reply-To: <20200409223249.29104-1-ashley.e.desimone@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZDI5NDQwMDctMTVlOS00NzUwLWI2YzUtM2U2ODNiYjcwODU1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiNzVxM0ZKYytOSjdwR0tWV0s1VzBsUmJqN1c0cHl2OXl6UFllMGN3YlwvWE41Tk9kNzJiQkI3Z1NHemFjWUdBUjEifQ== x-ctpclassification: CTP_NT x-originating-ip: [10.22.254.138] MIME-Version: 1.0 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I would prefer we match the pattern found in the commands directory. Someth= ing like import edkrepo.config.humble.config_factory as humble Thanks, Nate -----Original Message----- From: Desimone, Ashley E =20 Sent: Thursday, April 9, 2020 3:33 PM To: devel@edk2.groups.io Cc: Desimone, Nathaniel L ; Pandya, Puja ; Bjorge, Erik C ; Bret Barke= lew ; Agyeman, Prince Subject: [edk2-staging/EdkRepo] [PATCH] EdkRepo: Config_factory string clea= n up Define and store config_config factory informational and error strings in c= onfig/config_humble.py Signed-off-by: Ashley E Desimone Cc: Nate DeSimone Cc: Puja Pandya Cc: Erik Bjorge Cc: Bret Barkelew Cc: Prince Agyeman --- edkrepo/config/config_factory.py | 14 ++++++++------ edkrepo/config/confi= g_humble.py | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 edkr= epo/config/config_humble.py diff --git a/edkrepo/config/config_factory.py b/edkrepo/config/config_facto= ry.py index b86e0b8..d9eec87 100644 --- a/edkrepo/config/config_factory.py +++ b/edkrepo/config/config_factory.py @@ -11,12 +11,14 @@ import os import sys import configparser import collections +from ctypes import * + +import edkrepo.config.config_humble as humble from edkrepo.common.edkrepo_exception import EdkrepoGlobalConfigNotFoundEx= ception, EdkrepoConfigFileInvalidException from edkrepo.common.edkrepo_exc= eption import EdkrepoWorkspaceInvalidException, EdkrepoGlobalDataDirectoryN= otFoundException from edkrepo.common.edkrepo_exception import EdkrepoConfigFileReadOnlyExce= ption from edkrepo.common.humble import MIRROR_PRIMARY_REPOS_MISSING, MIRROR_DEC= ODE_WARNING, MAX_PATCH_SET_INVALID from edkrepo_manifest_parser import edk= _manifest -from ctypes import * =20 def get_edkrepo_global_data_directory(): global_data_dir =3D None @@ -34,7 +36,7 @@ def get_edkrepo_global_data_directory(): global_data_dir =3D os.path.expanduser("~/.edkrepo") if not os.path.isdir(global_data_dir): if not os.path.exists(os.path.dirname(global_data_dir)): - raise EdkrepoGlobalDataDirectoryNotFoundException("{} does not= exist".format(os.path.dirname(global_data_dir))) + raise=20 + EdkrepoGlobalDataDirectoryNotFoundException(humble.GLOBAL_DATA_DIR_NOT + _FOUND.format(os.path.dirname(global_data_dir))) os.mkdir(global_data_dir) return global_data_dir =20 @@ -63,7 +65,7 @@ def cfg_property(filename, cfg, read_only, section, key): return cfg[section][key] def _set(self, value): if read_only: - raise EdkrepoConfigFileReadOnlyException('The configuration fi= le is read only: {}'.format(filename)) + raise=20 + EdkrepoConfigFileReadOnlyException(humble.READ_ONLY_CFG.format(filenam + e)) cfg[section][key] =3D value with open(filename, 'w') as cfg_stream: cfg.write(cfg_stream) @@ -90,7 +92,7 @@ class BaseConfig(): if prop.section not in self.cfg or prop.key not in self.cfg[pr= op.section]: if prop.required or self.read_only: # Required property is missing - raise EdkrepoConfigFileInvalidException('{} is not pre= sent in {} section of {}'.format(prop.key, prop.section, os.path.basename(s= elf.filename))) + raise=20 + EdkrepoConfigFileInvalidException(humble.REQ_PROP_MISSING.format(prop. + key, prop.section, os.path.basename(self.filename))) if not self.read_only: # Create the missing property if prop.section not in self.cfg: @@ -126,7 +128,7 @@ class GlobalConfig(BaseConfig): CfgProp('preferred-command-package', 'preferred-package', = 'pref_pkg', None, True), CfgProp('preferred-entry-point', 'entry-point', 'pref_entr= y_point', None, True)] if not os.path.isfile(self.filename): - raise EdkrepoGlobalConfigNotFoundException("edkrepo global con= fig file {} does not exist".format(self.filename)) + raise=20 + EdkrepoGlobalConfigNotFoundException(humble.GLOBAL_CFG_NOT_FOUND.forma + t(self.filename)) super().__init__(self.filename, True) =20 @property @@ -189,7 +191,7 @@ def get_workspace_path(): if os.path.dirname(path) =3D=3D path: break path =3D os.path.dirname(path) - raise EdkrepoWorkspaceInvalidException("The current directory does not= appear to be a valid workspace") + raise EdkrepoWorkspaceInvalidException(humble.INVALID_WKSPC) =20 def get_workspace_manifest_file(): path =3D get_workspace_path() diff --git a/edkrepo/config/config_humble.py b/edkrepo/config/config_humble= .py new file mode 100644 index 0000000..3b8335f --- /dev/null +++ b/edkrepo/config/config_humble.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +# +## @file +# config_humble.py +# +# Copyright (c) 2020, Intel Corporation. All rights reserved.
#=20 +SPDX-License-Identifier: BSD-2-Clause-Patent # + +GLOBAL_DATA_DIR_NOT_FOUND =3D '{} does not exist.' +READ_ONLY_CFG =3D 'The configuration file is read only: {}' +REQ_PROP_MISSING =3D '{} is not present in {} section of {}' +GLOBAL_CFG_NOT_FOUND =3D 'The edkrepo global configuration file {} was not= found.' +INVALID_WKSPC =3D 'The current directory does not appear to be a valid wor= kspace.' \ No newline at end of file -- 2.16.2.windows.1