Reviewed-by: Nate DeSimone <nathaniel.l.desim...@intel.com> -----Original Message----- From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Ashley E Desimone Sent: Friday, April 10, 2020 12:26 PM To: devel@edk2.groups.io Cc: Desimone, Nathaniel L <nathaniel.l.desim...@intel.com>; Pandya, Puja <puja.pan...@intel.com>; Bjorge, Erik C <erik.c.bjo...@intel.com>; Bret Barkelew <bret.barke...@microsoft.com>; Agyeman, Prince <prince.agye...@intel.com> Subject: [edk2-devel] [edk2-staging/EdkRepo] [PATCH v2] EdkRepo: Config_factory string clean up
Define and store config_config factory informational and error strings in config/config_humble.py Signed-off-by: Ashley E Desimone <ashley.e.desim...@intel.com> Cc: Nate DeSimone <nathaniel.l.desim...@intel.com> Cc: Puja Pandya <puja.pan...@intel.com> Cc: Erik Bjorge <erik.c.bjo...@intel.com> Cc: Bret Barkelew <bret.barke...@microsoft.com> Cc: Prince Agyeman <prince.agye...@intel.com> --- 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(filenam + e)) 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.forma + t(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.<BR> # +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 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#57242): https://edk2.groups.io/g/devel/message/57242 Mute This Topic: https://groups.io/mt/72929409/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-