Megatest

Check-in [cf4ae67410]
Login
Overview
Comment:Added lookup to txtdb
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA1: cf4ae674104f2110d070cdd88ba860696059160d
User & Date: matt on 2013-07-14 23:28:15
Other Links: branch diff | manifest | tags
Context
2013-07-14
23:56
Renamed txtdb to refdb. Added to Makefile install target. Added ls check-in: 184bfa2327 user: matt tags: dev
23:28
Added lookup to txtdb check-in: cf4ae67410 user: matt tags: dev
21:54
Added a test for the txtdb editor check-in: 40cbab9b8b user: matt tags: dev
Changes

Modified txtdb/nada3/RunsToDo.dat from [2a156fc02f] to [fd5300a42f].

1
2

3
[a/b/c]
ww12a all


<
|
>


1
2
3

[ww12a]
b/c/d yes

Modified txtdb/nada3/sheet-names.cfg from [15a7137d49] to [380375514f].

1
2
3

RunsToDo
Second-sheet
First_Sheet

|

|
>
1
2
3
4
First_Sheet
Second-sheet
RunsToDo
RunsToLock

Modified txtdb/nada3/sxml/RunsToDo.sxml from [3e30754db8] to [53204fefd0].

83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
    (http://www.gnumeric.org/v10.dtd:ColInfo (@ (Unit "64.01") (No "0")))
    (http://www.gnumeric.org/v10.dtd:ColInfo (@ (Unit "48") (No "1"))))
  (http://www.gnumeric.org/v10.dtd:Rows
    (@ (DefaultSizePts "12.1"))
    (http://www.gnumeric.org/v10.dtd:RowInfo
      (@ (Unit "13.5") (No "0") (Count "2"))))
  (http://www.gnumeric.org/v10.dtd:Selections
    (@ (CursorRow "0") (CursorCol "0"))
    (http://www.gnumeric.org/v10.dtd:Selection
      (@ (startRow "0") (startCol "0") (endRow "0") (endCol "0"))))
  (http://www.gnumeric.org/v10.dtd:SheetLayout (@ (TopLeft "A1")))
  (http://www.gnumeric.org/v10.dtd:Solver
    (@ (ProgramR "0")
       (ProblemType "0")
       (NonNeg "1")
       (ModelType "0")
       (MaxTime "60")







|

|







83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
    (http://www.gnumeric.org/v10.dtd:ColInfo (@ (Unit "64.01") (No "0")))
    (http://www.gnumeric.org/v10.dtd:ColInfo (@ (Unit "48") (No "1"))))
  (http://www.gnumeric.org/v10.dtd:Rows
    (@ (DefaultSizePts "12.1"))
    (http://www.gnumeric.org/v10.dtd:RowInfo
      (@ (Unit "13.5") (No "0") (Count "2"))))
  (http://www.gnumeric.org/v10.dtd:Selections
    (@ (CursorRow "2") (CursorCol "1"))
    (http://www.gnumeric.org/v10.dtd:Selection
      (@ (startRow "2") (startCol "1") (endRow "2") (endCol "1"))))
  (http://www.gnumeric.org/v10.dtd:SheetLayout (@ (TopLeft "A1")))
  (http://www.gnumeric.org/v10.dtd:Solver
    (@ (ProgramR "0")
       (ProblemType "0")
       (NonNeg "1")
       (ModelType "0")
       (MaxTime "60")

Modified txtdb/nada3/sxml/Second-sheet.sxml from [3b0609e103] to [74cb91bdb6].

300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
    (http://www.gnumeric.org/v10.dtd:ColInfo
      (@ (Unit "48") (No "1") (Count "3"))))
  (http://www.gnumeric.org/v10.dtd:Rows
    (@ (DefaultSizePts "12.1"))
    (http://www.gnumeric.org/v10.dtd:RowInfo
      (@ (Unit "13.5") (No "0") (Count "20"))))
  (http://www.gnumeric.org/v10.dtd:Selections
    (@ (CursorRow "23") (CursorCol "8"))
    (http://www.gnumeric.org/v10.dtd:Selection
      (@ (startRow "23") (startCol "8") (endRow "23") (endCol "8"))))
  (http://www.gnumeric.org/v10.dtd:SheetLayout (@ (TopLeft "A1")))
  (http://www.gnumeric.org/v10.dtd:Solver
    (@ (ProgramR "0")
       (ProblemType "0")
       (NonNeg "1")
       (ModelType "0")
       (MaxTime "60")







|

|







300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
    (http://www.gnumeric.org/v10.dtd:ColInfo
      (@ (Unit "48") (No "1") (Count "3"))))
  (http://www.gnumeric.org/v10.dtd:Rows
    (@ (DefaultSizePts "12.1"))
    (http://www.gnumeric.org/v10.dtd:RowInfo
      (@ (Unit "13.5") (No "0") (Count "20"))))
  (http://www.gnumeric.org/v10.dtd:Selections
    (@ (CursorRow "0") (CursorCol "0"))
    (http://www.gnumeric.org/v10.dtd:Selection
      (@ (startRow "0") (startCol "0") (endRow "0") (endCol "0"))))
  (http://www.gnumeric.org/v10.dtd:SheetLayout (@ (TopLeft "A1")))
  (http://www.gnumeric.org/v10.dtd:Solver
    (@ (ProgramR "0")
       (ProblemType "0")
       (NonNeg "1")
       (ModelType "0")
       (MaxTime "60")

Modified txtdb/nada3/sxml/sheets.sxml from [ce29ae29e5] to [d0488b9272].

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53




54
55
   (http://www.gnumeric.org/v10.dtd:Attribute
     (http://www.gnumeric.org/v10.dtd:type "4")
     (http://www.gnumeric.org/v10.dtd:name "WorkbookView::is_protected")
     (http://www.gnumeric.org/v10.dtd:value "FALSE")))
 (urn:oasis:names:tc:opendocument:xmlns:office:1.0:document-meta
   (@ (urn:oasis:names:tc:opendocument:xmlns:office:1.0:version "1.2"))
   (urn:oasis:names:tc:opendocument:xmlns:office:1.0:meta
     (http://purl.org/dc/elements/1.1/:date "2013-07-15T03:52:43Z")
     (urn:oasis:names:tc:opendocument:xmlns:meta:1.0:creation-date
       "2013-07-15T03:51:51Z")))
 (http://www.gnumeric.org/v10.dtd:Calculation
   (@ (MaxIterations "100")
      (ManualRecalc "0")
      (IterationTolerance "0.001")
      (FloatRadix "2")
      (FloatDigits "53")
      (EnableIteration "1")))
 (http://www.gnumeric.org/v10.dtd:SheetNameIndex
   (http://www.gnumeric.org/v10.dtd:SheetName
     (@ (http://www.gnumeric.org/v10.dtd:Rows "65536")
        (http://www.gnumeric.org/v10.dtd:Cols "256"))
     "First_Sheet")
   (http://www.gnumeric.org/v10.dtd:SheetName
     (@ (http://www.gnumeric.org/v10.dtd:Rows "65536")
        (http://www.gnumeric.org/v10.dtd:Cols "256"))
     "Second-sheet")
   (http://www.gnumeric.org/v10.dtd:SheetName
     (@ (http://www.gnumeric.org/v10.dtd:Rows "65536")
        (http://www.gnumeric.org/v10.dtd:Cols "256"))
     "RunsToDo"))




 (http://www.gnumeric.org/v10.dtd:Geometry (@ (Width "1440") (Height "647")))
 (http://www.gnumeric.org/v10.dtd:UIData (@ (SelectedTab "1"))))







|

|



















|
>
>
>
>

|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
   (http://www.gnumeric.org/v10.dtd:Attribute
     (http://www.gnumeric.org/v10.dtd:type "4")
     (http://www.gnumeric.org/v10.dtd:name "WorkbookView::is_protected")
     (http://www.gnumeric.org/v10.dtd:value "FALSE")))
 (urn:oasis:names:tc:opendocument:xmlns:office:1.0:document-meta
   (@ (urn:oasis:names:tc:opendocument:xmlns:office:1.0:version "1.2"))
   (urn:oasis:names:tc:opendocument:xmlns:office:1.0:meta
     (http://purl.org/dc/elements/1.1/:date "2013-07-15T04:32:47Z")
     (urn:oasis:names:tc:opendocument:xmlns:meta:1.0:creation-date
       "2013-07-15T04:32:37Z")))
 (http://www.gnumeric.org/v10.dtd:Calculation
   (@ (MaxIterations "100")
      (ManualRecalc "0")
      (IterationTolerance "0.001")
      (FloatRadix "2")
      (FloatDigits "53")
      (EnableIteration "1")))
 (http://www.gnumeric.org/v10.dtd:SheetNameIndex
   (http://www.gnumeric.org/v10.dtd:SheetName
     (@ (http://www.gnumeric.org/v10.dtd:Rows "65536")
        (http://www.gnumeric.org/v10.dtd:Cols "256"))
     "First_Sheet")
   (http://www.gnumeric.org/v10.dtd:SheetName
     (@ (http://www.gnumeric.org/v10.dtd:Rows "65536")
        (http://www.gnumeric.org/v10.dtd:Cols "256"))
     "Second-sheet")
   (http://www.gnumeric.org/v10.dtd:SheetName
     (@ (http://www.gnumeric.org/v10.dtd:Rows "65536")
        (http://www.gnumeric.org/v10.dtd:Cols "256"))
     "RunsToDo")
   (http://www.gnumeric.org/v10.dtd:SheetName
     (@ (http://www.gnumeric.org/v10.dtd:Rows "65536")
        (http://www.gnumeric.org/v10.dtd:Cols "256"))
     "RunsToLock"))
 (http://www.gnumeric.org/v10.dtd:Geometry (@ (Width "1440") (Height "647")))
 (http://www.gnumeric.org/v10.dtd:UIData (@ (SelectedTab "3"))))

Modified txtdb/txtdb.scm from [f9c12e98ea] to [f716bafc90].

299
300
301
302
303
304
305




























306
307
308

309
310
311
312
313
314
315

316



317
318















319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
	      (loop (car tal)
		    (cdr tal)
		    new-rownames
		    new-colnames
		    (if (> curr-rownum rownum) curr-rownum rownum)
		    (if (> curr-colnum colnum) curr-colnum colnum)
		    ))))))




























(define (edit-txtdb path)
  (let* ((dbname  (pathname-strip-directory path))
	 (tmpf    (conc (create-temporary-file dbname) ".gnumeric")))

    (txtdb-export path tmpf)
    (let ((pid (process-run "gnumeric" (list tmpf))))
      (process-wait pid)
      (import-gnumeric-file tmpf path))))


(define (process-action action . param)

  (case (string->symbol action)



    ((edit)
     (edit-txtdb (car param)))))
















(define (main)
  (let* ((args (argv))
	 (prog (car args))
	 (rema (cdr args)))
    (cond
     ((null? rema)(print help))
     ((eq? (length rema) 2)
      (apply process-action (car rema)(cdr rema)))
     (else (print help)))))

(main)

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







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



>
|




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







|







299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342

343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
	      (loop (car tal)
		    (cdr tal)
		    new-rownames
		    new-colnames
		    (if (> curr-rownum rownum) curr-rownum rownum)
		    (if (> curr-colnum colnum) curr-colnum colnum)
		    ))))))
(define help
  (conc "Usage: txtdb action params ...

Note: txtdbdir is a path to the directory containg sheet-names.cfg

  import filename.gnumeric txtdbdir   : Import a gnumeric file into a txt db directory
  edit   txtdbdir                     : Edit a txtdbdir using gnumeric.
  lookup txtdbdir sheetname row col   : Look up a value in the text db   
  json   txtdbdir                     : Print the db as list of lists json data

Part of the Megatest tool suite. Learn more at http://www.kiatoa.com/fossils/megatest"))

(define (lookup path sheet row col)
  (let ((fname (conc path "/" sheet ".dat")))
    (if (file-exists? fname)
	(let ((dat (read-dat fname)))
	  (if (null? dat)
	      #f
	      (let loop ((hed (car dat))
			 (tal (cdr dat)))
		(if (and (equal? row (car hed))
			 (equal? col (cadr hed)))
		    (caddr hed)
		    (if (null? tal)
			#f
			(loop (car tal)(cdr tal)))))))
	#f)))

(define (edit-txtdb path)
  (let* ((dbname  (pathname-strip-directory path))
	 (tmpf    (conc (create-temporary-file dbname) ".gnumeric")))
    (if (file-exists? (conc path "/sheet-names.cfg"))
	(txtdb-export path tmpf))
    (let ((pid (process-run "gnumeric" (list tmpf))))
      (process-wait pid)
      (import-gnumeric-file tmpf path))))


(define (process-action action-str . param)
  (let ((num-params (length param))
	(action     (string->symbol action-str)))
    (cond
     ((eq? num-params 1)
      (case action
	((edit)
	 (edit-txtdb (car param)))))
     ((eq? num-params 2)
      (case action
	((import)
	 (let ((fname     (car param))
	       (targname  (cadr param)))
	   (import-gnumeric-file fname targname)))))
     ((eq? num-params 4)
      (case action
	((lookup)               ;; path    section     row          col 
	 (let ((res (lookup (car param)(cadr param)(caddr param)(cadddr param))))
	   (if res 
	       (print res)
	       (begin
		 (print "")
		 (exit 1))))))))))

(define (main)
  (let* ((args (argv))
	 (prog (car args))
	 (rema (cdr args)))
    (cond
     ((null? rema)(print help))
     ((>= (length rema) 2)
      (apply process-action (car rema)(cdr rema)))
     (else (print help)))))

(main)

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