def vs_conditions():
    return Transform(
        valuespec=VSExplicitConditions(rulespec=dummy_rulespec(),
                                       render="form_part"),
        forth=lambda c: RuleConditions("").from_config(c),
        back=lambda c: c.to_config_with_folder(),
    )
Beispiel #2
0
    def _save(self, entries):
        old_path = self._store.load_for_reading()[
            self._ident]["conditions"]["folder_path"]
        conditions = RuleConditions(**entries[self._ident]["conditions"])

        super(ModeEditPredefinedCondition, self)._save(entries)

        if old_path != conditions.folder_path:
            self._move_rules_for_conditions(conditions, old_path)

        self._rewrite_rules_for(conditions)
Beispiel #3
0
    def _save(self, entries):
        # In case it already existed before, remember the previous path
        old_entries = self._store.load_for_reading()
        old_path = None
        if self._ident in old_entries:
            old_path = self._store.load_for_reading()[self._ident]["conditions"]["host_folder"]

        super(ModeEditPredefinedCondition, self)._save(entries)

        conditions = RuleConditions(None).from_config(entries[self._ident]["conditions"])

        # Update rules of source folder in case the folder was changed
        if old_path is not None and old_path != conditions.host_folder:
            self._move_rules_for_conditions(conditions, old_path)

        self._rewrite_rules_for(conditions)
Beispiel #4
0
def vs_conditions():
    return Transform(
        VSExplicitConditions(rulespec=dummy_rulespec(), render="form_part"),
        forth=lambda c: RuleConditions(**c),
        back=lambda c: dict(c._asdict()),
    )