mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-26 12:12:11 +01:00
- added __str__() method to the ArFile class
- when rereading a file setup the 'datastructs' again
This commit is contained in:
parent
296f274f67
commit
5d27d74ee4
@ -75,6 +75,10 @@ class ArFile(StringIO.StringIO):
|
|||||||
gid = -1
|
gid = -1
|
||||||
os.chown(fn, uid, gid)
|
os.chown(fn, uid, gid)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return '%s %s %s %s' % (self.name, self.uid,
|
||||||
|
self.gid, self.mode)
|
||||||
|
|
||||||
class Ar():
|
class Ar():
|
||||||
"""
|
"""
|
||||||
Represents an ar archive (only GNU format is supported).
|
Represents an ar archive (only GNU format is supported).
|
||||||
@ -85,15 +89,18 @@ class Ar():
|
|||||||
|
|
||||||
def __init__(self, fn):
|
def __init__(self, fn):
|
||||||
self.filename = fn
|
self.filename = fn
|
||||||
self.hdrs = []
|
|
||||||
self.ext_fnhdr = None
|
|
||||||
# file object: will be closed in __del__()
|
# file object: will be closed in __del__()
|
||||||
self.__file = None
|
self.__file = None
|
||||||
|
self._init_datastructs()
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
if self.__file:
|
if self.__file:
|
||||||
self.__file.close()
|
self.__file.close()
|
||||||
|
|
||||||
|
def _init_datastructs(self):
|
||||||
|
self.hdrs = []
|
||||||
|
self.ext_fnhdr = None
|
||||||
|
|
||||||
def _appendHdr(self, hdr):
|
def _appendHdr(self, hdr):
|
||||||
# GNU uses an internal '//' file to store very long filenames
|
# GNU uses an internal '//' file to store very long filenames
|
||||||
if hdr.file.startswith('//'):
|
if hdr.file.startswith('//'):
|
||||||
@ -148,6 +155,7 @@ class Ar():
|
|||||||
raise e
|
raise e
|
||||||
else:
|
else:
|
||||||
self.__file.seek(0, os.SEEK_SET)
|
self.__file.seek(0, os.SEEK_SET)
|
||||||
|
self._init_datastructs()
|
||||||
data = self.__file.read(7)
|
data = self.__file.read(7)
|
||||||
if data != '!<arch>':
|
if data != '!<arch>':
|
||||||
raise ArError(self.filename, 'no ar archive')
|
raise ArError(self.filename, 'no ar archive')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user