Class: Yast::HWConfigClass

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

Instance Method Summary (collapse)

Instance Method Details

- (Array<String>) ConfigFiles

Return list of all available hardware configuration files

Returns:

  • (Array<String>)

    found files



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

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

- (Object) Flush

Flush - write the changes to files

Returns:

  • true on success



158
159
160
161
# File '../../src/modules/HWConfig.rb', line 158

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

- (String) GetComment(file, variable)

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



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

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

- (String) GetValue(file, variable)

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



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

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

- (Object) main



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

def main

  textdomain "base"
end

- (Object) RemoveConfig(file)

Remove configuration file from system

Parameters:

  • file (String)

    config name

Returns:

  • true on success



150
151
152
153
154
# File '../../src/modules/HWConfig.rb', line 150

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

- (Boolean) SetComment(file, variable, comment)

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



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

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

- (Boolean) SetValue(file, variable, value)

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



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

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

- (Hash) Values(file)

Read all values from the file

Parameters:

  • file (String)

    configuration file to read

Returns:

  • (Hash)

    map $[ “VARIABLE” : “value” ]



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

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

- (Array<String>) Variables(file)

Return list of all available variable in the configuration file

Parameters:

  • file (String)

    to search

Returns:

  • (Array<String>)

    found variables



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

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

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

  deep_copy(values)
end