Skip to content
Snippets Groups Projects
Commit c3d83933 authored by Denis Shirshov's avatar Denis Shirshov
Browse files

43

parent 0ee6569f
No related branches found
No related tags found
No related merge requests found
......@@ -8,12 +8,15 @@
(define ODYSSEUS "c:/denis/denis_core/odysseus/")
(define ODYSSEUS-RELEASES "c:/denis/denis_core/odysseus-releases/")
(define (extract-files files-set new-directory #:exception-set (exception-set #f) #:extract-to (extract-to ODYSSEUS-RELEASES))
(define (normalize-path astr)
(string-replace astr "//" "/"))
(define (extract-files files-set #:new-directory (new-directory "") #:exception-set (exception-set #f) #:extract-to (extract-to ODYSSEUS-RELEASES))
(let ((new-root (string->path (str ODYSSEUS-RELEASES new-directory))))
;(make-directory* new-root)
(for ((file files-set))
(let ((old-path (string->path (str ODYSSEUS file)))
(new-path (string->path (str extract-to new-directory "/" file))))
(new-path (string->path (normalize-path (str extract-to "/" new-directory "/" file)))))
;(when (directory-exists? old-path) (make-directory* new-path))
(delete-directory/files
new-path
......@@ -23,4 +26,5 @@
new-path)))
(when exception-set
(for ((file exception-set))
(delete-directory/files (string->path (str extract-to new-directory "/" file)))))))
(let* ((new-path (normalize-path (str extract-to "/" new-directory "/" file))))
(delete-directory/files (string->path new-path)))))))
......@@ -4,10 +4,14 @@
(extract-files
(list
"lib")
""
#:extract-to "c:/denis/denis_core/projects/sbgn-pd2af/server"
"lib"
"knowledge-base"
"graphics")
#:new-directory "odysseus"
#:extract-to "c:/denis/denis_core/projects/pd2af/libs/"
#:exception-set (list
"lib/projects/gis"
"lib/tests"
"knowledge-base/neo4j"
"knowledge-base/owl"
"graphics/tests"
))
......@@ -4,6 +4,7 @@
(require "base.rkt")
(require "seqs.rkt")
(require "tree.rkt")
(require "type.rkt")
(require "hash.rkt")
(require "debug.rkt")
......@@ -33,6 +34,21 @@
(indexof? k2s k1)
(equal? (hash-ref h1 k1) (hash-ref h2 (nth k2s (indexof k2s k1))))))))))
(define (check-hash-iso h1 h2 #:list-any-order? (list-any-order? #f))
(let* ((k1s (hash-keys h1))
(k2s (hash-keys h2))
(v1s (hash-values h1))
(v2s (hash-values h2)))
(if list-any-order?
(and (same-elements? k1s k2s iso?) (same-elements? v1s v2s iso?)) ; in the case we don't care about elements order in the lists. Although doesn't work for cross-permutations yet
(and
(same-elements? k1s k2s iso?) ; no extra unchecked keys neither at k1s nor at k2s
(for/and
((k1 k1s))
(and
(indexof? k2s k1)
(same-elements? (hash-ref h1 k1) (hash-ref h2 (nth k2s (indexof k2s k1))) iso?)))))))
(define-macro (check-hash-equal? h1 h2)
`(check-true
(check-hash ,h1 ,h2)))
......
......@@ -109,6 +109,14 @@
(check-true (same-elements?
'((((#f S1 (simple chemical)) (#f enzyme)) (#f P1 (simple chemical))) "positive influence")
'((((#f enzyme) (#f S1 (simple chemical))) (#f P1 (simple chemical))) "positive influence")))
(check-true (iso-elements? 2 2))
(check-false (iso-elements? 2 "3"))
(check-false (iso-elements? '(1 2) '(2 3 4)))
(check-true (iso-elements? '(1 2) '(20 5)))
(check-true (iso-elements? '(1 2 "foo") '(20 5 "3")))
(check-false (iso-elements? '(1 "foo" 4) '(20 5 "3")))
)
; #hash(
; (education . (list
......
......@@ -115,9 +115,9 @@
((plain-list? lst) (map f (f lst)))
(else (map (λ (x) (transform-list-recur x f)) (f lst)))))
(define (same-elements? as bs)
(define (same-elements? as bs (criterium? equal?))
(cond
((and (scalar? as) (scalar? bs)) (equal? as bs))
((and (scalar? as) (scalar? bs)) (criterium? as bs))
((and (list? as) (list? bs))
(and
(for/and
......@@ -126,4 +126,15 @@
(for/and
((b bs))
(ormap (λ (a) (same-elements? b a)) as)))
(else (equal? as bs))))
(else (criterium? as bs))))
(define (iso-elements? as bs)
(cond
((and (empty? as) (empty? bs)) #t)
((and (scalar? as) (scalar? bs)) (equal? (type as) (type bs)))
((and (list? as) (list? bs))
(and
(= (length as) (length bs))
(iso-elements? (car as) (car bs))
(iso-elements? (cdr as) (cdr bs))))
(else #f)))
......@@ -137,3 +137,7 @@
(define (untype-equal? a1 a2)
(equal? (->string a1) (->string a2)))
(define (iso? a b)
(printf "~a ~a ~a ~a~n" a b (type a) (type b))
(equal? (type a) (type b)))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment