当前位置: 首页>>代码示例>>Python>>正文


Python Notebook.modify_tags方法代码示例

本文整理汇总了Python中notebook.Notebook.modify_tags方法的典型用法代码示例。如果您正苦于以下问题:Python Notebook.modify_tags方法的具体用法?Python Notebook.modify_tags怎么用?Python Notebook.modify_tags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在notebook.Notebook的用法示例。


在下文中一共展示了Notebook.modify_tags方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from notebook import Notebook [as 别名]
# 或者: from notebook.Notebook import modify_tags [as 别名]
class Menu:
    '''Display a menu and respond to choices when run.'''
    def __init__(self):
        self.notebook = Notebook()
        self.choices = {
            "1": self.show_notes,
            "2": self.search_notes,
            "3": self.add_note,
            "4": self.modify_note,
            "5": self.quit
            }
    def display_menu(self):
        print("""
Notebook Menu
1. Show all Notes
2. Search Notes
3. Add Note
4. Modify Note
5. Quit
""")
    def run(self):
        '''Display the menu and respond to choices.'''
        while True:
            self.display_menu()
            choice = input("Enter an option: ")
            action = self.choices.get(choice)
            if action:
                action()
            else:
                print("{0} is not a valid choice".format(choice))

    def show_notes(self, notes=None):
        if not notes:
            notes = self.notebook.notes
            for note in notes:
                print("{0}: {1}\n{2}".format(
                    note.id, note.tags, note.memo))

    def search_notes(self):
        filter = input("Search for: ")
        notes = self.notebook.search(filter)
        self.show_notes(notes)

    def add_note(self):
        memo = input("Enter a memo: ")
        self.notebook.new_note(memo)
        print("Your note has been added.")

    def modify_note(self):
        id = input("Enter a note id: ")
        memo = input("Enter a memo: ")
        tags = input("Enter tags: ")
        if memo:
            self.notebook.modify_memo(id, memo)
        if tags:
            self.notebook.modify_tags(id, tags)

    def quit(self):
        print("Thank you for using your notebook today.")
        sys.exit(0)
开发者ID:nmukh,项目名称:Python-Notebook,代码行数:62,代码来源:menu.py

示例2: __init__

# 需要导入模块: from notebook import Notebook [as 别名]
# 或者: from notebook.Notebook import modify_tags [as 别名]
class Menu:
    def __init__(self):
        self.notebook = Notebook()
        self.choices = {
                "1": self.show_notes,
                "2": self.search_notes,
                "3": self.add_note,
                "4": self.modify_note,
                "5": self.quit
                }

    def display_menu(self):
        print ("""
                 Notebook Menu 
                   1. Show all Notes
                   2. Search Notes
                   3. Add Note
                   4. Modify Note
                   5. Quit """)

    def run(self):
        while True:
            self.display_menu()
            choice = input("enter an option: ")
            action = self.choice.get(choice)
            if action:
                action()
            else:
                print ("{0} is not a not valid".format(choice))

    def show_notes(self, notes=None):
        if not notes:
            notes = self.notebook.notes
        for note in notes:
            print ("%d: %s\n%s", % (note.id, note.tags, note.memo))

    def search_notes(self):
        title = input("search for: ")
        notes = self.notebook.lookin(title)
        self.show_notes(notes)


    def add_notes(self):
        memo = input("Enter a memo: ")
        self.notebook.new_note(memo)
        print ("you note added. ")

    def modify_note(self):
        id = input("enter note id: ")
        memo = input("enter a memo: ")
        tags = input("enter tags: ")
        if memo:
            self.notebook.modify_memo(id, memo)
        if tags:
            self.notebook.modify_tags(id, tags)


    def quit(self):
        print ("thanks! ")
        sys.exit(0)
开发者ID:thisiswei,项目名称:learning,代码行数:62,代码来源:menu.py

示例3: Menu

