[sugar] [PATCH] Browse - copy Image to clipboard under rainbow
Tomeu Vizoso
tomeu at tomeuvizoso.net
Mon Jun 9 07:01:08 EDT 2008
On Sun, Jun 8, 2008 at 11:44 AM, Simon Schampijer <simon at schampijer.de> wrote:
> Hi,
>
> tomeu can you verify that patch?
>
> Use case: Copying an image using the palette under rainbow.
>
> We loose the data which exist in the filename, should we try to store this
> somehow?
Hi,
good catches, what about:
- file_name = urlparse.urlparse(self._url).path
- extension = None
+ file_name = os.path.basename(urlparse.urlparse(self._url).path)
if '.' in file_name:
- extension = file_name.split('.')[1]
- fd, self._temp_file = tempfile.mkstemp(suffix='.' + extension)
+ base_name, extension = file_name.split('.')
+ extension = '.' + extension
+ else:
+ base_name = file_name
+ extension = ''
+
+ temp_path = os.path.join(activity.get_activity_root(), 'instance')
+ fd, self._temp_file = tempfile.mkstemp(dir=temp_path, prefix=base_name,
+ suffix=extension)
os.close(fd)
+ os.chmod(self._temp_file, 0644)
This way we specify the dir we want to save to, preserve the base file
name, and make sure it's unique by using mkstemp.
Thanks,
Tomeu
More information about the Sugar
mailing list