summaryrefslogtreecommitdiff
path: root/Pb/Break/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'Pb/Break/__init__.py')
-rwxr-xr-xPb/Break/__init__.py44
1 files changed, 23 insertions, 21 deletions
diff --git a/Pb/Break/__init__.py b/Pb/Break/__init__.py
index 3eb9b2a..cf12cc2 100755
--- a/Pb/Break/__init__.py
+++ b/Pb/Break/__init__.py
@@ -29,7 +29,7 @@ class PbBreak(Pb): #FIXME in db gallery
}
def __init__(self, **kwargs):
super(PbBreak,self).__init__();
- _definitions_hash = {
+ _definitions = {
'username': { 'type': 'string' },
'breaktype': { 'type': 'string' },
'breakmode': {
@@ -40,21 +40,23 @@ class PbBreak(Pb): #FIXME in db gallery
'breakangle': { 'type': 'float' },
'expanded': { 'type': 'bool' },
'url': { 'type': 'img_url' },
+ 'finalformat': { 'type': 'enum', 'enum_values' : ['png', 'gif', 'jpg' ] }
}
- self._files_created.append(self.params.url['path'])
- self.params.breaktype = self._get_breaktype(self.params.breaktype)
+ self.params.definitions_import(_definitions, kwargs, classname=self.__class__.__name__);
+ self._files_created.append(self.params.url.path)
+ self.params.breaktype.set_val(self._get_breaktype(str(self.params.breaktype)))
#psd returns an animation
- if not finalformat and self.params.url['mimetype'] == "gif":
- self.params.set_val("finalformat", "gif", value_type="string")
+ if not self.params.finalformat and self.params.url.mimetype == "gif":
+ self.params.finalformat.set_val("gif")
elif self.params.breaktype == 'miff':
- self.params.set_val("finalformat", "jpg", value_type="string")
- self.params.breakmode = "subtle"
- else:
- self.params.set_val("finalformat", finalformat or DEFAULT_FINALFORMAT, value_type="string")
- self._width_and_height_set(filepath=self.params.url['path'])
+ self.params.finalformat.set_val("jpg")
+ self.params.breakmode.set_val("subtle")
+ elif not self.params.finalformat:
+ self.params.finalformat.set_val(DEFAULT_FINALFORMAT)
+ self._width_and_height_set(filepath=self.params.url.path)
- self.filename, self.filepath = self._filename_filepath_create(url=self.params.url['url'], extension=self.params.finalformat)
+ self.filename, self.filepath = self._filename_filepath_create(url=self.params.url.url, extension=self.params.finalformat)
self._conversion_file = self._tempfilepath_create(namepart="conversion", extension=self.params.breaktype)
def _get_breaktype(self, key):
@@ -79,7 +81,7 @@ class PbBreak(Pb): #FIXME in db gallery
#{{{#########rotatefunctions#######################################
def _rotate(self):
- cmd = [BIN_CONVERT,self.params.url['path'],"-rotate",self.params.breakangle,"+repage",self.params.url['path']]
+ cmd = [BIN_CONVERT,self.params.url.path,"-rotate",self.params.breakangle,"+repage",self.params.url.path]
self._call_cmd(cmd)
def _rotate_back(self):
@@ -113,22 +115,22 @@ class PbBreak(Pb): #FIXME in db gallery
def _enforce_jpg(self):
- if self.params.breaktype in [ "exr", "bmp", "miff" ] and not re.match(r'jpe?g$', self.params.url['mimetype'], re.IGNORECASE):
+ if self.params.breaktype in [ "exr", "bmp", "miff" ] and not re.match(r'jpe?g$', self.params.url.mimetype, re.IGNORECASE):
jpg_file = self._tempfilepath_create(extension="jpg")
- self._call_cmd([BIN_CONVERT,self.params.url['path'], jpg_file])
+ self._call_cmd([BIN_CONVERT,self.params.url.path, jpg_file])
self._files_created.append(jpg_file)
self._conversion_file = jpg_file
def _first_conversion(self):
- if self.params.url['mimetype'] == self.params.breaktype:
- self._conversion_file = self.params.url['path']
+ if self.params.url.mimetype == self.params.breaktype:
+ self._conversion_file = self.params.url.path
return
- self._call_cmd([BIN_CONVERT, self.params.url['path'], self._conversion_file])
+ self._call_cmd([BIN_CONVERT, self.params.url.path, self._conversion_file])
self._files_created.append(self._conversion_file)
def _prepare_filedata(self):
- if self.params.url['mimetype'] == "gif": #FIXME and not miami
- self._choose_gif_frame(self.params.url['path'])
+ if self.params.url.mimetype == "gif" and self.params.breaktype not in [ 'mat', 'psd' ]:
+ self._choose_gif_frame(self.params.url.path)
if self.params.breakangle:
self._rotate()
self._enforce_jpg();
@@ -150,10 +152,10 @@ class PbBreak(Pb): #FIXME in db gallery
self._call_cmd( [BIN_CONVERT, self._conversion_file, self.filepath])
def psd_psbfilepath(num):
return os.path.join(re.sub(r'\.', "-%s." % num, self.filepath))
- if self.params.breaktype == 'psd':
+ if str(self.params.breaktype) == 'psd':
self._call_cmd(['mv', psd_psbfilepath(1), self.filepath])
self._files_created.append(psd_psbfilepath(0))
- if self.params.breaktype == 'psb':
+ if str(self.params.breaktype) == 'psb':
self._call_cmd(['mv', psd_psbfilepath(0), self.filepath])
self._files_created.append(psd_psbfilepath(1))
if self.params.breakangle: