instead of mainconfig the specifier value is now saved in a field with the name SPECIERFIERFIELD
This commit is contained in:
parent
f0a3d09d8a
commit
b9084b7493
2 changed files with 17 additions and 19 deletions
|
@ -51,6 +51,7 @@ VARIABLE_PARTS_SEP = "|"
|
||||||
VARIABLE_DEFAULT_SEP = "#"
|
VARIABLE_DEFAULT_SEP = "#"
|
||||||
NON_FORMFIELD = "Nonfield"
|
NON_FORMFIELD = "Nonfield"
|
||||||
CONFIGFIELD = "Mainconfig"
|
CONFIGFIELD = "Mainconfig"
|
||||||
|
SPECIFIERFIELD = "Specifier"
|
||||||
OUTPUTFIELD = "Outputconfig"
|
OUTPUTFIELD = "Outputconfig"
|
||||||
FORMOUTPUTFIELD = "Formoutputconfig"
|
FORMOUTPUTFIELD = "Formoutputconfig"
|
||||||
ON = ["Ja", "On", "ja"]
|
ON = ["Ja", "On", "ja"]
|
||||||
|
|
35
fillform.py
35
fillform.py
|
@ -58,6 +58,7 @@ import commands
|
||||||
import formfield
|
import formfield
|
||||||
import readformdata
|
import readformdata
|
||||||
from constants import (NON_FORMFIELD, CONFIGFIELD, OUTPUTFIELD,
|
from constants import (NON_FORMFIELD, CONFIGFIELD, OUTPUTFIELD,
|
||||||
|
SPECIFIERFIELD,
|
||||||
FORMOUTPUTFIELD, SUBINFO_SEP, ConfigError,
|
FORMOUTPUTFIELD, SUBINFO_SEP, ConfigError,
|
||||||
GENERALADVICE, EPILOG)
|
GENERALADVICE, EPILOG)
|
||||||
import writetopdf
|
import writetopdf
|
||||||
|
@ -152,10 +153,12 @@ def readDataPaths(configs, maindir="."):
|
||||||
Configs is a list of FormFields.
|
Configs is a list of FormFields.
|
||||||
In the configs there can be a field with the FieldName "Mainconfig".
|
In the configs there can be a field with the FieldName "Mainconfig".
|
||||||
This can specify with the info Data and the data specifier-Path
|
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 file, try to use that file for this data.
|
||||||
If this path is a directory, search for a file that gives this
|
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
|
data. This is the case if the config value SPECIFIERFIELD
|
||||||
specifies that is to be called this name in the info "Specifier".
|
of this other form file
|
||||||
|
specifies that is to be called this name.
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
configs ([FormField]):
|
configs ([FormField]):
|
||||||
|
@ -219,8 +222,8 @@ def findDataFile(directory, specifier):
|
||||||
Attributes:
|
Attributes:
|
||||||
directory (str): directory in which to be searched.
|
directory (str): directory in which to be searched.
|
||||||
specifier (str):
|
specifier (str):
|
||||||
the file searched for has the info "Specifier" with the value
|
the file searched for has the Field SPECIFIERFIELD with the value
|
||||||
specifier in the field with the FieldName "Mainconfig"
|
specifier.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
a list of fields from this file.
|
a list of fields from this file.
|
||||||
|
@ -231,6 +234,8 @@ def findDataFile(directory, specifier):
|
||||||
"""
|
"""
|
||||||
for dirpath, _, files in os.walk(directory):
|
for dirpath, _, files in os.walk(directory):
|
||||||
print("debug: directory:", directory)
|
print("debug: directory:", directory)
|
||||||
|
if ".git" in dirpath:
|
||||||
|
continue
|
||||||
print("debug: dirpath:", dirpath)
|
print("debug: dirpath:", dirpath)
|
||||||
print("debug: files:", files)
|
print("debug: files:", files)
|
||||||
for datafile in files:
|
for datafile in files:
|
||||||
|
@ -253,22 +258,14 @@ def findDataFile(directory, specifier):
|
||||||
"attempting to understand",
|
"attempting to understand",
|
||||||
filepath + ":",
|
filepath + ":",
|
||||||
str(e))
|
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:
|
else:
|
||||||
try:
|
if getConfigvalue(fieldname=SPECIFIERFIELD,
|
||||||
if mainconfig["Specifier"] == specifier:
|
fields=datalist,
|
||||||
return datalist
|
argument=None,
|
||||||
else:
|
default=None) == specifier:
|
||||||
print("debug:", datafile,
|
return datalist
|
||||||
"has mainconfig but wrong specifier")
|
else:
|
||||||
except KeyError:
|
print("debug:", datafile, "has no or wrong specifier.")
|
||||||
print("debug:", datafile,
|
|
||||||
"has no specifier in mainconfig")
|
|
||||||
# if none found
|
# if none found
|
||||||
print("debug: no file for", specifier, "found.")
|
print("debug: no file for", specifier, "found.")
|
||||||
raise ConfigError("I looked for a data file for the specifier " +
|
raise ConfigError("I looked for a data file for the specifier " +
|
||||||
|
|
Loading…
Reference in a new issue