{ "info": { "author": "Sidney Li", "author_email": "sidneyli5432@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Manufacturing", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Utilities" ], "description": "pypdx\n=====\n\n*A Simple parser for PDX (Product Data eXchange) XML files*\n\nIntroduction\n------------\n\nFrom `the Wikipedia article on PDX `__: \u201cthe PDX (Product\nData eXchange) standard for manufacturing is a multi-part standard,\nrepresented by the IPC 2570 series of specifications.\u201d\n\nAs the name implies, it is a standard for exchanging product definition\nbetween companies or organizations, and can include bill of material\n(BOM), approved manufacturer list, drawings, documents, etc.; pretty\nmuch anything can be included if desired.\n\nIn simple terms, a \\*.pdx file (usually exported from Agile/Oracle) is\nreally just a ZIP file that contains all the files (\u201cattachments\u201d)\nassociated with the product (assembly), plus a special XML file called\n**pdx.xml**. This XML file contains the particulars of the various Items\nand their properties/attributes, the relationship between the Items,\nwhich forms the bill-of-materials (BOM), and also information about the\nvarious files that are inside the PDX/ZIP file.\n\nThe DTD of this XML file (identified as \u201cDTD 2571 200111\u201d) can be found\non the `IPC website `__.\nFree PDX viewers are available, one of the most popular being PDXViewer\nfrom `PDXplorer `__.\n\nSince the \\*.pdx file is simply a ZIP file, it is easy to extract all\nthe attachments (documents, schematics, drawings, etc.) from the ZIP\nfile, and there are several ways one can view XML files. However, trying\nto make sense of the assembly from a generic XML viewer is not really\nfeasible, and although there are specialized free (and non-free)\nviewers, there are times when you might want to extract the data for\nyour own use. To this end I have written a simple PDX XML file parser,\npypdx (written in Python), as presented here.\n\nThe *pypdx* program can be used as a Python module, but also as a\ncommand-line stand-alone program that is more or less ready to use. Be\nwarned that it does. It does *not* implement all the elements defined in\nthe PDX standard, but only the parts that happen to be of interest to\n*me* at the moment, so don\u2019t be surprised if it does not have the\nfeatures you are looking for. What it does extract are the **Item**\\ s,\nthe **ApprovedManufacturerList**, the **BillOfMaterial**, and the\n**Attachments**. The main purpose of the program is to extract this data\nfrom the XML file, and organize them by saving them into a relational\ndatabase: in this case either a `SQLite3 `__\ndatabase or a `PostgreSQL `__ database.\nWhat you do after the data is stuffed into a relational database is up\nto you!\n\nInstallation and Usage\n----------------------\n\nTo install the module and program, run\n\n::\n\n pip install pypdx\n\nThis should create an executable pypdx. The usage is as follows:\n\n::\n\n USAGE: pypdx pdx-file.xml dsn [dump [remove_all_first]]\n - pdx-file.xml: this is the PDX XML file\n - dsn: can be a SQLite3 file (the program will create one if it does not exist; use the extension .sqlite3\n : or it can be the dsn connection string for a PostgreSQL database\n : if dsn is 'pg', the default database 'pdx' on localhost (port 5432) and username 'pdxuser' will be used\n - dump: 1 or 0; to dump to a JSON file pdx-dump.json (optional)\n - remove_all: 1 or 0; remove all records from the tables first (optional);\n - : WARNING: this will delete *all* existing parts, BOM, etc., records from the database\n\n\n*Examples*: for a SQLite3 database:\n\n::\n\n pypdx data/pdx-example.xml testout.sqlite3 1 1\n\nfor a postgreSQL database:\n\n::\n\n pypdx data/pdx-example.xml \"dbname='pdx' host='localhost' user='pdxuser' password='billofmaterials' port=5432\" 1 1\n\nA sample PDX XML file (data/pdx-example.xml) is included in the\ndistribution. This is obviously not for a real product.\n\nTo use **pypdx** as a module, do something like this:\n\n::\n\n import pypdx\n\n dsn = 'testout.sqlite3'\n xmlfile = 'data/pdx.xml'\n mypdx = pypdx.PDX(xmlfile, dsn, debug=True)\n\n # should return 'ok', otherwise you get the error message\n status = mypdx.removeall()\n status = mypdx.fillparts()\n\n\nmypdx.removeall() removes all old records from the database tables,\nmypdx.fillparts() then fills the database table with new records from\nthe XML file.\n\nDatabase and Tables\n-------------------\n\nThe data is saved into the following tables:\n\n- **partsmaster** is the main table that stores the Items; each Item is\n uniquely identified by a **itemUniqueIdentifier**\n- **bom** is the table the stores the BOM; each BOM record is\n essentially a \u201clink\u201d that points from the parent Item (identified by\n its **itemUniqueIdentifier**), to the target Item (also identified by\n its **itemUniqueIdentifier**). (Viewed as a directed graph, the\n records in the *partsmaster* are the nodes, and the records of the\n *bom* are the edges of the graph.)\n- **attachments** is the table that stores information on the\n attachment files, which should be in the ZIP file if the *isFileIn*\n field is TRUE. There can be multiple attachments to each Item, and\n these are linked to the Item through the Item\u2019s\n *itemUniqueIdentifier*.\n- **approvedmfg** is the table that stores the information on the\n approved manufacturers for each Item. There can also be mutiple\n approved manufacturers for each Item.\n\nThe definition of (and relations between) these tables are laid out in\nthe SQL files in the data/ directory. A sample program (*main.py*) in the source \ncode distribution illustrates the usage of the module (this is used to\nform the **pypdx** program mentioned above). You can also dump the contents of\nthe PDX file into a JSON file (with the PDX.dump(filename) function).\nHowever this merely mirrors the structure and contents of the XML file;\nit may not be particularly useful unless you process the JSON\nfile/object further on your own.\n\nAs mentioned above, the program allows you to extract the data into a\nSQLite3 database or a PostgreSQL database. The former is less trouble to\nset up, as it is file-based. The program will in fact create the SQLite3\ndatabase file for you (as well as create the tables).\n\nFor using this in a PostgreSQL database, the program **pypdx** will\ncreate the tables for you if they do not already exist, but it assumes\nthat the database called *pdx* already exists and is running on\nlocalhost (at port 5432). You can create the database with the\ncommands\n\n::\n\n % psql template1\n ....\n template1=# create database pdx;\n template1=# \\q\n\nor you can modify the *dsn* specifications in the example program\nto suit your needs. It should be relatively simple to modify the code\nto use a `MySQL database `__, but I have not\ntried this.\n\nThe program depends on a few Python modules (specified in the\nrequirement.txt file), including the SQLite3 driver (*sqlite3*) and\nthe PostgreSQL driver (*psycopg2*). Run\n\n::\n\n % sudo pip install -r requirement.txt\n\nto install the modules. If you do not care for the PostgreSQL database,\nyou should still be able to use the program without installing the\n*psycopg2* module, since it is not imported unless you specify the\nPostgreSQL database option.\n\nClosing Remarks\n---------------\n\nI have only seen a very small number of PDX files, and there does not\nseem to be any sample PDX files that you can download from the Internet\n(likely because the only PDX files available contain proprietary\nmanufacturing information!). Naturally the testing of this program has\nbeen very limited. While I believe the implementation to be correct (if\nincomplete), there is always the possibility of bugs. So use at your own\nrisk; you have been warned!\n\n(*Last Revised 2018-01-19*)\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/sid5432/pypdx", "keywords": "PDX package data exchange IPC IPC-2571 IPC-2570", "license": "", "maintainer": "", "maintainer_email": "", "name": "pypdx", "package_url": "https://pypi.org/project/pypdx/", "platform": "", "project_url": "https://pypi.org/project/pypdx/", "project_urls": { "Homepage": "https://github.com/sid5432/pypdx" }, "release_url": "https://pypi.org/project/pypdx/0.0.1b3/", "requires_dist": [ "psycopg2", "xmltodict", "pytest; extra == 'test'" ], "requires_python": "", "summary": "Extract information from a PDX XML file into a SQLite or PostgreSQL database", "version": "0.0.1b3" }, "last_serial": 3536786, "releases": { "0.0.1b3": [ { "comment_text": "", "digests": { "md5": "b60d7d2419c8ffb39e846d9b24c0a0c7", "sha256": "48c71f95dd0ca1dce694c4b2b4ad23555600678fc68970b91d969dacf51e3558" }, "downloads": -1, "filename": "pypdx-0.0.1b3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b60d7d2419c8ffb39e846d9b24c0a0c7", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 48310, "upload_time": "2018-01-31T00:09:54", "url": "https://files.pythonhosted.org/packages/98/a5/9778c7360bcb6c617a967cfa86f66f136c0a72da82c812377836e57332e0/pypdx-0.0.1b3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "66e4806e5d9c895b37780bb658fd3d9d", "sha256": "4b7f42aeaee431518db1769eae767c7760187d460c7cee769990a1144c18849b" }, "downloads": -1, "filename": "pypdx-0.0.1b3.tar.gz", "has_sig": false, "md5_digest": "66e4806e5d9c895b37780bb658fd3d9d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 44557, "upload_time": "2018-01-31T00:09:55", "url": "https://files.pythonhosted.org/packages/ac/13/e15ecb802b968cf4464504579ced5e501e1223d5023a62efe6d28e6ebad3/pypdx-0.0.1b3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b60d7d2419c8ffb39e846d9b24c0a0c7", "sha256": "48c71f95dd0ca1dce694c4b2b4ad23555600678fc68970b91d969dacf51e3558" }, "downloads": -1, "filename": "pypdx-0.0.1b3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b60d7d2419c8ffb39e846d9b24c0a0c7", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 48310, "upload_time": "2018-01-31T00:09:54", "url": "https://files.pythonhosted.org/packages/98/a5/9778c7360bcb6c617a967cfa86f66f136c0a72da82c812377836e57332e0/pypdx-0.0.1b3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "66e4806e5d9c895b37780bb658fd3d9d", "sha256": "4b7f42aeaee431518db1769eae767c7760187d460c7cee769990a1144c18849b" }, "downloads": -1, "filename": "pypdx-0.0.1b3.tar.gz", "has_sig": false, "md5_digest": "66e4806e5d9c895b37780bb658fd3d9d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 44557, "upload_time": "2018-01-31T00:09:55", "url": "https://files.pythonhosted.org/packages/ac/13/e15ecb802b968cf4464504579ced5e501e1223d5023a62efe6d28e6ebad3/pypdx-0.0.1b3.tar.gz" } ] }