p3lib 1.1.86__py3-none-any.whl → 1.1.88__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
p3lib/pconfig.py CHANGED
@@ -495,7 +495,7 @@ class ConfigManager(object):
495
495
  self._debug("----------> DROPPED FROM CONFIG: {} = {}".format(loadedConfigKey, loadedConfig[loadedConfigKey]))
496
496
  loadedConfig.pop(loadedConfigKey, None)
497
497
 
498
- self._configDict = loadedConfig
498
+ self._configDict = loadedConfig
499
499
  self._info("Loaded config from %s" % (self._cfgFile) )
500
500
 
501
501
  def inputFloat(self, key, prompt, minValue=UNSET_VALUE, maxValue=UNSET_VALUE):
@@ -756,6 +756,8 @@ class DotConfigManager(ConfigManager):
756
756
  The ~/.config folder holds either a single config file of the startup python filename.
757
757
  The ./config folder can contain another python module folder which contains the config
758
758
  file. E.G for this example app the ~/.config/examples/pconfig_example.cfg folder is used."""
759
+ DEFAULT_CONFIG = None # This must be overridden in a subclass to define the configuration parameters and values.
760
+ KEY_EDIT_ORDER_LIST = None
759
761
 
760
762
  @staticmethod
761
763
  def GetDefaultConfigFilename():
@@ -800,9 +802,10 @@ class DotConfigManager(ConfigManager):
800
802
 
801
803
  return configFilename
802
804
 
803
- def __init__(self, defaultConfig, uio=None, encrypt=False):
805
+ def __init__(self, defaultConfig, keyEditOrderList=None, uio=None, encrypt=False):
804
806
  """@brief Constructor
805
807
  @param defaultConfig A default config instance containing all the default key-value pairs.
808
+ @param keyEditOrderList A list of all the dict keys in the order that the caller wishes them to be displayed top the user.
806
809
  @param uio A UIO (User Input Output) instance. May be set to None if no user messages are required.
807
810
  @param encrypt If True then data will be encrypted in the saved files.
808
811
  The encryption uses part of the the local SSH RSA private key.
@@ -811,7 +814,33 @@ class DotConfigManager(ConfigManager):
811
814
  !!! Therefore if encrypt is set True then the an ssh key must be present !!!
812
815
  ||| in the ~/.ssh folder named id_rsa. !!!"""
813
816
  super().__init__(uio, DotConfigManager.GetDefaultConfigFilename(), defaultConfig, encrypt=encrypt)
817
+ self._keyEditOrderList = keyEditOrderList
814
818
  # Ensure the config file is present and loaded into the internal dict.
815
819
  self.load()
816
820
 
821
+ def show(self):
822
+ """@brief A helper method to show the dictionary config to the user.
823
+ @return A dictionary mapping the attribute ID's (keys) to dictionary keys (values)."""
824
+ maxKeyLen=10
825
+ # If the caller wants to present the parameters to the user in a partiular order
826
+ if self._keyEditOrderList:
827
+ keys = self._keyEditOrderList
828
+ defaultKeys = list(self._configDict.keys())
829
+ for defaultKey in defaultKeys:
830
+ if defaultKey not in keys:
831
+ raise Exception(f"BUG: DotConfigManager: {defaultKey} key is missing from the keyEditOrderList.")
832
+ # Present the parameters to the user in any order.
833
+ else:
834
+ keys = list(self._configDict.keys())
817
835
 
836
+ for key in keys:
837
+ if len(key) > maxKeyLen:
838
+ maxKeyLen = len(key)
839
+ self._info("ID PARAMETER"+" "*(maxKeyLen-8)+" VALUE")
840
+ id=1
841
+ idKeyDict = {}
842
+ for key in keys:
843
+ idKeyDict[id]=key
844
+ self._info("{:<3d} {:<{}} {}".format(id, key, maxKeyLen+1, self._configDict[key]))
845
+ id=id+1
846
+ return idKeyDict
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: p3lib
3
- Version: 1.1.86
3
+ Version: 1.1.88
4
4
  Summary: A group of python modules for networking, plotting data, config storage, automating boot scripts, ssh access and user input output.
5
5
  Home-page: https://github.com/pjaos/p3lib
6
6
  Author: Paul Austen
@@ -11,12 +11,12 @@ p3lib/mqtt_rpc.py,sha256=6LmFA1kR4HSJs9eWbOJORRHNY01L_lHWjvtE2fmY8P8,10511
11
11
  p3lib/netif.py,sha256=3QV5OGdHhELIf4MBj6mx5MNCtVeZ7JXoNEkeu4KzCaE,9796
12
12
  p3lib/netplotly.py,sha256=PMDx-w1jtRVW6Od5u_kuKbBxNpTS_Y88mMF60puMxLM,9363
13
13
  p3lib/ngt.py,sha256=rXA-6zQkfeOupZ-3Q-k3-1DvbKYIi2TCtLKgUb0waWY,37726
14
- p3lib/pconfig.py,sha256=g9Qk-tSjxtSuEfLbvIvR1SHC7x7BHxp1evT2IFfk05I,34407
14
+ p3lib/pconfig.py,sha256=ODSIkP902uaSeGj98U4V3-2obZR2fuFAxv_X0j2TvPc,35929
15
15
  p3lib/ssh.py,sha256=klqQ9YuqU8GwPVPHrAJeEs5PI5hgoYiXflq2kIGG3as,39509
16
16
  p3lib/table_plot.py,sha256=RPncwVlGUkkx5Fw0dHQedXo0TSPlTi__VrJBDzaMsuI,32116
17
17
  p3lib/uio.py,sha256=Aaxc99XiE3d2f9vLjaN-bZsckoNxay5t0ujdK6PXGrw,23265
18
- p3lib-1.1.86.dist-info/LICENSE,sha256=igqTy5u0kVWM1n-NUZMvAlinY6lVjAXKoag0okkS8V8,1067
19
- p3lib-1.1.86.dist-info/METADATA,sha256=viCrPzOCPwdWFfXg31oL2Q84MpF3bxesV2951yIULjA,918
20
- p3lib-1.1.86.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
21
- p3lib-1.1.86.dist-info/top_level.txt,sha256=SDCpXYh-19yCFp4Z8ZK4B-3J4NvTCJElZ42NPgcR6-U,6
22
- p3lib-1.1.86.dist-info/RECORD,,
18
+ p3lib-1.1.88.dist-info/LICENSE,sha256=igqTy5u0kVWM1n-NUZMvAlinY6lVjAXKoag0okkS8V8,1067
19
+ p3lib-1.1.88.dist-info/METADATA,sha256=Kib55jvHxBRhAlPWpgc7-Y0ZY1j-zmvE2uq2-8rYvkE,918
20
+ p3lib-1.1.88.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
21
+ p3lib-1.1.88.dist-info/top_level.txt,sha256=SDCpXYh-19yCFp4Z8ZK4B-3J4NvTCJElZ42NPgcR6-U,6
22
+ p3lib-1.1.88.dist-info/RECORD,,
File without changes