Use argument for mime type if available

This commit is contained in:
Lynn Ochs 2019-05-10 23:44:04 +02:00
parent ad306ad0e9
commit 757eb3c650
Signed by: apo
GPG Key ID: 588AD47B1D06BE99

View File

@ -10,7 +10,10 @@ s = socket.socket(socket.AF_UNIX)
s.connect(os.path.join(os.environ["HOME"], ".mailcap.sock"))
filename = sys.argv[1]
mime = subprocess.run(["file", "-i", "-b", filename], check=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
if len(sys.argv) > 2:
mime = sys.argv[2]
else:
mime = subprocess.run(["file", "-i", "-b", filename], check=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
data = open(filename, "rb").read()
def strtr(x, c="B"):