Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removal of python-future compatibility code #531

Merged
merged 23 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
30907df
Remove all imports of print_function compatibility method
knabar Feb 6, 2024
bfbe350
Replace all instances of isbytes and bytes_to_native_str
knabar Feb 6, 2024
2d9b411
Replace all usages of past.builtins.basestring
knabar Feb 6, 2024
f25db1a
Remove usage of past.builtins.long and "import long"
knabar Feb 6, 2024
6a71b74
Remove usage of future.standard_library.install_aliases
knabar Feb 6, 2024
8fa11fa
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 6, 2024
d9f88d2
Cleanup miscellaneous Python 2 codepaths
knabar Feb 7, 2024
e8f8ca5
Remove all unnecessary builtins imports
knabar Feb 7, 2024
913b76b
Remove future dependency
knabar Feb 7, 2024
5671f8e
Clean up outdated Docker infrastructure
knabar Feb 7, 2024
7db0f55
Remove Python version check
knabar Feb 7, 2024
0c4bc24
Remove more Python 2 compatibility code
knabar Feb 7, 2024
bb3a7f1
Fix flake8
knabar Feb 7, 2024
43a887f
Update build matrix by adding 3.12 and removing 3.8
knabar Feb 7, 2024
d4368c0
Fix flake8
knabar Feb 7, 2024
2edac67
Temporarily point at omero-py GitHub branch with Python 3.12 changes
sbesson Feb 8, 2024
5112ea7
Add Python 3.8 back to build matrix
knabar Feb 8, 2024
ad3ac72
Clean up thread check
knabar Feb 8, 2024
52c84a6
Temporarily require omero-py development branch
knabar Feb 8, 2024
538c256
Set omero-py version
knabar Feb 23, 2024
03ca53e
Remove custom omero-py version from tox
knabar Feb 23, 2024
7ddf814
Fix missing build matrix entry
knabar Feb 27, 2024
60ce356
Remove comment
knabar Feb 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove usage of past.builtins.long and "import long"
  • Loading branch information
knabar committed Feb 6, 2024
commit f25db1a82f1f85e24d6352348cda55919bf4b2f5
24 changes: 11 additions & 13 deletions omeroweb/webadmin/custom_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
from django.utils.encoding import smart_str
from django.core.validators import validate_email, EMPTY_VALUES

from past.builtins import long


##################################################################
# Fields
Expand Down Expand Up @@ -101,7 +99,7 @@ def to_python(self, value):
return None
res = False
for q in self.queryset:
if long(value) == q.id:
if int(value) == q.id:
res = True
if not res:
raise ValidationError(self.error_messages["invalid_choice"])
Expand Down Expand Up @@ -167,10 +165,10 @@ def to_python(self, value):
exps = self.queryset
for experimenter in exps:
if hasattr(experimenter.id, "val"):
if long(value) == experimenter.id.val:
if int(value) == experimenter.id.val:
res = True
else:
if long(value) == experimenter.id:
if int(value) == experimenter.id:
res = True
if not res:
raise ValidationError(self.error_messages["invalid_choice"])
Expand Down Expand Up @@ -221,17 +219,17 @@ def to_python(self, value):
final_values = []
for val in value:
try:
long(val)
int(val)
except Exception:
raise ValidationError(self.error_messages["invalid_choice"])
else:
res = False
for q in self.queryset:
if hasattr(q.id, "val"):
if long(val) == q.id.val:
if int(val) == q.id.val:
res = True
else:
if long(val) == q.id:
if int(val) == q.id:
res = True
if not res:
raise ValidationError(self.error_messages["invalid_choice"])
Expand Down Expand Up @@ -354,9 +352,9 @@ def checkValue(q, value):
if not hasattr(q, "id"):
return False
if hasattr(q.id, "val"):
if long(value) == q.id.val:
if int(value) == q.id.val:
return True
if long(value) == q.id:
if int(value) == q.id:
return True

for q in self.queryset:
Expand Down Expand Up @@ -421,17 +419,17 @@ def to_python(self, value):
final_values = []
for val in value:
try:
long(val)
int(val)
except Exception:
raise ValidationError(self.error_messages["invalid_choice"])
else:
res = False
for q in self.queryset:
if hasattr(q.id, "val"):
if long(val) == q.id.val:
if int(val) == q.id.val:
res = True
else:
if long(val) == q.id:
if int(val) == q.id:
res = True
if not res:
raise ValidationError(self.error_messages["invalid_choice"])
Expand Down
9 changes: 4 additions & 5 deletions omeroweb/webclient/controller/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import datetime
import time

