summaryrefslogtreecommitdiff
path: root/portato/config_parser.py
diff options
context:
space:
mode:
Diffstat (limited to 'portato/config_parser.py')
-rw-r--r--portato/config_parser.py51
1 files changed, 47 insertions, 4 deletions
diff --git a/portato/config_parser.py b/portato/config_parser.py
index 30873e7..19d3929 100644
--- a/portato/config_parser.py
+++ b/portato/config_parser.py
@@ -3,13 +3,33 @@
# File: portato/config_parser.py
# This file is part of the Portato-Project, a graphical portage-frontend.
#
-# Copyright (C) 2006 René 'Necoro' Neumann
+# Copyright (C) 2006-2007 René 'Necoro' Neumann
# This is free software. You may redistribute copies of it under the terms of
# the GNU General Public License version 2.
# There is NO WARRANTY, to the extent permitted by law.
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
+"""A simple parser for configuration files in ini-style.
+
+The main difference to other simple ini-parsers is, that it does not
+write the whole structure into the file, but only the changed values.
+Thus it keeps comments and structuring of the file.
+
+@var DELIMITER: list of delimiters allowed
+@type DELIMITER: string[]
+
+@var COMMENT: comment marks allowed
+@type COMMENT: string[]
+
+@var TRUE: Regular expression for all TRUE values allowed.
+Currently supported are the values (case insensitive): true, 1, on, wahr, ja, yes.
+@var FALSE: Regular expression for all FALSE values allowed.
+Currently supported are the values (case insensitive): false, 0, off, falsch, nein, no,
+@var SECTION: Regular expression allowing the recognition of a section header.
+@var EXPRESSION: Regular expression defining a normal option-value pair.
+"""
+
from helper import debug
import re
@@ -25,7 +45,18 @@ SECTION = re.compile("\s*\[(\w+)\]\s*")
EXPRESSION = re.compile(r"\s*(\w+)\s*[:=]\s*(.*)\s*")
class Value (object):
- """Class defining a value of a key."""
+ """Class defining a value of a key.
+
+ @ivar value: The specific value. This is a property.
+ @type value: arbitrary
+ @ivar line: The line in the config file.
+ @type line: int
+ @ivar boolean: The boolean meaning of this value. Set this to C{None} if this is not a boolean.
+ @type boolean: boolean
+ @ivar changed: Set to True if the value has been changed.
+ @type changed: boolean
+ @ivar old: The old value.
+ @type old: arbitrary"""
def __init__ (self, value, line, bool = None):
"""Constructor.
@@ -34,7 +65,7 @@ class Value (object):
@type value: string
@param line: the line in the config file
@type line: int
- @param bool: boolean meaning of the value
+ @param bool: The boolean meaning of the value. Set this to C{None} if this is not a boolean.
@type bool: boolean"""
self.__value = value
@@ -82,7 +113,19 @@ class Value (object):
value = property(get,set)
class ConfigParser:
- """The newly implemented Config-Parser."""
+ """The parser class.
+
+ @cvar true_false: A mapping from the truth values to their opposits.
+ @type true_false: string -> string
+
+ @ivar file: the file to scan
+ @type file: string
+ @ivar cache: caches the content of the file
+ @type cache: string[]
+ @ivar vars: the found options grouped by section
+ @type vars: string -> (string -> L{Value})
+ @ivar pos: the positions of the values grouped by lineno
+ @type pos: int -> (int, int)"""
# generates the complementary true-false-pairs
true_false = {
just changelog and translation 2008-01-18 r643@Devoty: necoro | 2008-01-16 18:55:49 +0100Necoro14-249/+525 Fixed small bug in PackageTable.cb_package_revert_clicked r646@Devoty: necoro | 2008-01-18 00:12:30 +0100 Make tabpositions being configurable by the user r647@Devoty: necoro | 2008-01-18 01:38:19 +0100 Renamed 'shm' to '_shm' to not hide the global one r648@Devoty: necoro | 2008-01-18 01:38:29 +0100 Renamed 'shm' to '_shm' to not hide the global one r649@Devoty: necoro | 2008-01-18 02:34:43 +0100 Added update queues; general UI improvement 2008-01-14 r634@Devoty: necoro | 2008-01-14 23:48:24 +0100Necoro3-1/+4 Removed the broken plugins until they get replaced 2008-01-14 r632@Devoty: necoro | 2008-01-14 23:44:52 +0100Necoro3-175/+181 small changes 2008-01-14(no commit message)Necoro10-758/+1014 2008-01-14 r621@Devoty: necoro | 2008-01-14 20:21:40 +0100Necoro2-21/+61 adjust changelog r622@Devoty: necoro | 2008-01-14 21:01:11 +0100 Some new views 2008-01-14 r618@Devoty: necoro | 2008-01-14 20:19:05 +0100Necoro2-35/+57 An ALL category 2008-01-14 r617@Devoty: necoro | 2008-01-14 19:12:59 +0100Necoro2-10/+10 Remove unnecessairy loads of the shm module 2008-01-14 r609@Devoty: necoro | 2008-01-14 17:04:38 +0100Necoro9-394/+477 Allowed '-' and '_' in key names. Also use group names instead of their number. r610@Devoty: necoro | 2008-01-14 17:05:42 +0100 Disabled saving of the queues r611@Devoty: necoro | 2008-01-14 17:08:53 +0100 Added the possibility to permanently en-/disable plugins r612@Devoty: necoro | 2008-01-14 17:14:09 +0100 adjust changelog and translations r613@Devoty: necoro | 2008-01-14 17:40:53 +0100 Dropdown should be localized too 2008-01-14 r605@Devoty: necoro | 2008-01-14 11:43:34 +0100Necoro2-26/+129 Updated shm module to version 1.1.4 2008-01-14 r603@Devoty: necoro | 2008-01-14 11:30:26 +0100Necoro4-26/+38 Improved 'update world'; really support new use defaults 2008-01-11 r598@Devoty: necoro | 2008-01-10 16:36:29 +0100Necoro4-10/+50 Handle the new useflag format correctly 2008-01-11 r597@Devoty: necoro | 2008-01-10 14:12:35 +0100Necoro1-3/+3 updated todo 2008-01-10 r595@Devoty: necoro | 2008-01-10 04:04:15 +0100Necoro1-52/+3 Re-Introduced etc-proposals 2008-01-09 r586@Devoty: necoro | 2008-01-09 14:54:18 +0100Necoro1-1/+1 Disabled catapult till it is really usable 2007-12-06 r577@Devoty: necoro | 2007-12-06 20:37:36 +0100Necoro1-1/+1 Fixed desktop file 2007-12-06 r572@Devoty: necoro | 2007-11-28 08:48:15 +0100Necoro1-0/+1 2007-11-27 r570@Devoty: necoro | 2007-11-27 02:08:21 +0100Necoro3-84/+108 Added scrollbars to update window