Class: Yast::HWConfigClass

Inherits:
Module
  • Object
show all
Defined in:
library/system/src/modules/HWConfig.rb

Instance Method Summary collapse

Instance Method Details

#ConfigFilesArray<String>

Return list of all available hardware configuration files

Returns:

  • (Array<String>)

    found files



47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'library/system/src/modules/HWConfig.rb', line 47

def ConfigFiles
  # read all files
  all = SCR.Dir(path(".sysconfig.hardware.section"))

  all = [] if all.nil?

  modules = Builtins.filter(all) do |file|
    !Builtins.regexpmatch(file, "[~]")
  end

  Builtins.y2debug("config files=%1", modules)

  deep_copy(all)
end

#FlushObject

Flush - write the changes to files

Returns:

  • true on success



155
156
157
158
# File 'library/system/src/modules/HWConfig.rb', line 155

def Flush
  # save all changes
  SCR.Write(path(".sysconfig.hardware"), nil)
end

#GetComment(file, variable) ⇒ String

Get comment of the variable from the config file

Parameters:

  • file (String)

    config file

  • variable (String)

    name of the variable

Returns:

  • (String)

    comment of the variable



133
134
135
136
137
138
139
140
141
142
# File 'library/system/src/modules/HWConfig.rb', line 133

def GetComment(file, variable)
  Convert.to_string(
    SCR.Read(
      Ops.add(
        Ops.add(path(".sysconfig.hardware.value_comment"), file),
        variable
      )
    )
  )
end

#GetValue(file, variable) ⇒ String

Set comment of the variable in the config file

Parameters:

  • file (String)

    config file

  • variable (String)

    name of the variable

Returns:

  • (String)

    comment the new comment



106
107
108
109
110
111
112
# File 'library/system/src/modules/HWConfig.rb', line 106

def GetValue(file, variable)
  Convert.to_string(
    SCR.Read(
      Ops.add(Ops.add(path(".sysconfig.hardware.value"), file), variable)
    )
  )
end

#mainObject



41
42
43
# File 'library/system/src/modules/HWConfig.rb', line 41

def main
  textdomain "base"
end

#RemoveConfig(file) ⇒ Object

Remove configuration file from system

Parameters:

  • file (String)

    config name

Returns:

  • true on success



147
148
149
150
151
# File 'library/system/src/modules/HWConfig.rb', line 147

def RemoveConfig(file)
  p = Ops.add(path(".sysconfig.hardware.section"), file)
  Builtins.y2debug("deleting: %1", file)
  SCR.Write(p, nil)
end

#SetComment(file, variable, comment) ⇒ Boolean

Set comment of the variable in the config file

Parameters:

  • file (String)

    config file

  • variable (String)

    name of the variable

  • comment (String)

    the new comment, the comment must be terminated by "\n" chacter!

Returns:

  • (Boolean)

    true on success



119
120
121
122
123
124
125
126
127
# File 'library/system/src/modules/HWConfig.rb', line 119

def SetComment(file, variable, comment)
  SCR.Write(
    Ops.add(
      Ops.add(path(".sysconfig.hardware.value_comment"), file),
      variable
    ),
    comment
  )
end

#SetValue(file, variable, value) ⇒ Boolean

Set value of the variable in the config file

Parameters:

  • file (String)

    config file

  • variable (String)

    name of the variable

  • value (String)

    the new value

Returns:

  • (Boolean)

    true on success



95
96
97
98
99
100
# File 'library/system/src/modules/HWConfig.rb', line 95

def SetValue(file, variable, value)
  SCR.Write(
    Ops.add(Ops.add(path(".sysconfig.hardware.value"), file), variable),
    value
  )
end

#Values(file) ⇒ Hash

Read all values from the file

Parameters:

  • file (String)

    configuration file to read

Returns:

  • (Hash)

    map $[ "VARIABLE" : "value" ]



77
78
79
80
81
82
83
84
85
86
87
88
# File 'library/system/src/modules/HWConfig.rb', line 77

def Values(file)
  vars = Variables(file)
  ret = {}
  p = Ops.add(path(".sysconfig.hardware.value"), file)

  Builtins.maplist(vars) do |var|
    item = Convert.to_string(SCR.Read(Ops.add(p, var)))
    Ops.set(ret, var, item) if !item.nil?
  end

  deep_copy(ret)
end

#Variables(file) ⇒ Array<String>

Return list of all available variable in the configuration file

Parameters:

Returns:

  • (Array<String>)

    found variables



65
66
67
68
69
70
71
72
# File 'library/system/src/modules/HWConfig.rb', line 65

def Variables(file)
  p = Ops.add(path(".sysconfig.hardware.value"), file)

  values = SCR.Dir(p)
  Builtins.y2debug("values=%1", values)

  deep_copy(values)
end