def get_csv_entries():
if TEST:
action = open(LOCAL_CSV)
else:
action = closing(urlopen(REMOTE_CSV, context=CONTEXT))
with action as f:
if not TEST and sys.version_info.major > 2:
f = codecs.iterdecode(f, 'utf-8') # needed for urlopen and py3
for entry in csv.DictReader(f, fieldnames=FIELDS):
yield entry
评论列表
文章目录