Sfoglia il codice sorgente

Updated: fixed lots of pylint errors.

Steve Thielemann 5 anni fa
parent
commit
1fe04d6ad9
2 ha cambiato i file con 34 aggiunte e 34 eliminazioni
  1. 33 33
      flexible.py
  2. 1 1
      proxy.py

+ 33 - 33
flexible.py

@@ -172,7 +172,7 @@ class PlayerInput(object):
                     self.queue_game.put("\a")
             elif ch == "\r":
                 self.queue_game.put(self.r + self.nl)
-                log.debug("Restore observer dispatch", self.save)
+                log.debug("Restore observer dispatch {0}".format(self.save))
                 assert not self.save is None
                 self.observer.load(self.save)
                 self.save = None
@@ -375,7 +375,7 @@ class CIMPortReport(object):
         # If we want it, it's here.
         self.defer = None
         self.to_player = self.game.to_player
-        log.debug("to_player (stored)", self.to_player)
+        log.debug("to_player (stored) {0}".format(self.to_player))
 
         # Hide what's happening from the player
         self.game.to_player = False
@@ -455,7 +455,7 @@ class CIMPortReport(object):
             self.game.gamedata.set_port(port, data)
             # self.portdata[port] = data
         else:
-            log.error("CIMPortReport:", line, "???")
+            log.error("CIMPortReport: {0} ???".format(line))
 
     def __del__(self):
         log.debug("CIMPortReport {0} RIP".format(self))
@@ -585,7 +585,7 @@ class ScriptPort(object):
                     
                     pi = PlayerInput(self.game)
                     def got_need1(*_):
-                        log.debug("Ok, I have:", pi.keep)
+                        log.debug("Ok, I have: {0}".format(pi.keep))
                         if pi.keep['count'].strip() == '':
                             self.deactivate()
                             return
@@ -626,7 +626,7 @@ class ScriptPort(object):
                             self.deactivate()
                             return
                         self.times_left = int(pi.keep['count'])
-                        log.debug("Ok, I have:", pi.keep)
+                        log.debug("Ok, I have: {0}".format(pi.keep))
                         # self.queue_game.put(pformat(pi.keep).replace("\n", "\n\r"))
                         self.state = 5
                         self.trade()
@@ -680,16 +680,16 @@ class ScriptPort(object):
                     parts = re.split(r"\s+", work)
                     amount = parts[2]
                     # Ok, we have the amount, now to figure pct...
-                    if self.sell_pct > 100:
-                        self.sell_pct -= 1
+                    if self.sell_percent > 100:
+                        self.sell_percent -= 1
                     else:
-                        self.sell_pct += 1
-                    price = amount * self.sell_pct // 100
-                    log.debug("start: {0} % {1} price {2}".format(amount, self.sell_perc, price))
-                    if self.sell_pct > 100:
-                        self.sell_pct -= 1
+                        self.sell_percent += 1
+                    price = amount * self.sell_percent // 100
+                    log.debug("start: {0} % {1} price {2}".format(amount, self.sell_percent, price))
+                    if self.sell_percent > 100:
+                        self.sell_percent -= 1
                     else:
-                        self.sell_pct += 1
+                        self.sell_percent += 1
                     self.queue_player.put("{0}\r".format(price))                    
 
         elif self.state == 8:
@@ -808,7 +808,7 @@ class ScriptPort(object):
             # First exploration
             if line.startswith("Sector  :"):
                 # We have starting sector information
-                parts = re.split("\s+", line)
+                parts = re.split(r"\s+", line)
                 self.this_sector = int(parts[2])
                 # These will be the ones swapped around as we trade back and forth.
                 self.sector1 = self.this_sector
@@ -817,7 +817,7 @@ class ScriptPort(object):
                 _, _, warps = line.partition(':')
                 warps = warps.replace('-', '').replace('(', '').replace(')', '').strip()
                 log.debug("Warps: [{0}]".format(warps))
-                self.warps = [ int(x) for x in re.split("\s+", warps)]
+                self.warps = [ int(x) for x in re.split(r"\s+", warps)]
                 log.debug("Warps: [{0}]".format(self.warps))
                 self.state = 2
         elif self.state == 2:
@@ -899,11 +899,11 @@ class ScriptPort(object):
                 # Sell
                 self.state = 7
                 self.queue_player.put("\r")
-                self.sell_perc = 100 + self.percent                
+                self.sell_percent = 100 + self.percent                
             if "We are selling up to" in line:
                 # Buy
                 self.state = 8
-                self.sell_perc = 100 - self.percent
+                self.sell_percent = 100 - self.percent
             if line.startswith('Fuel Ore') or line.startswith('Organics') or line.startswith('Equipment'):
                 work = line.replace('Fuel Ore', 'Fuel')
                 parts = re.split(r"\s+", work)
@@ -929,17 +929,17 @@ class ScriptPort(object):
             # Haggle Sell
             if "We'll buy them for" in line or "Our final offer" in line:
                 if "Our final offer" in line:
