euscan: Adding config file support
Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
		
							
								
								
									
										1
									
								
								TODO
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								TODO
									
									
									
									
									
								
							| @@ -17,7 +17,6 @@ euscan | |||||||
|  |  | ||||||
| ### Misc | ### Misc | ||||||
|  |  | ||||||
| - Add a config file (/etc/euscan.conf, ~/.euscan.conf) |  | ||||||
| - Add a HTTP cache (configurable) | - Add a HTTP cache (configurable) | ||||||
|  |  | ||||||
| ### Tests | ### Tests | ||||||
|   | |||||||
| @@ -230,7 +230,8 @@ def parse_args(): | |||||||
| def main(): | def main(): | ||||||
|     """Parse command line and execute all actions.""" |     """Parse command line and execute all actions.""" | ||||||
|     CONFIG['nocolor'] = ( |     CONFIG['nocolor'] = ( | ||||||
|         settings["NOCOLOR"] in ('yes', 'true') or not isatty |         CONFIG['nocolor'] or | ||||||
|  |         (settings["NOCOLOR"] in ('yes', 'true') or not isatty) | ||||||
|     ) |     ) | ||||||
|     if CONFIG['nocolor']: |     if CONFIG['nocolor']: | ||||||
|         pp.output.nocolor() |         pp.output.nocolor() | ||||||
|   | |||||||
| @@ -5,6 +5,10 @@ | |||||||
|  |  | ||||||
| __version__ = "git" | __version__ = "git" | ||||||
|  |  | ||||||
|  | import ConfigParser | ||||||
|  | import os | ||||||
|  |  | ||||||
|  |  | ||||||
| CONFIG = { | CONFIG = { | ||||||
|     'nocolor': False, |     'nocolor': False, | ||||||
|     'quiet': False, |     'quiet': False, | ||||||
| @@ -27,6 +31,13 @@ CONFIG = { | |||||||
|     'ebuild-uri': False, |     'ebuild-uri': False, | ||||||
| } | } | ||||||
|  |  | ||||||
|  | config = ConfigParser.ConfigParser() | ||||||
|  | config.read(['/etc/euscan.conf', os.path.expanduser('~/.euscan.conf')]) | ||||||
|  | if config.has_section("euscan"): | ||||||
|  |     for key, value in config.items("euscan"): | ||||||
|  |         if key in CONFIG: | ||||||
|  |             CONFIG[key] = value | ||||||
|  |  | ||||||
| BLACKLIST_VERSIONS = [ | BLACKLIST_VERSIONS = [ | ||||||
|     # Compatibility package for running binaries linked against a |     # Compatibility package for running binaries linked against a | ||||||
|     # pre gcc 3.4 libstdc++, won't be updated |     # pre gcc 3.4 libstdc++, won't be updated | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user