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

Remove python-future compatibility code #23

Merged
merged 15 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/omero_plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
env:
STAGE: scripts # app, cli, lib, scripts, srv
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Checkout omero-test-infra
uses: actions/checkout@master
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ jobs:
name: Build and publish Python distribution to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
sbesson marked this conversation as resolved.
Show resolved Hide resolved
- name: Build a binary wheel and a source tarball
run: |
python -mpip install wheel
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ jobs:
- '3.9'
- '3.10'
- '3.11'
- '3.12'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
32 changes: 0 additions & 32 deletions Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ def read(fname):
install_requires=[
"omero-py", # requires Ice (use wheel for faster installs)
],
python_requires='>=3',
python_requires='>=3.8',
tests_require=['pytest', 'pytest-mock'])
1 change: 0 additions & 1 deletion src/fsAbstractPlatformMonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
Use is subject to license terms supplied in LICENSE.txt

"""
from builtins import str
import threading


Expand Down
8 changes: 1 addition & 7 deletions src/fsDirectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,13 @@

"""

from builtins import str
from builtins import object
import logging
from time import localtime, strftime

# Third party path package. It provides much of the
# functionality of os.path but without the complexity.
# Imported as pathModule to avoid potential clashes.
try:
from omero_ext import path as pathModule
except ImportError:
# Python 2
import path as pathModule
from omero_ext import path as pathModule

import fsLists

Expand Down
8 changes: 1 addition & 7 deletions src/fsDropBox.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

"""

from builtins import str
from builtins import range
import logging
log = logging.getLogger("fsclient.DropBox")

Expand All @@ -23,11 +21,7 @@
# Third party path package. It provides much of the
# functionality of os.path but without the complexity.
# Imported as pathModule to avoid clashes.
try:
from omero_ext import path as pathModule
except ImportError:
# Python 2
import path as pathModule
from omero_ext import path as pathModule

import omero.all
import omero.grid.monitors as monitors
Expand Down
11 changes: 1 addition & 10 deletions src/fsDropBoxMonitorClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,12 @@

"""

from future import standard_library
standard_library.install_aliases()
from builtins import str
from builtins import range
from builtins import object
import shlex
import logging
import threading
import queue
import time
try:
from omero_ext import path as pathModule
except ImportError:
# Python 2
import path as pathModule
from omero_ext import path as pathModule

import omero
import omero.cli
Expand Down
12 changes: 2 additions & 10 deletions src/fsFileServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,14 @@
Use is subject to license terms supplied in LICENSE.txt

"""
from builtins import str
import logging

try:
from hashlib import sha1 as sha
except:
from sha import sha
from hashlib import sha1 as sha

# Third party path package. It provides much of the
# functionality of os.path but without the complexity.
# Imported as pathModule to avoid potential clashes.
try:
from omero_ext import path as pathModule
except ImportError:
# Python 2
import path as pathModule
from omero_ext import path as pathModule

import omero.all
import omero.grid.monitors as monitors
Expand Down
2 changes: 0 additions & 2 deletions src/fsLists.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
"""


from builtins import str
from builtins import object
class Greylist(object):

"""
Expand Down
9 changes: 1 addition & 8 deletions src/fsMac-10-5-Monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
Use is subject to license terms supplied in LICENSE.txt

"""
from builtins import str
from builtins import range
from builtins import object
import logging
import time
from Foundation import NSAutoreleasePool, NSMutableArray, NSString
Expand All @@ -19,11 +16,7 @@
# Third party path package. It provides much of the
# functionality of os.path but without the complexity.
# Imported as pathModule to avoid potential clashes.
try:
from omero_ext import path as pathModule
except ImportError:
# Python 2
import path as pathModule
from omero_ext import path as pathModule

__import__("omero.all")
import omero.grid.monitors as monitors
Expand Down
2 changes: 0 additions & 2 deletions src/fsMonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
Use is subject to license terms supplied in LICENSE.txt

"""
from builtins import str
from builtins import object
import logging
import threading

Expand Down
8 changes: 3 additions & 5 deletions src/fsMonitorServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
Use is subject to license terms supplied in LICENSE.txt

"""
from builtins import str
from future.utils import native_str, bytes_to_native_str, isbytes
import logging

