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 | from waeup.kofa.students.export import ( |
---|
11 | FirstStudentStudyCourseExporter, |
---|
12 | SecondStudentStudyCourseExporter, |
---|
13 | FirstStudentStudyLevelExporter, |
---|
14 | SecondStudentStudyLevelExporter, |
---|
15 | FirstCourseTicketExporter, |
---|
16 | SecondCourseTicketExporter, |
---|
17 | BedTicketExporter, |
---|
18 | get_students,) |
---|
19 | from waeup.kofa.applicants.export import ( |
---|
20 | ApplicantsContainerExporter) |
---|
21 | from waeup.kofa.hostels.export import ( |
---|
22 | HostelExporter, |
---|
23 | BedExporter) |
---|
24 | from waeup.kofa.documents.export import ( |
---|
25 | PDFDocumentExporter, HTMLDocumentExporter, RESTDocumentExporter) |
---|
26 | from waeup.kofa.accesscodes.export import ( |
---|
27 | AccessCodeBatchExporter, AccessCodeExporter) |
---|
28 | from waeup.kofa.userscontainer import UserExporter |
---|
29 | from waeup.kofa.configuration import ConfigurationContainerExporter |
---|
30 | |
---|
31 | from waeup.uniben.applicants.export import ( |
---|
32 | CustomApplicantExporter, |
---|
33 | CustomApplicantPaymentExporter, |
---|
34 | ) |
---|
35 | from waeup.uniben.students.export import ( |
---|
36 | CustomStudentExporter, |
---|
37 | CustomStudentPaymentExporter, |
---|
38 | CustomStudentStudyCourseExporter, |
---|
39 | CustomStudentStudyLevelExporter, |
---|
40 | CustomCourseTicketExporter, |
---|
41 | ) |
---|
42 | try: |
---|
43 | from waeup.uniben.configuration import CustomSessionConfigurationExporter as SessionConfigurationExporter |
---|
44 | except: |
---|
45 | from waeup.kofa.configuration import SessionConfigurationExporter |
---|
46 | |
---|
47 | try: |
---|
48 | from waeup.uniben.applicants import CustomApplicantRefereeReportExporter as ApplicantRefereeReportExporter |
---|
49 | except: |
---|
50 | from waeup.kofa.applicants.export import ApplicantRefereeReportExporter |
---|
51 | |
---|
52 | try: |
---|
53 | from waeup.uniben.applicants import CustomApplicantPaymentExporter as ApplicantPaymentExporter |
---|
54 | except: |
---|
55 | from kofacustom.nigeria.applicants.export import NigeriaApplicantPaymentExporter as ApplicantPaymentExporter |
---|
56 | |
---|
57 | |
---|
58 | exporter_klasses = [ |
---|
59 | |
---|
60 | HostelExporter, |
---|
61 | BedExporter, |
---|
62 | PDFDocumentExporter, |
---|
63 | HTMLDocumentExporter, |
---|
64 | RESTDocumentExporter, |
---|
65 | AccessCodeBatchExporter, |
---|
66 | AccessCodeExporter, |
---|
67 | SessionConfigurationExporter, |
---|
68 | UserExporter, |
---|
69 | ConfigurationContainerExporter, |
---|
70 | |
---|
71 | ApplicantsContainerExporter, |
---|
72 | CustomApplicantExporter, |
---|
73 | ApplicantPaymentExporter, |
---|
74 | ApplicantRefereeReportExporter, |
---|
75 | |
---|
76 | CustomStudentExporter, |
---|
77 | CustomStudentPaymentExporter, |
---|
78 | CustomStudentStudyCourseExporter, |
---|
79 | CustomStudentStudyLevelExporter, |
---|
80 | CustomCourseTicketExporter, |
---|
81 | BedTicketExporter, |
---|
82 | |
---|
83 | FirstStudentStudyCourseExporter, |
---|
84 | SecondStudentStudyCourseExporter, |
---|
85 | FirstStudentStudyLevelExporter, |
---|
86 | SecondStudentStudyLevelExporter, |
---|
87 | FirstCourseTicketExporter, |
---|
88 | SecondCourseTicketExporter, |
---|
89 | ] |
---|
90 | |
---|
91 | # exporter_klasses = [] |
---|
92 | |
---|
93 | def export_all(root): |
---|
94 | site = root["uniben"] |
---|
95 | setSite(site) |
---|
96 | for klass in exporter_klasses: |
---|
97 | c_name = "export_" + getattr(klass, "grokcore.component.directive.name") |
---|
98 | print(c_name) |
---|
99 | outfile = "csvdata/%s.csv" % c_name |
---|
100 | exporter = klass() |
---|
101 | print("Dump data to %s..." % outfile) |
---|
102 | exporter.export_all(site, outfile) |
---|
103 | #try: |
---|
104 | # exporter.export_all(site, outfile) |
---|
105 | #except: |
---|
106 | # print("CRASHED: " + c_name) |
---|
107 | # if outfile in glob.glob("csvdata/*.csv"): |
---|
108 | # os.remove(outfile) |
---|
109 | |
---|
110 | |
---|