Skip to main content

BCF-XML file handler.

Project description

bcf

A simple Python implementation of BCF. Manipulation of BCF-XML is available via bcfxml.py and manipulation of BCF-API is available via bcfapi.py.

It tries to support BCF-XML version 2.1 and 3.0, and BCF-API 3.0.

bcfxml

The bcfxml.load function lets you read a BCF-XML file. It takes care of using the right version based on the "bcf.version" file contained in the BCF package.

The BCF files are extracted and parsed on-demand, and edits are stored in memory until you call the save method.

from bcf.bcfxml import load

# Load a project
with load("/path/to/file.bcf") as bcfxml:
    project = bcfxml.project
    print(project.name)

    # To edit a project, just modify the object directly
    bcfxml.project.name = "New name"

    # Get a dictionary of topics
    topics = bcfxml.topics

    for topic_guid, topic_handler in bcfxml.topics.items():
        topic = topic_handler.topic
        print("Topic guid is", topic.guid)
        print("Topic title is", topic.title)

        # Fetch extra data about a topic
        header = topic_handler.header
        comments = topic_handler.comments
        viewpoints = topic_handler.viewpoints

        for comment in comments:
            print(comment.guid)
            print(comment.comment)
            print(comment.author)

    # Get a particular topic
    topic = bcfxml.get_topic(guid)

    # Modify a topic
    topic.title = "New title"

    bcfxml.save()

bcfapi

The bcfapi module lets you interact with the BCF-API standard.

from bcf.v3.bcfapi import FoundationClient, BcfClient

foundation_client = FoundationClient("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET", "OPENCDE_BASEURL")
auth_methods = foundation_client.get_auth_methods()

# Our library currently only implements the authorization_code flow
if "authorization_code" in auth_methods:
    foundation_client.login()

bcf_client = BcfClient(foundation_client)

versions = foundation_client.get_versions()
for version in versions:
if "3.0" in versions:
    if version["api_id"] == "bcf" and version["version_id"] == "3.0":
        bcf_client.set_version(version)

data = bcf_client.get_projects()
print(data)
project_id = data[0]["project_id"]
print(project_id)
data = bcf_client.get_project(project_id)
print(data)
data = bcf_client.get_extensions(project_id)
print(data)

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

bcf-client-0.0.230828.tar.gz (49.1 kB view details)

Uploaded Source

Built Distribution

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

bcf_client-0.0.230828-py3-none-any.whl (60.5 kB view details)

Uploaded Python 3

File details

Details for the file bcf-client-0.0.230828.tar.gz.

File metadata

  • Download URL: bcf-client-0.0.230828.tar.gz
  • Upload date:
  • Size: 49.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for bcf-client-0.0.230828.tar.gz
Algorithm Hash digest
SHA256 cbe5ce12fad2ef022af166779fde55f67e3669bc3e8a8e86c438e5c6f154e21d
MD5 c164f9faf65a166de68bb93227d35c42
BLAKE2b-256 35ba6ac14baab197ceb329085f2291e4135f4c7b06080f52912a5f5d951c16b6

See more details on using hashes here.

File details

Details for the file bcf_client-0.0.230828-py3-none-any.whl.

File metadata

File hashes

Hashes for bcf_client-0.0.230828-py3-none-any.whl
Algorithm Hash digest
SHA256 62a7d2839c0aa62c64f8c381e46a0d36d243f89ccb5d7916a371c78b36702b1d
MD5 4801e6f4761e5d5b9675798d5cbc663c
BLAKE2b-256 79ecef3eb017604d22f1c40e8b3cdb6cea3c4b2658c7aa85c3961a83737f5b2d

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