本文整理汇总了Python中OutputManager.OutputManager.printDiff方法的典型用法代码示例。如果您正苦于以下问题:Python OutputManager.printDiff方法的具体用法?Python OutputManager.printDiff怎么用?Python OutputManager.printDiff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputManager.OutputManager
的用法示例。
在下文中一共展示了OutputManager.printDiff方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: diffVersions
# 需要导入模块: from OutputManager import OutputManager [as 别名]
# 或者: from OutputManager.OutputManager import printDiff [as 别名]
def diffVersions(self, noteId):
'''
creates the diff of two versions of a note
:param noteId:
:return:
'''
if self._swiftManager.doesNoteExist(noteId) == True:
note, title, versions, noteList = self._versionMngr._getVersionInfo(
noteId)
# user input for id, if the input is not an integer the error
# message will be displayed
try:
diff1 = int(
raw_input("ID of base version? (0 is the current version) > "))
diff2 = int(
raw_input("ID of target version? (0 is the current version) > "))
except (ValueError):
print "invalid input"
sys.exit(1)
# check if the user wants to diff with the current note
if diff1 == 0:
diff1Content = self._swiftManager.getNote(noteId).getContent()
elif diff2 == 0:
diff2Content = self._swiftManager.getNote(noteId).getContent()
# append 0, because it's valid but not a key
self._keyList.append(0)
for key, value in versions.iteritems():
self._keyList.append(key)
diffTitle = versions[key][1]
# check which input is which note
if key == diff1:
diff1Content = noteList[diffTitle]
elif key == diff2:
diff2Content = noteList[diffTitle]
# as an information for the user, that the version doesn't exist
if diff1 not in self._keyList:
print str(diff1) + " doesn't exist"
elif diff2 not in self._keyList:
print str(diff2) + " doesn't exist"
OutputManager.printDiff(diff1Content, diff2Content)
# as an information for the user
else:
print "Note #" + str(noteId) + " doesn't exist"