aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDafydd Harries <daf@rhydd.org>2013-03-20 19:36:31 -0400
committerDafydd Harries <daf@rhydd.org>2013-03-20 19:36:31 -0400
commit5116d66561f188a7098be0f9b99b8ddb71ae0fc5 (patch)
tree4317102ae525720cfac4a0189be411d78083629f
parent31939dedc3286dd9bcfdd21a75d760b0ed5cedeb (diff)
refactor export_all()
Make file output separate, so that we can output to different formats.
-rw-r--r--export.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/export.py b/export.py
index 9adfd62..1198f82 100644
--- a/export.py
+++ b/export.py
@@ -296,12 +296,6 @@ def uname_srcpkgs(data, name):
return srcpkg_names
def export_all(data):
- outputdir = 'output'
- index = {}
-
- if not os.path.exists(outputdir):
- os.makedirs(outputdir)
-
# First, find all upstream names and the source packages corresponding
# to them.
@@ -326,12 +320,21 @@ def export_all(data):
warn('bad name: %r' % name)
continue
+ # Generator; exceptions are delayed.
+ templates = export_srcpkgs(data, name, srcpkgs)
+ yield (name, templates)
+
+def export_all_to_directory(data, outputdir):
+ index = {}
+
+ if not os.path.exists(outputdir):
+ os.makedirs(outputdir)
+
+ for (name, templates) in export_all(data):
print (name.encode('utf8') if isinstance(name, unicode) else name)
fname = filename(name)
path = os.path.join(outputdir, fname)
index[fname] = {'page': name, 'file': fname}
- # Generator; exceptions are delayed.
- templates = export_srcpkgs(data, name, srcpkgs)
try:
output(path, templates)
@@ -346,7 +349,7 @@ def main():
args = sys.argv[1:]
if len(args) == 0:
- export_all(data)
+ export_all_to_directory(data, 'output')
elif len(args) == 1:
# XXX: assumes argument is an upstream name
uname = args[0]