kopia lustrzana https://github.com/micropython/micropython-lib
os: Implement getenv().
rodzic
f3dd9abcda
commit
e8813f3f03
|
@ -0,0 +1,3 @@
|
|||
import os
|
||||
|
||||
print(os.getenv("HOME", "def"))
|
|
@ -32,6 +32,7 @@ _exit_ = libc.func("v", "_exit", "i")
|
|||
getpid_ = libc.func("i", "getpid", "")
|
||||
waitpid_ = libc.func("i", "waitpid", "ipi")
|
||||
system_ = libc.func("i", "system", "s")
|
||||
getenv_ = libc.func("s", "getenv", "P")
|
||||
|
||||
R_OK = const(4)
|
||||
W_OK = const(2)
|
||||
|
@ -204,6 +205,12 @@ def system(command):
|
|||
check_error(r)
|
||||
return r
|
||||
|
||||
def getenv(var, default=None):
|
||||
var = getenv_(var)
|
||||
if var is None:
|
||||
return default
|
||||
return var
|
||||
|
||||
def fsencode(s):
|
||||
if type(s) is bytes:
|
||||
return s
|
||||
|
|
Ładowanie…
Reference in New Issue