Class: Yast::ValueBrowserClass
- Inherits:
-
Module
- Object
- Module
- Yast::ValueBrowserClass
- Defined in:
- ../../library/general/src/modules/ValueBrowser.rb
Instance Method Summary (collapse)
-
- (Object) BrowseTree(variable)
Shows tree with contents of variable.
-
- (Object) BrowseTreeHelper(variable, indent)
Creates tree with contents of variable.
-
- (Object) DebugBrowse(variable)
Write contents of variable to log file.
-
- (Object) DebugBrowseHelper(variable, indent)
Write contents of variable to log file.
-
- (String) escapestring(s)
Helper function that replaces all ocurences of “n” with “n”, so items are not multiline :-).
-
- (Object) FormatSimpleType(variable, indent)
Shows tree with contents of variable.
- - (Object) main
Instance Method Details
- (Object) BrowseTree(variable)
Shows tree with contents of variable.
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File '../../library/general/src/modules/ValueBrowser.rb', line 146 def BrowseTree(variable) variable = deep_copy(variable) items = BrowseTreeHelper(variable, "") UI.OpenDialog( Opt(:defaultsize), VBox( # translators: Tree header Tree(Opt(:hstretch, :vstretch), _("&Variable"), [items]), ButtonBox( PushButton(Id(:ok), Opt(:okButton, :key_F10), Label.OKButton) ) ) ) UI.UserInput UI.CloseDialog nil end |
- (Object) BrowseTreeHelper(variable, indent)
Creates tree with contents of variable. This function creates the tree items and returns them as term. This offers using the generated output in your behavior, such as data-structure browser with editor. Heavy recursion…
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File '../../library/general/src/modules/ValueBrowser.rb', line 94 def BrowseTreeHelper(variable, indent) variable = deep_copy(variable) simple = FormatSimpleType(variable, indent) if !simple.nil? return Item(simple) elsif Ops.is_list?(variable) items = [] Builtins.foreach(Convert.to_list(variable)) do |i| items = Builtins.add(items, BrowseTreeHelper(i, "")) end return Item(Builtins.sformat("%1 (list)", indent), items) elsif Ops.is_map?(variable) items = [] Builtins.foreach(Convert.to_map(variable)) do |k, v| items = Builtins.add( items, BrowseTreeHelper(v, Builtins.sformat("%1: ", k)) ) end return Item(Builtins.sformat("%1 (map)", indent), items) elsif Ops.is_term?(variable) tvariable = Convert.to_term(variable) items = [] len = Builtins.size(tvariable) i = 0 while Ops.less_than(i, len) items = Builtins.add( items, BrowseTreeHelper(Ops.get(tvariable, i), "") ) i = Ops.add(i, 1) end return Item( Builtins.sformat("%1%2 (term)", indent, Builtins.symbolof(tvariable)), items ) end nil end |
- (Object) DebugBrowse(variable)
Write contents of variable to log file.
202 203 204 205 206 207 |
# File '../../library/general/src/modules/ValueBrowser.rb', line 202 def DebugBrowse(variable) variable = deep_copy(variable) DebugBrowseHelper(variable, "") nil end |
- (Object) DebugBrowseHelper(variable, indent)
Write contents of variable to log file. This function does the job. Heavy recursion…
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File '../../library/general/src/modules/ValueBrowser.rb', line 169 def DebugBrowseHelper(variable, indent) variable = deep_copy(variable) simple = FormatSimpleType(variable, indent) if !simple.nil? Builtins.y2debug("%1", simple) elsif Ops.is_list?(variable) Builtins.foreach(Convert.to_list(variable)) do |i| DebugBrowseHelper(i, Ops.add(indent, " ")) end elsif Ops.is_map?(variable) Builtins.foreach(Convert.to_map(variable)) do |k, v| Builtins.y2debug("%2%1 (map key)", k, indent) DebugBrowseHelper(v, Builtins.sformat(" %1", indent)) end elsif Ops.is_term?(variable) tvariable = Convert.to_term(variable) items = [] len = Builtins.size(tvariable) i = 0 Builtins.y2debug("%1%2 (term)", indent, Builtins.symbolof(tvariable)) while Ops.less_than(i, len) items = Builtins.add( items, DebugBrowseHelper(Ops.get(tvariable, i), "") ) i = Ops.add(i, 1) end end nil end |
- (String) escapestring(s)
Helper function that replaces all ocurences of “n” with “n”, so items are not multiline :-)
47 48 49 |
# File '../../library/general/src/modules/ValueBrowser.rb', line 47 def escapestring(s) Builtins.mergestring(Builtins.splitstring(s, "\n"), "\\n") end |
- (Object) FormatSimpleType(variable, indent)
Shows tree with contents of variable. This function does the job. Heavy recursion…
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File '../../library/general/src/modules/ValueBrowser.rb', line 54 def FormatSimpleType(variable, indent) variable = deep_copy(variable) if Ops.is_void?(variable) return Builtins.sformat("%2%1 (void)", variable, indent) elsif Ops.is_boolean?(variable) return Builtins.sformat("%2%1 (boolean)", variable, indent) elsif Ops.is_integer?(variable) return Builtins.sformat( "%2%1, %3 (integer)", variable, indent, Builtins.tohexstring(Convert.to_integer(variable)) ) elsif Ops.is_float?(variable) return Builtins.sformat("%2%1 (float)", variable, indent) elsif Ops.is_string?(variable) return Builtins.sformat( "%2%1 (string)", escapestring(Convert.to_string(variable)), indent ) elsif Ops.is_locale?(variable) return Builtins.sformat("%2%1 (locale)", variable, indent) elsif Ops.is_byteblock?(variable) return Builtins.sformat("%2%1 (byteblock)", variable, indent) elsif Ops.is_symbol?(variable) return Builtins.sformat("%2%1 (symbol)", variable, indent) elsif Ops.is_path?(variable) return Builtins.sformat("%2%1 (path)", variable, indent) else return nil end end |
- (Object) main
36 37 38 39 40 41 42 |
# File '../../library/general/src/modules/ValueBrowser.rb', line 36 def main Yast.import "UI" textdomain "base" Yast.import "Label" end |