Skip to content

Instantly share code, notes, and snippets.

@zhsj
Created August 7, 2017 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhsj/f9d38b702245ae51c9685feaf56de7a7 to your computer and use it in GitHub Desktop.
Save zhsj/f9d38b702245ae51c9685feaf56de7a7 to your computer and use it in GitHub Desktop.
import debian.deb822
import debian.copyright
import debian.changelog
with open('debian/control', 'r') as f:
ctrl_p = list(debian.deb822.Deb822.iter_paragraphs(f))
with open('debian/copyright', 'r') as f:
copyright = debian.copyright.Copyright(f)
with open('debian/changelog', 'r') as f:
changelog = debian.changelog.Changelog(f)
pkg_name, version, author, url, license, desc, long_desc, maint = ['']*8
for p in ctrl_p[:2]:
for k,v in p.items():
if k == 'Description':
lines = v.splitlines()
desc = lines[0]
long_desc = '\n'.join(lines[1:])
if k == 'Source':
pkg_name = v
if k == 'Homepage':
url = v
p = copyright.find_files_paragraph('*')
license = p.license.synopsis
author = p.copyright
version = changelog.upstream_version
maint = changelog.author
tmpl = '''
From: {maint}
To: submit@bugs.debian.org
Subject: ITP: {pkg_name} -- {desc}
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Debbugs-CC: debian-devel@lists.debian.org
Package: wnpp
Severity: wishlist
Owner: {maint}
* Package name : {pkg_name}
Version : {version}
Upstream Author : {author}
* URL : {url}
* License : {license}
Programming Lang: TODO
Description : {desc}
{long_desc}
'''.format(
pkg_name = pkg_name,
version = version,
author = author,
url = url,
license = license,
desc = desc,
long_desc = long_desc,
maint = maint
)
print(tmpl)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment