gns-deb-diff

automate the documentation of the differences between gNewSense and Debian.
git clone git://git.ricketyspace.net/gns-deb-diff.git
Log | Files | Refs

commit f209589c0fe62a9206a5930b7835cb4be357ba6d
parent 9031933d0ccac9c9732b40b53e7f03eb51fcaafe
Author: rsiddharth <s@ricketyspace.net>
Date:   Tue,  1 Nov 2016 22:57:56 +0000

Add `get_packages` function.

* gd_diff.py (get_packages): New function
* setup.py: Add `beautifulsoup4` and `requests` as installation
requirements; Add `mock` as dev requirements.
* tests/test_gd_diff.py (test_get_packages_error)
(test_get_packages): New functions

Diffstat:
gd_diff.py | 28++++++++++++++++++++++++++++
setup.py | 3++-
tests/test_gd_diff.py | 16++++++++++++++++
3 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/gd_diff.py b/gd_diff.py @@ -11,9 +11,12 @@ import re import shlex import sys +import requests + from os import path from subprocess import run, PIPE +from bs4 import BeautifulSoup # list of recognized fields. field_list = [ @@ -68,6 +71,31 @@ def read_packages(pkgs_file): return pkgs_iter +def get_packages(release): + """Prints out list packages for `release`. + + List of packages is slurped from + http://bzr.savannah.gnu.org/lh/gnewsense/packages-`release` + """ + url = 'http://bzr.savannah.gnu.org/lh/gnewsense/packages-{}/' + req = url.format(release) + + try: + res = requests.get(req) + except ConnectionError as ce: + print('ERROR: Problem GETting {} \n{}'.format(req, ce)) + sys.exit(1) + + if res.status_code != 200: + print('{}: Error GETting {}'.format(res.status_code, req)) + sys.exit(1) + + html_forest = BeautifulSoup(res.text, 'html.parser') + + for td in html_forest.find_all('td', class_='autcell'): + print(td.a.string.strip()) + + def save_gns_readme(content, release, pkg, local_dir): """Save README.gNewsense locally. diff --git a/setup.py b/setup.py @@ -41,8 +41,9 @@ config = { ], 'keywords': 'gNewSense Debian documentation', 'packages': find_packages(), + 'install_requires': ['beautifulsoup4', 'requests'], 'extras_require': { - 'dev': ['nose', 'coverage', 'twine', 'wheel'], + 'dev': ['nose', 'mock', 'coverage', 'twine', 'wheel'], } } diff --git a/tests/test_gd_diff.py b/tests/test_gd_diff.py @@ -10,8 +10,10 @@ import os import subprocess import sys +from io import StringIO from os import path from shutil import rmtree +from unittest import mock from nose.tools import * @@ -73,6 +75,20 @@ class TestGdDiff(object): for pkg in pkgs_iter: assert not ' ' in pkg + @raises(SystemExit) + def test_get_packages_error(self): + res = get_packages('foo_release') + + + def test_get_packages(self): + pkgs = '' + with mock.patch('sys.stdout', new=StringIO()) as output: + get_packages('parkes') + pkgs = output.getvalue() + + assert_equal(pkgs, 'antlr\napt\napt-setup\nautoconf\nautoconf2.59\nautoconf2.64\nbacula\nbase-files\nbase-installer\nbatik\ncairomm\ncdebootstrap\ncfitsio3\nchoose-mirror\nclaws-mail\ndb4.6\ndb4.7\ndb4.8\ndebian-cd\ndebian-edu\ndebian-installer\ndebian-installer-launcher\ndebootstrap\ndesktop-base\ndoc-linux\ndoc-linux-hr\ndoc-linux-it\ndoc-linux-ja\ndoc-linux-pl\nenscript\nepiphany-browser\nfop\nfreetype\ngalaxia\ngdm3\nglibmm2.4\ngnewsense-archive-keyring\ngnome-desktop\ngtkmm2.4\nicedove\niceweasel\nkde4libs\nkdebase\nkdebase-workspace\nkdenetwork\nkernel-wedge\nlensfun\nliferea\nlintian\nlinux-2.6\nlinux-kernel-di-amd64-2.6\nlinux-kernel-di-i386-2.6\nlinux-latest-2.6\nlive-build\nlive-config\nmeta-gnome2\nmplayer\nnet-retriever\nobjcryst-fox\nopenbox-themes\nopenjdk-6\nopenoffice.org\npangomm\nperl-tk\npkgsel\npopularity-contest\npsutils\npython-apt\nscreenlets\nsip4-qt3\nsoftware-center\ntcl8.4\ntcl8.5\ntexlive-extra\ntk8.4\ntk8.5\nupdate-manager\nvim\nwmaker\nxchat\nxdm\nxorg-server\nxserver-xorg-video-siliconmotion\nyeeloong-base\n') + + def test_save_gns_readme(self): cmd = 'bzr cat bzr://bzr.sv.gnu.org/gnewsense/packages-parkes/antlr/debian/README.gNewSense' cp = execute(cmd, out=subprocess.PIPE)