Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-polib for openSUSE:Factory checked in at 2021-06-06 22:41:00 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-polib (Old) and /work/SRC/openSUSE:Factory/.python-polib.new.1898 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-polib" Sun Jun 6 22:41:00 2021 rev:23 rq:897853 version:1.1.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-polib/python-polib.changes 2018-09-11 17:21:08.491057139 +0200 +++ /work/SRC/openSUSE:Factory/.python-polib.new.1898/python-polib.changes 2021-06-06 22:41:04.291444488 +0200 @@ -1,0 +2,9 @@ +Sun Jun 6 12:39:16 UTC 2021 - Dirk M??ller <dmuel...@suse.com> + +- update to 1.1.1: + - Strip UTF-16 BOM (U+FEFF) from start of file + - Message context (msgctxt) support for MO files + - Dropped Python < 2.7 support + - Updated docs and README after switch from Bitbucket to Github + +------------------------------------------------------------------- Old: ---- polib-1.1.0.tar.gz New: ---- polib-1.1.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-polib.spec ++++++ --- /var/tmp/diff_new_pack.xS3Tw5/_old 2021-06-06 22:41:04.879445640 +0200 +++ /var/tmp/diff_new_pack.xS3Tw5/_new 2021-06-06 22:41:04.883445648 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-polib # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2021 SUSE LLC # Copyright (c) 2013 LISA GmbH, Bingen, Germany. # # All modifications and additions to the file contributed by third parties @@ -13,18 +13,18 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-polib -Version: 1.1.0 +Version: 1.1.1 Release: 0 Summary: A library to manipulate gettext files License: MIT Group: Development/Languages/Python -URL: http://bitbucket.org/izi/polib/ +URL: https://github.com/izimobil/polib/ Source0: https://files.pythonhosted.org/packages/source/p/polib/polib-%{version}.tar.gz Patch0: polib-1.1.0-fix-tests-big-endian.patch BuildRequires: %{python_module setuptools} ++++++ polib-1.1.0.tar.gz -> polib-1.1.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/polib-1.1.0/CHANGELOG new/polib-1.1.1/CHANGELOG --- old/polib-1.1.0/CHANGELOG 2017-11-27 17:54:40.000000000 +0100 +++ new/polib-1.1.1/CHANGELOG 2021-03-26 23:20:34.000000000 +0100 @@ -2,6 +2,13 @@ Changelog ========= +Version 1.1.1 (2021/03/26) +-------------------------- + - Strip UTF-16 BOM (U+FEFF) from start of file + - Message context (msgctxt) support for MO files + - Dropped Python < 2.7 support + - Updated docs and README after switch from Bitbucket to Github + Version 1.1.0 (2017/11/27) -------------------------- - Fixed entries sorting when generating mo file (Fixes #78) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/polib-1.1.0/PKG-INFO new/polib-1.1.1/PKG-INFO --- old/polib-1.1.0/PKG-INFO 2017-11-27 18:33:18.000000000 +0100 +++ new/polib-1.1.1/PKG-INFO 2021-03-26 23:22:54.000000000 +0100 @@ -1,58 +1,96 @@ -Metadata-Version: 1.1 +Metadata-Version: 1.2 Name: polib -Version: 1.1.0 +Version: 1.1.1 Summary: A library to manipulate gettext files (po and mo files). -Home-page: http://bitbucket.org/izi/polib/ +Home-page: https://github.com/izimobil/polib/ Author: David Jean Louis Author-email: izimo...@gmail.com +Maintainer: David Jean Louis +Maintainer-email: izimo...@gmail.com License: MIT -Download-URL: https://pypi.python.org/packages/source/p/polib/polib-1.1.0.tar.gz -Description-Content-Type: UNKNOWN +Download-URL: https://pypi.python.org/packages/source/p/polib/polib-1.1.1.tar.gz Description: ===== polib ===== - .. image:: https://img.shields.io/pypi/dm/polib.svg - :alt: Downloads - - - .. image:: https://img.shields.io/pypi/pyversions/polib.svg - :alt: Supported Python versions - - - .. image:: https://img.shields.io/pypi/status/polib.svg - :alt: Development Status - - - .. image:: https://img.shields.io/pypi/l/polib.svg - :alt: License + |build-status-image| |codecov-image| |documentation-status-image| |pypi-version| |py-versions| + Overview + -------- polib is a library to manipulate, create, modify gettext files (pot, po and mo files). You can load existing files, iterate through it's entries, add, modify entries, comments or metadata, etc... or create new po files from scratch. - polib supports out of the box any version of python ranging from 2.5 to latest + polib supports out of the box any version of python ranging from 2.7 to latest 3.X version. polib is pretty stable now and is used by many `opensource projects <http://polib.readthedocs.org/en/latest/projects.html>`_. The project code and bugtracker is hosted on - `Bitbucket <http://bitbucket.org/izi/polib/>`_. + `Github <https://github.com/izimobil/polib/>`_. polib is generously documented, you can `browse the documentation online <http://polib.readthedocs.org/>`_, a good start is to read `the quickstart guide <http://polib.readthedocs.org/en/latest/quickstart.html>`_. - Thanks for downloading polib ! + + Installation + ~~~~~~~~~~~~ + + Just use ``pip``: + + .. code:: bash + + $ pip install polib + + + Basic example + ~~~~~~~~~~~~~ + + .. code:: python + + import polib + + pofile = polib.pofile('/path/to/pofile.po') + + for entry in pofile: + print(entry.msgid, entry.msgtxt) + + + .. |build-status-image| image:: https://secure.travis-ci.org/izimobil/polib.svg?branch=master + :target: http://travis-ci.org/izimobil/polib?branch=master + :alt: Travis build + + .. |codecov-image| image:: https://codecov.io/gh/izimobil/polib/branch/master/graph/badge.svg + :target: https://codecov.io/gh/izimobil/polib + + .. |pypi-version| image:: https://img.shields.io/pypi/v/polib.svg + :target: https://pypi.python.org/pypi/djangorestframework-datatables + :alt: Pypi version + + .. |documentation-status-image| image:: https://readthedocs.org/projects/polib/badge/?version=latest + :target: http://polib.readthedocs.io/en/latest/?badge=latest + :alt: Documentation Status + + .. |py-versions| image:: https://img.shields.io/pypi/pyversions/polib.svg + :target: https://img.shields.io/pypi/pyversions/polib.svg + :alt: Python versions ========= Changelog ========= + Version 1.1.1 (2021/03/26) + -------------------------- + - Strip UTF-16 BOM (U+FEFF) from start of file + - Message context (msgctxt) support for MO files + - Dropped Python < 2.7 support + - Updated docs and README after switch from Bitbucket to Github + Version 1.1.0 (2017/11/27) -------------------------- - Fixed entries sorting when generating mo file (Fixes #78) @@ -279,8 +317,6 @@ Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 -Classifier: Programming Language :: Python :: 2.5 -Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/polib-1.1.0/README.rst new/polib-1.1.1/README.rst --- old/polib-1.1.0/README.rst 2017-11-27 14:54:29.000000000 +0100 +++ new/polib-1.1.1/README.rst 2021-02-19 13:03:04.000000000 +0100 @@ -2,37 +2,67 @@ polib ===== -.. image:: https://img.shields.io/pypi/dm/polib.svg - :alt: Downloads - - -.. image:: https://img.shields.io/pypi/pyversions/polib.svg - :alt: Supported Python versions - - -.. image:: https://img.shields.io/pypi/status/polib.svg - :alt: Development Status - - -.. image:: https://img.shields.io/pypi/l/polib.svg - :alt: License +|build-status-image| |codecov-image| |documentation-status-image| |pypi-version| |py-versions| +Overview +-------- polib is a library to manipulate, create, modify gettext files (pot, po and mo files). You can load existing files, iterate through it's entries, add, modify entries, comments or metadata, etc... or create new po files from scratch. -polib supports out of the box any version of python ranging from 2.5 to latest +polib supports out of the box any version of python ranging from 2.7 to latest 3.X version. polib is pretty stable now and is used by many `opensource projects <http://polib.readthedocs.org/en/latest/projects.html>`_. The project code and bugtracker is hosted on -`Bitbucket <http://bitbucket.org/izi/polib/>`_. +`Github <https://github.com/izimobil/polib/>`_. polib is generously documented, you can `browse the documentation online <http://polib.readthedocs.org/>`_, a good start is to read `the quickstart guide <http://polib.readthedocs.org/en/latest/quickstart.html>`_. -Thanks for downloading polib ! + +Installation +~~~~~~~~~~~~ + +Just use ``pip``: + +.. code:: bash + + $ pip install polib + + +Basic example +~~~~~~~~~~~~~ + +.. code:: python + + import polib + + pofile = polib.pofile('/path/to/pofile.po') + + for entry in pofile: + print(entry.msgid, entry.msgtxt) + + +.. |build-status-image| image:: https://secure.travis-ci.org/izimobil/polib.svg?branch=master + :target: http://travis-ci.org/izimobil/polib?branch=master + :alt: Travis build + +.. |codecov-image| image:: https://codecov.io/gh/izimobil/polib/branch/master/graph/badge.svg + :target: https://codecov.io/gh/izimobil/polib + +.. |pypi-version| image:: https://img.shields.io/pypi/v/polib.svg + :target: https://pypi.python.org/pypi/djangorestframework-datatables + :alt: Pypi version + +.. |documentation-status-image| image:: https://readthedocs.org/projects/polib/badge/?version=latest + :target: http://polib.readthedocs.io/en/latest/?badge=latest + :alt: Documentation Status + +.. |py-versions| image:: https://img.shields.io/pypi/pyversions/polib.svg + :target: https://img.shields.io/pypi/pyversions/polib.svg + :alt: Python versions diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/polib-1.1.0/docs/contributing.rst new/polib-1.1.1/docs/contributing.rst --- old/polib-1.1.0/docs/contributing.rst 2017-11-27 11:55:38.000000000 +0100 +++ new/polib-1.1.1/docs/contributing.rst 2021-02-19 13:02:28.000000000 +0100 @@ -5,20 +5,20 @@ You are very welcome to contribute to the project! The bugtracker, wiki and mercurial repository can be found at the -`project's page <http://bitbucket.org/izi/polib/>`_. +`project's page <https://github.com/izimobil/polib/>`_. New releases are also published at the -`cheeseshop <http://cheeseshop.python.org/pypi/polib/>`_. +`"cheeseshop" (PyPI) <https://pypi.org/project/polib/>`_. How to contribute ~~~~~~~~~~~~~~~~~ There are various possibilities to get involved, for example you can: -* `Report bugs <http://www.bitbucket.org/izi/polib/issues/new/>`_ +* `Report bugs <https://github.com/izimobil/polib/issues/new/>`_ preferably with patches if you can; -* Enhance this `documentation <http://www.bitbucket.org/izi/polib/src/tip/docs/>`_ -* `Fork the code <http://www.bitbucket.org/izi/polib/>`_, implement new +* Enhance this `documentation <https://github.com/izimobil/polib/tree/master/docs/>`_ +* `Fork the code <https://github.com/izimobil/polib/>`_, implement new features, test and send a pull request Running the test suite diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/polib-1.1.0/docs/installation.rst new/polib-1.1.1/docs/installation.rst --- old/polib-1.1.0/docs/installation.rst 2017-11-27 11:55:38.000000000 +0100 +++ new/polib-1.1.1/docs/installation.rst 2021-03-26 23:13:37.000000000 +0100 @@ -6,7 +6,7 @@ Requirements ------------ -polib requires python 2.5 or higher. +polib requires python 2.7 or higher. Installing polib @@ -62,20 +62,20 @@ privileges (e.g., ``sudo python setup.py install``). -Manual installation from a Mercurial checkout -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Manual installation from a Git checkout +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If you'd like to try out the latest in-development code, you can obtain it from the polib repository, which is hosted at -`Bitbucket <http://bitbucket.org/>`_ and uses `Mercurial -<http://www.selenic.com/mercurial/wiki/>`_ for version control. +`Github <https://github.com/>`_ and uses `Git +<https://git-scm.com/>`_ for version control. -To obtain the latest code and documentation, you'll need to have Mercurial +To obtain the latest code and documentation, you'll need to have Git installed, at which point you can type:: - hg clone http://bitbucket.org/izi/polib/ + git clone https://github.com/izimobil/polib/ -This will create a copy of the polib Mercurial repository on your computer; +This will create a copy of the polib Git repository on your computer; you can then add the ``polib.py`` file to your Python import path, or use the ``setup.py`` script to install as a package. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/polib-1.1.0/docs/quickstart.rst new/polib-1.1.1/docs/quickstart.rst --- old/polib-1.1.0/docs/quickstart.rst 2017-11-27 11:55:38.000000000 +0100 +++ new/polib-1.1.1/docs/quickstart.rst 2021-03-26 23:13:37.000000000 +0100 @@ -6,7 +6,7 @@ Installing polib ---------------- -polib requires python 2.5 or superior. +polib requires python 2.7 or superior. There are several ways to install polib, this is explained in :ref:`the installation section <installation>`. @@ -86,7 +86,7 @@ import polib mo = polib.mofile('path/to/catalog.mo') - print mo + print(mo) As for po files, mofile also allows specifying the encoding explicitly. @@ -144,7 +144,7 @@ po = polib.pofile('path/to/catalog.po') for entry in po: - print entry.msgid, entry.msgstr + print(entry.msgid, entry.msgstr) Iterating over **all** entries except obsolete entries:: @@ -153,7 +153,7 @@ po = polib.pofile('path/to/catalog.po') valid_entries = [e for e in po if not e.obsolete] for entry in valid_entries: - print entry.msgid, entry.msgstr + print(entry.msgid, entry.msgstr) Iterating over translated entries only:: @@ -161,7 +161,7 @@ po = polib.pofile('path/to/catalog.po') for entry in po.translated_entries(): - print entry.msgid, entry.msgstr + print(entry.msgid, entry.msgstr) And so on... You could also iterate over the list of POEntry objects returned by the @@ -179,7 +179,7 @@ import polib po = polib.pofile('path/to/catalog.po') - print po.percent_translated() + print(po.percent_translated()) Compiling po to mo files and reversing mo files to po files diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/polib-1.1.0/polib.egg-info/PKG-INFO new/polib-1.1.1/polib.egg-info/PKG-INFO --- old/polib-1.1.0/polib.egg-info/PKG-INFO 2017-11-27 18:33:18.000000000 +0100 +++ new/polib-1.1.1/polib.egg-info/PKG-INFO 2021-03-26 23:22:54.000000000 +0100 @@ -1,58 +1,96 @@ -Metadata-Version: 1.1 +Metadata-Version: 1.2 Name: polib -Version: 1.1.0 +Version: 1.1.1 Summary: A library to manipulate gettext files (po and mo files). -Home-page: http://bitbucket.org/izi/polib/ +Home-page: https://github.com/izimobil/polib/ Author: David Jean Louis Author-email: izimo...@gmail.com +Maintainer: David Jean Louis +Maintainer-email: izimo...@gmail.com License: MIT -Download-URL: https://pypi.python.org/packages/source/p/polib/polib-1.1.0.tar.gz -Description-Content-Type: UNKNOWN +Download-URL: https://pypi.python.org/packages/source/p/polib/polib-1.1.1.tar.gz Description: ===== polib ===== - .. image:: https://img.shields.io/pypi/dm/polib.svg - :alt: Downloads - - - .. image:: https://img.shields.io/pypi/pyversions/polib.svg - :alt: Supported Python versions - - - .. image:: https://img.shields.io/pypi/status/polib.svg - :alt: Development Status - - - .. image:: https://img.shields.io/pypi/l/polib.svg - :alt: License + |build-status-image| |codecov-image| |documentation-status-image| |pypi-version| |py-versions| + Overview + -------- polib is a library to manipulate, create, modify gettext files (pot, po and mo files). You can load existing files, iterate through it's entries, add, modify entries, comments or metadata, etc... or create new po files from scratch. - polib supports out of the box any version of python ranging from 2.5 to latest + polib supports out of the box any version of python ranging from 2.7 to latest 3.X version. polib is pretty stable now and is used by many `opensource projects <http://polib.readthedocs.org/en/latest/projects.html>`_. The project code and bugtracker is hosted on - `Bitbucket <http://bitbucket.org/izi/polib/>`_. + `Github <https://github.com/izimobil/polib/>`_. polib is generously documented, you can `browse the documentation online <http://polib.readthedocs.org/>`_, a good start is to read `the quickstart guide <http://polib.readthedocs.org/en/latest/quickstart.html>`_. - Thanks for downloading polib ! + + Installation + ~~~~~~~~~~~~ + + Just use ``pip``: + + .. code:: bash + + $ pip install polib + + + Basic example + ~~~~~~~~~~~~~ + + .. code:: python + + import polib + + pofile = polib.pofile('/path/to/pofile.po') + + for entry in pofile: + print(entry.msgid, entry.msgtxt) + + + .. |build-status-image| image:: https://secure.travis-ci.org/izimobil/polib.svg?branch=master + :target: http://travis-ci.org/izimobil/polib?branch=master + :alt: Travis build + + .. |codecov-image| image:: https://codecov.io/gh/izimobil/polib/branch/master/graph/badge.svg + :target: https://codecov.io/gh/izimobil/polib + + .. |pypi-version| image:: https://img.shields.io/pypi/v/polib.svg + :target: https://pypi.python.org/pypi/djangorestframework-datatables + :alt: Pypi version + + .. |documentation-status-image| image:: https://readthedocs.org/projects/polib/badge/?version=latest + :target: http://polib.readthedocs.io/en/latest/?badge=latest + :alt: Documentation Status + + .. |py-versions| image:: https://img.shields.io/pypi/pyversions/polib.svg + :target: https://img.shields.io/pypi/pyversions/polib.svg + :alt: Python versions ========= Changelog ========= + Version 1.1.1 (2021/03/26) + -------------------------- + - Strip UTF-16 BOM (U+FEFF) from start of file + - Message context (msgctxt) support for MO files + - Dropped Python < 2.7 support + - Updated docs and README after switch from Bitbucket to Github + Version 1.1.0 (2017/11/27) -------------------------- - Fixed entries sorting when generating mo file (Fixes #78) @@ -279,8 +317,6 @@ Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 -Classifier: Programming Language :: Python :: 2.5 -Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/polib-1.1.0/polib.egg-info/SOURCES.txt new/polib-1.1.1/polib.egg-info/SOURCES.txt --- old/polib-1.1.0/polib.egg-info/SOURCES.txt 2017-11-27 18:33:18.000000000 +0100 +++ new/polib-1.1.1/polib.egg-info/SOURCES.txt 2021-03-26 23:22:54.000000000 +0100 @@ -38,6 +38,7 @@ tests/test_save_as_mofile.po tests/test_save_as_pofile.po tests/test_trailing_comment.po +tests/test_ufeff.po tests/test_unusual_metadata_location.po tests/test_utf8.mo tests/test_utf8.po diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/polib-1.1.0/polib.py new/polib-1.1.1/polib.py --- old/polib-1.1.0/polib.py 2017-11-27 18:27:09.000000000 +0100 +++ new/polib-1.1.1/polib.py 2021-03-26 23:20:47.000000000 +0100 @@ -19,20 +19,11 @@ import struct import sys import textwrap - -try: - import io -except ImportError: - # replacement of io.open() for python < 2.6 - # we use codecs instead - class io(object): - @staticmethod - def open(fpath, mode='r', encoding=None): - return codecs.open(fpath, mode, encoding) +import io __author__ = 'David Jean Louis <izimo...@gmail.com>' -__version__ = '1.1.0' +__version__ = '1.1.1' __all__ = ['pofile', 'POFile', 'POEntry', 'mofile', 'MOFile', 'MOEntry', 'default_encoding', 'escape', 'unescape', 'detect_encoding', ] @@ -102,8 +93,8 @@ In the latter case, this function will always return False. """ try: - return os.path.exists(filename_or_contents) - except (ValueError, UnicodeEncodeError): + return os.path.isfile(filename_or_contents) + except (TypeError, ValueError, UnicodeEncodeError): return False # }}} # function pofile() {{{ @@ -216,8 +207,8 @@ mode = 'r' rx = rxt f = open(file, mode) - for l in f.readlines(): - match = rx.search(l) + for line in f.readlines(): + match = rx.search(line) if match: f.close() enc = match.group(1).strip() @@ -421,7 +412,7 @@ e.flags.append('fuzzy') return e - def save(self, fpath=None, repr_method='__unicode__'): + def save(self, fpath=None, repr_method='__unicode__', newline=None): """ Saves the po file to ``fpath``. If it is an existing file and no ``fpath`` is provided, then the @@ -434,6 +425,9 @@ ``repr_method`` string, the method to use for output. + + ``newline`` + string, controls how universal newlines works """ if self.fpath is None and fpath is None: raise IOError('You must provide a file path to save() method') @@ -443,7 +437,12 @@ if repr_method == 'to_binary': fhandle = open(fpath, 'wb') else: - fhandle = io.open(fpath, 'w', encoding=self.encoding) + fhandle = io.open( + fpath, + 'w', + encoding=self.encoding, + newline=newline + ) if not isinstance(contents, text_type): contents = contents.decode(self.encoding) fhandle.write(contents) @@ -916,7 +915,7 @@ real_wrapwidth = wrapwidth - flength + specialchars_count if wrapwidth > 0 and len(field) > real_wrapwidth: # Wrap the line but take field name into account - lines = [''] + [unescape(item) for item in wrap( + lines = [''] + [unescape(item) for item in textwrap.wrap( escaped_field, wrapwidth - 2, # 2 for quotes "" drop_whitespace=False, @@ -933,6 +932,12 @@ for line in lines: ret.append('%s"%s"' % (delflag, escape(line))) return ret + + @property + def msgid_with_context(self): + if self.msgctxt: + return '%s%s%s' % (self.msgctxt, "\x04", self.msgid) + return self.msgid # }}} # class POEntry {{{ @@ -995,7 +1000,7 @@ if val: for comment in val.split('\n'): if wrapwidth > 0 and len(comment) + len(c[1]) > wrapwidth: - ret += wrap( + ret += textwrap.wrap( comment, wrapwidth, initial_indent=c[1], @@ -1019,7 +1024,7 @@ # what we want for filenames, so the dirty hack is to # temporally replace hyphens with a char that a file cannot # contain, like "*" - ret += [l.replace('*', '-') for l in wrap( + ret += [line.replace('*', '-') for line in textwrap.wrap( filestr.replace('-', '*'), wrapwidth, initial_indent='#: ', @@ -1062,28 +1067,27 @@ # Work on a copy to protect original occ1 = sorted(self.occurrences[:]) occ2 = sorted(other.occurrences[:]) - pos = 0 if occ1 > occ2: return 1 if occ1 < occ2: return -1 # Compare context - msgctxt = self.msgctxt or 0 - othermsgctxt = other.msgctxt or 0 + msgctxt = self.msgctxt or '0' + othermsgctxt = other.msgctxt or '0' if msgctxt > othermsgctxt: return 1 elif msgctxt < othermsgctxt: return -1 # Compare msgid_plural - msgid_plural = self.msgid_plural or 0 - othermsgid_plural = other.msgid_plural or 0 + msgid_plural = self.msgid_plural or '0' + othermsgid_plural = other.msgid_plural or '0' if msgid_plural > othermsgid_plural: return 1 elif msgid_plural < othermsgid_plural: return -1 # Compare msgstr_plural - msgstr_plural = self.msgstr_plural or 0 - othermsgstr_plural = other.msgstr_plural or 0 + msgstr_plural = self.msgstr_plural or '0' + othermsgstr_plural = other.msgstr_plural or '0' if msgstr_plural > othermsgstr_plural: return 1 elif msgstr_plural < othermsgstr_plural: @@ -1093,7 +1097,6 @@ return 1 elif self.msgid < other.msgid: return -1 - return 0 # Compare msgstr if self.msgstr > other.msgstr: return 1 @@ -1164,12 +1167,6 @@ def fuzzy(self): return 'fuzzy' in self.flags - @property - def msgid_with_context(self): - if self.msgctxt: - return '%s%s%s' % (self.msgctxt, "\x04", self.msgid) - return self.msgid - def __hash__(self): return hash((self.msgid, self.msgstr)) # }}} @@ -1321,6 +1318,10 @@ fpath = '%s ' % self.instance.fpath if self.instance.fpath else '' for line in self.fhandle: self.current_line += 1 + if self.current_line == 1: + BOM = codecs.BOM_UTF8.decode('utf-8') + if line.startswith(BOM): + line = line[len(BOM):] line = line.strip() if line == '': continue @@ -1783,98 +1784,3 @@ return tup[0] return tup # }}} -# class TextWrapper {{{ - - -class TextWrapper(textwrap.TextWrapper): - """ - Subclass of textwrap.TextWrapper that backport the - drop_whitespace option. - """ - def __init__(self, *args, **kwargs): - drop_whitespace = kwargs.pop('drop_whitespace', True) - textwrap.TextWrapper.__init__(self, *args, **kwargs) - self.drop_whitespace = drop_whitespace - - def _wrap_chunks(self, chunks): - """_wrap_chunks(chunks : [string]) -> [string] - - Wrap a sequence of text chunks and return a list of lines of - length 'self.width' or less. (If 'break_long_words' is false, - some lines may be longer than this.) Chunks correspond roughly - to words and the whitespace between them: each chunk is - indivisible (modulo 'break_long_words'), but a line break can - come between any two chunks. Chunks should not have internal - whitespace; ie. a chunk is either all whitespace or a "word". - Whitespace chunks will be removed from the beginning and end of - lines, but apart from that whitespace is preserved. - """ - lines = [] - if self.width <= 0: - raise ValueError("invalid width %r (must be > 0)" % self.width) - - # Arrange in reverse order so items can be efficiently popped - # from a stack of chucks. - chunks.reverse() - - while chunks: - - # Start the list of chunks that will make up the current line. - # cur_len is just the length of all the chunks in cur_line. - cur_line = [] - cur_len = 0 - - # Figure out which static string will prefix this line. - if lines: - indent = self.subsequent_indent - else: - indent = self.initial_indent - - # Maximum width for this line. - width = self.width - len(indent) - - # First chunk on line is whitespace -- drop it, unless this - # is the very beginning of the text (ie. no lines started yet). - if self.drop_whitespace and chunks[-1].strip() == '' and lines: - del chunks[-1] - - while chunks: - length = len(chunks[-1]) - - # Can at least squeeze this chunk onto the current line. - if cur_len + length <= width: - cur_line.append(chunks.pop()) - cur_len += length - - # Nope, this line is full. - else: - break - - # The current line is full, and the next chunk is too big to - # fit on *any* line (not just this one). - if chunks and len(chunks[-1]) > width: - self._handle_long_word(chunks, cur_line, cur_len, width) - - # If the last chunk on this line is all whitespace, drop it. - if self.drop_whitespace and cur_line and not cur_line[-1].strip(): - del cur_line[-1] - - # Convert current line back to a string and store it in list - # of all lines (return value). - if cur_line: - lines.append(indent + ''.join(cur_line)) - - return lines -# }}} -# function wrap() {{{ - - -def wrap(text, width=70, **kwargs): - """ - Wrap a single paragraph of text, returning a list of wrapped lines. - """ - if sys.version_info < (2, 6): - return TextWrapper(width=width, **kwargs).wrap(text) - return textwrap.wrap(text, width=width, **kwargs) - -# }}} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/polib-1.1.0/setup.py new/polib-1.1.1/setup.py --- old/polib-1.1.0/setup.py 2017-11-27 14:28:33.000000000 +0100 +++ new/polib-1.1.1/setup.py 2021-03-26 23:08:04.000000000 +0100 @@ -44,7 +44,7 @@ author_email=maintainer_email, maintainer=maintainer, maintainer_email=maintainer_email, - url='http://bitbucket.org/izi/polib/', + url='https://github.com/izimobil/polib/', download_url='https://pypi.python.org/packages/source/p/polib/polib-%s.tar.gz' % polib.__version__, license='MIT', platforms=['posix'], @@ -58,8 +58,6 @@ 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.5', - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.0', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/polib-1.1.0/tests/test_ufeff.po new/polib-1.1.1/tests/test_ufeff.po --- old/polib-1.1.0/tests/test_ufeff.po 1970-01-01 01:00:00.000000000 +0100 +++ new/polib-1.1.1/tests/test_ufeff.po 2020-11-06 11:40:21.000000000 +0100 @@ -0,0 +1,8 @@ +???# test for pofile/mofile with ufeff +msgid "" +msgstr "" +"Project-Id-Version: django +" + +msgid "foo" +msgstr "bar" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/polib-1.1.0/tests/tests.py new/polib-1.1.1/tests/tests.py --- old/polib-1.1.0/tests/tests.py 2017-11-27 17:19:25.000000000 +0100 +++ new/polib-1.1.1/tests/tests.py 2021-03-26 23:08:04.000000000 +0100 @@ -18,7 +18,7 @@ def test_pofile_and_mofile1(self): """ - Test bad usage of pofile/mofile. + Test bad usage of pofile/mofile. """ data = u('''# test for pofile/mofile with string buffer msgid "" @@ -97,6 +97,28 @@ po = polib.pofile('tests/test_obsolete_previousmsgid.po') self.assertTrue(isinstance(po, polib.POFile)) + def test_ufeff_data_pofile(self): + """ + Test that an ufeff prefixed pofile returns a POFile instance. + """ + data = u('''\ufeff# test for pofile/mofile with ufeff +msgid "" +msgstr "" +"Project-Id-Version: django\n" + +msgid "foo" +msgstr "bar" +''') + po = polib.pofile(data) + self.assertTrue(isinstance(po, polib.POFile)) + + def test_ufeff_pofile(self): + """ + Test that an ufeff prefixed pofile returns a POFile instance. + """ + po = polib.pofile('tests/test_ufeff.po') + self.assertTrue(isinstance(po, polib.POFile)) + def test_previous_msgid_1(self): """ Test previous msgid multiline. @@ -206,7 +228,7 @@ exc = sys.exc_info()[1] msg = 'Syntax error in po file (line 4): unescaped double quote found' self.assertEqual(str(exc), msg) - + def test_detect_encoding1(self): """ Test that given encoding is returned when file has no encoding defined. @@ -238,7 +260,7 @@ try: self.assertEqual(polib.detect_encoding(data), 'UTF-8') finally: - f.close() + f.close() def test_detect_encoding5(self): """ @@ -275,26 +297,26 @@ polib.unescape('\\\\t and \\\\n and \\\\r and \\\\" and \\\\\\\\'), '\\t and \\n and \\r and \\" and \\\\' ) - + def test_pofile_with_subclass(self): """ - Test that the pofile function correctly returns an instance of the + Test that the pofile function correctly returns an instance of the passed in class """ class CustomPOFile(polib.POFile): pass - + pofile = polib.pofile('tests/test_indented.po', klass=CustomPOFile) self.assertEqual(pofile.__class__, CustomPOFile) - + def test_mofile_with_subclass(self): """ - Test that the mofile function correctly returns an instance of the + Test that the mofile function correctly returns an instance of the passed in class """ class CustomMOFile(polib.MOFile): pass - + mofile = polib.mofile('tests/test_utf8.mo', klass=CustomMOFile) self.assertEqual(mofile.__class__, CustomMOFile) @@ -318,6 +340,11 @@ po = polib.pofile('tests/test_weird_occurrences.po') self.assertEqual(po[0].occurrences, [('C:\\foo\\bar.py', '12')]) + def test_is_file(self): + self.assertTrue(polib._is_file(os.path.abspath(__file__))) + self.assertFalse(polib._is_file('This is not a file !!!!')) + self.assertFalse(polib._is_file(True)) + class TestBaseFile(unittest.TestCase): """ @@ -620,6 +647,62 @@ e = po.find("Whatever", by='msgid') self.assertTrue(isinstance(e, polib.POEntry)) + def test_compare1(self): + entry = polib.POEntry(msgid="foo") + other = polib.POEntry(msgctxt="Some context", msgid="foo") + self.assertNotEqual(entry, other) + + def test_compare2(self): + entry = polib.POEntry(msgid="foo") + other = polib.POEntry(msgid_plural="Plural", msgid="foo") + self.assertNotEqual(entry, other) + + def test_compare3(self): + entry = polib.POEntry( + msgid_plural="Plural", msgid="foo" + ) + other = polib.POEntry( + msgid_plural="Plural", msgstr_plural="Pluriel", msgid="foo" + ) + self.assertNotEqual(entry, other) + + def test_compare4(self): + entry = polib.POEntry(msgctxt="Some context", msgid="foo") + other = polib.POEntry(msgctxt="Other context", msgid="foo") + self.assertNotEqual(entry, other) + + def test_compare5(self): + entry = polib.POEntry(msgid_plural="Some plural", msgid="foo") + other = polib.POEntry(msgid_plural="Other plural", msgid="foo") + self.assertNotEqual(entry, other) + + def test_compare6(self): + entry = polib.POEntry(msgstr_plural="Some plural", msgid="foo") + other = polib.POEntry(msgstr_plural="Other plural", msgid="foo") + self.assertTrue(entry > other) + + def test_compare7(self): + entry = polib.POEntry(msgstr="Some msgstr", msgid="foo") + other = polib.POEntry(msgstr="Other msgstr", msgid="foo") + self.assertTrue(entry >= other) + self.assertNotEqual(entry, other) + entry = polib.POEntry(msgstr="A msgstr", msgid="foo") + other = polib.POEntry(msgstr="Other msgstr", msgid="foo") + self.assertTrue(entry <= other) + self.assertNotEqual(entry, other) + + def test_compare8(self): + entry = polib.POEntry( + msgctxt="Some context", msgid_plural="Plural", + msgstr_plural="Pluriel", msgid="foo" + ) + other = polib.POEntry( + msgctxt="Some context", msgid_plural="Plural", + msgstr_plural="Pluriel", msgid="foo" + ) + self.assertEqual(entry, other) + + class TestMoFile(unittest.TestCase): """ Tests for MoFile class. @@ -659,7 +742,7 @@ self.assertEqual(s1, s2) finally: os.remove(tmpfile) - + def test_msgctxt(self): #import pdb; pdb.set_trace() mo = polib.mofile('tests/test_msgctxt.mo') @@ -699,25 +782,5 @@ self.assertEqual(mo.__unicode__(), expected) -class TestTextWrap(unittest.TestCase): - - def test_wrap1(self): - text = ' Some line that is longer than fifteen characters (whitespace will not be preserved) ' - ret = polib.TextWrapper(width=15).wrap(text) - expected = [ - ' Some line', 'that is longer', 'than fifteen', 'characters', - '(whitespace', 'will not be', 'preserved)' - ] - self.assertEqual(ret, expected) - - def test_wrap2(self): - text = ' Some line that is longer than fifteen characters (whitespace will be preserved) ' - ret = polib.TextWrapper(width=15, drop_whitespace=False).wrap(text) - expected = [ - ' Some line ', 'that is longer ', 'than fifteen ', 'characters ', - '(whitespace ', 'will be ', 'preserved) ' - ] - self.assertEqual(ret, expected) - if __name__ == '__main__': unittest.main()