daily pastebin goal
18%
SHARE
TWEET

Untitled

a guest Jun 19th, 2017 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- wicd/configmanager.py       2010-01-15 05:49:11.000000000 +0100
  2. +++ 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()
RAW Paste Data
Top