Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

configuration-parser.py 687 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  1. #!/usr/bin/env python
  2. """
  3. read configuration file and print the assignments for a bash script
  4. The idea comes from
  5. https://serverfault.com/questions/345665/how-to-parse-and-convert-ini-file-into-bash-array-variables
  6. which came from https://stdiff.net/MB2019051301.html
  7. """
  8. import click
  9. from configparser import ConfigParser
  10. @click.command()
  11. @click.option("--ini", default="config.ini", type=str)
  12. def parse_configuration(ini:str):
  13. config = ConfigParser()
  14. config.read(ini)
  15. for sec in config.keys():
  16. print("declare -A %s" % (sec))
  17. for k,v in config.items(sec):
  18. print("%s[%s]=%s" % (sec, k,v))
  19. if __name__ == "__main__":
  20. parse_configuration()
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...