Package: taza
Taza is a Python library with a set of abstractions over Tacyt that
provides an OO layer over the query language.InstalationInstall via pippip install tazaThe libraries for tacyt are vendored inside taza, this is because the
Tacyt python client is not distributed using pip.UsageThe library has currently two main components, the wrapper for the API
and the query abstractions.To use the API wrapper you must instantiate aTazaClientclass.fromtaza.tacyt.TacytAppimportTacytAppfromtazaimportTazaClientapp=TacytApp(APP_ID,SECREY_KEY)client=TazaClient(app)Clients can also be instantiated with a factory method that wraps the
TacytApp class. Removing the need of importing Tacyt to the current
script.fromtazaimportTazaClientclient=TazaClient.from_credentials(APP_ID,SECRET_KEY)Querying tacytYou can send queries to tacyt for searching apps throught thesearch_apps_with_querymethod. This method will handle pagination
automatically. It returns a generators, so no query is actually made
until the data is collected.For example, let’s get the SHA256 hash of the apk of whatsapp.fromtazaimportTazaClientclient=TazaClient.from_credentials(APP_ID,SECRET_KEY)query="packageName:com.whatsapp AND origin:GooglePlay"fields=["sha256"]apps=client.search_apps_with_query(query,fields)# No actual connection to Tacyt done here.forappinapps:# Now the generator starts yielding and therefore connecting to Tacyt.print(app)Query language abstractionThe queries are send as a string to Tacyt, this means that the queries
must be managed as strings, which sometimes can get messy. Taza has an
OO abstraction that allows to write queries in Python.First, each predicate can he specified with thecondclass. There
are shorthands for common predicates (at least common to me).fromtaza.queryimportcond,packageName,fromGooglePlayq1=cond('packageName','com.company.awesome_app')q2=packageName('com.company.awesome_app')str(q1)# => "packageName:com.company.awesome_app"str(q2)# => "packageName:com.company.awesome_app"str(fromGooglePlay)=>"origin:GooglePlay"assertstr(q1)==str(q2)The predicates can be combined with AND, OR and NOT operators.fromtaza.queryimportcond,packageName,fromGooglePlayq1=cond('packageName','com.company.awesome_app')q2=packageName('com.company.awesome_app')str(q1&fromGooglePlay)# => "packageName:com.company.awesome_app AND origin:GooglePlay"str(q2|-fromGooglePlay)# => "packageName:com.company.awesome_app OR -origin:GooglePlay"Bear in mind that Tacyt only allows up to 40 predicates per query.If you need to agreggate several predicates under the same operator, you
can use theor_manyandand_manyfunctions. They are usefull if
you need to define the query programatically under a set of elements.fromtaza.queryimportcond,packageName,fromGooglePlayq1=packageName("app1")q2=packageName("app2")q3=packageName("app3")assertor_many(q1,q2,q3)==(q1|q2|q3)qs=[fromGooglePlay,cond('versionCode','42'),packageName('my.another.app')]assertand_many(*qs)==(fromGooglePlay&cond('versionCode','42')&packageName('my.another.app'))These queries are sent to thesearch_apps_with_querymethod in the
same way that string based queries are sent. The whatsapp example could
be rewritten as such.fromtazaimportTazaClientfromtaza.queryimportpackageName,fromGooglePlayclient=TazaClient.from_credentials(APP_ID,SECRET_KEY)query=packageName('com.whatsapp')&fromGooglePlayfields=["sha256"]apps=client.search_apps_with_query(query,fields)# No actual connection to Tacyt done here.forappinapps:# Now the generator starts yielding and therefore connecting to Tacyt.print(app)