summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Israelsson Tampe <stefan.itampe@gmail.com>2018-09-12 21:27:03 +0200
committerStefan Israelsson Tampe <stefan.itampe@gmail.com>2018-09-12 21:27:03 +0200
commit02ed5ec9f06962b4ea5abb389a7c3d009af64524 (patch)
tree662b073f1f513a24dd7a964416ef448d2846f2d5
parent37e74d5ff3ea8023db23fcd7edd33af5cbda4687 (diff)
relative references in import
-rw-r--r--modules/language/python/compile.scm96
-rw-r--r--modules/language/python/module/xml/etree/ElementInclude.py2
2 files changed, 95 insertions, 3 deletions
diff --git a/modules/language/python/compile.scm b/modules/language/python/compile.scm
index b4ba58f..a45cc48 100644
--- a/modules/language/python/compile.scm
+++ b/modules/language/python/compile.scm
@@ -987,7 +987,13 @@
((x)
(if (not (fluid-ref *doc*))
(fluid-set! *doc* x)))))
-
+
+(define (u-it m)
+ (if (and (eq? (list-ref m 0) 'language)
+ (eq? (list-ref m 1) 'python)
+ (eq? (list-ref m 0) 'module))
+ (cddr m)
+ '()))
(define (tr-comp op x y)
(match op
@@ -1263,6 +1269,33 @@
(lambda x #f))))
(if (eq? ? #t) (for-each dont-warn (get-exported-symbols l)))
`(,(C 'use) ,? ,l ,l))))
+
+ ((_ (#:from (("." . nn) . nm) . #f))
+ (let* ((u (module-name (current-module)))
+ (u (reverse (list-cdr-ref (reverse (u-it u)) (length nn))))
+ (xl (append u (map (lambda (nm) (exp vs nm)) nm)))
+ (l `(language python module ,@xl)))
+
+ ;; Make sure to load the module in
+ (let ((? (catch #t
+ (lambda () (Module (reverse l) (reverse xl)) #t)
+ (lambda x #f))))
+ (if (eq? ? #t) (for-each dont-warn (get-exported-symbols l)))
+ `(,(C 'use) ,? ,l ,l))))
+
+ ((_ (#:from ("." . nn) . #f))
+ (let* ((nm '())
+ (u (module-name (current-module)))
+ (u (reverse (list-cdr-ref (reverse (u-it u)) (length nn))))
+ (xl (append u (map (lambda (nm) (exp vs nm)) nm)))
+ (l `(language python module ,@xl)))
+
+ ;; Make sure to load the module in
+ (let ((? (catch #t
+ (lambda () (Module (reverse l) (reverse xl)) #t)
+ (lambda x #f))))
+ (if (eq? ? #t) (for-each dont-warn (get-exported-symbols l)))
+ `(,(C 'use) ,? ,l ,l))))
((_ (#:from (() . nm) l))
;; Make sure to load the module in
@@ -1290,7 +1323,66 @@
(dont-warn s2)
(cons s1 s2)))))
l)))))
-
+
+ ((_ (#:from (("." . nn) . nm) l))
+ ;; Make sure to load the module in
+ (let* ((u (module-name (current-module)))
+ (u (reverse (list-cdr-ref (reverse (u-it u)) (length nn))))
+ (xl (append u (map (lambda (nm) (exp vs nm)) nm)))
+ (ll `(language python module ,@xl)))
+
+ `(,(C 'use) #t ()
+ (,ll
+ #:select
+ ,(map (lambda (x)
+ (match x
+ ((a . #f)
+ (let ((s (exp vs a)))
+ (fluid-set! ignore
+ (cons s (fluid-ref ignore)))
+ (dont-warn s)
+ s))
+
+ ((a . b)
+ (let ((s1 (exp vs a))
+ (s2 (exp vs b)))
+ (fluid-set! ignore
+ (cons s2
+ (fluid-ref ignore)))
+ (dont-warn s2)
+ (cons s1 s2)))))
+ l)))))
+
+ ((_ (#:from ("." . nn) l))
+ ;; Make sure to load the module in
+ (let* ((nm '())
+ (u (module-name (current-module)))
+ (u (reverse (list-cdr-ref (reverse (u-it u)) (length nn))))
+ (xl (append u (map (lambda (nm) (exp vs nm)) nm)))
+ (ll `(language python module ,@xl)))
+
+ `(,(C 'use) #t ()
+ (,ll
+ #:select
+ ,(map (lambda (x)
+ (match x
+ ((a . #f)
+ (let ((s (exp vs a)))
+ (fluid-set! ignore
+ (cons s (fluid-ref ignore)))
+ (dont-warn s)
+ s))
+
+ ((a . b)
+ (let ((s1 (exp vs a))
+ (s2 (exp vs b)))
+ (fluid-set! ignore
+ (cons s2
+ (fluid-ref ignore)))
+ (dont-warn s2)
+ (cons s1 s2)))))
+ l)))))
+
((_ (#:name ((ids ...) . as) ...) ...)
`(,(G 'begin)
diff --git a/modules/language/python/module/xml/etree/ElementInclude.py b/modules/language/python/module/xml/etree/ElementInclude.py
index ed4b682..f69611d 100644
--- a/modules/language/python/module/xml/etree/ElementInclude.py
+++ b/modules/language/python/module/xml/etree/ElementInclude.py
@@ -51,7 +51,7 @@ module(xml,etree,ElementInclude)
##
import copy
-from . import ElementTree
+import xml.etree.ElementTree as ElementTree
XINCLUDE = "{http://www.w3.org/2001/XInclude}"