From 88596cbd464830f60256d23a73e2d64817d38f44 Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Tue, 28 Mar 2023 17:26:51 +0200 Subject: [PATCH] feat: mv example from README to .ini file --- README.md | 17 ++--------------- cfg/example.ini | 12 ++++++++++++ src/netcup_dns/main.py | 4 ++++ 3 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 cfg/example.ini diff --git a/README.md b/README.md index 5da177a..697714e 100644 --- a/README.md +++ b/README.md @@ -4,22 +4,9 @@ Update DNS records with your current external IP address using the netcup DNS AP ## Configuration -For each netcup customer, create a `.ini` configuration file. Here is an example: +For each netcup customer, create a `.ini` configuration file. -```ini -[credentials] -customer = 123456 -api_key = abcdefghijklmnopqrstuvwxyz -api_password = abcdefghijklmnopqrstuvwxyz - -[example.com] -hostname = @ -type = A - -[foo.bar] -hostname = @ -type = A -``` +There is an [example configuration](cfg/example.ini). ## TODOs diff --git a/cfg/example.ini b/cfg/example.ini new file mode 100644 index 0000000..2195b40 --- /dev/null +++ b/cfg/example.ini @@ -0,0 +1,12 @@ +;[credentials] +;customer = 123456 +;api_key = abcdefghijklmnopqrstuvwxyz +;api_password = abcdefghijklmnopqrstuvwxyz +; +;[example.com] +;hostname = @ +;type = A +; +;[foo.bar] +;hostname = @ +;type = A diff --git a/src/netcup_dns/main.py b/src/netcup_dns/main.py index 96429dd..553a3f8 100644 --- a/src/netcup_dns/main.py +++ b/src/netcup_dns/main.py @@ -26,6 +26,10 @@ def main(): for cfg_file in cfg_files: cfg = configparser.ConfigParser() cfg.read(cfg_file) + if len(cfg.sections()) == 0: + # Skip completely empty configuration file. + continue + customer = cfg['credentials']['customer'] api_key = cfg['credentials']['api_key'] api_password = cfg['credentials']['api_password']