Skip to main content

Fluent builder for Android resources

Project description

resforge

A fluent Python library for generating Android XML resource files.

Installation

pip install resforge

Android

from resforge.android import PluralValues, ValuesWriter, dp, sp

with ValuesWriter("res/values/resources.xml") as res:
    res.comment("Strings")
    res.string(
        app_name="My App",
        welcome_message="Welcome to My App!",
    )

    res.comment("Booleans")
    res.boolean(
        feature_enabled=True,
        dark_mode=False,
    )

    res.comment("Colors")
    res.color(
        primary="#FF6200EE",
        secondary="#FF03DAC5",
        accent=0x6200EE,
    )

    res.comment("Dimensions")
    res.dimension(
        padding_small=dp(8),
        padding_large=dp(24),
        text_body=sp(16),
        text_heading=sp(24),
    )

    res.comment("Integers")
    res.integer(
        max_retries=3,
        timeout_seconds=30,
    )

    res.comment("Resource IDs")
    res.res_id("btn_submit", "tv_title", "iv_logo")

    res.comment("String arrays")
    res.string_array("planets", ["Mercury", "Venus", "Earth", "Mars"])

    res.comment("Integer arrays")
    res.integer_array("fibonacci", [1, 1, 2, 3, 5, 8, 13])

    res.comment("Typed arrays")
    res.typed_array(
        "icons", ["@drawable/home", "@drawable/settings", "@drawable/logout"]
    )

    res.comment("Plurals")
    res.plurals(
        item_count=PluralValues(one="%d item", other="%d items"),
        file_count=PluralValues(one="%d file", other="%d files"),
    )

    res.comment("Styles")
    res.style(
        "AppTheme",
        parent="Theme.MaterialComponents.DayNight",
        colorPrimary="@color/primary",
        colorSecondary="@color/secondary",
    )

iOS

Coming in v0.2.0.

License

MIT

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

resforge-0.1.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

resforge-0.1.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file resforge-0.1.0.tar.gz.

File metadata

  • Download URL: resforge-0.1.0.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for resforge-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0d04ee6491ab0cb383976d7eef2575ebef28987b8549e9a0d9e6ff012d355a63
MD5 db7c6cab47389f965d86589110d4a6aa
BLAKE2b-256 4a4173ffd9cfbf7f9c9812a8d58dc005d140406349a4ff7c47e4a3b2a8aa6c00

See more details on using hashes here.

Provenance

The following attestation bundles were made for resforge-0.1.0.tar.gz:

Publisher: publish.yml on ok100/resforge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file resforge-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: resforge-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for resforge-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0eec74145dba577828e9c23e84947d1f16b2042c46b306ac7b5689289b89e973
MD5 e6b271a8d23d68e8eea6dc27309c0f91
BLAKE2b-256 93f308afa0301d1b5191563c6d2f82507edb32c62ad86e385d87c25f97849879

See more details on using hashes here.

Provenance

The following attestation bundles were made for resforge-0.1.0-py3-none-any.whl:

Publisher: publish.yml on ok100/resforge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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