def class_get_trait_help(cls, trait, inst=None): """Get the help string for a single trait. If `inst` is given, it's current trait values will be used in place of the class default. """ assert inst is None or isinstance(inst, cls) lines = [] if hasattr(trait.__class__, '_displayname'): traittype = trait.__class__._displayname else: traittype = trait.__class__.__name__ header = "--%s.%s <%s>" % (cls.__name__, trait.name, traittype) lines.append(header) if inst is not None: lines.append(indent('Current: %r' % getattr(inst, trait.name), 4)) else: try: dvr = repr(trait.get_default_value()) except Exception: dvr = None # ignore defaults we can't construct if dvr is not None: if len(dvr) > 64: dvr = dvr[:61] + '...' lines.append(indent('Default: %s' % dvr, 4)) if 'Enum' in trait.__class__.__name__: # include Enum choices lines.append(indent('Choices: %r' % (trait.values, ))) help = trait.get_metadata('help') if help is not None: help = '\n'.join(wrap_paragraphs(help, 76)) lines.append(indent(help, 4)) return '\n'.join(lines)
def str(self, depth=0): dis = disasm.Disassembler(self) ind = indent(depth + 1) r = indent(depth, self.offset) + 'CODE:\n' + \ ind + 'argcount:\n%s\n' % self.argcount.str(depth + 2) + \ ind + 'nlocals:\n%s\n' % self.nlocals.str(depth + 2) + \ ind + 'stacksize:\n%s\n' % self.stacksize.str(depth + 2) + \ ind + 'flags:\n%s\n' % self.flags.str(depth + 2) + \ indent(depth + 2) + '(' + \ ', '.join([opcodes.flags[f] for f in opcodes.flags if f & self.flags.value]) + ')\n' + \ ind + 'code:\n%s\n' % self.code.str(depth + 2) + \ indentText(dis.codeDisasm(verbose=self.verboseDisasm, xref=self.xrefDisasm), depth + 2) + \ ind + 'consts:\n%s\n' % self.consts.str(depth + 2) + \ ind + 'names:\n%s\n' % self.names.str(depth + 2) + \ ind + 'varnames:\n%s\n' % self.varnames.str(depth + 2) + \ ind + 'freevars:\n%s\n' % self.freevars.str(depth + 2) + \ ind + 'cellvars:\n%s\n' % self.cellvars.str(depth + 2) + \ ind + 'filename:\n%s\n' % self.filename.str(depth + 2) + \ ind + 'name:\n%s\n' % self.name.str(depth + 2) + \ ind + 'firslineno:\n%s\n' % self.firstlineno.str(depth + 2) + \ ind + 'lnotab:\n%s\n' % self.lnotab.str(depth + 2) return r
def class_get_trait_help(cls, trait, inst=None): """Get the help string for a single trait. If `inst` is given, it's current trait values will be used in place of the class default. """ assert inst is None or isinstance(inst, cls) lines = [] if hasattr(trait.__class__, '_displayname'): traittype = trait.__class__._displayname else: traittype = trait.__class__.__name__ header = "--%s.%s <%s>" % (cls.__name__, trait.name, traittype) lines.append(header) if inst is not None: lines.append(indent('Current: %r' % getattr(inst, trait.name), 4)) else: try: dvr = repr(trait.get_default_value()) except Exception: dvr = None # ignore defaults we can't construct if dvr is not None: if len(dvr) > 64: dvr = dvr[:61]+'...' lines.append(indent('Default: %s' % dvr, 4)) if 'Enum' in trait.__class__.__name__: # include Enum choices lines.append(indent('Choices: %r' % (trait.values,))) help = trait.get_metadata('help') if help is not None: help = '\n'.join(wrap_paragraphs(help, 76)) lines.append(indent(help, 4)) return '\n'.join(lines)
def str(self, depth=0): if self.length == 0: return indent(depth, self.offset) + 'DICT: {}' return indent(depth, self.offset) + 'DICT: {\n' + \ ',\n'.join('%s : %s' % (i.str(depth+1), self.value[i].str()) for i in self.value) + '\n' + indent(depth) + '}'
def str(self, depth=0): if self.length == 0: return indent(depth, self.offset) + 'FROZENSET: frozenset([])' return indent(depth, self.offset) + 'FROZENSET: frozenset([\n' + \ self.showElements(depth) + '])'
def str(self, depth=0): if self.length == 0: return indent(depth, self.offset) + 'LIST: []' return indent(depth, self.offset) + 'LIST: [\n' + \ self.showElements(depth) + ']'
def str(self, depth=0): if self.length == 0: return indent(depth, self.offset) + 'TUPLE: ()' return indent(depth, self.offset) + 'TUPLE: (\n' + \ self.showElements(depth) + ')'
def showElements(self, depth=0): return ',\n'.join('%s' % e.str(depth+1).rstrip('\n') for e in self.value) + '\n' + indent(depth)
def str(self, depth=0): return indent(depth, self.offset) + self.type.upper() + \ ': %s (%s)' % (repr(shorten(self.value)), shorten(readRaw(self.raw)))
def str(self, depth=0): return indent(depth, self.offset) + \ shorten(str(self.value)) + \ ' (%s)' % shorten(readRaw(self.raw))