note package

Submodules

note.client module

class note.client.Note_Client[source]

Bases: object

This is the client side library to interact with the note server

Encrypt()[source]
Send(msg)[source]

Add a note to the database on the server :param msg: The text of the note. :type msg: str :param tags: A list of tags to associate with the note. :type tags: list :returns: The message from the server :rtype: str

note.db_api module

class note.db_api.dbBaseClass[source]

Bases: object

addItem(itemType, itemContents, itemID=None)[source]
deleteItem(itemID)[source]
getItem(itemID)[source]
makeBackupFile(dstPath, fileName)[source]
searchForItem(searchInfo, resultLimit=20, sortBy='relevance')[source]

note.mongo_driver module

class note.mongo_driver.mongoDB(dbName, uri=None)[source]

Bases: note.db_api.dbBaseClass

addItem(itemType, itemContents, itemID=None)[source]
Parameters:
  • itemType (str) – The type of the item, note, place, todo
  • itemContents (dict) – A dictionary of the item contents
  • itemID (int) – When editing a note, send the ID along with it
deleteItem(itemID)[source]
Desc:Deletes item with ID = itemID, takes care of IDs collection
Parameters:itemID (int) – The item ID to delete
Raises:ValueError
Returns ID:The ID of the deleted item
Rval:int
getAllItemTypes()[source]
Desc:Fetches a list of item types
Returns:A list of item types:
Rval:list
getByTime(startTime=None, endTime=None)[source]
Desc:

Get all the notes in the given time window

Parameters:
  • startTime (int) – The begining of the window
  • endTime (int) – The end of the window
Returns:

A list of IDs

Ravl:

list

getDone(done)[source]
Desc:Fetches a list of all the done ToDs
Parameters:done (bool) – done or undone?
Returns:A list of matching IDs
Rval:list
getItem(itemID)[source]
Desc:

Given an ID return the note JSON object {u’noteText’: u’note8’,

u’ID’: 3.0, u’tags’: [u‘8’], u’timestamps’: [1381719620.315899]}

Parameters:

itemID (int) – The item ID, an integer

Returns:

The matching note

Rval:

int

getItemType(itemID)[source]
Desc:Given an itemID, return the “type” i.e. the collection it belongs to.
Parameters:itemID (int) – The item ID, an integer
Returns:The note type
Rval:str
getNewID()[source]
Desc:Get a new ID by either incrementing the currentMax ID or using an unusedID
Returns:A new, valid, ID
Rval:int
makeBackupFile(dstPath, fileName)[source]
Parameters:
  • dstPath (str) – The destination path of the backup file
  • fileName (str) – The filename to use
searchForItem(searchInfo, resultLimit=20, sortBy='relevance')[source]
Desc:

Given a search term returns a list of results that match that term:

[{u’score’: 5.5,
u’obj’: {u’noteText’: u’note8’,

u’ID’: 3.0, u’timestamps’: [1381719620.315899]}}]

Parameters:

searchInfo (str) – The search term

Returns:

A list of matching notes

Rval:

list

verify()[source]
Desc:Verifies the integrity of the database, specifically checks the values for unusedIDs and currentMax
Returns:A boolean indicating whether the database is valid or not
Rval:bool

note.note_printer module

class note.note_printer.Note_Printer[source]

Bases: object

Print()[source]
print_OK()[source]
print_error()[source]

note.server module

class note.server.Note_Server(db_name='note')[source]

Bases: object

Check_Message(msg)[source]

Verifies the message is a valid note message

Handle_Delete(msg)[source]
Param:msg the JSON message from the client
Returns:The reply from the db driver
Rvalue:str
Handle_ERROR(msg)[source]
Handle_Events(events)[source]

Handle events from poll()

Events:A list of tuples form zmq.poll()
Returns:None
Handle_Get(msg)[source]
Param:msg the JSON message from the client
Returns:The reply from the db driver
Rvalue:str
Handle_NewNote(msg)[source]

Handle a new note.

Parameters:msg (dict) – the received note
Returns:The message to reply with
Return type:str
Handle_Place(msg)[source]
Handle_Receive(msg)[source]

Handle a received message.

Parameters:msg (str) – the received message
Returns:The message to reply with
Return type:str

Handle a search.

Parameters:msg (dict) – the received search
Returns:The message to reply with
Return type:str
Run()[source]

Wait for clients to connect and service them

Returns:None

note.sql_driver module

class note.sql_driver.sqliteDB[source]

Bases: note.db_api.dbBaseClass

addItem(itemType, itemContents)[source]
deleteItem(itemID)[source]
getItem(itemID)[source]
makeBackupFile()[source]
searchForItem(searchInfo)[source]

note.util module

note.util.scrubID(ID)[source]
Parameters:ID – An ID that can be of various types, this is very kludgy
Returns:An integer ID
note.util.which(bin_name)[source]
Parameters:bin_name – the name of the binary to test for (e.g. vim)
Returns:True or False depending on wether the binary exists

note.web module

note.web.Delete(*args, **kwargs)[source]
note.web.NewContact(*args, **kwargs)[source]
note.web.NewNote(*args, **kwargs)[source]
note.web.NewTodo(*args, **kwargs)[source]
note.web.Notes(*args, **kwargs)[source]
note.web.authenticate()[source]

Sends a 401 response that enables basic auth

note.web.check_auth(username, password)[source]

This function is called to check if a username / password combination is valid.

note.web.main()[source]
note.web.newPlace(*args, **kwargs)[source]
note.web.parseArgs()[source]
note.web.requires_auth(f)[source]
note.web.search(*args, **kwargs)[source]
note.web.start(*args, **kwargs)[source]

Module contents