diff options
author | Eduardo Julian | 2021-01-26 19:11:14 -0400 |
---|---|---|
committer | Eduardo Julian | 2021-01-26 19:11:14 -0400 |
commit | 43d28326ad59c74439b96343cc8f619ed7d90231 (patch) | |
tree | 3f410d48bfca7d8141e2e7fda0f8d978934dd5c2 /stdlib/source/lux/world/program.lux | |
parent | ae56acf791c2ed9bd5865f85fffa00b025d310fe (diff) |
Made the Python being generated more compatible with both P2.7 and P3.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/world/program.lux | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/stdlib/source/lux/world/program.lux b/stdlib/source/lux/world/program.lux index 92a5793bd..ca301e2ce 100644 --- a/stdlib/source/lux/world/program.lux +++ b/stdlib/source/lux/world/program.lux @@ -3,7 +3,7 @@ ["@" target] ["." host (#+ import:)] [abstract - [monad (#+ do)]] + ["." monad (#+ do)]] [control ["." function] ["." io (#+ IO)] @@ -166,7 +166,19 @@ (import: NodeJs_OS (homedir [] #io Path)) - (import: (require [host.String] Any)))} + (import: (require [host.String] Any))) + @.python (as_is (import: os + (#static getcwd [] #io host.String)) + + (import: os/path + (#static expanduser [host.String] #io host.String)) + + (import: os/environ + (#static keys [] #io (Array host.String)) + (#static get [host.String] #io host.String)) + + (import: sys + (#static exit [host.Integer] #io Nothing)))} (as_is))) (structure: #export default @@ -190,7 +202,15 @@ #.None (undefined)) - environment.empty))} + environment.empty)) + @.python (do {! io.monad} + [keys (os/environ::keys [])] + (monad.fold ! (function (_ variable environment) + (do ! + [value (os/environ::get [variable])] + (wrap (dictionary.put variable value environment)))) + environment.empty + (array.to_list keys)))} ## TODO: Replace dummy implementation. (io.io environment.empty)))) @@ -203,7 +223,8 @@ (|> (..require "os") (:coerce NodeJs_OS) (NodeJs_OS::homedir [])) - <default>)} + <default>) + @.python (os/path::expanduser ["~"])} ## TODO: Replace dummy implementation. <default>))) @@ -219,7 +240,8 @@ #.None <default>) - <default>)} + <default>) + @.python (os::getcwd [])} ## TODO: Replace dummy implementation. <default>))) @@ -236,4 +258,5 @@ (..exit_browser! code) ## else - (..default_exit! code))})))) + (..default_exit! code)) + @.python (sys::exit code)})))) |