Skip to content

Commit 5a56bdd

Browse files
committed
Updated files
1 parent 5f48e20 commit 5a56bdd

File tree

5 files changed

+51
-9
lines changed

5 files changed

+51
-9
lines changed

core/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from .report import *
1+
from .pdf import *
2+
from .xlsx import *
23
from .structure import *
34
from .process import *
45
from .syntax import *

core/report.py renamed to core/pdf.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from reportlab.lib.units import inch
99
from pathlib import Path
1010

11-
class Report:
11+
class PDF:
1212

1313
def __init__(self, nested_list: list):
1414
"""Report class handles all PDF generation methods and fits the translated list (nested_list)
@@ -56,8 +56,7 @@ def capture_student_name(self) -> None:
5656
name += f'{input} '
5757

5858
elif student_check == 1 and str(item).startswith(tuple(['Nickname', 'Place of Birth', 'Date of Birth'])):
59-
# name += str(idx)
60-
self.student_name.append(name)
59+
self.student_name.append(name[:-1])
6160
name = ''
6261
student_check = 0
6362

@@ -70,7 +69,7 @@ def capture_app_type(self) -> None:
7069
for item in app:
7170
if str(item).startswith('App ID'):
7271
app_type = str(item).split('| ')
73-
self.app_type.append(app_type[-1])
72+
self.app_type.append(app_type[-1][:-1])
7473

7574
def fit_student_data(self, app_data: list) -> list:
7675
"""Method for fitting the nested lists data of list and strings into a coherent list of strings.

core/structure.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def error_handler(self, markdown: str, text: str) -> None:
4848
"""
4949

5050
if text == 'Other':
51-
r = core.Report([self.output])
51+
r = core.PDF([self.output])
5252
r.capture_student_name()
5353
raise ReferenceError(f'{markdown} translation missing in structure: {self.target}, {self.idx}, {r.student_name}')
5454

core/xlsx.py

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import os
2+
import tkinter as tk
3+
from tkinter.filedialog import askdirectory
4+
from pathlib import Path
5+
from pdfrw import PdfReader
6+
7+
class XLSX:
8+
9+
def __init__(self):
10+
self.temp = 1
11+
12+
def find_pdfs_in_downloads(self):
13+
_default = str(os.path.join(Path.home(), "Downloads"))
14+
15+
tk.Tk().withdraw()
16+
folder = askdirectory(initialdir = _default, title='Select a folder with SPE files')
17+
18+
pdf_files = []
19+
20+
for root, dirs, files in os.walk(folder):
21+
sep = str(root).split('\\')
22+
if str(sep[-1]).startswith('International'):
23+
for file in files:
24+
pdf_files.append(os.path.abspath(os.path.join(root, file)))
25+
26+
return pdf_files
27+
28+
def read_pdf_content(self, pdf_files):
29+
30+
content_list = []
31+
32+
for pdf in pdf_files:
33+
with open(pdf, 'rb') as file:
34+
for line in file:
35+
print(line)
36+
37+
38+
39+
if __name__ == '__main__':
40+
x = XLSX()
41+
pdf_files = x.find_pdfs_in_downloads()
42+
x.read_pdf_content(pdf_files)

main.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def run(file_path: str, filename: str) -> None:
7272
translated_spe.append(s.translate())
7373
markdown_spe.append(s.markdown)
7474

75-
r = core.Report(translated_spe)
75+
r = core.PDF(translated_spe)
7676
r.capture_student_name()
7777
r.capture_app_type()
7878

@@ -131,8 +131,8 @@ def merge_xlsx()-> None:
131131

132132
if __name__ == "__main__":
133133

134-
# find_spe_files() # Multiple .spe files
135-
find_spe_file() # Singluar .spe file
134+
find_spe_files() # Multiple .spe files
135+
# find_spe_file() # Singluar .spe file
136136
print('Done')
137137

138138
# merge_xlsx()

0 commit comments

Comments
 (0)