<commit_before>import pprint
import inspect

def print_members(module):
  print "ALL MEMBERS"
  print "==========="
  print "{0:20}  {1}".format("Type", "Object")
  print "{0:20}  {1}".format("----", "------")
  for m_type, m_object in inspect.getmembers(module):
    print "{0:20}  {1}".format(m_type, m_object)
  print
  print "CLASSES"
  print "======="
  print "{0:20}  {1}".format("Type", "Object")
  print "{0:20}  {1}".format("----", "------")
  for m_type, m_object in inspect.getmembers(module, inspect.isclass):
    print "{0:20}  {1}".format(m_type, m_object)

def port_walk(tgt, spaces=0):
  for x in tgt.ports:
    print spaces*' ', x.parent.name, x
    for y in x.connections:
      fullname = y.name
      if y.parent:
        fullname = y.parent.name+'.'+fullname
      print spaces*' ', '   knctn: {0} {1}'.format(type(y), fullname)
    print spaces*' ', '   value:', x._value, x.value
  print
  for x in tgt.submodules:
    print spaces*' ', x.name
    port_walk(x, spaces+3)

def inspect_dec(fn):
  #pprint.pprint(vars(fn))
  #pprint.pprint(locals())
  #pprint.pprint(globals())
  #pprint.pprint(dir(fn))
  #pprint.pprint(dir(fn.func_code))
  #pprint.pprint(inspect.getmembers(fn, inspect.isdatadescriptor))
  print fn.func_code.co_varnames
  print fn.func_code.co_names
  print fn.func_code.co_freevars
  #print fn.im_class  # Only works if you call on instance! Boo.<commit_msg>[rtler] minor change to port_walk() for slice debugging<commit_after>import pprint
import inspect
import rtler_vbase

def print_members(module):
  print "ALL MEMBERS"
  print "==========="
  print "{0:20}  {1}".format("Type", "Object")
  print "{0:20}  {1}".format("----", "------")
  for m_type, m_object in inspect.getmembers(module):
    print "{0:20}  {1}".format(m_type, m_object)
  print
  print "CLASSES"
  print "======="
  print "{0:20}  {1}".format("Type", "Object")
  print "{0:20}  {1}".format("----", "------")
  for m_type, m_object in inspect.getmembers(module, inspect.isclass):
    print "{0:20}  {1}".format(m_type, m_object)

def port_walk(tgt, spaces=0):
  for x in tgt.ports:
    print spaces*' ', x.parent.name, x
    for y in x.connections:
      fullname = y.name
      if y.parent:
        fullname = y.parent.name+'.'+fullname
      print spaces*' ', '   knctn: {0} {1}'.format(type(y), fullname)
    print spaces*' ', '   value:', x._value, x.value
    if isinstance(x._value, rtler_vbase.VerilogSlice):
      print (spaces+1)*' ', '   slice:', x._value._value, bin(x._value.pmask)
  print
  for x in tgt.submodules:
    print spaces*' ', x.name
    port_walk(x, spaces+3)

def inspect_dec(fn):
  #pprint.pprint(vars(fn))
  #pprint.pprint(locals())
  #pprint.pprint(globals())
  #pprint.pprint(dir(fn))
  #pprint.pprint(dir(fn.func_code))
  #pprint.pprint(inspect.getmembers(fn, inspect.isdatadescriptor))
  print fn.func_code.co_varnames
  print fn.func_code.co_names
  print fn.func_code.co_freevars
  #print fn.im_class  # Only works if you call on instance! Boo.
{'fraction_non_alphanumeric': 0.18783422459893048, 'fraction_numerical': 0.019050802139037433, 'mean_word_length': 3.661993769470405, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6676749', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1178, 'n_words': 244}