Hello community, here is the log from the commit of package python-cssselect for openSUSE:Factory checked in at 2013-04-02 12:52:29 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-cssselect (Old) and /work/SRC/openSUSE:Factory/.python-cssselect.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-cssselect", Maintainer is "" Changes: -------- --- /work/SRC/openSUSE:Factory/python-cssselect/python-cssselect.changes 2013-01-21 17:44:57.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.python-cssselect.new/python-cssselect.changes 2013-04-02 12:52:30.000000000 +0200 @@ -1,0 +2,15 @@ +Thu Mar 28 20:18:04 UTC 2013 - [email protected] + +- updated to 0.8 + Changelog (http://pythonhosted.org/cssselect/#changelog): + Released on 2013-03-15. + Improvements: + #22 Let extended translators override what XPathExpr class is used + #19 Use the built-in lang() XPath function for implementing the :lang() pseudo-class with XML documents. This is probably faster than ancestor-or-self::. + + Bug fixes: + #14 Fix non-ASCII pseudo-classes. (Invalid selector instead of crash.) + #20 As per the spec, elements containing only whitespace are not considered empty for the :empty pseudo-class. + + +------------------------------------------------------------------- --- /work/SRC/openSUSE:Factory/python-cssselect/python3-cssselect.changes 2013-01-21 17:44:57.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.python-cssselect.new/python3-cssselect.changes 2013-04-02 12:52:30.000000000 +0200 @@ -1,0 +2,15 @@ +Thu Mar 28 20:18:57 UTC 2013 - [email protected] + +- updated to 0.8 + Changelog (http://pythonhosted.org/cssselect/#changelog): + Released on 2013-03-15. + Improvements: + #22 Let extended translators override what XPathExpr class is used + #19 Use the built-in lang() XPath function for implementing the :lang() pseudo-class with XML documents. This is probably faster than ancestor-or-self::. + + Bug fixes: + #14 Fix non-ASCII pseudo-classes. (Invalid selector instead of crash.) + #20 As per the spec, elements containing only whitespace are not considered empty for the :empty pseudo-class. + + +------------------------------------------------------------------- Old: ---- cssselect-0.7.1.tar.gz New: ---- cssselect-0.8.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-cssselect.spec ++++++ --- /var/tmp/diff_new_pack.USiNQt/_old 2013-04-02 12:52:32.000000000 +0200 +++ /var/tmp/diff_new_pack.USiNQt/_new 2013-04-02 12:52:32.000000000 +0200 @@ -13,15 +13,16 @@ # published by the Open Source Initiative. # Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Name: python-cssselect -Version: 0.7.1 +Version: 0.8 Release: 0 -License: BSD-3-Clause Summary: CSS3 selectors for Python -Url: http://packages.python.org/cssselect/ +License: BSD-3-Clause Group: Development/Languages/Python +Url: http://packages.python.org/cssselect/ Source: http://pypi.python.org/packages/source/c/cssselect/cssselect-%{version}.tar.gz BuildRequires: python-devel BuildRoot: %{_tmppath}/%{name}-%{version}-build python3-cssselect.spec: same change ++++++ cssselect-0.7.1.tar.gz -> cssselect-0.8.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cssselect-0.7.1/AUTHORS new/cssselect-0.8/AUTHORS --- old/cssselect-0.7.1/AUTHORS 2012-04-15 07:56:38.000000000 +0200 +++ new/cssselect-0.8/AUTHORS 2013-03-14 19:52:38.000000000 +0100 @@ -1,4 +1,5 @@ Ian Bicking Laurence Rowe +Simon Potter Simon Sapin Stefan Behnel diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cssselect-0.7.1/CHANGES new/cssselect-0.8/CHANGES --- old/cssselect-0.7.1/CHANGES 2012-06-14 23:37:52.000000000 +0200 +++ new/cssselect-0.8/CHANGES 2013-03-15 16:51:05.000000000 +0100 @@ -1,6 +1,30 @@ Changelog ========= +Version 0.8 +----------- + +Released on 2013-03-15. + +Improvements: + +* `#22 <https://github.com/SimonSapin/cssselect/issues/22>`_ + Let extended translators override what XPathExpr class is used +* `#19 <https://github.com/SimonSapin/cssselect/issues/19>`_ + Use the built-in ``lang()`` XPath function + for implementing the ``:lang()`` pseudo-class + with XML documents. + This is probably faster than ``ancestor-or-self::``. + +Bug fixes: + +* `#14 <https://github.com/SimonSapin/cssselect/issues/14>`_ + Fix non-ASCII pseudo-classes. (Invalid selector instead of crash.) +* `#20 <https://github.com/SimonSapin/cssselect/issues/20>`_ + As per the spec, elements containing only whitespace are not considered empty + for the ``:empty`` pseudo-class. + + Version 0.7.1 ------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cssselect-0.7.1/PKG-INFO new/cssselect-0.8/PKG-INFO --- old/cssselect-0.7.1/PKG-INFO 2012-06-14 23:38:49.000000000 +0200 +++ new/cssselect-0.8/PKG-INFO 2013-03-15 16:53:20.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: cssselect -Version: 0.7.1 +Version: 0.8 Summary: cssselect parses CSS3 Selectors and translates them to XPath 1.0 Home-page: http://packages.python.org/cssselect/ Author: Simon Sapin diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cssselect-0.7.1/cssselect/__init__.py new/cssselect-0.8/cssselect/__init__.py --- old/cssselect-0.7.1/cssselect/__init__.py 2012-06-14 23:36:47.000000000 +0200 +++ new/cssselect-0.8/cssselect/__init__.py 2013-03-15 16:52:22.000000000 +0100 @@ -18,5 +18,5 @@ from cssselect.xpath import GenericTranslator, HTMLTranslator, ExpressionError -VERSION = '0.7.1' +VERSION = '0.8' __version__ = VERSION diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cssselect-0.7.1/cssselect/tests.py new/cssselect-0.8/cssselect/tests.py --- old/cssselect-0.7.1/cssselect/tests.py 2012-06-14 23:33:00.000000000 +0200 +++ new/cssselect-0.8/cssselect/tests.py 2013-03-14 19:52:38.000000000 +0100 @@ -344,9 +344,9 @@ assert xpath('e:only-of-type') == ( "e[last() = 1]") assert xpath('e:empty') == ( - "e[not(*) and not(normalize-space())]") + "e[not(*) and not(string-length())]") assert xpath('e:EmPTY') == ( - "e[not(*) and not(normalize-space())]") + "e[not(*) and not(string-length())]") assert xpath('e:root') == ( "e[not(parent::*)]") assert xpath('e:hover') == ( @@ -385,6 +385,7 @@ assert xpath(r'[h\]ref]') == ( "*[attribute::*[name() = 'h]ref']]") + self.assertRaises(ExpressionError, xpath, u(':fİrst-child')) self.assertRaises(ExpressionError, xpath, ':first-of-type') self.assertRaises(ExpressionError, xpath, ':only-of-type') self.assertRaises(ExpressionError, xpath, ':last-of-type') @@ -463,6 +464,30 @@ assert series('foo') == None assert series('n+') == None + def test_lang(self): + document = etree.fromstring(XMLLANG_IDS) + sort_key = dict( + (el, count) for count, el in enumerate(document.getiterator()) + ).__getitem__ + css_to_xpath = GenericTranslator().css_to_xpath + + def langid(selector): + xpath = css_to_xpath(selector) + items = document.xpath(xpath) + items.sort(key=sort_key) + return [element.get('id', 'nil') for element in items] + + assert langid(':lang("EN")') == ['first', 'second', 'third', 'fourth'] + assert langid(':lang("en-us")') == ['second', 'fourth'] + assert langid(':lang(en-nz)') == ['third'] + assert langid(':lang(fr)') == ['fifth'] + assert langid(':lang(ru)') == ['sixth'] + assert langid(":lang('ZH')") == ['eighth'] + assert langid(':lang(de) :lang(zh)') == ['eighth'] + assert langid(':lang(en), :lang(zh)') == [ + 'first', 'second', 'third', 'fourth', 'eighth'] + assert langid(':lang(es)') == [] + def test_select(self): document = etree.fromstring(HTML_IDS) sort_key = dict( @@ -550,7 +575,7 @@ assert pcss('p:only-of-type') == ['paragraph'] assert pcss('a:empty', 'a:EMpty') == ['name-anchor'] assert pcss('li:empty') == [ - 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li'] + 'third-li', 'fourth-li', 'fifth-li', 'sixth-li'] assert pcss(':root', 'html:root') == ['html'] assert pcss('li:root', '* :root') == [] assert pcss('*:contains("link")', ':CONtains("link")') == [ @@ -674,6 +699,20 @@ assert count('div[class!=madeup]') == 243 # ? Seems right assert count('div[class~=dialog]') == 51 # ? Seems right +XMLLANG_IDS = ''' +<test> + <a id="first" xml:lang="en">a</a> + <b id="second" xml:lang="en-US">b</b> + <c id="third" xml:lang="en-Nz">c</c> + <d id="fourth" xml:lang="En-us">d</d> + <e id="fifth" xml:lang="fr">e</e> + <f id="sixth" xml:lang="ru">f</f> + <g id="seventh" xml:lang="de"> + <h id="eighth" xml:lang="zh"/> + </g> +</test> +''' + HTML_IDS = ''' <html id="html"><head> <link id="link-href" href="foo" /> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cssselect-0.7.1/cssselect/xpath.py new/cssselect-0.8/cssselect/xpath.py --- old/cssselect-0.7.1/cssselect/xpath.py 2012-06-14 23:17:51.000000000 +0200 +++ new/cssselect-0.8/cssselect/xpath.py 2013-03-14 19:52:38.000000000 +0100 @@ -102,6 +102,19 @@ of element names and attribute names. """ + + #### + #### HERE BE DRAGONS + #### + #### You are welcome to hook into this to change some behavior, + #### but do so at your own risks. + #### Until is has recieved a lot more work and review, + #### I reserve the right to change this API in backward-incompatible ways + #### with any minor version of cssselect. + #### See https://github.com/SimonSapin/cssselect/pull/22 + #### -- Simon Sapin. + #### + combinator_mapping = { ' ': 'descendant', '>': 'child', @@ -146,6 +159,9 @@ lower_case_attribute_names = False lower_case_attribute_values = False + # class used to represent and xpath expression + xpathexpr_cls = XPathExpr + def css_to_xpath(self, css, prefix='descendant-or-self::'): """Translate a *group of selectors* to XPath. @@ -190,7 +206,7 @@ if not tree: raise TypeError('Expected a parsed selector, got %r' % (selector,)) xpath = self.xpath(tree) - assert isinstance(xpath, XPathExpr) # help debug a missing 'return' + assert isinstance(xpath, self.xpathexpr_cls) # help debug a missing 'return' return (prefix or '') + _unicode(xpath) @staticmethod @@ -235,6 +251,8 @@ def xpath_function(self, function): """Translate a functional pseudo-class.""" method = 'xpath_%s_function' % function.name.replace('-', '_') + # getattr() with a non-ASCII name fails on Python 2.x + method = method.encode('ascii', 'replace').decode('ascii') method = getattr(self, method, None) if not method: raise ExpressionError( @@ -244,6 +262,8 @@ def xpath_pseudo(self, pseudo): """Translate a pseudo-class.""" method = 'xpath_%s_pseudo' % pseudo.ident.replace('-', '_') + # getattr() with a non-ASCII name fails on Python 2.x + method = method.encode('ascii', 'replace').decode('ascii') method = getattr(self, method, None) if not method: # TODO: better error message for pseudo-elements? @@ -301,7 +321,7 @@ # http://www.w3.org/TR/css3-namespace/#prefixes element = '%s:%s' % (selector.namespace, element) safe = safe and is_safe_name(selector.namespace) - xpath = XPathExpr(element=element) + xpath = self.xpathexpr_cls(element=element) if not safe: xpath.add_name_test() return xpath @@ -406,12 +426,7 @@ % function.arguments) value = function.arguments[0].value return xpath.add_condition( - "ancestor-or-self::*[@lang][1][starts-with(concat(" - # XPath 1.0 has no lower-case function... - "translate(@%s, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', " - "'abcdefghijklmnopqrstuvwxyz'), " - "'-'), %s)]" - % (self.lang_attribute, self.xpath_literal(value.lower() + '-'))) + "lang(%s)" % (self.xpath_literal(value))) # Pseudo: dispatch by pseudo-class name @@ -455,7 +470,7 @@ return xpath.add_condition('last() = 1') def xpath_empty_pseudo(self, xpath): - return xpath.add_condition("not(*) and not(normalize-space())") + return xpath.add_condition("not(*) and not(string-length())") def pseudo_never_matches(self, xpath): """Common implementation for pseudo-classes that never match.""" @@ -571,6 +586,20 @@ "and (name(.) = 'input' or name(.) = 'command')" "and (@type = 'checkbox' or @type = 'radio'))") + def xpath_lang_function(self, xpath, function): + if function.argument_types() not in (['STRING'], ['IDENT']): + raise ExpressionError( + "Expected a single string or ident for :lang(), got %r" + % function.arguments) + value = function.arguments[0].value + return xpath.add_condition( + "ancestor-or-self::*[@lang][1][starts-with(concat(" + # XPath 1.0 has no lower-case function... + "translate(@%s, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', " + "'abcdefghijklmnopqrstuvwxyz'), " + "'-'), %s)]" + % (self.lang_attribute, self.xpath_literal(value.lower() + '-'))) + def xpath_link_pseudo(self, xpath): return xpath.add_condition("@href and " "(name(.) = 'a' or name(.) = 'link' or name(.) = 'area')") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cssselect-0.7.1/cssselect.egg-info/PKG-INFO new/cssselect-0.8/cssselect.egg-info/PKG-INFO --- old/cssselect-0.7.1/cssselect.egg-info/PKG-INFO 2012-06-14 23:38:49.000000000 +0200 +++ new/cssselect-0.8/cssselect.egg-info/PKG-INFO 2013-03-15 16:53:20.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: cssselect -Version: 0.7.1 +Version: 0.8 Summary: cssselect parses CSS3 Selectors and translates them to XPath 1.0 Home-page: http://packages.python.org/cssselect/ Author: Simon Sapin diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cssselect-0.7.1/tox.ini new/cssselect-0.8/tox.ini --- old/cssselect-0.7.1/tox.ini 2012-04-15 10:34:41.000000000 +0200 +++ new/cssselect-0.8/tox.ini 2012-10-18 17:59:35.000000000 +0200 @@ -1,5 +1,5 @@ [tox] -envlist = py24,py25,py26,py27,py31,py32 +envlist = py24,py25,py26,py27,py31,py32,py33 [testenv] deps=lxml -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
