Module inilike.common
Common functions for dealing with entries in ini-like file.
See Also
Functions
Name | Description |
---|---|
boolToString(b)
|
Convert bool to string. Can be used to set boolean values. |
doUnescape(value, pairs)
|
Unescape value. If value does not need unescaping this function returns original value. |
dropEncodingPart(locale)
|
Drop encoding part from locale (it's not used in constructing localized keys). |
escapeValue(value)
|
Escapes string by replacing special symbols with escaped sequences. These symbols are: '\\' (backslash), '\n' (newline), '\r' (carriage return) and '\t' (tab). |
isBoolean(value)
|
Check if the entry value can be interpreted as boolean value. |
isComment(s)
|
Test whether the string represents a comment. |
isFalse(value)
|
Test whether the entry value represents false. |
isGroupHeader(s)
|
Test whether the string represents a group header. |
isTrue(value)
|
Test whether the entry value represents true. |
isValidDesktopFileKey(desktopKey)
|
Test whether the string is valid key in terms of Desktop File Specification. |
isValidKey(key)
|
Test whether the string is valid key, i.e. does not need escaping, is not a comment and not empty string. |
localizedKey(key, locale)
|
Construct localized key name from key and locale. |
localizedKey(key, lang, country, modifier)
|
ditto, but constructs locale name from arguments. |
makeLocaleName(lang, country, encoding, modifier)
|
Make locale name based on language, country, encoding and modifier. |
needEscaping(value)
|
Check if value needs to be escaped. This function is currently tolerant to single slashes and tabs. |
parseGroupHeader(s)
|
Retrieve group name from header entry. |
parseKeyValue(s)
|
Parse entry of kind Key=Value into pair of Key and Value. |
parseLocaleName(locale)
|
Parse locale name into the tuple of 4 values corresponding to language, country, encoding and modifier |
selectKeyLocale(locale, firstKeyLocale, secondKeyLocale)
|
Between two key locales (i.e. locales found in keys of .ini-like file) select a better match for the provided locale. The "goodness" is determined using algorithm described in Localized values for keys. |
selectLocalizedValue(locale, firstLocale, firstValue, secondLocale, secondValue)
|
Same as selectKeyLocale , but returns a locale bundled with a value in one tuple.
|
separateFromLocale(key)
|
Separate key name into non-localized key and locale name. If key is not localized returns original key and empty string. |
unescapeValue(value)
|
Unescapes string. You should unescape values returned by library before displaying until you want keep them as is (e.g., to allow user to edit values in escaped form). |