From bbc58ea395a62bb5e27a377f73ce586db7296d64 Mon Sep 17 00:00:00 2001 From: pepperpepperpepper Date: Tue, 1 Mar 2016 21:26:05 -0800 Subject: ok even better --- photoblaster/modules/base.py | 8 ++++++- photoblaster/modules/pbbreaker.py | 45 ++++++++++++++++++++++++-------------- photoblaster/modules/pbgradient.py | 17 ++++++++------ 3 files changed, 45 insertions(+), 25 deletions(-) diff --git a/photoblaster/modules/base.py b/photoblaster/modules/base.py index 4d39266..86cc8dc 100644 --- a/photoblaster/modules/base.py +++ b/photoblaster/modules/base.py @@ -25,7 +25,7 @@ class Pb(object): self.tag = self.__class__.__name__ self._db_url_param = None - self.output_file = None + self._output_file = None self.width = None self.height = None @@ -93,3 +93,9 @@ class Pb(object): def create(self): pass #self._cleanup() + + def get_output_file(self): + return self._output_file + + def set_output_file(self, output_file): + self._output_file = output_file diff --git a/photoblaster/modules/pbbreaker.py b/photoblaster/modules/pbbreaker.py index 4fa654f..94bfb3c 100755 --- a/photoblaster/modules/pbbreaker.py +++ b/photoblaster/modules/pbbreaker.py @@ -75,11 +75,12 @@ class PbBreaker(Pb): self.params.finalformat.set_val(DEFAULT_FINALFORMAT) self.width, self.height = self.params.url.get_file().get_dimensions() - self.output_file = File.from_url( - self.params.url.url, - extension=self.params.finalformat, - classname=self.__class__.__name__, - username=self.params.username + self.set_output_file( + File.from_url( + self.params.url.url, + extension=self.params.finalformat, + classname=self.__class__.__name__, + username=self.params.username) ) self._conversion_file = File( is_temp=True, @@ -105,18 +106,19 @@ class PbBreaker(Pb): def _rotate_back(self): angle = str(360-int(self.params.breakangle)) cmd = [BIN_CONVERT, - self.output_file.get_filepath(), - "-rotate", angle, "+repage", self.output_file.get_filepath()] + self.get_output_file().get_filepath(), + "-rotate", angle, "+repage", + self.get_output_file().get_filepath()] self._call_cmd(cmd) if not self.params.expanded: cmd = [BIN_CONVERT, - self.output_file.get_filepath(), + self.get_output_file().get_filepath(), "-gravity", "Center", "-crop", "{}x{}+0+0".format(self.width, self.height), "+repage", - self.output_file.get_filepath()] + self.get_output_file().get_filepath()] self._call_cmd(cmd) def _subtle_break(self): @@ -188,22 +190,31 @@ class PbBreaker(Pb): self._call_cmd([ BIN_CONVERT, self._conversion_file.get_filepath(), - self.output_file.get_filepath()]) + self.get_output_file().get_filepath()]) def psd_psbfilepath(num): return os.path.join( - re.sub(r'\.', "-%s." % num, self.output_file.get_filepath()) + re.sub( + r'\.', "-%s." % num, self.get_output_file().get_filepath()) ) if str(self.params.breaktype) == 'psd': self._call_cmd( - ['mv', psd_psbfilepath(1), self.output_file.get_filepath()]) - self.output_file.set_filepath(filepath=psd_psbfilepath(0)) - self._files_created.append(self.output_file) + [ + 'mv', psd_psbfilepath(1), + self.get_output_file().get_filepath() + ] + ) + self._output_file.set_filepath(filepath=psd_psbfilepath(0)) + self._files_created.append(self.get_output_file()) if str(self.params.breaktype) == 'psb': self._call_cmd( - ['mv', psd_psbfilepath(0), self.output_file.get_filepath()]) - self.output_file.set_filepath(filepath=psd_psbfilepath(1)) - self._files_created.append(self.output_file) + [ + 'mv', + psd_psbfilepath(0), + self.get_output_file().get_filepath() + ]) + self._output_file.set_filepath(filepath=psd_psbfilepath(1)) + self._files_created.append(self.get_output_file()) if self.params.breakangle: self._rotate_back() diff --git a/photoblaster/modules/pbgradient.py b/photoblaster/modules/pbgradient.py index b65412c..fe885b5 100755 --- a/photoblaster/modules/pbgradient.py +++ b/photoblaster/modules/pbgradient.py @@ -89,11 +89,12 @@ class PbGradient(Pb): str(self.params.color2).replace( '#', '').replace('(', '-').replace(')', '-') ) - self.output_file = File( - namepart=namepart, - extension=self.params.filetype, - classname=self.__class__.__name__, - username=self.params.username + self.set_output_file( + File( + namepart=namepart, + extension=self.params.filetype, + classname=self.__class__.__name__, + username=self.params.username) ) def _build_cmd(self): @@ -186,7 +187,7 @@ class PbGradient(Pb): self.params.hue or "100" ) ] - cmd.append(self.output_file.get_filepath()) + cmd.append(self.get_output_file().get_filepath()) self._call_cmd(cmd) if self.params.bevel: self._make_bevel() @@ -224,7 +225,9 @@ class PbGradient(Pb): def _make_bevel(self): cmd = [BEVELBORDER] cmd += self._get_bevelvalue() - cmd += [self.output_file.get_filepath(), self.output_file.get_filepath()] + cmd += [ + self.get_output_file().get_filepath(), + self.get_output_file().get_filepath()] self._call_cmd(cmd) def create(self): -- cgit v1.2.3-70-g09d2