refactoring, some readmes.
This commit is contained in:
		
							parent
							
								
									ec852c3b0e
								
							
						
					
					
						commit
						b25095001b
					
				@ -2,8 +2,15 @@ import os
 | 
			
		||||
import platform
 | 
			
		||||
 | 
			
		||||
class Settings(dict): 
 | 
			
		||||
    # note that settings is a dict.
 | 
			
		||||
    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
 | 
			
		||||
        system = platform.system()
 | 
			
		||||
        if system == 'Windows' or system.startswith('CYGWIN_NT'):
 | 
			
		||||
@ -13,19 +20,27 @@ class Settings(dict):
 | 
			
		||||
                                     'My Games',
 | 
			
		||||
                                     'StarConflict',)
 | 
			
		||||
        elif system == 'Linux':
 | 
			
		||||
            raise NotImplementedError("Implement Linux!")
 | 
			
		||||
            d = d or os.path.join(os.path.expanduser('~'), '.local', 'share', 'starconflict')
 | 
			
		||||
        elif system == 'Darwin':
 | 
			
		||||
            raise NotImplementedError("Implement Mac!")
 | 
			
		||||
            if not d:
 | 
			
		||||
                raise NotImplementedError("Implement Mac!")
 | 
			
		||||
        else:
 | 
			
		||||
            raise NotImplementedError("Unknown System! %s" % platform.system())
 | 
			
		||||
            if not d:
 | 
			
		||||
                raise NotImplementedError("Unknown System! %s" % platform.system())
 | 
			
		||||
        if not os.path.exists(d) or not os.path.isdir(d):
 | 
			
		||||
            raise Exception("Configuration Autodetection failed. ")
 | 
			
		||||
        self['root_path'] = d
 | 
			
		||||
            return False
 | 
			
		||||
        self['config_path'] = os.path.abspath(d)
 | 
			
		||||
        return True
 | 
			
		||||
        
 | 
			
		||||
    def get_path(self):
 | 
			
		||||
        return self.get('root_path', None)
 | 
			
		||||
    def get_config_path(self):
 | 
			
		||||
        """ gets the config_path if set, otherwise None. """
 | 
			
		||||
        return self.get('config_path', None)
 | 
			
		||||
    
 | 
			
		||||
    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()
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										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)
 | 
			
		||||
            parent.appendRow(child_item)
 | 
			
		||||
            if isinstance(children, dict):
 | 
			
		||||
                
 | 
			
		||||
                if isinstance(children[child], dict):
 | 
			
		||||
                    self._populateTree(children[child], child_item)
 | 
			
		||||
                
 | 
			
		||||
@ -47,6 +46,7 @@ class SessionTreeView(Qt.QTreeView):
 | 
			
		||||
                session.parse_files(['game.log'])
 | 
			
		||||
                info_object = Qt.QStandardItem('game.log - %s' % len(session.game_log.lines))
 | 
			
		||||
                info_object.setEditable(False)
 | 
			
		||||
                game_sessions = 0
 | 
			
		||||
                item.appendRow(info_object)
 | 
			
		||||
                #
 | 
			
		||||
                # add all starting events
 | 
			
		||||
@ -54,11 +54,13 @@ class SessionTreeView(Qt.QTreeView):
 | 
			
		||||
                    if isinstance(line, game.StartingLevel):
 | 
			
		||||
                        line.unpack()
 | 
			
		||||
                        v = line.values
 | 
			
		||||
                        o = Qt.QStandardItem("Level '%s' gametype '%s'" %( v.get('level'),
 | 
			
		||||
                                                                       v.get('gametype', '') ))
 | 
			
		||||
                        level = v.get('level')
 | 
			
		||||
                        o = Qt.QStandardItem("Level '%s' gametype '%s'" %( level, v.get('gametype', '') ))
 | 
			
		||||
                        if 'mainmenu' not in level:
 | 
			
		||||
                            game_sessions += 1
 | 
			
		||||
                        o.setEditable(False)
 | 
			
		||||
                        info_object.appendRow(o)
 | 
			
		||||
                
 | 
			
		||||
                info_object.setText('game.log - %s games' % (game_sessions,))
 | 
			
		||||
                return
 | 
			
		||||
                session.parse_files(['combat.log'])
 | 
			
		||||
                info_object = Qt.QStandardItem('combat.log - %s' % len(session.combat_log.lines))
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user