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

View File

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

View File

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

View File

@ -4,10 +4,10 @@
Tool to analyze Logs in general. Tool to analyze Logs in general.
""" """
import os, sys, logging import os, sys, logging
from logs.logfiles import LogFileResolver as LogFile from .logs.logfiles import LogFileResolver as LogFile
from logs import combat, game, chat from .logs import combat, game, chat
from logs.session import LogSessionCollector from .logs.session import LogSessionCollector
from logs.game import ClientInfo from .logs.game import ClientInfo
# for windows its kinda this: # for windows its kinda this:
settings = {'root_path': os.path.join(os.path.expanduser('~'), settings = {'root_path': os.path.join(os.path.expanduser('~'),
@ -28,6 +28,6 @@ if __name__ == '__main__':
logf.parse_files(['game.log', 'combat.log']) logf.parse_files(['game.log', 'combat.log'])
logf.clean() logf.clean()
if logf.combat_log: 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: 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 #from win32com.shell import shell, shellcon
import os, sys, logging import os, sys, logging
from logs.logfiles import LogFileResolver as LogFile from .logs.logfiles import LogFileResolver as LogFile
from logs import combat from .logs import combat
# for windows its kinda this: # for windows its kinda this:
settings = {'root_path': os.path.join(os.path.expanduser('~'), settings = {'root_path': os.path.join(os.path.expanduser('~'),
@ -78,8 +78,8 @@ if __name__ == '__main__':
if not l.unpack(): if not l.unpack():
rex[l.__class__.__name__] = rex.get(l.__class__.__name__, 0) + 1 rex[l.__class__.__name__] = rex.get(l.__class__.__name__, 0) + 1
if not isinstance(l, combat.UserEvent): if not isinstance(l, combat.UserEvent):
print l.values['log'] print((l.values['log']))
#f.write(l.values['log'] + '\n') #f.write(l.values['log'] + '\n')
#f.close() #f.close()
#print type(l) #print type(l)
print rex print(rex)

View File

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

View File

@ -13,13 +13,13 @@ class Settings(dict):
'My Games', 'My Games',
'StarConflict',) 'StarConflict',)
elif system == 'Linux': elif system == 'Linux':
raise NotImplementedError, "Implement Linux!" raise NotImplementedError("Implement Linux!")
elif system == 'Darwin': elif system == 'Darwin':
raise NotImplementedError, "Implement Mac!" raise NotImplementedError("Implement Mac!")
else: 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): 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 self['root_path'] = d
def get_path(self): def get_path(self):

View File

@ -31,7 +31,7 @@ class FolderLibrary(object):
folders = property(get_folders, set_folders) folders = property(get_folders, set_folders)
def build_keycache(self): def build_keycache(self):
self._keys = self._folders.keys() self._keys = list(self._folders.keys())
self._keys.sort(key=lambda item: (-len(item), item)) self._keys.sort(key=lambda item: (-len(item), item))
def add_folder(self, url, folder): 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)) logging.error('%s does not seem to be a subpath of %s' % (real_folder, folder))
def print_folders(self): def print_folders(self):
print '{' print('{')
for k in self._keys: for k in self._keys:
print "'%s': '%s'," % (k, self._folders[k]) print(("'%s': '%s'," % (k, self._folders[k])))
print '}' print('}')
if __name__ == "__main__": if __name__ == "__main__":
@ -80,5 +80,5 @@ if __name__ == "__main__":
f.add_folder('abc/dub/', 'c:/dubdub') f.add_folder('abc/dub/', 'c:/dubdub')
f.print_folders() 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 import os, logging
from PyQt4 import QtCore, QtGui, QtWebKit, QtNetwork from PyQt4 import QtCore, QtGui, QtWebKit, QtNetwork
from django.test import Client from django.test import Client
from folders import FolderLibrary from .folders import FolderLibrary
from django.http.request import QueryDict from django.http.request import QueryDict
from urlparse import urlparse, parse_qs from urllib.parse import urlparse, parse_qs
import cgi import cgi
from io import BytesIO from io import BytesIO
from django.http.multipartparser import MultiPartParser from django.http.multipartparser import MultiPartParser
@ -126,7 +126,7 @@ class ResourceReply(BasePageReply):
def initialize_content(self, url, operation): def initialize_content(self, url, operation):
# determine folder: # determine folder:
path = unicode(url.path()).lstrip('/') path = str(url.path()).lstrip('/')
folders = getattr(self.parent(), 'folders') folders = getattr(self.parent(), 'folders')
if folders: if folders:
path = folders.matched_folder(path) path = folders.matched_folder(path)
@ -156,7 +156,7 @@ class PageReply(ResourceReply):
c = Client() c = Client()
logging.info( "Response for %s, method %s" % (url.path(), operation) ) logging.info( "Response for %s, method %s" % (url.path(), operation) )
if operation == DejaNetworkAccessManager.GetOperation: if operation == DejaNetworkAccessManager.GetOperation:
response = c.get(unicode(url.path()), follow=True ) response = c.get(str(url.path()), follow=True )
elif operation == DejaNetworkAccessManager.PostOperation: elif operation == DejaNetworkAccessManager.PostOperation:
ct = str(self.request.rawHeader('Content-Type')) ct = str(self.request.rawHeader('Content-Type'))
cl = str(self.request.rawHeader('Content-Length')) cl = str(self.request.rawHeader('Content-Length'))
@ -170,11 +170,11 @@ class PageReply(ResourceReply):
}, },
b, b,
[]).parse() []).parse()
response = c.post(unicode(url.path()), q, follow=True) response = c.post(str(url.path()), q, follow=True)
else: else:
# assume post data. # assume post data.
q = QueryDict( s ) 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) self.content_type = response.get('Content-Type', self.content_type)
# response code # response code
#print "Response Status: %s" % response.status_code #print "Response Status: %s" % response.status_code

