Changeset 288
- Timestamp:
- 03/08/06 01:17:30 (3 years ago)
- Files:
-
- pycrash/trunk/crash/component.py (modified) (3 diffs)
- pycrash/trunk/crash/console.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
pycrash/trunk/crash/component.py
r287 r288 27 27 class ComponentError(Exception): pass 28 28 29 class InterfaceMeta(type): 30 _interfaces = [] 31 32 def __new__(cls, name, bases, d): 33 new_class = type.__new__(cls, name, bases, d) 34 if name != 'Interface': 35 InterfaceMeta._interfaces.append(new_class) 36 return new_class 37 29 38 class Interface(object): 30 39 """Dummy base class for interfaces. … … 32 41 (Might use PyProtocols in the future.) 33 42 """ 43 __metaclass__ = InterfaceMeta 34 44 35 45 class ExtensionPoint(object): … … 266 276 name of the component to use. """ 267 277 raise NotImplementedError 278 279 def get_interfaces(self): 280 """ Return all known interfaces. """ 281 return InterfaceMeta._interfaces pycrash/trunk/crash/console.py
r285 r288 14 14 pass 15 15 16 if sys.stdout.isatty() and __colour_terminal: 17 def cwrite(io, text): 18 bold = underline = 0 19 out = [] 20 for token in __cprint_re.finditer(text): 21 if token.group(1): 22 c = token.group(1) 23 if c == 'B': 24 if bold: 25 out.append("[22m") 26 else: 27 out.append("[1m") 28 bold = not bold 29 elif c == 'U': 30 if underline: 31 out.append("[24m") 32 else: 33 out.append("[4m") 34 underline = not underline 35 elif c == 'N': 36 underline = bold = 0 37 out.append("[0m") 38 elif c >= '0' and c <= '7': 39 out.append("[3" + c + "m") 16 def colour_cwrite(io, text): 17 bold = underline = 0 18 out = [] 19 for token in __cprint_re.finditer(text): 20 if token.group(1): 21 c = token.group(1) 22 if c == 'B': 23 if bold: 24 out.append("[22m") 40 25 else: 41 out.append(token.group(0)) 26 out.append("[1m") 27 bold = not bold 28 elif c == 'U': 29 if underline: 30 out.append("[24m") 31 else: 32 out.append("[4m") 33 underline = not underline 34 elif c == 'N': 35 underline = bold = 0 36 out.append("[0m") 37 elif c >= '0' and c <= '7': 38 out.append("[3" + c + "m") 42 39 else: 43 40 out.append(token.group(0)) 44 for t in out: 45 io.write(t) 46 41 else: 42 out.append(token.group(0)) 43 for t in out: 44 io.write(t) 45 46 def mono_cwrite(io, text): 47 io.write(__cprint_strip.sub('', text)) 48 49 if sys.stdout.isatty() and __colour_terminal: 50 cwrite = colour_cwrite 47 51 else: 48 def cwrite(io, text): 49 io.write(__cprint_strip.sub('', text)) 50 51 cwrite.__doc__ = """ Print using colour escape codes similar to the Quake engine. That is, 52 ^0-7 correspond to colours, ^B toggles bold, ^U toggles underline and 53 ^N is reset to normal text. Colour is not automatically reset at the 54 end of output. """ 55 52 cwrite = mono_cwrite 53 54 cwrite.__doc__ = """ 55 Print using colour escape codes similar to the Quake engine. That is, 56 ^0-7 correspond to colours, ^B toggles bold, ^U toggles underline and 57 ^N is reset to normal text. Colour is not automatically reset at the 58 end of output. 59 """ 60 56 61 def cprint(*args): 57 62 stream = sys.stdout
