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.0.tar.gz (6.6 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for anymarkup-0.1.0.tar.gz
Algorithm Hash digest
SHA256 51c312bad499b853078ca1332bb7e664a2c5b0dd78b05dcc502dfdefdf06d157
MD5 e092546aa92848b0aa10074144576c2f
BLAKE2b-256 53c55f12021e8406b863969271c41bee37657897a25fb640681380165280629a

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