forked from SimpleAccounts/SimpleAccounts-UAE
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsafe_fix_kendo.py
More file actions
86 lines (77 loc) · 5.18 KB
/
safe_fix_kendo.py
File metadata and controls
86 lines (77 loc) · 5.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import os
import re
def safe_fix(filepath):
print(f"Safe fixing {filepath}")
if not os.path.exists(filepath):
print(f"File not found: {filepath}")
return
with open(filepath, 'r') as f:
content = f.read()
# 1. Remove imports from @progress/kendo
content = re.sub(r'import.*@progress/kendo-.*;\n?', '', content)
# 2. Replace PDFExport with div
content = content.replace("<PDFExport", "<div")
content = content.replace("</PDFExport>", "</div>")
# 3. Comment out calls to .save() on the ref, handling one-liners and standard calls
# One-liners: () => pdfExportComponent.save() -> () => { /* pdfExportComponent.save() */ }
content = re.sub(r'(=>\s*)((?:\w+\.)?pdfExportComponent(?:\.current)?\.save\(\))', r'\1{ /* \2 */ }', content)
# Standard calls: pdfExportComponent.save() -> // pdfExportComponent.save()
# Only if not already commented out or wrapped in braces by the previous step
# We use a negative lookbehind for { /* and a negative lookahead for */ }
# But simple // is easier:
content = re.sub(r'(?<!{ /\* )\b((?:\w+\.)?pdfExportComponent(?:\.current)?\.save\(\))(?!\s*\*/ })', r'// \1', content)
with open(filepath, 'w') as f:
f.write(content)
# Files to fix - expanded list
files_to_fix = [
"apps/frontend/src/screens/request_for_quotation/screens/view/screen.js",
"apps/frontend/src/screens/goods_received_note/screens/view/screen.js",
"apps/frontend/src/screens/goods_received_note/screens/view/screen.jsx",
"apps/frontend/src/screens/detailed_general_ledger_report/screen.js",
"apps/frontend/src/screens/creditNotes/screens/view/screen.js",
"apps/frontend/src/screens/inventory/sections/inventory_summary/index.jsx",
"apps/frontend/src/screens/inventory/sections/inventory_summary/sections/invetoryHistorymodal.js",
"apps/frontend/src/screens/purchase_order/screens/view/screen.js",
"apps/frontend/src/screens/purchase_order/screens/view/screen.jsx",
"apps/frontend/src/screens/product/screens/detail/sections/invetoryHistorymodal.jsx",
"apps/frontend/src/screens/payrollemp/screens/view/sections/viewPayslip.js",
"apps/frontend/src/screens/financial_report/sections/expense_details/screen.js",
"apps/frontend/src/screens/financial_report/sections/payables_invoice_details/screen.js",
"apps/frontend/src/screens/financial_report/sections/purchase_by_item/screen.js",
"apps/frontend/src/screens/financial_report/sections/ar_aging_report/screen.jsx",
"apps/frontend/src/screens/financial_report/sections/sales_by_customer/screen.js",
"apps/frontend/src/screens/financial_report/sections/sales_by_product/screen.js",
"apps/frontend/src/screens/financial_report/sections/trail_Balances/screen.js",
"apps/frontend/src/screens/financial_report/sections/payroll_summary/screen.js",
"apps/frontend/src/screens/financial_report/sections/purchase_by_vendor/screen.js",
"apps/frontend/src/screens/financial_report/sections/Fta_Audit_Report/screen.js",
"apps/frontend/src/screens/financial_report/sections/balance_sheet/screen.js",
"apps/frontend/src/screens/financial_report/sections/receivable_invoice_details/screen.js",
"apps/frontend/src/screens/financial_report/sections/horizontal_balance_sheet/screen.js",
"apps/frontend/src/screens/financial_report/sections/expense_by_catogery/screen.js",
"apps/frontend/src/screens/financial_report/sections/corporate_tax/screens/view/screen.js",
"apps/frontend/src/screens/financial_report/sections/debit_note_details/screen.js",
"apps/frontend/src/screens/financial_report/sections/payables_invoice_summary/screen.js",
"apps/frontend/src/screens/financial_report/sections/cashflow/screen.js",
"apps/frontend/src/screens/financial_report/sections/credit_note_details/screen.js",
"apps/frontend/src/screens/financial_report/sections/Excise_Audit_Report/screen.js",
"apps/frontend/src/screens/financial_report/sections/invoice_details/screen.jsx",
"apps/frontend/src/screens/financial_report/sections/receivable_invoice_summary/screen.js",
"apps/frontend/src/screens/financial_report/sections/soa_statementsOfAccounts/screen.jsx",
"apps/frontend/src/screens/financial_report/sections/vat_return/screen.js",
"apps/frontend/src/screens/financial_report/sections/profit_and_loss/screen.js",
"apps/frontend/src/screens/financial_report/sections/customer_account_statement/screen.js",
"apps/frontend/src/screens/quotation/screens/view/screen.js",
"apps/frontend/src/screens/request_for_quotation/screens/view/screen.jsx",
"apps/frontend/src/screens/customer_invoice/screens/view/screen.js",
"apps/frontend/src/screens/creditNotes/screens/view/screen.jsx",
"apps/frontend/src/screens/debitNotes/screens/view/screen.js",
"apps/frontend/src/screens/quotation/screens/view/screen.jsx",
"apps/frontend/src/screens/expense/screens/view/screen.js",
"apps/frontend/src/screens/supplier_invoice/screens/view/screen.js",
"apps/frontend/src/screens/supplier_invoice/screens/view/screen.jsx",
"apps/frontend/src/screens/expense/screens/view/screen.jsx",
"apps/frontend/src/screens/debitNotes/screens/view/screen.jsx"
]
for f in files_to_fix:
safe_fix(f)