mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-03-09 18:21:09 +00:00
Factor write_sources into its own function
Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
parent
92fe1724db
commit
329f1901b4
12
britney.py
12
britney.py
@ -216,7 +216,7 @@ from britney_util import (old_libraries_format, same_source, undo_changes,
|
||||
register_reverses, compute_reverse_tree,
|
||||
read_nuninst, write_nuninst, write_heidi,
|
||||
eval_uninst, newly_uninst, make_migrationitem,
|
||||
write_excuses, write_heidi_delta)
|
||||
write_excuses, write_heidi_delta, write_sources)
|
||||
from consts import (VERSION, SECTION, BINARIES, MAINTAINER, FAKESRC,
|
||||
SOURCE, SOURCEVER, ARCHITECTURE, DEPENDS, CONFLICTS,
|
||||
PROVIDES, RDEPENDS, RCONFLICTS, MULTIARCH, ESSENTIAL)
|
||||
@ -911,14 +911,8 @@ class Britney(object):
|
||||
f.close()
|
||||
|
||||
filename = os.path.join(basedir, 'Sources')
|
||||
f = open(filename, 'w')
|
||||
for src in sources:
|
||||
output = "Package: %s\n" % src
|
||||
for key, k in ((VERSION, 'Version'), (SECTION, 'Section'), (MAINTAINER, 'Maintainer')):
|
||||
if not sources[src][key]: continue
|
||||
output += (k + ": " + sources[src][key] + "\n")
|
||||
f.write(output + "\n")
|
||||
f.close()
|
||||
write_sources(sources, filename)
|
||||
|
||||
|
||||
# Utility methods for package analysis
|
||||
# ------------------------------------
|
||||
|
@ -33,7 +33,7 @@ from migrationitem import MigrationItem, UnversionnedMigrationItem
|
||||
|
||||
from consts import (VERSION, BINARIES, PROVIDES, DEPENDS, CONFLICTS,
|
||||
RDEPENDS, RCONFLICTS, ARCHITECTURE, SECTION,
|
||||
SOURCE, SOURCEVER)
|
||||
SOURCE, SOURCEVER, MAINTAINER)
|
||||
|
||||
binnmu_re = re.compile(r'^(.*)\+b\d+$')
|
||||
|
||||
@ -475,3 +475,21 @@ def write_excuses(excuses, dest_file, output_format="yaml"):
|
||||
else:
|
||||
raise ValueError('Output format must be either "yaml or "legacy-html"')
|
||||
|
||||
|
||||
def write_sources(sources_s, filename):
|
||||
"""Write a sources file from Britney's state for a given suite
|
||||
|
||||
Britney discards fields she does not care about, so the resulting
|
||||
file omitts a lot of regular fields.
|
||||
"""
|
||||
|
||||
key_pairs = ((VERSION, 'Version'), (SECTION, 'Section'),
|
||||
(MAINTAINER, 'Maintainer'))
|
||||
|
||||
with open(filename, 'w') as f:
|
||||
for src in sources_s:
|
||||
src_data = sources_s[src]
|
||||
output = "Package: %s\n" % src
|
||||
output += "\n".join(k + ": "+ src_data[key]
|
||||
for key, k in key_pairs if src_data[key])
|
||||
f.write(output + "\n\n")
|
||||
|
Loading…
x
Reference in New Issue
Block a user