Read the configuration files.
()
| 51 | registered_configs[section] = function |
| 52 | |
| 53 | def initialize(): |
| 54 | """Read the configuration files.""" |
| 55 | from pwnlib.log import getLogger |
| 56 | log = getLogger(__name__) |
| 57 | |
| 58 | xdg_config_home = os.environ.get('XDG_CONFIG_HOME', |
| 59 | os.path.expanduser("~/.config")) |
| 60 | |
| 61 | c = configparser.ConfigParser() |
| 62 | c.read(['/etc/pwn.conf', |
| 63 | os.path.join(xdg_config_home, 'pwn.conf'), |
| 64 | os.path.expanduser('~/.pwn.conf')]) |
| 65 | |
| 66 | for section in c.sections(): |
| 67 | if section not in registered_configs: |
| 68 | log.warn("Unknown configuration section %r", section) |
| 69 | continue |
| 70 | settings = dict(c.items(section)) |
| 71 | registered_configs[section](settings) |