Skip to content

Commit

Permalink
Upgrade from python 2 to 3.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Mar 14, 2023
1 parent 7bcfc3b commit 1ccc60d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 75 deletions.
2 changes: 1 addition & 1 deletion commonlib
Submodule commonlib updated from 599c81 to 57a3dc
14 changes: 7 additions & 7 deletions scripts/future-fetch.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/python
#!/usr/bin/env python3
# encoding: utf-8

import json
import os
import sys
import re
import urllib2
import urllib.request
import MySQLdb

import datetime
Expand All @@ -32,7 +32,7 @@

def fetch_url(date):
data = CALENDAR_BASE % {'date': date}
data = urllib2.urlopen(data)
data = urllib.request.urlopen(data)
data = json.load(data)
return data

Expand Down Expand Up @@ -115,9 +115,9 @@ def __init__(self, event):
if not match:
match = lordsList.match_by_mnis(id, self.event_date)
if match:
self.people.append(
int(match['id'].replace('uk.org.publicwhip/person/', ''))
)
self.people.append(
int(match['id'].replace('uk.org.publicwhip/person/', ''))
)

self.witnesses = []
witnesses_str = []
Expand Down Expand Up @@ -272,7 +272,7 @@ def update(self):
if old_tuple != new_tuple:
new_entry.update()

old_entries.discard((long(id),))
old_entries.discard((int(id),))
else:
new_entry.add()

Expand Down
2 changes: 1 addition & 1 deletion scripts/morningupdate
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ system "./xml2db.pl $cronquiet --recent --scotwrans --quiet";
system "./xml2db.pl $cronquiet --recent --scotqs --quiet";
system "./xml2db.pl $cronquiet --recent --standing --quiet";
system "./xml2db.pl $cronquiet --recent --lmqs --quiet";
system "python ./future-fetch.py";
system "python3 ./future-fetch.py";

$cronquiet = substr($cronquiet, 2) if $cronquiet;

Expand Down
10 changes: 5 additions & 5 deletions scripts/photo-attribution-import.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# encoding: utf-8

import json
Expand Down Expand Up @@ -31,13 +31,13 @@
)
db_cursor = db_connection.cursor()

data_blank = filter(lambda r: not r["data_value"], data)
data_blank = map(lambda r: (r["person_id"], r["data_key"]), data_blank)
data_blank = [r for r in data if not r["data_value"]]
data_blank = [(r["person_id"], r["data_key"]) for r in data_blank]
db_cursor.executemany("""DELETE FROM personinfo
WHERE person_id=%s AND data_key=%s""", data_blank)

data = filter(lambda r: r["data_value"], data)
data = map(lambda r: (r["person_id"], r["data_key"], r["data_value"]), data)
data = [r for r in data if r["data_value"]]
data = [(r["person_id"], r["data_key"], r["data_value"]) for r in data]
db_cursor.executemany("""INSERT INTO personinfo
(person_id, data_key, data_value) VALUES (%s, %s, %s)
ON DUPLICATE KEY UPDATE data_value = VALUES(data_value)""", data)
Expand Down
61 changes: 0 additions & 61 deletions scripts/wikipedia-backlinks.py

This file was deleted.

0 comments on commit 1ccc60d

Please sign in to comment.