Skip to main content

Brief

read/write .properties file in line-oriented format
key=value per line through function.

the code refers to java.util.Properties in Java 1.6.

Common Usage

  • file I/O:

    # input
    properties = load(file)
    # or update existing dictionary
    load(file, properties)
    
    # output
    store(file, properties)
    
  • custom input:
    class LineReader read in one key-value data. It skips all comment lines,
    blank lines, leading whitespace, and processes multi-line data.
    loadSingle(string) read each piece of data given above to key-value.

    for line in LineReader(file): # each key-value line has no line seperator
        key, value = loadSingle(line)
        # do something
    
  • custom output:
    storeComments(writable, comments, linesep=os.linesep))
    write comment (accept multi-line), can specify the line terminator.
    storeSingle(writable, key, value, sep='=', linesep=os.linesep)
    write one key-value, can specify the seperator and the line terminator.

    storeComments(file, 'this is a comment')
    storeSingle(file, 'key', 'value')
    

File Format

normally each line is comment line or a key-value pair.

main features:

  • seperate key and value by one of =, :, , \t
  • ignore whitespaces leading in a line or around = or :
  • comment line begin with # or !
  • escape unicode by \uxxxx
  • escape special characters by adding \

others:

  • data line ends with \ discard the line break

differences with Java:

  • store method will not write datetime comment

Changelog

v0.1.1, 2019-2-9

  • change to run with python3

v0.1.0, 2018-6-7

  • set up.

Release files for sine.properties 0.1.1

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

Source distribution (sdist)

Source distribution for sine.properties 0.1.1
File Size Uploaded
sine.properties-0.1.1.tar.gz 13.1 kB Details

Release files / sine.properties-0.1.1.tar.gz

Download URL sine.properties-0.1.1.tar.gz
Size 13.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4f35c8a9f1cbdd24bf98c36ddb5ad447112a540ea3b50ec96d1112a293da21db
BLAKE2b-256 checksum
How to use checksums
8d52d64f96b46aeb1d650849f270ad4c5cde446afcf381ef2b3a5023e609cb05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.0 CPython/3.7.2

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file

0.1.0

2 release files

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