Skip to content

Commit

Permalink
Updated files
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-prog committed Jul 5, 2024
1 parent 5f48e20 commit 5a56bdd
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 9 deletions.
3 changes: 2 additions & 1 deletion core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .report import *
from .pdf import *
from .xlsx import *
from .structure import *
from .process import *
from .syntax import *
Expand Down
7 changes: 3 additions & 4 deletions core/report.py → core/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from reportlab.lib.units import inch
from pathlib import Path

class Report:
class PDF:

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

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

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

def fit_student_data(self, app_data: list) -> list:
"""Method for fitting the nested lists data of list and strings into a coherent list of strings.
Expand Down
2 changes: 1 addition & 1 deletion core/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def error_handler(self, markdown: str, text: str) -> None:
"""

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

Expand Down
42 changes: 42 additions & 0 deletions core/xlsx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import os
import tkinter as tk
from tkinter.filedialog import askdirectory
from pathlib import Path
from pdfrw import PdfReader

class XLSX:

def __init__(self):
self.temp = 1

def find_pdfs_in_downloads(self):
_default = str(os.path.join(Path.home(), "Downloads"))

tk.Tk().withdraw()
folder = askdirectory(initialdir = _default, title='Select a folder with SPE files')

pdf_files = []

for root, dirs, files in os.walk(folder):
sep = str(root).split('\\')
if str(sep[-1]).startswith('International'):
for file in files:
pdf_files.append(os.path.abspath(os.path.join(root, file)))

return pdf_files

def read_pdf_content(self, pdf_files):

content_list = []

for pdf in pdf_files:
with open(pdf, 'rb') as file:
for line in file:
print(line)



if __name__ == '__main__':
x = XLSX()
pdf_files = x.find_pdfs_in_downloads()
x.read_pdf_content(pdf_files)
6 changes: 3 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def run(file_path: str, filename: str) -> None:
translated_spe.append(s.translate())
markdown_spe.append(s.markdown)

r = core.Report(translated_spe)
r = core.PDF(translated_spe)
r.capture_student_name()
r.capture_app_type()

Expand Down Expand Up @@ -131,8 +131,8 @@ def merge_xlsx()-> None:

if __name__ == "__main__":

# find_spe_files() # Multiple .spe files
find_spe_file() # Singluar .spe file
find_spe_files() # Multiple .spe files
# find_spe_file() # Singluar .spe file
print('Done')

# merge_xlsx()
Expand Down

0 comments on commit 5a56bdd

Please sign in to comment.