-                    self.sell_perc -= 1
+                    self.sell_percent -= 1
                 parts = line.replace(',', '').split()
                 start_price = int(parts[4])
-                price = start_price * self.sell_perc // 100
-                log.debug("start: {0} % {1} price {2}".format(start_price, self.sell_perc, price))
-                self.sell_perc -= 1
+                price = start_price * self.sell_percent // 100
+                log.debug("start: {0} % {1} price {2}".format(start_price, self.sell_percent, price))
+                self.sell_percent -= 1
                 self.queue_player.put("{0}\r".format(price))
             if "We are selling up to" in line:
                 # Buy
                 self.state = 8
-                self.sell_perc = 100 - self.percent      
+                self.sell_percent = 100 - self.percent      
             if "We're not interested." in line:
                 log.info("Try, try again.  :(")
                 self.state = 5
@@ -958,12 +958,12 @@ class ScriptPort(object):
             # Haggle Buy
             if "We'll sell them for" in line or "Our final offer" in line:
                 if "Our final offer" in line:
-                    self.sell_perc += 1
+                    self.sell_percent += 1
                 parts = line.replace(',', '').split()
                 start_price = int(parts[4])
-                price = start_price * self.sell_perc // 100
-                log.debug("start: {0} % {1} price {2}".format(start_price, self.sell_perc, price))                
-                self.sell_perc += 1
+                price = start_price * self.sell_percent // 100
+                log.debug("start: {0} % {1} price {2}".format(start_price, self.sell_percent, price))                
+                self.sell_percent += 1
                 self.queue_player.put("{0}\r".format(price))
             if "We're not interested." in line:
                 log.info("Try, try again.  :(")
@@ -1485,7 +1485,7 @@ class ScriptSpace(object):
                         if pos not in seen:
                             next_possible.add(pos)
                 else:
-                    log.debug("unknown found:", s)
+                    log.debug("unknown found: {0}".format(s))
                     self.unknown = s
                     done = True
                     break
@@ -1493,7 +1493,7 @@ class ScriptSpace(object):
                 seen.add(s)
 
             if self.unknown is None:
-                log.debug("possible:", next_possible)
+                log.debug("possible: {0}".format(next_possible))
                 possible = next_possible
                 yield
 
@@ -1577,7 +1577,7 @@ class ScriptSpace(object):
                     return
 
     def next_unknown(self, sector):
-        log.info("Unknown is :", sector)
+        log.info("Unknown is : {0}".format(sector))
         self.deactivate()
 
     def game_line(self, line: str):
@@ -1587,7 +1587,7 @@ class ScriptSpace(object):
             work = line.strip()
             parts = re.split(r"\s+", work)
             self.this_sector = int(parts[2])
-            log.debug("game_line sector", self.this_sector)
+            log.debug("game_line sector {0}".format(self.this_sector))
         elif line.startswith("Command [TL=]"):
             # Ok, get the current sector from this
             _, _, sector = line.partition("]:[")
@@ -1617,7 +1617,7 @@ class ScriptSpace(object):
                 # Parse Density Scan values
                 work = line.replace('(', '').replace(')', '').replace(':', '').replace('%', '').replace(',', '')
                 parts = re.split(r'\s+', work)
-                log.debug("Sector", parts)
+                log.debug("Sector {0}".format(parts))
                 sector = int(parts[1])
                 self.density[sector] = int(parts[3])
                 if parts[7] != '0':
@@ -1644,7 +1644,7 @@ class ScriptSpace(object):
             else:
                 work = line.replace("(", "").replace(")", "").replace(">", "").strip()
                 self.path = [int(x) for x in work.split()]
-                log.debug("Path:", self.path)
+                log.debug("Path: {0}".format(self.path))
 
                 # Verify
                 current = self.path.pop(0)
@@ -1820,7 +1820,7 @@ class ProxyMenu(object):
             self.trade_report.extend(ok_trades)
 
         if not show_best and not show_ok:
-            self.queue_game.put(Boxes.alert("You probably want to choose something to display in configuration!", color="red"))
+            self.queue_game.put(Boxes.alert("You probably want to choose something to display in configuration!", base="red"))
 
         # self.queue_game.put("BEST TRADES:" + self.nl + self.nl.join(best_trades) + self.nl)
         # self.queue_game.put("OK TRADES:" + self.nl + self.nl.join(ok_trades) + self.nl)

+ 1 - 1
proxy.py

@@ -107,7 +107,7 @@ class Game(protocol.Protocol):
             # Pass received data to the server
             if type(chunk) == str:
                 self.transport.write(chunk.encode("latin-1"))
-                log.msg(">> [{0}]".format(chunk))
+                log.debug(">> [{0}]".format(chunk))
             else:
                 self.transport.write(chunk)
                 self.log.debug(">> [{0}]".format(chunk.decode("latin-1", "ignore")))