~ubuntu-branches/ubuntu/lucid/phatch/lucid

« back to all changes in this revision

Viewing changes to phatch/actions/copy.py

  • Committer: Package Import Robot
  • Author(s): Emilio Pozuelo Monfort, Stani M, Emilio Pozuelo Monfort
  • Date: 2010-03-12 14:04:02 UTC
  • mfrom: (1.1.11) (4.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20100312140402-o6g6terpbqksf1dw
Tags: 0.2.7-1
[ Stani M ]
* Upstream bugfix release (Closes LP: #472978, #487435, #516763, #516858, 
  #525999, #526047, #526235, #526237, #526489, #529343, #529429, #525831, 
  #526237, #529544, #529605, #531375, #531705, #531728, #532346, #532356, 
  #532540, #532544, #533068, #534723, #534834, #534835, #535189, #535192,
  #536820)
* debian/control: Add python-nautilus to phatch-nautilus's Depends

[ Emilio Pozuelo Monfort ]
* debian/rules:
  - Adapt for the upstream changes.
* debian/copyright:
  - Updated for the new version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# Phatch recommends SPE (http://pythonide.stani.be) for editing python files.
18
18
 
19
19
# Embedded icon is designed by Igor Kekeljevic (http://www.admiror-ns.co.yu).
 
20
#
 
21
# Follows PEP8
 
22
 
20
23
 
21
24
from core import ct, models
22
25
from lib.reverse_translation import _t
23
26
 
24
27
#no need to lazily import these as they are always imported
25
 
import os, shutil
 
28
import os
 
29
import shutil
 
30
 
26
31
 
27
32
class Action(models.Action):
28
33
    """Defined variables: <filename> <type> <folder> <width> <height>"""
29
34
 
30
 
    label       = _t('Copy')
31
 
    author      = 'Stani'
32
 
    email       = 'spe.stani.be@gmail.com'
33
 
    version     = '0.1'
34
 
    tags        = [_t('file')]
35
 
    __doc__     = _t('Copy the original image')
36
 
    valid_last  = True
 
35
    label = _t('Copy')
 
36
    author = 'Stani'
 
37
    email = 'spe.stani.be@gmail.com'
 
38
    version = '0.1'
 
39
    tags = [_t('file')]
 
40
    __doc__ = _t('Copy the original image')
 
41
    valid_last = True
37
42
 
38
 
    def interface(self,fields):
39
 
        fields[_t('File Name')]    = self.FileNameField(choices=self.FILENAMES)
40
 
        fields[_t('In')]           = self.FolderField(self.DEFAULT_FOLDER,
 
43
    def interface(self, fields):
 
44
        fields[_t('File Name')] = self.FileNameField(choices=self.FILENAMES)
 
45
        fields[_t('In')] = self.FolderField(self.DEFAULT_FOLDER,
41
46
                                        choices=self.FOLDERS)
42
47
 
43
 
    def apply(self,photo,setting,cache):
 
48
    def apply(self, photo, setting, cache):
44
49
        #get info
45
 
        info                    = photo.info
 
50
        info = photo.info
46
51
        #get file values
47
 
        folder, filename, typ   = self.is_done_info(info)
48
 
        if setting('overwrite_existing_images') or not os.path.exists(filename):
 
52
        folder, filename, typ = self.is_done_info(info)
 
53
        if setting('overwrite_existing_images') \
 
54
                or not os.path.exists(filename):
49
55
            #ensure folder
50
56
            filename = self.ensure_path_or_desktop(folder, photo, filename)
51
57
            #do it
52
 
            shutil.copy2(info['path'],filename)
 
58
            shutil.copy2(info['path'], filename)
53
59
        return photo
54
60
 
55
 
    def is_done_info(self,info):
56
 
        folder      = self.get_field('In',info)
57
 
        filename    = self.get_field('File Name',info)
58
 
        typ         = info['type']
59
 
        return folder, os.path.join(folder,'%s.%s'%(filename,typ)), typ
 
61
    def is_done_info(self, info):
 
62
        folder = self.get_field('In', info)
 
63
        filename = self.get_field('File Name', info)
 
64
        typ = info['type']
 
65
        return folder, os.path.join(folder, '%s.%s' % (filename, typ)), typ
60
66
 
61
67
    def is_overwrite_existing_images_forced(self):
62
68
        """Force overwrite when copying in place."""