diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 2ee5ff3..0000000 --- a/.coveragerc +++ /dev/null @@ -1,9 +0,0 @@ -[run] -branch = True - -[report] -exclude_lines = - pragma: no cover - def __repr__ - if sys.version_info - if __name__ == '__main__': diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 4c89f4c..0000000 --- a/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -*.pyc -*.egg-info -/.tox -/MANIFEST -/dist -/docs/_build -/.coverage diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ba56d9a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: python - -python: - - "2.6" - - "2.7" - - "3.2" - - "3.3" - - "3.4" - -install: - - pip install --use-mirrors lxml -e . - -script: py.test diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index e98d213..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -include AUTHORS CHANGES LICENSE README.rst tox.ini .coveragerc -recursive-include docs * -prune docs/_build diff --git a/README.md b/README.md new file mode 100644 index 0000000..a516f4e --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# cssselect +CSS Selectors for Python + +Cssselect module bundled for use in Kodi diff --git a/docs/conf.py b/docs/conf.py deleted file mode 100644 index 22e6032..0000000 --- a/docs/conf.py +++ /dev/null @@ -1,250 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# cssselect documentation build configuration file, created by -# sphinx-quickstart on Tue Mar 27 14:20:34 2012. -# -# This file is execfile()d with the current directory set to its containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys, os, re - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) - -# -- General configuration ----------------------------------------------------- - -# If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', - 'sphinx.ext.doctest'] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix of source filenames. -source_suffix = '.rst' - -# The encoding of source files. -#source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = 'cssselect' -copyright = '2012, Simon Sapin' - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The full version, including alpha/beta/rc tags. -init_py = open(os.path.join(os.path.dirname(__file__), - '..', 'cssselect', '__init__.py')).read() -release = re.search("VERSION = '([^']+)'", init_py).group(1) -# The short X.Y version. -version = release.rstrip('dev') - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -#language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -#today = '' -# Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ['_build'] - -# The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -#add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -#show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] - - -# -- Options for HTML output --------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -#html_theme = 'agogo' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -#html_theme_options = {} - -# Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -#html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -#html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -#html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -#html_static_path = ['_static'] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -#html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -#html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -#html_additional_pages = {} - -# If false, no module index is generated. -#html_domain_indices = True - -# If false, no index is generated. -#html_use_index = True - -# If true, the index is split into individual pages for each letter. -#html_split_index = False - -# If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -#html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None - -# Output file base name for HTML help builder. -htmlhelp_basename = 'cssselectdoc' - - -# -- Options for LaTeX output -------------------------------------------------- - -latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', - -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', - -# Additional stuff for the LaTeX preamble. -#'preamble': '', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass [howto/manual]). -latex_documents = [ - ('index', 'cssselect.tex', 'cssselect Documentation', - 'Simon Sapin', 'manual'), -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -#latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -#latex_use_parts = False - -# If true, show page references after internal links. -#latex_show_pagerefs = False - -# If true, show URL addresses after external links. -#latex_show_urls = False - -# Documents to append as an appendix to all manuals. -#latex_appendices = [] - -# If false, no module index is generated. -#latex_domain_indices = True - - -# -- Options for manual page output -------------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'cssselect', 'cssselect Documentation', - ['Simon Sapin'], 1) -] - -# If true, show URL addresses after external links. -#man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------------ - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ('index', 'cssselect', 'cssselect Documentation', - 'Simon Sapin', 'cssselect', 'One line description of project.', - 'Miscellaneous'), -] - -# Documents to append as an appendix to all manuals. -#texinfo_appendices = [] - -# If false, no module index is generated. -#texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' - - -# Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'http://docs.python.org/': None} diff --git a/docs/index.rst b/docs/index.rst deleted file mode 100644 index 4ac7401..0000000 --- a/docs/index.rst +++ /dev/null @@ -1,153 +0,0 @@ -.. module:: cssselect - -.. include:: ../README.rst - - -.. contents:: Contents - :local: - :depth: 1 - -Quickstart -========== - -Use :class:`HTMLTranslator` for HTML documents, :class:`GenericTranslator` -for "generic" XML documents. (The former has a more useful translation -for some selectors, based on HTML-specific element types or attributes.) - - -.. sourcecode:: pycon - - >>> from cssselect import GenericTranslator, SelectorError - >>> try: - ... expression = GenericTranslator().css_to_xpath('div.content') - ... except SelectorError: - ... print('Invalid selector.') - ... - >>> print(expression) - descendant-or-self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' content ')] - -The resulting expression can be used with lxml's `XPath engine`_: - -.. _XPath engine: http://lxml.de/xpathxslt.html#xpath - -.. sourcecode:: pycon - - >>> from lxml.etree import fromstring - >>> document = fromstring(''' - ...
- ...
text
- ...
- ... ''') - >>> [e.get('id') for e in document.xpath(expression)] - ['inner'] - -User API -======== - -In CSS3 Selectors terms, the top-level object is a `group of selectors`_, a -sequence of comma-separated selectors. For example, ``div, h1.title + p`` -is a group of two selectors. - -.. _group of selectors: http://www.w3.org/TR/selectors/#grouping - -.. autofunction:: parse -.. autoclass:: Selector() - :members: - -.. autoclass:: FunctionalPseudoElement - -.. autoclass:: GenericTranslator - :members: css_to_xpath, selector_to_xpath - -.. autoclass:: HTMLTranslator - -Exceptions ----------- - -.. autoexception:: SelectorError -.. autoexception:: SelectorSyntaxError -.. autoexception:: ExpressionError - - -Supported selectors -=================== - -This library implements CSS3 selectors as described in `the W3C specification -`_. -In this context however, there is no interactivity or history of visited links. -Therefore, these pseudo-classes are accepted but never match anything: - -* ``:hover`` -* ``:active`` -* ``:focus`` -* ``:target`` -* ``:visited`` - -Additionally, these depend on document knowledge and only have a useful -implementation in :class:`HTMLTranslator`. In :class:`GenericTranslator`, -they never match: - -* ``:link`` -* ``:enabled`` -* ``:disabled`` -* ``:checked`` - -These applicable pseudo-classes are not yet implemented: - -* ``*:first-of-type``, ``*:last-of-type``, ``*:nth-of-type``, - ``*:nth-last-of-type``, ``*:only-of-type``. All of these work when - you specify an element type, but not with ``*`` - -On the other hand, *cssselect* supports some selectors that are not -in the Level 3 specification: - -* The ``:contains(text)`` pseudo-class that existed in `an early draft`_ - but was then removed. -* The ``!=`` attribute operator. ``[foo!=bar]`` is the same as - ``:not([foo=bar])`` -* ``:not()`` accepts a *sequence of simple selectors*, not just single - *simple selector*. For example, ``:not(a.important[rel])`` is allowed, - even though the negation contains 3 *simple selectors*. - -.. _an early draft: http://www.w3.org/TR/2001/CR-css3-selectors-20011113/#content-selectors - -.. - The following claim was copied from lxml: - - """ - XPath has underspecified string quoting rules (there seems to be no - string quoting at all), so if you use expressions that contain - characters that requiring quoting you might have problems with the - translation from CSS to XPath. - """ - - It seems "string quoting" meant "quote escaping". There is indeed - no quote escaping, but the xpath_literal method handles this. - It should not be a problem anymore. - - -Customizing the translation -=========================== - -Just like :class:`HTMLTranslator` is a subclass of :class:`GenericTranslator`, -you can make new sub-classes of either of them and override some methods. -This enables you, for example, to customize how some pseudo-class is -implemented without forking or monkey-patching cssselect. - -The "customization API" is the set of methods in translation classes -and their signature. You can look at the `source code`_ to see how it works. -However, be aware that this API is not very stable yet. It might change -and break your sub-class. - -.. _source code: https://github.com/SimonSapin/cssselect/blob/master/cssselect/xpath.py - - -Namespaces -========== - -In CSS you can use ``namespace-prefix|element``, similar to -``namespace-prefix:element`` in an XPath expression. In fact, it maps -one-to-one. How prefixes are mapped to namespace URIs depends on the -XPath implementation. - -.. include:: ../CHANGES diff --git a/script.module.cssselect.zip b/script.module.cssselect.zip new file mode 100644 index 0000000..ddc97cf Binary files /dev/null and b/script.module.cssselect.zip differ diff --git a/AUTHORS b/script.module.cssselect/AUTHORS similarity index 100% rename from AUTHORS rename to script.module.cssselect/AUTHORS diff --git a/CHANGES b/script.module.cssselect/CHANGES similarity index 100% rename from CHANGES rename to script.module.cssselect/CHANGES diff --git a/LICENSE b/script.module.cssselect/LICENSE similarity index 100% rename from LICENSE rename to script.module.cssselect/LICENSE diff --git a/README.rst b/script.module.cssselect/README similarity index 100% rename from README.rst rename to script.module.cssselect/README diff --git a/script.module.cssselect/addon.xml b/script.module.cssselect/addon.xml new file mode 100644 index 0000000..bcdd87e --- /dev/null +++ b/script.module.cssselect/addon.xml @@ -0,0 +1,17 @@ + + + + + + + + parses CSS3 Selectors and translates them to XPath 1.0 + Packed for Kodi from https://github.com/SimonSapin/cssselect/ + all + + Apache2 + https://github.com/SimonSapin/cssselect/issues + https://pypi.python.org/pypi/cssselect + https://github.com/SimonSapin/cssselect/ + + diff --git a/cssselect/__init__.py b/script.module.cssselect/cssselect/__init__.py similarity index 100% rename from cssselect/__init__.py rename to script.module.cssselect/cssselect/__init__.py diff --git a/cssselect/parser.py b/script.module.cssselect/cssselect/parser.py similarity index 100% rename from cssselect/parser.py rename to script.module.cssselect/cssselect/parser.py diff --git a/cssselect/tests.py b/script.module.cssselect/cssselect/tests.py old mode 100755 new mode 100644 similarity index 100% rename from cssselect/tests.py rename to script.module.cssselect/cssselect/tests.py diff --git a/cssselect/xpath.py b/script.module.cssselect/cssselect/xpath.py similarity index 100% rename from cssselect/xpath.py rename to script.module.cssselect/cssselect/xpath.py diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 7a3317f..0000000 --- a/setup.cfg +++ /dev/null @@ -1,13 +0,0 @@ -[build_sphinx] -source-dir = docs -build-dir = docs/_build -#all_files = 1 - -[upload_sphinx] # Sphinx-PyPI-upload -upload-dir = docs/_build/html - -[pytest] -python_files=tests.py - -[bdist_wheel] -universal = 1 diff --git a/setup.py b/setup.py deleted file mode 100644 index 42bde1f..0000000 --- a/setup.py +++ /dev/null @@ -1,44 +0,0 @@ -# coding: utf-8 - -import re -import os.path -try: - from setuptools import setup - extra_kwargs = {'test_suite': 'cssselect.tests'} -except ImportError: - from distutils.core import setup - extra_kwargs = {} - - -ROOT = os.path.dirname(__file__) -README = open(os.path.join(ROOT, 'README.rst')).read() -INIT_PY = open(os.path.join(ROOT, 'cssselect', '__init__.py')).read() -VERSION = re.search("VERSION = '([^']+)'", INIT_PY).group(1) - - -setup( - name='cssselect', - version=VERSION, - author='Ian Bicking', - author_email='ianb@colorstudy.com', - maintainer='Simon Sapin', - maintainer_email='simon.sapin@exyr.org', - description= - 'cssselect parses CSS3 Selectors and translates them to XPath 1.0', - long_description=README, - url='http://packages.python.org/cssselect/', - license='BSD', - packages=['cssselect'], - classifiers=[ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: BSD License', - '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.2', - ], - **extra_kwargs -) diff --git a/tox.ini b/tox.ini deleted file mode 100644 index ca053d8..0000000 --- a/tox.ini +++ /dev/null @@ -1,10 +0,0 @@ -[tox] -envlist = py25,py26,py27,py32,py33 - -[testenv] -deps=lxml -commands = python cssselect/tests.py - -[testenv:py25] -setenv = - PIP_INSECURE = 1