Skip to content

Commit

Permalink
URLize URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
andylolz committed May 1, 2024
1 parent 3c0ed61 commit 1c4890b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions script.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
from io import StringIO
import csv
from datetime import datetime, date, timedelta
from io import StringIO
import re
import requests


url_re = re.compile(r"(https?://[^\s]+)")


def to_isoformat(ms_since_epoch):
return str(datetime.utcfromtimestamp(int(ms_since_epoch[:-3])))


def urlize(inp):
return url_re.sub(r'<a target="_blank" href="\1">\1</a>', inp)


reasons = {
"misleadingOther": "Other",
"misleadingFactualError": "Factual error",
Expand Down Expand Up @@ -69,7 +77,7 @@ def get_generator():
"note_author_id": row["noteAuthorParticipantId"],
"classification": row["classification"].replace("_", " ").lower().capitalize(),
"reasons": get_reasons(row),
"summary": row["summary"],
"summary": urlize(row["summary"]),
"trustworthy_source": bool(row["trustworthySources"]),
"created_at": to_isoformat(row["createdAtMillis"]),
}
Expand Down

0 comments on commit 1c4890b

Please sign in to comment.