Skip to content

Commit

Permalink
Port simplechanges to python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
bersace committed Dec 27, 2021
1 parent 22554dc commit 676516e
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions packaging/deb/simplechanges
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ from tempfile import mkdtemp

logger = logging.getLogger('simplechanges')

PY2 = sys.version_info < (3,)


@contextmanager
def tmpdir():
Expand Down Expand Up @@ -103,10 +105,16 @@ def generate_changes(controls, filename, filesize, md5, sha1, sha256):
k: v for k, v in controls.items()
if k in {'Architecture', 'Description', 'Maintainer', 'Version'}
})
changes['Changed-By'] = u"%s <%s>" % (
os.environ['DEBFULLNAME'].decode('utf-8'),
os.environ['DEBEMAIL'].decode('utf-8'),
)
if PY2:
changes['Changed-By'] = u"%s <%s>" % (
os.environ['DEBFULLNAME'].decode('utf-8'),
os.environ['DEBEMAIL'].decode('utf-8'),
)
else:
changes['Changed-By'] = u"%s <%s>" % (
os.environ['DEBFULLNAME'],
os.environ['DEBEMAIL'],
)
changes['Changes'] = CHANGELOG_FMT % changes
changes['Files'] = [u' '.join([
md5,
Expand Down Expand Up @@ -144,7 +152,9 @@ def main():
)

for payload in format(changes):
sys.stdout.write(payload.encode('utf-8'))
if PY2:
payload = payload.encode('UTF-8')
sys.stdout.write(payload)
logger.info(".changes generated for %s.", deb)

sys.exit(0)
Expand Down

0 comments on commit 676516e

Please sign in to comment.