Difference between revisions of "TruxtonExport"

From truxwiki.com
Jump to navigation Jump to search
Line 15: Line 15:
  
 
=Sample=
 
=Sample=
<source lang="Python" highlight="9,12,15-17,20,23,26,29,31">
+
<source lang="Python" highlight="9,12,15-17,20,23,26,29,32,34">
 
import truxton
 
import truxton
  
Line 36: Line 36:
 
   # Only output files that have an MD5 starting with E4
 
   # Only output files that have an MD5 starting with E4
 
   exporter.addcriteria( exporter.fqhash, "e4" )
 
   exporter.addcriteria( exporter.fqhash, "e4" )
 +
 +
  # Select files that belong to a particular piece of media
 +
  exporter.addcriteria( exporter.fqmedia, "174bcbe6-ef53-170f-8903-3958c45521a4" )
  
 
   # We want the files to be named with their hash followed by original name
 
   # We want the files to be named with their hash followed by original name

Revision as of 09:16, 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

import truxton

def main():
  t = truxton.create()

  exporter = t.newexporter()

  # Limit the number of files exported to 99
  exporter.addcriteria( exporter.fqlimit, 99 )

  # Make sure the files being exported are at least 4KB
  exporter.addcriteria( exporter.fqsizeminimum, 4096)

  # 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" )

  # Select files that belong to a particular piece of media
  exporter.addcriteria( exporter.fqmedia, "174bcbe6-ef53-170f-8903-3958c45521a4" )

  # We want the files to be named with their hash followed by original name
  exporter.addoption( exporter.eoname, "{hash}_{name}" )

  # Write the exported files to C:\temp
  exporter.addoption( exporter.eofolder, "c:\\temp" )

  # Write the files to output.tar in c:\temp
  exporter.addoption( exporter.eotar, "output.tar" )

  exporter.execute()

if __name__ == "__main__":
  main()