Portal Auth and Cursed Screech Updates

This commit is contained in:
sud0nick
2018-07-15 23:51:02 -04:00
parent ae53ba8ea1
commit 5189bc5bc3
76 changed files with 2585 additions and 5974 deletions

View File

@@ -0,0 +1,24 @@
div.body {
text-align: left;
}
div.document p, div.document ul {
margin-top: 0;
margin-bottom: 1em;
}
div.document ul ul {
margin-top: 0;
margin-bottom: .5em;
}
.field-name {
padding-right: .5em;
}
table.field-list p, table.field-list ul {
margin-bottom: .5em;
}
table {
border-collapse: collapse;
margin-bottom: 1em;
}
table.docutils td, table.docutils th {
padding: .2em .5em;
}

View File

@@ -0,0 +1,4 @@
{% extends "!layout.html" %}
{% block extrahead %}
<link rel="stylesheet" href="{{ pathto('_static/custom.css', 1) }}" />
{% endblock %}

View File

@@ -0,0 +1 @@
.. include:: ../CHANGES

View File

@@ -0,0 +1,252 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# tinycss 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
# 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.viewcode', '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 = 'tinycss'
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.
#release = '0.1dev'
import re
with open(os.path.join(os.path.dirname(__file__), '..',
'tinycss', 'version.py')) as init_py:
release = re.search("VERSION = '([^']+)'", init_py.read()).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
# "<project> v<release> 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 <link> 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 = 'tinycssdoc'
# -- 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', 'tinycss.tex', 'tinycss 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', 'tinycss', 'tinycss 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', 'tinycss', 'tinycss Documentation',
'Simon Sapin', 'tinycss', '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}

View File

@@ -0,0 +1,116 @@
CSS 3 Modules
=============
.. _selectors3:
Selectors 3
-----------
.. currentmodule:: tinycss.css21
On :attr:`RuleSet.selector`, the :meth:`~.token_data.TokenList.as_css` method
can be used to serialize a selector back to an Unicode string.
>>> import tinycss
>>> stylesheet = tinycss.make_parser().parse_stylesheet(
... 'div.error, #root > section:first-letter { color: red }')
>>> selector_string = stylesheet.rules[0].selector.as_css()
>>> selector_string
'div.error, #root > section:first-letter'
This string can be parsed by cssselect_. The parsed objects have information
about pseudo-elements and selector specificity.
.. _cssselect: http://packages.python.org/cssselect/
>>> import cssselect
>>> selectors = cssselect.parse(selector_string)
>>> [s.specificity() for s in selectors]
[(0, 1, 1), (1, 0, 2)]
>>> [s.pseudo_element for s in selectors]
[None, 'first-letter']
These objects can in turn be translated to XPath expressions. Note that
the translation ignores pseudo-elements, you have to account for them
somehow or reject selectors with pseudo-elements.
>>> xpath = cssselect.HTMLTranslator().selector_to_xpath(selectors[1])
>>> xpath
"descendant-or-self::*[@id = 'root']/section"
Finally, the XPath expressions can be used with lxml_ to find the matching
elements.
>>> from lxml import etree
>>> compiled_selector = etree.XPath(xpath)
>>> document = etree.fromstring('''<section id="root">
... <section id="head">Title</section>
... <section id="content">
... Lorem <section id="sub-section">ipsum</section>
... </section>
... </section>''')
>>> [el.get('id') for el in compiled_selector(document)]
['head', 'content']
.. _lxml: http://lxml.de/xpathxslt.html#xpath
Find more details in the `cssselect documentation`_.
.. _cssselect documentation: http://packages.python.org/cssselect/
.. module:: tinycss.color3
Color 3
-------
This module implements parsing for the *<color>* values, as defined in
`CSS 3 Color <http://www.w3.org/TR/css3-color/>`_.
The (deprecated) CSS2 system colors are not supported, but you can
easily test for them if you want as they are simple ``IDENT`` tokens.
For example::
if token.type == 'IDENT' and token.value == 'ButtonText':
return ...
All other values types *are* supported:
* Basic, extended (X11) and transparent color keywords;
* 3-digit and 6-digit hexadecimal notations;
* ``rgb()``, ``rgba()``, ``hsl()`` and ``hsla()`` functional notations.
* ``currentColor``
This module does not integrate with a parser class. Instead, it provides
a function that can parse tokens as found in :attr:`.css21.Declaration.value`,
for example.
.. autofunction:: parse_color
.. autofunction:: parse_color_string
.. autoclass:: RGBA
.. module:: tinycss.page3
Paged Media 3
-------------
.. autoclass:: CSSPage3Parser
.. autoclass:: MarginRule
.. module:: tinycss.fonts3
Fonts 3
-------
.. autoclass:: CSSFonts3Parser
.. autoclass:: FontFaceRule
.. autoclass:: FontFeatureValuesRule
.. autoclass:: FontFeatureRule
Other CSS modules
-----------------
To add support for new CSS syntax, see :ref:`extending`.

