paka.sitemaps


Namepaka.sitemaps JSON
Version 1.6.1 PyPI version JSON
download
home_pagehttps://github.com/PavloKapyshin/paka.sitemaps
Summary
upload_time2017-05-17 17:17:47
maintainer
docs_urlNone
authorPavlo Kapyshin
requires_python
licenseBSD
keywords sitemap robots
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
Coveralis test coverage
            paka.sitemaps
=============
.. image:: https://travis-ci.org/PavloKapyshin/paka.sitemaps.svg?branch=master
    :target: https://travis-ci.org/PavloKapyshin/paka.sitemaps

``paka.sitemaps`` is a Python library that helps generate XML files according
to `sitemaps.org protocol <https://www.sitemaps.org/protocol.html>`_.


Features
--------
- Python 2.7 and 3.5 are supported
- PyPy (Python 2.7) is supported
- does not depend on any web framework
- automatically splits all added URLs into sitemaps and sitemap indexes
- lazily writes to file system


Examples
--------
.. code-block:: pycon

    >>> from paka import sitemaps

Create directory for resulting XML files (here it is a temporary directory):

.. code-block:: pycon

    >>> import tempfile
    >>> fs_root = tempfile.mkdtemp()

Create sitemap building context, add few URLs to it, and close the context:

.. code-block:: pycon

    >>> ctx = sitemaps.Context(
    ...     fs_root=fs_root, base_url=u"http://example.org")
    >>> ctx.add(u"/some/path-here/", priority=0.1)
    >>> ctx.add(u"/other")
    >>> ctx.close()

Now `fs_root` contains one sitemap and one sitemap index:

.. code-block:: pycon

    >>> import os
    >>> sorted(os.listdir(fs_root))
    ['i1.xml', 's1-1.xml']

Results can be checked with XML parser (here ``lxml`` is used):

.. code-block:: pycon

    >>> from lxml import etree
    >>> doc = etree.parse(os.path.join(fs_root, "s1-1.xml"))
    >>> ns = {"s": sitemaps.XMLNS}
    >>> url_els = doc.xpath("//s:url", namespaces=ns)
    >>> sorted([el.findtext("s:loc", namespaces=ns) for el in url_els])
    ['http://example.org/other', 'http://example.org/some/path-here/']

Remove directory and files created for demonstration:

.. code-block:: pycon

    >>> import shutil
    >>> shutil.rmtree(fs_root)


Installation
------------
Library is `available on PyPI <https://pypi.python.org/pypi/paka.sitemaps>`_,
you can use ``pip`` for installation:

.. code-block:: console

    $ pip install paka.sitemaps


Getting documentation
---------------------
Build HTML docs:

.. code-block:: console

    $ tox -e docs

View built docs:

.. code-block:: console

    $ sensible-browser .tox/docs/tmp/docs_html/index.html


Running tests
-------------
.. code-block:: console

    $ tox


Getting coverage
----------------
Collect info:

.. code-block:: console

    $ tox -e coverage

View HTML report:

.. code-block:: console

    $ sensible-browser .tox/coverage/tmp/cov_html/index.html


Checking code style
-------------------
Run code checkers:

.. code-block:: console

    $ tox -e checks

            

