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

Function parse_file

python3_cron_scripts/common_crawl_graph.py:117–153  ·  view source on GitHub ↗

For each vertices files, iterate over the entries searching for matching zones.

(logger, vertices_file, reversed_zones, dns_manager)

Source from the content-addressed store, hash-verified

115
116
117def parse_file(logger, vertices_file, reversed_zones, dns_manager):
118 """
119 For each vertices files, iterate over the entries searching for matching zones.
120 """
121 vertices = open(vertices_file, "r")
122
123 google_dns = GoogleDNS.GoogleDNS()
124
125 for line in vertices:
126 parts = line.split("\t")
127 if len(parts) > 1:
128 domain = parts[1].rstrip("\n")
129 reversed_zone = check_zones(domain, reversed_zones)
130 if reversed_zone is not None:
131 matched_domain = swap_order(domain)
132 matched_zone = swap_order(reversed_zone)
133
134 results = google_dns.fetch_DNS_records(matched_domain)
135 if results is None:
136 time.sleep(1)
137 # Try again
138 results = google_dns.fetch_DNS_records(matched_domain)
139
140 if results is None:
141 # Not going to work
142 continue
143 else:
144 for result in results:
145 if (
146 result["fqdn"].endswith("." + matched_zone)
147 or result["fqdn"] == matched_zone
148 ):
149 logger.debug("Inserting: " + matched_domain)
150 result["created"] = datetime.now()
151 result["status"] = "confirmed"
152 result["zone"] = matched_zone
153 dns_manager.insert_record(result, "common_crawl")
154
155
156def get_first_and_last_line(fname):

Callers 1

mainFunction · 0.85

Calls 4

fetch_DNS_recordsMethod · 0.95
swap_orderFunction · 0.85
check_zonesFunction · 0.70
insert_recordMethod · 0.45

Tested by

no test coverage detected