~ubuntu-branches/ubuntu/wily/wicd/wily

« back to all changes in this revision

Viewing changes to debian/patches/33-deepcopy_python27_fixes.patch

  • Committer: Bazaar Package Importer
  • Author(s): David Paleino
  • Date: 2011-02-12 00:16:58 UTC
  • mfrom: (8.2.12 sid)
  • Revision ID: james.westby@ubuntu.com-20110212001658-a7yd2p5vepbr7xyp
Tags: 1.7.0+ds1-6
* debian/patches/:
  - 26-support_etc-network_scripts.patch refreshed, /etc/network/
    scripts should now be properly supported (Closes: #579497)
  - 31-dont_crash_on_notification_exceptions.patch added
    (Closes: #569755, #587303)
  - 32-prefer_gksu.patch added (Closes: #575403)
  - 33-deepcopy_python27_fixes.patch backported from Ubuntu,
    thanks to Matthieu Baerts (LP: #602825)
  - 34-dont_save_useless_config.patch added: don't save link quality,
    signal strength and bitrates in the configuration files.
    (Closes: #612918)
  - 35-restrict_netmode_characters.patch added, don't crash
    if the network mode is not what we expect. Thanks to Julien
    Blache for the patch (Closes: #550957)
* debian/control:
  - removed depedency on python-iniparse from wicd-daemon
  - removed Build-Depends on quilt
  - fixed typo in long description, thanks to Martin Eberhard Schauer
    (Closes: #611567)
  - bump Standards-Version to 3.9.1, no changes needed
  - use Breaks+Replaces instead of Conflicts+Replaces
* debian/rules:
  - don't use "--with quilt" anymore
* debian/po/pt_BR.po added: debconf translation for Brazilian
  Portuguese, thanks to Adriano Rafael Gomes (Closes: #594266)
* debian/wicd-daemon.config: don't ask if all users are already
  in the netdev group (Closes: #588078)
* debian/wicd-cli.8: explain -w/--save and -m/--name (Closes: #583586)
* debian/wicd-daemon.wicd.init, export $PATH, makes the daemon work
  in a clean environment. Thanks to Peter Palfrader (Closes: #604810)
* debian/wicd-curses.postrm: redirect stderr (Closes: #605338)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From: Matthieu Baerts <matttbe@gmail.com>
 
2
Subject: Added the compatibility with python2.7
 
3
Origin: vendor, http://repos.archlinux.org/wsvn/packages/wicd/trunk/deepcopy%2Bpython27-fixes.patch
 
4
Origin: upstream, http://bazaar.launchpad.net/~wicd-devel/wicd/experimental/revision/564
 
5
Bug: https://bugs.launchpad.net/wicd/+bug/602825
 
6
Forwarded: yes
 
7
 
 
8
---
 
9
 wicd/configmanager.py |   39 +++++++++++++++++++++++----------------
 
10
 1 file changed, 23 insertions(+), 16 deletions(-)
 
11
 
 
12
--- wicd.orig/wicd/configmanager.py
 
13
+++ wicd/wicd/configmanager.py
 
14
@@ -24,7 +24,7 @@ reusable for other purposes as well.
 
15
 #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
 #
 
17
 
 
18
-import os, copy
 
19
+import sys, os, copy
 
20
 
 
21
 from ConfigParser import RawConfigParser, ParsingError
 
22
 
 
23
@@ -35,7 +35,10 @@ from dbus import Int32
 
24
 class ConfigManager(RawConfigParser):
 
25
     """ A class that can be used to manage a given configuration file. """
 
26
     def __init__(self, path, debug=False, mark_whitespace="`'`"):
 
27
-        RawConfigParser.__init__(self)
 
28
+        if sys.version_info >= (2, 7, 0):
 
29
+            RawConfigParser.__init__(self, allow_no_value=True)
 
30
+        else:
 
31
+            RawConfigParser.__init__(self)
 
32
         self.config_file = path
 
33
         self.debug = debug
 
34
         self.mrk_ws = mark_whitespace
 
35
@@ -46,7 +49,6 @@ class ConfigManager(RawConfigParser):
 
36
             try:
 
37
                 self.read(path)
 
38
             except ParsingError, p:
 
39
-                import sys
 
40
                 print "Could not start wicd: %s" % p.message
 
41
                 sys.exit(1)
 
42
 
 
43
@@ -185,28 +187,33 @@ class ConfigManager(RawConfigParser):
 
44
 
 
45
 
 
46
     def _copy_section(self, name):
 
47
-        # Yes, deepcopy sucks, but it is robust to changes in both
 
48
-        # this class and RawConfigParser.
 
49
-        p = copy.deepcopy(self)
 
50
-        for sname in p.sections():
 
51
-            if sname != name:
 
52
-                p.remove_section(sname)
 
53
+        p = ConfigManager("", self.debug, self.mrk_ws)
 
54
+        p.add_section(name)
 
55
+        for (iname, value) in self.items(name):
 
56
+            p.set(name, iname, value)
 
57
+        # Store the filename this section was read from.
 
58
         p.config_file = p.get_option(name, '_filename_', p.config_file)
 
59
         p.remove_option(name, '_filename_')
 
60
         return p
 
61
 
 
62
     def write(self):
 
63
         """ Writes the loaded config file to disk. """
 
64
-        # Really don't like this deepcopy.
 
65
-        p = copy.deepcopy(self)
 
66
-        for sname in p.sections():
 
67
-            fname = p.get_option(sname, '_filename_')
 
68
+        in_this_file = []
 
69
+        for sname in self.sections():
 
70
+            fname = self.get_option(sname, '_filename_')
 
71
             if fname and fname != self.config_file:
 
72
                 section = self._copy_section(sname)
 
73
-                p.remove_section(sname)
 
74
                 section._write_one()
 
75
+            else:
 
76
+                # Save names of local sections
 
77
+                in_this_file.append(sname)
 
78
 
 
79
-        for sname in p.sections():
 
80
+        # Make an instance with only these sections
 
81
+        p = ConfigManager("", self.debug, self.mrk_ws)
 
82
+        p.config_file = self.config_file
 
83
+        for sname in in_this_file:
 
84
+            p.add_section(sname)
 
85
+            for (iname, value) in self.items(sname):
 
86
+                p.set(sname, iname, value)
 
87
             p.remove_option(sname, '_filename_')
 
88
         p._write_one()
 
89
-