Coder Social home page Coder Social logo

tefra / xsdata-attrs Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 0.0 37 KB

Naive XML & JSON Bindings for python attrs!

Home Page: https://xsdata-attrs.readthedocs.io

License: MIT License

Python 100.00%
python attrs bindings xml json xsd schema wsdl code-generator python-library

xsdata-attrs's Introduction

xsdata powered by attrs!

https://readthedocs.org/projects/xsdata-attrs/badge https://www.codefactor.io/repository/github/tefra/xsdata-attrs/badge

xsData is a complete data binding library for python allowing developers to access and use XML and JSON documents as simple objects rather than using DOM.

Now powered by attrs!

Install

$ # Install with cli support
$ pip install xsdata-attrs[cli]

Generate Models

$ # Generate models
$ xsdata http://rss.cnn.com/rss/edition.rss --output attrs
Parsing document edition.rss
Analyzer input: 9 main and 0 inner classes
Analyzer output: 9 main and 0 inner classes
Generating package: init
Generating package: generated.rss
...

@attr.s
class Rss:
    class Meta:
        name = "rss"

    version: Optional[float] = attr.ib(
        default=None,
        metadata={
            "type": "Attribute",
        }
    )
    channel: Optional[Channel] = attr.ib(
        default=None,
        metadata={
            "type": "Element",
        }
    )

...

XML Parsing

>>> from xsdata_attrs.bindings import XmlParser
>>> from urllib.request import urlopen
>>> from generated.rss import Rss
>>>
>>> parser = XmlParser()
>>> with urlopen("http://rss.cnn.com/rss/edition.rss") as rq:
...     result = parser.parse(rq, Rss)
...
>>> result.channel.item[2].title
'Vatican indicts 10 people, including a Cardinal, over an international financial scandal'
>>> result.channel.item[2].pub_date
'Sat, 03 Jul 2021 16:37:14 GMT'
>>> result.channel.item[2].link
'https://www.cnn.com/2021/07/03/europe/vatican-financial-scandal-intl/index.html'

Changelog: 23.8 (2023-08-12)

  • Removed python 3.6 and 3.7 support
  • Added official support for 3.11 and 3.12
  • Set xsdata minimum version v23.5

This project is still alive :)

xsdata-attrs's People

Contributors

tefra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

xsdata-attrs's Issues

Support next-gen api

I tried this library, everything looks fine. But it would be good to support a next generation api. Especially mutable, frozen and field keywords. They are much more readable aliases with sane defaults.

And it would be nice to add kw_only parameter when it's needed, even if it's not specified in a generator config. I think the same needs to be done with xsdata on dataclasses.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.