本文整理汇总了Python中DIRAC.ConfigurationSystem.private.Modificator.Modificator.removeOption方法的典型用法代码示例。如果您正苦于以下问题:Python Modificator.removeOption方法的具体用法?Python Modificator.removeOption怎么用?Python Modificator.removeOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.ConfigurationSystem.private.Modificator.Modificator
的用法示例。
在下文中一共展示了Modificator.removeOption方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from DIRAC.ConfigurationSystem.private.Modificator import Modificator [as 别名]
# 或者: from DIRAC.ConfigurationSystem.private.Modificator.Modificator import removeOption [as 别名]
#.........这里部分代码省略.........
def mergeFromCFG( self, cfg ):
""" Merge the internal CFG data with the input
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
self.__csMod.mergeFromCFG( cfg )
self.__csModified = True
return S_OK()
def modifyValue( self, optionPath, newValue ):
"""Modify an existing value at the specified options path.
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
prevVal = self.__csMod.getValue( optionPath )
if not prevVal:
return S_ERROR( 'Trying to set %s to %s but option does not exist' % ( optionPath, newValue ) )
gLogger.verbose( "Changing %s from \n%s \nto \n%s" % ( optionPath, prevVal, newValue ) )
self.__csMod.setOptionValue( optionPath, newValue )
self.__csModified = True
return S_OK( 'Modified %s' % optionPath )
def setOption( self, optionPath, optionValue ):
"""Create an option at the specified path.
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
self.__csMod.setOptionValue( optionPath, optionValue )
self.__csModified = True
return S_OK( 'Created new option %s = %s' % ( optionPath, optionValue ) )
def setOptionComment( self, optionPath, comment ):
"""Create an option at the specified path.
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
self.__csMod.setComment( optionPath, comment )
self.__csModified = True
return S_OK( 'Set option comment %s : %s' % ( optionPath, comment ) )
def delOption( self, optionPath ):
""" Delete an option
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
if not self.__csMod.removeOption( optionPath ):
return S_ERROR( "Couldn't delete option %s" % optionPath )
self.__csModified = True
return S_OK( 'Deleted option %s' % ( optionPath ) )
def createSection( self, sectionPath, comment = "" ):
""" Create a new section
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
self.__csMod.createSection( sectionPath )
self.__csModified = True
if comment:
self.__csMod.setComment( sectionPath, comment )
return S_OK()
def delSection( self, sectionPath ):
""" Delete a section
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
if not self.__csMod.removeSection( sectionPath ):
return S_ERROR( "Could not delete section %s " % sectionPath )
self.__csModified = True
return S_OK()
def mergeCFGUnderSection( self, sectionPath, cfg ):
""" Merge the given cfg under a certain section
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
result = self.createSection( sectionPath )
if not result[ 'OK' ]:
return result
if not self.__csMod.mergeSectionFromCFG( sectionPath, cfg ):
return S_ERROR( "Could not merge cfg into section %s" % sectionPath )
self.__csModified = True
return S_OK()
def mergeWithCFG( self, cfg ):
""" Merge the given cfg with the current config
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
self.__csMod.mergeFromCFG( cfg )
self.__csModified = True
return S_OK()
def getCurrentCFG( self ):
""" Get the current CFG as it is
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
return S_OK( self.__csMod.getCFG() )
示例2: CSAPI
# 需要导入模块: from DIRAC.ConfigurationSystem.private.Modificator import Modificator [as 别名]
# 或者: from DIRAC.ConfigurationSystem.private.Modificator.Modificator import removeOption [as 别名]
#.........这里部分代码省略.........
return self.__initialized
prevVal = self.__csMod.getValue( optionPath )
if prevVal is None:
return S_ERROR( 'Trying to set %s to %s but option does not exist' % ( optionPath, newValue ) )
gLogger.verbose( "Changing %s from \n%s \nto \n%s" % ( optionPath, prevVal, newValue ) )
self.__csMod.setOptionValue( optionPath, newValue )
self.csModified = True
return S_OK( 'Modified %s' % optionPath )
def setOption( self, optionPath, optionValue ):
"""Create an option at the specified path.
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
self.__csMod.setOptionValue( optionPath, optionValue )
self.csModified = True
return S_OK( 'Created new option %s = %s' % ( optionPath, optionValue ) )
def setOptionComment( self, optionPath, comment ):
"""Create an option at the specified path.
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
self.__csMod.setComment( optionPath, comment )
self.csModified = True
return S_OK( 'Set option comment %s : %s' % ( optionPath, comment ) )
def delOption( self, optionPath ):
""" Delete an option
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
if not self.__csMod.removeOption( optionPath ):
return S_ERROR( "Couldn't delete option %s" % optionPath )
self.csModified = True
return S_OK( 'Deleted option %s' % optionPath )
def createSection( self, sectionPath, comment = "" ):
""" Create a new section
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
self.__csMod.createSection( sectionPath )
self.csModified = True
if comment:
self.__csMod.setComment( sectionPath, comment )
return S_OK()
def delSection( self, sectionPath ):
""" Delete a section
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
if not self.__csMod.removeSection( sectionPath ):
return S_ERROR( "Could not delete section %s " % sectionPath )
self.csModified = True
return S_OK( )
def copySection( self, originalPath, targetPath ):
""" Copy a whole section to a new location
"""
if not self.__initialized['OK']:
return self.__initialized
cfg = self.__csMod.getCFG( )
sectionCfg = cfg[originalPath]
示例3: CSShellCLI
# 需要导入模块: from DIRAC.ConfigurationSystem.private.Modificator import Modificator [as 别名]
# 或者: from DIRAC.ConfigurationSystem.private.Modificator.Modificator import removeOption [as 别名]
#.........这里部分代码省略.........
self.root = self.root + "/" + os.path.normpath(line)
self.update_prompt()
else:
print "cd: no such section: " + line
def complete_cd(self, text, _line, _begidx, _endidx):
secs = self.modificator.getSections(self.root)
return [(s + "/") for s in secs if s.startswith(text)]
def do_cat(self, line):
"""cat
Read the content of an option in the CS"""
if self.connected:
opts = self.modificator.getOptionsDict(self.root)
if line in opts.keys():
print opts[line]
else:
print "cat: No such option"
def complete_cat(self, text, _line, _begidx, _endidx):
opts = self.modificator.getOptions(self.root)
return [o for o in opts if o.startswith(text)]
do_less = do_cat
complete_less = complete_cat
def do_mkdir(self, line):
"""mkdir
Create a new section in the CS"""
if self.connected:
self.modificator.createSection(self.root + "/" + line)
self.dirty = True
complete_mkdir = complete_cd
def do_rmdir(self, line):
"""rmdir
Delete a section in the CS"""
if self.connected:
self.modificator.removeSection(self.root + "/" + line)
self.dirty = True
complete_rmdir = complete_cd
def do_rm(self, line):
"""rm
Delete an option in the CS"""
if self.connected:
self.modificator.removeOption(self.root + "/" + line)
self.dirty = True
complete_rm = complete_cat
def do_set(self, line):
"""set
Set an option in the CS (or create it if it does not exists)
Usage: set <str> to set a string option (will be stored as a string in CS)
set <str>,<str>,... to set a list option (will be stored as a list in CS)
"""
if self.connected:
line = line.split(" ", 2)
if len(line) != 2:
print "Usage: set <key> <value>"
else:
self.modificator.setOptionValue(self.root + "/" + line[0], line[1])
self.dirty = True
complete_set = complete_cat
def do_unset(self, line):
"""unset
Unset an option in the CS: Making the option equal to the
empty string."""
if self.connected:
self.modificator.setOptionValue(self.root + "/" + line, "")
self.dirty = True
complete_unset = complete_cat
def do_commit(self, _line):
"""commit
Commit the modifications to the CS"""
if self.connected and self.dirty:
self.modificator.commit()
def default(self, line):
"""Override [Cmd.default(line)] function."""
if line == "EOF":
if self.prompt:
print
return self.do_quit(line)
else:
cmd.Cmd.default(self, line)
def do_quit(self, _line):
"""quit
Quit"""
self.do_disconnect("")
CLI.do_quit(self, _line)
示例4: CSCLI
# 需要导入模块: from DIRAC.ConfigurationSystem.private.Modificator import Modificator [as 别名]
# 或者: from DIRAC.ConfigurationSystem.private.Modificator.Modificator import removeOption [as 别名]
#.........这里部分代码省略.........
print "Data sent to server."
self.modificator.loadFromRemote()
else:
print "Error sending data, server said: %s" % response['Message']
return
else:
print "Commit aborted"
except Exception as x:
_showTraceback()
print "Could not upload changes. ", str( x )
def do_set( self, args ):
"""
Sets option's value
Usage: set <optionPath> <value>...
From second argument until the last one is considered option's value
NOTE: If specified section does not exist it is created.
"""
try:
argsList = args.split()
if len( argsList ) < 2:
print "Must specify option and value to use"
return
optionPath = argsList[0].strip()
value = " ".join( argsList[1:] ).strip()
self.modificator.setOptionValue( optionPath, value )
self.modifiedData = True
except Exception as x:
print "Cannot insert value: ", str( x )
def do_removeOption( self, args ):
"""
Removes an option.
Usage: removeOption <option>
There can be empty sections.
"""
try:
argsList = args.split()
if len( argsList ) < 1:
print "Must specify option to delete"
return
optionPath = argsList[0].strip()
choice = raw_input( "Are you sure you want to delete %s? yes/no [no]: " % optionPath )
choice = choice.lower()
if choice in ( "yes", "y", "true" ):
if self.modificator.removeOption( optionPath ):
self.modifiedData = True
else:
print "Can't be deleted"
else:
print "Aborting removal."
except Exception as x:
print "Error removing option, %s" % str( x )
def do_removeSection( self, args ):
"""
Removes a section.
Usage: removeSection <section>
"""
try: