Skip to content

Commit

Permalink
Remove usage of past.builtins.long and "import long"
Browse files Browse the repository at this point in the history
  • Loading branch information
knabar committed Feb 6, 2024
1 parent 2d9b411 commit f25db1a
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 93 deletions.
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

0 comments on commit f25db1a

Please sign in to comment.