This phabricator task for fixing two separate bugs in handling commons files where mediainfo doesn't exist.these.
**Bug 1 is that there is no handling for missing mediainfo or creating empty mediainfo for files**
Code
```
gen = pagegenerators.RecentChangesPageGenerator(
site=self.site,
namespaces=[6], # File namespace
changetype="new",
total=100
)
"""Seek to first page without mediainfo."""
for page in gen:
if not 'mediainfo' in page.latest_revision.slots:
item = page.data_item()
"""Get fails as there is no mediainfo."""
item.get()
```
Result
```
Traceback (most recent call last):
File "/Users/kimmovirtanen/wikitech/core/tests/file_tests.py", line 400, in test_file_exist_but_without_item
item.get()
File "/Users/kimmovirtanen/wikitech/core/pywikibot/page/_wikibase.py", line 427, in get
data = self.file.latest_revision.slots['mediainfo']['*']
KeyError: 'mediainfo'
```
Fix
Handle the missing key as NoWikibaseEntityError and creating get_data_for_new_entity() if user wants to create new item for the file.
**Bug 2 (T222159) is that the empty statements is list instead of dictionary **
Pywikibot fix is to convert the detect incorrect list and convert to dictionary when it is loaded.