Skip to main content

Flags

A small no-requirements package for making bitwise flags in Python.

Installing

Available on PyPi:

pip install -U vf-flags

To install off of Github you can do the following

pip install -U git+https://github.com/Voxel-Fox-Ltd/Flags

Quick Example

Here’s a basic example of creating a flags class using decorators.

import vfflags

class WebsitePermissions(vfflags.Flags):

    @vfflags.flag_value
    def view_posts(self):
        """If the user can view posts."""
        return 0b001

    @vfflags.flag_value
    def edit_posts(self):
        """If the user can edit posts."""
        return 0b010

    @vfflags.flag_value
    def delete_posts(self):
        return 0b100

Here’s an alternative way to create a flags class using a class attribute.

import vfflags

class WebsitePermissions(vfflags.Flags):

    # You can optionally add a docstring by adding your value to a tuple
    CREATE_FLAGS = {
        "view_posts": (0b001, "If the user can view posts."),
        "edit_posts": (0b010, "If the user can edit posts."),
        "delete_posts": 0b100,
    }

Here’s the usage of either of the above.

perms1 = WebsitePermissions(0b011)  # Init with a value
perms1.view_posts  # True
perms1.delete_posts  # False

perms2 = WebsitePermissions(delete_posts=True)  # Init with kwargs
perms2.view_posts  # False
perms2.delete_posts  # True

Metadata

Release files for vf-flags 0.2.5

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

Source distribution (sdist)

Source distribution for vf-flags 0.2.5
File Size Uploaded Provenance Actions
vf-flags-0.2.5.tar.gz 39.6 kB Without provenance Details for vf-flags-0.2.5.tar.gz

Release files / vf-flags-0.2.5.tar.gz

Download URL vf-flags-0.2.5.tar.gz
Size 39.6 kB
Tags Source
SHA-256 checksum
How to use checksums
878dae29ec332a092af40ef91fb7a0a8b6408a3e106e42600501b555821487d2
BLAKE2b-256 checksum
How to use checksums
75fa0ec82c128172a43f4f5fa256b8b9c9cccc12dff490744c16f4946802f0b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.11

Security for vf-flags 0.2.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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