Skip to main content

A Python module to process Qualitative Data Exchange (QDPX) XML files.

Project description

pyqdpx

A Python module to process Qualitative Data Exchange (QDPX) XML files, which are zip-compressed archives containing a project.qde XML file and a Sources directory.

Features

  • List source files within a .qdpx archive.
  • Retrieve content of individual source files.
  • Load and manipulate project.qde XML data.
  • Manage users (add, list) within the project.
  • Manage qualitative codes (add, modify, delete, navigate hierarchy).
  • Save modifications back to the .qdpx archive, ensuring data integrity.

Installation

You can install pyqdpx using pip:

pip install pyqdpx

If you want to install from source for development:

git clone https://github.com/DEPT-metagenom/pyqdpx.git
cd pyqdpx
pip install .

Usage

Here's a quick example of how to use pyqdpx:

from pyqdpx import QDPX, User, Code
import os

# Assume 'my_project.qdpx' exists and is a valid QDPX file
# For demonstration, you might create a dummy file first as in your tests.

# Initialize the QDPX object
qdpx_file = QDPX("my_project.qdpx")

# Get the QDE project
project = qdpx_file.get_project()

if project:
    print("Project Title:", project._bs4_obj.find('Title').string)

    # List users
    print("\nUsers:")
    for user_guid, user_obj in project.users.items():
        print(f"- {user_obj.name} (ID: {user_obj.id})")

    # Add a new user
    new_user = User(id="AL", name="Ada Lovelace")
    project.add_user(new_user)
    print(f"\nAdded new user: {new_user.name}")

    # Print code tree
    print("\nCode Tree:")
    project.print_code_tree()

    # Find and modify a code
    susceptibility_code = project.find_code("1. Perceived Susceptibility")
    if susceptibility_code:
        print(f"\nOriginal Susceptibility Description: {susceptibility_code.description}")
        susceptibility_code.description = "Updated description for perceived susceptibility."
        print(f"New Susceptibility Description: {susceptibility_code.description}")

    # Save changes (this will update the project.qde inside the zip)
    project.save()
    print("\nProject saved successfully!")
else:
    print("Could not load project.")

# Clean up (if you created a dummy file for testing)
# os.remove("my_project.qdpx")

Running Tests

To run the unit tests, navigate to the root directory of the package (pyqdpx_package/) and use pytest:

pip install pytest
pytest

Contributing

Contributions are welcome! Please feel free to open issues or submit pull requests.LicenseThis project is licensed under the MIT License - see the LICENSE file for details.

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

pyqdpx-0.1.4.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyqdpx-0.1.4-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file pyqdpx-0.1.4.tar.gz.

File metadata

  • Download URL: pyqdpx-0.1.4.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyqdpx-0.1.4.tar.gz
Algorithm Hash digest
SHA256 426db1d6f83751e778fbe3ab5b2b944ba590309ec1fcd94da7b3c28e9ba8381e
MD5 79abb0d6c87139c2a1d295420f274073
BLAKE2b-256 e1b5941fcfa3a0a0c465d8ad9bc1abf1e907da318ec3784527f98c2018669038

See more details on using hashes here.

File details

Details for the file pyqdpx-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: pyqdpx-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyqdpx-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6ca078dc2c91acaf19ad0db87b26414b604f482a31d610e1e5909a1ddb5e9663
MD5 d1d1b1d4c425a8d08f15a5b3bf8a6d29
BLAKE2b-256 02692032e8cf07855d5ee97f9dfa39d372ada3195260903de9801e3800063c8b

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