Difference between revisions of "TruxtonChildFileIO"
Jump to navigation
Jump to search
| Line 1: | Line 1: | ||
This class provides a writable file to add to Truxton. | This class provides a writable file to add to Truxton. | ||
| + | =IOBase Methods= | ||
From [https://docs.python.org/3/library/io.html#io.IOBase IOBase] it implements: | From [https://docs.python.org/3/library/io.html#io.IOBase IOBase] it implements: | ||
| Line 18: | Line 19: | ||
* [https://docs.python.org/3/library/io.html#io.IOBase.writelines writelines()] | * [https://docs.python.org/3/library/io.html#io.IOBase.writelines writelines()] | ||
| + | =RawIOBase Methods= | ||
From [https://docs.python.org/3/library/io.html#io.RawIOBase RawIOBase] it implements: | From [https://docs.python.org/3/library/io.html#io.RawIOBase RawIOBase] it implements: | ||
| Line 25: | Line 27: | ||
* [https://docs.python.org/3/library/io.html#io.RawIOBase.write write()] | * [https://docs.python.org/3/library/io.html#io.RawIOBase.write write()] | ||
| + | =Truxton Methods= | ||
The above methods will let you read from a file in Truxton as if it were any other file in Python. | The above methods will let you read from a file in Truxton as if it were any other file in Python. | ||
The following methods are also present to make tasks of adding items extracted from a file easier. | The following methods are also present to make tasks of adding items extracted from a file easier. | ||
Revision as of 14:31, 25 May 2020
This class provides a writable file to add to Truxton.
IOBase Methods
From IOBase it implements:
- close()
- closed
- fileno() - Will return ERROR
- flush()
- isatty()
- readable() - Always returns FALSE
- readline() - Do not use, will return ERROR
- readlines() - Do not use, will return ERROR
- seek() - Will return ERROR
- seekable() - returns FALSE
- tell()
- truncate()
- writable() - returns TRUE
- writelines()
RawIOBase Methods
From RawIOBase it implements:
Truxton Methods
The above methods will let you read from a file in Truxton as if it were any other file in Python. The following methods are also present to make tasks of adding items extracted from a file easier.
Sample
This will retrieve a file from Truxton, print the name and hash as stored in the database then calculate a hash on the contents and print that.
import truxton
import hashlib
def main():
t = truxton.create()
file = t.getfileid("5ec2a123-74d6-5da7-0653-4e6800000000")
print(file.hash + " is the hash in the database for " + file.name )
bytes = file.readall()
readable_hash = hashlib.md5(bytes).hexdigest()
print(readable_hash + " is the calculated hash of the contents")
if __name__ == "__main__":
main()