Exemple #1
0
 def __init__(self, name="Unnamed"):
     Profile.__init__(self, ActionParser())
     self.name = name
     self.next_menu_id = 1
     self.action_set_id = 0
     self.action_sets = {'default': self}
     self.action_set_switches = set()
    def _add_refereced_menu(self, model, menu_id, used):
        """
		As _add_refereced_profile, but reads and parses menu file.
		"""
        if "." in menu_id and menu_id not in used:
            # Dot in id means filename
            used.add(menu_id)
            filename = find_menu(menu_id)
            name = ".".join(menu_id.split(".")[0:-1])
            if name.startswith(".") and menu_is_default(menu_id):
                # Default and hidden, don't bother user with it
                return
            if filename:
                model.append((not menu_is_default(menu_id), _("Menu"), name,
                              filename, True, self.TP_MENU))
                try:
                    menu = MenuData.from_file(filename, ActionParser())
                except Exception, e:
                    # Menu that cannot be parsed shouldn't be exported
                    log.error(e)
                    return
                for item in menu:
                    if isinstance(item, Submenu):
                        self._add_refereced_menu(
                            model,
                            os.path.split(item.filename)[-1], used)
                    if hasattr(item, "action"):
                        self._parse_action(model, item.action, used)
            else:
                model.append((False, _("Menu"), _("%s (not found)") % (name, ),
                              "", False, self.TP_MENU))
 def export_menu(tar, filename):
     try:
         menu = MenuData.from_json_data(
             json.loads(open(filename, "r").read()), ActionParser())
         tar.add(filename,
                 arcname=os.path.split(filename)[-1],
                 recursive=False)
     except Exception, e:
         # Menu that cannot be parsed shouldn't be exported
         log.error(e)
         return False
	def parse(self):
		"""
		Returns parsed action or None if action cannot be parsed.
		"""
		try:
			a = ActionParser.parse(self)
			a.string = self.string
			return a
		except ParseError, e:
			log.error("Failed to parse '%s'", self.string)
			log.error(e)
			return InvalidAction(self.string, e)
Exemple #5
0
	def parse(self):
		"""
		Returns parsed action or None if action cannot be parsed.
		"""
		try:
			a = ActionParser.parse(self)
			a.string = self.string
			return a
		except ParseError, e:
			log.error("Failed to parse '%s'", self.string)
			log.error(e)
			return InvalidAction(self.string, e)
    def _add_refereced_profile(self, model, giofile, used):
        """
		Loads profile file and recursively adds all profiles and menus
		referenced by it into 'package' list.
		
		Returns True on success or False if something cannot be parsed.
		"""
        # Load & parse selected profile and check every action in it
        profile = Profile(ActionParser())
        try:
            profile.load(giofile.get_path())
        except Exception, e:
            # Profile that cannot be parsed shouldn't be exported
            log.error(e)
            return False
	def restart(self, string):
		self.string = string
		return ActionParser.restart(self, string)
Exemple #8
0
from scc.uinput import Keys, Axes, Rels
from scc.constants import SCButtons, HapticPos
from scc.modifiers import DoubleclickModifier
from scc.actions import Action, AxisAction
from scc.macros import Macro
from scc.parser import ActionParser

parser = ActionParser()

CASES = {
	# Contains all test cases that are tested by
	# test_sensitivity and test_feedback
	# This should contain key for every Action that supports setting feedback
	# or sensitivity. test_tests method tests whether it realy does.
	'axis'  : {
		'action' : 'axis(ABS_RX)',
		'sensitivity' : (2.0,)
	},
	'raxis'  : {
		'action' : 'axis(ABS_RX)',
		'sensitivity' : (2.0,)
	},
	'mouse' : {
		'action' : 'mouse',
		'sensitivity' : (2.0, 3.0,),
		'feedback' : ('BOTH',)
	},
	'mouseabs' : {
		'action' : 'mouseabs(REL_X)',
		'sensitivity' : (2.0, 3.0,)
	},
Exemple #9
0
	def restart(self, string):
		self.string = string
		return ActionParser.restart(self, string)