from configparser import ConfigParser prefs = None defaults = { 'Main': { # Logging level # Options: debug, info, warning, error, critical # (see https://docs.python.org/3/howto/logging.html#when-to-use-logging) 'logging': 'debug', # Cache location # Directory to store slide preview images for each presentation 'cache': r'''C:\Windows\Temp\ppt-cache''', # Cache format # Can be set to any image filter set in the registry, but most commonly JPG or PNG # (see https://docs.microsoft.com/en-us/office/vba/api/powerpoint.slide.export) 'cache_format': 'JPG', # Cache timeout # Time after which slides should be exported again to reflect any changes made in the # PowerPoint editor. Value is in seconds. 'cache_timeout': 5*60, # Cache initialisation # Whether to export all slides when a slideshow is started. Can be set to any falsy or # truthy value. 'cache_init': True, # Black-white behaviour # Sets the behaviour when returning from black or white mode. Options: "both", "literal" # In PowerPoint's presenter view, if the slideshow is in black or white screen mode, # attempting to switch to the other mode (white/black) will result in the slideshow # returning to a normal (visible) state, rather than white/black. This behaviour is # also the default for ppt-control, and is set by setting the value of "blackwhite" # to "both" (since when the slideshow is in black or white mode, requesting either # of black or white mode will return the slideshow to normal). The more intuitive # settings is "literal", whereby when the slideshow is in black or white mode, # pressing the button corresponding to the mode that the slideshow is already in will # return the slideshow to normal mode, and pressing the other button will put the # slideshow into that mode. 'blackwhite': 'both', # Refresh interval # Describes the number of seconds between backend updates, which consist of: # - synchronisation of PowerPoint's events with the internal state. # - updating the interface (systray icon) status # - check for PowerPoint files that have been opened in protected view # You could set a shorter value here, but these updates don't have to be instant so # the default value of 2 seconds should work fine. 'refresh': 2, # Disable protecte view # If set to a truthy value, ppt-control will attempt to disable protected view on files # which have been opened in protected view. Obviously this introduces some security risk, # so if you are uncomfortable with this, leave it off and you will have to disable # protected view for each file manually to be able to control it will ppt-control. 'disable_protected': True }, 'HTTP': { # HTTP interface # The interface to listen for HTTP requests on. Change this if you want to restrict the # HTTP frontend to a specific network. A blank value means all interfaces. 'interface': '', # HTTP port # The port to listen for HTTP requests on. The default value of 80 is the standard # port for HTTP, so when set to this value you don't need to include the port number # in the URL when navigating to the frontend. For all other values you will need to # specify the port number in the web browser (except 443, but that's a bad idea). 'port': 80 }, 'WebSocket': { # WebSocket interface # The interface to listen for WebSocket requests on. Change this if you want to restrict # the WebSocket interface to a specific network. A value of 0.0.0.0 means all interfaces. 'interface': '0.0.0.0', # WebSocket port # The port to listen for WebSocket requests on. This needs to match the port specified in # whatever frontend you are using (e.g. in the JS code for the HTTP frontend, or in the # script settings for the OBS frontend). 'port': 5678 } } def loadconf(configpaths): """ Initial setup for a ConfigParser object. `configpaths` should be a list of configuration files to load (typically only one). To use the generated ConfigParser, use `import logparse.config` and then `config.prefs.get(..)`. The prefs object is returned after creation as a convenience but this method should only be called once per runtime. """ prefs = ConfigParser() prefs.read_dict(defaults) try: success = prefs.read(configpaths) print("Loaded {0} config file(s): {1}".format( str(len(success)), str(success))) except Exception as e: print("Error processing config: " + str(e)) return prefs def export_defaults(file): """ Write the default settings to a file object, including comments and with spaces around delimeters. This function is intended to be used to populate the config file with defaults after installation. """ prefs = loadconf([]) prefs.write(file, space_around_delimiters=True)