2to3 conversion tool

actual converted files.
This commit is contained in:
Gabor Körber 2017-05-12 18:19:36 +02:00
parent 288065d066
commit 149fc122d0
25 changed files with 3445 additions and 3445 deletions

View File

@ -4,10 +4,10 @@
Tool to analyze Logs in general.
"""
import os, sys, logging
from logs.logfiles import LogFileResolver as LogFile
from logs import combat, game, chat
from logs.session import LogSessionCollector
from logs.game import ClientInfo
from .logs.logfiles import LogFileResolver as LogFile
from .logs import combat, game, chat
from .logs.session import LogSessionCollector
from .logs.game import ClientInfo
# for windows its kinda this:
settings = {'root_path': os.path.join(os.path.expanduser('~'),
@ -38,7 +38,7 @@ if __name__ == '__main__':
for logf in coll.sessions:
logf.parse_files(['game.log', 'combat.log', 'chat.log'])
print "----- Log %s -----" % logf.idstr
print(("----- Log %s -----" % logf.idstr))
if logf.combat_log:
for l in logf.combat_log.lines:
if isinstance(l, dict):
@ -49,42 +49,42 @@ if __name__ == '__main__':
rex_combat[l.__class__.__name__] = rex_combat.get(l.__class__.__name__, 0) + 1
if not isinstance(l, combat.UserEvent):
if not LOG_GOOD:
print l.values['log']
print((l.values['log']))
if logf.game_log:
for l in logf.game_log.lines:
if isinstance(l, dict):
rex_game['dict'] = rex_game.get('dict', 0) + 1
elif isinstance(l, str):
print l
print(l)
else:
if l.unpack() and not LOG_GOOD:
pass
else:
rex_game[l.__class__.__name__] = rex_game.get(l.__class__.__name__, 0) + 1
if not LOG_GOOD:
print l.values['log']
print((l.values['log']))
if logf.chat_log:
for l in logf.chat_log.lines:
if isinstance(l, dict):
rex_chat['dict'] = rex_chat.get('dict', 0) + 1
elif isinstance(l, str):
print l
print(l)
else:
if l.unpack() and not LOG_GOOD:
pass
else:
rex_chat[l.__class__.__name__] = rex_chat.get(l.__class__.__name__, 0) + 1
if not LOG_GOOD:
print l.values['log']
print((l.values['log']))
logf.clean(True)
# additional cleanup:
logf.chat_log.lines = []
logf.game_log.lines = []
logf.combat_log.lines = []
print 'Analysis complete:'
print '#'*20+' RexCombat ' + '#' *20
print rex_combat
print '#'*20+' RexGame ' + '#' *20
print rex_game
print '#'*20+' RexChat ' + '#' *20
print rex_chat
print('Analysis complete:')
print(('#'*20+' RexCombat ' + '#' *20))
print(rex_combat)
print(('#'*20+' RexGame ' + '#' *20))
print(rex_game)
print(('#'*20+' RexChat ' + '#' *20))
print(rex_chat)

View File

@ -101,13 +101,13 @@ class BasePageReply(QtNetwork.QNetworkReply):
class PageReply(BasePageReply):
def initialize_content(self, url, operation):
c = Client()
print "Response for %s, method %s" % (url.path(), operation)
print(("Response for %s, method %s" % (url.path(), operation)))
if operation == LocalNetworkAccessManager.GetOperation:
response = c.get(unicode(url.path()), )
response = c.get(str(url.path()), )
elif operation == LocalNetworkAccessManager.PostOperation:
response = c.post(unicode(url.path()))
response = c.post(str(url.path()))
# response code
print "Response Status: %s" % response.status_code
print(("Response Status: %s" % response.status_code))
# note: on a 404, we might need to trigger file response.
return response.content
@ -129,7 +129,7 @@ class ImageReply(BasePageReply):
BasePageReply.__init__(self, parent, url, operation)
def initialize_content(self, url, operation):
path = os.path.join(self.basedir, unicode(url.path()).lstrip('/'))
path = os.path.join(self.basedir, str(url.path()).lstrip('/'))
if not os.path.exists(path):
logging.error('Image does not exist: %s' % path)
return ''

View File

@ -49,20 +49,20 @@ def backup_log_directory(log_directory, backup_directory, compress=True,
full_dir)
logging.info('Backed up %s' % directory)
if verbose:
print "Backed up %s" % directory
print(("Backed up %s" % directory))
else:
if verbose:
print "Directory Raw Backup not implemented yet."
print("Directory Raw Backup not implemented yet.")
raise NotImplementedError
else:
if verbose:
print "%s is not a directory." % full_dir
print(("%s is not a directory." % full_dir))
if verbose and nothing_found:
print "Nothing to backup found in %s" % log_directory
print(("Nothing to backup found in %s" % log_directory))
if __name__ == '__main__':
print "Performing Log Backup (Dev)"
print("Performing Log Backup (Dev)")
log_source = os.path.join(os.path.expanduser('~'),
'Documents', 'My Games', 'StarConflict', 'logs')
log_dest = os.path.join(os.path.expanduser('~'),

View File

@ -4,10 +4,10 @@
Tool to analyze Logs in general.
"""
import os, sys, logging
from logs.logfiles import LogFileResolver as LogFile
from logs import combat, game, chat
from logs.session import LogSessionCollector
from logs.game import ClientInfo
from .logs.logfiles import LogFileResolver as LogFile
from .logs import combat, game, chat
from .logs.session import LogSessionCollector
from .logs.game import ClientInfo
# for windows its kinda this:
settings = {'root_path': os.path.join(os.path.expanduser('~'),
@ -28,6 +28,6 @@ if __name__ == '__main__':
logf.parse_files(['game.log', 'combat.log'])
logf.clean()
if logf.combat_log:
print 'length combat log ', len(logf.combat_log.lines)
print(('length combat log ', len(logf.combat_log.lines)))
if logf.game_log:
print 'length game log ', len(logf.game_log.lines)
print(('length game log ', len(logf.game_log.lines)))

View File

@ -16,8 +16,8 @@
"""
#from win32com.shell import shell, shellcon
import os, sys, logging
from logs.logfiles import LogFileResolver as LogFile
from logs import combat
from .logs.logfiles import LogFileResolver as LogFile
from .logs import combat
# for windows its kinda this:
settings = {'root_path': os.path.join(os.path.expanduser('~'),
@ -78,8 +78,8 @@ if __name__ == '__main__':
if not l.unpack():
rex[l.__class__.__name__] = rex.get(l.__class__.__name__, 0) + 1
if not isinstance(l, combat.UserEvent):
print l.values['log']
print((l.values['log']))
#f.write(l.values['log'] + '\n')
#f.close()
#print type(l)
print rex
print(rex)

View File

@ -2,7 +2,7 @@
Simple brainstorm to display a config file.
"""
import os, logging
from settings import settings
from .settings import settings
logging.basicConfig(level=logging.INFO)
# import ET:
try:
@ -22,7 +22,7 @@ except ImportError:
logging.info('Using xml.ElementTree')
finally:
if not ET:
raise NotImplementedError, "XML Parser not found in your Python."
raise NotImplementedError("XML Parser not found in your Python.")
##################################################################################################
class ConfigFile(object):
@ -53,7 +53,7 @@ class ConfigFile(object):
def pprint(self):
# print out my cvars
for child in self.cvars:
print '%s = %s' % (child.tag, child.attrib['val'])
print(('%s = %s' % (child.tag, child.attrib['val'])))
def write(self, filename):
output = '<?xml version="1.0"?>\n'
@ -63,7 +63,7 @@ class ConfigFile(object):
def append_node(node, depth=0):
# xml serializing helper function...
s = ['%s<%s' % (' '*depth*2, node.tag),]
for key, val in node.attrib.items():
for key, val in list(node.attrib.items()):
s.append(' %s="%s"' % (key, val))
if len(node):
s.append('>\n')
@ -108,12 +108,12 @@ if __name__ == '__main__':
# Read the config
settings.autodetect()
c = ConfigFile().open()
print '#' * 80
print "Output File would be:"
print c.write(None)
print '#' * 80
print "Detected Settings:"
print(('#' * 80))
print("Output File would be:")
print((c.write(None)))
print(('#' * 80))
print("Detected Settings:")
c.pprint()
print '#' * 80
print 'Serializing Test successful: %s' % c.debug_serializing()
print(('#' * 80))
print(('Serializing Test successful: %s' % c.debug_serializing()))

View File

@ -13,13 +13,13 @@ class Settings(dict):
'My Games',
'StarConflict',)
elif system == 'Linux':
raise NotImplementedError, "Implement Linux!"
raise NotImplementedError("Implement Linux!")
elif system == 'Darwin':
raise NotImplementedError, "Implement Mac!"
raise NotImplementedError("Implement Mac!")
else:
raise NotImplementedError, "Unknown System! %s" % platform.system()
raise NotImplementedError("Unknown System! %s" % platform.system())
if not os.path.exists(d) or not os.path.isdir(d):
raise Exception, "Configuration Autodetection failed. "
raise Exception("Configuration Autodetection failed. ")
self['root_path'] = d
def get_path(self):

View File

@ -31,7 +31,7 @@ class FolderLibrary(object):
folders = property(get_folders, set_folders)
def build_keycache(self):
self._keys = self._folders.keys()
self._keys = list(self._folders.keys())
self._keys.sort(key=lambda item: (-len(item), item))
def add_folder(self, url, folder):
@ -59,10 +59,10 @@ class FolderLibrary(object):
logging.error('%s does not seem to be a subpath of %s' % (real_folder, folder))
def print_folders(self):
print '{'
print('{')
for k in self._keys:
print "'%s': '%s'," % (k, self._folders[k])
print '}'
print(("'%s': '%s'," % (k, self._folders[k])))
print('}')
if __name__ == "__main__":
@ -80,5 +80,5 @@ if __name__ == "__main__":
f.add_folder('abc/dub/', 'c:/dubdub')
f.print_folders()
print f.matched_folder('abc/dab/okokok/some.png')
print((f.matched_folder('abc/dab/okokok/some.png')))

View File

@ -4,9 +4,9 @@
import os, logging
from PyQt4 import QtCore, QtGui, QtWebKit, QtNetwork
from django.test import Client
from folders import FolderLibrary
from .folders import FolderLibrary
from django.http.request import QueryDict
from urlparse import urlparse, parse_qs
from urllib.parse import urlparse, parse_qs
import cgi
from io import BytesIO
from django.http.multipartparser import MultiPartParser
@ -126,7 +126,7 @@ class ResourceReply(BasePageReply):
def initialize_content(self, url, operation):
# determine folder:
path = unicode(url.path()).lstrip('/')
path = str(url.path()).lstrip('/')
folders = getattr(self.parent(), 'folders')
if folders:
path = folders.matched_folder(path)
@ -156,7 +156,7 @@ class PageReply(ResourceReply):
c = Client()
logging.info( "Response for %s, method %s" % (url.path(), operation) )
if operation == DejaNetworkAccessManager.GetOperation:
response = c.get(unicode(url.path()), follow=True )
response = c.get(str(url.path()), follow=True )
elif operation == DejaNetworkAccessManager.PostOperation:
ct = str(self.request.rawHeader('Content-Type'))
cl = str(self.request.rawHeader('Content-Length'))
@ -170,11 +170,11 @@ class PageReply(ResourceReply):
},
b,
[]).parse()
response = c.post(unicode(url.path()), q, follow=True)
response = c.post(str(url.path()), q, follow=True)
else:
# assume post data.
q = QueryDict( s )
response = c.post(unicode(url.path()), q, follow=True)
response = c.post(str(url.path()), q, follow=True)
self.content_type = response.get('Content-Type', self.content_type)
# response code
#print "Response Status: %s" % response.status_code

