def _save_options(self):

    options = dict(LABEL_DEFAULTS)

    for widget in self.option_widgets:
      prefix, sep, name = widget.get_name().partition("_")
      if sep and name in options:
        widget_type = type(widget)
        if widget_type in OP_MAP:
          getter = getattr(widget, OP_MAP[widget_type][1])
          options[name] = getter()

    for rb in self.rgrp_move_data_completed:
      if rb.get_active():
        prefix, sep, mode = rb.get_name().rpartition("_")
        options["move_data_completed_mode"] = mode

        break

    lines = textview_get_text(self.we.tv_auto_queries).split("\n")
    options["auto_queries"] = [x.strip() for x in lines if x.strip()]

    options["max_upload_slots"] = int(options["max_upload_slots"])
    options["max_connections"] = int(options["max_connections"])

    options["tmp_auto_retroactive"] = \
        self.we.chk_auto_retroactive.get_active()
    options["tmp_auto_unlabeled"] = \
        self.we.chk_auto_unlabeled.get_active()

    client.labelplus.set_options(self.label_id, options)
Exemplo n.º 2
0
  def _get_defaults(self):

    options = dict(LABEL_DEFAULTS)

    for widget in self.defaults_widgets:
      prefix, sep, name = widget.get_name().partition("_")
      if sep and name in options:
        widget_type = type(widget)
        if widget_type in OP_MAP:
          getter = getattr(widget, OP_MAP[widget_type][1])
          options[name] = getter()

    options["max_upload_slots"] = int(options["max_upload_slots"])
    options["max_connections"] = int(options["max_connections"])

    for rb in self.rgrp_move_data_completed:
      if rb.get_active():
        prefix, sep, mode = rb.get_name().rpartition("_")
        options["move_data_completed_mode"] = mode

        break

    if options["move_data_completed_mode"] == "folder":
      if self.daemon_is_local:
        options["move_data_completed_path"] = \
            self.we.fcb_move_data_completed_select.get_filename()
      else:
        options["move_data_completed_path"] = \
            self.we.txt_move_data_completed_entry.get_text().strip()

    lines = textview_get_text(self.we.tv_auto_queries).split("\n")
    options["auto_queries"] = tuple(x.strip() for x in lines if x.strip())

    return options