~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: Marius Kruger
  • Date: 2006-12-22 06:04:04 UTC
  • mto: (2220.1.1 bzr.enhanced_move)
  • mto: This revision was merged to the branch mainline in revision 2241.
  • Revision ID: amanic@gmail.com-20061222060404-49pvclo8t1v8eiyx
* errors
  - change comments to doc-strings
  - Make FilesExist handle plurals properly for 1 or more files
  - change contextInfo to context_info
* test_mv
  - apply error message suggestions
* workingtree
  - remov old style error imports
  - fix some long lines

Show diffs side-by-side

added added

removed removed

Lines of Context:
320
320
 
321
321
 
322
322
class FilesExist(PathError):
 
323
    """Used when reporting that files do exist"""
323
324
    
324
 
    _fmt = "File(s) exist: %(paths_as_string)s%(extra)s"
325
 
 
326
 
    # used when reporting that files do exist
 
325
    _fmt = "File%(plural)s exist: %(paths_as_string)s%(extra)s"
327
326
 
328
327
    def __init__(self, paths, extra=None):
329
328
        # circular import
330
329
        from bzrlib.osutils import quotefn
331
330
        BzrError.__init__(self)
332
331
        self.paths = paths
333
 
        self.paths_as_string = ' '.join([quotefn(p) for p in paths])
 
332
        self.paths_as_string = ' '.join(paths)
334
333
        if extra:
335
334
            self.extra = ': ' + str(extra)
336
335
        else:
337
336
            self.extra = ''
 
337
        if len(paths) > 1:
 
338
            self.plural = 's'
 
339
        else:
 
340
            self.plural = ''
338
341
 
339
342
class NotADirectory(PathError):
340
343
 
519
522
 
520
523
 
521
524
class AlreadyVersionedError(BzrError):
522
 
    #Used when a path is expected not to be versioned, but it is.
 
525
    """Used when a path is expected not to be versioned, but it is."""
523
526
    
524
 
    _fmt = "%(contextInfo)s%(path)s is already versioned"
 
527
    _fmt = "%(context_info)s%(path)s is already versioned"
525
528
 
526
 
    def __init__(self, path, contextInfo=None):
 
529
    def __init__(self, path, context_info=None):
527
530
        """Construct a new NotVersionedError.
528
531
 
529
532
        :param path: This is the path which is versioned, 
530
533
        which should be in a user friendly form.
531
 
        :param contextInfo: If given, this is information about the context,
 
534
        :param context_info: If given, this is information about the context,
532
535
        which could explain why this is expected to not be versioned.
533
536
        """
534
537
        BzrError.__init__(self)
535
538
        self.path = path
536
 
        if contextInfo is None:
537
 
            self.contextInfo = ''
 
539
        if context_info is None:
 
540
            self.context_info = ''
538
541
        else:
539
 
            self.contextInfo = contextInfo + ": "
 
542
            self.context_info = context_info + ". "
540
543
 
541
544
 
542
545
class NotVersionedError(BzrError):
543
 
    #Used when a path is expected to be versioned, but it is not.
 
546
    """Used when a path is expected to be versioned, but it is not."""
544
547
    
545
 
    _fmt = "%(contextInfo)s%(path)s is not versioned"
 
548
    _fmt = "%(context_info)s%(path)s is not versioned"
546
549
 
547
 
    def __init__(self, path, contextInfo=None):
 
550
    def __init__(self, path, context_info=None):
548
551
        """Construct a new NotVersionedError.
549
552
 
550
553
        :param path: This is the path which is not versioned, 
551
554
        which should be in a user friendly form.
552
 
        :param contextInfo: If given, this is information about the context,
 
555
        :param context_info: If given, this is information about the context,
553
556
        which could explain why this is expected to be versioned.
554
557
        """
555
558
        BzrError.__init__(self)
556
559
        self.path = path
557
 
        if contextInfo is None:
558
 
            self.contextInfo = ''
 
560
        if context_info is None:
 
561
            self.context_info = ''
559
562
        else:
560
 
            self.contextInfo = contextInfo + ": "
 
563
            self.context_info = context_info + ". "
561
564
        
562
565
        
563
566
class PathsNotVersionedError(BzrError):
564
 
    # used when reporting several paths which are not versioned
 
567
    """Used when reporting several paths which are not versioned"""
565
568
 
566
569
    _fmt = "Path(s) are not versioned: %(paths_as_string)s"
567
570