View File

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

View File

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

View File

@ -2,8 +2,8 @@
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
from django.template import RequestContext, loader from django.template import RequestContext, loader
import logic from . import logic
import models from . import models
def config(request): def config(request):
t = loader.get_template('scon/config.html') 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) krs = (self.shield_max/100.0 * self.shield_res_kn)
ers = (self.shield_max/100.0 * self.shield_res_em) ers = (self.shield_max/100.0 * self.shield_res_em)
trs = (self.shield_max/100.0 * self.shield_res_th) 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) krh = (self.hull_max/100.0 * self.hull_res_kn)
erh = (self.hull_max/100.0 * self.hull_res_em) erh = (self.hull_max/100.0 * self.hull_res_em)
trh = (self.hull_max/100.0 * self.hull_res_th) 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 "?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: # another try:
@ -65,25 +65,25 @@ class ShipInstance(object):
lets assume survivability is really measured through applying 1000 dps for 10 secs. lets assume survivability is really measured through applying 1000 dps for 10 secs.
""" """
print "Assuming dps..." print("Assuming dps...")
shield = self.shield_max shield = self.shield_max
hull = self.hull_max hull = self.hull_max
r1s = shield / (1.0*dam_res(1000, self.shield_res_kn)) r1s = shield / (1.0*dam_res(1000, self.shield_res_kn))
r2s = shield / (1.0*dam_res(1000, self.shield_res_em)) r2s = shield / (1.0*dam_res(1000, self.shield_res_em))
r3s = shield / (1.0*dam_res(1000, self.shield_res_th)) 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 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)) r1h = hull / (1.0*dam_res(1000, self.hull_res_kn))
r2h = hull / (1.0*dam_res(1000, self.hull_res_em)) r2h = hull / (1.0*dam_res(1000, self.hull_res_em))
r3h = hull / (1.0*dam_res(1000, self.hull_res_th)) 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 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(("Total survival time ", rXs + rXh, " sec"))
print "Surv should be ", int(round((rXs+rXh) * 1000)) print(("Surv should be ", int(round((rXs+rXh) * 1000))))
@ -92,9 +92,9 @@ class ShipInstance(object):
ship = ShipInstance() ship = ShipInstance()
print ship.survivability() print((ship.survivability()))
print "#" * 80 print(("#" * 80))
mykatanas=ShipInstance(7664, 4296, (70,61,100), (20,80,50)) mykatanas=ShipInstance(7664, 4296, (70,61,100), (20,80,50))
print "We know its 19736... but own calcs say..." print("We know its 19736... but own calcs say...")
print mykatanas.survivability() print((mykatanas.survivability()))

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
Logging Session. Logging Session.
""" """
import zipfile, logging, os import zipfile, logging, os
from logfiles import CombatLogFile, GameLogFile, ChatLogFile from .logfiles import CombatLogFile, GameLogFile, ChatLogFile
class LogSession(object): class LogSession(object):
""" """
@ -187,7 +187,7 @@ class LogSessionCollector(object):
self.sessions = self.collect() self.sessions = self.collect()
sessions_dict = {} sessions_dict = {}
for session in self.sessions: 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 sessions_dict[session.idstr] = session
return sessions_dict 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 = LogFileSession('D:\\Users\\g4b\\Documents\\My Games\\sc\\2014.05.20 23.49.19.zip')
l_zip.parse_files() 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\\') 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): def close(self, filename):
# close a single file by key, does not do anything if not found. # 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 = self.files.pop(filename)
close_file['file'].close() close_file['file'].close()
del close_file del close_file
def close_all(self): def close_all(self):
""" closes all open files in the monitor """ """ closes all open files in the monitor """
for key in self.files.keys(): for key in list(self.files.keys()):
self.close(key) self.close(key)
def read_line(self, afile): def read_line(self, afile):
@ -109,7 +109,7 @@ class SconMonitor(object):
def do(self): def do(self):
''' Monitor main task handler, call this in your mainloop in ~1 sec intervals ''' ''' Monitor main task handler, call this in your mainloop in ~1 sec intervals '''
# read all file changes. # read all file changes.
for key, value in self.files.items(): for key, value in list(self.files.items()):
lines = [] lines = []
data = self.read_line(value) data = self.read_line(value)
while data is not None: while data is not None:

View File

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

View File

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