Reduce nest of _update_user()

In _update_user(), if sequence numbers are set and the same,
the merger of user profiles is not needed and just return
user_e. This patch makes the method just return the value
directly by reducing nest for the cleanup.

Change-Id: Ibeeb9e079589772d09a894267b755ae002a7ec64
This commit is contained in:
Ken'ichi Ohmichi
2017-06-20 14:30:29 -07:00
parent f7c1c27edf
commit 2639d52470

View File

@@ -283,25 +283,25 @@ class RecordProcessor(object):
if ((user_e.get('seq') == user_l.get('seq') == user_g.get('seq') ==
user_z.get('seq')) and user_e.get('seq')):
# sequence numbers are set and the same, merge is not needed
user = user_e
# If sequence numbers are set and the same, merge is not needed
return user_e
user = self._create_user(launchpad_id, email, gerrit_id, zanata_id,
user_name)
if user_e or user_l or user_g or user_z:
user = self._merge_user_profiles(
[user_e, user_l, user_g, user_z, user])
else:
user = self._create_user(launchpad_id, email, gerrit_id, zanata_id,
user_name)
# create new
if (self._need_to_fetch_launchpad() and not user_name):
user_name = self._get_lp_user_name(launchpad_id)
if user_name:
user['user_name'] = user_name
LOG.debug('Created new user: %s', user)
if user_e or user_l or user_g or user_z:
user = self._merge_user_profiles(
[user_e, user_l, user_g, user_z, user])
else:
# create new
if (self._need_to_fetch_launchpad() and not user_name):
user_name = self._get_lp_user_name(launchpad_id)
if user_name:
user['user_name'] = user_name
LOG.debug('Created new user: %s', user)
user_processor.store_user(self.runtime_storage_inst, user)
LOG.debug('Stored user: %s', user)
user_processor.store_user(self.runtime_storage_inst, user)
LOG.debug('Stored user: %s', user)
return user