from daklib.dbconn import *
from daklib.config import Config
+from daklib.filewriter import BinaryContentsFileWriter
from multiprocessing import Pool
from shutil import rmtree
}
if self.component is not None:
values['component'] = self.component.component_name
- return BinaryContentsWriter(values)
+ return BinaryContentsFileWriter(**values)
def get_header(self):
'''
'''
Base class for compressed and uncompressed file writing.
'''
- def __init__(template, **keywords):
+ def __init__(self, template, **keywords):
'''
The template argument is a string template like
"dists/%(suite)s/%(component)s/Contents-%(architecture)s.gz" that
'''
Returns a file object for writing.
'''
- self.file = open(self.path + '.new')
+ self.file = open(self.path + '.new', 'w')
+ return self.file
# internal helper function
def rename(self, filename):
if self.uncompressed:
self.rename(self.path)
else:
- os.unlink(self.path)
+ os.unlink(self.path + '.new')
-class BinaryContentsWriter(BaseFileWriter):
- def __init__(**keywords):
+class BinaryContentsFileWriter(BaseFileWriter):
+ def __init__(self, **keywords):
'''
The value of the keywords suite, component, and architecture are
strings. The value of component may be omitted if not applicable.
}
flags.update(keywords)
if 'component' in flags:
- template "dists/%(suite)s/%(component)s/Contents-%(architecture)s.gz" % values
+ template = "dists/%(suite)s/%(component)s/Contents-%(architecture)s"
else:
- template = "dists/%(suite)s/Contents-%(architecture)s.gz" % values
+ template = "dists/%(suite)s/Contents-%(architecture)s"
BaseFileWriter.__init__(self, template, **flags)