Skip to main content

A simple Python implementation of BCF

Project description

bcf

A simple Python implementation of BCF. The data model is described in data.py. Manipulation of BCF-XML is available via bcfxml.py and manipulation of BCF-API is available via bcfapi.py.

  • BCF-XML version 2.1: Fully supported
  • BCF-API version 2.1: Not supported, will probably tackle this after BCF-API v3.0
  • BCF-XML version 3.0: Almost fully supported, except for the documents module
  • BCF-API version 3.0: Almost fully supported, except for two requests.

bcfxml

The bcfxml module lets you interact with the BCF-XML standard.

from bcf import bcfxml


# Load a project
bcfxml = bcfxml.load("/path/to/file.bcf")


# The project is also stored in the module
# project == bcfxml.project
project=bcfxml.get_project()
print(project.name)

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

# The BCF file is extracted to this temporary directory
print(bcfxml.filepath)

# Get a dictionary of topics
topics = bcfxml.get_topics()

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

    # Fetch extra data about a topic
    header = bcfxml.get_header(guid)
    comments = bcfxml.get_comments(guid)
    viewpoints = bcfxml.get_viewpoints(guid)

    # Note: comments == topic.comments, and so on
    for comment_guid, comment in comments.items():
        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.edit_topic(topic)

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)

Todo List

The remaining work that needs to be completed in bcfxml.py and bcfapi.py.

  • For bcfxml.py two xsds support is remaining namely 'documents.xsdandextensions.xsd`.
  • For bcfapi.py two requests that are get_topics and get_comments are remaining.

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.1.tar.gz (40.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.1-py3-none-any.whl (45.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bcf-client-0.0.1.tar.gz
  • Upload date:
  • Size: 40.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for bcf-client-0.0.1.tar.gz
Algorithm Hash digest
SHA256 cff3bd1db8117adc4bc4bb3dc402c98fc3e3548fb74f5035c4ac84aecbbba5e5
MD5 ed55cc32af0864cc37b61a370d9bf7f2
BLAKE2b-256 5423b585153723f011765fa45e146aaff159fa85c19e1cf82edc228d9c8ad96f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bcf_client-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 45.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for bcf_client-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 92d73bdd82079f8c8841f3d5fe34782c7254de722a9fd8267e5fe9c1257fe68a
MD5 dfc28556977c66d192fa19c8c2eacf09
BLAKE2b-256 d6298ceda5dcdc54ec2aa881a26aeca9c8a77dfd0e2cb15f4b79365e16629722

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