4.8. foundations.io

io.py

Platform:
Windows, Linux, Mac Os X.
Description:
This module provides file input / output objects and resources manipulation objects.

Others:

4.8.1. Module Attributes

foundations.io.LOGGER

4.8.2. Functions

foundations.io.setDirectory(path)[source]
This definition creates a directory with given path.
The directory creation is delegated to Python os.makedirs() definition so that directories hierarchy is recursively created.
Parameters:path – Directory path. ( String )
Returns:Definition success. ( Boolean )
foundations.io.copy(source, destination)[source]

This definition copies the given file or directory to destination.

Parameters:
  • source – Source to copy from. ( String )
  • destination – Destination to copy to. ( String )
Returns:

Method success. ( Boolean )

foundations.io.remove(path)[source]

This definiton removes the given file or directory.

Parameters:path – Resource to remove. ( String )
Returns:Method success. ( Boolean )

4.8.3. Classes

class foundations.io.File(file=None, content=None)[source]

Bases: object

This class provides methods to read / write and append to files.

Usage:

>>> file = File("file.txt")
>>> file.content = ["Some file content ...\n", "... ready to be saved!\n"]
>>> file.write()
True
>>> file.read()
>>> file.content
['Some file content ...\n', '... ready to be saved!\n']
Parameters:
  • file – File path. ( String )
  • content – Content. ( List )
file[source]

This method is the property for self.__file attribute.

Returns:self.__file. ( String )
content[source]

This method is the property for self.__content attribute.

Returns:self.__content. ( List )
read(mode='r')[source]

This method reads given file content.

Parameters:mode – File read mode. ( String )
Returns:Method success. ( Boolean )
readAll()[source]

This method reads given file content and returns it.

Parameters:mode – File read mode. ( String )
Returns:File content. ( String )
write(mode='w')[source]

This method writes content to given file.

Parameters:mode – File write mode. ( String )
Returns:Method success. ( Boolean )
append(mode='a')[source]

This method appends content to given file.

Parameters:mode – File write mode. ( String )
Returns:Method success. ( Boolean )

Table Of Contents

Previous topic

4.7. foundations.globals.constants

Next topic

4.9. foundations.library

This Page