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



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

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



157
158
159
160
# File 'library/system/src/modules/HWConfig.rb', line 157

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



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

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



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

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

#mainObject



43
44
45
# File 'library/system/src/modules/HWConfig.rb', line 43

def main
  textdomain "base"
end

#RemoveConfig(file) ⇒ Object

Remove configuration file from system



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

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



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

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



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

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



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

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



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

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

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

  deep_copy(values)
end