/usr/lib/python3/dist-packages/decopy/output.py is in decopy 0.2.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | #!/usr/bin/env python3
# -*- coding: utf-8 -*- vim60:fdm=marker
#
# Copyright: 2016, Maximiliano Curia <maxy@debian.org>
#
# License: ISC
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
# .
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
from __future__ import print_function
import logging
import sys
from contextlib import contextmanager
from .datatypes import License
@contextmanager
def open_output_file(filename):
if filename:
with open(filename, 'wt', encoding='utf-8') as f:
yield f
else:
yield sys.stdout
def _generate_header(copyright_, f, options):
if options.mode == 'partial':
paragraph = ('Format: '
'http://www.debian.org/doc/packaging-manuals/'
'copyright-format/1.0/\n'
'Comment: *** only: {} ***'.format(
', '.join(options.files)))
elif copyright_:
paragraph = copyright_.header.dump().rstrip('\n')
else:
paragraph = ('Format: '
'http://www.debian.org/doc/packaging-manuals/'
'copyright-format/1.0/')
print(paragraph, file=f)
print(file=f)
if options.output:
logging.debug('Generated header:\n%s', paragraph)
def generate_output(groups, filetree, copyright_, options):
# Track the licenses that are in use
licenses = set()
with open_output_file(options.output) as f:
# Print header
_generate_header(copyright_, f, options)
# Avoid printing 'Files: *' when working in partial mode
if options.mode == 'partial':
for item in options.files:
if not filetree[item].parent:
continue
filetree[item].parent.tally()
# Print files paragraphs
for _, group in sorted(
groups.items(), key=lambda i: i[1].sort_key()):
if not group.copyright_block_valid():
continue
licenses.update(group.licenses.keys())
paragraph = group.copyright_block()
print(paragraph, file=f)
print(file=f)
if options.output:
logging.debug('Generated group:\n%s', paragraph)
# Print license paragraphs
for key in sorted(licenses):
license_ = License.get(key)
paragraph = str(license_)
print(paragraph, file=f)
print(file=f)
if options.output:
logging.debug('Generated license block:\n%s', paragraph)
|