MCPcopy Create free account
hub / github.com/adobe/Marinus / main

Function main

python3_cron_scripts/create_tpd_graphs.py:171–327  ·  view source on GitHub ↗

The main thread for this program.

(logger=None)

Source from the content-addressed store, hash-verified

169
170
171def main(logger=None):
172 """
173 The main thread for this program.
174 """
175 if logger is None:
176 logger = LoggingUtil.create_log(__name__)
177
178 now = datetime.now()
179 print("Starting: " + str(now))
180 logger.info("Starting...")
181
182 mongo_connector = MongoConnector.MongoConnector()
183 jobs_manager = JobsManager.JobsManager(mongo_connector, "create_tpd_graphs")
184 jobs_manager.record_job_start()
185
186 zones = ZoneManager.get_distinct_zones(mongo_connector)
187
188 tpds = get_tpds(mongo_connector)
189
190 # For third-party-domain in the list of third-party-domains
191 for tpd in tpds:
192 groups = []
193 graph = nx.DiGraph()
194 add_to_list(tpd, groups)
195
196 # A space is added because sometimes the tpd is the same as the end target node
197 graph.add_node(
198 tpd + " ",
199 data_type="tld",
200 type=0,
201 depends=[],
202 dependedOnBy=[],
203 docs="<h1>Parent</h1>",
204 )
205
206 # Get the zones associated with the tpd
207 find_zones_by_tld(graph, tpd, groups, mongo_connector)
208
209 data = json_graph.node_link_data(graph)
210
211 reformat_data(data, tpd, groups)
212
213 new_data = {}
214 new_data["directed"] = data["directed"]
215 new_data["graph"] = data["graph"]
216 new_data["multigraph"] = data["multigraph"]
217 new_data["errs"] = []
218 new_data["links"] = data["links"]
219 new_data["data"] = {}
220
221 for i in range(0, len(data["nodes"])):
222 new_data["data"][data["nodes"][i]["id"].replace(".", REPLACE_CHAR)] = data[
223 "nodes"
224 ][i]
225
226 for entry in new_data["data"]:
227 for dep in new_data["data"][entry]["depends"]:
228 if (

Callers 1

Calls 11

record_job_startMethod · 0.95
record_job_completeMethod · 0.95
get_tpdsFunction · 0.85
find_zones_by_tldFunction · 0.85
create_logMethod · 0.80
get_distinct_zonesMethod · 0.80
perform_insertMethod · 0.80
add_to_listFunction · 0.70
reformat_dataFunction · 0.70
build_docsFunction · 0.70

Tested by

no test coverage detected