• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yast / yast-autoinstallation / 13494013411

24 Feb 2025 08:44AM UTC coverage: 69.018% (+0.03%) from 68.993%
13494013411

push

github

web-flow
Merge pull request #881 from yast/merge_SLE-15-SP7

Added pervasive encryption fields (master)

6429 of 9315 relevant lines covered (69.02%)

10.35 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

24.53
/src/include/autoinstall/tree.rb
1
# File:  include/tree.ycp
2
# Package:  Auto-installation/Partition
3
# Summary:     helper functions for dealing with tree widget
4
# Author:  Sven Schober (sschober@suse.de)
5
#
6
# $Id: tree.ycp 2805 2008-05-27 15:12:42Z sschober $
7
module Yast
1✔
8
  module AutoinstallTreeInclude
1✔
9
    def initialize_autoinstall_tree(include_target)
1✔
10
      Yast.import "UI"
1✔
11
      Yast.include include_target, "autoinstall/common.rb"
1✔
12

13
      # name of tree widget to be displayed (in storage dialog)
14
      @sTree = :tree
1✔
15
      # common way to refer to the tree widget id
16
      @iTree = Id(@sTree)
1✔
17
    end
18

19
    # Set tree widget to tree represented by newTree
20
    #
21
    # @param [Array<Yast::Term>] newTree tree to display.
22
    def setTree(newTree)
1✔
23
      newTree = deep_copy(newTree)
×
24
      UI.ChangeWidget(@iTree, :Items, newTree)
×
25

26
      nil
×
27
    end
28

29
    # Get the currently selected tree item id string.
30
    #
31
    # @return Item id string that is currently selected.
32
    def currentTreeItem
1✔
33
      symbol2string(Convert.to_symbol(UI.QueryWidget(@iTree, :Value)))
×
34
    end
35

36
    # Searches through term t recursively looking for an arg of
37
    # type string which is equal to s. This function is neccessary
38
    # due to the nature trees are stored/represented in the tree
39
    # widget.
40
    #
41
    # @param [Yast::Term] t The term to inspect.
42
    # @param [Symbol] s The symbol to look for.
43
    def termContains(t, s)
1✔
44
      t = deep_copy(t)
×
45
      # if term itself is named like s -> yes, contains
46
      return true if s == Builtins.symbolof(t)
×
47

48
      # other wise inspect arguments
49
      args = Builtins.argsof(t)
×
50
      found = false
×
51
      Builtins.foreach(args) do |e|
×
52
        if Ops.is_term?(e)
×
53
          found = termContains(Convert.to_term(e), s)
×
54
          raise Break if found
×
55
        elsif Ops.is(e, "list <term>")
×
56
          found = isContainedInTree(
×
57
            s,
58
            Convert.convert(e, from: "any", to: "list <term>")
59
          )
60
          raise Break if found
×
61
        elsif Ops.is_symbol?(e) && s == Convert.to_symbol(e)
×
62
          found = true
×
63
          raise Break
×
64
        end
65
      end
66
      found
×
67
    end
68

69
    def isContainedInTree(s, tree)
1✔
70
      tree = deep_copy(tree)
×
71
      found = false
×
72
      Builtins.foreach(tree) do |item|
×
73
        if termContains(item, s)
×
74
          found = true
×
75
          raise Break
×
76
        end
77
      end
78
      found
×
79
    end
80

81
    # Select item 'newItem' in tree.
82
    #
83
    # @return true if item exists in tree (and was selected), false
84
    # otherwise
85
    def selectTreeItem(newItem)
1✔
86
      item = string2symbol(newItem)
×
87
      allItems = Convert.convert(
×
88
        UI.QueryWidget(@iTree, :Items),
89
        from: "any",
90
        to:   "list <term>"
91
      )
92
      if isContainedInTree(item, allItems)
×
93
        UI.ChangeWidget(@iTree, :CurrentItem, item)
×
94
        return true
×
95
      end
96
      Builtins.y2warning("Item '%1' not found in tree", item)
×
97
      Builtins.y2debug("Tree was '%1'", allItems)
×
98
      false
×
99
    end
100

101
    # Wrapper function to create a new tree node
102
    #
103
    # @param [String] reference Tree item id string (e.g. "part_2_0")
104
    # @param [String] name Tree node name, displayed in widget
105
    # @param [Array<Yast::Term>] children list of child nodes
106
    def createTreeNode(reference, name, children)
1✔
107
      children = deep_copy(children)
×
108
      result = if 0 == Builtins.size(children)
×
109
        Item(Id(string2symbol(reference)), name)
×
110
      else
111
        Item(Id(string2symbol(reference)), name, true, children)
×
112
      end
113
      Builtins.y2milestone("new node: '%1'", result)
×
114
      deep_copy(result)
×
115
    end
116
  end
117
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc