Skip to content

Instantly share code, notes, and snippets.

@rivermont
Last active July 17, 2019 22:19
Show Gist options
  • Save rivermont/a30f4edccc4bcad6a9d0672d43fcb7db to your computer and use it in GitHub Desktop.
Save rivermont/a30f4edccc4bcad6a9d0672d43fcb7db to your computer and use it in GitHub Desktop.
OSM payment tags converter
# fixing incorrect tag 'payments' and fixing other tags syntax
db = {
"mastercard": "payment:mastercard = yes",
"mc": "payment:mastercard = yes",
"cash": "payment:cash = yes",
"visa": "payment:visa = yes",
"checks": "payment:cheque = yes",
"check": "payment:cheque = yes",
"discover": "payment:discover_card = yes",
"amex": "payment:american_express = yes",
"credit card": "payment:credit_cards = yes",
"invoice": "payment:invoice = yes",
"debit": "payment:debit_cards = yes",
"care": "payment:care_credit = yes",
"financing": "payment:financing = yes",
"paypal": "payment:paypal = yes",
"insurance": "payment:insurance = yes",
"insurances": "payment:insurance = yes",
"square": "payment:operator = Square",
"cheque": "payment:cheque = yes",
"bank transfer": "payment:bank_transfer = yes",
"apple pay": "payment:apple_pay = yes",
"android pay": "payment:android_pay = yes",
"e-verify": "payment:e_verify = yes",
"ach": "payment:ach = yes",
"nfc": "payment:nfc = yes",
"bacs": "payment:bacs = yes"
}
bad = ["credit", "card", "all", "major", "cards", "master", "american", "express", "and", "cc", "personal", "most", "bank", "transfer", "accepted"]
def go(value):
value = value.lower().replace('␣', " ")
l = []
# special case for 'credit card'
if "credit card" in value:
l.append("credit card")
if "credit," in value:
l.append("credit card")
if "master card" in value:
l.append("mastercard")
if "american express" in value:
l.append("amex")
if "major cc" in value:
l.append("credit card")
if "bank transfer" in value:
l.append("bank transfer")
if "android pay" in value:
l.append("android pay")
if "apple pay" in "value":
l.append("apple pay")
l += (value.replace(',', " ").split())
for i in l:
if i in bad:
None
else:
print(" " + db[i])
print("\n\n")
# Fixing incorrect key 'payments'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment