mediacollectiondb package¶
Media Collection DB for program evaluation.
Infrastructure¶
Media and MediaCollection representations.
mediacollectiondb database define the media collection datbase and provides tools to manage the database.
-
class
mediacollectiondb.media.Media(pageid, filename, uploader=None, width=None, height=None, size=None, quality_image=None, featured_picture=None, valued_image=None, timestamp=None)¶ Bases:
objectMedia representation in database.
-
pageid¶ str – MediaWiki pageid
-
filename¶ unicode – MediaWiki filename
-
uploader¶ unicode – Username of the uploader
-
width¶ int – width of the image
-
height¶ int – height of the image
-
size¶ int – Size in pixels of the image (width x height)
-
quality_image¶ bool – Whether the image is quality image or not
-
featured_picture¶ bool – Whether the image is featured picture or not
-
valued_image¶ bool – Whether the image is valued image or not
-
timestamp¶ date – Datetime of upload
-
classmethod
fromtuple(media)¶ Return a Media from a tuple.
-
totuple()¶ Return the object as a tuple of all values.
-
-
class
mediacollectiondb.media.MediaCollection(filename)¶ Bases:
objectPersistent media collection, i.e. collection saved into SQLite database.
-
connection¶ sqlite connection.
-
cursor¶ sqlite cursor.
-
COLLECTIONS_TABLE= 'media_collections'¶
-
exists(media)¶ Test whether a media is already in database or not.
In order to test whether the media is already in the database we count whether there is more than 0 element in the table with the same pageid
Parameters: media (dict) – a media to check if it is in the database. Returns: True if a media with the same pageid exists in the database False otherwise Return type: bool
-
insert(media)¶ Insert a media into the database.
-
listall()¶ List all elements of the collection.
-
reset()¶ Delete all entry in the database.
-
save(media)¶ Add media to the persistent media collection.
Parameters: media – media object to save to the into the persistent collection.
-
update(media)¶ Update a media already in database.
-
Metrics¶
Metrics module provide metrics for the Media Collections.
-
class
mediacollectiondb.metrics.MediaCollectionsMetrics(collections)¶ Bases:
objectMedia Collections Metrics.
-
collections¶ list – list of MediaCollections
-
cache_allmedia¶ list – cache list of all the media.Media from collections. None until cache is filled.
-
fpcount()¶ Amount of featured pictures in the set of collections.
-
listall()¶ List all Media objects from the media collections.
-
mediacount()¶ Count of media in the collections.
-
pixelcount()¶ Amount of pixels within all media collections.
-
qicount()¶ Amount of quality images in the set of collections.
-
qualitypixelcount()¶ Amount of pixels from quality images in all media collections.
-
uploadercount()¶ Amount of distinct uploader.
-
vicount()¶ Amount of valued images in the set of collections.
-