#4651 HIGH Update.: Sugar should make better use of tmp space

Zarro Boogs per Child bugtracker at laptop.org
Tue Dec 11 11:19:12 EST 2007


#4651: Sugar should make better use of tmp space
---------------------+------------------------------------------------------
  Reporter:  tomeu   |       Owner:  rwh     
      Type:  defect  |      Status:  new     
  Priority:  high    |   Milestone:  Update.1
 Component:  sugar   |     Version:          
Resolution:          |    Keywords:  review- 
  Verified:  0       |  
---------------------+------------------------------------------------------
Changes (by marco):

  * keywords:  review? => review-


Comment:

 {{{

 +    def get_icon_data(self):
 +        """Get the activity icon data"""
          icon_path = os.path.join('activity', self._icon + '.svg')
          if self._unpacked:
 -            return os.path.join(self._path, icon_path)
 +            f = open(os.path.join(self._path, icon_path))
          else:
 -            icon_data = self._get_file(icon_path).read()
 -            temp_file, temp_file_path = tempfile.mkstemp(self._icon)
 -            os.write(temp_file, icon_data)
 -            os.close(temp_file)
 -            return temp_file_path
 +            f = self._get_file(icon_path)
 +        return f.read()

 }}}

 We need to make sure to close the file there.

 {{{
 +    def load_svg_data(self, icon, entities):
 }}}

 I think create_handle would be a more descriptive name for the method.

 {{{
 +            if is_svg:
 +                handle = self._load_svg(icon_info.file_name)
 +                dimensions = handle.get_dimension_data()
 +                icon_width = int(dimensions[0])
 +                icon_height = int(dimensions[1])
 }}}

 It should be possible to avoid the dimension code duplication there. In
 general I feel like this part of the patch could use some cleanups, but
 see below.

 {{{
 +        'svg-data'     : (str, None, None, None,
 +                           gobject.PARAM_READWRITE),
 }}}

 Any reason to make this svg only? It seem like we could easily detect the
 mime type from the data and use our svg loader for svg icons and pixbuf
 for any other mime.

-- 
Ticket URL: <http://dev.laptop.org/ticket/4651#comment:18>
One Laptop Per Child <http://dev.laptop.org>
OLPC bug tracking system



More information about the Bugs mailing list