Difference between revisions of "TruxtonExport"

From truxwiki.com
Jump to navigation Jump to search
(Created page with "This class gives you the capability to export files from Truxton. =Attributes and Methods= ==<code>addcriteria(field, value)</code>== Adds criteria to the selection of files...")
 
Line 15: Line 15:
  
 
=Sample=
 
=Sample=
<source lang="Python" highlight="6,8-12,14">
+
<source lang="Python" line highlight="9,12,15-17">
 
import truxton
 
import truxton
  
Line 21: Line 21:
 
   t = truxton.create()
 
   t = truxton.create()
  
   exporter = t.newfilexporter()
+
   exporter = t.newexporter()
  
   file_type.parentid = truxton.Type_XML
+
   # Limit the number of files exported to 99
  file_type.shortname = "MyType"
+
   exporter.addcriteria( exporter.fqlimit, 99 )
   file_type.longname = "A custom file type derived from XML for demo purposes"
 
  file_type.extension = "xm2"
 
  file_type.mimetype = "text/xml"
 
  
   file_type.save()
+
   # Make sure the files being exported are at least 4KB
 +
  exporter.addcriteria( exporter.fqsizeminimum, 4096)
  
   print( "ID is " + str(file_type.id))
+
   # We want JPGs, EXIF and GIFs
 +
  exporter.addcriteria( exporter.fqtype, truxton.Type_JPEG )
 +
  exporter.addcriteria( exporter.fqtype, truxton.Type_JPEGWithExif)
 +
  exporter.addcriteria( exporter.fqtype, truxton.Type_GIF)
 +
 
 +
  # Only output files that have an MD5 starting with E4
 +
  exporter.addcriteria( exporter.fqhash, "e4" )
 +
 
 +
 
 +
  exporter.execute()
  
 
if __name__ == "__main__":
 
if __name__ == "__main__":
 
   main()
 
   main()
 
</source>
 
</source>

Revision as of 09:09, 2 December 2020

This class gives you the capability to export files from Truxton.

Attributes and Methods

addcriteria(field, value)

Adds criteria to the selection of files to export.

addoption(field, value)

Sets one of the output options.

execute()

After the criteria and options have been set, this function will perform the task of exporting the files from Truxton.

where

Holds the SQL WHERE clause based on the current criteria.

Sample

 1 import truxton
 2 
 3 def main():
 4   t = truxton.create()
 5 
 6   exporter = t.newexporter()
 7 
 8   # Limit the number of files exported to 99
 9   exporter.addcriteria( exporter.fqlimit, 99 )
10 
11   # Make sure the files being exported are at least 4KB
12   exporter.addcriteria( exporter.fqsizeminimum, 4096)
13 
14   # We want JPGs, EXIF and GIFs
15   exporter.addcriteria( exporter.fqtype, truxton.Type_JPEG )
16   exporter.addcriteria( exporter.fqtype, truxton.Type_JPEGWithExif)
17   exporter.addcriteria( exporter.fqtype, truxton.Type_GIF)
18 
19   # Only output files that have an MD5 starting with E4
20   exporter.addcriteria( exporter.fqhash, "e4" )
21 
22 
23   exporter.execute()
24 
25 if __name__ == "__main__":
26   main()