From 47752597d1ac4dcf0f7edd132869e32ad900955b Mon Sep 17 00:00:00 2001 Message-Id: <47752597d1ac4dcf0f7edd132869e32ad900955b.1715189400.git.mdw@distorted.org.uk> From: Mark Wooding Date: Thu, 28 Mar 2013 00:05:33 +0000 Subject: [PATCH 1/1] agpl.py (dump_dir): Replace unpleasant control-flow variable with an escape. Organization: Straylight/Edgeware From: Mark Wooding If only Python had a proper `goto'. --- agpl.py | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/agpl.py b/agpl.py index caed713..a35ea3f 100644 --- a/agpl.py +++ b/agpl.py @@ -198,28 +198,27 @@ def dump_dir(name, dir, dirmap, tf, root): ## Work through each file. for file in lister(dir): - full = OS.path.join(dir, file) - tarname = OS.path.join(root, name, file) - skip = False - - ## Check for symbolic links. If we find one that points to another - ## directory we're going to dump separately then fiddle it so that it - ## works in the directory tree we're going to make. - if OS.path.islink(full): - dest = OS.path.realpath(full) - for d, local in dirmap: - if dest.startswith(d): - fix = OS.path.relpath(OS.path.join('/', local, dest[len(d):]), - OS.path.join('/', name, - OS.path.dirname(file))) - st = OS.stat(full) - ti = tf.gettarinfo(full, tarname) - ti.linkname = fix - tf.addfile(ti) - skip = True - - ## Nothing special, so just dump the file. Or whatever it is. - if not skip: + with U.Escape() as skip: + full = OS.path.join(dir, file) + tarname = OS.path.join(root, name, file) + + ## Check for symbolic links. If we find one that points to another + ## directory we're going to dump separately then fiddle it so that it + ## works in the directory tree we're going to make. + if OS.path.islink(full): + dest = OS.path.realpath(full) + for d, local in dirmap: + if dest.startswith(d): + fix = OS.path.relpath(OS.path.join('/', local, dest[len(d):]), + OS.path.join('/', name, + OS.path.dirname(file))) + st = OS.stat(full) + ti = tf.gettarinfo(full, tarname) + ti.linkname = fix + tf.addfile(ti) + skip() + + ## Nothing special, so just dump the file. Or whatever it is. tf.add(full, tarname, recursive = False) def source(out): -- [mdw]