From b4e9e94f2c6dafa32dee7d70adee2c53ab24ab3d Mon Sep 17 00:00:00 2001 From: ldericher Date: Tue, 4 Aug 2020 16:52:30 +0200 Subject: [PATCH] begin work on python implementation --- .gitignore | 1 + .idea/.gitignore | 4 ++++ .../inspectionProfiles/profiles_settings.xml | 6 ++++++ .idea/kiwi-config.iml | 10 ++++++++++ .idea/misc.xml | 4 ++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ src/etc/default.kiwi.yml | 12 +++++++++++ src/kiwi-config.py | 20 +++++++++++++++++++ src/kiwi/__init__.py | 1 + src/kiwi/config.py | 15 ++++++++++++++ 11 files changed, 87 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/kiwi-config.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 src/etc/default.kiwi.yml create mode 100644 src/kiwi-config.py create mode 100644 src/kiwi/__init__.py create mode 100644 src/kiwi/config.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c18dd8d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__/ diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..351c96d --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,4 @@ +# Default ignored files +/shelf/ +/workspace.xml + diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/kiwi-config.iml b/.idea/kiwi-config.iml new file mode 100644 index 0000000..15c0cd1 --- /dev/null +++ b/.idea/kiwi-config.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d4fc832 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..b44487f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/etc/default.kiwi.yml b/src/etc/default.kiwi.yml new file mode 100644 index 0000000..ec93e07 --- /dev/null +++ b/src/etc/default.kiwi.yml @@ -0,0 +1,12 @@ +version: 0.1 + +suffix: + project: .project + down: .down + +docker: + net: kiwinet + cidr: 10.22.46.0/24 + +target: + root: /var/kiwi diff --git a/src/kiwi-config.py b/src/kiwi-config.py new file mode 100644 index 0000000..5fae606 --- /dev/null +++ b/src/kiwi-config.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 + +import argparse +from kiwi import * + + +def main(): + parser = argparse.ArgumentParser(description='kiwi-config') + parser.add_argument('cmd', metavar='command', type=str, help='subcommand to execute') + + args = parser.parse_args() + print(args.cmd) + + cf = config.Config.default() + + pass + + +if __name__ == "__main__": + main() diff --git a/src/kiwi/__init__.py b/src/kiwi/__init__.py new file mode 100644 index 0000000..7c281ff --- /dev/null +++ b/src/kiwi/__init__.py @@ -0,0 +1 @@ +__all__ = ['config'] diff --git a/src/kiwi/config.py b/src/kiwi/config.py new file mode 100644 index 0000000..abff981 --- /dev/null +++ b/src/kiwi/config.py @@ -0,0 +1,15 @@ +class Config: + # version, suffix_project, suffix_down, docker_net, docker_cidr, target_root = None + + def __init__(self, filename): + import yaml + + with open(filename, 'r') as stream: + try: + print(yaml.safe_load(stream)) + except yaml.YAMLError as exc: + print(exc) + + @classmethod + def default(cls): + return cls("./etc/default.kiwi.yml")