-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcsDetectorAdapter.py
39 lines (29 loc) · 1.72 KB
/
csDetectorAdapter.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
from csDetector import CsDetector
# this is the adapter class. we can use it to call the adapter from different sources of input
# by inheriting csDetector, we override the method with bad specified interface with a better
# one that will call the superclass method after parsing the given input
# this is the adapter class. we can use it to call the adapter from different sources of input
# by inheriting csDetector, we override the method with bad specified interface with a better
# one that will call the superclass method after parsing the given input
class CsDetectorAdapter(CsDetector):
def __init__(self):
super().__init__()
def executeTool(self, gitRepository, gitPAT, startingDate="null", sentiFolder="./sentiStrenght", outputFolder="./out", endDate="null"):
args = ["-p", gitPAT, "-r", gitRepository, "-s", sentiFolder, "-o", outputFolder]
if startingDate == "null":
# in this branch we execute the tool normally because no date was provided
return super().executeTool(args)
if(startingDate != "null"):
args.extend(['-sd', startingDate])
if(endDate != "null"):
args.extend(['-ed', endDate])
return super().executeTool(args)
if __name__ == "__main__":
tool = CsDetectorAdapter()
formattedResult, result = tool.executeTool(gitRepository="https://github.com/tensorflow/ranking",
gitPAT="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",
startingDate=None,
outputFolder="./output",
sentiFolder="./senti")
print(result)
print(formattedResult)