refactoring, some readmes.
This commit is contained in:
parent
ec852c3b0e
commit
b25095001b
@ -2,8 +2,15 @@ import os
|
|||||||
import platform
|
import platform
|
||||||
|
|
||||||
class Settings(dict):
|
class Settings(dict):
|
||||||
|
# note that settings is a dict.
|
||||||
def autodetect(self, path=None):
|
def autodetect(self, path=None):
|
||||||
# autodetect settings.
|
""" autodetects config_path, returns True on success.
|
||||||
|
if a path is given, it is set to it, as far as it exists.
|
||||||
|
"""
|
||||||
|
# this code is mostly in here to remember how to check Operation Systems,
|
||||||
|
# if the project ever needs releasable binaries.
|
||||||
|
# following code tries autodetecting star conflict user file folder
|
||||||
|
#
|
||||||
d = path
|
d = path
|
||||||
system = platform.system()
|
system = platform.system()
|
||||||
if system == 'Windows' or system.startswith('CYGWIN_NT'):
|
if system == 'Windows' or system.startswith('CYGWIN_NT'):
|
||||||
@ -13,19 +20,27 @@ class Settings(dict):
|
|||||||
'My Games',
|
'My Games',
|
||||||
'StarConflict',)
|
'StarConflict',)
|
||||||
elif system == 'Linux':
|
elif system == 'Linux':
|
||||||
raise NotImplementedError("Implement Linux!")
|
d = d or os.path.join(os.path.expanduser('~'), '.local', 'share', 'starconflict')
|
||||||
elif system == 'Darwin':
|
elif system == 'Darwin':
|
||||||
|
if not d:
|
||||||
raise NotImplementedError("Implement Mac!")
|
raise NotImplementedError("Implement Mac!")
|
||||||
else:
|
else:
|
||||||
|
if not d:
|
||||||
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. ")
|
return False
|
||||||
self['root_path'] = d
|
self['config_path'] = os.path.abspath(d)
|
||||||
|
return True
|
||||||
|
|
||||||
def get_path(self):
|
def get_config_path(self):
|
||||||
return self.get('root_path', None)
|
""" gets the config_path if set, otherwise None. """
|
||||||
|
return self.get('config_path', None)
|
||||||
|
|
||||||
def get_logs_path(self):
|
def get_logs_path(self):
|
||||||
return os.path.join(self.get_path, 'logs')
|
""" gets the logfolder in the config_path or None. """
|
||||||
|
p = self.get_config_path()
|
||||||
|
if p:
|
||||||
|
return os.path.join(p, 'logs')
|
||||||
|
return None
|
||||||
|
|
||||||
settings = Settings()
|
settings = Settings()
|
||||||
|
5
src/scon/dj/readme.rst
Normal file
5
src/scon/dj/readme.rst
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
DJ Module
|
||||||
|
---------
|
||||||
|
|
||||||
|
This is a small django project inside scon, considered deprecated.
|
||||||
|
You might fish some stuff in here.
|
10
src/scon/game/readme.rst
Normal file
10
src/scon/game/readme.rst
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
Game Submodule
|
||||||
|
--------------
|
||||||
|
|
||||||
|
This is the submodule that is intended to make a higher level api for scon.
|
||||||
|
While scon.logs is dealing with the parsing itself, scon.game should offer tools to quickly understand common parts of the data.
|
||||||
|
This includes:
|
||||||
|
- determining the user
|
||||||
|
- creating base classes for different game modes
|
||||||
|
|
||||||
|
*This Level of the API is work in progress and atm. not usable in this package*
|
1
src/scon/gui/readme.rst
Normal file
1
src/scon/gui/readme.rst
Normal file
@ -0,0 +1 @@
|
|||||||
|
Atm. the GUI submodule is only a few example scripts and tests.
|
28
src/scon/logs/readme.rst
Normal file
28
src/scon/logs/readme.rst
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
Logs Submodule
|
||||||
|
==============
|
||||||
|
|
||||||
|
The Logs Submodule is the core parsing mechanism in Scon.
|
||||||
|
It defines classes for opening logfiles from zips, directories, or as a stream, and are intended to be used by higher level apis to adjust to the wanted log retrieval scenario, while keeping the base logic how logs are interpreted unified.
|
||||||
|
|
||||||
|
For the programmer, following submodules are of particular interest
|
||||||
|
|
||||||
|
Game
|
||||||
|
----
|
||||||
|
|
||||||
|
Contains all the Packets occuring in game.log; from an interpretation perspective, this holds data of joining games.
|
||||||
|
|
||||||
|
Combat
|
||||||
|
------
|
||||||
|
|
||||||
|
Contains all the Combat Packets, occuring during gameplay of any sort. From an interpretation perspective, this holds the juicy data about pew pew.
|
||||||
|
|
||||||
|
Chat
|
||||||
|
----
|
||||||
|
|
||||||
|
Contains chat packets.
|
||||||
|
|
||||||
|
Session
|
||||||
|
-------
|
||||||
|
|
||||||
|
This is the module holding the session collector, trying to make it easy to access your logs and parse them.
|
||||||
|
|
@ -19,7 +19,6 @@ class SessionTreeView(Qt.QTreeView):
|
|||||||
#child_item.clicked.connect(self.onClickItem)
|
#child_item.clicked.connect(self.onClickItem)
|
||||||
parent.appendRow(child_item)
|
parent.appendRow(child_item)
|
||||||
if isinstance(children, dict):
|
if isinstance(children, dict):
|
||||||
|
|
||||||
if isinstance(children[child], dict):
|
if isinstance(children[child], dict):
|
||||||
self._populateTree(children[child], child_item)
|
self._populateTree(children[child], child_item)
|
||||||
|
|
||||||
@ -47,6 +46,7 @@ class SessionTreeView(Qt.QTreeView):
|
|||||||
session.parse_files(['game.log'])
|
session.parse_files(['game.log'])
|
||||||
info_object = Qt.QStandardItem('game.log - %s' % len(session.game_log.lines))
|
info_object = Qt.QStandardItem('game.log - %s' % len(session.game_log.lines))
|
||||||
info_object.setEditable(False)
|
info_object.setEditable(False)
|
||||||
|
game_sessions = 0
|
||||||
item.appendRow(info_object)
|
item.appendRow(info_object)
|
||||||
#
|
#
|
||||||
# add all starting events
|
# add all starting events
|
||||||
@ -54,11 +54,13 @@ class SessionTreeView(Qt.QTreeView):
|
|||||||
if isinstance(line, game.StartingLevel):
|
if isinstance(line, game.StartingLevel):
|
||||||
line.unpack()
|
line.unpack()
|
||||||
v = line.values
|
v = line.values
|
||||||
o = Qt.QStandardItem("Level '%s' gametype '%s'" %( v.get('level'),
|
level = v.get('level')
|
||||||
v.get('gametype', '') ))
|
o = Qt.QStandardItem("Level '%s' gametype '%s'" %( level, v.get('gametype', '') ))
|
||||||
|
if 'mainmenu' not in level:
|
||||||
|
game_sessions += 1
|
||||||
o.setEditable(False)
|
o.setEditable(False)
|
||||||
info_object.appendRow(o)
|
info_object.appendRow(o)
|
||||||
|
info_object.setText('game.log - %s games' % (game_sessions,))
|
||||||
return
|
return
|
||||||
session.parse_files(['combat.log'])
|
session.parse_files(['combat.log'])
|
||||||
info_object = Qt.QStandardItem('combat.log - %s' % len(session.combat_log.lines))
|
info_object = Qt.QStandardItem('combat.log - %s' % len(session.combat_log.lines))
|
||||||
|
Loading…
Reference in New Issue
Block a user