mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-23 18:52:10 +01:00
Fix pylint error: Using variable 'fd' before assignment
This commit is contained in:
parent
b1e2a00b82
commit
7f885ac6b2
10
osc/core.py
10
osc/core.py
@ -2134,7 +2134,6 @@ class Package:
|
|||||||
def diff_add_delete(fname, add, revision):
|
def diff_add_delete(fname, add, revision):
|
||||||
diff = []
|
diff = []
|
||||||
diff.append(diff_hdr % fname.encode())
|
diff.append(diff_hdr % fname.encode())
|
||||||
tmpfile = None
|
|
||||||
origname = fname
|
origname = fname
|
||||||
if add:
|
if add:
|
||||||
diff.append(b'--- %s\t(revision 0)\n' % fname.encode())
|
diff.append(b'--- %s\t(revision 0)\n' % fname.encode())
|
||||||
@ -2155,6 +2154,8 @@ class Package:
|
|||||||
diff.append(b'+++ %s\t(working copy)\n' % fname.encode())
|
diff.append(b'+++ %s\t(working copy)\n' % fname.encode())
|
||||||
fname = os.path.join(self.storedir, fname)
|
fname = os.path.join(self.storedir, fname)
|
||||||
|
|
||||||
|
fd = None
|
||||||
|
tmpfile = None
|
||||||
try:
|
try:
|
||||||
if revision is not None and not add:
|
if revision is not None and not add:
|
||||||
(fd, tmpfile) = tempfile.mkstemp(prefix='osc_diff')
|
(fd, tmpfile) = tempfile.mkstemp(prefix='osc_diff')
|
||||||
@ -2180,8 +2181,9 @@ class Package:
|
|||||||
lines.append(b'\n\\ No newline at end of file\n')
|
lines.append(b'\n\\ No newline at end of file\n')
|
||||||
diff.extend(lines)
|
diff.extend(lines)
|
||||||
finally:
|
finally:
|
||||||
if tmpfile is not None:
|
if fd is not None:
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
|
if tmpfile is not None and os.path.exists(tmpfile):
|
||||||
os.unlink(tmpfile)
|
os.unlink(tmpfile)
|
||||||
return diff
|
return diff
|
||||||
|
|
||||||
@ -2226,6 +2228,7 @@ class Package:
|
|||||||
if revision is None:
|
if revision is None:
|
||||||
yield get_source_file_diff(self.absdir, f.name, self.rev)
|
yield get_source_file_diff(self.absdir, f.name, self.rev)
|
||||||
else:
|
else:
|
||||||
|
fd = None
|
||||||
tmpfile = None
|
tmpfile = None
|
||||||
diff = []
|
diff = []
|
||||||
try:
|
try:
|
||||||
@ -2234,8 +2237,9 @@ class Package:
|
|||||||
diff = get_source_file_diff(self.absdir, f.name, revision,
|
diff = get_source_file_diff(self.absdir, f.name, revision,
|
||||||
os.path.basename(tmpfile), os.path.dirname(tmpfile), f.name)
|
os.path.basename(tmpfile), os.path.dirname(tmpfile), f.name)
|
||||||
finally:
|
finally:
|
||||||
if tmpfile is not None:
|
if fd is not None:
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
|
if tmpfile is not None and os.path.exists(tmpfile):
|
||||||
os.unlink(tmpfile)
|
os.unlink(tmpfile)
|
||||||
yield diff
|
yield diff
|
||||||
|
|
||||||
|
@ -86,6 +86,8 @@ class Fetcher:
|
|||||||
pac = pkgs[decode_it(hdr.filename)]
|
pac = pkgs[decode_it(hdr.filename)]
|
||||||
|
|
||||||
# Extract a single file from the cpio archive
|
# Extract a single file from the cpio archive
|
||||||
|
fd = None
|
||||||
|
tmpfile = None
|
||||||
try:
|
try:
|
||||||
fd, tmpfile = tempfile.mkstemp(prefix='osc_build_file')
|
fd, tmpfile = tempfile.mkstemp(prefix='osc_build_file')
|
||||||
archive.copyin_file(hdr.filename,
|
archive.copyin_file(hdr.filename,
|
||||||
@ -93,8 +95,9 @@ class Fetcher:
|
|||||||
decode_it(os.path.basename(tmpfile)))
|
decode_it(os.path.basename(tmpfile)))
|
||||||
self.move_package(tmpfile, pac.localdir, pac)
|
self.move_package(tmpfile, pac.localdir, pac)
|
||||||
finally:
|
finally:
|
||||||
|
if fd is not None:
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
if os.path.exists(tmpfile):
|
if tmpfile is not None and os.path.exists(tmpfile):
|
||||||
os.unlink(tmpfile)
|
os.unlink(tmpfile)
|
||||||
|
|
||||||
for pac in pkgs.values():
|
for pac in pkgs.values():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user