From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web12.4174.1586546792092138636 for ; Fri, 10 Apr 2020 12:26:32 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: ashley.e.desimone@intel.com) IronPort-SDR: cw+M7N46W9EvH/5AUU8g0Zta4CVZ3SMxFmCttEqjqhXSrUeQVKTVPBHBohHs4PQjDTMCLnI9vm pviRW8p1MgRw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2020 12:26:31 -0700 IronPort-SDR: rQmIHCJ9ut+IPLMlKoNL/RnjiKqVnWOccwLH4PTNzgAXSFU6ARqz/YmkJelZ3UKEuh8mMqui6p HIwp4m6Z9ibQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,367,1580803200"; d="scan'208";a="331258536" Received: from aedesimo-desk.amr.corp.intel.com ([10.7.159.171]) by orsmga001.jf.intel.com with ESMTP; 10 Apr 2020 12:26:31 -0700 From: "Ashley E Desimone" To: devel@edk2.groups.io Cc: Nate DeSimone , Puja Pandya , Erik Bjorge , Bret Barkelew , Prince Agyeman Subject: [edk2-staging/EdkRepo] [PATCH v2] EdkRepo: Config_factory string clean up Date: Fri, 10 Apr 2020 12:26:09 -0700 Message-Id: <20200410192609.23656-1-ashley.e.desimone@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 Define and store config_config factory informational and error strings in config/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/humble/config_factory_humble.py | 14 ++++++++++++++ setup.py | 4 ++-- 3 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 edkrepo/config/humble/config_factory_humble.py diff --git a/edkrepo/config/config_factory.py b/edkrepo/config/config_factory.py index b86e0b8..c342838 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.humble.config_factory_humble as humble from edkrepo.common.edkrepo_exception import EdkrepoGlobalConfigNotFoundException, EdkrepoConfigFileInvalidException from edkrepo.common.edkrepo_exception import EdkrepoWorkspaceInvalidException, EdkrepoGlobalDataDirectoryNotFoundException from edkrepo.common.edkrepo_exception import EdkrepoConfigFileReadOnlyException from edkrepo.common.humble import MIRROR_PRIMARY_REPOS_MISSING, MIRROR_DECODE_WARNING, MAX_PATCH_SET_INVALID from edkrepo_manifest_parser import edk_manifest -from ctypes import * def get_edkrepo_global_data_directory(): global_data_dir = None @@ -34,7 +36,7 @@ def get_edkrepo_global_data_directory(): global_data_dir = 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 EdkrepoGlobalDataDirectoryNotFoundException(humble.GLOBAL_DATA_DIR_NOT_FOUND.format(os.path.dirname(global_data_dir))) os.mkdir(global_data_dir) return global_data_dir @@ -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 file is read only: {}'.format(filename)) + raise EdkrepoConfigFileReadOnlyException(humble.READ_ONLY_CFG.format(filename)) cfg[section][key] = 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[prop.section]: if prop.required or self.read_only: # Required property is missing - raise EdkrepoConfigFileInvalidException('{} is not present in {} section of {}'.format(prop.key, prop.section, os.path.basename(self.filename))) + raise 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_entry_point', None, True)] if not os.path.isfile(self.filename): - raise EdkrepoGlobalConfigNotFoundException("edkrepo global config file {} does not exist".format(self.filename)) + raise EdkrepoGlobalConfigNotFoundException(humble.GLOBAL_CFG_NOT_FOUND.format(self.filename)) super().__init__(self.filename, True) @property @@ -189,7 +191,7 @@ def get_workspace_path(): if os.path.dirname(path) == path: break path = os.path.dirname(path) - raise EdkrepoWorkspaceInvalidException("The current directory does not appear to be a valid workspace") + raise EdkrepoWorkspaceInvalidException(humble.INVALID_WKSPC) def get_workspace_manifest_file(): path = get_workspace_path() diff --git a/edkrepo/config/humble/config_factory_humble.py b/edkrepo/config/humble/config_factory_humble.py new file mode 100644 index 0000000..3b8335f --- /dev/null +++ b/edkrepo/config/humble/config_factory_humble.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +# +## @file +# config_humble.py +# +# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +GLOBAL_DATA_DIR_NOT_FOUND = '{} does not exist.' +READ_ONLY_CFG = 'The configuration file is read only: {}' +REQ_PROP_MISSING = '{} is not present in {} section of {}' +GLOBAL_CFG_NOT_FOUND = 'The edkrepo global configuration file {} was not found.' +INVALID_WKSPC = 'The current directory does not appear to be a valid workspace.' \ No newline at end of file diff --git a/setup.py b/setup.py index e7e6ce8..2d14334 100755 --- a/setup.py +++ b/setup.py @@ -12,8 +12,8 @@ setup(name='edkrepo', version='2.0.0', description='The edkrepo tools', packages=['edkrepo', 'edkrepo.commands', 'edkrepo.commands.arguments', 'edkrepo.commands.humble', - 'edkrepo.git_automation', 'edkrepo.common', 'edkrepo.config', 'edkrepo_manifest_parser', - 'project_utils'], + 'edkrepo.git_automation', 'edkrepo.common', 'edkrepo.config', 'edkrepo.config.humble', + 'edkrepo_manifest_parser', 'project_utils'], package_data={ }, include_package_data=True, -- 2.16.2.windows.1