本文整理匯總了Python中DIRAC.ConfigurationSystem.private.Modificator.Modificator.showCurrentDiff方法的典型用法代碼示例。如果您正苦於以下問題:Python Modificator.showCurrentDiff方法的具體用法?Python Modificator.showCurrentDiff怎麽用?Python Modificator.showCurrentDiff使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DIRAC.ConfigurationSystem.private.Modificator.Modificator
的用法示例。
在下文中一共展示了Modificator.showCurrentDiff方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: CSAPI
# 需要導入模塊: from DIRAC.ConfigurationSystem.private.Modificator import Modificator [as 別名]
# 或者: from DIRAC.ConfigurationSystem.private.Modificator.Modificator import showCurrentDiff [as 別名]
#.........這裏部分代碼省略.........
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]
result = self.createSection( targetPath )
if not result['OK']:
return result
if not self.__csMod.mergeSectionFromCFG( targetPath, sectionCfg ):
return S_ERROR( "Could not merge cfg into section %s" % targetPath )
self.csModified = True
return S_OK( )
def moveSection( self, originalPath, targetPath ):
""" Move a whole section to a new location
"""
result = self.copySection( originalPath, targetPath )
if not result['OK']:
return result
result = self.delSection( originalPath )
if not result['OK']:
return result
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() )
def showDiff( self ):
""" Just shows the differences accumulated within the Modificator object
"""
diffData = self.__csMod.showCurrentDiff()
gLogger.notice( "Accumulated diff with master CS" )
for line in diffData:
if line[0] in ( '+', '-' ):
gLogger.notice( line )
示例2: CSCLI
# 需要導入模塊: from DIRAC.ConfigurationSystem.private.Modificator import Modificator [as 別名]
# 或者: from DIRAC.ConfigurationSystem.private.Modificator.Modificator import showCurrentDiff [as 別名]
#.........這裏部分代碼省略.........
_showTraceback()
print "Couldn't read from file %s: %s" % ( filename, str( x ) )
def do_showData( self, dummy ):
"""
Shows the current modified configuration
Usage: showData
"""
print self.modificator
def do_showHistory( self, args ):
"""
Shows the last commit history
Usage: showHistory <update limit>
"""
try:
argsList = args.split()
limit = 100
if len( argsList ) > 0:
limit = int( argsList[0] )
history = self.modificator.getHistory( limit )
print "%s recent commits:" % limit
for entry in history:
self.printPair( entry[0], entry[1], "@" )
except:
_showTraceback()
def do_showDiffWithServer( self, dummy ):
"""
Shows diff with lastest version in server
Usage: showDiffWithServer
"""
try:
diffData = self.modificator.showCurrentDiff()
print "Diff with latest from server ( + local - remote )"
for line in diffData:
if line[0] in ( '-' ):
print colorize( line, "red" )
elif line[0] in ( '+' ):
print colorize( line, "green" )
elif line[0] in ( '?' ):
print colorize( line, "yellow" ),
else:
print line
except:
_showTraceback()
def do_showDiffBetweenVersions( self, args ):
"""
Shows diff between two versions
Usage: showDiffBetweenVersions <version 1 with spaces> <version 2 with spaces>
"""
try:
argsList = args.split()
if len( argsList ) < 4:
print "What are the two versions to compare?"
return
v1 = " ".join ( argsList[0:2] )
v2 = " ".join ( argsList[2:4] )
print "Comparing '%s' with '%s' " % ( v1, v2 )
diffData = self.modificator.getVersionDiff( v1, v2 )
print "Diff with latest from server ( + %s - %s )" % ( v2, v1 )
for line in diffData:
if line[0] in ( '-' ):
print colorize( line, "red" )
elif line[0] in ( '+' ):