p3lib 1.1.87__tar.gz → 1.1.89__tar.gz

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.
Files changed (31) hide show
  1. {p3lib-1.1.87 → p3lib-1.1.89}/PKG-INFO +1 -1
  2. {p3lib-1.1.87 → p3lib-1.1.89}/setup.cfg +1 -1
  3. {p3lib-1.1.87 → p3lib-1.1.89}/src/p3lib/pconfig.py +56 -38
  4. {p3lib-1.1.87 → p3lib-1.1.89}/src/p3lib.egg-info/PKG-INFO +1 -1
  5. {p3lib-1.1.87 → p3lib-1.1.89}/LICENSE +0 -0
  6. {p3lib-1.1.87 → p3lib-1.1.89}/README.md +0 -0
  7. {p3lib-1.1.87 → p3lib-1.1.89}/pyproject.toml +0 -0
  8. {p3lib-1.1.87 → p3lib-1.1.89}/src/p3lib/__init__.py +0 -0
  9. {p3lib-1.1.87 → p3lib-1.1.89}/src/p3lib/ate.py +0 -0
  10. {p3lib-1.1.87 → p3lib-1.1.89}/src/p3lib/bokeh_auth.py +0 -0
  11. {p3lib-1.1.87 → p3lib-1.1.89}/src/p3lib/bokeh_gui.py +0 -0
  12. {p3lib-1.1.87 → p3lib-1.1.89}/src/p3lib/boot_manager.py +0 -0
  13. {p3lib-1.1.87 → p3lib-1.1.89}/src/p3lib/conduit.py +0 -0
  14. {p3lib-1.1.87 → p3lib-1.1.89}/src/p3lib/database_if.py +0 -0
  15. {p3lib-1.1.87 → p3lib-1.1.89}/src/p3lib/helper.py +0 -0
  16. {p3lib-1.1.87 → p3lib-1.1.89}/src/p3lib/json_networking.py +0 -0
  17. {p3lib-1.1.87 → p3lib-1.1.89}/src/p3lib/mqtt_rpc.py +0 -0
  18. {p3lib-1.1.87 → p3lib-1.1.89}/src/p3lib/netif.py +0 -0
  19. {p3lib-1.1.87 → p3lib-1.1.89}/src/p3lib/netplotly.py +0 -0
  20. {p3lib-1.1.87 → p3lib-1.1.89}/src/p3lib/ngt.py +0 -0
  21. {p3lib-1.1.87 → p3lib-1.1.89}/src/p3lib/ssh.py +0 -0
  22. {p3lib-1.1.87 → p3lib-1.1.89}/src/p3lib/table_plot.py +0 -0
  23. {p3lib-1.1.87 → p3lib-1.1.89}/src/p3lib/uio.py +0 -0
  24. {p3lib-1.1.87 → p3lib-1.1.89}/src/p3lib.egg-info/SOURCES.txt +0 -0
  25. {p3lib-1.1.87 → p3lib-1.1.89}/src/p3lib.egg-info/dependency_links.txt +0 -0
  26. {p3lib-1.1.87 → p3lib-1.1.89}/src/p3lib.egg-info/requires.txt +0 -0
  27. {p3lib-1.1.87 → p3lib-1.1.89}/src/p3lib.egg-info/top_level.txt +0 -0
  28. {p3lib-1.1.87 → p3lib-1.1.89}/tests/test_conduit.py +0 -0
  29. {p3lib-1.1.87 → p3lib-1.1.89}/tests/test_json_networking.py +0 -0
  30. {p3lib-1.1.87 → p3lib-1.1.89}/tests/test_netif.py +0 -0
  31. {p3lib-1.1.87 → p3lib-1.1.89}/tests/test_ssh.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: p3lib
3
- Version: 1.1.87
3
+ Version: 1.1.89
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
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = p3lib
3
- version = 1.1.87
3
+ version = 1.1.89
4
4
  author = Paul Austen
5
5
  author_email = pausten.os@gmail.com
6
6
  description = A group of python modules for networking, plotting data, config storage, automating boot scripts, ssh access and user input output.
