<commit_before>#!/usr/bin/env python2

import hashlib
import getopt
import re
import sys

def lump(pre, post):
    return [pre + i for i in post]

class states:
    START   =  0
    SIGINP  =  1
    SIGOUTP =  2
    TRANPRE =  3
    TRANOUT =  4
    TRANEFF =  5
    NAME    =  6
    STATE   =  7
    TASKS   =  8
    TRANNAM =  9
    SIGINT  =  10

def newauto():
    r = {'sigin': [], 'sigint': [], 'sigout': [], 'trans': [],
         'state': [], 'tasks':[], 'connectout': {}}

    return r

class Tran:

    def __init__(self):
        self.pres = []
        self.effs = []
        self.out = []
        self.name = 'unknown'

    def __repr__(self):
        ret = '<Tran "%s" ' % (self.name)
        ret += 'Precondition: '
        ret += ';'.join(self.pres)
        ret += ' Output: '
        ret += ';'.join(self.out)
        ret += ' Effects: '
        ret += ';'.join(self.effs)
        ret += '>'

        return ret

    def addpre(self, l):
        self.pres.append(l)
    def addeff(self, l):
        self.effs.append(l)
    def addout(self, l):
        self.out.append(l)

    def prpre(self, idts):
        self.prprologue(idts)
        if not self.pres:
            print '\t'*idts + 'return False'

        for i in self.pres:
            print '\t'*idts + i

    def preff(self, idts):
        self.prprologue(idts)
        if not self.effs:
            print '\t'*idts + 'pass'

        for i in self.effs:
            print '\t'*idts + i

    def prout(self, idts):
        self.prprologue(idts)
        # outputs can be omitted
        if not self.out:
            #print '\t'*idts + 'raise Exception("no imp")'
            print '\t'*idts + 'return None'

        for i in self.out:
            print '\t'*idts + i

    def prprologue(self, idts):
        print '\t'*idts + 'i, N = self.i, self.N'
        print '\t'*idts + 'mark = self.mark'

    def setname(self, l):
        self.name = l

class Parser:

    def __init__(self):
        self.state = states.START
        self.allautos = []
        self.auto = None

    def addtoret(self, ntd, n, idts):
        print '\t'*idts + 'd = {',
        for k in ntd:
            print self.mklit(k) + ': %s,' % (ntd[k]),

        print '}'
        print '\t'*idts + 'ret[%s] = d' % (self.mklit(n))

    def dump(self):
        self.dumpglobal()
        allclasses = []
        for i in self.allautos:<commit_msg>Remove local var i (should be through self.)<commit_after>#!/usr/bin/env python2

import hashlib
import getopt
import re
import sys

def lump(pre, post):
    return [pre + i for i in post]

class states:
    START   =  0
    SIGINP  =  1
    SIGOUTP =  2
    TRANPRE =  3
    TRANOUT =  4
    TRANEFF =  5
    NAME    =  6
    STATE   =  7
    TASKS   =  8
    TRANNAM =  9
    SIGINT  =  10

def newauto():
    r = {'sigin': [], 'sigint': [], 'sigout': [], 'trans': [],
         'state': [], 'tasks':[], 'connectout': {}}

    return r

class Tran:

    def __init__(self):
        self.pres = []
        self.effs = []
        self.out = []
        self.name = 'unknown'

    def __repr__(self):
        ret = '<Tran "%s" ' % (self.name)
        ret += 'Precondition: '
        ret += ';'.join(self.pres)
        ret += ' Output: '
        ret += ';'.join(self.out)
        ret += ' Effects: '
        ret += ';'.join(self.effs)
        ret += '>'

        return ret

    def addpre(self, l):
        self.pres.append(l)
    def addeff(self, l):
        self.effs.append(l)
    def addout(self, l):
        self.out.append(l)

    def prpre(self, idts):
        self.prprologue(idts)
        if not self.pres:
            print '\t'*idts + 'return False'

        for i in self.pres:
            print '\t'*idts + i

    def preff(self, idts):
        self.prprologue(idts)
        if not self.effs:
            print '\t'*idts + 'pass'

        for i in self.effs:
            print '\t'*idts + i

    def prout(self, idts):
        self.prprologue(idts)
        # outputs can be omitted
        if not self.out:
            #print '\t'*idts + 'raise Exception("no imp")'
            print '\t'*idts + 'return None'

        for i in self.out:
            print '\t'*idts + i

    def prprologue(self, idts):
        print '\t'*idts + 'N = self.N'
        print '\t'*idts + 'mark = self.mark'

    def setname(self, l):
        self.name = l

class Parser:

    def __init__(self):
        self.state = states.START
        self.allautos = []
        self.auto = None

    def addtoret(self, ntd, n, idts):
        print '\t'*idts + 'd = {',
        for k in ntd:
            print self.mklit(k) + ': %s,' % (ntd[k]),

        print '}'
        print '\t'*idts + 'ret[%s] = d' % (self.mklit(n))

    def dump(self):
        self.dumpglobal()
        allclasses = []
        for i in self.allautos:
{'fraction_non_alphanumeric': 0.15391049769970724, 'fraction_numerical': 0.005437055625261397, 'mean_word_length': 1.6222587719298245, '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': '7619237', 'n_tokens_mistral': 1758, 'n_tokens_neox': 1723, 'n_words': 438}