Skip to content

Commit 717c54c

Browse files
authored
Merge pull request #6350 from fchapoton/minor_old_py2
remove traces of python2 ; other ruff UP fixes
2 parents 23cdcff + b97293a commit 717c54c

File tree

4 files changed

+20
-27
lines changed

4 files changed

+20
-27
lines changed

lmfdb/artin_representations/math_classes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ def GaloisLabel(self):
424424
return self._data['GaloisLabel']
425425

426426
def group(self):
427-
n, t = [int(z) for z in self._data['GaloisLabel'].split("T")]
427+
n, t = (int(z) for z in self._data['GaloisLabel'].split("T"))
428428
return group_display_short(n, t)
429429

430430
def pretty_galois_knowl(self):

lmfdb/knowledge/knowl.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# the basic knowledge object, with database awareness, …
22

3-
from datetime import datetime, timedelta
43
from collections import defaultdict
5-
import time
4+
from datetime import datetime, timedelta
5+
import re
66
import subprocess
7-
import sys
7+
import time
88

99
from psycodict.base import PostgresBase
1010
from psycodict import DelayCommit
@@ -17,7 +17,7 @@
1717
from psycopg2.sql import SQL, Identifier, Placeholder
1818
from sage.all import cached_function
1919

20-
import re
20+
2121
text_keywords = re.compile(r"\b[a-zA-Z0-9-]{3,}\b")
2222
top_knowl_re = re.compile(r"(.*)\.top$")
2323
comment_knowl_re = re.compile(r"(.*)\.(\d+)\.comment$")
@@ -582,11 +582,8 @@ def code_references(self, knowl):
582582
matches = []
583583
for kid in kids:
584584
try:
585-
if sys.version_info[0] == 3:
586-
matches.extend(subprocess.check_output(['git', 'grep', '--full-name', '--line-number', '--context', '2', """['"]%s['"]""" % (kid.replace('.',r'\.'))],encoding='utf-8').split('\n--\n'))
587-
else:
588-
matches.extend(subprocess.check_output(['git', 'grep', '--full-name', '--line-number', '--context', '2', """['"]%s['"]""" % (kid.replace('.',r'\.'))]).split('\n--\n'))
589-
except subprocess.CalledProcessError: # no matches
585+
matches.extend(subprocess.check_output(['git', 'grep', '--full-name', '--line-number', '--context', '2', """['"]%s['"]""" % (kid.replace('.',r'\.'))],encoding='utf-8').split('\n--\n'))
586+
except subprocess.CalledProcessError: # no matches
590587
pass
591588
return [self._process_git_grep(match) for match in matches]
592589

@@ -600,11 +597,8 @@ def check_sed_safety(self, knowlid):
600597
- -1 if the knowl is referenced but cannot be safely replaced.
601598
"""
602599
try:
603-
if sys.version_info[0] == 3:
604-
matches = subprocess.check_output(['git', 'grep', """['"]%s['"]""" % (knowlid.replace('.',r'\.'))],encoding='utf-8').split('\n')
605-
else:
606-
matches = subprocess.check_output(['git', 'grep', """['"]%s['"]""" % (knowlid.replace('.',r'\.'))]).split('\n')
607-
except subprocess.CalledProcessError: # no matches
600+
matches = subprocess.check_output(['git', 'grep', """['"]%s['"]""" % (knowlid.replace('.',r'\.'))],encoding='utf-8').split('\n')
601+
except subprocess.CalledProcessError: # no matches
608602
return 0
609603

