public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-staging/EdkRepo] [PATCH v2] EdkRepo: Config_factory string clean up
@ 2020-04-10 19:26 Ashley E Desimone
  2020-04-10 23:22 ` [edk2-devel] " Nate DeSimone
  0 siblings, 1 reply; 2+ messages in thread
From: Ashley E Desimone @ 2020-04-10 19:26 UTC (permalink / raw)
  To: devel
  Cc: Nate DeSimone, Puja Pandya, Erik Bjorge, Bret Barkelew,
	Prince Agyeman

Define and store config_config factory informational
and error strings in config/config_humble.py

Signed-off-by: Ashley E Desimone <ashley.e.desimone@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Puja Pandya <puja.pandya@intel.com>
Cc: Erik Bjorge <erik.c.bjorge@intel.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Prince Agyeman <prince.agyeman@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(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.<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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [edk2-devel] [edk2-staging/EdkRepo] [PATCH v2] EdkRepo: Config_factory string clean up
  2020-04-10 19:26 [edk2-staging/EdkRepo] [PATCH v2] EdkRepo: Config_factory string clean up Ashley E Desimone
@ 2020-04-10 23:22 ` Nate DeSimone
  0 siblings, 0 replies; 2+ messages in thread
From: Nate DeSimone @ 2020-04-10 23:22 UTC (permalink / raw)
  To: devel@edk2.groups.io, Desimone, Ashley E
  Cc: Pandya, Puja, Bjorge, Erik C, Bret Barkelew, Agyeman, Prince

Reviewed-by: Nate DeSimone <nathaniel.l.desimone@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.desimone@intel.com>; Pandya, Puja <puja.pandya@intel.com>; Bjorge, Erik C <erik.c.bjorge@intel.com>; Bret Barkelew <Bret.Barkelew@microsoft.com>; Agyeman, Prince <prince.agyeman@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.desimone@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Puja Pandya <puja.pandya@intel.com>
Cc: Erik Bjorge <erik.c.bjorge@intel.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Prince Agyeman <prince.agyeman@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





^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-10 23:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-10 19:26 [edk2-staging/EdkRepo] [PATCH v2] EdkRepo: Config_factory string clean up Ashley E Desimone
2020-04-10 23:22 ` [edk2-devel] " Nate DeSimone

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox