On 05/ 5/11 12:46 PM, Drew Fisher wrote:
On 5/5/11 1:40 PM, Keith Mitchell wrote:
cpio.py:
Any reason to not just make the line "else:"?
I don't see one. I also streamlined the code a bit:
if not self.dry_run:
for item in trans.get(CONTENTS):
entry = os.path.join(self.dst, item.rstrip())
try:
if os.path.isdir(item):
shutil.rmtree(entry)
else:
os.unlink(entry)
except OSError:
# If the item isn't there that's what we
# wanted anyway so just continue.
pass
That seems a bit of a big hammer.
If you actually wanted to check to see if it was a simple case of not
existing, you'd have to do something like this:
except OSError, e:
if hasattr(e, "errno") and e.errno != errno.ENOENT:
raise
It's not as easy for rmtree(); there's a long sordid story behind it's
crappy error handling.
-Shawn
_______________________________________________
caiman-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/caiman-discuss