View File

@@ -0,0 +1,97 @@
.. _extending:
Extending the parser
====================
Modules such as :mod:`.page3` extend the CSS 2.1 parser to add support for
CSS 3 syntax.
They do so by sub-classing :class:`.css21.CSS21Parser` and overriding/extending
some of its methods. If fact, the parser is made of methods in a class
(rather than a set of functions) solely to enable this kind of sub-classing.
tinycss is designed to enable you to have parser subclasses outside of
tinycss, without monkey-patching. If however the syntax you added is for a
W3C specification, consider including your subclass in a new tinycss module
and send a pull request: see :ref:`hacking`.
.. currentmodule:: tinycss.css21
Example: star hack
------------------
.. _star hack: https://en.wikipedia.org/wiki/CSS_filter#Star_hack
The `star hack`_ uses invalid declarations that are only parsed by some
versions of Internet Explorer. By default, tinycss ignores invalid
declarations and logs an error.
>>> from tinycss.css21 import CSS21Parser
>>> css = '#elem { width: [W3C Model Width]; *width: [BorderBox Model]; }'
>>> stylesheet = CSS21Parser().parse_stylesheet(css)
>>> stylesheet.errors
[ParseError('Parse error at 1:35, expected a property name, got DELIM',)]
>>> [decl.name for decl in stylesheet.rules[0].declarations]
['width']
If for example a minifier based on tinycss wants to support the star hack,
it can by extending the parser::
>>> class CSSStarHackParser(CSS21Parser):
... def parse_declaration(self, tokens):
... has_star_hack = (tokens[0].type == 'DELIM' and tokens[0].value == '*')
... if has_star_hack:
... tokens = tokens[1:]
... declaration = super(CSSStarHackParser, self).parse_declaration(tokens)
... declaration.has_star_hack = has_star_hack
... return declaration
...
>>> stylesheet = CSSStarHackParser().parse_stylesheet(css)
>>> stylesheet.errors
[]
>>> [(d.name, d.has_star_hack) for d in stylesheet.rules[0].declarations]
[('width', False), ('width', True)]
This class extends the :meth:`~CSS21Parser.parse_declaration` method.
It removes any ``*`` delimeter :class:`~.token_data.Token` at the start of
a declaration, and adds a ``has_star_hack`` boolean attribute on parsed
:class:`Declaration` objects: ``True`` if a ``*`` was removed, ``False`` for
“normal” declarations.
Parser methods
--------------
In addition to methods of the user API (see :ref:`parsing`), here
are the methods of the CSS 2.1 parser that can be overriden or extended:
.. automethod:: CSS21Parser.parse_rules
.. automethod:: CSS21Parser.read_at_rule
.. automethod:: CSS21Parser.parse_at_rule
.. automethod:: CSS21Parser.parse_media
.. automethod:: CSS21Parser.parse_page_selector
.. automethod:: CSS21Parser.parse_declarations_and_at_rules
.. automethod:: CSS21Parser.parse_ruleset
.. automethod:: CSS21Parser.parse_declaration_list
.. automethod:: CSS21Parser.parse_declaration
.. automethod:: CSS21Parser.parse_value_priority
Unparsed at-rules
-----------------
.. autoclass:: AtRule
.. module:: tinycss.parsing
Parsing helper functions
------------------------
The :mod:`tinycss.parsing` module contains helper functions for parsing
tokens into a more structured form:
.. autofunction:: strip_whitespace
.. autofunction:: split_on_comma
.. autofunction:: validate_value
.. autofunction:: validate_block
.. autofunction:: validate_any

View File

@@ -0,0 +1,117 @@
.. _hacking:
Hacking tinycss
===============
.. highlight:: sh
Bugs and feature requests
-------------------------
Bug reports, feature requests and other issues should got to the
`tinycss issue tracker`_ on Github. Any suggestion or feedback is welcome.
Please include in full any error message, trackback or other detail that
could be helpful.
.. _tinycss issue tracker: https://github.com/SimonSapin/tinycss/issues
Installing the development version
----------------------------------
First, get the latest git version::
git clone https://github.com/SimonSapin/tinycss.git
cd tinycss
You will need Cython_ and pytest_. Installing in a virtualenv_ is recommended::
virtualenv env
. env/bin/activate
pip install Cython pytest
.. _Cython: http://cython.org/
.. _pytest: http://pytest.org/
.. _virtualenv: http://www.virtualenv.org/
Then, install tinycss in-place with pips *editable mode*. This will also
build the accelerators::
pip install -e .
Running the test suite
----------------------
Once you have everything installed (see above), just run pytest from the
*tinycss* directory::
py.test
If the accelerators are not available for some reason, use the
``TINYCSS_SKIP_SPEEDUPS_TESTS`` environment variable::
TINYCSS_SKIP_SPEEDUPS_TESTS=1 py.test
If you get test failures on a fresh git clone, something may have gone wrong
during the installation. Otherwise, you probably found a bug. Please
`report it <#bugs-and-feature-requests>`_.
Test in multiple Python versions with tox
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tox_ automatically creates virtualenvs for various Python versions and
runs the test suite there::
pip install tox
Change to the projects root directory and just run::
tox
.. _tox: http://tox.testrun.org/
tinycss comes with a pre-configured ``tox.ini`` file to test in CPython
2.6, 2.7, 3.1 and 3.2 as well as PyPy. You can change that with the ``-e``
parameter::
tox -e py27,py32
If you use ``--`` in the arguments passed to tox, further arguments
are passed to the underlying ``py.test`` command::
tox -- -x --pdb
Building the documentation
--------------------------
This documentation is made with Sphinx_::
pip install Sphinx
.. _Sphinx: http://sphinx.pocoo.org/
To build the HTML version of the documentation, change to the projects root
directory and run::
python setup.py build_sphinx
The built HTML files are in ``docs/_build/html``.
Making a patch and a pull request
---------------------------------
If you would like to see something included in tinycss, please fork
`the repository <https://github.com/SimonSapin/tinycss/>`_ on Github
and make a pull request. Make sure to include tests for your change.
Mailing-list
------------
tinycss does not have a mailing-list of its own for now, but the
`WeasyPrint mailing-list <http://weasyprint.org/community/>`_
is appropriate to discuss it.

