Merge pull request #387 from lbryio/wallet-whitespace

cleanup whitespace for increased readability
This commit is contained in:
Job Evers‐Meltzer 2017-01-06 08:20:06 -06:00 committed by GitHub
commit 69c0da695b

View file

@ -502,7 +502,9 @@ class Wallet(object):
def get_claim(self, name, claim_id):
d = self.get_claims_for_name(name)
d.addCallback(lambda claims: next(claim for claim in claims['claims'] if claim['claimId'] == claim_id))
d.addCallback(
lambda claims: next(
claim for claim in claims['claims'] if claim['claimId'] == claim_id))
return d
def get_claimid(self, name, txid, nout):
@ -511,8 +513,13 @@ class Wallet(object):
return defer.succeed(claim_id)
else:
d = self.get_claims_from_tx(txid)
d.addCallback(lambda claims: next(c for c in claims if c['name'] == name and c['nOut'] == claim_outpoint['nout']))
d.addCallback(lambda claim: self._update_claimid(claim['claimId'], name, ClaimOutpoint(txid, claim['nOut'])))
d.addCallback(
lambda claims: next(
c for c in claims if c['name'] == name and
c['nOut'] == claim_outpoint['nout']))
d.addCallback(
lambda claim: self._update_claimid(
claim['claimId'], name, ClaimOutpoint(txid, claim['nOut'])))
return d
claim_outpoint = ClaimOutpoint(txid, nout)
d = self._get_claimid_for_tx(name, claim_outpoint)
@ -526,10 +533,14 @@ class Wallet(object):
claim['value'] = json.loads(claim['value'])
return claim
def _get_my_unspent_claim(claims):
for claim in claims:
if claim['name'] == name and not claim['is spent'] and claim['category'] != 'support':
is_unspent = (
claim['name'] == name and
not claim['is spent'] and
not claim.get('supported_claimid', False)
)
if is_unspent:
return claim
return False
@ -556,8 +567,10 @@ class Wallet(object):
result['txid'] = claim['txid']
result['nout'] = claim['n']
result['value'] = metadata if metadata else json.loads(claim['value'])
result['supports'] = [{'txid': support['txid'], 'n': support['n']} for support in claim['supports']]
result['meta_version'] = meta_version if meta_version else result['value'].get('ver', '0.0.1')
result['supports'] = [
{'txid': support['txid'], 'n': support['n']} for support in claim['supports']]
result['meta_version'] = (
meta_version if meta_version else result['value'].get('ver', '0.0.1'))
return result
def _get_claim_info(self, name, claim_outpoint):
@ -576,8 +589,9 @@ class Wallet(object):
claim,
metadata=metadata,
meta_version=meta_ver))
log.debug("get claim info lbry://%s metadata: %s, claimid: %s", name, meta_ver, claim['claimId'])
log.info(
"get claim info lbry://%s metadata: %s, claimid: %s",
name, meta_ver, claim['claimId'])
return d
d = self.get_claimid(name, claim_outpoint['txid'], claim_outpoint['nout'])
@ -603,7 +617,8 @@ class Wallet(object):
raise Exception(msg)
claim_out.pop('success')
claim_outpoint = ClaimOutpoint(claim_out['txid'], claim_out['nout'])
log.debug("Saving metadata for claim %s %d" % (claim_outpoint['txid'], claim_outpoint['nout']))
log.info("Saving metadata for claim %s %d",
claim_outpoint['txid'], claim_outpoint['nout'])
d = self._save_name_metadata(name, claim_outpoint, metadata['sources']['lbry_sd_hash'])
d.addCallback(lambda _: claim_out)
return d
@ -616,9 +631,10 @@ class Wallet(object):
log.debug("Updating over own claim")
d = self.update_metadata(metadata, claim['value'])
claim_outpoint = ClaimOutpoint(claim['txid'], claim['nOut'])
d.addCallback(lambda new_metadata: self._send_name_claim_update(name, claim['claim_id'],
claim_outpoint,
new_metadata, _bid))
d.addCallback(
lambda new_metadata: self._send_name_claim_update(name, claim['claim_id'],
claim_outpoint,
new_metadata, _bid))
return d
meta = Metadata(m)
@ -997,6 +1013,8 @@ class LBRYumWallet(Wallet):
# run commands as a deferToThread, lbryum commands that only make
# queries to lbryum server should be run this way
# TODO: keep track of running threads and cancel them on `stop`
# otherwise the application will hang, waiting for threads to complete
def _run_cmd_as_defer_to_thread(self, command_name, *args):
cmd_runner = self._get_cmd_runner()
cmd = known_commands[command_name]