From 6485299a7cd2a9cbdfa10d6e52b23bd8f7d22536 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 16 Sep 2011 17:08:59 +0200 Subject: [PATCH] prepare source records, cleanup Signed-off-by: Nico Schottelius --- bin/cdist | 57 ++++++++++++++++++++----------------------------------- 1 file changed, 21 insertions(+), 36 deletions(-) diff --git a/bin/cdist b/bin/cdist index 34c89d86..032b078d 100755 --- a/bin/cdist +++ b/bin/cdist @@ -77,37 +77,6 @@ def file_to_list(filename): return lines -class TypeEmulator: - def __init__(self, name): - self.name = name - self.type = os.path.basename(name) - - - def type_emulator(self): - type = basename(sys.argv[0]) - - type_is_singleton(type) - - # Check object id - - # Prevent double slash if id begins with / - - # Record parameter: opt_file="${opt#--}" - # [ $# -ge 1 ] || __cdist_usage "Missing value for $opt" - # echo "${value}" > "${__cdist_parameter_dir}/${opt_file}" - - # Record requirements - # echo $requirement >> "$(__cdist_object_require "$__cdist_object_self")" - - # Ensure required parameters are given - # Ensure that only optional or required parameters are given - # [ "$is_valid" ] || __cdist_usage "Unknown parameter $parameter" - - # Merge object (creating twice with the same parameter + requirements == allowed) - - # diff -ru "${__cdist_new_object_dir}/${__cdist_name_parameter} - # # Add "I was here message" - # _cdist_object_source_add "${__cdist_object_dir}" class Cdist: """Cdist main class to hold arbitrary data""" @@ -471,9 +440,9 @@ class Cdist: # Legacy stuff to make cdist-type-emulator work env['__cdist_core_dir'] = os.path.join(self.base_dir, "core") env['__cdist_local_base_dir'] = self.temp_dir - env['__cdist_manifest'] = self.initial_manifest # Submit information to new type emulator + env['__cdist_manifest'] = manifest env['__cdist_type_base_dir'] = self.type_base_dir # Other environment stuff @@ -644,22 +613,38 @@ def emulator(): # Setup optional parameters for parameter in file_to_list(os.path.join(param_dir, "optional")): argument = "--" + parameter - print("Adding" + argument) parser.add_argument(argument, action='store', required=False) # Setup required parameters for parameter in file_to_list(os.path.join(param_dir, "required")): argument = "--" + parameter - print("Adding" + argument) parser.add_argument(argument, action='store', required=True) # Setup positional parameter, if not singleton + if not os.path.isfile(os.path.join(type_dir, "singleton")): + parser.add_argument("object_id", nargs=1) + else: + print("singleton") + # And finally verify parameter args = parser.parse_args(sys.argv[1:]) - print("Oh, noe") - sys.exit(1) + # Record parameter + # wh + print(args) + + # Record requirements + if "__require" in os.environ: + requirements = os.environ['__require'] + + # Merge / mv object into tree + + # Record / Append source + source = os.environ['__cdist_manifest'] + # write to .source? + + # sys.exit(1) def commandline():