cfg_main.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env python3
  2. import os
  3. from mmgen.cfg import Config
  4. from mmgen.util import msg
  5. cfg = Config(process_opts=True)
  6. cmd_args = cfg._args
  7. from mmgen.cfgfile import mmgen_cfg_file
  8. cf_usr = mmgen_cfg_file(cfg,'usr')
  9. cf_sys = mmgen_cfg_file(cfg,'sys')
  10. cf_sample = mmgen_cfg_file(cfg,'sample')
  11. msg(f'Usr cfg file: {os.path.relpath(cf_usr.fn)}')
  12. msg(f'Sys cfg file: {os.path.relpath(cf_sys.fn)}')
  13. msg(f'Sample cfg file: {os.path.relpath(cf_sample.fn)}')
  14. if cmd_args:
  15. if cmd_args[0] == 'parse_test':
  16. ps = cf_sample.get_lines()
  17. msg(f'parsed chunks: {len(ps)}')
  18. pu = cf_usr.get_lines()
  19. msg('usr cfg: {}'.format( ' '.join(f'{i.name}={i.value}' for i in pu) ))
  20. elif cmd_args[0] == 'coin_specific_vars':
  21. for varname in cmd_args[1:]:
  22. msg('{}.{}: {}'.format(
  23. type(cfg._proto).__name__,
  24. varname,
  25. getattr(cfg._proto,varname)
  26. ))
  27. elif cmd_args[0] == 'autoset_opts':
  28. assert cfg.rpc_backend == 'aiohttp', "cfg.rpc_backend != 'aiohttp'"
  29. elif cmd_args[0] == 'autoset_opts_cmdline':
  30. assert cfg.rpc_backend == 'curl', "cfg.rpc_backend != 'curl'"
  31. elif cmd_args[0] == 'mnemonic_entry_modes':
  32. from mmgen.mn_entry import mn_entry
  33. msg('mnemonic_entry_modes: {}\nmmgen: {}\nbip39: {}'.format(
  34. cfg.mnemonic_entry_modes,
  35. mn_entry(cfg,'mmgen').usr_dfl_entry_mode,
  36. mn_entry(cfg,'bip39').usr_dfl_entry_mode ))