Source: python-popcon Version: 1.4 Severity: wishlist Tags: patch X-Debbugs-Cc: Mattia Rizzolo <mat...@debian.org>
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Hi Bastian, thanks for writing and maintaining python-popcon, it's a nice and useful library. Also having a /usr/bin/popcon is helpful. I just noticed that the output of the script is a bit terse (both the format and that it only shows the totals), so I thought it might be worth to have a some more verbose variant. I came up with a first draft, but as I hardly speak any Python, I asked for help, and mapreri kindly sat down and integrated my ideas into something which supposedly matches what other Python code and packages in Debian do :) [Thanks again!] What the diff does is to add a '-v' option to the script in popcon/__main__.py, which outputs, optionally coloured, the total and separate popcon values of a package. The rest is housekeeping for the package (recommends). I hope you like the idea and can either apply our work or use it as a base. Cheers, gregor -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEE0eExbpOnYKgQTYX6uzpoAYZJqgYFAmKORFFfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldEQx RTEzMTZFOTNBNzYwQTgxMDREODVGQUJCM0E2ODAxODY0OUFBMDYACgkQuzpoAYZJ qgbEvA//aGgG383gTb7dn1aM1dDW1oz6BGZuv/pLUAh5E7DOtLlM716yLY7DQ8gK mzySVAWy0L6bFAwNQDnppBcovbBjpydCvht4IBXGAzR/mBxDeI0h3btDIBZpP9u9 iyyY8Pv6ccxGYWj5rINdR8WfIudYNkn/qQGc3+Wh/7v4tSaqLx30mC1cdamXsf/A A/bYkKAEaMfvDqoDtzheo0v54yT0feTfqjf4hzygpwH1BC1Vp5CbZNqKIug0Htuf DWSdOePzBlKxmkK9YiMQC4Em4ewwe3MOtu7sAh2bpgMrCvr5VELJDg753ibd3TsB ICeEIkbGwGZl4WmhcFkvh3EuTQk203I+JL1Hk4CzaWQjqrag6gF/SzrPxUHk2vVi Ep80wkl0zJGWrgrPHHCtcXRqtx+vHEuCuF20J0Z6d+wrB9HKrLkIRxliy6KqxF9u 2kqE0324kvitONKRzbiMPzU0cIN2yl4oQbN+3k9jraIqgvKV1FMM7e87pP3eUnf5 cuAgwJjZBDWiAYdrFEn+Qk0JVZTyplyDxC6aQgKxJliuOJynzvTorG6b3zD7yPgm 3ALpPuRNp46N4+slIWeGDFsuZZ3dxD1zQf9sXzH2MakRAAqHUReClhoez+1MvGSj HxnUAZT5eiPPOIrFlAsGx4hUwXMrkAgoTYX839/IqIc4pCQY1y8= =U90f -----END PGP SIGNATURE-----
diff --git a/debian/changelog b/debian/changelog index 0b94411..f2bd813 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-popcon (2.0.4+nmu1) UNRELEASED; urgency=medium + + * Non-maintainer upload. + * Add -v option to /usr/bin/popcon. + + -- Mattia Rizzolo <mat...@debian.org> Wed, 25 May 2022 15:44:19 +0200 + python-popcon (2.0.4) unstable; urgency=medium * updated debian's build system diff --git a/debian/control b/debian/control index a6eef1c..b0aab59 100644 --- a/debian/control +++ b/debian/control @@ -1,7 +1,7 @@ Source: python-popcon Priority: optional Maintainer: Bastian Venthur <vent...@debian.org> -Build-Depends: debhelper-compat (= 12), dh-python, python3, python3-setuptools +Build-Depends: debhelper-compat (= 12), dh-python, python3, python3-setuptools, python3-termcolor Standards-Version: 4.1.1 Section: python Vcs-Git: https://github.com/venthur/python-popcon.git @@ -10,6 +10,7 @@ Vcs-Browser: https://github.com/venthur/python-popcon Package: python3-popcon Architecture: all Depends: ${misc:Depends}, ${python3:Depends} +Recommends: ${python3:Recommends} Description: Python interface to Debian's Popularity Contest (popcon) This package provides the popcon module for Python 3 and the popcon CLI, which allows one to query Debian's Popularity Contest data. diff --git a/debian/rules b/debian/rules index 6f20359..23f2d62 100755 --- a/debian/rules +++ b/debian/rules @@ -13,3 +13,6 @@ export PYBUILD_NAME=popcon %: dh $@ --with python3 --buildsystem=pybuild + +override_dh_python3: + dh_python3 --recommends-section=colors diff --git a/popcon/__main__.py b/popcon/__main__.py index 641ac72..a35fbe1 100644 --- a/popcon/__main__.py +++ b/popcon/__main__.py @@ -1,14 +1,47 @@ import sys -from popcon import packages +from popcon import packages, packages_raw + +try: + from termcolor import colored, cprint + COLOR = True +except ImportError: + def colored(arg): + return arg + COLOR = False def main(): if len(sys.argv) == 1: - raise RuntimeError('No package name given') + print('Error: no package name given', file=sys.stderr) + sys.exit(1) + elif sys.argv[1] == '-v': + verbose_output = True + sys.argv.pop(1) + else: + verbose_output = False + if len(sys.argv) > 2: + print('Warning: arguments after the first ignored', file=sys.stderr) + pkg = sys.argv[1] - print(pkg) - print(packages([pkg])) + if verbose_output: + return(verbose(pkg)) + else: + print(pkg) + print(packages([pkg])) + + +def verbose(pkg): + if COLOR: + cprint(f"Popcon for src:{pkg}", "cyan") + else: + print(f"Popcon for src:{pkg}") + values = packages_raw([pkg])[pkg] + print('+ vote: {}'.format(colored(values.vote, 'green'))) + print(f'+ old: {values.old}') + print(f'+ recent-ctime (upgrades): {values.recent}') + print(f'+ no-files (atime=ctime=0): {values.no_files}') + print('= installed: {}'.format(colored(sum(values), 'magenta'))) if __name__ == '__main__': diff --git a/setup.py b/setup.py index 945df6d..1995a9a 100644 --- a/setup.py +++ b/setup.py @@ -18,6 +18,9 @@ setup( license='GPL2', packages=['popcon'], python_requires='>=3.6, <4', + extras_require={ + "colors": "termcolor", + }, entry_points={ 'console_scripts': [ 'popcon = popcon.__main__:main'