610604
easy_matches = subprocess.check_output(['git', 'grep', knowlid.replace('.',r'\.')],encoding='utf-8').split('\n')
@@ -705,10 +699,7 @@ def broken_links_code(self):
705699
ids that show up in an expression of the form ``KNOWL('BAD_ID')``.
706700
"""
707701
all_kids = {k['id'] for k in self.get_all_knowls(['id'])}
708-
if sys.version_info[0] == 3:
709-
matches = subprocess.check_output(['git', 'grep', '-E', '--full-name', '--line-number', '--context', '2', link_finder_re.pattern],encoding='utf-8').split('\n--\n')
710-
else:
711-
matches = subprocess.check_output(['git', 'grep', '-E', '--full-name', '--line-number', '--context', '2', link_finder_re.pattern]).split('\n--\n')
702+
matches = subprocess.check_output(['git', 'grep', '-E', '--full-name', '--line-number', '--context', '2', link_finder_re.pattern],encoding='utf-8').split('\n--\n')
712703
results = []
713704
for match in matches:
714705
lines = match.split('\n')

lmfdb/nfutils/psort.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def prime_label(P):
170170
def prime_from_label(K, lab):
171171
"""Return the prime of K from a label, or 0 is there is no such prime
172172
"""
173-
n, j = [ZZ(c) for c in lab.split(".")]
173+
n, j = (ZZ(c) for c in lab.split("."))
174174
p, f = n.factor()[0]
175175
make_keys(K,p)
176176
d = K.psort_dict[p]
@@ -316,15 +316,17 @@ def ppower_norm_ideal_key(Q):
316316
"""
317317
return (Q.norm(), ppower_norm_ideal_index(Q))
318318

319+
319320
def ppower_norm_ideal_label(Q):
320321
r""" return the label of an ideal of prime-power norm.
321322
"""
322323
return "{}.{}".format(Q.norm(),ppower_norm_ideal_index(Q))
323324

325+
324326
def ppower_norm_ideal_from_label(K,lab):
325327
r""" return the ideal of prime-power norm from its label.
326328
"""
327-
n, i = [int(c) for c in lab.split(".")]
329+
n, i = (int(c) for c in lab.split("."))
328330
p, f = ZZ(n).factor()[0]
329331
make_keys(K,p)
330332
PP = K.primes_dict[p]
@@ -369,12 +371,14 @@ def ideal_label(I):
369371
"""
370372
return "{}.{}".format(I.norm(),ideal_norm_index(I))
371373

374+
372375
def ideal_from_label(K,lab):
373376
r""" Return the ideal with a given label.
374377
"""
375-
n, j = [int(c) for c in lab.split(".")]
378+
n, j = (int(c) for c in lab.split("."))
376379
return ideals_of_norm(K,ZZ(n))[j-1]
377380

381+
378382
def ideals_iterator(K,minnorm=1,maxnorm=Infinity):
379383
r""" Return an iterator over all ideals of norm n up to maxnorm (sorted).
380384
"""

lmfdb/users/main.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ def admin():
319319
@app.route("/restartserver")
320320
@admin_required
321321
def restart():
322-
import sys
323322
from subprocess import Popen, PIPE
324323
from urllib.parse import urlparse
325324
urlparts = urlparse(request.url)
@@ -330,14 +329,12 @@ def restart():
330329
else:
331330
command = None
332331
if command:
333-
if sys.version_info[0] == 3:
334-
out = Popen(command, stdout=PIPE, encoding='utf-8').communicate()[0]
335-
else:
336-
out = Popen(command, stdout=PIPE).communicate()[0]
332+
out = Popen(command, stdout=PIPE, encoding='utf-8').communicate()[0]
337333
return out.replace('\n', '<br>')
338334
else:
339335
return "Only supported in beta.lmfdb.org, prodweb1.lmfdb.xyz, and prodweb2.lmfdb.xyz"
340336

337+
341338
class Reviewer(Uploader):
342339
"""
343340
This uploader is used to collect UploadSection objects from different sections of the LMFDB that use them.
@@ -346,6 +343,7 @@ def __init__(self):
346343
from lmfdb.modular_curves.upload import Points, PointCompleteness, GonalityBounds, Models, UniversalEC, MultiKnowl
347344
super().__init__([Points(), PointCompleteness(), GonalityBounds(), Models(), UniversalEC(), MultiKnowl()])
348345

346+
349347
@login_page.route("/uploads", methods=["GET", "POST"])
350348
@login_required
351349
def review_uploads():

0 commit comments

Comments
 (0)