from past.builtins import long
from django.conf import settings

from omeroweb.webclient.controller import BaseController
Expand Down Expand Up @@ -172,8 +171,8 @@ def calendar_items(self, month, monthrange):
("%i-%s-%i 23:59:59" % (self.year, mn, monthrange)), "%Y-%m-%d %H:%M:%S"
)

start = long(time.mktime(d1.timetuple()) + 1e-6 * d1.microsecond) * 1000
end = long(time.mktime(d2.timetuple()) + 1e-6 * d2.microsecond) * 1000
start = int(time.mktime(d1.timetuple()) + 1e-6 * d1.microsecond) * 1000
end = int(time.mktime(d2.timetuple()) + 1e-6 * d2.microsecond) * 1000
all_logs = self.conn.getEventsByPeriod(start, end, self.eid)

items = dict()
Expand Down Expand Up @@ -218,8 +217,8 @@ def get_items(self, page=None):
("%i-%s-%s 23:59:59" % (self.year, mn, dy)), "%Y-%m-%d %H:%M:%S"
)

start = long(time.mktime(d1.timetuple()) + 1e-6 * d1.microsecond) * 1000
end = long(time.mktime(d2.timetuple()) + 1e-6 * d2.microsecond) * 1000
start = int(time.mktime(d1.timetuple()) + 1e-6 * d1.microsecond) * 1000
end = int(time.mktime(d2.timetuple()) + 1e-6 * d2.microsecond) * 1000

self.day_items = list()
self.day_items_size = 0
Expand Down
5 changes: 2 additions & 3 deletions omeroweb/webclient/controller/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
# Version: 1.0
#

from past.builtins import long
import time
import omero
import logging
Expand Down Expand Up @@ -89,11 +88,11 @@ def search(

created = [
rtime(
long(time.mktime(d1.timetuple()) + 1e-6 * d1.microsecond)
int(time.mktime(d1.timetuple()) + 1e-6 * d1.microsecond)
* 1000
),
rtime(
long(time.mktime(d2.timetuple()) + 1e-6 * d2.microsecond)
int(time.mktime(d2.timetuple()) + 1e-6 * d2.microsecond)
* 1000
),
]
Expand Down
7 changes: 3 additions & 4 deletions omeroweb/webclient/controller/share.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import datetime
import time
from past.builtins import long

from omero.rtypes import rtime

Expand Down Expand Up @@ -99,7 +98,7 @@ def createShare(self, host, images, message, members, enable, expiration=None):
expiration + " 23:59:59", "%Y-%m-%d %H:%M:%S"
)
expiration_date = (
long(time.mktime(d1.timetuple()) + 1e-6 * d1.microsecond) * 1000
int(time.mktime(d1.timetuple()) + 1e-6 * d1.microsecond) * 1000
)
image_objects = list(self.conn.getObjects("Image", images))
member_objects = list(self.conn.getObjects("Experimenter", members))
Expand All @@ -114,7 +113,7 @@ def createDiscussion(self, host, message, members, enable, expiration=None):
expiration + " 23:59:59", "%Y-%m-%d %H:%M:%S"
)
expiration_date = rtime(
long(time.mktime(d1.timetuple()) + 1e-6 * d1.microsecond) * 1000
int(time.mktime(d1.timetuple()) + 1e-6 * d1.microsecond) * 1000
)
member_objects = list(self.conn.getObjects("Experimenter", members))
return self.conn.createShare(
Expand All @@ -128,7 +127,7 @@ def updateShareOrDiscussion(self, host, message, members, enable, expiration=Non
expiration + " 23:59:59", "%Y-%m-%d %H:%M:%S"
)
expiration_date = (
long(time.mktime(d1.timetuple()) + 1e-6 * d1.microsecond) * 1000
int(time.mktime(d1.timetuple()) + 1e-6 * d1.microsecond) * 1000
)

old_groups = [m._obj for m in self.conn.getAllMembers(self.share.id)]
Expand Down
Loading