How to use the configparser.ConfigParser.read function in configparser

To help you get started, we’ve selected a few configparser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github arista-eosplus / pyeapi / pyeapi / client.py View on Github external
def read(self, filename):
        """Reads the file specified by filename

        This method will load the eapi.conf file specified by filename into
        the instance object.  It will also add the default connection localhost
        if it was not defined in the eapi.conf file

        Args:
            filename (str): The full path to the file to load
        """

        try:
            SafeConfigParser.read(self, filename)
        except SafeConfigParserError as exc:
            # Ignore file and syslog a message on SafeConfigParser errors
            msg = ("%s: parsing error in eapi conf file: %s" %
                   (type(exc).__name__, filename))
            debug(msg)

        self._add_default_connection()

        for name in self.sections():
            if name.startswith('connection:') and \
               'host' not in dict(self.items(name)):

                self.set(name, 'host', name.split(':')[1])
        self.generate_tags()
github fail2ban / fail2ban / fail2ban / client / configparserinc.py View on Github external
def read(self, filenames):
		fileNamesFull = []
		if not isinstance(filenames, list):
			filenames = [ filenames ]
		for filename in filenames:
			fileNamesFull += SafeConfigParserWithIncludes.getIncludes(filename)
		logSys.debug("Reading files: %s" % fileNamesFull)
		if sys.version_info >= (3,2): # pragma: no cover
			return SafeConfigParser.read(self, fileNamesFull, encoding='utf-8')
		else:
			return SafeConfigParser.read(self, fileNamesFull)
github AudiusProject / audius-protocol / discovery-provider / src / utils / config.py View on Github external
def read(self, filenames, encoding=None):
        """Overridden read() method to call parse_flask_section() at the end"""
        ret = configparser.ConfigParser.read(self, filenames, encoding)
        self.parse_flask_section()
        return ret
github nthmost / python-secureconfig / secureconfig / secureconfigparser.py View on Github external
def read(self, filenames):
        """Read the list of config files."""
        # print("[DEBUG] filenames: ", filenames)
        ConfigParser.read(self, filenames)
github tehmaze / classified / classified / config.py View on Github external
def read(self, filename):
        if isinstance(filename, (list, tuple)):
            self.filename = filename[0]
        else:
            self.filename = filename

        ConfigParser.read(self, filename)
github juantascon / tvcmd / tvcmd / fs.py View on Github external
def read(self):
        return ConfigParser.read(self, self.filename)