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

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

Add forgotten exporters.

  • Property svn:executable set to *
File size: 3.8 KB
RevLine 
[17780]1#!/usr/bin/env python2
2#
3# $ ./bin/kofactl debug
[17786]4# >>> import sys; sys.path.append("."); import dumper; dumper.export_all(root)
[17780]5#
6
7import glob
8import os
9from zope.component.hooks import setSite
[17795]10
11from waeup.kofa.university.export import(
12        FacultyExporter,
13        DepartmentExporter,
14        CourseExporter,
15        CertificateExporter,
16        CertificateCourseExporter,
17    )
[17780]18from waeup.kofa.students.export import (
[17795]19        FirstStudentStudyCourseExporter,
20        SecondStudentStudyCourseExporter,
21        FirstStudentStudyLevelExporter,
22        SecondStudentStudyLevelExporter,
23        FirstCourseTicketExporter,
24        SecondCourseTicketExporter,
25        BedTicketExporter,
26        get_students,)
[17780]27from waeup.kofa.applicants.export import (
[17788]28        ApplicantsContainerExporter)
[17780]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
[17786]37from waeup.kofa.configuration import ConfigurationContainerExporter
[17780]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        )
[17788]50try:
51  from waeup.uniben.configuration import CustomSessionConfigurationExporter as SessionConfigurationExporter
52except:
53  from waeup.kofa.configuration import SessionConfigurationExporter
[17780]54
[17788]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
[17780]66exporter_klasses = [
67
68    HostelExporter,
69    BedExporter,
70    PDFDocumentExporter,
71    HTMLDocumentExporter,
72    RESTDocumentExporter,
73    AccessCodeBatchExporter,
74    AccessCodeExporter,
[17788]75    SessionConfigurationExporter,
[17780]76    UserExporter,
[17786]77    ConfigurationContainerExporter,
[17780]78
[17795]79    FacultyExporter,
80    DepartmentExporter,
81    CourseExporter,
82    CertificateExporter,
83    CertificateCourseExporter,
84
[17780]85    ApplicantsContainerExporter,
86    CustomApplicantExporter,
[17788]87    ApplicantPaymentExporter,
[17780]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
[17795]105exporter_klasses = [
106    FacultyExporter,
107    DepartmentExporter,
108    CourseExporter,
109    CertificateExporter,
110    CertificateCourseExporter,
111    ]
[17788]112
[17780]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.