Skip to main content

pdmparse

pdmparse 是一个用于解析 PowerDesigner 的数据库设计 PDM 文件并生成模板代码的工具。它允许开发者通过读取 PDM 文件中的表结构、字段、关系等信息,自动生成符合特定模板的代码。

功能概述

  • 解析 PDM 文件:读取 PowerDesigner 导出的 PDM 文件,提取表结构、字段、外键关系、图表信息等。
  • 模板代码生成:基于解析的数据,使用 Jinja2 模板引擎生成目标代码(如 Flask API 模型)。
  • 灵活的过滤和重命名:支持通过自定义函数对表进行过滤和重命名。

主要模块

test.py

test.py 是一个测试脚本,展示了如何使用 pdmparse 库的功能。

主要功能

  1. 生成模型代码:

    • 使用 PdmParse 类解析 PDM 文件。
    • 应用表过滤函数,仅处理特定图表中的表。
    • 使用自定义重命名函数为每个表生成输出文件名。
    • 通过 Jinja2 模板生成目标代码。
  2. 打印读取内容:

    • 使用 read 函数直接读取 PDM 文件中的表信息。
    • 打印每个表的详细信息,包括字段、外键关系、图表等。

使用示例

以下是如何使用 test.py 脚本的示例:

  1. 生成模型代码:
    from pdmparse.api import PdmParse
    from pdmparse.parsers import read
    
    def table_filter_func(table):
        """
        表过滤函数:仅处理属于 '服务系统' 图表的表。
        """
        return len([diagram for diagram in table.diagrams if diagram.name == '服务系统']) > 0
    
    def rename(table):
        """
        自定义重命名函数:为每个表生成输出文件名。
        """
        f_name = '%s.py' % (table.code.lower())
        print(f_name)
        return f_name
    
    # 初始化 PdmParse 对象
    api = PdmParse(r'C:\Users\china\OneDrive\Dev\pdm\lnwork_open.pdm', 'templates', __filters__)
    
    # 生成模板文件
    api.gen_template_file(
        'output', 
        'flask_api.jinja2',
        table_filter_func, 
        rename, 
        **{'app_name': 'app_name', 'package_name': 'package_name'}
    )
    

Metadata

Release files for pdmparse 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pdmparse 1.0.3
File Size Uploaded Provenance Actions
pdmparse-1.0.3.tar.gz 6.5 kB Without provenance Details for pdmparse-1.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pdmparse 1.0.3
File Interpreter ABI Platform Actions
pdmparse-1.0.3-py3-none-any.whl Python 3 none any Details for pdmparse-1.0.3-py3-none-any.whl

Total release size: 13.5 kB

Release files / pdmparse-1.0.3.tar.gz

Download URL pdmparse-1.0.3.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
565bb5c903c67d0370c32208d247491f5af399c43b8509743d70b30df978bd64
BLAKE2b-256 checksum
How to use checksums
d9683d7795fb29808e3c020aaea245afd5cfcaf4b1dbcccca96297a932218eff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.8

Release files / pdmparse-1.0.3-py3-none-any.whl

Download URL pdmparse-1.0.3-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e9271575a1d8b6bcedc5270c65d978d7270f06dd77744e83f3031586e1b07539
BLAKE2b-256 checksum
How to use checksums
1469a73eb00315a789f0b994523ac500ec4b0d2b6d35efa8219c96b418bf6d0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.8

Security for pdmparse 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page