mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-04 18:46:17 +01:00
simplified class metafile __init__ method
simplified and fixed the __init__ method of the metafile class. input can be string, bytes-like object, list of strings or list of bytes-like objects now. Based on the input now always a list is generated and joined to a string for writing in the fd. (This is ugly but needed for compat reasons)
This commit is contained in:
parent
9a098c4af8
commit
2568f88438
17
osc/core.py
17
osc/core.py
@ -3660,12 +3660,19 @@ class metafile:
|
|||||||
self.url = url
|
self.url = url
|
||||||
self.change_is_required = change_is_required
|
self.change_is_required = change_is_required
|
||||||
(fd, self.filename) = tempfile.mkstemp(prefix = 'osc_metafile.', suffix = file_ext)
|
(fd, self.filename) = tempfile.mkstemp(prefix = 'osc_metafile.', suffix = file_ext)
|
||||||
if not input or isinstance(input[0], str) or isinstance(input, str):
|
|
||||||
f = os.fdopen(fd, 'w')
|
open_mode = 'w'
|
||||||
f.write(''.join(input))
|
input_as_str = None
|
||||||
|
|
||||||
|
if not isinstance(input, list):
|
||||||
|
input = [input]
|
||||||
|
if isinstance(input[0], str):
|
||||||
|
input_as_str = ''.join(input)
|
||||||
else:
|
else:
|
||||||
f = os.fdopen(fd, 'wb')
|
open_mode = 'wb'
|
||||||
f.write(b''.join(input))
|
input_as_str = b''.join(input)
|
||||||
|
f = os.fdopen(fd, open_mode)
|
||||||
|
f.write(input_as_str)
|
||||||
f.close()
|
f.close()
|
||||||
self.hash_orig = dgst(self.filename)
|
self.hash_orig = dgst(self.filename)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user