Powered by Tachyonic Project Luxon Framework v0.0.0

Luxon Framework for rapid application development. (luxon)

Version

Files

Some useful File Opperations

Socket Check

luxon.utils.files.is_socket(socket)[source]

Is Unix socket

Parameters:socket (str) – Socket path.
Retrurns:
Bool whether file is unix socket

File Tracker

class luxon.utils.files.TrackFile(file)[source]

Tracks a given file

Parameters:file (file) – file to be tracked
is_deleted()[source]

Checks if file was deleted since tracking started

Returns:True if deleted
is_modified()[source]

Checks if file was modified since tracking started

Returns:True if modified

File Object

class luxon.utils.files.FileObject(filename, type, file)[source]

Simple File Object structure for internal use

contains attributes for: filename, type and the file itself

Open

class luxon.utils.files.Open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, perms=600, create=True)[source]

Open File

Opens a given file and performs actions on the file object. A number of default options can be specified as keyword arguments when spawning the file object.

Options such as:

  • buffering
  • encoding
  • errors
  • newline
  • closefd
  • opener
Parameters:
  • file (file) – file to be opened
  • mode (str) – mode
buffer

Property

Buffer size

close()[source]

Close File

encoding

Property

Encode file

errors

Property

Unicode Error Handler

flush()[source]

Clear the buffer

newlines

Property

end-of-line convention

read(size=-1)[source]

Read file

readline(size=-1)[source]

Read line

seek(offset, whence=0)[source]

Move to new file position

tell()[source]

Current file position

write(value)[source]

Write File

Free Space

luxon.utils.files.get_free_space(path)[source]

Get free space in path.

blocks = Size of filesystem in bytes. bytes = Actual number of free bytes. avail = Number of free bytes that ordinary users can use.

Returns tuple (blocks, bytes, bytes_avail)

Mounts

Only works on Linux

luxon.utils.files.get_mounts()[source]

Get mounts

Current Working Directory

luxon.utils.files.get_cwd()[source]

Return Current working directory

Change Directory

luxon.utils.files.chdir(path)[source]

Change Owner

luxon.utils.files.chown(path, uid=None, gid=None, recursive=False)[source]

Change Ownership

Parameters:
  • path (str) – file path
  • uid (str) – new user id
  • gid (str) – new group id

Exists

luxon.utils.files.exists(path)[source]

Is the path a directory

Is Directory

luxon.utils.files.is_dir(path)[source]

Is the path a directory

Is File

luxon.utils.files.is_file(path)[source]

Is the path a file

Is Mount

luxon.utils.files.is_mount(path)[source]

Is the path a mount

Remove

luxon.utils.files.rm(path, recursive=False)[source]

Remove file or directory at given location

Parameters:
  • path (str) – path to be removed
  • recursive (bool) – recursive option

Make Directory

luxon.utils.files.mkdir(path, recursive=False)[source]

Creates a new directory in a given location

Parameters:path (str) – location of new directory

Change Permissions

luxon.utils.files.chmod(path, perms)[source]

Change file mode permissi0ns.

Expects value of int such as 755, Alternatively you can provide format in string rwxrwxrwx.

File Info

luxon.utils.files.file_info(path)[source]

File Information

Args (str): location of file

Returns a tuple with the following info:

  • file type
  • full path
  • short name
  • uid
  • gid
  • file mode
  • file size
  • access time
  • modified time
  • create time
  • extra

Walk

luxon.utils.files.walk(path)[source]

Walks through directory

Parameters:path (str) – location of directory

Returns a list of file information tuples for each file in directory