[Python-modules-commits] r15874 - in packages/python-html2text/trunk/debian (12 files)

stefanor at users.alioth.debian.org stefanor at users.alioth.debian.org
Sat Feb 26 11:19:15 UTC 2011


    Date: Saturday, February 26, 2011 @ 11:19:14
  Author: stefanor
Revision: 15874

* Install html2markdown symlink, replacing the html2markdown package.
  (Closes: #614886)
  - Breaks html2markdown << 3.0.1-2.
  - Add html2markdown transitional package.
  - Add html2markdown.1 manpage.
  - Manage html2markdown and html2markdown.1 via alternatives, allowing both
    Python 2 and 3 packages to provide this command.
* optparse.patch: Use optparse for parsing arguments, which also provides
  help.
* utf-output.patch: Encode output in UTF-8.
* Recommend python-feedparser in Python 2 package (not available in Python 3
  yet).

Added:
  packages/python-html2text/trunk/debian/html2markdown.1
  packages/python-html2text/trunk/debian/patches/
  packages/python-html2text/trunk/debian/patches/optparse.patch
  packages/python-html2text/trunk/debian/patches/series
  packages/python-html2text/trunk/debian/patches/utf8-output.patch
  packages/python-html2text/trunk/debian/python-html2text.postinst
  packages/python-html2text/trunk/debian/python-html2text.prerm
  packages/python-html2text/trunk/debian/python3-html2text.postinst
  packages/python-html2text/trunk/debian/python3-html2text.prerm
Modified:
  packages/python-html2text/trunk/debian/changelog
  packages/python-html2text/trunk/debian/control
  packages/python-html2text/trunk/debian/rules

Modified: packages/python-html2text/trunk/debian/changelog
===================================================================
--- packages/python-html2text/trunk/debian/changelog	2011-02-26 09:29:32 UTC (rev 15873)
+++ packages/python-html2text/trunk/debian/changelog	2011-02-26 11:19:14 UTC (rev 15874)
@@ -1,3 +1,20 @@
+python-html2text (3.0.1-2) UNRELEASED; urgency=low
+
+  * Install html2markdown symlink, replacing the html2markdown package.
+    (Closes: #614886)
+    - Breaks html2markdown << 3.0.1-2.
+    - Add html2markdown transitional package.
+    - Add html2markdown.1 manpage.
+    - Manage html2markdown and html2markdown.1 via alternatives, allowing both
+      Python 2 and 3 packages to provide this command.
+  * optparse.patch: Use optparse for parsing arguments, which also provides
+    help.
+  * utf-output.patch: Encode output in UTF-8.
+  * Recommend python-feedparser in Python 2 package (not available in Python 3
+    yet).
+
+ -- Stefano Rivera <stefanor at debian.org>  Fri, 25 Feb 2011 16:09:24 +0200
+
 python-html2text (3.0.1-1) unstable; urgency=low
 
   * New upstream release.

Modified: packages/python-html2text/trunk/debian/control
===================================================================
--- packages/python-html2text/trunk/debian/control	2011-02-26 09:29:32 UTC (rev 15873)
+++ packages/python-html2text/trunk/debian/control	2011-02-26 11:19:14 UTC (rev 15874)
@@ -19,20 +19,33 @@
 Package: python-html2text
 Architecture: all
 Depends: ${misc:Depends}, ${python:Depends}
-Breaks: ${python:Breaks}
+Recommends: python-feedparser
+Breaks: html2markdown (<< 3.0.1-2), ${python:Breaks}
 Description: Python module for converting HTML to Markdown text
  html2text is a Python module that converts a page of HTML into clean,
  easy-to-read plain ASCII text. Better yet, that ASCII also happens to be
  valid Markdown (a text-to-HTML format).
  .
- This package contains the Python 2 version of the library.
+ This package contains the Python 2 version of the library, and a script,
+ html2markdown.
 
 Package: python3-html2text
 Architecture: all
 Depends: ${misc:Depends}, ${python3:Depends}
+Breaks: html2markdown (<< 3.0.1-2)
 Description: Python module for converting HTML to Markdown text (Python3 version)
  html2text is a Python module that converts a page of HTML into clean,
  easy-to-read plain ASCII text. Better yet, that ASCII also happens to be
  valid Markdown (a text-to-HTML format).
  .
- This package contains the Python 3 version of the library.
+ This package contains the Python 3 version of the library, and a script,
+ html2markdown.
+
+Package: html2markdown
+Architecture: all
+Depends:
+ python-html2text (= ${source:Version}) | python3-html2text (= ${source:Version}),
+ ${misc:Depends}
+Description: Dummy upgrade package for merge of html2markdown into python-html2text
+ This is a transitional package and can safely be removed; see the
+ python-html2text and python3-html2text packages instead.

Added: packages/python-html2text/trunk/debian/html2markdown.1
===================================================================
--- packages/python-html2text/trunk/debian/html2markdown.1	                        (rev 0)
+++ packages/python-html2text/trunk/debian/html2markdown.1	2011-02-26 11:19:14 UTC (rev 15874)
@@ -0,0 +1,29 @@
+.TH HTML2MARKDOWN "1" "February 2011" "html2markdown 3.01" "User Commands"
+.SH NAME
+html2markdown \- converts a page of HTML into markdown.
+.SH SYNOPSIS
+.B html2markdown
+[(\fIfilename\fR|\fIurl\fR) [\fIencoding\fR]]
+.SH DESCRIPTION
+\fBhtml2markdown\fR downloads the specified HTML page, and converts it
+to text marked up with markdown.
+The source HTML page may be a local file or remote URL.
+If not specified, it will be read from standard input.
+The output is printed to standard output.
+.P
+If an \fIencoding\fR is specified, it will override any encoding
+information provided by the HTTP Server.
+When not specified, \fBpython-feedparser\fR (if available) will be used
+to determine the source encoding.
+If not available, or when reading local files, the encoding is assumed
+to be UTF-8.
+.SH OPTIONS
+.TP
+\fB\-\-version\fR
+show program's version number and exit
+.TP
+\fB\-h\fR, \fB\-\-help\fR
+show a help message and exit
+.SH AUTHOR
+This manpage was written for Debian, by Stefano Rivera
+<stefanor at debian.org>.

Added: packages/python-html2text/trunk/debian/patches/optparse.patch
===================================================================
--- packages/python-html2text/trunk/debian/patches/optparse.patch	                        (rev 0)
+++ packages/python-html2text/trunk/debian/patches/optparse.patch	2011-02-26 11:19:14 UTC (rev 15874)
@@ -0,0 +1,69 @@
+Description: Use optparse for parsing arguments.
+Author: Stefano Rivera <stefanor at debian.org>
+Forwarded: https://github.com/aaronsw/html2text/pull/3
+Last-Update: 2011-02-25
+--- a/html2text.py
++++ b/html2text.py
+@@ -30,7 +30,7 @@
+     import urllib.request as urllib
+ except:
+     import urllib
+-import re, sys, codecs, types
++import optparse, re, sys, codecs, types
+ 
+ try: from textwrap import wrap
+ except: pass
+@@ -446,28 +446,36 @@
+ 
+ if __name__ == "__main__":
+     baseurl = ''
+-    if sys.argv[1:]:
+-        arg = sys.argv[1]
+-        if arg.startswith('http://') or arg.startswith('https://'):
+-            baseurl = arg
++
++    p = optparse.OptionParser('%prog [(filename|url) [encoding]]')
++    args = p.parse_args()[1]
++    if len(args) > 0:
++        file_ = args[0]
++        encoding = None
++        if len(args) == 2:
++            encoding = args[1]
++        if len(args) > 2:
++            p.error('Too many arguments')
++
++        if file_.startswith('http://') or file_.startswith('https://'):
++            baseurl = file_
+             j = urllib.urlopen(baseurl)
+-            try:
+-                from feedparser import _getCharacterEncoding as enc
+-            except ImportError:
+-                   enc = lambda x, y: ('utf-8', 1)
+             text = j.read()
+-            encoding = enc(j.headers, text)[0]
+-            if encoding == 'us-ascii': encoding = 'utf-8'
++            if encoding is None:
++                try:
++                    from feedparser import _getCharacterEncoding as enc
++                except ImportError:
++                    enc = lambda x, y: ('utf-8', 1)
++                encoding = enc(j.headers, text)[0]
++                if encoding == 'us-ascii':
++                    encoding = 'utf-8'
+             data = text.decode(encoding)
+ 
+         else:
+-            encoding = 'utf8'
+-            if len(sys.argv) > 2:
+-                encoding = sys.argv[2]
+-            try: #Python3
+-                data = open(arg, 'r', encoding=encoding).read()
+-            except TypeError:
+-                data = open(arg, 'r').read().decode(encoding)
++            data = open(file_, 'rb').read()
++            if encoding is None:
++                encoding = 'utf-8'
++            data = data.decode(encoding)
+     else:
+         data = sys.stdin.read()
+     wrapwrite(html2text(data, baseurl))

Added: packages/python-html2text/trunk/debian/patches/series
===================================================================
--- packages/python-html2text/trunk/debian/patches/series	                        (rev 0)
+++ packages/python-html2text/trunk/debian/patches/series	2011-02-26 11:19:14 UTC (rev 15874)
@@ -0,0 +1,2 @@
+optparse.patch
+utf8-output.patch

Added: packages/python-html2text/trunk/debian/patches/utf8-output.patch
===================================================================
--- packages/python-html2text/trunk/debian/patches/utf8-output.patch	                        (rev 0)
+++ packages/python-html2text/trunk/debian/patches/utf8-output.patch	2011-02-26 11:19:14 UTC (rev 15874)
@@ -0,0 +1,20 @@
+Description: Encode output in UTF-8.
+Author: Stefano Rivera <stefanor at debian.org>
+Forwarded: https://github.com/aaronsw/html2text/pull/5
+Last-Update: 2011-02-25
+--- a/html2text.py
++++ b/html2text.py
+@@ -433,7 +433,12 @@
+     
+     def unknown_decl(self, data): pass
+ 
+-def wrapwrite(text): sys.stdout.write(text)
++def wrapwrite(text):
++    text = text.encode('utf-8')
++    try: #Python3
++        sys.stdout.buffer.write(text)
++    except AttributeError:
++        sys.stdout.write(text)
+ 
+ def html2text_file(html, out=wrapwrite, baseurl=''):
+     h = _html2text(out, baseurl)

Added: packages/python-html2text/trunk/debian/python-html2text.postinst
===================================================================
--- packages/python-html2text/trunk/debian/python-html2text.postinst	                        (rev 0)
+++ packages/python-html2text/trunk/debian/python-html2text.postinst	2011-02-26 11:19:14 UTC (rev 15874)
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+    configure)
+        update-alternatives --install /usr/bin/html2markdown html2markdown \
+                                      /usr/bin/html2markdown.py2 20 \
+                            --slave /usr/share/man/man1/html2markdown.1.gz \
+                                    html2markdown.1.gz \
+                                    /usr/share/man/man1/html2markdown.py2.1.gz
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+#DEBHELPER#
+
+exit 0
+# vi: set et:

Added: packages/python-html2text/trunk/debian/python-html2text.prerm
===================================================================
--- packages/python-html2text/trunk/debian/python-html2text.prerm	                        (rev 0)
+++ packages/python-html2text/trunk/debian/python-html2text.prerm	2011-02-26 11:19:14 UTC (rev 15874)
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+    remove|deconfigure)
+        update-alternatives --remove html2markdown /usr/bin/html2markdown.py2
+    ;;
+
+    upgrade|failed-upgrade)
+    ;;
+
+    *)
+        echo "prerm called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+#DEBHELPER#
+
+exit 0
+# vi: set et:

Added: packages/python-html2text/trunk/debian/python3-html2text.postinst
===================================================================
--- packages/python-html2text/trunk/debian/python3-html2text.postinst	                        (rev 0)
+++ packages/python-html2text/trunk/debian/python3-html2text.postinst	2011-02-26 11:19:14 UTC (rev 15874)
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+    configure)
+        update-alternatives --install /usr/bin/html2markdown html2markdown \
+                                      /usr/bin/html2markdown.py3 10 \
+                            --slave /usr/share/man/man1/html2markdown.1.gz \
+                                    html2markdown.1.gz \
+                                    /usr/share/man/man1/html2markdown.py3.1.gz
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+#DEBHELPER#
+
+exit 0
+# vi: set et:

Added: packages/python-html2text/trunk/debian/python3-html2text.prerm
===================================================================
--- packages/python-html2text/trunk/debian/python3-html2text.prerm	                        (rev 0)
+++ packages/python-html2text/trunk/debian/python3-html2text.prerm	2011-02-26 11:19:14 UTC (rev 15874)
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+    remove|deconfigure)
+        update-alternatives --remove html2markdown /usr/bin/html2markdown.py3
+    ;;
+
+    upgrade|failed-upgrade)
+    ;;
+
+    *)
+        echo "prerm called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+#DEBHELPER#
+
+exit 0
+# vi: set et:

Modified: packages/python-html2text/trunk/debian/rules
===================================================================
--- packages/python-html2text/trunk/debian/rules	2011-02-26 09:29:32 UTC (rev 15873)
+++ packages/python-html2text/trunk/debian/rules	2011-02-26 11:19:14 UTC (rev 15874)
@@ -15,12 +15,34 @@
 override_dh_auto_install:
 	set -e; \
 	for py in $(PYVERS); do \
-		$$py setup.py install --skip-build --root debian/python-html2text --install-layout=deb; \
+		$$py setup.py install --skip-build --root debian/python-html2text \
+		                      --install-layout deb; \
 	done
 	set -e; \
 	for py in $(PY3VERS); do \
-		$$py setup.py install --skip-build --root debian/python3-html2text --install-layout=deb; \
+		$$py setup.py install --skip-build --root debian/python3-html2text \
+		                      --install-layout deb; \
 	done
 
+override_dh_installman:
+	cp debian/html2markdown.1 debian/html2markdown.py2.1
+	dh_installman -p python-html2text debian/html2markdown.py2.1
+	cp debian/html2markdown.1 debian/html2markdown.py3.1
+	dh_installman -p python3-html2text debian/html2markdown.py3.1
+
+override_dh_link:
+	dh_link -p python-html2text /usr/share/pyshared/html2text.py \
+	                            /usr/bin/html2markdown.py2
+	dh_link -p python3-html2text /usr/lib/python3/dist-packages/html2text.py \
+	                             /usr/bin/html2markdown.py3
+	sed -i '1s,python$$,python3,' \
+	    debian/python3-html2text/usr/lib/python3/dist-packages/html2text.py
+
+override_dh_fixperms:
+	dh_fixperms
+	chmod +x debian/python-html2text/usr/share/pyshared/html2text.py
+	chmod +x debian/python3-html2text/usr/lib/python3/dist-packages/html2text.py
+
 override_dh_auto_clean:
 	rm -rf build *.egg-info
+	rm -f debian/html2markdown.py2.1 debian/html2markdown.py3.1




More information about the Python-modules-commits mailing list