import uuid
Expand Down Expand Up @@ -246,8 +244,8 @@ def callback(self, monitorId, fileList):
eventList = []
for fileEvent in fileList:
fileId = fileEvent[0]
if isbytes(fileId):
fileId = bytes_to_native_str(fileId)
if isinstance(fileId, bytes):
fileId = fileId.decode("utf-8")
info = monitors.EventInfo(fileId, fileEvent[1])
eventList.append(info)

Expand All @@ -256,7 +254,7 @@ def callback(self, monitorId, fileList):
try:
self.log.info('Event notification on monitor id= %s', monitorId)
self.log.debug(' ...notifications are: %s', str(eventList))
proxy.fsEventHappened(native_str(monitorId), eventList)
proxy.fsEventHappened(str(monitorId), eventList)
except Exception as e:
self.log.info(
'Callback to monitor id=' + monitorId
Expand Down
3 changes: 0 additions & 3 deletions src/fsNotificationScheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
Use is subject to license terms supplied in LICENSE.txt

"""
from future import standard_library
standard_library.install_aliases()
from builtins import range
import logging
import threading
import queue
Expand Down
21 changes: 6 additions & 15 deletions src/fsPyinotifyMonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
Use is subject to license terms supplied in LICENSE.txt

"""
from __future__ import division
from future.utils import bytes_to_native_str, isbytes
from builtins import str
from past.utils import old_div
from builtins import object
import logging
import copy
import time
Expand All @@ -30,11 +25,7 @@
# Third party path package. It provides much of the
# functionality of os.path but without the complexity.
# Imported as pathModule to avoid potential clashes.
try:
from omero_ext import path as pathModule
except ImportError:
# Python 2
import path as pathModule
from omero_ext import path as pathModule


class PlatformMonitor(AbstractPlatformMonitor):
Expand Down Expand Up @@ -176,8 +167,8 @@ def addBaseWatch(self, path, mask, rec=False, auto_add=False):
def addWatch(self, path, mask):
if not self.isPathWatched(path):
try:
if isbytes(path):
path_obj = pathModule.path(bytes_to_native_str(path))
if isinstance(path, bytes):
path_obj = pathModule.path(path.decode("utf-8"))
else:
path_obj = pathModule.path(path)
res = pyinotify.WatchManager.add_watch(
Expand Down Expand Up @@ -261,8 +252,8 @@ def process_default(self, event):
maskname = event.maskname
except Exception:
# pyinotify 0.7 or below
name = old_div(pathModule.path(event.path),
pathModule.path(event.name))
name = (pathModule.path(event.path) /
pathModule.path(event.name))
maskname = event.event_name

el = []
Expand All @@ -278,7 +269,7 @@ def process_default(self, event):

# New directory within watch area,
# either created, moved in or modfied attributes, ie now readable.
path_name = pathModule.path(bytes_to_native_str(name))
path_name = pathModule.path(name.decode("utf-8"))
if (event.mask == (pyinotify.IN_CREATE | pyinotify.IN_ISDIR)
or event.mask == (pyinotify.IN_MOVED_TO | pyinotify.IN_ISDIR)
or event.mask == (pyinotify.IN_ATTRIB | pyinotify.IN_ISDIR)):
Expand Down
9 changes: 4 additions & 5 deletions src/fsUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@
"""

import logging
from future.utils import isbytes, bytes_to_native_str


class NativeKeyDict(dict):

def __getitem__(self, key):
if isbytes(key):
key = bytes_to_native_str(key)
if isinstance(key, bytes):
key = key.decode("utf-8")
return dict.__getitem__(self, key)

def __setitem__(self, key, val):
if isbytes(key):
key = bytes_to_native_str(key)
if isinstance(key, bytes):
key = key.decode("utf-8")
return dict.__setitem__(self, key, val)


Expand Down
8 changes: 1 addition & 7 deletions src/fsWin-XP-Monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
Use is subject to license terms supplied in LICENSE.txt

"""
from builtins import str
from builtins import object
import logging
import threading
import os
Expand All @@ -17,11 +15,7 @@
# Third party path package. It provides much of the
# functionality of os.path but without the complexity.
# Imported as pathModule to avoid clashes.
try:
from omero_ext import path as pathModule
except ImportError:
# Python 2
import path as pathModule
from omero_ext import path as pathModule

__import__("omero.all")
import omero.grid.monitors as monitors
Expand Down
2 changes: 0 additions & 2 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# how-can-i-repeat-each-test-multiple-times-in-a-py-test-run
#

from builtins import range
from builtins import object
import os
import pytest

Expand Down
Loading