예제 #1
0
파일: cli.py 프로젝트: chutzimir/kedpm
    def do_new(self, arg):
        '''Add new password to current category. You will be prompted to enter
fields.

Syntax:
    new [-p | -t]

    -p - Get properties by parsing provided text. Will open default text editor
         for you to paste text in. Mutually exclusive with -t option. 
    -t - Display editor template in default text editor. Mutually exclusive with -p option.
'''
        new_pass = FigaroPassword() # FIXME: Password type shouldn't be hardcoded.
        argv = arg.split()

        if   "-p" in argv and "-t" in argv:
            print _("new: -p and -t arguments are mutually exclusive.")          
            print _("try 'help new' for more information")
        elif "-p" in argv:
            text = self.getEditorInput()
            choosendict = parser.parseMessage(text, self.conf.patterns)
            new_pass.update(choosendict)
        elif "-t" in argv:
            text = self.getEditorInput(new_pass.asEditText())
            choosendict = parser.parseMessage(text, [new_pass.getEditPattern()])
            new_pass.update(choosendict)

        try:
            self.editPassword(new_pass)
        except (KeyboardInterrupt, EOFError):
            self.printMessage(_("Cancelled"))
        else:
            tree = self.getCwd()
            tree.addNode(new_pass)
            self.tryToSave()
예제 #2
0
    def do_new(self, arg):
        '''Add new password to current category. You will be prompted to enter
fields.

Syntax:
    new [-p]

    -p - Get properties by parsing provided text. Will open default text editor
         for you to paste text in.
'''
        new_pass = FigaroPassword(
        )  # FIXME: Password type shouldn't be hardcoded.
        argv = arg.split()

        if "-p" in argv:
            text = self.getEditorInput()
            choosendict = parser.parseMessage(text, self.conf.patterns)
            new_pass.update(choosendict)

        try:
            self.editPassword(new_pass)
        except (KeyboardInterrupt, EOFError):
            print "Cancelled"
        else:
            tree = self.getCwd()
            tree.addNode(new_pass)
            self.tryToSave()
예제 #3
0
파일: wnd_main.py 프로젝트: widgital/kedpm
 def on_mi_parse_password_activate(self, widget):
     dlg = dialogs.ParsePasswordDialog()
     response = dlg.run()
     if response == gtk.RESPONSE_OK:
         pswd = FigaroPassword()
         pswd.update(dlg.parseddict)
         self.addPasswordInteractively(pswd)
예제 #4
0
파일: wnd_main.py 프로젝트: sbjud/kedpm
 def on_mi_parse_password_activate(self, widget):
     dlg = dialogs.ParsePasswordDialog()
     response = dlg.run()
     if response == gtk.RESPONSE_OK:
         pswd = FigaroPassword()
         pswd.update(dlg.parseddict)
         self.addPasswordInteractively(pswd)
예제 #5
0
파일: cli.py 프로젝트: chutzimir/kedpm
    def do_import(self, arg):
        '''Imports new password records into current category.
Syntax:
    import
    
    Get properties by parsing provided text. Will open default text editor
    for you to paste text in.
'''
        argv = arg.split()
        tree = self.getCwd()

        text = self.getEditorInput()
        for line in text.split("\n"):
            new_pass = FigaroPassword() # FIXME: Password type shouldn't be hardcoded.
            choosendict = parser.parseMessage(line, self.conf.patterns)
            new_pass.update(choosendict)
            tree.addNode(new_pass)

        self.tryToSave()
예제 #6
0
    def do_new(self, arg):
        '''Add new password to current category. You will be prompted to enter
fields.

Syntax:
    new [-p | -t]

    -p - Get properties by parsing provided text. Will open default text editor
         for you to paste text in. Mutually exclusive with -t option. 
    -t - Display editor template in default text editor. Mutually exclusive with -p option.

    If the config option 'force-editor is set, this command defaults to the -t option when no options are provided.
'''
        new_pass = FigaroPassword(
        )  # FIXME: Password type shouldn't be hardcoded.

        argv = arg.split()

        use_visual_editor = len(
            argv) == 0 and self.conf.options["force-editor"]

        if "-p" in argv and "-t" in argv:
            print _("new: -p and -t arguments are mutually exclusive.")
            print _("try 'help new' for more information")
        elif "-p" in argv:
            text = self.getEditorInput()
            choosendict = parser.parseMessage(text, self.conf.patterns)
            new_pass.update(choosendict)
        elif "-t" in argv or use_visual_editor:
            text = self.getEditorInput(new_pass.asEditText())
            choosendict = parser.parseMessage(text,
                                              [new_pass.getEditPattern()])
            new_pass.update(choosendict)

        try:
            if not use_visual_editor:
                self.editPassword(new_pass)
        except (KeyboardInterrupt, EOFError):
            self.printMessage(_("Cancelled"))
        else:
            tree = self.getCwd()
            tree.addNode(new_pass)
            self.tryToSave()
예제 #7
0
    def do_import(self, arg):
        '''Imports new password records into current category.
Syntax:
    import
    
    Get properties by parsing provided text. Will open default text editor
    for you to paste text in.
'''
        argv = arg.split()
        tree = self.getCwd()

        text = self.getEditorInput()
        for line in [x for x in text.splitlines() if x]:
            new_pass = FigaroPassword(
            )  # FIXME: Password type shouldn't be hardcoded.
            choosendict = parser.parseMessage(line, self.conf.patterns)
            new_pass.update(choosendict)
            tree.addNode(new_pass)

        self.tryToSave()