mirror of https://github.com/CIRCL/PyCIRCLean
Refactored mimetype code into its own method
parent
62e62412cf
commit
146f258e54
|
@ -2,12 +2,13 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import magic
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import shutil
|
import shutil
|
||||||
from twiggy import quick_setup, log
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
import magic
|
||||||
|
from twiggy import quick_setup, log
|
||||||
|
|
||||||
|
|
||||||
class KittenGroomerError(Exception):
|
class KittenGroomerError(Exception):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
|
@ -37,7 +38,9 @@ class FileBase(object):
|
||||||
self.log_details = {'filepath': self.src_path}
|
self.log_details = {'filepath': self.src_path}
|
||||||
self.log_string = ''
|
self.log_string = ''
|
||||||
a, self.extension = os.path.splitext(self.src_path)
|
a, self.extension = os.path.splitext(self.src_path)
|
||||||
|
self._get_mimetype()
|
||||||
|
|
||||||
|
def _get_mimetype(self):
|
||||||
if os.path.islink(self.src_path):
|
if os.path.islink(self.src_path):
|
||||||
# magic will throw an IOError on a broken symlink
|
# magic will throw an IOError on a broken symlink
|
||||||
self.mimetype = 'inode/symlink'
|
self.mimetype = 'inode/symlink'
|
||||||
|
|
Loading…
Reference in New Issue