Bläddra i källkod

Add skeleton for new text UI

oz123 10 år sedan
förälder
incheckning
6e2a6289a4
2 ändrade filer med 122 tillägg och 0 borttagningar
  1. 41 0
      pwman/tests/test_base_ui.py
  2. 81 0
      pwman/ui/baseui.py

+ 41 - 0
pwman/tests/test_base_ui.py

@@ -0,0 +1,41 @@
+# ============================================================================
+# This file is part of Pwman3.
+#
+# Pwman3 is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License, version 2
+# as published by the Free Software Foundation;
+#
+# Pwman3 is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Pwman3; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+# ============================================================================
+# Copyright (C) 2014 Oz Nahum Tiram <nahumoz@gmail.com>
+# ============================================================================
+import os
+import unittest
+from pwman.data.drivers.sqlite import SQLite
+from pwman.data.nodes import Node
+from pwman.util.crypto_engine import CryptoEngine
+from .test_crypto_engine import give_key, DummyCallback
+from pwman.ui.baseui import BaseCommands
+
+
+class TestSQLite(unittest.TestCase):
+
+    pass
+
+if __name__ == '__main__':
+
+    ce = CryptoEngine.get()
+    ce.callback = DummyCallback()
+    ce.changepassword(reader=give_key)
+
+    try:
+        unittest.main(verbosity=2, failfast=True)
+    except SystemExit:
+        os.remove('test.db')

+ 81 - 0
pwman/ui/baseui.py

@@ -0,0 +1,81 @@
+# ============================================================================
+# This file is part of Pwman3.
+#
+# Pwman3 is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License, version 2
+# as published by the Free Software Foundation;
+#
+# Pwman3 is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Pwman3; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+# ============================================================================
+# Copyright (C) 2013, 2014 Oz Nahum Tiram <nahumoz@gmail.com>
+# ============================================================================
+from __future__ import print_function
+from pwman.util.crypto_engine import CryptoEngine, zerome
+import re
+import sys
+import os
+import time
+import select as uselect
+import ast
+from pwman.util.config import get_pass_conf
+from pwman.ui import tools
+from pwman.ui.tools import CliMenuItem
+from colorama import Fore
+from pwman.data.nodes import NewNode, Node
+from pwman.ui.tools import CMDLoop
+import getpass
+from pwman.data.tags import TagNew
+import csv
+
+if sys.version_info.major > 2:
+    raw_input = input
+
+from base import HelpUI
+
+
+class BaseCommands(HelpUI):
+
+    def do_copy(self, args):
+        """copy item to clipboard"""
+        pass
+
+    def do_exit(self, args):
+        """close the text console"""
+        pass
+
+    def do_export(self, args):
+        """export the database to a given format"""
+        pass
+
+    def do_forget(self, args):
+        """drop saved key forcing the user to re-enter the master
+        password"""
+        pass
+
+    def do_cls(self, args):
+        """clear the screen"""
+        pass
+
+    def do_edit(self, args):
+        """edit a node"""
+        pass
+
+    def do_clear(self, args):
+        """remove db filter"""
+        pass
+
+    def do_passwd(self, args):
+        """change the master password of the database"""
+        pass
+
+    def do_tags(self, args):
+        """print all existing tags """
+
+