mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-06-08 08:11:33 +00:00
Support writing excuses YAML to xz and gz files
This commit is contained in:
parent
65351ba511
commit
c9d45ecb2b
@ -311,7 +311,14 @@ def write_excuses(excuses, dest_file, output_format="yaml"):
|
|||||||
excuselist = sorted(excuses.values(), key=lambda x: x.sortkey())
|
excuselist = sorted(excuses.values(), key=lambda x: x.sortkey())
|
||||||
if output_format == "yaml":
|
if output_format == "yaml":
|
||||||
os.makedirs(os.path.dirname(dest_file), exist_ok=True)
|
os.makedirs(os.path.dirname(dest_file), exist_ok=True)
|
||||||
with open(dest_file, 'w', encoding='utf-8') as f:
|
opener = open
|
||||||
|
if dest_file.endswith('.xz'):
|
||||||
|
import lzma
|
||||||
|
opener = lzma.open
|
||||||
|
elif dest_file.endswith('.gz'):
|
||||||
|
import gzip
|
||||||
|
opener = gzip.open
|
||||||
|
with opener(dest_file, 'wt', encoding='utf-8') as f:
|
||||||
edatalist = [e.excusedata(excuses) for e in excuselist]
|
edatalist = [e.excusedata(excuses) for e in excuselist]
|
||||||
excusesdata = {
|
excusesdata = {
|
||||||
'sources': edatalist,
|
'sources': edatalist,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user