From 9b713efb860823d508110147ddd57f8a1975e4b3 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 3 Apr 2020 08:54:53 +0000 Subject: [PATCH] flake8 format --- donate.py | 56 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/donate.py b/donate.py index 054b5042..48298a9f 100644 --- a/donate.py +++ b/donate.py @@ -1,24 +1,24 @@ -__filename__="donate.py" -__author__="Bob Mottram" -__license__="AGPL3+" -__version__="1.1.0" -__maintainer__="Bob Mottram" -__email__="bob@freedombone.net" -__status__="Production" +__filename__ = "donate.py" +__author__ = "Bob Mottram" +__license__ = "AGPL3+" +__version__ = "1.1.0" +__maintainer__ = "Bob Mottram" +__email__ = "bob@freedombone.net" +__status__ = "Production" -import json def getDonationTypes() -> str: - return ('patreon','paypal','gofundme','liberapay', \ - 'kickstarter','indiegogo','crowdsupply', \ + return ('patreon', 'paypal', 'gofundme', 'liberapay', + 'kickstarter', 'indiegogo', 'crowdsupply', 'subscribestar') + def getDonationUrl(actorJson: {}) -> str: """Returns a link used for donations """ if not actorJson.get('attachment'): return '' - donationType=getDonationTypes() + donationType = getDonationTypes() for propertyValue in actorJson['attachment']: if not propertyValue.get('name'): continue @@ -28,58 +28,62 @@ def getDonationUrl(actorJson: {}) -> str: continue if not propertyValue.get('value'): continue - if propertyValue['type']!='PropertyValue': + if propertyValue['type'] != 'PropertyValue': continue if ' None: + +def setDonationUrl(actorJson: {}, donateUrl: str) -> None: """Sets a link used for donations """ if not actorJson.get('attachment'): - actorJson['attachment']=[] + actorJson['attachment'] = [] - donationType=getDonationTypes() - donateName=None + donationType = getDonationTypes() + donateName = None for paymentService in donationType: if paymentService in donateUrl: - donateName=paymentService + donateName = paymentService if not donateName: return # remove any existing value - propertyFound=None + propertyFound = None for propertyValue in actorJson['attachment']: if not propertyValue.get('name'): continue if not propertyValue.get('type'): continue - if not propertyValue['name'].lower()!=donateName: + if not propertyValue['name'].lower() != donateName: continue - propertyFound=propertyValue + propertyFound = propertyValue break if propertyFound: actorJson['attachment'].remove(propertyFound) - donateValue=''+donateUrl+'' + donateValue = \ + '' + \ + donateUrl + '' for propertyValue in actorJson['attachment']: if not propertyValue.get('name'): continue if not propertyValue.get('type'): continue - if propertyValue['name'].lower()!=donateName: + if propertyValue['name'].lower() != donateName: continue - if propertyValue['type']!='PropertyValue': + if propertyValue['type'] != 'PropertyValue': continue - propertyValue['value']=donateValue + propertyValue['value'] = donateValue return - newDonate={ + newDonate = { "name": donateName, "type": "PropertyValue", "value": donateValue