MCPcopy Index your code
hub / github.com/Persper/code-analytics / GoGraphServer

Class GoGraphServer

persper/analytics/go.py:9–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7
8
9class GoGraphServer(GraphServer):
10 def __init__(self, server_addr, filename_regex_strs):
11 self.server_addr = server_addr
12 self.filename_regexes = [re.compile(regex_str) for regex_str in filename_regex_strs]
13 self.config_param = dict()
14
15 def register_commit(self, hexsha, author_name, author_email, commit_message):
16 # TODO: use 'message' or 'commit_message', but not both
17 payload = {'hexsha': hexsha,
18 'author_name': author_name,
19 'author_email': author_email,
20 'message': commit_message}
21 register_url = urllib.parse.urljoin(self.server_addr, '/register_commit')
22 r = requests.post(register_url, json=payload).json()
23 if r != '0':
24 raise ValueError()
25
26 def update_graph(self, old_filename, old_src,
27 new_filename, new_src, patch):
28 payload = {'oldFname': old_filename,
29 'oldSrc': old_src,
30 'newFname': new_filename,
31 'newSrc': new_src,
32 'patch': patch.decode('utf-8', 'replace'),
33 'config': self.config_param}
34
35 update_url = urllib.parse.urljoin(self.server_addr, '/update')
36 r = requests.post(update_url, json=payload).json()
37 if r != '0':
38 raise ValueError()
39
40 def get_graph(self):
41 graph_url = self.server_addr + '/callgraph'
42 r = requests.get(graph_url)
43 graph_data = r.json()
44 graph_data['directed'] = True
45 graph_data['multigraph'] = False
46 return CallCommitGraph(graph_data)
47
48 def reset_graph(self):
49 reset_url = urllib.parse.urljoin(self.server_addr, '/reset')
50 requests.post(reset_url)
51
52 def filter_file(self, filename):
53 for regex in self.filename_regexes:
54 if not regex.match(filename):
55 return False
56 return True
57
58 def config(self, param):
59 self.config_param = param

Callers 3

azFunction · 0.90
azFunction · 0.90
azFunction · 0.90

Calls

no outgoing calls

Tested by 3

azFunction · 0.72
azFunction · 0.72
azFunction · 0.72