(Steve Dougherty)
2013-06-04: Refactor variable names for conciseness. Refactor variable names for conciseness.
diff --git a/infocalypse/wot.py b/infocalypse/wot.py --- a/infocalypse/wot.py +++ b/infocalypse/wot.py @@ -16,16 +16,16 @@ def resolve_own_identity(ui, nickname_pr """ ui.status("Querying WoT for own identities.\n") node = fcp.FCPNode() - own_response =\ + response =\ node.fcpPluginMessage(async=False, plugin_name="plugins.WebOfTrust.WebOfTrust", plugin_params={'Message': 'GetOwnIdentities'})[0] - if own_response['header'] != 'FCPPluginReply' or\ - 'Replies.Message' not in own_response or\ - own_response['Replies.Message'] != 'OwnIdentities': - ui.warn("Unexpected reply. Got {0}\n.".format(own_response)) + if response['header'] != 'FCPPluginReply' or\ + 'Replies.Message' not in response or\ + response['Replies.Message'] != 'OwnIdentities': + ui.warn("Unexpected reply. Got {0}\n.".format(response)) return # TODO: Single function to resolve identity used for own and remote? @@ -35,15 +35,15 @@ def resolve_own_identity(ui, nickname_pr prefix = 'Replies.Nickname' nickname = None id_num = -1 - for key in own_response.iterkeys(): + for key in response.iterkeys(): if key.startswith(prefix) and\ - own_response[key].startswith(nickname_prefix): + response[key].startswith(nickname_prefix): if nickname is not None: # More than one matched. ui.warn("Prefix '{0}' is ambiguous.\n".format(nickname_prefix)) return - nickname = own_response[key] + nickname = response[key] # Key is Replies.Nickname<number>, where number is used in # the other attributes returned for that identity. id_num = key[len(prefix):] @@ -53,12 +53,12 @@ def resolve_own_identity(ui, nickname_pr return # Return properties for the selected identity. (by number) - results = {} + result = {} for item in [ 'Nickname', 'InsertURI','RequestURI', 'Identity' ]: - results[item] = own_response['Replies.{0}{1}'.format(item, id_num)] + result[item] = response['Replies.{0}{1}'.format(item, id_num)] # LCWoT also puts these things as properties, which would be nicer to # depend on and would allow just returning all properties for the identity. #property_prefix = "Replies.Properties{0}".format(id_num) - return results + return result