Ignore:
Timestamp:
03/24/19 08:15:59 (5 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
python3
Phase:
public
Message:

Ran 2to3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/config.py

    r738 r919  
    11# -*- encoding: utf-8 -*-
    22
    3 import const
    4 from util import secondaryInstallation, utf2unicode
     3from . import const
     4from .util import secondaryInstallation, utf2unicode
    55
    66import os
    77import sys
    88import traceback
    9 import ConfigParser
     9import configparser
    1010
    1111## @package mlx.config
     
    163163        baseName = "callouts." + const.icaoCodes[aircraftType] + "."
    164164        index = 0
    165         for (altitude, path) in self._mapping.iteritems():
     165        for (altitude, path) in self._mapping.items():
    166166            option = baseName + str(index)
    167167            config.set(ApproachCallouts.SECTION, option,
     
    171171    def getAltitudes(self, descending = True):
    172172        """Get the altitudes in decreasing order by default."""
    173         altitudes = self._mapping.keys()
     173        altitudes = list(self._mapping.keys())
    174174        altitudes.sort(reverse = descending)
    175175        return altitudes
    176176
    177     def __nonzero__(self):
     177    def __bool__(self):
    178178        """Return if there is anything in the mapping."""
    179179        return not not self._mapping
     
    704704        """Load the configuration from its default location."""
    705705        try:
    706             config = ConfigParser.RawConfigParser()
     706            config = configparser.RawConfigParser()
    707707            config.read(configPath)
    708708        except:
     
    806806            return
    807807
    808         config = ConfigParser.RawConfigParser()
     808        config = configparser.RawConfigParser()
    809809
    810810        config.add_section("login")
     
    892892        try:
    893893            fd = os.open(configPath, os.O_CREAT|os.O_TRUNC|os.O_WRONLY,
    894                          0600)
     894                         0o600)
    895895            with os.fdopen(fd, "wt") as f:
    896896                config.write(f)
    897897            self._modified = False
    898898
    899             print "Configuration saved:"
     899            print("Configuration saved:")
    900900            self.log()
    901901
    902         except Exception, e:
    903             print >> sys.stderr, "Failed to update config: " + \
    904                                  utf2unicode(str(e))
     902        except Exception as e:
     903            print("Failed to update config: " + \
     904                                 utf2unicode(str(e)), file=sys.stderr)
    905905
    906906    def _getBoolean(self, config, section, option, default):
     
    945945        import locale
    946946        if self._language:
    947             print "Setting up locale for", self._language
     947            print("Setting up locale for", self._language)
    948948            os.environ["LANGUAGE"] = self._language
    949949            langAndEncoding = self._language + "." + locale.getpreferredencoding()
     
    978978    def log(self):
    979979        """Log the configuration by printing the values"""
    980         print "  pilot ID:", self._pilotID
    981         print "  rememberPassword:", self._rememberPassword
    982 
    983         print "  language:", self._language
    984 
    985         print "  hideMinimizedWindow:", self._hideMinimizedWindow
    986         print "  quitOnClose:", self._quitOnClose
    987 
    988         print "  onlineGateSystem:", self._onlineGateSystem
    989         print "  onlineACARS:", self._onlineACARS
    990 
    991         print "  flareTimeFromFS:", self._flareTimeFromFS
    992         print "  syncFSTime:", self._syncFSTime
    993         print "  usingFS2Crew:", self._usingFS2Crew
    994 
    995         print "  iasSmoothingLength:", self._iasSmoothingLength
    996         print "  vsSmoothingLength:", self._vsSmoothingLength
    997 
    998         print "  useSimBrief:", self._useSimBrief
    999         print "  simBriefUserName:", self._simBriefUserName
    1000         print "  rememberSimBriefPassword:", self._rememberSimBriefPassword
    1001 
    1002         print "  pirepDirectory:", self._pirepDirectory
    1003         print "  pirepAutoSave:", self._pirepAutoSave
    1004 
    1005         print "  defaultMSFS:", self._defaultMSFS
    1006 
    1007         print "  enableSounds:", self._enableSounds
    1008 
    1009         print "  pilotControlsSounds:", self._pilotControlsSounds
    1010         print "  pilotHotkey:", str(self._pilotHotkey)
    1011 
    1012         print "  enableApproachCallouts:", self._enableApproachCallouts
    1013         print "  speedbrakeAtTD:", self._speedbrakeAtTD
    1014 
    1015         print "  enableChecklists:", self._enableChecklists
    1016         print "  checklistHotkey:", str(self._checklistHotkey)
    1017 
    1018         print "  autoUpdate:", self._autoUpdate
    1019         print "  updateURL:", self._updateURL
    1020         print "  useRPC:", self._useRPC
    1021 
    1022         print "  messageTypeLevels:"
    1023         for (type, level) in self._messageTypeLevels.iteritems():
    1024             print "    %s: %s" % (const.messageType2string(type),
    1025                                   const.messageLevel2string(level))
    1026 
    1027         print "  checklists:"
    1028         for (type, checklist) in self._checklists.iteritems():
    1029             print "    %s:" % (const.icaoCodes[type],)
     980        print("  pilot ID:", self._pilotID)
     981        print("  rememberPassword:", self._rememberPassword)
     982
     983        print("  language:", self._language)
     984
     985        print("  hideMinimizedWindow:", self._hideMinimizedWindow)
     986        print("  quitOnClose:", self._quitOnClose)
     987
     988        print("  onlineGateSystem:", self._onlineGateSystem)
     989        print("  onlineACARS:", self._onlineACARS)
     990
     991        print("  flareTimeFromFS:", self._flareTimeFromFS)
     992        print("  syncFSTime:", self._syncFSTime)
     993        print("  usingFS2Crew:", self._usingFS2Crew)
     994
     995        print("  iasSmoothingLength:", self._iasSmoothingLength)
     996        print("  vsSmoothingLength:", self._vsSmoothingLength)
     997
     998        print("  useSimBrief:", self._useSimBrief)
     999        print("  simBriefUserName:", self._simBriefUserName)
     1000        print("  rememberSimBriefPassword:", self._rememberSimBriefPassword)
     1001
     1002        print("  pirepDirectory:", self._pirepDirectory)
     1003        print("  pirepAutoSave:", self._pirepAutoSave)
     1004
     1005        print("  defaultMSFS:", self._defaultMSFS)
     1006
     1007        print("  enableSounds:", self._enableSounds)
     1008
     1009        print("  pilotControlsSounds:", self._pilotControlsSounds)
     1010        print("  pilotHotkey:", str(self._pilotHotkey))
     1011
     1012        print("  enableApproachCallouts:", self._enableApproachCallouts)
     1013        print("  speedbrakeAtTD:", self._speedbrakeAtTD)
     1014
     1015        print("  enableChecklists:", self._enableChecklists)
     1016        print("  checklistHotkey:", str(self._checklistHotkey))
     1017
     1018        print("  autoUpdate:", self._autoUpdate)
     1019        print("  updateURL:", self._updateURL)
     1020        print("  useRPC:", self._useRPC)
     1021
     1022        print("  messageTypeLevels:")
     1023        for (type, level) in self._messageTypeLevels.items():
     1024            print("    %s: %s" % (const.messageType2string(type),
     1025                                  const.messageLevel2string(level)))
     1026
     1027        print("  checklists:")
     1028        for (type, checklist) in self._checklists.items():
     1029            print("    %s:" % (const.icaoCodes[type],))
    10301030            for path in checklist:
    1031                 print "      " + path
    1032 
    1033         print "  approachCallouts:"
    1034         for (type, approachCallouts) in self._approachCallouts.iteritems():
    1035             print "    %s:" % (const.icaoCodes[type],)
     1031                print("      " + path)
     1032
     1033        print("  approachCallouts:")
     1034        for (type, approachCallouts) in self._approachCallouts.items():
     1035            print("    %s:" % (const.icaoCodes[type],))
    10361036            for (altitude, path) in approachCallouts:
    1037                 print "      %d: %s" % (altitude, path)
     1037                print("      %d: %s" % (altitude, path))
    10381038
    10391039#-------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.