dbrtools/dbr/dbrresults.py
author MattD <mattd@symbian.org>
Sun, 13 Jun 2010 15:29:20 +0100
branchDBRToolsDev
changeset 283 398d483e91bb
parent 242 9fd4819bf104
permissions -rw-r--r--
Changed help so that summaries come from components. Added smoketest method to try to reduce regressions (when I write some tests). A few minor cleanups.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
242
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
     1
# Copyright (c) 2010 Symbian Foundation Ltd
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
     2
# This component and the accompanying materials are made available
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
     3
# under the terms of the License "Eclipse Public License v1.0"
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
     4
# which accompanies this distribution, and is available
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
     5
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
     6
#
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
     7
# Initial Contributors:
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
     8
# Symbian Foundation Ltd - initial contribution.
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
     9
#
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    10
# Contributors:
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    11
# mattd <mattd@symbian.org>
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    12
#
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    13
# Description:
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    14
# DBRResults - DBR Comparison results classes  
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    15
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    16
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    17
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    18
class DBRResults:
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    19
  added = set()
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    20
  removed = set()
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    21
  touched = set()
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    22
  changed = set()
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    23
  unknown = set()
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    24
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    25
  def __init__(self, added, removed, touched, changed, unknown):
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    26
    #Should probably assert that these are disjoint.
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    27
    self.added = added
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    28
    self.removed = removed
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    29
    self.touched = touched
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    30
    self.changed = changed
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    31
    self.unknown = unknown
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    32
    
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    33
  def __rand__(self, other):
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    34
    return DBRResults(self.added & other.added, self.removed & other.removed, self.touched & other.touched, self.changed & other.changed, self.unknown & other.unknown)
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    35
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    36
  def __iand__(self, other):
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    37
    self.added &= other.added
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    38
    self.removed &= other.removed
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    39
    self.touched &= other.touched
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    40
    self.changed &= other.changed
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    41
    self.unknown &= other.unknown  
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    42
    return self
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    43
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    44
  def __ror__(self, other):
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    45
    return DBRResults(self.added | other.added, self.removed | other.removed, self.touched | other.touched, self.changed | other.changed, self.unknown | other.unknown)
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    46
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    47
  def __ior__(self, other):
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    48
    self.added |= other.added
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    49
    self.removed |= other.removed
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    50
    self.touched |= other.touched
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    51
    self.changed |= other.changed
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    52
    self.unknown |= other.unknown
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    53
    return self
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    54
  
283
398d483e91bb Changed help so that summaries come from components. Added smoketest method to try to reduce regressions (when I write some tests). A few minor cleanups.
MattD <mattd@symbian.org>
parents: 242
diff changeset
    55
  def __sub__(self, other):
398d483e91bb Changed help so that summaries come from components. Added smoketest method to try to reduce regressions (when I write some tests). A few minor cleanups.
MattD <mattd@symbian.org>
parents: 242
diff changeset
    56
    return DBRResults(self.added - other.added, self.removed - other.removed, self.touched - other.touched, self.changed - other.changed, self.unknown - other.unknown)
242
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    57
         
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    58
  def printdetail(self):
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    59
    for file in sorted(self.added):
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    60
      print 'added:', file
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    61
    for file in sorted(self.removed):
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    62
      print 'removed:', file
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    63
    for file in sorted(self.changed):
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    64
      print 'changed:', file
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    65
    for file in sorted(self.unknown):
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    66
      print 'unknown:', file
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    67
    
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    68
  def printsummary(self):
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    69
    if(len(self.added | self.removed | self.changed | self.unknown)):
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    70
      print 'status: dirty'
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    71
    else:
9fd4819bf104 DBRTools - Added filtering support. It's currently implmented in checkenv and diffenv, but adding it to other commands is pretty easy.
MattD <mattd@symbian.org>
parents:
diff changeset
    72
      print 'status: clean'