Beispiel #1
0
    def _to_valuespec(self, tp_spec):
        if not tp_spec:
            return {}

        exceptions = []
        for exception_name, time_ranges in tp_spec.items():
            if exception_name not in defines.weekday_ids() + [
                    "alias", "exclude"
            ]:
                exceptions.append(
                    (exception_name,
                     self._time_ranges_to_valuespec(time_ranges)))

        vs_spec = {
            "name":
            unique_default_name_suggestion(self._name or "time_period",
                                           list(self._timeperiods.keys())),
            "alias":
            timeperiod_spec_alias(tp_spec),
            "weekdays":
            self._weekdays_to_valuespec(tp_spec),
            "exclude":
            tp_spec.get("exclude", []),
            "exceptions":
            sorted(exceptions),
        }

        return vs_spec
Beispiel #2
0
 def _default_id(self) -> str:
     return unique_default_name_suggestion(
         self._mode_type.name_singular(),
         self._store.load_for_reading().keys(),
     )
Beispiel #3
0
def test_urlencode_vars(template, used_names, suggestion):
    assert unique_default_name_suggestion(template, used_names) == suggestion