View File

@@ -0,0 +1,50 @@
.. include:: ../README.rst
Requirements
------------
`tinycss is tested <https://travis-ci.org/Kozea/tinycss>`_ on CPython 2.7, 3.3,
3.4 and 3.5 as well as PyPy 5.3 and PyPy3 2.4; it should work on any
implementation of **Python 2.7 or later version (including 3.x)** of the
language.
Cython_ is used for optional accelerators but is only required for
development versions on tinycss.
.. _Cython: http://cython.org/
Installation
------------
Installing with `pip <http://www.pip-installer.org/>`_ should Just Work:
.. code-block:: sh
pip install tinycss
The release tarballs contain pre-*cythoned* C files for the accelerators:
you will not need Cython to install like this.
If the accelerators fail to build for some reason, tinycss will
print a warning and fall back to a pure-Python installation.
Documentation
-------------
.. Have this page in the sidebar, but do not show a link to itself here:
.. toctree::
:hidden:
self
.. toctree::
:maxdepth: 2
parsing
css3
extending
hacking
changelog

View File

@@ -0,0 +1,97 @@
Parsing with tinycss
====================
.. highlight:: python
Quickstart
----------
Import *tinycss*, make a parser object with the features you want,
and parse a stylesheet:
.. doctest::
>>> import tinycss
>>> parser = tinycss.make_parser('page3')
>>> stylesheet = parser.parse_stylesheet_bytes(b'''@import "foo.css";
... p.error { color: red } @lorem-ipsum;
... @page tables { size: landscape }''')
>>> stylesheet.rules
[<ImportRule 1:1 foo.css>, <RuleSet at 2:5 p.error>, <PageRule 3:5 ('tables', None)>]
>>> stylesheet.errors
[ParseError('Parse error at 2:29, unknown at-rule in stylesheet context: @lorem-ipsum',)]
Youll get a :class:`~tinycss.css21.Stylesheet` object which contains
all the parsed content as well as a list of encountered errors.
Parsers
-------
Parsers are subclasses of :class:`tinycss.css21.CSS21Parser`. Various
subclasses add support for more syntax. You can choose which features to
enable by making a new parser class with multiple inheritance, but there
is also a convenience function to do that:
.. module:: tinycss
.. autofunction:: make_parser
.. module:: tinycss.css21
.. _parsing:
Parsing a stylesheet
~~~~~~~~~~~~~~~~~~~~
Parser classes have three different methods to parse CSS stylesheet,
depending on whether you have a file, a byte string, or an Unicode string.
.. autoclass:: CSS21Parser
:members: parse_stylesheet_file, parse_stylesheet_bytes, parse_stylesheet
Parsing a ``style`` attribute
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. automethod:: CSS21Parser.parse_style_attr
Parsed objects
--------------
These data structures make up the results of the various parsing methods.
.. autoclass:: tinycss.parsing.ParseError()
.. autoclass:: Stylesheet()
.. note::
All subsequent objects have :obj:`line` and :obj:`column` attributes (not
repeated every time fore brevity) that indicate where in the CSS source
this object was read.
.. autoclass:: RuleSet()
.. autoclass:: ImportRule()
.. autoclass:: MediaRule()
.. autoclass:: PageRule()
.. autoclass:: Declaration()
Tokens
------
Some parts of a stylesheet (such as selectors in CSS 2.1 or property values)
are not parsed by tinycss. They appear as tokens instead.
.. module:: tinycss.token_data
.. autoclass:: TokenList()
:member-order: bysource
:members:
.. autoclass:: Token()
:members:
.. autoclass:: tinycss.speedups.CToken()
.. autoclass:: ContainerToken()
:members:
.. autoclass:: FunctionToken()