Skip to content

Commit 5f1eebf

Browse files
author
Forni B
authored
Merge pull request #11 from fabfab1/develop
Error corrections
2 parents 6fb5f9d + 123897b commit 5f1eebf

25 files changed

+451
-638
lines changed

EnCAB/EnCAB.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,24 @@
1919
os.chdir(__location__)
2020

2121

22+
class Logger(object):
23+
def __init__(self):
24+
self.terminal = sys.stdout
25+
self.log = open('log.txt', 'w')
26+
27+
def write(self, message):
28+
self.terminal.write(message)
29+
self.log.write(message)
30+
31+
def flush(self):
32+
pass
33+
34+
# save text to log.txt
35+
logger = Logger()
36+
sys.stdout = logger
37+
sys.stderr = logger
38+
39+
2240
def files_index(website_dir):
2341
""" Generate dict of file names from first subdirectories """
2442

@@ -59,7 +77,6 @@ def parse(filename, index):
5977
tree = ET.parse(filename)
6078
except ET.ParseError as err:
6179
print(f'[Err] "{os.path.basename(filename)}" {err}.')
62-
input()
6380
sys.exit()
6481

6582
"""
@@ -103,7 +120,7 @@ def parse(filename, index):
103120
.format(d_type.tag+'/'+d_type.text.replace(' ','_'), os.path.basename(filename)))
104121

105122
# Check operations
106-
op = False
123+
op_result = False
107124
if root.find('algdata/results'):
108125
for var in root.find('algdata/results'):
109126
# Check <unit> in results
@@ -116,9 +133,8 @@ def parse(filename, index):
116133
.format('units/'+unit.replace(' ', '_'), os.path.basename(filename)))
117134
# Check <op> in results
118135
if not var.find('op').text:
119-
print(f'[Err] Missing <op> in "{os.path.basename(filename)}"')
120-
else:
121-
op = True
136+
print(f'[Err] Missing <op> in <results> in "{os.path.basename(filename)}"')
137+
op_result = True
122138
if root.find('algdata/variables'):
123139
for var in root.find('algdata/variables'):
124140
# Check <unit> in variables
@@ -130,11 +146,8 @@ def parse(filename, index):
130146
print('[Err] "{}" from "{}" not found in website files.'
131147
.format('units/'+unit.replace(' ', '_'), os.path.basename(filename)))
132148
# Check <op> in variables
133-
if not op:
134-
if var.find('op').text:
135-
op = True
136-
if not op:
137-
print(f'[Err] Missing <op> in "{os.path.basename(filename)}"')
149+
if not op_result and (var.find('op') is None or not var.find('op').text):
150+
print(f'[Err] Missing <op> in "{os.path.basename(filename)}"')
138151

139152
# TODO: all errors trap (check codes and info) [NOT everything must be present]
140153

@@ -237,14 +250,6 @@ def generate_html(template, blocks_data):
237250
.get_template(filename).render(blocks_data=blocks_data)
238251

239252

240-
def perror(text):
241-
""" Print the error and write it to log """
242-
243-
print(text) # TODO
244-
245-
return
246-
247-
248253
def check_config():
249254
""" Base check to assert existence of files and directories """
250255

EnCAB/log.txt

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -16,51 +16,8 @@ Press ENTER to Continue, Ctrl-C to Abort.
1616

1717
[*] Generating indexes...
1818
[*] Importing algorithms data...
19-
[Err] "algorithm_type/weight_calculations" from "Abrams_1994_46_3.xml" not found in website files.
20-
[Err] "position_in_process/material" from "Abrams_1994_46_3.xml" not found in website files.
21-
22-
[Err] Missing <unit> in "Abrams_1994_47_3.xml"
23-
[Err] Missing <unit> in "Abrams_1994_47_3.xml"
24-
[Err] Missing <unit> in "Abrams_1994_47_3.xml"
2519
[Err] Missing <unit> in "Abrams_1994_47_3.xml"
2620
[Err] Missing <unit> in "Abrams_1994_47_3.xml"
27-
[Err] Missing <unit> in "Abrams_1994_47_3.xml"
28-
29-
[Err] "algorithm_type/tool" from "Abrams_1994_48_1.xml" not found in website files.
30-
31-
[Err] "units/cm2" from "Abrams_1994_49_1.xml" not found in website files.
32-
[Err] "units/cm2" from "Abrams_1994_49_2.xml" not found in website files.
33-
34-
[Err] "source_type/experimental_archaeology" from "Aurenche_1981_46.xml" not found in website files.
35-
[Err] "source_geographical_location/" from "Aurenche_1981_46.xml" not found in website folders.
36-
[Err] "units/percentage" from "Aurenche_1981_46.xml" not found in website files.
37-
[Err] "algorithm_type/building_wall" from "Aurenche_1981_54.xml" not found in website files.
38-
[Err] "material/pise'" from "Aurenche_1981_54.xml" not found in website files.
39-
[Err] "source_type/experimental_archaeology" from "Aurenche_1981_54.xml" not found in website files.
40-
[Err] "source_geographical_location/" from "Aurenche_1981_54.xml" not found in website folders.
41-
[Err] "units/cm" from "Aurenche_1981_54.xml" not found in website files.
42-
[Err] "units/days" from "Aurenche_1981_54.xml" not found in website files.
43-
[Err] "source_geographical_location/" from "Aurenche_1981_66.xml" not found in website folders.
44-
[Err] "units/bricks" from "Aurenche_1981_66.xml" not found in website files.
45-
[Err] "source_geographical_location/" from "Buccellati_2016_108.xml" not found in website folders.
46-
[Err] "source_geographical_location/" from "Buccellati_2016_109.xml" not found in website folders.
47-
[Err] "source_geographical_location/" from "Cornerstones_2006_132.xml" not found in website folders.
48-
[Err] "units/cm" from "Cornerstones_2006_132.xml" not found in website files.
49-
[Err] "units/cm" from "Cornerstones_2006_132.xml" not found in website files.
50-
[Err] "source_geographical_location/" from "Cornerstones_2006_133.xml" not found in website folders.
51-
[Err] "units/calcius" from "Cornerstones_2006_133.xml" not found in website files.
52-
[Err] "units/piece" from "Cornerstones_2006_133.xml" not found in website files.
53-
[Err] "algorithm_type/building_wall" from "Garner_1984_5.xml" not found in website files.
54-
[Err] "source_geographical_location/" from "Garner_1984_5.xml" not found in website folders.
55-
[Err] "units/m" from "Garner_1984_5.xml" not found in website files.
56-
[Err] "source_geographical_location/" from "Heimpel_2009_223.xml" not found in website folders.
57-
[Err] "units/bricks" from "Heimpel_2009_223.xml" not found in website files.
58-
[Err] "source_geographical_location/" from "Minke_1994_55.xml" not found in website folders.
59-
[Err] "units/units" from "Minke_1994_55.xml" not found in website files.
60-
[Err] "source_geographical_location/" from "Robson_1999_67.xml" not found in website folders.
61-
[Err] "source_geographical_location/" from "Wulff_1966_126.xml" not found in website folders.
62-
[Err] "units/calcius" from "Wulff_1966_126.xml" not found in website files.
63-
[Err] "units/gypsum" from "Wulff_1966_126.xml" not found in website files.
6421
[*] Writing data...
6522

6623
[+] Done!

EnCAB/templates/algorithm.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
<b>{{ b.find('reference').text|replace('_','&nbsp;') }}</b>
1111
<table class="data">
1212
<tr>
13-
<td class="col-1">Al Statement:</td><td class="col-2">{{ b.find('algdata/algorithm_statement').text or '' }}</td>
14-
<td class="col-3">Al Math:</td><td class="col-4">{{ b.find('algdata/algorithm_math').text or '' }}</td>
13+
<td class="col-1 AI-Statement">Al Statement:</td><td class="col-2 AI-Statement-input">{{ b.find('algdata/algorithm_statement').text or '' }}</td>
14+
<td class="col-3 AI-Math">Al Math:</td><td class="col-4 AI-Math-input">{{ b.find('algdata/algorithm_math').text or '' }}</td>
1515
</tr>
1616
<tr>
1717
<td colspan="4">{%- if b.find('algdata/variables') %}
@@ -68,14 +68,14 @@
6868
<tr>
6969
<td>How to cite:</td><td>EnCAB alg. - {{ b.find('reference').text }}</td>
7070
<td>Created by/on:</td><td>{% if b.find('algauthors/creation_author_group/author') %}<a href="../bibliography/bibliography.html#{{(b.find('algauthors/creation_author_group/author/surname').text or '').strip('.,')|replace(' ','')}}{{(b.find('algauthors/creation_author_group/author/firstname').text or '').strip('.,')|replace(' ','')}}">{{(b.find('algauthors/creation_author_group/author/surname').text or '')}} {{(b.find('algauthors/creation_author_group/author/firstname').text or '')}}</a>{% endif %}
71-
{%- if b.find('algauthors/creation_author_group/creation_date').text %}, {{ b.find('algauthors/creation_author_group/creation_date').text }}{% endif %}</td>
71+
{%- if b.find('algauthors/creation_author_group/author/creation_date').text %}, {{ b.find('algauthors/creation_author_group/author/creation_date').text }}{% endif %}</td>
7272
</tr>
7373
<tr>
7474
<td>Input data:</td><td><a href="../algorithms_data/{{filename}}">{{ filename }}</a></td>
7575
<td>Modified by/on:</td><td>
7676
{%- for modification_author in b.find('algauthors/modification_author_group') %}
7777
<a href="../bibliography/bibliography.html#{{(modification_author.find('surname').text or '').strip('.,')|replace(' ','')}}{{(modification_author.find('firstname').text or '').strip('.,')|replace(' ','')}}">{{(modification_author.find('surname').text or '')}} {{(modification_author.find('firstname').text or '')}}</a>
78-
{%- if modification_author.find('creation_date').text %}, {{ modification_author_group.find('creation_date').text }}{% endif %}
78+
{%- if modification_author.find('modification_date').text %}, {{ modification_author.find('modification_date').text }}{% endif %}
7979
{%- if not loop.last %}; {% endif %}{% endfor %}</td>
8080
</tr>
8181
</table>

EnCAB/to-do programming.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
List of things still to do in EnCAB Program:
22

3-
PRIORITY 1
4-
----------
5-
Created by/on field is missing the 'on' portion, which should be taken from <creation_date>. I assume same needs to be done for Modified by/on. Only the author's name would be linked, as you have it now.
63

7-
source_geography seems to give an error in the log.txt for missing HTML file when it is there.
84

5+
- check Aurence <op>
96

10-
PRIORITY 2
11-
----------
12-
in the algorithm table, it would be good if the "Al Statement" and "Al Math:" as well as their inputs could be different in the style.css (so a total of 4 styles), so that they can individually be made bold or italics or slightly larger font so as to make them stand out.
137

148
The HTML files where the algorithms are placed should have links to anchors for the different categories; example, at the top of 'Algorithms by Material' instead of links to the individual algorithms (Abrans 1994_47_1 etc) there should be links to the materials, so 'earth', 'mudbrick', 'pise'', 'plaster' etc. The same for the algorithm_type.html and the algorithm_position_in_process.html. The algorithm_bibliography.html would instead be by author_year, so Abrams 1994.
159

@@ -20,7 +14,7 @@ write programming page
2014
write Bernardo bio page
2115

2216

23-
PRIORITY 3
2417
----------
18+
2519
create a CSV data dump from all the input files used (also the ones with errors) with the XML tags as headers. Filename should be "EnCAB_input_xyz.csv" where xyz is the date (year month day format) and time. the seperator should be a tab character (the error trapping should give an error if there is a tab used in the input, and should replace that character with 5 spaces when sending to the CSV file)
2620

0 commit comments

Comments
 (0)