~sircmpwn/hiprompt-gtk-py

9c457a9ccf31b7898491e2ff061c0b71c9b934a3 — Drew DeVault 2 years ago e402f47
key.py: fix parsing of values with symbols
3 files changed, 14 insertions(+), 11 deletions(-)

M hiprompt_gtk/key.py
M hiprompt_gtk/proto.py
M hiprompt_gtk/window.py
M hiprompt_gtk/key.py => hiprompt_gtk/key.py +3 -1
@@ 6,7 6,7 @@ class Key:
    def __init__(self, key):
        self._pairs = []

        lexer = shlex.shlex(StringIO(key), punctuation_chars="=")
        lexer = shlex.shlex(StringIO(key))
        lexer.commenters = ''

        while True:


@@ 19,7 19,9 @@ class Key:
            while True:
                tok = lexer.get_token()
                if tok == "=":
                    lexer.whitespace_split = True
                    value = lexer.get_token()
                    lexer.whitespace_split = False
                    value = shlex.split(value)[0]
                    self._pairs.append(Pair(key, value, optional, private))
                    break

M hiprompt_gtk/proto.py => hiprompt_gtk/proto.py +6 -7
@@ 5,7 5,6 @@ from .key import Key

class PromptMode(Enum):
    disclose = "disclose"
    unlock = "unlock"


class Session:


@@ 27,7 26,8 @@ class Session:
                break

    def _version(self, args):
        print("version 0.0.0")
        sys.stdout.write("version 0.0.0\n")
        sys.stdout.flush()

    def _key(self, args):
        self.keys.append(Key(args))


@@ 45,12 45,11 @@ class Session:
        until the daemon answers regarding the password's validity, returning
        True if it was correct and False otherwise.
        """
        sys.stdout.write(f"password {pw}\n")
        sys.stdout.flush()
        # TODO: Don't block
        print(f"password {pw}")
        line = sys.stdin.readline()
        if line == "":
            return True
        elif line == "incorrect-password":
        if line == "incorrect-password":
            return False
        else:
            assert False
            return True

M hiprompt_gtk/window.py => hiprompt_gtk/window.py +5 -3
@@ 25,12 25,14 @@ class Window:

        self.entry = None

        if self.session.mode == PromptMode.unlock:
            self.make_unlock_ui()
        elif self.session.mode == PromptMode.disclose:
        if self.session.mode == PromptMode.disclose:
            self.make_disclose_ui()
        else:
            raise ValueError("Unexpected mode")

        if self.session.unlock:
            self.make_unlock_ui()

        self.header.show_all()

    def on_close(self, *args):