Example #1
0
    def update(self,parser_out_stream = sys.stdout,progress = None):
        """Update the load order based on input rules."""
        self.is_sorted = False
        self.graph = pluggraph.pluggraph()
        if self.order == []:
            order_logger.error("No plugins detected! mlox needs to run somewhere under where the game is installed.")
            return
        order_logger.debug("Initial load order:")
        for p in self.get_original_order():
            order_logger.debug("  " + p)


        # read rules from various sources, and add orderings to graph
        # if any subsequent rule causes a cycle in the current graph, it is discarded
        parser = ruleParser.rule_parser(self.active, self.graph, self.datadir,parser_out_stream,self.caseless)
        if os.path.exists(user_file):
            parser.read_rules(user_file, progress)
        if not parser.read_rules(base_file, progress):
            order_logger.error("Unable to parse 'mlox_base.txt', load order NOT sorted!")
            self.new_order = []
            return

        # now do the topological sort of all known plugins (rules + load order)
        self.add_current_order() # tertiary order "pseudo-rules" from current load order
        sorted = self.graph.topo_sort()

        # the "sorted" list will be a superset of all known plugin files,
        # inluding those in our Data Files directory.
        # but we only want to update plugins that are in our current "Data Files"
        sorted_datafiles = [f for f in sorted if f in self.active]
        (esm_files, esp_files) = configHandler.partition_esps_and_esms(sorted_datafiles)
        new_order_cname = [p for p in esm_files + esp_files]
        self.new_order = [self.caseless.truename(p) for p in new_order_cname]

        order_logger.debug("New load order:")
        for p in self.get_new_order():
            order_logger.debug("  " + p)

        if len(self.new_order) != len(self.order):
            order_logger.error("sanity check: len(self.new_order %d) != len(self.order %d)" % (len(self.new_order), len(self.order)))
            self.new_order = []
            return

        if self.order == new_order_cname:
            order_logger.info("[Plugins already in sorted order. No sorting needed!]")
            self.is_sorted = True

        if self.datadir != None:
            # these are things we do not want to do if just testing a load order from a file
            # save the load orders to file for future reference
            self.save_order(old_loadorder_output, [self.caseless.truename(p) for p in self.order], "current")
            self.save_order(new_loadorder_output, self.new_order, "mlox sorted")
        return
Example #2
0
    def __init__(self):
        # order is the list of plugins in Data Files, ordered by mtime
        self.active = {}                   # current active plugins
        self.order = []                    # the load order
        self.new_order = []                # the new load order
        self.datadir = None                # where plugins live
        self.plugin_file = None            # Path to the file containing the plugin list
        self.graph = pluggraph.pluggraph()
        self.is_sorted = False
        self.origin = None                 # where plugins came from (active, installed, file)
        self.game_type = None              # 'Morrowind', 'Oblivion', or None for unknown
        self.caseless = fileFinder.caseless_filenames()

        self.game_type, self.plugin_file, self.datadir = fileFinder.find_game_dirs()
Example #3
0
    def explain(self,plugin_name,base_only = False):
        """Expalin why a mod is in it's current position"""
        original_graph = self.graph
        self.graph = pluggraph.pluggraph()

        parser = ruleParser.rule_parser(self.active, self.graph, self.datadir,StringIO.StringIO(),self.caseless)
        if os.path.exists(user_file):
            parser.read_rules(user_file)
        parser.read_rules(base_file)

        if not base_only:
            self.add_current_order() # tertiary order "pseudo-rules" from current load order
        output = self.graph.explain(plugin_name, self.active)

        self.graph = original_graph
        return output
Example #4
0
dirHandler = configHandler.dataDirHandler("./test1.data/")
print "\x1b[0;30;41m" + "Reading dirHandler" + '\x1b[0m'
plugins = dirHandler.read()
print plugins
print "\x1b[0;30;41m" + "Writing dirHandler" + '\x1b[0m'
dirHandler.write(plugins)


logging.getLogger('').setLevel(logging.INFO)

#Parser, ang pluggraph
import modules.ruleParser as ruleParser
import modules.pluggraph as pluggraph
print "\x1b[0;30;41m" + "Testing parser on dirHandler plugins" + '\x1b[0m'
graph = pluggraph.pluggraph()
myParser = ruleParser.rule_parser(plugins,graph,"./test1.data/",sys.stdout,file_names)
myParser.read_rules("./test1.data/mlox_base.txt")
print graph.topo_sort()
print "\x1b[0;30;41m" + "Testing filename version" + '\x1b[0m'
(f_ver,d_ver) = ruleParser.get_version("BB_Clothiers_of_Vvardenfell_v1.1.esp","./test1.data/")
print (f_ver,d_ver,"BB_Clothiers_of_Vvardenfell_v1.1.esp")

#Load order
from modules.loadOrder import loadorder
print "\x1b[0;30;41m" + "Testing loadorder 1" + '\x1b[0m'
l1 = loadorder()
l1.datadir = fileFinder.caseless_dirlist("./test1.data/")
l1.plugin_file = "./userfiles/abot.txt"
l1.game_type = None
l1.get_active_plugins()