Cache v2 format

= Cache v2-3 (.c2 files) = Cache v2 uses Python pickle package to store python object. cache v2 is implemented in helpers.py file (save and load functions). It identify data from a unique key (a dictionary, e.g. {'network':'Wiki','lang':'it','date':'2008-06-26'}) in addition to the file path.

How to read files
In [15]: import pickle In [16]: from gzip import GzipFile In [17]: d = pickle.load(GzipFile('path/filename.c2'))

or

In [9]: from trustlet import * In [10]: dictionary = read_c2('path/filename.c2')

= Networks = The Python object that rappresent a Network is a tuple (nodes,edges): the first element is a list of strings; the second is again a list, each entry is a tuple (a,b,c), where a and b are nodes, and c is the weight of the edge.

Sometimes you can find a serialized instance of Network class instead (In WikiPredGraph, or other generic Network). We should standardize this. Moreover both the format are supported by trustlet.

WikiNetwork
WikiNetwork can born only in c2 format (the scripts function generate it from xml in c2 format) but can be converted by conversion module of trustlet in other format (dot or pajek)

Cache Key
The dictionary key that identify a WikiNetwork has the following keys:
 * network (always is 'Wiki')
 * lang (using Wikipedia format {lang}.wikipedia.org)
 * date

An example

{'network':'Wiki', 'lang':'eml', 'date':'2008-06-26'}

Other Network
The other network (Advogato-like) can born in dot, or c2 or pajek format. All this format had to be converted in c2, in order to use it with trustlet. For advogato-like network, the conversion can be made automatically when you try to load a dot (automatic conversion is supported only for dot).

Cache Key
The dictionary key that identify a generic Network has the following keys:
 * network (name of the network had to be capital case and must exclude 'Network' ex. KaitiakiNetwork has name Kaitiaki )
 * date

An example

{'network':'Advogato', 'date':'2008-06-26'}

Other information
In a WikiNetwork c2 file there are other information in addition of network's nodes and edges.
 * List of bots
 * {'lang':lang, 'list':'bots'}


 * List of Blocked Users
 * {'lang':lang, 'list':'blockedusers'}


 * Number of all Wikipedia users
 * {'lang':lang, 'info':'number of users'}

You can also use c2 format to store all types of data that support pickling, simply using "save" and "load" function in trustlet.helpers module.