Skip to main content

Generate attrs models content using DRF from sqlalchemy models.

Project description

exdrf-gen-al2xl

exdrf-gen-al2xl is an exdrf-gen plugin that generates Python helpers for Excel-oriented workflows (import/export style) from SQLAlchemy-backed ExDataset metadata. It mirrors the category / resource tree used by al2at, and adds schema_from_text.py for parsing structured text into rows.

Despite the name similarity to attrs, this package is not the same as exdrf-gen-al2at: it focuses on spreadsheet tooling (type_to_xl, read_only_columns, custom sorted_fields), not generic attrs models.

Python 3.12.2+ is required.

What it generates

Under the output path:

  • __init__.py, api.py, schema_from_text.py
  • Per category: {category}/__init__.py, {category}/api.py
  • Per resource: {category}/{resource}.py

Templates live under exdrf_gen_al2xl/al2xl_templates/.

Dependencies

Declared in pyproject.toml:

  • attrs

Runtime (with your app and models):

  • exdrf-gen, exdrf-al, click

Command-line usage

exdrf-gen al2xl DATASET OUT-PATH OUT-MODULE DB-MODULE

Or: python -m exdrf_gen al2xl ... with the same arguments.

  • DATASETmodule.path:Symbol for the SQLAlchemy declarative base.
  • OUT-PATH — output directory. Env: EXDRF_AL2XL_PATH.
  • OUT-MODULE — target Python package for generated imports.
  • DB-MODULE — module containing SQLAlchemy models (for templates).

Python API

from exdrf_gen_al2xl.creator import generate_xl_from_alchemy
from exdrf_gen.jinja_support import jinja_env

generate_xl_from_alchemy(
    d_set=dataset,
    out_path="/path/to/out",
    out_module="my_app.xl_gen",
    db_module="my_app.db.models",
    env=jinja_env,
)

Template context includes type_to_xl, sorted_fields, read_only_columns, and the usual out_module / db_module / source_module fields.

Plugin registration

[project.entry-points.'exdrf.plugins']
exdrf_gen = 'exdrf_gen_al2xl'

See also

  • exdrf-gen-al2at — attrs-focused sibling generator
  • exdrf-genREADME.md

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

exdrf_gen_al2xl-0.1.17.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.

exdrf_gen_al2xl-0.1.17-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file exdrf_gen_al2xl-0.1.17.tar.gz.

File metadata

  • Download URL: exdrf_gen_al2xl-0.1.17.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for exdrf_gen_al2xl-0.1.17.tar.gz
Algorithm Hash digest
SHA256 8c90aeb7d3fa7cb6dd3211a618988af64a9738fb85c2ac5f22bb19971b984479
MD5 39a2e1aba5d7122fac284d000c690bd7
BLAKE2b-256 e1fa110ad744e4415f4c2789a1ccecdee215b0e776dc7bc3ddd7f01a15add95d

See more details on using hashes here.

File details

Details for the file exdrf_gen_al2xl-0.1.17-py3-none-any.whl.

File metadata

File hashes

Hashes for exdrf_gen_al2xl-0.1.17-py3-none-any.whl
Algorithm Hash digest
SHA256 ac406ebc4628d38c8a68ec52de75f258eb8c9e73d3c3ddcd1232c2a132f1c665
MD5 799550625f21b74629ffb4059f87ee07
BLAKE2b-256 b5f078cffa224e7b60e1090cd70c33bd1be7eadad331fb841f5615660b8b02d0

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