mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-30 01:37:17 +00:00
chg: [import_dir] fix is_gzip test, use magic number
This commit is contained in:
parent
998f8cc8e1
commit
873797d87f
1 changed files with 4 additions and 2 deletions
|
@ -7,9 +7,9 @@ from io import StringIO
|
|||
import datetime
|
||||
import gzip
|
||||
import argparse
|
||||
import binascii
|
||||
import os
|
||||
import time, datetime
|
||||
import magic
|
||||
import re
|
||||
|
||||
'''
|
||||
|
@ -37,6 +37,8 @@ import re
|
|||
'
|
||||
'''
|
||||
|
||||
def is_gzip_file(magic_nuber):
|
||||
return binascii.hexlify(magic_nuber) == b'1f8b'
|
||||
|
||||
def is_hierachy_valid(path):
|
||||
var = path.split('/')
|
||||
|
@ -82,7 +84,7 @@ if __name__ == "__main__":
|
|||
messagedata = f.read()
|
||||
|
||||
#verify that the data is gzipEncoded. if not compress it
|
||||
if 'text/plain' in str(magic.from_buffer(messagedata, mime=True)):
|
||||
if not is_gzip_file(messagedata[0:2]):
|
||||
messagedata = gzip.compress(messagedata)
|
||||
complete_path += '.gz'
|
||||
|
||||
|
|
Loading…
Reference in a new issue