Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Userspace rules are not merged. #399

Closed
LexiconCode opened this issue Mar 7, 2019 · 0 comments
Closed

Userspace rules are not merged. #399

LexiconCode opened this issue Mar 7, 2019 · 0 comments
Labels
Bug Unexpected behavior from existing features.

Comments

@LexiconCode
Copy link
Member

LexiconCode commented Mar 7, 2019

The user space. It appears in ~/.caster/rules

.py files in ~/.caster/rules require a get_rule method. .py files in ~/.caster/filters require a get_filter

Example user rule in the user space:

from dragonfly import Text

from castervoice.lib import control
from castervoice.lib.dfplus.merge.mergerule import MergeRule
from castervoice.lib.dfplus.state.short import R

class Decker(MergeRule):
    pronunciation = "decker"

    mapping = {
        "hit the deck": R(Text("shipwrecked"))
    }

def get_rule():
    return Decker()

get_rule should a load and merge the grammar. Currently this is not the case.

However when control.nexus().merger.add_global_rule(Decker()) with get_rule results in a Rule Naming Conflict (Which is expected with a duplicate rule). It seems to suggest that the rule is loaded but not merged?

Error loading _caster from E:\NatLink\NatLink\MacroSystem\_caster.py
Traceback (most recent call last):
  File "E:\NatLink\NatLink\MacroSystem\core\natlinkmain.py", line 331, in loadFile
    imp.load_module(modName,fndFile,fndName,fndDesc)
  File "E:\NatLink\NatLink\MacroSystem\_caster.py", line 254, in <module>
    _NEXUS.process_user_content()
  File "E:\NatLink\NatLink\MacroSystem\castervoice\lib\ctrl\nexus.py", line 45, in process_user_content
    self.merger.add_user_content(self.user_content_manager)
  File "E:\NatLink\NatLink\MacroSystem\castervoice\lib\dfplus\merge\ccrmerger.py", line 142, in add_user_content
    self.add_global_rule(rule)
  File "E:\NatLink\NatLink\MacroSystem\castervoice\lib\dfplus\merge\ccrmerger.py", line 115, in add_global_rule
    self._add_to(rule, self._global_rules)
  File "E:\NatLink\NatLink\MacroSystem\castervoice\lib\dfplus\merge\ccrmerger.py", line 151, in _add_to
    raise Exception("Rule Naming Conflict: " + rule.get_pronunciation())
Exception: Rule Naming Conflict: decker
@LexiconCode LexiconCode added the Bug Unexpected behavior from existing features. label Mar 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Unexpected behavior from existing features.
Projects
None yet
Development

No branches or pull requests

1 participant