[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [PATCH 1/4] Add logpicker into utils



----- "Brian C. Lane" <bcl redhat com> wrote:
> On Mon, Sep 13, 2010 at 11:24:34AM +0200, Ales Kozumplik wrote:
> > 
> > this method name:
> > >+    def _get_file(self, file):
> > >+        self.get_files([file])
> > >+
> > and this method name:
> > >+    def _get_files(self, files):
> > >+        if self._used:
> > >+            self._write_separator()
> > >+        self._used = True
> > >+
> > >+        for filename in files:
> > >+            self.logfile.write('%s:\n' % filename)
> > >+            try:
> > >+                f = open(filename, 'r')
> > >+            except (IOError) as e:
> > >+                self.logfile.write("Exception while opening: %s\n"
> % e)
> > >+                continue
> > >+
> > >+            self.logfile.writelines(f)
> > >+            f.close()
> > are not too fortunate: the methods are not getting anything, have
> > side effects and return None. Just '_write_file()' or similar?
> 
> Also, there is no need to have two methods here. Use one method and
> check to see if you get a list, and if not make it a 1 element list.
> Like this:
> 
> 
> def _get_files(self, files):
>     if not isinstance(files, list):
>         files = [files]
> 
> 
> Brian

Hi, 
thank you for advice. I've changed code. Now I have only one method (_write_files)

Tomas


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]