def main():
    n = Note('hello')
    print('Testing of class Note')
    print()
    print(type(n))
    print(dir(n))
    print(n.__str__())
    print(n.__init__)
    print(n.__dict__)
    print(n.tags)
    print(n.memo)
    print(n.creation_date)
    print(n.match('hello'))
    print(n.match('hi'))
    print(n.id)

    nb = Notebook()
    print('Testing of class Notebook')
    print()
    print(type(nb))
    print(dir(nb))
    print(nb.__str__())
    print(nb.__init__)
    print(nb.__dict__)
    print(nb.notes)
    print(nb.new_note('hi'))
Ejemplo n.º 2
0
import sys
from notebook import Notebook, Note
from menu import Menu

if __name__ == "__main__":

    print('___' * 30)

    n1 = Note("hello first")
    n2 = Note("hello again")
    print('\nClass Note')
    print('ID of the first note:', n1.id)  # 1
    print('ID of the second note:', n2.id)  # 2
    print('Function match, the first note:', n1.match('hello'))  # True
    print('Function match, the second note:', n2.match('second'))  # False
    print('\ndir, class Note:', dir(Note))
    print('\ndir, the first note:', dir(n1))
    print("\ndir, n1.match", dir(n1.match))
    print('\nn1 is Note:', isinstance(n1, Note))
    print('n1 is object:', isinstance(n1, object))
    print('type of n1.id:', type(n1.id))
    print('type of n1.tags:', type(n1.tags))
    print('type of n1.creation_date:', type(n1.creation_date))
    print('\ndict of n1:', n1.__dict__)

    print('___' * 30)

    n = Notebook()
    n.new_note("hello world")
    n.new_note("hello again")
    print('\nClass Notebook')
Ejemplo n.º 3
0
from notebook import Note

n1 = Note("Hello first")
n2 = Note("Hello", 'tag1 teg2')

print(n1.id, n2.id)
print(n1.match('Hello'), n2.match('he'))

from notebook import Notebook
n = Notebook()
n.new_note('Hello', 'first note in the note book')
n.new_note('See you')
print(n.notes)
for note in n.notes:
    print(note.id)
n.modify_tags(4, 'checked')
n.modify_memo(3, "Hello again!")
print(n.notes[0].memo, ';', n.notes[1].tags)
print(n.search('you'), n.search('You'))
Ejemplo n.º 4
0
from notebook import Note, Notebook

if __name__ == "__main__":
    note1 = Note("My first note")
    print('Id of note1:', note1.id)
    note2 = Note("My second first note")
    print('Id of note2:', note2.id)
    print(note2.match('second'))

    print('\nIs n1 type - object?')
    print(isinstance(note1, object),'\n')

    print('\nThe contents of object note1:\n',dir(note1))
    print('\nThe contents of class Note:\n',dir(Note))

    print('\nType of note1.__init__(''):',type(note1.__init__('NoneType')))
    print('The contents of note1.__init__(''):\n',dir(note1.__init__('')))

    print('\nIs type of note1.memo: str?')
    print(isinstance(note1.memo, str))
    print('\nType of note1.creation_date')
    print(type(note1.creation_date))

    note1.type_self()

    print('\nType of note1.__str__')
    print(type(note1.__str__))
    print('Dir of note1.__str___')
    print(dir(note1.__str__))

    n = Notebook()
Ejemplo n.º 5
0
from notebook import Notebook, Note
from menu import Menu

# Exploring Note
print("Let's explore Note: \n")
note = Note("It's a new notebook.")
print('memo: ', note.memo)
print('memo type: ', type(note.memo))
print('id: ', note.id)
print('id type: ', type(note.id))
print('creation date: ', note.creation_date)
print('creation date type: ', type(note.creation_date), '\n')

print('Exploring some class methods: ')
print("method match: ")
print(note.match('new'))
print(note.match('hello'))

print('\nAll attributes of class Note: ')
print(dir(Note))

print("\nDocumentation of note: ")
print(note.__doc__)

print("Type of note: ")
print(type(note))

print("\nWhether note is object: ")
print(isinstance(note, object))

print("\nWhether note is Note: ")
Ejemplo n.º 6
0
 def test_match_bad(self):
     """Must not match when filter is not present in memo or tags"""
     n1 = Note('first note', 'one')
     self.assertFalse(n1.match('second'))
     self.assertFalse(n1.match('two'))
     self.assertFalse(n1.match('notebook'))
Ejemplo n.º 7
0
from notebook import Note, Notebook
from menu import Menu

n1 = Note("hello first")
n2 = Note("hello again")
print(n1.id)
print(n2.id)
n1.match('hello')
n2.match('second')

notb = Notebook()
notb.new_note("hello world")
notb.new_note("hello again")
print(notb.notes)

print(notb.notes[0].id)
print(notb.notes[1].id)

notb.notes[0]
notb.search("hello")
notb.search("world")

notb.modify_memo(1, "hi world")
print(notb.notes[0].memo)

print(dir(notb))
print(dir(n2))

print(isinstance(n1, Note))
print(isinstance(notb, Notebook))
Ejemplo n.º 8
0
class Note:
    '''Represent a note in the notebook. Match against a string in searches and store tags for each note.'''
    def __init__(self, memo, tags=''):
        '''initialize a note with memo and optional space-separated tags.
        Automatically set the note's creation date and a unique id.'''
        self.memo = memo
        self.tags = tags
        self.creation_date = datetime.date.today()
        global last_id
        last_id += 1
        self.id = last_id

    def match(self, filter):
        '''Determine if this note matches the filter text.
        Return True if it matches, False otherwise.

        Search is case sensitive and matches both text and tags.'''
        return filter in self.memo or filter in self.tags


from notebook import Note

n1 = Note("hello first")
n2 = Note("hello again")

print(n1.id)
print(n1.match('hello'))
print(n2.id)
print(n2.match('again'))
# print(n1.match('wow'))
Ejemplo n.º 9
0
 def test_match(self):
     """Note must match string present in its memo and tags"""
     n1 = Note('first note', 'one')
     self.assertTrue(n1.match('first'))
     self.assertTrue(n1.match('note'))
     self.assertTrue(n1.match('one'))
Ejemplo n.º 10
0
print('Exploring classes Notebook and Note:')
print('Note1: Hello it is me!!!')
print('Note2: Here me again.')
print('Note3: Hello everyone in the world.')

notee = Note('Hello it is me!!!', 'me')
noteee = Note('Here me again', 'hi!')
note = Note('Hello everyone in the world.', 'world')
notebook = Notebook()

print(
    'Type of the note, the dictionary of first note, first note attributes: ')
print(type(notee))
print(notee.__dict__)
print(dir(notee))
note_match = notee.match('my note')
note_match2 = notee.match('Hello')
print('first note match function result(word: my note):', note_match)
print('first note match function result(word: Hello): ', note_match2)

notebook.new_note(notee.memo, notee.tags)  #сreating a new note
notebook.new_note(noteee.memo, noteee.tags)
notebook.new_note(note.memo, note.tags)
print('All notes in the notebook:')
for note in notebook.notes:
    print(note.__dict__)

print('Notebook notes: ')
print(notebook.notes)

print('Find the first note:')
Ejemplo n.º 11
0
from notebook import Note, Notebook

if __name__ == "__main__":
    n1 = Note("hello first")
    n2 = Note("hello again")
    print(n1.id)
    print(n2.id)
    n1.match('hello')
    n = Notebook()
    print(dir(n))
    print(n.__dir__)
    print(n.__dict__)
    print(isinstance(n.modify_memo, object))
    print(isinstance(n.modify_memo, Note))
    print(isinstance(n.modify_memo, Notebook))
    print(isinstance(n1.match, object))
    print(isinstance(n1, object))

    n.new_note("hello world")
    print(n.notes[0])
    print(n.notes[0].id)
    print(dir(n))
    print(n.__dict__)
    n.new_note("hello again")
    print(isinstance(n.new_note, object))
    print(isinstance(n.__dict__, object))
    print(isinstance(n.notes[0].id, object))

    print(n.__dict__)
    print(n.notes[0].memo)
    print(n.notes[1].memo)
Ejemplo n.º 12
0
def test_search_succeeds_when_filter_term_in_memo():
    note = Note("hello first")
    assert note.match("hello") == True
Ejemplo n.º 13
0
def test_search_fails_when_filter_term_not_in_memo():
    note = Note("hello again")
    assert note.match("second") == False
Ejemplo n.º 14
0
print("Created notebook.")

print("\nIs notebook an object?", isinstance(notebook, object))
print("Is note an object?", isinstance(note, object))
print("Is notebook.new_note('Elon Musk', 'Elon') an object?",
      isinstance(notebook.new_note('Elon Musk'), object))
print("Is notebook.search('Elon') an object?",
      isinstance(notebook.search('Elon'), object))
print("Is notebook.__init__() an object?",
      isinstance(notebook.__init__(), object))
print("Is notebook.__str__() a string?", isinstance(notebook.__str__(), str))
print("Is note.memo a string?", isinstance(note.memo, str))
print("Is notebook an object of class Notebook?",
      isinstance(notebook, Notebook))

print("\nIs the word 'Steve' in note?", note.match('I'))
print("Is the word 'love' in note?", note.match('love'))

print("\nAdding new notes to the notebook...")
notebook.new_note('You are not Steve Jobs!', 'answer 1')
notebook.new_note('I am.', 'answer 2')
for note in notebook.notes:
    print('Memo: {}, Tag: {}.'.format(note.memo, note.tags))

print("\nModifying memo of the first note:")
notebook.modify_memo(notebook.notes[0].id, 'Nice boy')
for note in notebook.notes:
    print('Memo: {}, Tag: {}.'.format(note.memo, note.tags))

print("\nModifying tag of the first note:")
notebook.modify_tags(notebook.notes[0].id, 'Boy')