[elbe-devel] [PATCH 08/25] py3: use open instead of file

Manuel Traut manuel.traut at linutronix.de
Fri Dec 8 16:23:11 CET 2017


On Wed, Dec 06, 2017 at 11:12:49AM +0100, Torben Hohn wrote:
> On Fri, Dec 01, 2017 at 04:51:05PM +0100, Manuel Traut wrote:
> > When opening a file, it's preferable to use open() instead of invoking
> > the file constructor directly. file is more suited to type testing
> > (for example, writing "isinstance(f, file)").
> 
> thats blabla. file () is gone in py3 
> > 
> > Also, file() has been removed since Python 3.0
> > 
> > Signed-off-by: Manuel Traut <manut at linutronix.de>
> 
> Reviewed-by: Torben Hohn <torbenh at linutronix.de>

thanks for the review, applied to devel/elbe-3.0

> 
> > ---
> >  elbepack/daemons/soap/esoap.py | 2 +-
> >  elbepack/soapclient.py         | 4 ++--
> >  elbepack/templates.py          | 2 +-
> >  3 files changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/elbepack/daemons/soap/esoap.py b/elbepack/daemons/soap/esoap.py
> > index a866aee5..8189a94f 100644
> > --- a/elbepack/daemons/soap/esoap.py
> > +++ b/elbepack/daemons/soap/esoap.py
> > @@ -119,7 +119,7 @@ class ESoap (ServiceBase):
> >          if (pos >= file_stat.st_size):
> >              return "EndOfFile"
> >  
> > -        with file (file_name) as fp:
> > +        with open (file_name) as fp:
> >              if not fp:
> >                  return "FileNotFound"
> >              try:
> > diff --git a/elbepack/soapclient.py b/elbepack/soapclient.py
> > index 1384acc1..ede9164e 100644
> > --- a/elbepack/soapclient.py
> > +++ b/elbepack/soapclient.py
> > @@ -255,7 +255,7 @@ class SetXmlAction(ClientAction):
> >  
> >          size = 1024 * 1024
> >          part = 0
> > -        with file (filename, "rb") as fp:
> > +        with open (filename, "rb") as fp:
> >              while (True):
> >                  xml_base64 = binascii.b2a_base64(fp.read (size))
> >                  # finish upload
> > @@ -684,7 +684,7 @@ class UploadPackageAction(RepoAction):
> >          # Uploads file f into builddir in intivm
> >          size = 1024 * 1024
> >          part = 0
> > -        with file (f, "rb") as fp:
> > +        with open (f, "rb") as fp:
> >              while (True):
> >                  xml_base64 = binascii.b2a_base64(fp.read (size))
> >                  # finish upload
> > diff --git a/elbepack/templates.py b/elbepack/templates.py
> > index 9808ad1c..634b7ccd 100644
> > --- a/elbepack/templates.py
> > +++ b/elbepack/templates.py
> > @@ -38,7 +38,7 @@ def template(fname, d, linebreak=False):
> >          raise
> >  
> >  def write_template( outname, fname, d, linebreak=False ):
> > -    outfile = file(outname, "w")
> > +    outfile = open(outname, "w")
> >      outfile.write( template( fname, d, linebreak ) )
> >      outfile.close()
> >  
> > -- 
> > 2.15.1
> > 
> > 
> > _______________________________________________
> > elbe-devel mailing list
> > elbe-devel at linutronix.de
> > https://lists.linutronix.de/mailman/listinfo/elbe-devel
> 
> -- 
> Mit freundlichen Grüßen
> Torben Hohn
> 
> Linutronix GmbH
> 
> Standort: Bremen
> 
> Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99
> 
> Firmensitz / Registered Office: D-88690 Uhldingen, Bahnhofstr. 3
> Registergericht / Local District Court: Amtsgericht Freiburg i. Br.; HRB
> Nr. / Trade register no.: 700 806
> 
> Geschäftsführer / Managing Directors: Heinz Egger, Thomas Gleixner
> 
> Eine Bitte von uns: Sollten Sie diese E-Mail irrtümlich erhalten haben,
> benachrichtigen Sie uns in diesem Falle bitte sobald wie es Ihnen
> möglich ist, durch Antwort-Mail. Vielen Dank!





More information about the elbe-devel mailing list