Пример #1
0
    def __init__(self, bookmark_file = ""):
        # Dictionary for the 'set' command
        self.variables = { "threshold" : "0.75",
                           "bookmarks" : pybookmark.get_conf_location(),
                           "strict" : "1",
                           "symlink": "0",
                           "exec_best" : "mv %file% %match%",
                           "exec_latter" : "ln -s %file% %match%",
                           "exec_unmatched" : "",
                           "handle_directories": "2",
                           "retain_structure": "1",
                           "loglevel": str(common.loglevel),
                           }
        self.parsers = [ y() for y in RuleParsers.__dict__.values() if \
                            type(y) == type(RuleParsers.Parser) and \
                            issubclass(y, RuleParsers.Parser) and \
                            y != RuleParsers.Parser ] 
        

        self.rules = []

        rweight = "\(\ *w(eight)?\ *=\ *([0-9]*[\.[0-9]*]?)\ *\)"
        rvariable = "^\ *([A-Z]+[A-Z0-9_]*)\ *=\ *(.*)\ *$"

        self.re_weight = re.compile(rweight, re.IGNORECASE)
        self.re_variable = re.compile(rvariable, re.IGNORECASE)

        self.set_bookmarks(bookmark_file)
Пример #2
0
    def set_bookmarks(self, bookmarks):
        """Load bookmark file"""

        if bookmarks == "":
            if hasattr(self.variables, "bookmarks"):
                bookmarks = self.variables["bookmarks"]
            else:
                bookmarks = pybookmark.get_conf_location()

        common.debug("Reading bookmarks from %s" % bookmarks)
        self.bookmarks = pybookmark.read_bookmarks(bookmarks)
        self.variables["bookmarks"] = bookmarks