Skip to content

Commit

Permalink
Removed Python2 compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
MeanEYE committed Jan 9, 2019
1 parent 6df6a6b commit 9677dda
Show file tree
Hide file tree
Showing 12 changed files with 1 addition and 56 deletions.
5 changes: 0 additions & 5 deletions sunflower/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
import sys


if sys.version_info[0] == 2:
reload(sys)
sys.setdefaultencoding('utf8')
sys.path.append(os.path.dirname(__file__)) # Not necessary for us, but it might help old plugins

try:
# check if gtk is available
import gi
Expand Down
5 changes: 0 additions & 5 deletions sunflower/associations.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
from __future__ import absolute_import

import sys
if sys.version_info[0] == 2:
import future.standard_library
future.standard_library.install_aliases()

import os
import shlex
import subprocess
Expand Down
6 changes: 0 additions & 6 deletions sunflower/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,6 @@ def load_translation():
def decode_file_name(file_name):
"""Replace surrogate codepoints in a filename with a replacement character
to display non-UTF-8 filenames."""
if sys.version_info[0] == 2:
return file_name

if isinstance(file_name, bytes):
return file_name.decode('utf-8', 'replace')

Expand All @@ -204,7 +201,4 @@ def decode_file_name(file_name):
def encode_file_name(file_name):
"""Encode filename to bytes so it can be passed to GI APIs that expect a file name
(and specify `filename` as their argument type in the GIR bindings)."""
if sys.version_info[0] == 2:
return file_name

return str(file_name).encode('utf-8', 'surrogateescape')
5 changes: 0 additions & 5 deletions sunflower/operation.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
from __future__ import absolute_import

import sys
if sys.version_info[0] == 2:
import future.standard_library
future.standard_library.install_aliases()

import os
import fnmatch

Expand Down
4 changes: 0 additions & 4 deletions sunflower/plugin_base/item_list.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
from __future__ import absolute_import
import sys
if sys.version_info[0] == 2:
import future.standard_library
future.standard_library.install_aliases()

import os
import urllib.parse
Expand Down
4 changes: 0 additions & 4 deletions sunflower/plugin_base/monitor.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
from __future__ import absolute_import
import sys
if sys.version_info[0] == 2:
import future.standard_library
future.standard_library.install_aliases()

from gi.repository import GObject
from queue import Queue, Empty as QueueEmptyException
Expand Down
3 changes: 0 additions & 3 deletions sunflower/plugins/file_list/file_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ def __init__(self, parent, notebook, options):

self.scheme = 'file'
self.path = self._options.get('path', os.path.expanduser('~'))
if sys.version_info[0] == 2 and type(self.path) == unicode:
self.path = self.path.encode('utf-8')

self._sort_column = self._options.get('sort_column', 0)
self._sort_ascending = self._options.get('sort_ascending', True)

Expand Down
5 changes: 0 additions & 5 deletions sunflower/plugins/file_list/gio_provider.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
from __future__ import absolute_import

import sys
if sys.version_info[0] == 2:
import future.standard_library
future.standard_library.install_aliases()

import os

from gi.repository import Gio, GLib
Expand Down
2 changes: 0 additions & 2 deletions sunflower/plugins/file_list/local_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,6 @@ def rename_path(self, source, destination, relative_to=None):

def list_dir(self, path, relative_to=None):
"""Get directory list"""
if sys.version_info[0] == 2 and type(path) == unicode:
path = path.encode('utf-8')
real_path = self.real_path(path, relative_to)
return os.listdir(real_path)

Expand Down
5 changes: 0 additions & 5 deletions sunflower/queue.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
from __future__ import absolute_import
import sys
if sys.version_info[0] == 2:
import future.standard_library
future.standard_library.install_aliases()

from gi.repository import Gtk

from threading import Lock
from queue import Queue, Empty

Expand Down
8 changes: 1 addition & 7 deletions sunflower/tools/version_check.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
from __future__ import absolute_import
import sys
if sys.version_info[0] == 2:
import future.standard_library
future.standard_library.install_aliases()

from urllib.request import urlopen

from gi.repository import Gtk, Gdk, GObject
from urllib.request import urlopen
from json import JSONDecoder
from threading import Thread

Expand All @@ -22,7 +17,6 @@ class VersionCheck:

def __init__(self, application):
self._dialog = Gtk.Window(type=Gtk.WindowType.TOPLEVEL)

self._application = application

# configure window
Expand Down
5 changes: 0 additions & 5 deletions sunflower/widgets/location_menu.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
from __future__ import absolute_import

import sys
if sys.version_info[0] == 2:
import future.standard_library
future.standard_library.install_aliases()

import os
import urllib.parse

Expand Down

0 comments on commit 9677dda

Please sign in to comment.