/breezy-debian/unstable

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy-debian/unstable

« back to all changes in this revision

Viewing changes to upstream/__init__.py

  • Committer: Jelmer Vernooij
  • Date: 2018-10-15 07:45:11 UTC
  • Revision ID: jelmer@jelmer.uk-20181015074511-0kwd639wr7y4w5ot
Use context managers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
518
518
        hosted_file = release_files[0]
519
519
        tmpdir = tempfile.mkdtemp(prefix="builddeb-launchpad-source-")
520
520
        try:
521
 
            inf = hosted_file.open()
522
 
            try:
 
521
            with hosted_file.open() as inf:
523
522
                note("Downloading upstream tarball %s from Launchpad",
524
523
                     inf.filename)
525
524
                filename = inf.filename.encode(osutils._fs_enc)
526
525
                filename = filename.replace("/", "")
527
526
                tmppath = os.path.join(tmpdir, filename)
528
 
                outf = open(tmppath, 'wb')
529
 
                try:
 
527
                with open(tmppath, 'wb') as outf:
530
528
                    outf.write(inf.read())
531
 
                finally:
532
 
                    outf.close()
533
 
            finally:
534
 
                inf.close()
535
529
            dest_name = new_tarball_name(package, version, filename)
536
530
            repack_tarball(tmppath, dest_name, target_dir=target_dir)
537
531
            return os.path.join(target_dir, dest_name)