Commit 3ca08cf5 authored by Mattia Bondanza's avatar Mattia Bondanza

Solved a problem with different version of magic module

parent 8c22da53
......@@ -5,7 +5,7 @@ from fnmatch import fnmatch
from pyPdf import PdfFileReader
from searchISBN import *
root = '/home/mattia/Nextcloud/Università/Libreria/'
root = '/home/mattia/ownCloud/Università/Libreria/'
pattern = "*"
type_stat = {}
......@@ -20,7 +20,13 @@ for path, subdirs, files in os.walk(root):
#print os.path.join(path, name)
total_files += 1
#file type analysis
ftype = magic.from_file( os.path.join(path, name), mime=True)
try:
ftype = magic.from_file( os.path.join(path, name), mime=True)
except:
f = open( os.path.join(path, name), "r")
ftype = magic.detect_from_fobj( f ).mime_type
f.close()
#print "File type: ", ftype
if ftype in type_stat:
type_stat[ftype] += 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment