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"
        "bacon"
    ]
  • 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.2.tar.gz (19.5 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.2-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for scuff-0.2.tar.gz
Algorithm Hash digest
SHA256 850dca43444d2bfa1cf52f3b8584c3e8116e925f4ed828cbb695e186244b8ce2
MD5 968b6a19b704e5ef5e0384e00b4a36a1
BLAKE2b-256 bd1baa1bbe48d4811d63bf699db1f68754ea967b57646c5a57aaa943370ae019

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for scuff-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 172376db396383d9ca9456f6cf6b7082448f2a2f5130db882e17bfe77c2bfb11
MD5 dd0702a9fef7c660297247c54bc073bc
BLAKE2b-256 e0226db29a47777d0919a966e3b7226ba420500f271c3fd20e57a93ff83454e3

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