<commit_before># import lino
# lino.startup('lino_book.projects.team.settings.demo')
# import django
# print django.__file__
# from lino.api.doctest import *
# show_sql_queries()
# #doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
# r = demo_get('robin','api/tickets/AllTickets', fmt='json', limit=1)
# print(r)
# show_sql_queries()



import re
import sys
# from pprint import pprint
import textwrap

def p(kw, sql_width = 60):
    """Prints a parsed sql log nicely"""
    kw['sql'] = ("\n    ").join(textwrap.wrap(kw['sql'], sql_width))
    print(
          "table: {table}\n"
          "Longest_time: {time}\n"
          "Queries: {count}\n"
          "total_time: {total_time}\n"
          "sql: {sql}".format(**kw))


if __name__ == "__main__":
    matches = []
    regex = r"^.+\((?P<time>[\d\.]*)\) (?P<sql>.*FROM \`(?P<table>.*?)\`.*)$"
    # f = open("log/lino.log", 'r')
    f = sys.stdin
    d= {}
    l = f.readline()
    while l:
        m = re.match(regex, l)
        # print m
        if m:
            g = m.groupdict()
            g['time'] = float(g['time'])
            r = d.setdefault(g['table'], {})
            r['count'] = r.get('count', 0) + 1
            r["total_time"] = r.get("total_time", 0 ) + float(g['time'])
            if r.get('time', -1) < g['time']:
                d[g['table']].update(g)
        l = f.readline()<commit_msg>update regex for sql log parse<commit_after># import lino
# lino.startup('lino_book.projects.team.settings.demo')
# import django
# print django.__file__
# from lino.api.doctest import *
# show_sql_queries()
# #doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
# r = demo_get('robin','api/tickets/AllTickets', fmt='json', limit=1)
# print(r)
# show_sql_queries()



import re
import sys
# from pprint import pprint
import textwrap

def p(kw, sql_width = 60):
    """Prints a parsed sql log nicely"""
    kw['sql'] = ("\n    ").join(textwrap.wrap(kw['sql'], sql_width))
    print(
          "table: {table}\n"
          "Longest_time: {time}\n"
          "Queries: {count}\n"
          "total_time: {total_time}\n"
          "sql: {sql}".format(**kw))


if __name__ == "__main__":
    matches = []
    regex = r"^.+?\((?P<time>[\d\.]*)\) (?P<sql>.*FROM \`(?P<table>.*?)\`.*?;).*$"
    # f = open("log/lino.log", 'r')
    f = sys.stdin
    d= {}
    l = f.readline()
    while l:
        m = re.match(regex, l)
        # print m
        if m:
            g = m.groupdict()
            g['time'] = float(g['time'])
            r = d.setdefault(g['table'], {})
            r['count'] = r.get('count', 0) + 1
            r["total_time"] = r.get("total_time", 0 ) + float(g['time'])
            if r.get('time', -1) < g['time']:
                d[g['table']].update(g)
        l = f.readline()
{'fraction_non_alphanumeric': 0.2081199707388442, 'fraction_numerical': 0.005120702267739576, 'mean_word_length': 2.4059775840597757, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 9, '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': '184993', 'n_tokens_mistral': 1055, 'n_tokens_neox': 1033, 'n_words': 208}