Skip to content

Commit b832947

Browse files
fix CSV writing for bulk lookups
1 parent 1bcd116 commit b832947

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ __pycache__/
88
*.egg-info/
99
*.egg
1010
*.pyc
11-
.hypothesis/
11+
.hypothesis/
12+
.vscode/

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = ipdata
3-
version = 4.0.5
3+
version = 4.0.6
44
author = Jonathan Kosgei
55
author_email = jonathan@ipdata.co
66
description = This is the official IPData client library for Python

src/ipdata/cli.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def batch(ctx, input, fields, output, format, exclude):
403403
resources = [resource.strip() for resource in input.readlines()]
404404
bulk_results = process(resources, ipdata.bulk, fields)
405405

406-
# Prepare CSV writing by expanding fieldnames eg. asn to asn, name, domain etc
406+
# Prepare CSV writing by expanding fieldnames eg. asn to [asn, name, domain] etc
407407
csv_writer = None
408408
fieldnames = []
409409
for field in fields:
@@ -413,15 +413,15 @@ def batch(ctx, input, fields, output, format, exclude):
413413
for sub_field in ["asn", "name", "domain", "route", "type"]
414414
]
415415
continue
416-
if field == "company":
416+
elif field == "company":
417417
fieldnames += [
418418
f"company_{sub_field}"
419-
for sub_field in ["asn", "name", "domain", "network", "type"]
419+
for sub_field in ["name", "domain", "network", "type"]
420420
]
421421
continue
422-
if field == "threat":
422+
elif field == "threat":
423423
fieldnames += [
424-
f"asn_{sub_field}"
424+
f"threat_{sub_field}"
425425
for sub_field in [
426426
"is_tor",
427427
"is_icloud_relay",
@@ -436,7 +436,7 @@ def batch(ctx, input, fields, output, format, exclude):
436436
]
437437
]
438438
continue
439-
if field in ipdata.valid_fields:
439+
elif field in ipdata.valid_fields:
440440
fieldnames += [field]
441441

442442
# Do lookups concurrenctly using threads in batches of 100 each

0 commit comments

Comments
 (0)