]> git.pld-linux.org Git - packages/wicd.git/blob - no-deepcopy.patch
- better systemd deps
[packages/wicd.git] / no-deepcopy.patch
1 --- wicd-1.7.0/wicd/configmanager.py    2010-01-15 05:49:11.000000000 +0100
2 +++ wicd-1.7.0/wicd/configmanager.py.new        2010-10-05 22:10:33.267799689 +0200
3 @@ -176,28 +176,35 @@
4  
5  
6      def _copy_section(self, name):
7 -        # Yes, deepcopy sucks, but it is robust to changes in both
8 -        # this class and RawConfigParser.
9 -        p = copy.deepcopy(self)
10 -        for sname in p.sections():
11 -            if sname != name:
12 -                p.remove_section(sname)
13 +        p = ConfigManager("", self.debug, self.mrk_ws)
14 +        p.add_section(name)
15 +        for (iname, value) in self.items(name):
16 +            p.set(name, iname, value)
17 +        # Store the filename this section was read from.
18          p.config_file = p.get_option(name, '_filename_', p.config_file)
19          p.remove_option(name, '_filename_')
20          return p
21  
22      def write(self):
23          """ Writes the loaded config file to disk. """
24 -        # Really don't like this deepcopy.
25 -        p = copy.deepcopy(self)
26 -        for sname in p.sections():
27 -            fname = p.get_option(sname, '_filename_')
28 +        in_this_file = []
29 +        for sname in self.sections():
30 +            fname = self.get_option(sname, '_filename_')
31              if fname and fname != self.config_file:
32 +                # Write sections from other files
33                  section = self._copy_section(sname)
34 -                p.remove_section(sname)
35                  section._write_one()
36 +            else:
37 +                # Save names of local sections
38 +                in_this_file.append(sname)
39  
40 -        for sname in p.sections():
41 +        # Make an instance with only these sections
42 +        p = ConfigManager("", self.debug, self.mrk_ws)
43 +        p.config_file = self.config_file
44 +        for sname in in_this_file:
45 +            p.add_section(sname)
46 +            for (iname, value) in self.items(sname):
47 +                p.set(sname, iname, value)
48              p.remove_option(sname, '_filename_')
49          p._write_one()
50  
51 --- wicd-1.7.0/wicd/configmanager.py~   2010-01-15 05:49:11.000000000 +0100
52 +++ wicd-1.7.0/wicd/configmanager.py    2010-10-07 23:07:33.133465822 +0200
53 @@ -35,7 +35,7 @@
54  class ConfigManager(RawConfigParser):
55      """ A class that can be used to manage a given configuration file. """
56      def __init__(self, path, debug=False, mark_whitespace="`'`"):
57 -        RawConfigParser.__init__(self)
58 +        RawConfigParser.__init__(self,allow_no_value=True)
59          self.config_file = path
60          self.debug = debug
61          self.mrk_ws = mark_whitespace
This page took 0.070351 seconds and 3 git commands to generate.