Raw

Platform:Unix
Class Authors:Authors: Logan Rickert, Cole Loewer, David Sutherin
Standard:Flake8

The main purpose of this class is to handle getting meta-data about files.

class FoRREST.plugins.raw.File.File(forrest)
get_extension()
Description:
Returns the extension of the current file.
Example:
file = /cake/awesome/sweet.py returns: “py”
Returns:
str. The extenstion.
get_inode()
Description:
Returns the inode of the current file.
Example:
303 forrest.py returns: 303
Returns:
int. The inode.
get_md5()
Description:
Returns the MD5 sum for the file.
Example:
file = /cake/awesome/sweet.py returns: “943172131622f261d9af95e1634159d9”
Returns:
str. The hash.
get_name()
Description:
Returns the filename of the current file.
Example:
file = /cake/awesome/sweet.py returns: “sweet.py”
Returns:
str. The filename.
get_path()
Description:
Returns the path to the file.
Example:

file = /cake/awesome/sweet.py returns: “/cake/awesome”

file = plugins/raw/Raw.py returns: “plugins/raw”

Returns:
str. The path.
get_sha1()
Description:
Returns the SHA1 sum for the file.
Example:
file = /cake/awesome/sweet.py returns: “943172131622f261d9af95e1634159d9”
Returns:
str. The hash.
get_sha256()
Description:
Returns the SHA256 sum for the file.
Example:
file = /cake/awesome/sweet.py returns: “943172131622f261d9af95e1634159d9”
Returns:
str. The hash.
get_sha512()
Description:
Returns the SHA512 sum for the file.
Example:
file = /cake/awesome/sweet.py returns: “943172131622f261d9af95e1634159d9”
Returns:
str. The hash.
get_size()
Description:
Returns the size of the current file in bytes.
Example:
3343 forrest.py returns: 3343
Returns:
int. The size of the file.
static hash_file(filename, hash_algo)
Description:
Returns a hash for @filename based on the the @hash_algo.
Args:
filename (str): The name of the file to hash. hash_algo (hashlib): The hashing algorithm. (IE: hashlib.sha512())
Returns:
str. The hash.
read_chunck(chunksize=4096)
Description:
Returns a chunck of the file. By default, the size is 4096. The function will start at the beginning and hold its position each read. Once the file has been completely read in, calling this function will return empty string (‘’) and reset to the beginning of the file.
Args:
chunksize (int): The lenght of string to read in.
Returns:
str. The chunck from the requested file in rb.
reset_read()
Description:
Force reset the read_chunck method to start at the beginning.
Returns:
None.

Previous topic

Plugins

Next topic

Extract

This Page