summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2008-03-04 22:02:32 +0100
committerRené 'Necoro' Neumann <necoro@necoro.net>2008-03-04 22:02:32 +0100
commit615173a21c7efb8e7df57a64f1f3ee30d971a4db (patch)
treec40a5246df812692fecf1b42db993fc55d47445d
parentda80e4fcaaa9bbeac8df8bbd548391b3d38cbfbe (diff)
downloadportato-615173a21c7efb8e7df57a64f1f3ee30d971a4db.tar.gz
portato-615173a21c7efb8e7df57a64f1f3ee30d971a4db.tar.bz2
portato-615173a21c7efb8e7df57a64f1f3ee30d971a4db.zip
Fixed comments
-rw-r--r--portato/config_parser.py244
-rw-r--r--portato/dependency.py11
-rw-r--r--portato/gui/gtk/windows.py5
-rw-r--r--portato/gui/gui_helper.py4
-rw-r--r--portato/session.py2
5 files changed, 160 insertions, 106 deletions
diff --git a/portato/config_parser.py b/portato/config_parser.py
index 76a022a..268f747 100644
--- a/portato/config_parser.py
+++ b/portato/config_parser.py
@@ -10,26 +10,38 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
-"""A simple parser for configuration files in ini-style.
+"""
+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[]
+:Variables:
+
+ DELIMITER : string[]
+ list of delimiters allowed
+
+ COMMENT : string []
+ comment marks allowed
-@var COMMENT: comment marks allowed
-@type COMMENT: string[]
+ TRUE
+ Regular expression for all TRUE values allowed.
+ Currently supported are the values (case insensitive): true, 1, on, wahr, ja, yes.
-@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.
+ FALSE
+ Regular expression for all FALSE values allowed.
+ Currently supported are the values (case insensitive): false, 0, off, falsch, nein, no.
+
+ SECTION
+ Regular expression allowing the recognition of a section header.
+
+ EXPRESSION
+ Regular expression defining a normal option-value pair.
"""
+
from __future__ import absolute_import, with_statement
+__docformat__ = "restructuredtext"
import re
from gettext import lgettext as _
@@ -47,28 +59,43 @@ SECTION = re.compile("\s*\[(?P<name>\w(\w|[-_])*)\]\s*")
EXPRESSION = re.compile(r"\s*(?P<key>\w(\w|[-_])*)\s*[:=]\s*(?P<value>.*)\s*")
class Value (object):
- """Class defining a value of a key.
+ """
+ Class defining a value of a key.
+
+ :IVariables:
+
+ value
+ The specific value.
+
+ old
+ The old value
+
+ line : int
+ The line in the config file.
+
+ boolean : boolean
+ The boolean meaning of this value. Set this to ``None`` if this is not a boolean.
+
+ changed : boolean
+ Set to True if the value has been changed.
+ """
- @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.
+ """
+ Constructor.
- @param value: the value
- @type value: string
- @param line: the line in the config file
- @type line: int
- @param bool: The boolean meaning of the value. Set this to C{None} if this is not a boolean.
- @type bool: boolean"""
+ :Parameters:
+
+ value : string
+ the value
+
+ line : int
+ the line in the config file
+
+ bool : boolean
+ The boolean meaning of the value. Set this to ``None`` if this is not a boolean.
+ """
self.__value = value
self.line = line
@@ -78,10 +105,12 @@ class Value (object):
self.old = value # keep the original one ... so if we change it back to this one, we do not have to write
def set (self, value):
- """Sets the value to a new one.
+ """
+ Sets the value to a new one.
- @param value: new value
- @type value: string"""
+ :param value: new value
+ :type value: string
+ """
self.__value = value
@@ -91,18 +120,20 @@ class Value (object):
self.changed = False
def get (self):
- """Returns the actual value.
+ """
+ Returns the actual value.
- @returns: the actual value
- @rtype: string"""
+ :rtype: string
+ """
return self.__value
def is_bool (self):
- """Returns whether the actual value has a boolean meaning.
+ """
+ Returns whether the actual value has a boolean meaning.
- @returns: True if the actual value can be interpreted as a boolean
- @rtype: boolean"""
+ :rtype: boolean
+ """
return (self.boolean != None)
@@ -115,19 +146,25 @@ class Value (object):
value = property(get,set)
class ConfigParser:
- """The parser class.
+ """
+ The parser class.
- @cvar true_false: A mapping from the truth values to their opposits.
- @type true_false: string -> string
+ :CVariables:
+
+ true_false : string -> string
+ A mapping from the truth values to their opposits.
- @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)"""
+ :IVariables:
+
+ file : string
+ the file to scan
+ cache : string[]
+ caches the content of the file
+ vars : string -> (string -> `Value`)
+ the found options grouped by section
+ pos : int -> (int, int)
+ the positions of the values grouped by lineno
+ """
# generates the complementary true-false-pairs
true_false = {
@@ -140,10 +177,12 @@ class ConfigParser:
true_false.update(zip(true_false.values(), true_false.keys()))
def __init__ (self, file):
- """Constructor.
+ """
+ Constructor.
- @param file: the configuration file to open
- @type file: string"""
+ :param file: the configuration file to open
+ :type file: string
+ """
self.file = file
self.writelock = Lock()
@@ -158,12 +197,16 @@ class ConfigParser:
self.sections = {"MAIN" : -1} # the line with the section header
def _invert (self, val):
- """Invertes a given boolean.
+ """
+ Invertes a given boolean.
+
+ :param val: value to invert
+ :type val: string
+ :returns: inverted value
+ :rtype: string
- @param val: value to invert
- @type val: string
- @returns: inverted value
- @rtype: string"""
+ :see: `true_false`
+ """
return self.true_false[val.lower()]
@@ -214,35 +257,43 @@ class ConfigParser:
error(_("Unrecognized line in configuration: %s"), line)
def get (self, key, section = "MAIN"):
- """Returns the value of a given key in a section.
+ """
+ Returns the value of a given key in a section.
+
+ :Parameters:
- @param key: the key
- @type key: string
- @param section: the section
- @type section: string
+ key : string
+ the key
+ section : string
+ the section
- @returns: value
- @rtype: string
+ :returns: value
+ :rtype: string
- @raises KeyError: if section or key could not be found"""
+ :raises KeyError: if section or key could not be found
+ """
section = section.upper()
key = key.lower()
return self.vars[section][key].value
def get_boolean (self, key, section = "MAIN"):
- """Returns the boolean value of a given key in a section.
+ """
+ Returns the boolean value of a given key in a section.
- @param key: the key
- @type key: string
- @param section: the section
- @type section: string
+ :Parameters:
+
+ key : string
+ the key
+ section : string
+ the section
- @returns: value
- @rtype: boolean
+ :returns: value
+ :rtype: boolean
- @raises KeyError: if section or key could not be found
- @raises ValueError: if key does not have a boolean value"""
+ :raises KeyError: if section or key could not be found
+ :raises ValueError: if key does not have a boolean value
+ """
section = section.upper()
key = key.lower()
@@ -255,16 +306,20 @@ class ConfigParser:
raise ValueError, "\"%s\" is not a boolean. (%s)" % (key, val.value)
def set (self, key, value = "", section = "MAIN"):
- """Sets a new value of a given key in a section.
-
- @param key: the key
- @type key: string
- @param value: the new value
- @type value: string
- @param section: the section
- @type section: string
+ """
+ Sets a new value of a given key in a section.
+
+ :Parameters:
+
+ key : string
+ the key
+ value : string
+ the new value
+ section : string
+ the section
- @raises KeyError: if section or key could not be found"""
+ :raises KeyError: if section or key could not be found
+ """
section = section.upper()
key = key.lower()
@@ -272,18 +327,21 @@ class ConfigParser:
self.vars[section][key].value = value
def set_boolean (self, key, value, section = "MAIN"):
- """Sets a new boolean value of a given key in a section.
+ """
+ Sets a new boolean value of a given key in a section.
Therefore it invertes the string representation of the boolean (in lowercase).
- @param key: the key
- @type key: string
- @param value: the new value
- @type value: boolean
- @param section: the section
- @type section: string
-
- @raises KeyError: if section or key could not be found
- @raises ValueError: if the old/new value is not a boolean"""
+ :Parameters:
+
+ key : string
+ the key
+ value : boolean
+ the new value
+ section : string
+ the section
+
+ :raises KeyError: if section or key could not be found
+ :raises ValueError: if the old/new value is not a boolean"""
section = section.upper()
key = key.lower()
diff --git a/portato/dependency.py b/portato/dependency.py
index 718906f..91e4fb5 100644
--- a/portato/dependency.py
+++ b/portato/dependency.py
@@ -10,15 +10,16 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
-from __future__ import absolute_import, with_statement
-
-from .helper import debug
-
"""
Provides classes for the presentation of dependencies.
"""
+
+from __future__ import absolute_import, with_statement
__docformat__ = "restructuredtext"
+
+from .helper import debug
+
class Dependency (object):
"""
@@ -93,7 +94,7 @@ class DependencyTree (object):
deps : set(`Dependency`)
The list of dependencies which are not dependent on a useflag.
- flags : dict(string -> `DependencyTree`)
+ flags : string -> `DependencyTree`
Holds the additional dependency trees per useflag.
"""
diff --git a/portato/gui/gtk/windows.py b/portato/gui/gtk/windows.py
index ff8dc90..aecebd3 100644
--- a/portato/gui/gtk/windows.py
+++ b/portato/gui/gtk/windows.py
@@ -637,11 +637,6 @@ class PackageTable:
self.useList.set_enable_tree_lines(True)
def build_version_combo (self):
- """Builds the package list.
-
- @param name: name of the selected catetegory
- @type name: string"""
-
store = gtk.ListStore(gtk.gdk.Pixbuf, str)
# build view
diff --git a/portato/gui/gui_helper.py b/portato/gui/gui_helper.py
index 57b9e43..15125c9 100644
--- a/portato/gui/gui_helper.py
+++ b/portato/gui/gui_helper.py
@@ -434,7 +434,7 @@ class EmergeQueue:
@param cpv: Package to add
@type cpv: string (cat/pkg-ver)
@param type: The type of this append process. Possible values are "install", "uninstall", "update".
- @type unmerge: string
+ @type type: string
@param update: Set to True if a package is going to be updated (e.g. if the use-flags changed).
@type update: boolean
@param forceUpdate: Set to True if the update should be forced.
@@ -665,7 +665,7 @@ class EmergeQueue:
@param force: If False, '-pv' is send to emerge. Default: False.
@type force: boolean
@param newuse: If True, append newuse options
- @type force: boolean
+ @type newuse: boolean
@param deep: If True, append deep options
@type deep: boolean
@param options: Additional options to send to the emerge command
diff --git a/portato/session.py b/portato/session.py
index 026c7fc..be622cf 100644
--- a/portato/session.py
+++ b/portato/session.py
@@ -33,7 +33,7 @@ class Session (object):
def __init__ (self, file):
"""
- Initialize a session with a certain file inside L{SESSION_DIR.}
+ Initialize a session with a certain file inside L{SESSION_DIR}.
@param file: the file in L{SESSION_DIR}, where the options will be saved.
"""