Skip to main content

A config file format and transpiler suite written in Python.

Project description

A human-readable data serialization language written in Python.

Introduction

Scuff is a language for data serialization: a way to store and read data between formats.

One likely use for Scuff is application configuration files.

Installation

To install Scuff and its tools for Python from the Python Package Index, run the following in the command line:

$ python -m pip install scuff

Grammar

Assigning Variables

Variables are assigned with a key and a value. Key names must be valid identifiers, meaning they must contain no spaces or symbols except underscore (_). Values can be assigned to variables with or without an equals sign (=):

my_favorite_number = 42
my_favorite_color "Magenta"
is_but_a_flesh_wound yes

When left without a value, variables will evaluate to null/None:

set_to_null =
also_null
but_this_has_a_value 15

Data Types

  • Numbers

    Numbers can be positive integers or floats:

    1 1.2 1_000 0.123 .123_4
  • Booleans

    The boolean values True and False are given using these variants:

    True true yes
    False false no
  • Strings

    Single-line strings can be enclosed by single quotes ('), double quotes (") or backticks (`), and multiline strings are enclosed by three of any of those:

    foo "abc"
    bar 'def'
    baz '''Hi,
            did you know
                you're cute?
                    '''
  • Lists

    Lists are enclosed by square brackets ([]). Elements inside lists are separated by spaces, commas or line breaks:

    groceries [
        "bread",
        "milk" "eggs"
        "spam"
    ]
  • Mappings

    Mappings are groups of key-value pairs enclosed by curly braces ({}). Values may be any expression, even other mappings:

    me {
        name "Samantha"
        age 24
        job "Developer"
        favorite_things {
            editor "Vim"
            languages ["Python", "Rust"]
        }
    }

    Mappings may also take the form of dotted attribute lookups:

    outer.middle.inner yes  # == {'outer': {'middle': {'inner': True}}}
  • Comments

    Single-line comments are made using the # symbol:

    option = "The parser reads this."
    # But this is a comment.
        #And so is this.
    option2 = "# But not this; It's inside a string."
    # The parser ignores everything between ``#`` and the end of the line.
     #   ignore = "Comment out any lines of code you want to skip."

Usage

Once you install Scuff, you can then import scuff as a Python module and use its tools:

>>> import scuff
>>> scuff.convert_file('file.conf')
...

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

scuff-0.3.tar.gz (20.6 kB view details)

Uploaded Source

Built Distribution

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

scuff-0.3-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file scuff-0.3.tar.gz.

File metadata

  • Download URL: scuff-0.3.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for scuff-0.3.tar.gz
Algorithm Hash digest
SHA256 7816a6ab80b5833fea502193020c8a21b86e706a018a8a9eb3c89f4da1c9ac83
MD5 2b57209e47ea86942424f18cb2c374b5
BLAKE2b-256 61e6eb5823accdf34dad2c67cea38e364d21862d9044129935d0c12a5f93d4fe

See more details on using hashes here.

File details

Details for the file scuff-0.3-py3-none-any.whl.

File metadata

  • Download URL: scuff-0.3-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for scuff-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8c630b6904ea60b89be5cda23eea484fed96807089b0334da578581f76eeb617
MD5 3a337f45688fa6ad052a3175a3523f59
BLAKE2b-256 8365434cad44e44ae1f852937ae9599a606989d3ef426bb3037fc0b1b0f33f34

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