filename supplied in __init__ will be read last, so it has highest priority
This commit is contained in:
		@@ -12,8 +12,6 @@ class Conf(object):
 | 
				
			|||||||
        if debug:
 | 
					        if debug:
 | 
				
			||||||
            self.set_debug(debug)
 | 
					            self.set_debug(debug)
 | 
				
			||||||
        filenames = []
 | 
					        filenames = []
 | 
				
			||||||
        if filename:
 | 
					 | 
				
			||||||
            filenames.append(filename)
 | 
					 | 
				
			||||||
        if not force_filename:
 | 
					        if not force_filename:
 | 
				
			||||||
            # default config files are $HOME/etc/userconfig2.conf and
 | 
					            # default config files are $HOME/etc/userconfig2.conf and
 | 
				
			||||||
            # {sys.prefix}/etc/userconfig2.conf
 | 
					            # {sys.prefix}/etc/userconfig2.conf
 | 
				
			||||||
@@ -21,6 +19,9 @@ class Conf(object):
 | 
				
			|||||||
                filenames.append(f'{os.environ.get("HOME")}/etc/userconfig2.conf')
 | 
					                filenames.append(f'{os.environ.get("HOME")}/etc/userconfig2.conf')
 | 
				
			||||||
            if os.path.isfile(f'{sys.prefix}/etc/userconfig2.conf'):
 | 
					            if os.path.isfile(f'{sys.prefix}/etc/userconfig2.conf'):
 | 
				
			||||||
                filenames.append(f'{sys.prefix}/etc/userconfig2.conf')
 | 
					                filenames.append(f'{sys.prefix}/etc/userconfig2.conf')
 | 
				
			||||||
 | 
					        # supplied filename will be read last, has highest priority
 | 
				
			||||||
 | 
					        if filename:
 | 
				
			||||||
 | 
					            filenames.append(filename)
 | 
				
			||||||
        ret = self.set_filenames(filenames)
 | 
					        ret = self.set_filenames(filenames)
 | 
				
			||||||
        if not ret:
 | 
					        if not ret:
 | 
				
			||||||
            raise ValueError(f'Cannot open either configuration file: {",".join(filenames)}')
 | 
					            raise ValueError(f'Cannot open either configuration file: {",".join(filenames)}')
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user