diff --git a/qutebrowser/utils/appdirs.py b/qutebrowser/utils/appdirs.py index 1d24dd858..86a2d2b54 100644 --- a/qutebrowser/utils/appdirs.py +++ b/qutebrowser/utils/appdirs.py @@ -20,13 +20,6 @@ __version__ = '.'.join(map(str, __version_info__)) import sys import os -PY3 = sys.version_info[0] == 3 - -if PY3: - unicode = str - - - def user_data_dir(appname=None, appauthor=None, version=None, roaming=False): r"""Return full path to the user-specific data dir for this application. @@ -372,7 +365,7 @@ def _get_win_folder_from_registry(csidl_name): registry for this guarantees us the correct answer for all CSIDL_* names. """ - import _winreg + import winreg shell_folder_name = { "CSIDL_APPDATA": "AppData", @@ -380,9 +373,9 @@ def _get_win_folder_from_registry(csidl_name): "CSIDL_LOCAL_APPDATA": "Local AppData", }[csidl_name] - key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, + key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders") - dir, type = _winreg.QueryValueEx(key, shell_folder_name) + dir, type = winreg.QueryValueEx(key, shell_folder_name) return dir def _get_win_folder_with_pywin32(csidl_name): @@ -392,7 +385,7 @@ def _get_win_folder_with_pywin32(csidl_name): # not return unicode strings when there is unicode data in the # path. try: - dir = unicode(dir) + dir = str(dir) # Downgrade to short path name if have highbit chars. See # . @@ -463,15 +456,15 @@ if __name__ == "__main__": print("-- app dirs (with optional 'version')") dirs = AppDirs(appname, appauthor, version="1.0") for prop in props: - print("%s: %s" % (prop, getattr(dirs, prop))) + print(("%s: %s" % (prop, getattr(dirs, prop)))) print("\n-- app dirs (without optional 'version')") dirs = AppDirs(appname, appauthor) for prop in props: - print("%s: %s" % (prop, getattr(dirs, prop))) + print(("%s: %s" % (prop, getattr(dirs, prop)))) print("\n-- app dirs (without optional 'appauthor')") dirs = AppDirs(appname) for prop in props: - print("%s: %s" % (prop, getattr(dirs, prop))) + print(("%s: %s" % (prop, getattr(dirs, prop)))) diff --git a/qutebrowser/utils/usersettings.py b/qutebrowser/utils/usersettings.py index bf46267d1..d04173b50 100644 --- a/qutebrowser/utils/usersettings.py +++ b/qutebrowser/utils/usersettings.py @@ -3,10 +3,10 @@ Provide interface for persistent portable editable user settings """ import os -import ConfigParser +import configparser import ast -import appdirs +import qutebrowser.utils.appdirs as appdirs class Settings(dict): @@ -38,13 +38,13 @@ class Settings(dict): def load_settings(self): """ Set default values and parse stored settings file """ # Set the defaults - for key, value in self._settings_defaults.items(): + for key, value in list(self._settings_defaults.items()): if key not in self._settings_types: self._settings_types[key] = str super(Settings, self).__setitem__(key, value) # Load the stored values - parser = ConfigParser.RawConfigParser() + parser = configparser.RawConfigParser() try: with open(self.settings_file, 'r') as settings_fp: parser.readfp(settings_fp) @@ -75,10 +75,10 @@ class Settings(dict): def save_settings(self): """ Write the settings data to disk """ if not os.path.exists(self.settings_directory): - os.makedirs(self.settings_directory, 0755) - parser = ConfigParser.RawConfigParser() + os.makedirs(self.settings_directory, 0o755) + parser = configparser.RawConfigParser() parser.add_section('settings') - for key, value in self.items(): + for key, value in list(self.items()): parser.set('settings', key, value) with open(self.settings_file, 'wb') as settings_fp: parser.write(settings_fp)