def do_adhoc(text, g, trace=False, geo=False): ads = [] if args['--geo']: ads = parse_with_geo(text, g, trace) else: ads = parse(text, trace) for ad in ads: print ad
def do_file_bulk(fn, g, trace=False, geo=False): ads = [] line = codecs.open(fn, encoding="utf-8").read() line = line.encode("ascii", "ignore").strip() if geo: ads = parse_with_geo(line, g, trace) else: ads = parse(line, trace) print "Summary: %03d discovered" % len(ads) for i, ad in zip(range(1, len(ads) + 1), ads): print "%03d:\t%s" % (i, ad)
def checkExpectation(self, sample, expect): source = os.path.join(self.cwd, sample) expectation = os.path.join(self.cwd, expect) expected = open(expectation).readlines() expected = [e.strip() for e in expected] text = codecs.open(source, 'r', encoding='utf8').read() addresses = parser.parse(text) for loc in addresses: print loc self.assertIn(loc, expected) expected.remove(loc) self.assertEqual(expected, [])
def do_file(fn, g, trace=False, geo=False): total, parsed, failed = 0, 0, 0 ads = [] for line in codecs.open(fn, encoding="utf-8"): line = line.encode("ascii", "ignore").strip() if line == "": continue total += 1 if geo: ads = parse_with_geo(line, g, trace) else: ads = parse(line, trace) if ads: parsed += 1 print "ok: [%s]" % line else: failed += 1 print "Summary:\n\t%04d parsed\n\t%04d failed\n\t%04d Total" % (parsed, failed, total)
def do_file(fn, g, trace=False, geo=False): total, parsed, failed = 0, 0, 0 ads = [] for line in codecs.open(fn, encoding='utf-8'): line = line.encode('ascii', 'ignore').strip() if line == '': continue total += 1 if geo: ads = parse_with_geo(line, g, trace) else: ads = parse(line, trace) if ads: parsed += 1 print 'ok: [%s]' % line else: failed += 1 print 'Summary:\n\t%04d parsed\n\t%04d failed\n\t%04d Total' \ % (parsed, failed, total)