Raw data

            {
    "maintainer": "", 
    "docs_url": null, 
    "requires_python": "", 
    "maintainer_email": "", 
    "cheesecake_code_kwalitee_id": null, 
    "coveralis": true, 
    "keywords": "sitemap robots", 
    "upload_time": "2017-05-17 17:17:47", 
    "author": "Pavlo Kapyshin", 
    "home_page": "https://github.com/PavloKapyshin/paka.sitemaps", 
    "github_user": "PavloKapyshin", 
    "download_url": "https://pypi.python.org/packages/df/bc/40caa33ceb17ccbcbb763864b628b8094d792bd7c32cba354440efaade95/paka.sitemaps-1.6.1.tar.gz", 
    "platform": "UNKNOWN", 
    "version": "1.6.1", 
    "cheesecake_documentation_id": null, 
    "description": "paka.sitemaps\n=============\n.. image:: https://travis-ci.org/PavloKapyshin/paka.sitemaps.svg?branch=master\n    :target: https://travis-ci.org/PavloKapyshin/paka.sitemaps\n\n``paka.sitemaps`` is a Python library that helps generate XML files according\nto `sitemaps.org protocol <https://www.sitemaps.org/protocol.html>`_.\n\n\nFeatures\n--------\n- Python 2.7 and 3.5 are supported\n- PyPy (Python 2.7) is supported\n- does not depend on any web framework\n- automatically splits all added URLs into sitemaps and sitemap indexes\n- lazily writes to file system\n\n\nExamples\n--------\n.. code-block:: pycon\n\n    >>> from paka import sitemaps\n\nCreate directory for resulting XML files (here it is a temporary directory):\n\n.. code-block:: pycon\n\n    >>> import tempfile\n    >>> fs_root = tempfile.mkdtemp()\n\nCreate sitemap building context, add few URLs to it, and close the context:\n\n.. code-block:: pycon\n\n    >>> ctx = sitemaps.Context(\n    ...     fs_root=fs_root, base_url=u\"http://example.org\")\n    >>> ctx.add(u\"/some/path-here/\", priority=0.1)\n    >>> ctx.add(u\"/other\")\n    >>> ctx.close()\n\nNow `fs_root` contains one sitemap and one sitemap index:\n\n.. code-block:: pycon\n\n    >>> import os\n    >>> sorted(os.listdir(fs_root))\n    ['i1.xml', 's1-1.xml']\n\nResults can be checked with XML parser (here ``lxml`` is used):\n\n.. code-block:: pycon\n\n    >>> from lxml import etree\n    >>> doc = etree.parse(os.path.join(fs_root, \"s1-1.xml\"))\n    >>> ns = {\"s\": sitemaps.XMLNS}\n    >>> url_els = doc.xpath(\"//s:url\", namespaces=ns)\n    >>> sorted([el.findtext(\"s:loc\", namespaces=ns) for el in url_els])\n    ['http://example.org/other', 'http://example.org/some/path-here/']\n\nRemove directory and files created for demonstration:\n\n.. code-block:: pycon\n\n    >>> import shutil\n    >>> shutil.rmtree(fs_root)\n\n\nInstallation\n------------\nLibrary is `available on PyPI <https://pypi.python.org/pypi/paka.sitemaps>`_,\nyou can use ``pip`` for installation:\n\n.. code-block:: console\n\n    $ pip install paka.sitemaps\n\n\nGetting documentation\n---------------------\nBuild HTML docs:\n\n.. code-block:: console\n\n    $ tox -e docs\n\nView built docs:\n\n.. code-block:: console\n\n    $ sensible-browser .tox/docs/tmp/docs_html/index.html\n\n\nRunning tests\n-------------\n.. code-block:: console\n\n    $ tox\n\n\nGetting coverage\n----------------\nCollect info:\n\n.. code-block:: console\n\n    $ tox -e coverage\n\nView HTML report:\n\n.. code-block:: console\n\n    $ sensible-browser .tox/coverage/tmp/cov_html/index.html\n\n\nChecking code style\n-------------------\nRun code checkers:\n\n.. code-block:: console\n\n    $ tox -e checks\n", 
    "tox": true, 
    "lcname": "paka.sitemaps", 
    "bugtrack_url": null, 
    "github": true, 
    "name": "paka.sitemaps", 
    "license": "BSD", 
    "travis_ci": true, 
    "github_project": "paka.sitemaps", 
    "summary": "", 
    "split_keywords": [
        "sitemap", 
        "robots"
    ], 
    "author_email": "i@93z.org", 
    "urls": [
        {
            "has_sig": false, 
            "upload_time": "2017-05-17T17:17:45", 
            "comment_text": "", 
            "python_version": "py2.py3", 
            "url": "https://pypi.python.org/packages/38/b7/a2bbbc1d020521ce425728438bfa6581d96cd2b60e1e701aa20770baed01/paka.sitemaps-1.6.1-py2.py3-none-any.whl", 
            "md5_digest": "68dfdab669e7e9b0fe38f5ace4eb97dc", 
            "downloads": 0, 
            "filename": "paka.sitemaps-1.6.1-py2.py3-none-any.whl", 
            "packagetype": "bdist_wheel", 
            "path": "38/b7/a2bbbc1d020521ce425728438bfa6581d96cd2b60e1e701aa20770baed01/paka.sitemaps-1.6.1-py2.py3-none-any.whl", 
            "size": 5457
        }, 
        {
            "has_sig": false, 
            "upload_time": "2017-05-17T17:17:47", 
            "comment_text": "", 
            "python_version": "source", 
            "url": "https://pypi.python.org/packages/df/bc/40caa33ceb17ccbcbb763864b628b8094d792bd7c32cba354440efaade95/paka.sitemaps-1.6.1.tar.gz", 
            "md5_digest": "a4481d896a586e0761f2ebf71b6fb28b", 
            "downloads": 0, 
            "filename": "paka.sitemaps-1.6.1.tar.gz", 
            "packagetype": "sdist", 
            "path": "df/bc/40caa33ceb17ccbcbb763864b628b8094d792bd7c32cba354440efaade95/paka.sitemaps-1.6.1.tar.gz", 
            "size": 5266
        }
    ], 
    "_id": null, 
    "cheesecake_installability_id": null
}