#:use-module ((language python module python)
#:select ((open . builtin:open)))
#:use-module (language python list)
- #:export (error name ctermid environ environb chdir fchdir getcwd
- fsencode fdencode fspath PathLike getenv getenvb
+ #:replace (getcwd getuid getenv)
+ #:export (error name ctermid environ environb chdir fchdir
+ fsencode fdencode fspath PathLike getenvb
get_exec_path getgid getegid geteuid fdopen
getgroups getgrouplist getlogin getpgid getpgrp getpid
getppid PRIO_PROCESS PRIO_PRGRP PRIO_USER getpriority
- getresgid getuid initgroups putenv setegid seteuid
+ getresgid initgroups putenv setegid seteuid
setgid setgroups setpgrp setpgid setpriority setregid
setresgid setreuid setresuid getsid setsid setuid strerr
umask uname unsetenv
#:use-module (language python module os)
#:use-module (language python module pwd)
#:use-module (language python module errno)
+ #:use-module (language python module stat)
#:use-module (language python for)
+ #:use-module (language python try)
+ #:use-module (system foreign)
+ #:use-module (parser stis-parser)
#:use-module (language python exceptions)
- #:use-module (oop pg-objects)
+ #:use-module (oop pf-objects)
+ #:use-module (ice-9 match)
#:export (abspath basename commonpath commonprefix dirname exists
lexists expanduser expandvars getatime getmtime
getctime getsize isabs isfile isdir islink ismount
(define (basename path) (ca ((@ (guile) basename) (path-it path))))
(define (commonprefix paths)
- (letrec ((l (for ((p paths)) ((l '()))
+ (letrec ((l (for ((p : paths)) ((l '()))
(cons (string->list (normpath p)) l)
#:final l))
(f (lambda (l)
- (let lp ((l l)) ((r #f) (d '()))
+ (let lp ((l l) (r #f) (d '()))
(match l
((() . _) '())
(((x . u) . l)
(define (commonpath paths)
(define kind
- (for ((p paths)) ((e #f))
+ (for ((p : paths)) ((e #f))
(let ((x (if (isabs (path-it p)) 'abs 'rel)))
(if e
(if (eq? e x)
(if (not kind) (raise ValueError "No paths"))
- (letrec ((l (for ((p paths)) ((l '()))
+ (letrec ((l (for ((p : paths)) ((l '()))
(cons (string-split (normpath p) #\/) l)
#:final l))
(f (lambda (l)
- (let lp ((l l)) ((r #f) (d '()))
+ (let lp ((l l) (r #f) (d '()))
(match l
((() . _) '())
(((x . u) . l)
(string-join (append (string-split (lookup-self) "/")
(cdr (string-split path #\/)))))))))
-(define f-var (f-mk (f-or!
- (f-seq (f-tag! "$") (f+ (f-reg! "[a-zA-Z0-9]")))
- (f-seq (f-tag! "$") (f-tag "{") (f+ (f-not! (f-tag "}")))
- (f-tag "}")))))
+(define f-var (mk-token
+ (f-or!
+ (f-seq (f-tag! "$") (f+ (f-reg! "[a-zA-Z0-9]")))
+ (f-seq (f-tag! "$") (f-tag "{") (f+ (f-not! (f-tag "}")))
+ (f-tag "}")))))
+
+(define f-other (mk-token (f* (f-not! f-var))))
+
+(define f-f (f-cons f-other (ff* (f-seq f-var f-other))))
+
(define (expandvars p)
- (let lp ((l (f-split (path-it p) f-var)) (r '()))
+ (let lp ((l (parse (path-it p) f-f)) (r '()))
(match l
((a b . l)
(lp l (cons* (getenv b) a r)))
(stat:dev ((@ (guile) stat) q)))))))
- (normpath (string-join (map path-it l) "/")))
-
(define (normcase x) x)
(define join (@@ (language python module os) path:join))
(free s)
ret))))))
-(define* (relpath p #:optional (start curpath))
- (define l1 (string-aplit (realpath (path-it p)) #\/))
- (define l2 (string-split (realpath start)) #\/)
+(define* (relpath p #:optional (start curdir))
+ (define (reduce f s l)
+ (if (pair? l)
+ (reduce f (f (car l) s) (cdr l))
+ s))
+ (define l1 (string-split (realpath (path-it p)) #\/))
+ (define l2 (string-split (realpath start) #\/))
(define red (lambda (x s) (cons ".." s)))
(let lp ((l1 l1) (l2 l2))
(match (cons l1 l2)