1
1
mirror of https://github.com/mcuadros/ascode synced 2024-11-23 01:11:59 +01:00
ascode/_documentation/runtime/os.md
2020-03-26 21:26:03 +01:00

4.1 KiB

title
os

os provides a platform-independent interface to operating system functionality.

Index

Functions

def os.chdir

os.chdir(dir)

changes the current working directory to the named directory.

Arguments
name type description
dir string target dir

def os.getenv

os.getenv(key) dir

retrieves the value of the environment variable named by the key.

Arguments
name type description
key string name of the environment variable

def os.getwd

os.getwd() dir

returns a rooted path name corresponding to the current directory.

def os.mkdir

os.mkdir(name, perms=0o777)

creates a new directory with the specified name and permission bits (before umask).

Arguments
name type description
name string name of the folder to be created
perms int optional, permission of the folder

def os.mkdir_all

os.mkdir_all(name, perms=0o777)

creates a new directory with the specified name and permission bits (before umask).

Arguments
name type description
name string name of the folder to be created
perms int optional, permission of the folder

def os.read_file

os.read_file(filename) string

reads the file named by filename and returns the contents.

Arguments
name type description
filename string name of the file to be written
data string content to be witten to the file
perms int optional, permission of the file

def os.remove

os.remove(name)

removes the named file or (empty) directory.

Arguments
name type description
name string name of the file or directory to be deleted

def os.remove_all

os.remove_all(path)

removes path and any children it contains. It removes everything it can but returns the first error it encounters.

Arguments
name type description
name string path to be deleted

def os.rename

os.rename(oldpath, newpath)

renames (moves) oldpath to newpath. If newpath already exists and is not a directory, Rename replaces it. OS-specific restrictions may apply when oldpath and newpath are in different directories.

Arguments
name type description
oldpath string old path
newpath string new path

def os.setenv

os.setenv(key, value) dir

sets the value of the environment variable named by the key.

Arguments
name type description
key string name of the environment variable
value string value of the environment variable

def os.write_file

os.write_file(filename, data, perms=0o644)

retrieves the value of the environment variable named by the key.

Arguments
name type description
filename string name of the file to be written
data string content to be witten to the file
perms int optional, permission of the file