Skip to main content

Parse/serialize any markup format

Project description

Parse or serialize any markup. Currently supports ini, json, xml and yaml. Report bugs and new functionality requests at https://github.com/bkabrda/anymarkup/issues.

Parsing (see below for more examples):

import anymarkup
anymarkup.parse('foo: bar')
anymarkup.parse_file('foo/bar.ini')

Serializing: coming in next version

Examples

Parsing examples:

import anymarkup

ini = """
[a]
foo = bar"""

json = """
{"a": {
    "foo": "bar"
}}"""

xml = """<?xml version="1.0" encoding="UTF-8"?>
<a>
    <foo>bar</foo>
</a>"""

yaml = """
a:
  foo: bar
"""

# these will all yield the same value (except that xml parsing will yield OrderedDict)
anymarkup.parse(ini)
anymarkup.parse(json)
anymarkup.parse(xml)
anymarkup.parse(yaml)

# explicitly specify a type of format to expect and/or encoding (utf-8 is default)
anymarkup.parse('foo: bar', format='yaml', encoding='ascii')

# or parse a file
anymarkup.parse_file('foo.ini')

# if a file doesn't have a format extension, pass it explicitly
anymarkup.parse_file('foo', format='json')

# you can also pass encoding explicitly (utf-8 is default)
anymarkup.parse_file('bar', format='xml', encoding='ascii')

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

anymarkup-0.1.1.tar.gz (6.5 kB view details)

Uploaded Source

File details

Details for the file anymarkup-0.1.1.tar.gz.

File metadata

  • Download URL: anymarkup-0.1.1.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for anymarkup-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e5e4e45aca9ef89eb9524cdb4a846c03246f48eac5c2a4a04e2a7ada0e1d52d5
MD5 2573d25a69111eff268f0c72fc06c90c
BLAKE2b-256 2540dfbe1d08689b753dd7eb1b29421649f773a61ac33de79d676187f1c2177e

See more details on using hashes here.

Supported by

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