diff options
| author | Mark McLoughlin <markmc@redhat.com> | 2013-03-01 11:17:43 +0000 |
|---|---|---|
| committer | Mark McLoughlin <markmc@redhat.com> | 2013-03-01 11:17:43 +0000 |
| commit | afcf037b8f5d4cf55f4ac70e26729c6571efb396 (patch) | |
| tree | 741509c280be884608a836b80b8afa2f70eb9496 | |
| parent | d5a07c4306ea8f44aaab66d4553f37b90f88bb94 (diff) | |
| download | oslo-afcf037b8f5d4cf55f4ac70e26729c6571efb396.tar.gz oslo-afcf037b8f5d4cf55f4ac70e26729c6571efb396.tar.xz oslo-afcf037b8f5d4cf55f4ac70e26729c6571efb396.zip | |
update.py: DRY up using functools.partial()
We call _copy_pyfile() a bunch of times with the same base and
dest_dir arguments. Clean that up using functools.partial().
Change-Id: I22a3e748f2e138b17a6b99d90ec9eca72698f6e7
| -rw-r--r-- | update.py | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -55,6 +55,7 @@ the modules to copy and the base destination module Obviously, the first way is the easiest! """ +import functools import glob import os import os.path @@ -169,23 +170,26 @@ def _copy_module(mod, base, dest_dir): print ("Copying openstack.common.%s under the %s module in %s" % (mod, base, dest_dir)) + copy_pyfile = functools.partial(_copy_pyfile, + base=base, dest_dir=dest_dir) + if '.' in mod: path = _mod_to_path('openstack.common') for d in mod.split('.')[:-1]: path = os.path.join(path, d) - _copy_pyfile(os.path.join(path, '__init__.py'), base, dest_dir) + copy_pyfile(os.path.join(path, '__init__.py')) mod_path = _mod_to_path('openstack.common.%s' % mod) mod_file = '%s.py' % mod_path if os.path.isfile(mod_file): - _copy_pyfile(mod_file, base, dest_dir) + copy_pyfile(mod_file) elif os.path.isdir(mod_path): dest = os.path.join(dest_dir, _mod_to_path(base), 'openstack', 'common', mod) _make_dirs(dest) sources = filter(lambda x: x[-3:] == '.py', os.listdir(mod_path)) for s in sources: - _copy_pyfile(os.path.join(mod_path, s), base, dest_dir) + copy_pyfile(os.path.join(mod_path, s)) globs_to_copy = [ os.path.join('bin', 'oslo-' + mod + '*'), |
