-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfiletypes.py
49 lines (34 loc) · 1.35 KB
/
filetypes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# pylint: disable=C0103, too-few-public-methods, locally-disabled, no-self-use, unused-argument
"""This module contains listing of file types by extension"""
class _BaseFileType():
_extensions = ()
@classmethod
def extensions(cls):
"""bare extensions tuple
"""
return cls._extensions
@classmethod
def dotted(cls):
"""() -> tuple
Returns dotted tuple of file extensions, e.g. ('.bmp','jpeg',...)
"""
return tuple('.{}'.format(s) for s in cls._extensions)
@classmethod
def asterixed(cls):
"""() -> tuple
Returns dotted tuple of file extensions, e.g. ('*.bmp','*.jpeg',...)
"""
return tuple('*.{}'.format(s) for s in cls._extensions)
class Images(_BaseFileType):
"""Raster file types"""
_extensions = ('bmp', 'jpg', 'jpeg',
'png', 'tif', 'tiff', 'pbm', 'pgm', 'ppm', 'gif')
class Zip(_BaseFileType):
"""pkzip compatible"""
_extensions = ('zip', 'pkzip', 'rar', 'arj', 'lzh') # specific compatibility for any single file cannot be known
class MSWord(_BaseFileType):
_extensions = ('doc', 'docx', 'docm', 'dot', 'dotm', 'dotx', 'odt', 'rtf')
class Text(_BaseFileType):
_extensions = ('txt', 'csv')
class MSExcl(_BaseFileType):
_extensions = ('xls', 'xlsm', 'csv', 'xlsb', 'xlsx', 'xlt', 'xltm', 'xltx', 'xlw')