diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2014-03-31 17:08:20 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2014-03-31 17:08:20 +0000 |
commit | b32fc9b3e09a61c45dff39809fafe4313fac2c12 (patch) | |
tree | 47d0a02657b843c5f020e39be8ee9f1f89e62c98 | |
parent | 6603d0633de5020c43042bab3aad5bd0a8b1d41e (diff) | |
download | lorry-controller-b32fc9b3e09a61c45dff39809fafe4313fac2c12.tar.gz |
Refactor a long statement to another method
-rw-r--r-- | lorrycontroller/lstroves.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/lorrycontroller/lstroves.py b/lorrycontroller/lstroves.py index d2ca301..20b06aa 100644 --- a/lorrycontroller/lstroves.py +++ b/lorrycontroller/lstroves.py @@ -116,16 +116,7 @@ class TroveRepositoryLister(object): def update_lorries_for_trove(self, statedb, trove_info, repo_map): trovehost = trove_info['trovehost'] for remote_path, local_path in repo_map.items(): - lorry = { - local_path: { - 'type': 'git', - 'url': self.construct_lorry_url(trove_info, remote_path), - 'refspecs': [ - "+refs/heads/*", - "+refs/tags/*", - ], - } - } + lorry = self.construct_lorry(trove_info, local_path, remote_path) statedb.add_to_lorries( path=local_path, text=json.dumps(lorry, indent=4), @@ -140,6 +131,18 @@ class TroveRepositoryLister(object): for local_path in delete_local_paths: statedb.remove_lorry(local_path) + def construct_lorry(self, trove_info, local_path, remote_path): + return { + local_path: { + 'type': 'git', + 'url': self.construct_lorry_url(trove_info, remote_path), + 'refspecs': [ + "+refs/heads/*", + "+refs/tags/*", + ], + } + } + def construct_lorry_url(self, trove_info, remote_path): vars = dict(trove_info) vars['remote_path'] = remote_path |