# 需要导入模块: from notebook import Notebook [as 别名]
# 或者: from notebook.Notebook import modify_tags [as 别名]
class Menu(object):
    "Display a menu and respond to choices when run"
    def __init__(self):
        self.notebook = Notebook()
        self.choices = {
                        "1": self.show_notes,
                        "2": self.search_notes,
                        "3": self.add_note,
                        "4": self.modify_note,
                        "5": self.quit
                        }

    def display_menu(self):
        print "1: show notes, 2: search, 3: add, 4: modify, 5: quit"

    def run(self):
        "Display the menu and respond to choices"
        while True:
            self.display_menu()
            choice = raw_input("> ")
            action = self.choices.get(choice)
            if action:
                action()
            else:
                print "{0} is not a valid choice".format(choice)

    def show_notes(self, notes=None):
        if not notes:
            notes = self.notebook.notes
        for note in notes:
            print "{0}, {1}:\n{2}".format(
                note.id, note.tags, note.memo)

    def search_notes(self):
        pattern = raw_input("Search for: ")
        notes = self.notebook.search(pattern)
        self.show_notes(notes)

    def add_note(self):
        memo = raw_input("Enter a memo: ")
        self.notebook.new_note(memo)
        print "Your note has been added."

    def modify_note(self):
        note_id = int(raw_input("Enter a note id: "))
        if not self.notebook._find_note(note_id):
            return
        memo = raw_input("Enter a memo: ")
        tags = raw_input("Enter tags: ")
        if memo:
            self.notebook.modify_memo(note_id, memo)
        if tags:
            self.notebook.modify_tags(note_id, tags)

    def quit(self):
        print "Thanks for using your notebook today."
        sys.exit()
开发者ID:jainarchita,项目名称:60-days-of-python,代码行数:59,代码来源:menu.py

示例4: Menu

# 需要导入模块: from notebook import Notebook [as 别名]
# 或者: from notebook.Notebook import modify_tags [as 别名]
class Menu(object):
	"""
	display a menu and respond to user choiced to interact 
	with the Note and Notebook when run
	"""

	def __init__(self):
		self.notebook = Notebook()
		self.choices = {
			'1': self.show_notes,
			'2': self.search_notes,
			'3': self.add_notes,
			'4': self.modify_notes,
			'5': self.quit
		}

	def display_menu(self):
		# use triple quotes for managing multiple lines of long printing
		print(
			"""
			Notebook Menu

			1.Show All Notes
			2.Search Notes
			3.Add Notes
			4.Modify Notes
			5.Quit
			"""
		)

	def run(self):
		"""display the menu and respond to choices"""

		while True:
			self.display_menu()
			choice = input('Enter an option: ')
			# .get() allows you to provide a value as the second parameter
			# and return that value if the key is missing, instead of 
			# throwing KeyError
			action = self.choices.get(choice)
			if action:
				action()
			else:
				print( '{0} is not a valid choice'.format(choice) )
	
	def show_notes( self, notes = None ):
		"""
		optional notes parameter. If it's supplied,
		it displays only the filtered notes, but if it's not, it displays all notes
		"""
		if not notes:
			notes = self.notebook.notes

		for note in notes:
			print( '{0}: {1}\n{2}'.format( note.id, note.tags, note.memo ) )

	def search_notes(self):
		filter_string = input('Search For: ')
		notes = self.notebook.search(filter_string)
		self.show_notes(notes)

	def add_note(self):
		memo = input('Enter a memo: ')
		self.notebook.new_note(memo)
		print('Your note has been added.')

	def modify_notes(self):
		id   = input('Enter a note id: ')
		memo = input('Enter a memo: ')
		tags = input('Enter tags: ')
		
		if memo:
			self.notebook.modify_memo( id, memo )
		if tags:
			self.notebook.modify_tags( id, tags )

	def quit(self):
		print('Thank you for using your notebook today.')
		# Exit the interpreter by raising SystemExit(status)
		sys.exit(0)
开发者ID:ethen8181,项目名称:programming,代码行数:82,代码来源:menu.py


注:本文中的notebook.Notebook.modify_tags方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。