Skip to content

Commit 3f8565e

Browse files
Update
1 parent 1d0da1a commit 3f8565e

3 files changed

Lines changed: 4 additions & 12836 deletions

File tree

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ Others?
2525

2626
## TODO
2727

28-
- Some places don't have chapter numbers.
29-
- Some sections are missing or have misplaced starting points (fix in update_OET_sections.py).
3028
- Need to fix issue with standard single quotes in the HTML.
3129

3230

@@ -65,7 +63,7 @@ Navigate to ``/assets/bibles`` and run the file with ``python update_OET_json.py
6563

6664
## Updating the OET sections
6765

68-
After converting the OET ESFM to json, navigate to the folder with ``cd assets/bibles`` and run ``python update_OET_sections.py``. This will generate two dart files mapping the OET sections for use in Bibleside. Move back to the root folder with ``cd ../..`` and run ``dart format ./lib -l 120`` to format the file.
66+
After converting the OET ESFM to json, navigate to the folder with ``cd assets/bibles`` and run ``python update_OET_sections.py``. This will generate a dart file mapping the OET sections for use in Bibleside. Move back to the root folder with ``cd ../..`` and run ``dart format ./lib -l 120`` to format the file.
6967

7068

7169
## License

assets/bibles/update_OET_sections.py

Lines changed: 3 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Script to automatically generate dart files mapping the OET-RV sections from the OET json files
1+
# Script to automatically generate a dart file mapping the OET-RV sections from the OET json files
22
# Requirements: Python 3 and the standard library
33

44
# The resulting oet_rv_section_headings.dart file is formatted like so:
@@ -14,32 +14,12 @@
1414
# ],
1515
# };
1616

17-
# The resulting oet_rv_section_start_end.dart file is formatted like so:
18-
#
19-
# Map<String, List<Map<String, dynamic>>> sectionStartEndMappingForOET = {
20-
# 'JHN': {
21-
# '1:1': {
22-
# 'section': 'The coming of the true light',
23-
# 'start' : {
24-
# 'chapter': 1,
25-
# 'verse': 1,
26-
# },
27-
# 'end': {
28-
# 'chapter': 1,
29-
# 'verse': 2,
30-
# }
31-
# }
32-
# }
33-
# }
34-
35-
3617
import os
3718
import re
3819
import json
3920

4021
RV_local_path = "./OET-RV/"
4122
oet_rv_section_headings_file = "../../lib/common/oet_rv_section_headings.dart"
42-
oet_rv_section_start_end_file = "../../lib/common/oet_rv_section_start_end.dart"
4323

4424
section_headings_dart_file_template = """
4525
// GENERATED FILE. DO NOT EDIT DIRECTLY
@@ -48,13 +28,6 @@
4828
Map<String, List<List<String>>> sectionHeadingsMappingForOET = {};
4929
"""
5030

51-
section_start_end_dart_file_template = """
52-
// GENERATED FILE. DO NOT EDIT DIRECTLY
53-
// This file can be regenerated by running the update_OET_sections.py file
54-
55-
Map<String, List<Map<String, dynamic>>> sectionStartEndMappingForOET = {};
56-
"""
57-
5831

5932
def generate_headings_mappings_file():
6033
file_list = os.listdir(RV_local_path)
@@ -119,53 +92,6 @@ def generate_headings_mappings_file():
11992
with open(oet_rv_section_headings_file, "w") as file:
12093
file.write(contents)
12194

122-
return sections_mapping
123-
124-
125-
def generate_start_end_mappings_file(sections_mapping):
126-
start_end_sections = {}
127-
for book in sections_mapping:
128-
book_sections = sections_mapping[book]
129-
list_length = len(book_sections)
130-
131-
inner = []
132-
for index in range(0, list_length):
133-
134-
# Section start
135-
start = book_sections[index][0]
136-
start_section_ref = section_ref_from_section(start)
137-
start_chapter_ref, start_verse_ref = split_section_ref(start_section_ref)
138-
139-
# Section end
140-
if index+1 < list_length:
141-
# A section can be spread over two chapters
142-
next_section = book_sections[index+1][0]
143-
end = next_section
144-
else:
145-
end = start
146-
147-
end_section_ref = section_ref_from_section(end)
148-
end_chapter_ref, end_verse_ref = split_section_ref(end_section_ref)
149-
150-
inner.append({
151-
'section': section_heading_from_section(start),
152-
'start': {
153-
'chapter': int(start_chapter_ref),
154-
'verse': int(start_verse_ref),
155-
},
156-
'end': {
157-
'chapter': int(end_chapter_ref),
158-
'verse': int(end_verse_ref),
159-
}
160-
})
161-
162-
start_end_sections[book] = inner
163-
164-
contents = section_start_end_dart_file_template.format(str(start_end_sections))
165-
166-
with open(oet_rv_section_start_end_file, "w") as file:
167-
file.write(contents)
168-
16995

17096
def read_json_file(path):
17197
with open(path, "r") as json_file:
@@ -196,8 +122,7 @@ def split_section_ref(ref):
196122

197123

198124
if __name__ == "__main__":
199-
print("Generating files...")
200-
sections_mapping = generate_headings_mappings_file()
201-
generate_start_end_mappings_file(sections_mapping)
125+
print("Generating file...")
126+
generate_headings_mappings_file()
202127
print("Generating complete.")
203128

0 commit comments

Comments
 (0)