View File

@ -1,5 +1,5 @@
from django.contrib import admin
import models
from . import models
# Register your models here.
admin.site.register(models.Crafting)
admin.site.register(models.CraftingInput)

View File

@ -16,7 +16,7 @@ def build_pk_cache(data, models=None):
pk_cache = {}
# fill cache from existing
for d in data:
if 'pk' in d.keys():
if 'pk' in list(d.keys()):
# has pk
pk_cache[d['model']] = max(pk_cache.get('model', 0), d['pk'])
for d in data:
@ -24,11 +24,11 @@ def build_pk_cache(data, models=None):
if models:
if m not in models:
continue
if 'pk' in d.keys():
if 'pk' in list(d.keys()):
#print "PK was already in there! %s" % d
pass
else:
if m not in pk_cache.keys():
if m not in list(pk_cache.keys()):
pk_cache[m] = 1
i = 1
else:
@ -43,7 +43,7 @@ def lookup_pk(data, name, mdl='scon.item', kwargs=None):
if d['fields'].get('name', '').lower() == name.lower():
found = True
if kwargs is not None:
for key, val in kwargs.items():
for key, val in list(kwargs.items()):
if not d['fields'].get(key, None) == val:
found = False
if found:
@ -559,7 +559,7 @@ def generate_fixtures():
item = recipee
kwargs = None
if isinstance(item, tuple) or isinstance(item, list):
print item
print(item)
kwargs = item[1]
item = item[0]
@ -587,6 +587,6 @@ if __name__ == "__main__":
# check pks:
for d in fixes:
if d.get('pk', None) is None:
print "%s is fail." % d
print(("%s is fail." % d))
write_fixture(fixes)

