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

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

Adjust to base package.

  • Property svn:executable set to *
File size: 3.3 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
10from waeup.kofa.students.export import (
11    FirstStudentStudyCourseExporter,
12    SecondStudentStudyCourseExporter,
13    FirstStudentStudyLevelExporter,
14    SecondStudentStudyLevelExporter,
15    FirstCourseTicketExporter,
16    SecondCourseTicketExporter,
17    BedTicketExporter,
18    get_students,)
19from waeup.kofa.applicants.export import (
20        ApplicantsContainerExporter)
21from waeup.kofa.hostels.export import (
22        HostelExporter,
23        BedExporter)
24from waeup.kofa.documents.export import (
25        PDFDocumentExporter, HTMLDocumentExporter, RESTDocumentExporter)
26from waeup.kofa.accesscodes.export import (
27        AccessCodeBatchExporter, AccessCodeExporter)
28from waeup.kofa.userscontainer import UserExporter
29from waeup.kofa.configuration import ConfigurationContainerExporter
30
31from waeup.uniben.applicants.export import (
32        CustomApplicantExporter,
33        CustomApplicantPaymentExporter,
34        )
35from waeup.uniben.students.export import (
36        CustomStudentExporter,
37        CustomStudentPaymentExporter,
38        CustomStudentStudyCourseExporter,
39        CustomStudentStudyLevelExporter,
40        CustomCourseTicketExporter,
41        )
42try:
43  from waeup.uniben.configuration import CustomSessionConfigurationExporter as SessionConfigurationExporter
44except:
45  from waeup.kofa.configuration import SessionConfigurationExporter
46
47try:
48  from waeup.uniben.applicants import CustomApplicantRefereeReportExporter as ApplicantRefereeReportExporter
49except:
50  from waeup.kofa.applicants.export import ApplicantRefereeReportExporter
51
52try:
53  from waeup.uniben.applicants import CustomApplicantPaymentExporter as ApplicantPaymentExporter
54except:
55  from kofacustom.nigeria.applicants.export import NigeriaApplicantPaymentExporter as ApplicantPaymentExporter
56
57
58exporter_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
93def 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
Note: See TracBrowser for help on using the repository browser.