From b9084b7493e081452bcb539c9e358ea7e90c431b Mon Sep 17 00:00:00 2001 From: Bela Date: Mon, 16 Jul 2018 11:25:00 +0200 Subject: [PATCH] instead of mainconfig the specifier value is now saved in a field with the name SPECIERFIERFIELD --- constants.py | 1 + fillform.py | 35 ++++++++++++++++------------------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/constants.py b/constants.py index 4ce1a16..c32f21b 100644 --- a/constants.py +++ b/constants.py @@ -51,6 +51,7 @@ VARIABLE_PARTS_SEP = "|" VARIABLE_DEFAULT_SEP = "#" NON_FORMFIELD = "Nonfield" CONFIGFIELD = "Mainconfig" +SPECIFIERFIELD = "Specifier" OUTPUTFIELD = "Outputconfig" FORMOUTPUTFIELD = "Formoutputconfig" ON = ["Ja", "On", "ja"] diff --git a/fillform.py b/fillform.py index 13c1da5..ff528bd 100755 --- a/fillform.py +++ b/fillform.py @@ -58,6 +58,7 @@ import commands import formfield import readformdata from constants import (NON_FORMFIELD, CONFIGFIELD, OUTPUTFIELD, + SPECIFIERFIELD, FORMOUTPUTFIELD, SUBINFO_SEP, ConfigError, GENERALADVICE, EPILOG) import writetopdf @@ -152,10 +153,12 @@ def readDataPaths(configs, maindir="."): Configs is a list of FormFields. In the configs there can be a field with the FieldName "Mainconfig". This can specify with the info Data and the data specifier-Path + paths for data to be found in. If this path is a file, try to use that file for this data. If this path is a directory, search for a file that gives this - data. This is the case if the mainconfig of this other form file - specifies that is to be called this name in the info "Specifier". + data. This is the case if the config value SPECIFIERFIELD + of this other form file + specifies that is to be called this name. Attributes: configs ([FormField]): @@ -219,8 +222,8 @@ def findDataFile(directory, specifier): Attributes: directory (str): directory in which to be searched. specifier (str): - the file searched for has the info "Specifier" with the value - specifier in the field with the FieldName "Mainconfig" + the file searched for has the Field SPECIFIERFIELD with the value + specifier. Returns: a list of fields from this file. @@ -231,6 +234,8 @@ def findDataFile(directory, specifier): """ for dirpath, _, files in os.walk(directory): print("debug: directory:", directory) + if ".git" in dirpath: + continue print("debug: dirpath:", dirpath) print("debug: files:", files) for datafile in files: @@ -253,22 +258,14 @@ def findDataFile(directory, specifier): "attempting to understand", filepath + ":", str(e)) - try: - mainconfig = formfield.FormField.findByFieldName( - datalist, CONFIGFIELD, - include=lambda fi: NON_FORMFIELD in fi) - except KeyError: - print("debug", datafile, "has no mainconfig") else: - try: - if mainconfig["Specifier"] == specifier: - return datalist - else: - print("debug:", datafile, - "has mainconfig but wrong specifier") - except KeyError: - print("debug:", datafile, - "has no specifier in mainconfig") + if getConfigvalue(fieldname=SPECIFIERFIELD, + fields=datalist, + argument=None, + default=None) == specifier: + return datalist + else: + print("debug:", datafile, "has no or wrong specifier.") # if none found print("debug: no file for", specifier, "found.") raise ConfigError("I looked for a data file for the specifier " +