View File

@ -2,8 +2,8 @@
from django.shortcuts import render
from django.http import HttpResponse
from django.template import RequestContext, loader
import logic
import models
from . import logic
from . import models
def config(request):
t = loader.get_template('scon/config.html')

View File

@ -49,15 +49,15 @@ class ShipInstance(object):
krs = (self.shield_max/100.0 * self.shield_res_kn)
ers = (self.shield_max/100.0 * self.shield_res_em)
trs = (self.shield_max/100.0 * self.shield_res_th)
print "Shield.", krs, ers, trs
print(("Shield.", krs, ers, trs))
krh = (self.hull_max/100.0 * self.hull_res_kn)
erh = (self.hull_max/100.0 * self.hull_res_em)
trh = (self.hull_max/100.0 * self.hull_res_th)
print "Hull.", krh, erh, trh
print(("Hull.", krh, erh, trh))
#print "?1", ((krs+ers+trs+krh+erh+trh)/6.0)+self.shield_max + self.hull_max
print "?2", ((krs+ers+trs+3*self.shield_max)/3.0)+((krh+erh+trh+3*self.hull_max)/3.0)
print(("?2", ((krs+ers+trs+3*self.shield_max)/3.0)+((krh+erh+trh+3*self.hull_max)/3.0)))
# another try:
@ -65,25 +65,25 @@ class ShipInstance(object):
lets assume survivability is really measured through applying 1000 dps for 10 secs.
"""
print "Assuming dps..."
print("Assuming dps...")
shield = self.shield_max
hull = self.hull_max
r1s = shield / (1.0*dam_res(1000, self.shield_res_kn))
r2s = shield / (1.0*dam_res(1000, self.shield_res_em))
r3s = shield / (1.0*dam_res(1000, self.shield_res_th))
print r1s, r2s, r3s
print((r1s, r2s, r3s))
rXs = (r1s+r2s+r3s) / 3.0
print "Shield survival time at 1kdps", rXs
print(("Shield survival time at 1kdps", rXs))
r1h = hull / (1.0*dam_res(1000, self.hull_res_kn))
r2h = hull / (1.0*dam_res(1000, self.hull_res_em))
r3h = hull / (1.0*dam_res(1000, self.hull_res_th))
print r1h, r2h, r3h
print((r1h, r2h, r3h))
rXh = (r1h+r2h+r3h) / 3.0
print "Hull survival time at 1kdps", rXh
print(("Hull survival time at 1kdps", rXh))
print "Total survival time ", rXs + rXh, " sec"
print "Surv should be ", int(round((rXs+rXh) * 1000))
print(("Total survival time ", rXs + rXh, " sec"))
print(("Surv should be ", int(round((rXs+rXh) * 1000))))
@ -92,9 +92,9 @@ class ShipInstance(object):
ship = ShipInstance()
print ship.survivability()
print((ship.survivability()))
print "#" * 80
print(("#" * 80))
mykatanas=ShipInstance(7664, 4296, (70,61,100), (20,80,50))
print "We know its 19736... but own calcs say..."
print mykatanas.survivability()
print("We know its 19736... but own calcs say...")
print((mykatanas.survivability()))

View File

@ -439,6 +439,6 @@ if __name__ == '__main__':
/home/user/Projects/Learning/LearningQt/LearningQt80.png'''
nodes = get_filelist_nodes(files.split('\n'))
for n in nodes:
print n
print(n)
dev_show_file_list(nodes)

View File

@ -13,7 +13,7 @@ import sys
from PyQt4 import QtCore, QtGui, QtWebKit, QtNetwork
from scon.dejaqt.folders import FolderLibrary
from scon.dejaqt.qweb import DejaWebView
from treeview import TreeViewModel, Node
from .treeview import TreeViewModel, Node
class MenuTree(QtGui.QTreeView):
def __init__(self, *args, **kwargs):

View File

@ -70,7 +70,7 @@ class Stacktrace(Log):
@classmethod
def is_handler(cls, log):
# do i have a system crash report beginning here?
if isinstance(log, basestring):
if isinstance(log, str):
l = log.strip()
elif isinstance(log, dict):
l = log.get('log', '').strip()

View File

@ -54,7 +54,7 @@ class ChatLog(Log):
return self.values.get('log', 'Unknown Chat Log')
def clean(self):
if 'log' in self.values.keys():
if 'log' in list(self.values.keys()):
del self.values['log']
class SystemMessage(ChatLog):
@ -71,7 +71,7 @@ class SystemMessage(ChatLog):
def append(self, something):
''' System Messages accept appends '''
if 'message' in self.values.keys():
if 'message' in list(self.values.keys()):
self.values['message'] = '%s\n%s' % (self.values['message'], something)
return True
@ -91,7 +91,7 @@ class PrivateMessageReceived(ChatLog):
def append(self, something):
''' Private Messages accept appends '''
if 'message' in self.values.keys():
if 'message' in list(self.values.keys()):
self.values['message'] = '%s\n%s' % (self.values['message'], something)
return True
@ -109,7 +109,7 @@ class PrivateMessageSent(ChatLog):
def append(self, something):
''' Private Messages accept appends '''
if 'message' in self.values.keys():
if 'message' in list(self.values.keys()):
self.values['message'] = '%s\n%s' % (self.values['message'], something)
return True
@ -127,8 +127,8 @@ class ChatMessage(ChatLog):
def append(self, something):
''' ChatMessages accept appends '''
if not 'message' in self.values.keys():
print "Missing message? %s" % self.values
if not 'message' in list(self.values.keys()):
print(("Missing message? %s" % self.values))
self.values['message'] = ''
self.values['message'] = '%s\n%s' % (self.values['message'], something)
return True

View File

@ -20,7 +20,7 @@
01:04:38.805 CMBT |
"""
import re
from base import Log, L_CMBT, Stacktrace
from .base import Log, L_CMBT, Stacktrace
import logging
class CombatLog(Log):
@ -69,7 +69,7 @@ class CombatLog(Log):
return self.values.get('log', 'Unknown Combat Log')
def clean(self):
if 'log' in self.values.keys():
if 'log' in list(self.values.keys()):
del self.values['log']
@ -219,7 +219,7 @@ class GameEvent(CombatLog):
self.trash = True
def clean(self):
if 'log' in self.values.keys():
if 'log' in list(self.values.keys()):
del self.values['log']
class PVE_Mission(CombatLog):

