Skip to main content

xmlobj is simple utility to map xml file to python object

Project description

Description

xmlobj is simple utility to map xml file to python object

xmlobj also allows you to add functionality to mapped object by adding mixin class

A Simple Example

from pathlib import Path

from PIL import Image, ImageDraw

from xmlobj.xmlmapping import get_xml_obj


class DrawBoxesMixin:
    def draw_box(self, image) -> Image.Image:
        p1 = (self.object.bndbox.xmin, self.object.bndbox.ymin)
        p2 = (self.object.bndbox.xmax, self.object.bndbox.ymax)
        img_draw = ImageDraw.Draw(image)
        img_draw.text(p1, self.object.name, align="left")
        img_draw.rectangle([p1, p2])
        return image


if __name__ == "__main__":
    pascal_annotation = Path("samples/000027.xml")
    img_file = "samples/000027.jpg"
    img = Image.open(img_file)
    obj = get_xml_obj(pascal_annotation, mixin_cls=DrawBoxesMixin)
    rendered_img = obj.draw_box(img.copy())
    rendered_img.show()

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

xmlobj-1.0.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

xmlobj-1.0.1-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file xmlobj-1.0.1.tar.gz.

File metadata

  • Download URL: xmlobj-1.0.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for xmlobj-1.0.1.tar.gz
Algorithm Hash digest
SHA256 fcfe347c30899cae9e71a56e6f1ec0ba02033d1d8e6a3f211a5663f3a69a4c1a
MD5 f3ad446ed0c88ac317a3533aecda3915
BLAKE2b-256 ad5bab5e0cadf6a7db360cc15a41f418d7599c6f15da0e53dfb2dd4524c626b9

See more details on using hashes here.

File details

Details for the file xmlobj-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: xmlobj-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for xmlobj-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c1b01ca057b722771af7131e36a0806dc26ac81222f9e7d79ee0989f0bae6a5e
MD5 073b6af7a7fe2c811651c112bf491dfc
BLAKE2b-256 2a714fed93d0ec2e208bcfa5f3dfc501831239accd2320d82da16830c7c9a12c

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