packages: wicd/no-deepcopy.patch (NEW) - initial - https://bugs.launchpad.n...

uzsolt uzsolt at pld-linux.org
Tue Oct 5 22:59:36 CEST 2010


Author: uzsolt                       Date: Tue Oct  5 20:59:36 2010 GMT
Module: packages                      Tag: HEAD
---- Log message:
- initial
- https://bugs.launchpad.net/wicd/+bug/602825/comments/24

---- Files affected:
packages/wicd:
   no-deepcopy.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: packages/wicd/no-deepcopy.patch
diff -u /dev/null packages/wicd/no-deepcopy.patch:1.1
--- /dev/null	Tue Oct  5 22:59:36 2010
+++ packages/wicd/no-deepcopy.patch	Tue Oct  5 22:59:31 2010
@@ -0,0 +1,50 @@
+--- wicd-1.7.0/wicd/configmanager.py	2010-01-15 05:49:11.000000000 +0100
++++ wicd-1.7.0/wicd/configmanager.py.new	2010-10-05 22:10:33.267799689 +0200
+@@ -176,28 +176,35 @@
+ 
+ 
+     def _copy_section(self, name):
+-        # Yes, deepcopy sucks, but it is robust to changes in both
+-        # this class and RawConfigParser.
+-        p = copy.deepcopy(self)
+-        for sname in p.sections():
+-            if sname != name:
+-                p.remove_section(sname)
++        p = ConfigManager("", self.debug, self.mrk_ws)
++        p.add_section(name)
++        for (iname, value) in self.items(name):
++            p.set(name, iname, value)
++        # Store the filename this section was read from.
+         p.config_file = p.get_option(name, '_filename_', p.config_file)
+         p.remove_option(name, '_filename_')
+         return p
+ 
+     def write(self):
+         """ Writes the loaded config file to disk. """
+-        # Really don't like this deepcopy.
+-        p = copy.deepcopy(self)
+-        for sname in p.sections():
+-            fname = p.get_option(sname, '_filename_')
++        in_this_file = []
++        for sname in self.sections():
++            fname = self.get_option(sname, '_filename_')
+             if fname and fname != self.config_file:
++                # Write sections from other files
+                 section = self._copy_section(sname)
+-                p.remove_section(sname)
+                 section._write_one()
++            else:
++                # Save names of local sections
++                in_this_file.append(sname)
+ 
+-        for sname in p.sections():
++        # Make an instance with only these sections
++        p = ConfigManager("", self.debug, self.mrk_ws)
++        p.config_file = self.config_file
++        for sname in in_this_file:
++            p.add_section(sname)
++            for (iname, value) in self.items(sname):
++                p.set(sname, iname, value)
+             p.remove_option(sname, '_filename_')
+         p._write_one()
+ 
================================================================


More information about the pld-cvs-commit mailing list