View File

@ -68,7 +68,7 @@ class GameLog(Log):
self.reviewed = False
def clean(self):
if 'log' in self.values.keys():
if 'log' in list(self.values.keys()):
del self.values['log']
def unpack(self, force=False):

View File

@ -4,10 +4,10 @@
Resolves Logs.
"""
from logfile import LogFile
from combat import COMBAT_LOGS
from game import GAME_LOGS
from chat import CHAT_LOGS
from .logfile import LogFile
from .combat import COMBAT_LOGS
from .game import GAME_LOGS
from .chat import CHAT_LOGS
class LogFileResolver(LogFile):
''' dynamic logfile resolver '''

View File

@ -71,8 +71,8 @@ class LogStream(object):
l.clean()
lines.append(l)
else:
print type(l)
print l
print((type(l)))
print(l)
self.lines = lines
self._unset_data()
@ -82,7 +82,7 @@ class LogStream(object):
self._data = None
def pre_parse_line(self, line):
if not isinstance(line, basestring):
if not isinstance(line, str):
return line
elif line.startswith('---'):
return None
@ -95,7 +95,7 @@ class LogStream(object):
m = R_SCLOG.match(line)
if m:
g = m.groupdict()
if 'logtype' in g.keys():
if 'logtype' in list(g.keys()):
g['logtype'] = g['logtype'].strip()
return g
else:
@ -106,7 +106,7 @@ class LogStream(object):
# add the line to my lines.
if line is not None:
o = line
if isinstance(line, basestring):
if isinstance(line, str):
# Unknown Log?
if not line:
return

View File

@ -2,7 +2,7 @@
Logging Session.
"""
import zipfile, logging, os
from logfiles import CombatLogFile, GameLogFile, ChatLogFile
from .logfiles import CombatLogFile, GameLogFile, ChatLogFile
class LogSession(object):
"""
@ -187,7 +187,7 @@ class LogSessionCollector(object):
self.sessions = self.collect()
sessions_dict = {}
for session in self.sessions:
if session.idstr and not session.idstr in sessions_dict.keys():
if session.idstr and not session.idstr in list(sessions_dict.keys()):
sessions_dict[session.idstr] = session
return sessions_dict
@ -203,7 +203,7 @@ if __name__ == '__main__':
l_zip = LogFileSession('D:\\Users\\g4b\\Documents\\My Games\\sc\\2014.05.20 23.49.19.zip')
l_zip.parse_files()
print l_zip.combat_log.lines
print((l_zip.combat_log.lines))
collector = LogSessionCollector('D:\\Users\\g4b\\Documents\\My Games\\sc\\')
print collector.collect_unique()
print((collector.collect_unique()))

View File

@ -83,14 +83,14 @@ class SconMonitor(object):
def close(self, filename):
# close a single file by key, does not do anything if not found.
if filename in self.files.keys():
if filename in list(self.files.keys()):
close_file = self.files.pop(filename)
close_file['file'].close()
del close_file
def close_all(self):
""" closes all open files in the monitor """
for key in self.files.keys():
for key in list(self.files.keys()):
self.close(key)
def read_line(self, afile):
@ -109,7 +109,7 @@ class SconMonitor(object):
def do(self):
''' Monitor main task handler, call this in your mainloop in ~1 sec intervals '''
# read all file changes.
for key, value in self.files.items():
for key, value in list(self.files.items()):
lines = []
data = self.read_line(value)
while data is not None:

View File

@ -4,9 +4,9 @@
"""
import os, sys, logging
import sys
import urllib2
import urllib.request, urllib.error, urllib.parse
from PyQt4 import QtCore, QtGui
from monitor import SconMonitor
from .monitor import SconMonitor
from PyQt4.QtCore import QObject, pyqtSignal, pyqtSlot
@ -46,7 +46,7 @@ class MainWindow(QtGui.QWidget):
def notify_filelines(self, filename, lines):
if filename not in self.tabs.keys():
if filename not in list(self.tabs.keys()):
new_tab = QtGui.QWidget()
new_tab.list_widget = QtGui.QListWidget()
layout = QtGui.QVBoxLayout(new_tab)
@ -57,9 +57,9 @@ class MainWindow(QtGui.QWidget):
def notify_created(self, filename, is_directory):
if is_directory:
print "Created Directory %s" % filename
print(("Created Directory %s" % filename))
else:
print "Created File %s" % filename
print(("Created File %s" % filename))
def start_monitor(self):
self.button.setDisabled(True)

View File

@ -22,4 +22,4 @@ R_SCLOG = re.compile(RE_SCLOG)
for line in Lines:
m = R_SCLOG.match(line)
if m:
print m.groups()
print((m.groups()))