6.9. foundations.io

io.py

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

Others:

6.9.1. Module Attributes

foundations.io.LOGGER

6.9.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 )

6.9.3. Classes

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

Bases: object

This class provides methods to read / write and append to files or retrieve online file content.

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:
  • path – File path. ( String )
  • content – Content. ( List )
path[source]

This method is the property for self.__path attribute.

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

This method is the property for self.__content attribute.

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

This method reads given file content and stores it in the content cache.

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

This method uncaches the cached content.

Returns:Method success. ( Boolean )
read()[source]

This method returns defined file content.

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

This method writes content to defined file.

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

This method appends content to defined file.

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

This method clears the defined file content.

Returns:Method success. ( Boolean )

Table Of Contents

Previous topic

6.8. foundations.globals.constants

Next topic

6.10. foundations.library

This Page