aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDafydd Harries <daf@rhydd.org>2013-03-18 19:33:28 -0400
committerDafydd Harries <daf@rhydd.org>2013-03-18 19:33:28 -0400
commit300f632be6bfcbd732b1ea18c86ac14edad39e30 (patch)
tree1f948587940de1c50611f7b7f049f0029fa360b1
parent590f15910bf32957feacab33567e9ab91e6eaefb (diff)
move bulk export to separate function
-rw-r--r--export.py48
1 files changed, 26 insertions, 22 deletions
diff --git a/export.py b/export.py
index f76394e..9601d97 100644
--- a/export.py
+++ b/export.py
@@ -254,39 +254,43 @@ def output(path, xs):
for x in xs:
f.write(str(x) + '\n')
-def main():
- data = PkgData()
- args = sys.argv[1:]
+def export_all(data):
outputdir = 'output'
if not os.path.exists(outputdir):
os.makedirs(outputdir)
- if len(args) == 0:
- # First, find all upstream names and the source packages corresponding
- # to them.
+ # First, find all upstream names and the source packages corresponding
+ # to them.
+
+ unames = set(data.cps['Upstream-Name'].dropna())
- unames = set(data.cps['Upstream-Name'].dropna())
+ for uname in unames:
+ if not uname:
+ continue
- for uname in unames:
- if not uname:
- continue
+ uname = uname.encode('utf8')
+ print uname
+ fname = os.path.join(outputdir, filename(uname))
+ output(fname, export(data, uname))
- uname = uname.encode('utf8')
- print uname
- fname = os.path.join(outputdir, filename(uname))
- output(fname, export(data, uname))
+ # For source packages with no upstream name, use the source package
+ # name as the upstream name.
- # For source packages with no upstream name, use the source package
- # name as the upstream name.
+ no_uname = set(data.cps[
+ data.cps['Upstream-Name'].isnull()]['_srcpkg'])
- no_uname = set(data.cps[
- data.cps['Upstream-Name'].isnull()]['_srcpkg'])
+ for srcpkg in no_uname:
+ print srcpkg
+ fname = os.path.join(outputdir, filename(srcpkg))
+ output(fname, export_srcpkgs(data, srcpkg, [srcpkg]))
- for srcpkg in no_uname:
- print srcpkg
- fname = os.path.join(outputdir, filename(srcpkg))
- output(fname, export_srcpkgs(data, srcpkg, [srcpkg]))
+def main():
+ data = PkgData()
+ args = sys.argv[1:]
+
+ if len(args) == 0:
+ export_all(data)
elif len(args) == 1:
# XXX: assumes argument is an upstream name
for template in export(data, args[0]):