Skip to content

Commit

Permalink
compose cmd class.
Browse files Browse the repository at this point in the history
  • Loading branch information
liwei-lai committed Oct 14, 2012
1 parent 7f4a5b5 commit 98c185e
Showing 1 changed file with 75 additions and 5 deletions.
80 changes: 75 additions & 5 deletions papyrus.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# -*- coding:utf-8 -*-
"""
pypw.handler
~~~~~~~~~~~~
papyrus
~~~~~~~
Implements the actually handling object for pypw.
A simple cmd program that manage the infomation of passwords.
:copyright: (c) 2012 by Jason Lai.
:license: BSD, see LICENSE for more details.
"""

import os
import json
import cmd
import logging
import hashlib
from datetime import datetime
Expand All @@ -28,7 +29,7 @@ class AESHandler(object):

def __init__(self):
# Initialize Log
self.log = logging.getLogger('pypw')
self.log = logging.getLogger('papyrus')
# Initialize the attributes of class
self.initialized = False
self.filepath = ''
Expand Down Expand Up @@ -133,7 +134,7 @@ def delete_record(self, group, item):

@property
def records(self):
pass
return self._records

def _init_data(self):
structure = {
Expand Down Expand Up @@ -212,3 +213,72 @@ def decrypt(cls, ciphertext, key):
iv = Random.new().read(AES.block_size)
cipher = AES.new(key, AES.MODE_CFB, iv)
return cipher.decrypt(ciphertext)[AES.block_size:]


class Papyrus(cmd.Cmd):
"""A simple cmd program that manage the infomation of passwords."""

prompt = u'(papyrus) >>> '
intro = ("Papyrus: A simple cmd program that manage the infomation of "
"passwords.\n")

def do_init(self, line):
"""Help message:
Usage: init [init_cipher]
Initialize the program. This operation should be launched before
other operations.
"""
print line

def do_ls(self, line):
"""Help message:
Usage: ls {group | record | `group_name` | `group_id`}
List all the groups or records existing in the current program.
"""
print line

def do_add(self, line):
"""Help message:
Usage:
"""
pass

def do_update(self, line):
"""Help message:
Usage:
"""
pass

def do_del(self, line):
"""Help message:
Usage:
"""
pass

def complete_del(self, text, line, begidx, endidx):
pass

def complete_update(self, text, line, begidx, endidx):
pass

def complete_ls(self, text, line, begidx, endidx):
pass

def do_quit(self, line):
"""Help message:
Usage: quit
Exit the program.
"""
return True

def do_EOF(self, line):
"""Exit"""
return True


if __name__ == '__main__':
Papyrus().cmdloop()

0 comments on commit 98c185e

Please sign in to comment.