source: main/waeup.uniben/trunk/dumper.py @ 17905

Last change on this file since 17905 was 17795, checked in by Henrik Bettermann, 6 months ago

Add forgotten exporters.

  • Property svn:executable set to *
File size: 3.8 KB
Line 
1#!/usr/bin/env python2
2#
3# $ ./bin/kofactl debug
4# >>> import sys; sys.path.append("."); import dumper; dumper.export_all(root)
5#
6
7import glob
8import os
9from zope.component.hooks import setSite
10
11from waeup.kofa.university.export import(
12        FacultyExporter,
13        DepartmentExporter,
14        CourseExporter,
15        CertificateExporter,
16        CertificateCourseExporter,
17    )
18from waeup.kofa.students.export import (
19        FirstStudentStudyCourseExporter,
20        SecondStudentStudyCourseExporter,
21        FirstStudentStudyLevelExporter,
22        SecondStudentStudyLevelExporter,
23        FirstCourseTicketExporter,
24        SecondCourseTicketExporter,
25        BedTicketExporter,
26        get_students,)
27from waeup.kofa.applicants.export import (
28        ApplicantsContainerExporter)
29from waeup.kofa.hostels.export import (
30        HostelExporter,
31        BedExporter)
32from waeup.kofa.documents.export import (
33        PDFDocumentExporter, HTMLDocumentExporter, RESTDocumentExporter)
34from waeup.kofa.accesscodes.export import (
35        AccessCodeBatchExporter, AccessCodeExporter)
36from waeup.kofa.userscontainer import UserExporter
37from waeup.kofa.configuration import ConfigurationContainerExporter
38
39from waeup.uniben.applicants.export import (
40        CustomApplicantExporter,
41        CustomApplicantPaymentExporter,
42        )
43from waeup.uniben.students.export import (
44        CustomStudentExporter,
45        CustomStudentPaymentExporter,
46        CustomStudentStudyCourseExporter,
47        CustomStudentStudyLevelExporter,
48        CustomCourseTicketExporter,
49        )
50try:
51  from waeup.uniben.configuration import CustomSessionConfigurationExporter as SessionConfigurationExporter
52except:
53  from waeup.kofa.configuration import SessionConfigurationExporter
54
55try:
56  from waeup.uniben.applicants import CustomApplicantRefereeReportExporter as ApplicantRefereeReportExporter
57except:
58  from waeup.kofa.applicants.export import ApplicantRefereeReportExporter
59
60try:
61  from waeup.uniben.applicants import CustomApplicantPaymentExporter as ApplicantPaymentExporter
62except:
63  from kofacustom.nigeria.applicants.export import NigeriaApplicantPaymentExporter as ApplicantPaymentExporter
64
65
66exporter_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
105exporter_klasses = [
106    FacultyExporter,
107    DepartmentExporter,
108    CourseExporter,
109    CertificateExporter,
110    CertificateCourseExporter,
111    ]
112
113def 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
Note: See TracBrowser for help on using the repository browser.