<commit_before>#!/usr/bin/env python
from __future__ import print_function
import sys


class Dbg(object):
  _dbg_shared_state = {}
  _dbg_shared_state["active"]        = False
  _dbg_shared_state["indent_level"]  = 0
  _dbg_shared_state["my_indent_str"] = ""
  _dbg_shared_state['levelA']        = []
  _dbg_shared_state['current_level'] = 1
  _dbg_shared_state['vpl']           = 0

  def __new__(cls, *a, **k):
    obj = super(Dbg, cls).__new__(cls, *a, **k)
    obj.__dict__ = cls._dbg_shared_state
    return obj

  def activateDebug(self, level=1):
    self.active        = True
    self.current_level = level
    self.levelA.append(level)

  def is_active(self):
    return self.active

  def indent_string(self):
    return  self.my_indent_str

  def __change_indent_level(self, i):
    self.indent_level  = max( self.indent_level + i, 0)
    self.my_indent_str = " "*(self.indent_level*2)


  def __startVPL(self, level):
    vpl      = level or self.vpl
    self.vpl = vpl
    self.levelA.append(vpl)
    return vpl

  def start(self,name,*a,**kw):
    if (not self.active): return

    self.__startVPL(kw.get('level'))
    if (self.vpl > self.current_level): return


    sA = []
    sA.append(self.my_indent_str)
    sA.append(str(name))
    sA.append("(")

    for v in a:
      sA.append(str(v))
      sA.append(", ")

    if (sA[len(sA)-1] == ", "):
      sA[len(sA)-1] = ""

    sA.append("){\n")
    sys.stderr.write("".join(sA))
    self.__change_indent_level(1)

  def fini(self,*a):
    if (not self.active): return
    
    if (self.vpl <= self.current_level):
      self.__change_indent_level(-1)
      sA = []<commit_msg>dbg.start supports kw output<commit_after>#!/usr/bin/env python
from __future__ import print_function
import sys


class Dbg(object):
  _dbg_shared_state = {}
  _dbg_shared_state["active"]        = False
  _dbg_shared_state["indent_level"]  = 0
  _dbg_shared_state["my_indent_str"] = ""
  _dbg_shared_state['levelA']        = []
  _dbg_shared_state['current_level'] = 1
  _dbg_shared_state['vpl']           = 0

  def __new__(cls, *a, **k):
    obj = super(Dbg, cls).__new__(cls, *a, **k)
    obj.__dict__ = cls._dbg_shared_state
    return obj

  def activateDebug(self, level=1):
    self.active        = True
    self.current_level = level
    self.levelA.append(level)

  def is_active(self):
    return self.active

  def indent_string(self):
    return  self.my_indent_str

  def __change_indent_level(self, i):
    self.indent_level  = max( self.indent_level + i, 0)
    self.my_indent_str = " "*(self.indent_level*2)


  def __startVPL(self, level):
    vpl      = level or self.vpl
    self.vpl = vpl
    self.levelA.append(vpl)
    return vpl

  def start(self,name,*a,**kw):
    if (not self.active): return

    self.__startVPL(kw.get('level'))
    if (self.vpl > self.current_level): return


    sA = []
    sA.append(self.my_indent_str)
    sA.append(str(name))
    sA.append("(")

    for v in a:
      sA.append(str(v))
      sA.append(", ")


    for k in sorted(kw):
      sA.append(str(k))
      sA.append(" = ")
      sA.append(str(kw[k]))
      sA.append(", ")

    if (sA[len(sA)-1] == ", "):
      sA[len(sA)-1] = ""

    sA.append("){\n")
    sys.stderr.write("".join(sA))
    self.__change_indent_level(1)

  def fini(self,*a):
    if (not self.active): return
    
    if (self.vpl <= self.current_level):
      self.__change_indent_level(-1)
      sA = []
{'fraction_non_alphanumeric': 0.15115261161365626, 'fraction_numerical': 0.005836008170411439, 'mean_word_length': 2.869074492099323, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3244953', 'n_tokens_mistral': 1334, 'n_tokens_neox': 1294, 'n_words': 231}