Difference between revisions of "TruxtonSubject"
(→Sample) |
|||
| (9 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
This class lets you add information about the subject of an investigation. | This class lets you add information about the subject of an investigation. | ||
| − | This will populate the <code>Suspect</code> table in the database. | + | This will populate the <code>[Suspect]</code> table in the database. |
=Attributes and Methods= | =Attributes and Methods= | ||
| − | ==<code> | + | ==<code>addnote(investigation: object, text: str) -> boolean</code>== |
| − | + | This adds an investigator's note. | |
| − | + | The <code>text</code> parameter is the contents of the note. | |
| + | It will return | ||
| + | [https://docs.python.org/3.10/library/constants.html?highlight=false#True True] if the tag was associated with the subject, [https://docs.python.org/3.10/library/constants.html?highlight=false#False False] on failure. | ||
| + | The note is stored in the <code>[InvestigatorNote]</code> table in the database. | ||
| − | ==<code>custom</code>== | + | ==<code>birthday: [https://docs.python.org/3/library/datetime.html datetime]</code>== |
| + | When the subject was born. | ||
| + | This value can be set with either a datetime value or an integer representing [https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime FILETIME] ticks. | ||
| + | This corresponds to the <code>[DateOfBirth]</code> column of the <code>[Suspect]</code> table. | ||
| + | |||
| + | ==<code>custom: str</code>== | ||
Free form notes about the subject. | Free form notes about the subject. | ||
These appear as "Remarks" in the desktop user interface. | These appear as "Remarks" in the desktop user interface. | ||
| − | This corresponds to the <code>Custom</code> column of the <code>Suspect</code> table. | + | This corresponds to the <code>[Custom]</code> column of the <code>[Suspect]</code> table. |
| − | ==<code>description</code>== | + | ==<code>description: str</code>== |
A description of the subject, their title, etc. | A description of the subject, their title, etc. | ||
| − | This corresponds to the <code>Description</code> column of the <code>Suspect</code> table. | + | This corresponds to the <code>[Description]</code> column of the <code>[Suspect]</code> table. |
| − | ==<code>id</code>== | + | ==<code>id: object</code>== |
| − | This is the [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the | + | This is the [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the subject. |
Unlike most of the other identifiers in Truxton, this one can be optionally set. | Unlike most of the other identifiers in Truxton, this one can be optionally set. | ||
If you have generated a well known [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] you can store it in <code>id</code> before calling <code>save()</code> | If you have generated a well known [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] you can store it in <code>id</code> before calling <code>save()</code> | ||
If <code>id</code> is all zeroes, a random value will be generated in the call to <code>save()</code>. | If <code>id</code> is all zeroes, a random value will be generated in the call to <code>save()</code>. | ||
| − | ==<code>name</code>== | + | ==<code>name: str</code>== |
The name of the subject. | The name of the subject. | ||
| − | This corresponds to the <code>Name</code> column of the <code>Suspect</code> table. | + | This corresponds to the <code>[Name]</code> column of the <code>[Suspect]</code> table. |
| − | ==<code>picture</code>== | + | ==<code>picture: str</code>== |
A [https://en.wikipedia.org/wiki/Base64 base64] encoded 300x300 [https://en.wikipedia.org/wiki/Portable_Network_Graphics PNG] image of the subject. | A [https://en.wikipedia.org/wiki/Base64 base64] encoded 300x300 [https://en.wikipedia.org/wiki/Portable_Network_Graphics PNG] image of the subject. | ||
| − | ==<code>save()</code>== | + | ==<code>save() -> boolean</code>== |
| − | This will commit the information to the <code>Suspect</code> table. | + | This will commit the information to the <code>[Suspect]</code> table. |
| + | It will return [https://docs.python.org/3/library/constants.html#True True] if the record was saved to the database, [https://docs.python.org/3/library/constants.html#False False] if there was an error. | ||
| − | ==<code>tag(tag, reason, origin)</code>== | + | ==<code>tag(tag: str, reason: str, origin: int) -> boolean</code>== |
This creates a tag associated with this event in Truxton. | This creates a tag associated with this event in Truxton. | ||
The <code>tag</code> parameter is a short, one or two word, bit of text that will be displayed in the UI. | The <code>tag</code> parameter is a short, one or two word, bit of text that will be displayed in the UI. | ||
| − | The <code>reason</code> a sentence explaining why this | + | The <code>reason</code> a sentence explaining why this subject was tagged. |
The <code>origin</code> is either <code>TAG_ORIGIN_AUTOMATIC</code> (1) or <code>TAG_ORIGIN_HUMAN</code> (2). | The <code>origin</code> is either <code>TAG_ORIGIN_AUTOMATIC</code> (1) or <code>TAG_ORIGIN_HUMAN</code> (2). | ||
It will return | It will return | ||
| Line 41: | Line 50: | ||
=Sample= | =Sample= | ||
| − | + | <source lang="Python" highlight="3-10"> | |
| − | < | ||
def add_subject(): | def add_subject(): | ||
t = truxton.create() | t = truxton.create() | ||
| Line 53: | Line 61: | ||
s.save() | s.save() | ||
s.tag("AUS", "Australia - Friendly Foreign Government", truxton.TAG_ORIGIN_HUMAN) | s.tag("AUS", "Australia - Friendly Foreign Government", truxton.TAG_ORIGIN_HUMAN) | ||
| − | return | + | return None |
def b64(filename): | def b64(filename): | ||
| Line 59: | Line 67: | ||
data = input_file.read() | data = input_file.read() | ||
return str(base64.b64encode(data))[2:-1] | return str(base64.b64encode(data))[2:-1] | ||
| − | </ | + | </source> |
Latest revision as of 18:53, 2 May 2023
This class lets you add information about the subject of an investigation.
This will populate the [Suspect] table in the database.
Contents
Attributes and Methods
addnote(investigation: object, text: str) -> boolean
This adds an investigator's note.
The text parameter is the contents of the note.
It will return
True if the tag was associated with the subject, False on failure.
The note is stored in the [InvestigatorNote] table in the database.
birthday: datetime
When the subject was born.
This value can be set with either a datetime value or an integer representing FILETIME ticks.
This corresponds to the [DateOfBirth] column of the [Suspect] table.
custom: str
Free form notes about the subject.
These appear as "Remarks" in the desktop user interface.
This corresponds to the [Custom] column of the [Suspect] table.
description: str
A description of the subject, their title, etc.
This corresponds to the [Description] column of the [Suspect] table.
id: object
This is the GUID of the subject.
Unlike most of the other identifiers in Truxton, this one can be optionally set.
If you have generated a well known GUID you can store it in id before calling save()
If id is all zeroes, a random value will be generated in the call to save().
name: str
The name of the subject.
This corresponds to the [Name] column of the [Suspect] table.
picture: str
A base64 encoded 300x300 PNG image of the subject.
save() -> boolean
This will commit the information to the [Suspect] table.
It will return True if the record was saved to the database, False if there was an error.
tag(tag: str, reason: str, origin: int) -> boolean
This creates a tag associated with this event in Truxton.
The tag parameter is a short, one or two word, bit of text that will be displayed in the UI.
The reason a sentence explaining why this subject was tagged.
The origin is either TAG_ORIGIN_AUTOMATIC (1) or TAG_ORIGIN_HUMAN (2).
It will return
True if the tag was associated with the file, False on failure.
Sample
def add_subject():
t = truxton.create()
s = t.newsubject()
s.id = "00138955-133D-D2C1-A9E9-ADFF27FA80F4"
s.name = "Alexander Downer"
s.description = "Australian High Commissioner to the United Kingdom."
s.birthday = ticks("1951-09-09T00:00:00-00:00")
s.picture = b64(SUPPORT_DOCUMENTS_FOLDER + "Images/Alexander Downer.png")
s.save()
s.tag("AUS", "Australia - Friendly Foreign Government", truxton.TAG_ORIGIN_HUMAN)
return None
def b64(filename):
with open( filename, "rb" ) as input_file:
data = input_file.read()
return str(base64.b64encode(data))[2:-1]