Skip to main content
Master: [![Build Status](https://travis-ci.org/unfoldingWord-dev/python-resource-container.svg?branch=master)](https://travis-ci.org/unfoldingWord-dev/python-resource-container)

# python-resource-container
A utility for managing Door43 Resource Containers. This follows the specification at http://resource-container.readthedocs.io/en/v0.2/.

## What is an RC?
A Resource Container (RC) is a modular/portable package of translation data.

## Installation
```
pip install resource_container
```

## Requirements

python 2.7+

## Usage
To get started you must first load an RC. Then you can read/write as needed.

```python
from resource_container import factory


rc = factory.load('/path/to/resource/container/dir')

# some attributes have dedicated properties
print(rc.type)

# other attributes are accessible from the manifest
print(rc.manifest['dublin_core']['rights'])

# read
chapter = rc.read_chunk('01', 'title')

# write
rc.write_chunk('front', 'title', 'Some book title')
```

### Multiple Projects
It is possible for an RC to contain multiple projects.
In such cases methods like writing and reading chunks will
throw an error telling you to specify the project.

```python
# assume rc contains the projects: gen, exo.

# this throws an error
rc.read_chunk('01', 'title')

# you can check how many projects are in an rc
rc.project_count

# this works as expected
chapter01title = rc.read_chunk('gen', '01', 'title')
```

### Strict Mode

By default the tool will operate in strict mode when loading an RC.
This will perform some checks to ensure the RC is valid.
If you need to look at an RC regardless of it's validity
you can disable strict mode by passing in `False`.

```python
rc = factory.load('/invalid/rc/dir', False)
# do stuff with the invalid rc
```


### Creating an RC

This tool also allows you to create a brand new RC.

> NOTE: currently you must specify the complete manifest manually.
> This might change a little in the future.

```python
manifest = {
...
}

rc = factory.create('/my/rc/dir/', manifest)
# do stuff with your new rc
```


Metadata

Release files for resource_container 1.1

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

Source distribution (sdist)

Source distribution for resource_container 1.1
File Size Uploaded
resource_container-1.1.tar.gz 6.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for resource_container 1.1
File Interpreter ABI Platform
resource_container-1.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 16.5 kB

Release files / resource_container-1.1.tar.gz

Download URL resource_container-1.1.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
05043c14e2dc8d46c24eb321310594382f957e477ea9605a1664ff7a23b7d413
BLAKE2b-256 checksum
How to use checksums
0c1d9412c45a33139a6c541a14e0f7dcd04683b97797354a40beb582128f9857
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / resource_container-1.1-py2.py3-none-any.whl

Download URL resource_container-1.1-py2.py3-none-any.whl
Size 9.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
348f05b24ad9aa9fd3f8b01a7fb58d660ce4f1b700dc72f8c10fbd263e2de757
BLAKE2b-256 checksum
How to use checksums
5bab93d0614f7877ef57bea4a71e075029411457296c27e801fc198dabbb6717
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.1 This release

2 release files

1.0

2 release files

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