diff options
Diffstat (limited to 'modules/language/python/module/python.scm')
-rw-r--r-- | modules/language/python/module/python.scm | 56 |
1 files changed, 3 insertions, 53 deletions
diff --git a/modules/language/python/module/python.scm b/modules/language/python/module/python.scm index 30434af..96b0aa7 100644 --- a/modules/language/python/module/python.scm +++ b/modules/language/python/module/python.scm @@ -8,6 +8,7 @@ object-method)) #:use-module (language python exceptions ) #:use-module ((language python module string ) #:select ()) + #:use-module ((language python module io ) #:select (open)) #:use-module (language python def ) #:use-module (language python for ) #:use-module (language python try ) @@ -38,13 +39,13 @@ SyntaxError bool len dir next dict None property range tuple bytes bytearray eval locals globals - compile exec type object + compile exec type object open ) #:export (print repr complex float int str set all any bin callable reversed chr classmethod staticmethod objectmethod - divmod enumerate filter open + divmod enumerate filter getattr hasattr setattr hex isinstance issubclass iter map sum id input oct ord pow super sorted zip @@ -52,11 +53,6 @@ (define-syntax-rule (aif it p x y) (let ((it p)) (if it x y))) -(define (path-it path) - (aif it (ref path '__fspath__) - (it) - path)) - (define print (case-lambda (() ((@ (guile) format) #t "~%")) @@ -263,52 +259,6 @@ (yield (reverse r)) (lp)))))))))) -(define DEFAULT_BUFFER_SIZE 4096) -(def (open path - (= mode "r") - (= buffering -1 ) - (= encoding None) - (= errors None) - (= newline None) - (= closefd #t) - (= opener None)) - - (define modelist (string->list mode)) - (define path (path-it path)) - (define (clean ch l) - (filter (lambda (c) (not (eq? ch c))) l)) - (let ((port (if (number? path) - (begin - (if (member #\a modelist) - (seek path 0 SEEK_END)) - (if (member #\x modelist) - (error "cannot use mode 'x' for fd input")) - (cond - ((member #\r modelist) - (fdes->inport path)) - ((member #\w modelist) - (fdes->outport path)))) - (begin - (if (member #\x modelist) - (if (file-exists? path) - (raise OSError "mode='x' and file exists") - (set mode (list->string - (clean #\x modelist))))) - ((@ (guile) open-file) (path-it path) mode))))) - - (case buffering - ((-1) - (setvbuf port 'block DEFAULT_BUFFER_SIZE)) - ((0) - (setvbuf port 'none)) - ((1) - (setvbuf port 'line)) - (else - (setvbuf port 'block buffering))) - - port)) - - (define-python-class ClassMethod ()) (define-python-class StaticMethod ()) (define-python-class Funcobj ()) |