@@ -756,53 +756,45 @@ 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():
762
764
  """@brief Get the default name of the config file for this app. This will be the program name
763
- (file that started up initially) without the .py extension. On Linux systems this
764
- will reside in the ~/.config folder. If the ~/.config does not exist an attempt to
765
- create it is made. If the ~/.config folder cannot be created then the config file
766
- will be as detailed above but will be prefixed by a . character and will reside
767
- in the users home folder."""
768
- progName = sys.argv[0]
769
- if progName.endswith('.py'):
770
- progName = progName[0:-3]
771
-
772
- folder = '.config'
773
- homePath = os.path.expanduser("~")
774
- configFolder = os.path.join(homePath, folder)
775
-
776
- if not os.path.isdir(homePath):
777
- raise Exception(f"{homePath} HOME path does not exist.")
765
+ (file that started up initially) without the .py extension. A .cfg extension is added
766
+ and it will be found in the ~/.config folder."""
767
+ dotConfigFolder = '.config'
768
+ homePath = os.path.expanduser("~")
769
+ configFolder = os.path.join(homePath, dotConfigFolder)
770
+
771
+ if not os.path.isdir(homePath):
772
+ raise Exception(f"{homePath} HOME path does not exist.")
778
773
 
779
- # Create the ~/.config folder if it does not exist
780
- if not os.path.isdir(configFolder):
781
- # Create the ~/.config folder
782
- os.makedir(configFolder)
783
-
784
- # Note that we assume that addDotToFilename in the ConfigManager constructor is set True
785
- # as this will prefix the filename with the . character.
786
- if os.path.isdir(configFolder):
787
- extraFolders = os.path.dirname(progName)
788
- configFolder = os.path.join(configFolder, extraFolders)
789
- if not os.path.isdir(configFolder):
790
- os.makedirs(configFolder)
791
- if not os.path.isdir(configFolder):
792
- raise Exception(f"Failed to create the {configFolder} folder.")
793
-
794
- configFolder = "config"
795
- configFolder = os.path.join(configFolder, extraFolders)
796
- configFilename = os.path.join(configFolder, os.path.basename(progName) + '.cfg')
774
+ # Create the ~/.config folder if it does not exist
775
+ if not os.path.isdir(configFolder):
776
+ # Create the ~/.config folder
777
+ os.makedir(configFolder)
797
778
 
798
- else:
799
- configFilename = progName
779
+ progName = sys.argv[0]
780
+ if progName.endswith('.py'):
781
+ progName = progName[0:-3]
782
+ progName = os.path.basename(progName).strip()
800
783
 
801
- return configFilename
802
-
803
- def __init__(self, defaultConfig, uio=None, encrypt=False):
784
+ # Note that we assume that addDotToFilename in the ConfigManager constructor is set True
785
+ # as this will prefix the filename with the . character.
786
+ if os.path.isdir(configFolder):
787
+ configFilename = os.path.join(".config", progName + ".cfg")
788
+
789
+ else:
790
+ raise Exception(f"Failed to create the {configFolder} folder.")
791
+
792
+ return configFilename
793
+
794
+ def __init__(self, defaultConfig, keyEditOrderList=None, uio=None, encrypt=False):
804
795
  """@brief Constructor
805
796
  @param defaultConfig A default config instance containing all the default key-value pairs.
797
+ @param keyEditOrderList A list of all the dict keys in the order that the caller wishes them to be displayed top the user.
806
798
  @param uio A UIO (User Input Output) instance. May be set to None if no user messages are required.
807
799
  @param encrypt If True then data will be encrypted in the saved files.
808
800
  The encryption uses part of the the local SSH RSA private key.
@@ -811,7 +803,33 @@ class DotConfigManager(ConfigManager):
811
803
  !!! Therefore if encrypt is set True then the an ssh key must be present !!!
812
804
  ||| in the ~/.ssh folder named id_rsa. !!!"""
813
805
  super().__init__(uio, DotConfigManager.GetDefaultConfigFilename(), defaultConfig, encrypt=encrypt)
806
+ self._keyEditOrderList = keyEditOrderList
814
807
  # Ensure the config file is present and loaded into the internal dict.
815
808
  self.load()
816
809
 
810
+ def show(self):
811
+ """@brief A helper method to show the dictionary config to the user.
812
+ @return A dictionary mapping the attribute ID's (keys) to dictionary keys (values)."""
813
+ maxKeyLen=10
814
+ # If the caller wants to present the parameters to the user in a partiular order
815
+ if self._keyEditOrderList:
816
+ keys = self._keyEditOrderList
817
+ defaultKeys = list(self._configDict.keys())
818
+ for defaultKey in defaultKeys:
819
+ if defaultKey not in keys:
820
+ raise Exception(f"BUG: DotConfigManager: {defaultKey} key is missing from the keyEditOrderList.")
821
+ # Present the parameters to the user in any order.
822
+ else:
823
+ keys = list(self._configDict.keys())
817
824
 
825
+ for key in keys:
826
+ if len(key) > maxKeyLen:
827
+ maxKeyLen = len(key)
828
+ self._info("ID PARAMETER"+" "*(maxKeyLen-8)+" VALUE")
829
+ id=1
830
+ idKeyDict = {}
831
+ for key in keys:
832
+ idKeyDict[id]=key
833
+ self._info("{:<3d} {:<{}} {}".format(id, key, maxKeyLen+1, self._configDict[key]))
834
+ id=id+1
835
+ return idKeyDict
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: p3lib
3
- Version: 1.1.87
3
+ Version: 1.1.89
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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes