convert App to subclass of dict to support parsing/dumping libs

Python is heavily based on its core data types, and dict is one of the more
important ones.  Even classes are basically a wrapper around a dict. This
converts metadata.App to be a subclass of dict so it can behave like a dict
when being dumped and loaded.  This makes its drastically easier to use
different data formats for build metadata and for sending data to the
client.  This approach will ultimately mean we no longer have to maintain
custom parsing and dumping code.

This also means then that the YAML/JSON field names will not have spaces in
them, and they will match exactly what it used as the dict keys once the
data is parsed, as well as matching exactly the instance attribute names:

* CurrentVersion: 1.2.6
* app['CurrentVersion'] == '1.2.6'
* app.CurrentVersion == '1.2.6'

Inspired by:
https://goodcode.io/articles/python-dict-object/
This commit is contained in:
Hans-Christoph Steiner 2016-11-23 17:25:59 +01:00
parent 4625651192
commit b7fc7f2228
10 changed files with 165 additions and 229 deletions

View file

@ -1,17 +1,17 @@
AntiFeatures: []
Archive Policy: null
Author Email: null
Author Name: null
Auto Name: AdAway
Auto Update Mode: Version v%v
ArchivePolicy: null
AuthorEmail: null
AuthorName: null
AutoName: AdAway
AutoUpdateMode: Version v%v
Binaries: null
Bitcoin: null
Categories:
- System
- Security
Changelog: ''
Current Version: '3.0'
Current Version Code: '52'
CurrentVersion: '3.0'
CurrentVersionCode: '52'
Description: 'An ad blocker that uses the hosts file. The hosts file
contains a list of mappings between hostnames and IP addresses. When
@ -38,24 +38,24 @@ Description: 'An ad blocker that uses the hosts file. The hosts file
Disabled: null
Donate: http://sufficientlysecure.org/index.php/adaway
FlattrID: '369138'
Issue Tracker: https://github.com/dschuermann/ad-away/issues
IssueTracker: https://github.com/dschuermann/ad-away/issues
License: GPLv3
Litecoin: null
Maintainer Notes: ''
MaintainerNotes: ''
Name: null
No Source Since: ''
NoSourceSince: ''
Provides: org.sufficientlysecure.adaway
Repo: https://github.com/dschuermann/ad-away.git
Repo Type: git
Requires Root: true
Source Code: https://github.com/dschuermann/ad-away
RepoType: git
RequiresRoot: true
SourceCode: https://github.com/dschuermann/ad-away
Summary: Block advertisements
Update Check Data: null
Update Check Ignore: null
Update Check Mode: Tags
Update Check Name: null
Vercode Operation: null
Web Site: http://sufficientlysecure.org/index.php/adaway
UpdateCheckData: null
UpdateCheckIgnore: null
UpdateCheckMode: Tags
UpdateCheckName: null
VercodeOperation: null
WebSite: http://sufficientlysecure.org/index.php/adaway
added: null
builds:
- antcommands: []

View file

@ -1,16 +1,16 @@
AntiFeatures: []
Archive Policy: null
Author Email: null
Author Name: null
Auto Name: SMSSecure
Auto Update Mode: Version v%v
ArchivePolicy: null
AuthorEmail: null
AuthorName: null
AutoName: SMSSecure
AutoUpdateMode: Version v%v
Binaries: null
Bitcoin: null
Categories:
- Phone & SMS
Changelog: ''
Current Version: 0.6.0
Current Version Code: '102'
CurrentVersion: 0.6.0
CurrentVersionCode: '102'
Description: 'SMSSecure is an SMS/MMS application that allows you to protect your
privacy while communicating with friends.
@ -35,24 +35,24 @@ Description: 'SMSSecure is an SMS/MMS application that allows you to protect you
Disabled: null
Donate: null
FlattrID: null
Issue Tracker: https://github.com/SMSSecure/SMSSecure/issues
IssueTracker: https://github.com/SMSSecure/SMSSecure/issues
License: GPLv3
Litecoin: null
Maintainer Notes: ''
MaintainerNotes: ''
Name: null
No Source Since: ''
NoSourceSince: ''
Provides: null
Repo: https://github.com/SMSSecure/SMSSecure
Repo Type: git
Requires Root: false
Source Code: https://github.com/SMSSecure/SMSSecure
RepoType: git
RequiresRoot: false
SourceCode: https://github.com/SMSSecure/SMSSecure
Summary: Send encrypted text messages (SMS)
Update Check Data: null
Update Check Ignore: null
Update Check Mode: Tags
Update Check Name: null
Vercode Operation: null
Web Site: http://www.smssecure.org
UpdateCheckData: null
UpdateCheckIgnore: null
UpdateCheckMode: Tags
UpdateCheckName: null
VercodeOperation: null
WebSite: http://www.smssecure.org
added: null
builds:
- antcommands: []

View file

@ -1,16 +1,16 @@
AntiFeatures: []
Archive Policy: 9 versions
Author Email: null
Author Name: null
Auto Name: VLC
Auto Update Mode: None
ArchivePolicy: 9 versions
AuthorEmail: null
AuthorName: null
AutoName: VLC
AutoUpdateMode: None
Binaries: null
Bitcoin: null
Categories:
- Multimedia
Changelog: ''
Current Version: 1.2.6
Current Version Code: '1030005'
CurrentVersion: 1.2.6
CurrentVersionCode: '1030005'
Description: 'Video and audio player that supports a wide range of formats,
for both local and remote playback.
@ -22,10 +22,10 @@ Description: 'Video and audio player that supports a wide range of formats,
Disabled: null
Donate: http://www.videolan.org/contribute.html#money
FlattrID: null
Issue Tracker: http://www.videolan.org/support/index.html#bugs
IssueTracker: http://www.videolan.org/support/index.html#bugs
License: GPLv3
Litecoin: null
Maintainer Notes: 'Instructions and dependencies here: http://wiki.videolan.org/AndroidCompile
MaintainerNotes: 'Instructions and dependencies here: http://wiki.videolan.org/AndroidCompile
see http://buildbot.videolan.org/builders/ for version code scheme
@ -42,19 +42,19 @@ Maintainer Notes: 'Instructions and dependencies here: http://wiki.videolan.org/
'
Name: null
No Source Since: ''
NoSourceSince: ''
Provides: null
Repo: git://git.videolan.org/vlc-ports/android.git
Repo Type: git
Requires Root: false
Source Code: http://git.videolan.org/?p=vlc-ports/android.git;a=summary
RepoType: git
RequiresRoot: false
SourceCode: http://git.videolan.org/?p=vlc-ports/android.git;a=summary
Summary: Media player
Update Check Data: null
Update Check Ignore: null
Update Check Mode: Tags
Update Check Name: null
Vercode Operation: '%c + 5'
Web Site: http://www.videolan.org/vlc/download-android.html
UpdateCheckData: null
UpdateCheckIgnore: null
UpdateCheckMode: Tags
UpdateCheckName: null
VercodeOperation: '%c + 5'
WebSite: http://www.videolan.org/vlc/download-android.html
added: null
builds:
- antcommands: []