Skip to main content

No project description provided

Project description

https://travis-ci.org/PavloKapyshin/paka.sitemaps.svg?branch=master

paka.sitemaps is a Python library that helps generate XML files according to sitemaps.org protocol.

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

>>> from paka import sitemaps

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

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

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

>>> 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:

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

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

>>> 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:

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

Installation

Library is available on PyPI, you can use pip for installation:

$ pip install paka.sitemaps

Getting documentation

Build HTML docs:

$ tox -e docs

View built docs:

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

Running tests

$ tox

Getting coverage

Collect info:

$ tox -e coverage

View HTML report:

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

Checking code style

Run code checkers:

$ tox -e checks

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

paka.sitemaps-1.6.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

paka.sitemaps-1.6.1-py2.py3-none-any.whl (5.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file paka.sitemaps-1.6.1.tar.gz.

File metadata

  • Download URL: paka.sitemaps-1.6.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for paka.sitemaps-1.6.1.tar.gz
Algorithm Hash digest
SHA256 ad6001d1d9ae01a234dacf24de7d6df2b018574e7133fc7817cf1ce0c1c37fcc
MD5 a4481d896a586e0761f2ebf71b6fb28b
BLAKE2b-256 dfbc40caa33ceb17ccbcbb763864b628b8094d792bd7c32cba354440efaade95

See more details on using hashes here.

File details

Details for the file paka.sitemaps-1.6.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for paka.sitemaps-1.6.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a30b03a669c09677f09760d441a3dee5939e9189523feb700f9d166e676816c6
MD5 68dfdab669e7e9b0fe38f5ace4eb97dc
BLAKE2b-256 38b7a2bbbc1d020521ce425728438bfa6581d96cd2b60e1e701aa20770baed01

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page