def __init__(self, name=None, mode="<STR_LIT:r>", fileobj=None, format=None,<EOL>tarinfo=None, dereference=None, ignore_zeros=None, encoding=None,<EOL>errors="<STR_LIT>", pax_headers=None, debug=None, errorlevel=None):
if len(mode) > <NUM_LIT:1> or mode not in "<STR_LIT>":<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>self.mode = mode<EOL>self._mode = {"<STR_LIT:r>": "<STR_LIT:rb>", "<STR_LIT:a>": "<STR_LIT>", "<STR_LIT:w>": "<STR_LIT:wb>"}[mode]<EOL>if not fileobj:<EOL><INDENT>if self.mode == "<STR_LIT:a>" and not os.path.exists(name):<EOL><INDENT>self.mode = "<STR_LIT:w>"<EOL>self._mode = "<STR_LIT:wb>"<EOL><DEDENT>fileobj = bltn_open(name, self._mode)<EOL>self._extfileobj = False<EOL><DEDENT>else:<EOL><INDENT>if name is None and hasattr(fileobj, "<STR_LIT:name>"):<EOL><INDENT>name = fileobj.name<EOL><DEDENT>if hasattr(fileobj, "<STR_LIT>"):<EOL><INDENT>self._mode = fileobj.mode<EOL><DEDENT>self._extfileobj = True<EOL><DEDENT>self.name = os.path.abspath(name) if name else None<EOL>self.fileobj = fileobj<EOL>if format is not None:<EOL><INDENT>self.format = format<EOL><DEDENT>if tarinfo is not None:<EOL><INDENT>self.tarinfo = tarinfo<EOL><DEDENT>if dereference is not None:<EOL><INDENT>self.dereference = dereference<EOL><DEDENT>if ignore_zeros is not None:<EOL><INDENT>self.ignore_zeros = ignore_zeros<EOL><DEDENT>if encoding is not None:<EOL><INDENT>self.encoding = encoding<EOL><DEDENT>self.errors = errors<EOL>if pax_headers is not None and self.format == PAX_FORMAT:<EOL><INDENT>self.pax_headers = pax_headers<EOL><DEDENT>else:<EOL><INDENT>self.pax_headers = {}<EOL><DEDENT>if debug is not None:<EOL><INDENT>self.debug = debug<EOL><DEDENT>if errorlevel is not None:<EOL><INDENT>self.errorlevel = errorlevel<EOL><DEDENT>self.closed = False<EOL>self.members = []       <EOL>self._loaded = False    <EOL>self.offset = self.fileobj.tell()<EOL>self.inodes = {}        <EOL>try:<EOL><INDENT>if self.mode == "<STR_LIT:r>":<EOL><INDENT>self.firstmember = None<EOL>self.firstmember = self.next()<EOL><DEDENT>if self.mode == "<STR_LIT:a>":<EOL><INDENT>while True:<EOL><INDENT>self.fileobj.seek(self.offset)<EOL>try:<EOL><INDENT>tarinfo = self.tarinfo.fromtarfile(self)<EOL>self.members.append(tarinfo)<EOL><DEDENT>except EOFHeaderError:<EOL><INDENT>self.fileobj.seek(self.offset)<EOL>break<EOL><DEDENT>except HeaderError as e:<EOL><INDENT>raise ReadError(str(e))<EOL><DEDENT><DEDENT><DEDENT>if self.mode in "<STR_LIT>":<EOL><INDENT>self._loaded = True<EOL>if self.pax_headers:<EOL><INDENT>buf = self.tarinfo.create_pax_global_header(self.pax_headers.copy())<EOL>self.fileobj.write(buf)<EOL>self.offset += len(buf)<EOL><DEDENT><DEDENT><DEDENT>except:<EOL><INDENT>if not self._extfileobj:<EOL><INDENT>self.fileobj.close()<EOL><DEDENT>self.closed = True<EOL>raise<EOL><DEDENT>
Open an (uncompressed) tar archive `name'. `mode' is either 'r' to
           read from an existing archive, 'a' to append data to an existing
           file or 'w' to create a new file overwriting an existing one. `mode'
           defaults to 'r'.
           If `fileobj' is given, it is used for reading or writing data. If it
           can be determined, `mode' is overridden by `fileobj's mode.
           `fileobj' is not closed, when TarFile is closed.