1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-29 02:55:52 +00:00
bazarr/libs/subzero/lib/rar.py
Louis Vézina 3ca2c98cd4 WIP
2019-09-16 22:04:27 -04:00

26 lines
679 B
Python

# coding=utf-8
from __future__ import absolute_import
import logging
import rarfile
log = logging.getLogger(__name__)
class RarFile(rarfile.RarFile):
def read(self, fname, psw=None):
"""
read specific content of rarfile without parsing
:param fname:
:param psw:
:return:
"""
cmd = [rarfile.UNRAR_TOOL] + list(rarfile.ORIG_OPEN_ARGS)
with rarfile.XTempFile(self._rarfile) as rf:
log.debug(u"RAR CMD: %s", cmd + [rf, fname])
p = rarfile.custom_popen(cmd + [rf, fname])
output = p.communicate()[0]
rarfile.check_returncode(p, output)
return output