Refactor function safecopy().
authorHuang Hao <hao.h.huang@intel.com>
Wed, 6 Mar 2013 03:04:37 +0000 (11:04 +0800)
committerGerrit Code Review <gerrit2@otctools.jf.intel.com>
Tue, 12 Mar 2013 02:37:19 +0000 (19:37 -0700)
commit83e3dc8a095ac6fd20e3680f50b2f0a0af091943
tree40dde4cc0ea52894bfb215e26c0055c2809a4d0c
parentbbdcae8f31aad3fdcaae6ac96dd8277285d347d1
Refactor function safecopy().

* Change ignore_ptns from [] to (). A mutable default value isn't
as expected when invoke in the second time.
>>> def safecopy(ignore_ptns=[]):
...     ignore_ptns += ['*.pyc']
...     print ignore_ptns
...
>>> safecopy()
['*.pyc']
>>> safecopy()
['*.pyc', '*.pyc']

* Add a list into ignore_ptns rather than a string
>>> l = []
>>> l += os.path.basename('/usr/bin')
>>> l
['b', 'i', 'n']

* Include all exception classes by (), otherwise it will catch
OSError and assign this exception instance to a local variable
named IOError.
* Move shutil.ignore_patterns() out of try block since it can
never throw OSError nor IOError.
* Remove useless try/except/raise block which catches every
error but reraise it. It's the same as without this try block.

Change-Id: I8837169bbf4acbadf4a2cfd8ac999d371831d86a
mic/rt_util.py