コード例 #1
0
ファイル: cmdline.py プロジェクト: BackupTheBerlios/tel-svn
        def get_input(self, field, oldvalue, new):
            """Gets a value from command line input.

            :param field: The fieldname of the edited field
            :param oldvalue: The old value of the field
            :param new: Whether the entry is new"""
            if new:
                prompt = '%s: ' % phonebook.translate_field(field)
            else:
                prompt = '%s [%s]: '
                prompt = prompt % (phonebook.translate_field(field), oldvalue)
            return raw_input(prompt)
コード例 #2
0
ファイル: cmdline.py プロジェクト: BackupTheBerlios/tel-svn
        def get_input(self, field, oldvalue, new):
            """Gets a value from command line input.

            :param field: The fieldname of the edited field
            :param oldvalue: The old value of the field
            :param new: Whether the entry is new"""
            if new:
                prompt = '%s: ' % phonebook.translate_field(field)
            else:
                prompt = '%s [%s]: '
                prompt = prompt % (phonebook.translate_field(field),
                                   oldvalue)
            return raw_input(prompt)
コード例 #3
0
ファイル: cmdline.py プロジェクト: BackupTheBerlios/tel-svn
    def edit(self, entry):
        """Edits `entry`.
        :returns: The edited `entry`"""
        new = entry.parent is None
        print
        if new:
            # entry is new
            print >> stdout, self.NEW_MSG
        else:
            print >> stdout, self.EDIT_MSG % entry

        self.initialize_editor()
        for field in self.fields:
            oldvalue = unicode(entry[field])
            while True:
                value = self.get_input(field, oldvalue, new)
                try:
                    entry[field] = value
                    break
                except ValueError:
                    msg = _('You entered an invalid value for the field'
                            '"%s"!')
                    print >> stdout, msg % phonebook.translate_field(field)
        self.finalize_editor()
        return entry
コード例 #4
0
ファイル: cmdline.py プロジェクト: BackupTheBerlios/tel-svn
    def edit(self, entry):
        """Edits `entry`.
        :returns: The edited `entry`"""
        new = entry.parent is None
        print
        if new:
            # entry is new
            print >> stdout, self.NEW_MSG
        else:
            print >> stdout, self.EDIT_MSG % entry

        self.initialize_editor()
        for field in self.fields:
            oldvalue = unicode(entry[field])
            while True:
                value = self.get_input(field, oldvalue, new)
                try:
                    entry[field] = value
                    break
                except ValueError:
                    msg = _('You entered an invalid value for the field'
                            '"%s"!')
                    print >> stdout, msg % phonebook.translate_field(field)
        self.finalize_editor()
        return entry
コード例 #5
0
ファイル: cmdline.py プロジェクト: BackupTheBerlios/tel-svn
 def _cmd_help_fields(self, options, *args):
     if not args:
         args = phonebook.FIELDS
     try:
         items = [(phonebook.translate_field(field), unicode(field))
                  for field in args]
     except phonebook.NoSuchField, e:
         exit(_('There is no field %s.') % e.field)
コード例 #6
0
ファイル: cmdline.py プロジェクト: BackupTheBerlios/tel-svn
 def _cmd_help_fields(self, options, *args):
     if not args:
         args = phonebook.FIELDS
     try:
         items = [(phonebook.translate_field(field), unicode(field))
                  for field in args]
     except phonebook.NoSuchField, e:
         exit(_('There is no field %s.') % e.field)
コード例 #7
0
ファイル: cmdline.py プロジェクト: BackupTheBerlios/tel-svn
        def get_input(self, field, oldvalue, new):
            """Gets a value from command line input.

            :param field: The fieldname of the edited field
            :param oldvalue: The old value of the field
            :param new: Whether the entry is new"""
            if not new:
                self.oldvalue = oldvalue
            else:
                self.oldvalue = None
            prompt = u'%s: ' % phonebook.translate_field(field)
            return raw_input(prompt)
コード例 #8
0
ファイル: cmdline.py プロジェクト: BackupTheBerlios/tel-svn
        def get_input(self, field, oldvalue, new):
            """Gets a value from command line input.

            :param field: The fieldname of the edited field
            :param oldvalue: The old value of the field
            :param new: Whether the entry is new"""
            if not new:
                self.oldvalue = oldvalue
            else:
                self.oldvalue = None
            prompt = u'%s: ' % phonebook.translate_field(field)
            return raw_input(prompt)