You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ambar2/Pipeline/parsers/contenttypeanalyzer.py

27 lines
800 B
Python

import re
class ContentTypeAnalyzer:
@classmethod
def IsImageByContentType(cls, ContentType):
regex = re.compile(r'^image\/',re.I)
return regex.match(ContentType)
@classmethod
def IsPdfByContentType(cls, ContentType):
return True if ContentType == 'application/pdf' else False
@classmethod
def IsArchive(cls, FileName):
regex = re.compile('(\\.zip$)', re.I)
return True if regex.search(FileName) else False
@classmethod
def IsPst(cls, FileName):
regex = re.compile('(\\.pst$)', re.I)
return True if regex.search(FileName) else False
@classmethod
def IsPdf(cls, FileName):
regex = re.compile('(\\.pdf$)', re.I)
return True if regex.search(FileName) else False