[Python-modules-commits] r10368 - in packages/chardet/trunk/debian (8 files)
piotr at users.alioth.debian.org
piotr at users.alioth.debian.org
Wed Nov 11 16:16:36 UTC 2009
Date: Wednesday, November 11, 2009 @ 16:16:31
Author: piotr
Revision: 10368
* New upstream release (no changes in the code)
* Add /usr/bin/chardet (thanks to Ben Finney, closes: #479178)
* Convert package to dh sequencer and python-support
* Bump Standards-Version to 3.8.3 (no changes needed)
Added:
packages/chardet/trunk/debian/chardet
packages/chardet/trunk/debian/chardet.1
packages/chardet/trunk/debian/install
packages/chardet/trunk/debian/preinst
Modified:
packages/chardet/trunk/debian/changelog
packages/chardet/trunk/debian/control
packages/chardet/trunk/debian/copyright
packages/chardet/trunk/debian/rules
Modified: packages/chardet/trunk/debian/changelog
===================================================================
--- packages/chardet/trunk/debian/changelog 2009-11-11 15:30:24 UTC (rev 10367)
+++ packages/chardet/trunk/debian/changelog 2009-11-11 16:16:31 UTC (rev 10368)
@@ -1,19 +1,23 @@
-chardet (1.0.1-2) UNRELEASED; urgency=low
+chardet (2.0.1-1) unstable; urgency=low
[ Sandro Tosi ]
- * debian/control
- - switch Vcs-Browser field to viewsvn
+ * Switch Vcs-Browser field to viewsvn
[ Piotr Ożarowski ]
+ * New upstream release (no changes in the code)
+ * Add /usr/bin/chardet (thanks to Ben Finney, closes: #479178)
+ * Convert package to dh sequencer and python-support
* debian/watch file updated (now points to the Python 2.X version)
+ * Bump Standards-Version to 3.8.3 (no changes needed)
- -- Sandro Tosi <morph at debian.org> Mon, 03 Nov 2008 22:12:48 +0100
+ -- Piotr Ożarowski <piotr at debian.org> Wed, 11 Nov 2009 14:14:10 +0100
chardet (1.0.1-1.1) unstable; urgency=low
* NMU. Rebuild to move files to /usr/share/pyshared. Closes: #490452.
-- Matthias Klose <doko at debian.org> Fri, 18 Jul 2008 15:58:15 +0000
+
chardet (1.0.1-1) unstable; urgency=low
* New upstream release
Added: packages/chardet/trunk/debian/chardet
===================================================================
--- packages/chardet/trunk/debian/chardet (rev 0)
+++ packages/chardet/trunk/debian/chardet 2009-11-11 16:16:31 UTC (rev 10368)
@@ -0,0 +1,159 @@
+#! /usr/bin/python
+# -*- coding: utf-8 -*-
+
+# bin/chardet
+# Part of chardet, the Universal Encoding Detector.
+#
+# Copyright © 2008â2009 Ben Finney <ben+python at benfinney.id.au>
+#
+# This is free software; you may copy, modify and/or distribute this
+# work under the terms of the GNU Lesser General Public License;
+# either version 2.1 or, at your option, any later version.
+# No warranty expressed or implied. See the file COPYING for details.
+
+""" %prog [options] [file ...]
+
+Report heuristically-detected character encoding for each file.
+
+For every specified file (defaulting to stdin if no files are
+specified), reads and determines the character encoding of the file
+content. Reports the name and confidence level for each file's
+detected character encoding.
+"""
+
+import sys
+import optparse
+import chardet
+
+
+class OptionParser(optparse.OptionParser, object):
+ """ Command-line parser for this program """
+
+ def __init__(self, *args, **kwargs):
+ """ Set up a new instance """
+ super(OptionParser, self).__init__(*args, **kwargs)
+
+ global __doc__
+ self.usage = __doc__.strip()
+
+
+def detect_encoding(in_file):
+ """ Detect encoding of text in `in_file`
+
+ Parameters
+ in_file
+ Opened file object to read and examine.
+
+ Return value
+ The mapping as returned by `chardet.detect`.
+
+ """
+ in_data = in_file.read()
+ params = chardet.detect(in_data)
+ return params
+
+
+def report_file_encoding(in_file, encoding_params):
+ """ Return a report of the file's encoding
+
+ Parameters
+ in_file
+ File object being reported. Should have an appropriate
+ `name` attribute.
+
+ encoding_params
+ Mapping as returned by `detect_encoding` on the file's
+ data.
+
+ Return value
+ The report is a single line of text showing filename,
+ detected encoding, and detection confidence.
+
+ """
+ file_name = in_file.name
+ encoding_name = encoding_params['encoding']
+ confidence = encoding_params['confidence']
+ report = (
+ "%(file_name)s: %(encoding_name)s"
+ " (confidence: %(confidence)0.2f)") % vars()
+ return report
+
+
+def process_file(in_file):
+ """ Process a single file
+
+ Parameters
+ in_file
+ Opened file object to read and examine.
+
+ Return value
+ None.
+
+ Reads the file contents, detects the encoding, and writes a
+ report line to stdout.
+ """
+ encoding_params = detect_encoding(in_file)
+ encoding_report = report_file_encoding(in_file, encoding_params)
+ message = "%(encoding_report)s\n" % vars()
+ sys.stdout.write(message)
+
+
+class DetectEncodingApp(object):
+ """ Application behaviour for 'detect-encoding' program """
+
+ def __init__(self, argv):
+ """ Set up a new instance """
+ self._parse_commandline(argv)
+
+ def _parse_commandline(self, argv):
+ """ Parse command-line arguments """
+ option_parser = OptionParser()
+ (options, args) = option_parser.parse_args(argv[1:])
+ self.file_names = args
+
+ def _emit_file_error(self, file_name, error):
+ """ Emit an error message regarding file processing """
+ error_name = error.__class__.__name__
+ message = (
+ "%(file_name)s: %(error_name)s: %(error)s\n") % vars()
+ sys.stderr.write(message)
+
+ def _process_all_files(self, file_names):
+ """ Process all files in list """
+ if not len(file_names):
+ file_names = [None]
+ for file_name in file_names:
+ try:
+ if file_name is None:
+ file_name = sys.stdin.name
+ in_file = sys.stdin
+ else:
+ in_file = open(file_name)
+ process_file(in_file)
+ except IOError, exc:
+ self._emit_file_error(file_name, exc)
+
+ def main(self):
+ """ Main entry point for application """
+ self._process_all_files(self.file_names)
+
+
+def __main__(argv=None):
+ """ Mainline code for this program """
+
+ from sys import argv as sys_argv
+ if argv is None:
+ argv = sys_argv
+
+ app = DetectEncodingApp(argv)
+ exitcode = None
+ try:
+ app.main()
+ except SystemExit, e:
+ exitcode = e.code
+
+ return exitcode
+
+if __name__ == "__main__":
+ exitcode = __main__(argv=sys.argv)
+ sys.exit(exitcode)
Added: packages/chardet/trunk/debian/chardet.1
===================================================================
--- packages/chardet/trunk/debian/chardet.1 (rev 0)
+++ packages/chardet/trunk/debian/chardet.1 2009-11-11 16:16:31 UTC (rev 10368)
@@ -0,0 +1,26 @@
+.TH CHARDET "1" "November 2009" "chardet 2.0.1" "User Commands"
+.SH NAME
+chardet \- universal character encoding detector
+.SH SYNOPSIS
+.B chardet
+[\fIoptions\fR] [\fIfile \fR...]
+.SH DESCRIPTION
+Report heuristically\-detected character encoding for each file.
+.PP
+For every specified file (defaulting to stdin if no files are
+specified), reads and determines the character encoding of the file
+content. Reports the name and confidence level for each file's
+detected character encoding.
+.SH OPTIONS
+.TP
+\fB\-h\fR, \fB\-\-help\fR
+show this help message and exit
+.SH "SEE ALSO"
+/usr/share/doc/python-chardet/index.html
+.SH AUTHOR
+chardet module was written by Mark Pilgrim <mark at diveintomark.org>
+.PP
+chardet script was written by Ben Finney <ben+python at benfinney.id.au>
+.PP
+This manual page was written by Piotr Ożarowski <piotr at debian.org>,
+for the Debian project (but may be used by others).
Modified: packages/chardet/trunk/debian/control
===================================================================
--- packages/chardet/trunk/debian/control 2009-11-11 15:30:24 UTC (rev 10367)
+++ packages/chardet/trunk/debian/control 2009-11-11 16:16:31 UTC (rev 10368)
@@ -3,18 +3,17 @@
Priority: optional
Maintainer: Piotr Ożarowski <piotr at debian.org>
Uploaders: Mark Pilgrim <mark at diveintomark.org>, Debian Python Modules Team <python-modules-team at lists.alioth.debian.org>
-Build-Depends: python (>= 2.3.5-11), debhelper (>= 5.0.37.2), cdbs (>= 0.4.43)
-Build-Depends-Indep: python-all-dev, python-central (>= 0.5.6)
-Standards-Version: 3.7.3
+Build-Depends: python (>= 2.3.5-11), debhelper (>= 7)
+Build-Depends-Indep: python-support
+Standards-Version: 3.8.3
Homepage: http://chardet.feedparser.org/
-XS-Python-Version: all
Vcs-Svn: svn://svn.debian.org/python-modules/packages/chardet/trunk
Vcs-Browser: http://svn.debian.org/viewsvn/python-modules/packages/chardet/trunk/
+XS-Python-Version: all
Package: python-chardet
Architecture: all
-XB-Python-Version: ${python:Versions}
-Depends: ${python:Depends}
+Depends: python, ${python:Depends}, ${misc:Depends}
Description: universal character encoding detector
Chardet takes a sequence of bytes in an unknown character encoding, and
attempts to determine the encoding.
Modified: packages/chardet/trunk/debian/copyright
===================================================================
--- packages/chardet/trunk/debian/copyright 2009-11-11 15:30:24 UTC (rev 10367)
+++ packages/chardet/trunk/debian/copyright 2009-11-11 16:16:31 UTC (rev 10368)
@@ -77,8 +77,14 @@
-----------------------------------------------------------
+debian/chardet script:
+
+ Copyright © 2008â2009 Ben Finney <ben+python at benfinney.id.au>
+
+ -----------------------------------------------------------
+
On Debian systems, the complete text of the GNU Library General Public
License can be found in the file `/usr/share/common-licenses/LGPL-2.1'.
-The Debian packaging is (C) 2006-2008, Piotr Ożarowski <piotr at debian.org> and
+The Debian packaging is © 2006-2009, Piotr Ożarowski <piotr at debian.org> and
is licensed under the LGPL.
Added: packages/chardet/trunk/debian/install
===================================================================
--- packages/chardet/trunk/debian/install (rev 0)
+++ packages/chardet/trunk/debian/install 2009-11-11 16:16:31 UTC (rev 10368)
@@ -0,0 +1,2 @@
+debian/chardet /usr/bin
+debian/chardet.1 /usr/share/man/man1/
Added: packages/chardet/trunk/debian/preinst
===================================================================
--- packages/chardet/trunk/debian/preinst (rev 0)
+++ packages/chardet/trunk/debian/preinst 2009-11-11 16:16:31 UTC (rev 10368)
@@ -0,0 +1,8 @@
+#!/bin/sh
+# TODO: remove this file after releasing Squeeze
+set -e
+if [ "$1" = upgrade ] && dpkg --compare-versions "$2" lt 1.2-3
+then
+ pycentral pkgremove python-chardet
+fi
+#DEBHELPER#
Modified: packages/chardet/trunk/debian/rules
===================================================================
--- packages/chardet/trunk/debian/rules 2009-11-11 15:30:24 UTC (rev 10367)
+++ packages/chardet/trunk/debian/rules 2009-11-11 16:16:31 UTC (rev 10368)
@@ -1,6 +1,3 @@
#!/usr/bin/make -f
-# -*- mode: makefile -*-
-DEB_PYTHON_SYSTEM = pycentral
-
-include /usr/share/cdbs/1/rules/debhelper.mk
-include /usr/share/cdbs/1/class/python-distutils.mk
+%:
+ dh $@
More information about the Python-modules-commits
mailing list