Module properties
source code
classes that hold units of .properties files (propunit) or entire
files (propfile) these files are used in translating Mozilla and other
software
The following .properties file description and example give some good references to the .properties
specification.
Properties file may also hold Java MessageFormat messages. No special handling is
provided in this storage class for MessageFormat, but this may be
implemented in future.
Implementation
A simple summary of what is permissible follows.
Comments:
# a comment
! a comment
Name and Value pairs:
# Note that the b and c are escaped for epydoc rendering
a = a string
d.e.f = another string
b = a string with escape sequences \t \n \r \\ \" \' \ (space) \u0123
c = a string with a continuation line \
continuation line
|
propunit
an element of a properties file i.e.
|
|
propfile
this class represents a .properties file, made up of propunits
|
Tuple (Delimeter char, Offset Integer)
|
|
Boolean
|
|
str
|
|
Imports:
base,
quote,
data,
re
Find the type and position of the delimeter in a property line.
Property files can be delimeted by "=", ":" or
whitespace (space for now). We find the position of each delimeter, then
find the one that appears first.
- Parameters:
line (str) - A properties line
- Returns: Tuple (Delimeter char, Offset Integer)
- Delimeter character and offset within
line
|
Determine whether line has a line
continuation marker.
.properties files can be terminated with a backslash (\) indicating
that the 'value' continues on the next line. Continuation is only valid
if there are an odd number of backslashses (an even number would result
in a set of N/2 slashes not an escape)
- Parameters:
line (str) - A properties line
- Returns: Boolean
- Does
line end with a line continuation
|
Cleanup whitespace found around a key
- Parameters:
key (str) - A properties key
- Returns: str
- Key without any uneeded whitespace
|
default_encoding
- Value:
{ ' java ' : ' latin1 ' , ' mozilla ' : ' utf-8 ' , ' skype ' : ' utf-16 ' }
|
|