1 | #!/usr/bin/env python2 |
---|
2 | # |
---|
3 | # $ ./bin/kofactl debug |
---|
4 | # >>> import sys; sys.path.append("."); import dumper; dumper.export_all(root) |
---|
5 | # |
---|
6 | |
---|
7 | import glob |
---|
8 | import os |
---|
9 | from zope.component.hooks import setSite |
---|
10 | |
---|
11 | from waeup.kofa.university.export import( |
---|
12 | FacultyExporter, |
---|
13 | DepartmentExporter, |
---|
14 | CourseExporter, |
---|
15 | CertificateExporter, |
---|
16 | CertificateCourseExporter, |
---|
17 | ) |
---|
18 | from waeup.kofa.students.export import ( |
---|
19 | FirstStudentStudyCourseExporter, |
---|
20 | SecondStudentStudyCourseExporter, |
---|
21 | FirstStudentStudyLevelExporter, |
---|
22 | SecondStudentStudyLevelExporter, |
---|
23 | FirstCourseTicketExporter, |
---|
24 | SecondCourseTicketExporter, |
---|
25 | BedTicketExporter, |
---|
26 | get_students,) |
---|
27 | from waeup.kofa.applicants.export import ( |
---|
28 | ApplicantsContainerExporter) |
---|
29 | from waeup.kofa.hostels.export import ( |
---|
30 | HostelExporter, |
---|
31 | BedExporter) |
---|
32 | from waeup.kofa.documents.export import ( |
---|
33 | PDFDocumentExporter, HTMLDocumentExporter, RESTDocumentExporter) |
---|
34 | from waeup.kofa.accesscodes.export import ( |
---|
35 | AccessCodeBatchExporter, AccessCodeExporter) |
---|
36 | from waeup.kofa.userscontainer import UserExporter |
---|
37 | from waeup.kofa.configuration import ConfigurationContainerExporter |
---|
38 | |
---|
39 | from waeup.uniben.applicants.export import ( |
---|
40 | CustomApplicantExporter, |
---|
41 | CustomApplicantPaymentExporter, |
---|
42 | ) |
---|
43 | from waeup.uniben.students.export import ( |
---|
44 | CustomStudentExporter, |
---|
45 | CustomStudentPaymentExporter, |
---|
46 | CustomStudentStudyCourseExporter, |
---|
47 | CustomStudentStudyLevelExporter, |
---|
48 | CustomCourseTicketExporter, |
---|
49 | ) |
---|
50 | try: |
---|
51 | from waeup.uniben.configuration import CustomSessionConfigurationExporter as SessionConfigurationExporter |
---|
52 | except: |
---|
53 | from waeup.kofa.configuration import SessionConfigurationExporter |
---|
54 | |
---|
55 | try: |
---|
56 | from waeup.uniben.applicants import CustomApplicantRefereeReportExporter as ApplicantRefereeReportExporter |
---|
57 | except: |
---|
58 | from waeup.kofa.applicants.export import ApplicantRefereeReportExporter |
---|
59 | |
---|
60 | try: |
---|
61 | from waeup.uniben.applicants import CustomApplicantPaymentExporter as ApplicantPaymentExporter |
---|
62 | except: |
---|
63 | from kofacustom.nigeria.applicants.export import NigeriaApplicantPaymentExporter as ApplicantPaymentExporter |
---|
64 | |
---|
65 | |
---|
66 | exporter_klasses = [ |
---|
67 | |
---|
68 | HostelExporter, |
---|
69 | BedExporter, |
---|
70 | PDFDocumentExporter, |
---|
71 | HTMLDocumentExporter, |
---|
72 | RESTDocumentExporter, |
---|
73 | AccessCodeBatchExporter, |
---|
74 | AccessCodeExporter, |
---|
75 | SessionConfigurationExporter, |
---|
76 | UserExporter, |
---|
77 | ConfigurationContainerExporter, |
---|
78 | |
---|
79 | FacultyExporter, |
---|
80 | DepartmentExporter, |
---|
81 | CourseExporter, |
---|
82 | CertificateExporter, |
---|
83 | CertificateCourseExporter, |
---|
84 | |
---|
85 | ApplicantsContainerExporter, |
---|
86 | CustomApplicantExporter, |
---|
87 | ApplicantPaymentExporter, |
---|
88 | ApplicantRefereeReportExporter, |
---|
89 | |
---|
90 | CustomStudentExporter, |
---|
91 | CustomStudentPaymentExporter, |
---|
92 | CustomStudentStudyCourseExporter, |
---|
93 | CustomStudentStudyLevelExporter, |
---|
94 | CustomCourseTicketExporter, |
---|
95 | BedTicketExporter, |
---|
96 | |
---|
97 | FirstStudentStudyCourseExporter, |
---|
98 | SecondStudentStudyCourseExporter, |
---|
99 | FirstStudentStudyLevelExporter, |
---|
100 | SecondStudentStudyLevelExporter, |
---|
101 | FirstCourseTicketExporter, |
---|
102 | SecondCourseTicketExporter, |
---|
103 | ] |
---|
104 | |
---|
105 | exporter_klasses = [ |
---|
106 | FacultyExporter, |
---|
107 | DepartmentExporter, |
---|
108 | CourseExporter, |
---|
109 | CertificateExporter, |
---|
110 | CertificateCourseExporter, |
---|
111 | ] |
---|
112 | |
---|
113 | def export_all(root): |
---|
114 | site = root["uniben"] |
---|
115 | setSite(site) |
---|
116 | for klass in exporter_klasses: |
---|
117 | c_name = "export_" + getattr(klass, "grokcore.component.directive.name") |
---|
118 | print(c_name) |
---|
119 | outfile = "csvdata/%s.csv" % c_name |
---|
120 | exporter = klass() |
---|
121 | print("Dump data to %s..." % outfile) |
---|
122 | exporter.export_all(site, outfile) |
---|
123 | #try: |
---|
124 | # exporter.export_all(site, outfile) |
---|
125 | #except: |
---|
126 | # print("CRASHED: " + c_name) |
---|
127 | # if outfile in glob.glob("csvdata/*.csv"): |
---|
128 | # os.remove(outfile) |
---|
129 | |
---|
130 | |
---|