<commit_before>Juju Resources provides helpers for charms to load binary resources from
external sources, as well as tools for creating mirrors of external resources
for network-restricted deployments.

This is intended as a stop-gap until Juju has core support for resources,
as well as to prototype what features are needed.


Installing
----------

Install Juju Resources using pip:

    pip install jujuresources


Charm Usage
-----------

A charm using Juju Resources will need to define a ``resources.yaml``,
such as::

    resources:
        my_resource:
            url: http://example.com/path/to/my_resource.tgz
            hash: b377b7cccdd281bc5e4c4071f80e84a3
            hash_type: sha256
    optional_resources:
        my_optional_resource:
            url: http://example.com/path/to/my_optional_resource.tgz
            hash: 476881ef4012262dfc8adc645ee786c4
            hash_type: sha256

Then, once the charm has installed Juju Resources, it can fetch
and verify resources, either in Python::

    from jujuresources import fetch_resources, verify_resources, config_get

    if not fetch_resources(base_url=config_get('resources_mirror')):
        print "Mandatory resources did not download; check resources_mirror option"
        sys.exit(1)

    fetch_resources('my_optional_resource', base_url=config_get('resources_mirror'))
    if verify_resources('my_optional_resource'):
        install_tgz(resource_path('my_optional_resource'))
<commit_msg>Fixed README to match new API function names<commit_after>Juju Resources provides helpers for charms to load binary resources from
external sources, as well as tools for creating mirrors of external resources
for network-restricted deployments.

This is intended as a stop-gap until Juju has core support for resources,
as well as to prototype what features are needed.


Installing
----------

Install Juju Resources using pip:

    pip install jujuresources


Charm Usage
-----------

A charm using Juju Resources will need to define a ``resources.yaml``,
such as::

    resources:
        my_resource:
            url: http://example.com/path/to/my_resource.tgz
            hash: b377b7cccdd281bc5e4c4071f80e84a3
            hash_type: sha256
    optional_resources:
        my_optional_resource:
            url: http://example.com/path/to/my_optional_resource.tgz
            hash: 476881ef4012262dfc8adc645ee786c4
            hash_type: sha256

Then, once the charm has installed Juju Resources, it can fetch
and verify resources, either in Python::

    from jujuresources import fetch, verify, config_get

    if not fetch(base_url=config_get('resources_mirror')):
        print "Mandatory resources did not download; check resources_mirror option"
        sys.exit(1)

    fetch('my_optional_resource', base_url=config_get('resources_mirror'))
    if verify('my_optional_resource'):
        install_tgz(resource_path('my_optional_resource'))

{'fraction_non_alphanumeric': 0.07326258130777132, 'fraction_numerical': 0.031496062992125984, 'mean_word_length': 3.440729483282675, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3331751', 'n_tokens_mistral': 889, 'n_tokens_neox': 798, 'n_words': 265}