Skip to content
Snippets Groups Projects
Commit 7609e2a1 authored by Florian Obersteiner's avatar Florian Obersteiner
Browse files

updated calculation of number of normal comment lines

parent 201348d9
No related branches found
No related tags found
1 merge request!6code refactor
......@@ -208,10 +208,11 @@ class KeywordComment:
class StandardNormalComments(collections.UserList):
@property
def nlines(self):
# "+ 1" -> shortnames line, and keywords might be multiline...
return (
len(self.freeform) + 1 + sum([len(k.data) for k in self.keywords.values()])
)
n = 1 # shortnames line, and keywords might be multiline...
n += len(self.freeform)
n += sum(len(k.data) or 1 for k in self.keywords.values())
# was: len(self.freeform) + 1 + sum([len(k.data) for k in self.keywords.values()])
return n
@property
def data(self):
......@@ -652,7 +653,7 @@ class Dataset:
# this section of the header along with the relevant data listed after the
# colon. For key words where information is not needed or applicable, simply
# enter N/A.).
rawNcom = [f.readline(doSplit=False) for i in range(0, nncom)]
rawNcom = [f.readline(doSplit=False) for _ in range(nncom)]
self.normalComments.ingest(rawNcom)
self.nHeaderFile = f.line
......@@ -786,6 +787,7 @@ class Dataset:
# Variable names and units (Short variable name and units are required, and optional long descriptive name, in that order, and separated by commas. If the variable is unitless, enter the keyword "none" for its units. Each short variable name and units (and optional long name) are entered on one line. The short variable name must correspond exactly to the name used for that variable as a column header, i.e., the last header line prior to start of data.).
for DVAR in self.dependentVariables.values():
write_to_file(DVAR.desc(delimiter))
if self.format == Formats.FFI2110:
# Number of variables (Integer value showing the number of dependent variables: the total number of columns of data is this value plus one.).
write_to_file(len(self.auxiliaryVariables))
......@@ -805,7 +807,6 @@ class Dataset:
for AUXVAR in self.auxiliaryVariables.values():
write_to_file(AUXVAR.desc(delimiter))
# Number of SPECIAL comment lines (Integer value indicating the number of lines of special comments, NOT including this line.).
write_to_file(f"{len(self.specialComments)}")
# Special comments (Notes of problems or special circumstances unique to this file. An example would be comments/problems associated with a particular flight.).
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment