Move map provider function to upper level class

master
Mark Veidemanis 2 years ago
parent e86664551d
commit 5b2e4e5bd0
Signed by: m
GPG Key ID: 5ACFCEED46C0904F

@ -44,6 +44,19 @@ class Local(util.Base):
self.lc_cheat.start(int(self.sets.CheatSec)) self.lc_cheat.start(int(self.sets.CheatSec))
self.log.debug("Finished setting up loops.") self.log.debug("Finished setting up loops.")
def map_provider(self, provider, reverse=False):
provider_map = {"NATIONAL_BANK": "national-bank-transfer"}
if reverse:
try:
return next(key for key, value in provider_map.items() if value == provider)
except StopIteration:
return False
else:
try:
return provider_map[provider]
except KeyError:
return False
@inlineCallbacks @inlineCallbacks
def got_dashboard(self, dash): def got_dashboard(self, dash):
dash_tmp = yield self.wrap_dashboard(dash) dash_tmp = yield self.wrap_dashboard(dash)
@ -294,8 +307,8 @@ class Local(util.Base):
# coin = "monero" # coin = "monero"
# elif asset == "BTC": # elif asset == "BTC":
# coin = "bitcoins" # coin = "bitcoins"
# if not providers: if not providers:
# providers = ["NATIONAL_BANK"] providers = ["NATIONAL_BANK"]
# buy-monero-online, buy-bitcoin-online # buy-monero-online, buy-bitcoin-online
# Work around Agora weirdness calling it bitcoins # Work around Agora weirdness calling it bitcoins
# ads = yield self.api._api_call( # ads = yield self.api._api_call(
@ -306,6 +319,7 @@ class Local(util.Base):
ads = yield self.api.buy_monero_online(currency_code=currency, page=page) ads = yield self.api.buy_monero_online(currency_code=currency, page=page)
elif asset == "BTC": elif asset == "BTC":
ads = yield self.api.buy_bitcoins_online(currency_code=currency, page=page) ads = yield self.api.buy_bitcoins_online(currency_code=currency, page=page)
# with open("pub.json", "a") as f: # with open("pub.json", "a") as f:
# import json # import json
# f.write(json.dumps([page, currency, asset, ads])+"\n") # f.write(json.dumps([page, currency, asset, ads])+"\n")
@ -319,7 +333,12 @@ class Local(util.Base):
if "data" not in ads["response"]: if "data" not in ads["response"]:
return False return False
for ad in ads["response"]["data"]["ad_list"]: for ad in ads["response"]["data"]["ad_list"]:
if ad["data"]["online_provider"] not in providers: provider = ad["data"]["online_provider"]
if self.platform == "lbtc":
provider_test = self.map_provider(provider)
else:
provider_test = provider
if provider_test not in providers:
continue continue
date_last_seen = ad["data"]["profile"]["last_online"] date_last_seen = ad["data"]["profile"]["last_online"]
# Check if this person was seen recently # Check if this person was seen recently
@ -328,7 +347,6 @@ class Local(util.Base):
ad_id = ad["data"]["ad_id"] ad_id = ad["data"]["ad_id"]
username = ad["data"]["profile"]["username"] username = ad["data"]["profile"]["username"]
temp_price = ad["data"]["temp_price"] temp_price = ad["data"]["temp_price"]
provider = ad["data"]["online_provider"]
if ad["data"]["currency"] != currency: if ad["data"]["currency"] != currency:
continue continue
to_append = [ad_id, username, temp_price, provider, asset, currency] to_append = [ad_id, username, temp_price, provider, asset, currency]

@ -29,19 +29,6 @@ class LBTC(sources.local.Local):
# Assets that cheat has been run on # Assets that cheat has been run on
self.cheat_run_on = [] self.cheat_run_on = []
def map_provider(self, provider, reverse=False):
provider_map = {"NATIONAL_BANK": "national-bank-transfer"}
if reverse:
try:
return next(key for key, value in provider_map.items() if value == provider)
except StopIteration:
return False
else:
try:
return provider_map[provider]
except KeyError:
return False
@util.handle_exceptions @util.handle_exceptions
def release_funds(self, contact_id): def release_funds(self, contact_id):
""" """

Loading…
Cancel
Save