opt_set 575 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env python
  2. import sys, os, config
  3. def main():
  4. args = sys.argv[1:]
  5. if len(args) % 2 != 0:
  6. print("ERROR: Please provide pairs of <name> <value>")
  7. return
  8. for i in range(0, len(args), 2):
  9. name = args[i]
  10. value = args[i + 1]
  11. changed = False
  12. for file in config.FILES:
  13. if os.path.exists(file):
  14. if config.set(file, name, value):
  15. changed = True
  16. if not changed:
  17. config.add(config.FILES[0], name, value)
  18. if __name__ == "__main__":
  19. main()