Megatest

Diff
Login

Differences From Artifact [5e94ada62d]:

To Artifact [2933c5fd59]:


114
115
116
117
118
119
120




121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136



137
138
139
140
141
142
143
144
145
146
								 (string? b))
							    (string< a b))))))))))
    (with-output-to-file (conc targdir "/xml/" sheet-name ".xml")
      (lambda ()
	(print (sxml-serializer#serialize-sxml remaining))))
    sheet-name))






(define (extract-txtdb dat targdir)
  (let* ((wrkbk   (find-section   dat   'http://www.gnumeric.org/v10.dtd:Workbook))
	 (wrk-rem (remove-section dat   'http://www.gnumeric.org/v10.dtd:Workbook))
	 (sheets  (find-section   wrkbk 'http://www.gnumeric.org/v10.dtd:Sheets))
	 (sht-rem (remove-section wrkbk 'http://www.gnumeric.org/v10.dtd:Sheets)))
    (create-directory (conc targdir "/xml") #t)
    (with-output-to-file (conc targdir "/xml/workbook.xml")
      (lambda ()
	(print (sxml-serializer#serialize-sxml wrk-rem))))
    (with-output-to-file (conc targdir "/xml/sheets.xml")
      (lambda ()
	(print (sxml-serializer#serialize-sxml sht-rem))))
    (let ((sheet-names (map (lambda (sheet)
			      (sheet->txtdb sheet targdir))
			    sheets)))



      (with-output-to-file (conc targdir "/sheet-names.cfg")
	(lambda ()
	  (map print sheet-names))))))

(define (read-gnumeric-file fname)
  (if (not (string-match (regexp ".*.gnumeric$") fname))
      (begin
	(print "ERROR: Attempt to import gnumeric file with extention other than .gnumeric")
	(exit))
      (let ((tmpf (create-temporary-file (pathname-strip-directory fname))))







>
>
>
>


|
|
|
|
<
<
<
<
<
<
<
|
|
|
>
>
>
|
|
|







114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130







131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
								 (string? b))
							    (string< a b))))))))))
    (with-output-to-file (conc targdir "/xml/" sheet-name ".xml")
      (lambda ()
	(print (sxml-serializer#serialize-sxml remaining))))
    sheet-name))

(define (sxml->file dat fname)
  (with-output-to-file fname
    (lambda ()
      (print (sxml-serializer#serialize-sxml dat)))))

(define (extract-txtdb dat targdir)
  (let* ((wrkbk       (find-section   dat   'http://www.gnumeric.org/v10.dtd:Workbook))
	 (wrk-rem     (remove-section dat   'http://www.gnumeric.org/v10.dtd:Workbook))
	 (sheets      (find-section   wrkbk 'http://www.gnumeric.org/v10.dtd:Sheets))
	 (sht-rem     (remove-section wrkbk 'http://www.gnumeric.org/v10.dtd:Sheets))







	 (sheet-names (map (lambda (sheet)
			     (sheet->txtdb sheet targdir))
			   sheets)))
    (create-directory (conc targdir "/xml") #t)
    (sxml->file wrk-rem (conc targdir "/xml/workbook.xml"))
    (sxml->file sht-rem (conc targdir "/xml/sheets.xml"))
    (with-output-to-file (conc targdir "/sheet-names.cfg")
      (lambda ()
	(map print sheet-names)))))

(define (read-gnumeric-file fname)
  (if (not (string-match (regexp ".*.gnumeric$") fname))
      (begin
	(print "ERROR: Attempt to import gnumeric file with extention other than .gnumeric")
	(exit))
      (let ((tmpf (create-temporary-file (pathname-strip-directory fname))))
157
158
159
160
161
162
163
164



165



166
167

168
169
170
171



172
173
174
175
176
177
178
	(tmpf     (create-temporary-file (pathname-strip-directory fname))))
    (with-output-to-file tmpf
      (lambda ()
	(print (sxml-serializer#serialize-sxml sxml-dat))))
    (system (conc "gzip " tmpf))
    (file-copy tmpf fname)
    (delete-file tmpf)))
    



(define (txtdb->sxml dbdir)



  ;; Read sheets list
  ;; Read sheets

  ;; Read xml for each sheet
  ;; Read meta data xml
  ;; Construct the final sxml and return it
  #f)




#|  
 (define x (txtdb:read-gnumeric-xml "testdata-stripped.xml"))



;; Write out sxml







|
>
>
>

>
>
>
|
|
>
|
<
<
|
>
>
>







157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175


176
177
178
179
180
181
182
183
184
185
186
	(tmpf     (create-temporary-file (pathname-strip-directory fname))))
    (with-output-to-file tmpf
      (lambda ()
	(print (sxml-serializer#serialize-sxml sxml-dat))))
    (system (conc "gzip " tmpf))
    (file-copy tmpf fname)
    (delete-file tmpf)))

(define (read-dat fname)
  (read-file fname read-line)) ;; Placeholder!
    
(define (txtdb->sxml dbdir)
  (let* ((sht-names (read-file (conc dbdir "/sheet-names.cfg")  read-line))
	 (wrk-rem   (read-file (conc dbdir "/xml/workbook.xml") read-line))
	 (sht-rem   (read-file (conc dbdir "/xml/sheets.xml")   read-line))
	 (sheets    (fold (lambda (sheetname res)
			    (let ((sheetdat (read-dat (conc dbdir "/" sheetname ".dat")))
				  (sht-meta (txtdb:read-gnumeric-xml (conc dbdir "/xml/" sheetname ".xml"))))
			      (cons (cons sht-meta sheetdat)


				    res)))
			  '()
			  sht-names)))
    (append wrk-rem (list sheets))))

#|  
 (define x (txtdb:read-gnumeric-xml "testdata-stripped.xml"))



;; Write out sxml