34
34
import iniparse
35
35
import logging
36
36
import os
37
- import libdnf .conf as cfg
38
-
39
- PRIO_EMPTY = cfg .Option .Priority_EMPTY
40
- PRIO_DEFAULT = cfg .Option .Priority_DEFAULT
41
- PRIO_MAINCONFIG = cfg .Option .Priority_MAINCONFIG
42
- PRIO_AUTOMATICCONFIG = cfg .Option .Priority_AUTOMATICCONFIG
43
- PRIO_REPOCONFIG = cfg .Option .Priority_REPOCONFIG
44
- PRIO_PLUGINDEFAULT = cfg .Option .Priority_PLUGINDEFAULT
45
- PRIO_PLUGINCONFIG = cfg .Option .Priority_PLUGINCONFIG
46
- PRIO_COMMANDLINE = cfg .Option .Priority_COMMANDLINE
47
- PRIO_RUNTIME = cfg .Option .Priority_RUNTIME
37
+ import libdnf .conf
38
+
39
+ PRIO_EMPTY = libdnf . conf .Option .Priority_EMPTY
40
+ PRIO_DEFAULT = libdnf . conf .Option .Priority_DEFAULT
41
+ PRIO_MAINCONFIG = libdnf . conf .Option .Priority_MAINCONFIG
42
+ PRIO_AUTOMATICCONFIG = libdnf . conf .Option .Priority_AUTOMATICCONFIG
43
+ PRIO_REPOCONFIG = libdnf . conf .Option .Priority_REPOCONFIG
44
+ PRIO_PLUGINDEFAULT = libdnf . conf .Option .Priority_PLUGINDEFAULT
45
+ PRIO_PLUGINCONFIG = libdnf . conf .Option .Priority_PLUGINCONFIG
46
+ PRIO_COMMANDLINE = libdnf . conf .Option .Priority_COMMANDLINE
47
+ PRIO_RUNTIME = libdnf . conf .Option .Priority_RUNTIME
48
48
49
49
logger = logging .getLogger ('dnf' )
50
50
@@ -70,10 +70,10 @@ class Option(object):
70
70
written to config file.
71
71
"""
72
72
def __init__ (self , option ):
73
- if isinstance (option , cfg .Option ):
73
+ if isinstance (option , libdnf . conf .Option ):
74
74
self ._option = option
75
75
else :
76
- self ._option = cfg .OptionString (option )
76
+ self ._option = libdnf . conf .OptionString (option )
77
77
78
78
def _get (self ):
79
79
"""Get option's value."""
@@ -94,9 +94,9 @@ def _set(self, value, priority=PRIO_RUNTIME):
94
94
else :
95
95
try :
96
96
if isinstance (value , list ) or isinstance (value , tuple ):
97
- self ._option .set (priority , cfg .VectorString (value ))
98
- elif (isinstance (self ._option , cfg .OptionBool ) or
99
- isinstance (self ._option , cfg .OptionChildBool )) and isinstance (value , int ):
97
+ self ._option .set (priority , libdnf . conf .VectorString (value ))
98
+ elif (isinstance (self ._option , libdnf . conf .OptionBool ) or
99
+ isinstance (self ._option , libdnf . conf .OptionChildBool )) and isinstance (value , int ):
100
100
self ._option .set (priority , bool (value ))
101
101
else :
102
102
self ._option .set (priority , value )
@@ -128,51 +128,51 @@ def _tostring(self):
128
128
129
129
class IntOption (Option ):
130
130
def __init__ (self , default = 0 ):
131
- option = cfg .OptionNumberInt32 (default )
131
+ option = libdnf . conf .OptionNumberInt32 (default )
132
132
super (IntOption , self ).__init__ (option )
133
133
134
134
135
135
class LongOption (Option ):
136
136
def __init__ (self , default = 0 ):
137
- option = cfg .OptionNumberInt64 (default )
137
+ option = libdnf . conf .OptionNumberInt64 (default )
138
138
super (LongOption , self ).__init__ (option )
139
139
140
140
141
141
class BoolOption (Option ):
142
142
def __init__ (self , default = False ):
143
- option = cfg .OptionBool (default )
143
+ option = libdnf . conf .OptionBool (default )
144
144
super (BoolOption , self ).__init__ (option )
145
145
146
146
147
147
class SelectionOption (Option ):
148
148
"""Handles string values where only specific values are allowed."""
149
149
def __init__ (self , default = None , choices = ()):
150
- option = cfg . OptionEnumString (default , cfg .VectorString (choices ))
150
+ option = libdnf . conf . OptionEnumString (default , libdnf . conf .VectorString (choices ))
151
151
super (SelectionOption , self ).__init__ (option )
152
152
153
153
154
154
class ListOption (Option ):
155
155
"""Handles string values where only specific values are allowed."""
156
156
def __init__ (self , default = None ):
157
- option = cfg . OptionStringList (cfg .VectorString (default ))
157
+ option = libdnf . conf . OptionStringList (libdnf . conf .VectorString (default ))
158
158
super (ListOption , self ).__init__ (option )
159
159
160
160
161
161
class SecondsOption (Option ):
162
162
def __init__ (self , default = 0 ):
163
- option = cfg .OptionSeconds (default )
163
+ option = libdnf . conf .OptionSeconds (default )
164
164
super (SecondsOption , self ).__init__ (option )
165
165
166
166
167
167
class StringOption (Option ):
168
168
def __init__ (self , default = "" ):
169
- option = cfg .OptionString (default )
169
+ option = libdnf . conf .OptionString (default )
170
170
super (StringOption , self ).__init__ (option )
171
171
172
172
173
173
class PathOption (Option ):
174
174
def __init__ (self , default = "" , exists = False , absPath = False ):
175
- option = cfg .OptionPath (default , exists , absPath )
175
+ option = libdnf . conf .OptionPath (default , exists , absPath )
176
176
super (PathOption , self ).__init__ (option )
177
177
178
178
@@ -211,7 +211,7 @@ def __getattr__(self, name):
211
211
value = option ().getValue ()
212
212
except Exception as ex :
213
213
return None
214
- if isinstance (value , cfg .VectorString ):
214
+ if isinstance (value , libdnf . conf .VectorString ):
215
215
return list (value )
216
216
if type (value ).__name__ == "VectorString" :
217
217
# every module generated with swig provides a different VectorString class
@@ -239,9 +239,9 @@ def __setattr__(self, name, value):
239
239
else :
240
240
try :
241
241
if isinstance (value , list ) or isinstance (value , tuple ):
242
- option ().set (priority , cfg .VectorString (value ))
243
- elif (isinstance (option (), cfg .OptionBool ) or
244
- isinstance (option (), cfg .OptionChildBool )) and isinstance (value , int ):
242
+ option ().set (priority , libdnf . conf .VectorString (value ))
243
+ elif (isinstance (option (), libdnf . conf .OptionBool ) or
244
+ isinstance (option (), libdnf . conf .OptionChildBool )) and isinstance (value , int ):
245
245
option ().set (priority , bool (value ))
246
246
else :
247
247
option ().set (priority , value )
@@ -377,7 +377,7 @@ def write_raw_configfile(filename, section_id, substitutions, modify):
377
377
# out which one is which
378
378
if section_id not in ini :
379
379
for sect in ini :
380
- if cfg .ConfigParser .substitute (sect , substitutions ) == section_id :
380
+ if libdnf . conf .ConfigParser .substitute (sect , substitutions ) == section_id :
381
381
section_id = sect
382
382
383
383
for name , value in modify .items ():
@@ -394,7 +394,7 @@ class MainConf(BaseConfig):
394
394
"""Configuration option definitions for dnf.conf's [main] section."""
395
395
def __init__ (self , section = 'main' , parser = None ):
396
396
# pylint: disable=R0915
397
- config = cfg .ConfigMain ()
397
+ config = libdnf . conf .ConfigMain ()
398
398
super (MainConf , self ).__init__ (config , section , parser )
399
399
self ._get_option ('pluginpath' )._set ([dnf .const .PLUGINPATH ], PRIO_DEFAULT )
400
400
self ._get_option ('pluginconfpath' )._set ([dnf .const .PLUGINCONFPATH ], PRIO_DEFAULT )
@@ -448,7 +448,7 @@ def _search_inside_installroot(self, optname):
448
448
if not isinstance (val , str ):
449
449
if any (os .path .exists (os .path .join (self ._get_value ('installroot' ),
450
450
p .lstrip ('/' ))) for p in val ):
451
- opt ._set (cfg .VectorString ([self ._prepend_installroot_path (p ) for p in val ]), prio )
451
+ opt ._set (libdnf . conf .VectorString ([self ._prepend_installroot_path (p ) for p in val ]), prio )
452
452
elif os .path .exists (os .path .join (self ._get_value ('installroot' ),
453
453
val .lstrip ('/' ))):
454
454
opt ._set (self ._prepend_installroot_path (val ), prio )
@@ -462,7 +462,7 @@ def prepend_installroot(self, optname):
462
462
463
463
def _prepend_installroot_path (self , path ):
464
464
root_path = os .path .join (self ._get_value ('installroot' ), path .lstrip ('/' ))
465
- return cfg .ConfigParser .substitute (root_path , self .substitutions )
465
+ return libdnf . conf .ConfigParser .substitute (root_path , self .substitutions )
466
466
467
467
def _configure_from_options (self , opts ):
468
468
"""Configure parts of CLI from the opts """
@@ -575,7 +575,7 @@ def read(self, filename=None, priority=PRIO_DEFAULT):
575
575
# :api
576
576
if filename is None :
577
577
filename = self ._get_value ('config_file_path' )
578
- self ._parser = cfg .ConfigParser ()
578
+ self ._parser = libdnf . conf .ConfigParser ()
579
579
try :
580
580
self ._parser .read (filename )
581
581
except RuntimeError as e :
@@ -596,9 +596,9 @@ class RepoConf(BaseConfig):
596
596
"""Option definitions for repository INI file sections."""
597
597
598
598
def __init__ (self , parent , section = None , parser = None ):
599
- super (RepoConf , self ).__init__ (cfg .ConfigRepo (
600
- parent ._config if parent else cfg .ConfigMain ()), section , parser )
601
- self ._masterConfig = parent ._config if parent else cfg .ConfigMain ()
599
+ super (RepoConf , self ).__init__ (libdnf . conf .ConfigRepo (
600
+ parent ._config if parent else libdnf . conf .ConfigMain ()), section , parser )
601
+ self ._masterConfig = parent ._config if parent else libdnf . conf .ConfigMain ()
602
602
603
603
def _configure_from_options (self , opts ):
604
604
"""Configure repos from the opts. """
0 commit comments