-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.py
98 lines (80 loc) · 2.72 KB
/
extension.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from os.path import join, dirname
from os import walk
from importlib import import_module
class ExtensionParam:
def __init__(self, name, description, **kwargs):
self.name = name
self.description = description
if "default" in kwargs:
self.default_value = kwargs["default"]
else:
self.default_value = None
if "values" in kwargs:
self.enum_values = kwargs["values"]
else:
self.enum_values = None
class Extension:
def on_name_query(self):
"""
Returns the full name of the extension. Must be implemented.
Returns:
str:Extension name
"""
pass
def on_description_query(self):
"""
Returns the description of the extension. Must be implemented.
Returns:
str:Extension description
"""
pass
def on_params_query(self):
"""
Returns the list of parameters supported by the extension.
Returns:
list:List of ExtensionParam objects
"""
return []
def on_params_passed(self, params:dict):
"""
Invoked after the extension is loaded.
Parameters:
params: A dictionary consisting of parameters passed as an input
Returns:
None if the parameters are correct. A string with an error message if
one or more parameters have incorrect values.
"""
return None
def before_file_added(self, filename):
"""
Invoked for each file encountered before its entry is created and added
to the index. Allows to filter the files in the index, discarding selected
ones.
Parameters:
filename: Name of the file added to the index
Returns:
True if the file is to be added to the index. False if the file has to be discarded.
"""
return True
def after_file_added(self, entry):
"""
Invoked for each file encountered right after it is added to the index.
Allows to assign a single file to a group or build its metadata information.
"""
pass
def on_index_complete(self, index):
"""
Invoked after all the files are added to the index. Allows to manipulate the index
when its complete shape is already known.
"""
def before_file_ops(self, entry):
"""
Invoked for each file in the index before the rename/move/copy/link operations
are triggered. The metadata is already processed and updated.
"""
pass
def after_file_ops(self, entry):
"""
Invoked for each file in the index after the rename/move/copy/link operations
are triggered.
"""