From b41ed0201c80e3de0078dbacd766f5ef62819363 Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Mon, 20 Feb 2023 01:13:52 -0800 Subject: add python ini config example --- Dockerfile | 1 + config.ini | 12 ++++++++++++ config.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 Dockerfile create mode 100644 config.ini create mode 100644 config.py diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2d13273 --- /dev/null +++ b/Dockerfile @@ -0,0 +1 @@ +FROM python:3 diff --git a/config.ini b/config.ini new file mode 100644 index 0000000..8b4f7bf --- /dev/null +++ b/config.ini @@ -0,0 +1,12 @@ +; [DEFAULT] +; ServerAliveInterval = 45 +; Compression = yes +; CompressionLevel = 9 +; ForwardX11 = yes + +; [forge.example] +; User = hg + +; [topsecret.server.example] +; Port = 50022 +; ForwardX11 = no diff --git a/config.py b/config.py new file mode 100644 index 0000000..7f8e2f0 --- /dev/null +++ b/config.py @@ -0,0 +1,28 @@ +# https://docs.python.org/3/library/configparser.html + +# import configparser +# config = configparser.ConfigParser() +# config['DEFAULT'] = {'ServerAliveInterval': '45', +# 'Compression': 'yes', +# 'CompressionLevel': '9'} +# config['forge.example'] = {} +# config['forge.example']['User'] = 'hg' +# config['topsecret.server.example'] = {} +# topsecret = config['topsecret.server.example'] +# topsecret['Port'] = '50022' # mutates the parser +# topsecret['ForwardX11'] = 'no' # same here +# config['DEFAULT']['ForwardX11'] = 'yes' +# with open('example.ini', 'w') as configfile: +# config.write(configfile) + +# config = configparser.ConfigParser() +# config.sections() +# config.read('example.ini') +# config.sections() +# topsecret = config['topsecret.server.example'] +# topsecret['ForwardX11'] +# topsecret['Port'] +# for key in config['forge.example']: +# print(key) + +# config['forge.example']['ForwardX11'] -- cgit v1.2.3