<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-

# This is a wrapper script to run tests using the unittest
# framework. It setups the environment properly and defines some
# commandline options for running tests.
#
# Copyright 2008 <NAME> <<EMAIL>>

import os
import json
import getopt
import random
import time

filename="listaDocs.yml"

verbose       = True
debug         = False
checkreserved = True
refusereserved= True

#nomes = { "reservados":reservados, "em uso":usados, "duplicados": duplicados}
nomes={}
usados = []
duplicados = []
reservados = []

def newName():
    pass
    
def nameIsGood(name):
    if (name in usados):
        return False
    if (refusereserved and name in reservados):
        return False
    return True

def main(argv=None):
    '''Apresenta um nome que no esteja sendo usado.'''
    seed=time.clock()
    random.seed(seed)
    anumber=random.randrange(1000,9999)
    
    with open("./"+filename, "r") as f:
        nomes = json.load(f)
        
    if (debug):
        print nomes.keys()
        
    reservados = nomes["reservados"]
    reservados.append('0000')

    usados = nomes["em uso"]
    duplicados = nomes["duplicados"]
    
    aStrNumber = str(anumber)
    if (verbose):
        print("Nmero aleatrio: " + aStrNumber)
        #for i in usados:
        #    print(i)
    #while (aStrNumber in usados):
    while (not nameIsGood(aStrNumber)):
        if (verbose):
            print (aStrNumber + " est em uso ou reservado")
    if (checkreserved):<commit_msg>faltava buscar novo número em caso de colisão.<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-

# This is a wrapper script to run tests using the unittest
# framework. It setups the environment properly and defines some
# commandline options for running tests.
#
# Copyright 2008 <NAME> <<EMAIL>>

import os
import json
import getopt
import random
import time

filename="listaDocs.yml"

verbose       = True
debug         = False
checkreserved = True
refusereserved= True

#nomes = { "reservados":reservados, "em uso":usados, "duplicados": duplicados}
nomes={}
usados = []
duplicados = []
reservados = []

def newName():
    pass
    
def nameIsGood(name):
    if (name in usados):
        return False
    if (refusereserved and name in reservados):
        return False
    return True

def main(argv=None):
    '''Apresenta um nome que no esteja sendo usado.'''
    seed=time.clock()
    random.seed(seed)
    anumber=random.randrange(1000,9999)
    
    with open("./"+filename, "r") as f:
        nomes = json.load(f)
        
    if (debug):
        print nomes.keys()
        
    reservados = nomes["reservados"]
    reservados.append('0000')

    usados = nomes["em uso"]
    duplicados = nomes["duplicados"]
    
    aStrNumber = str(anumber)
    if (verbose):
        print("Nmero aleatrio: " + aStrNumber)
        #for i in usados:
        #    print(i)
    #while (aStrNumber in usados):
    while (not nameIsGood(aStrNumber)):
        if (verbose):
            print (aStrNumber + " est em uso ou reservado")
        aStrNumber = str(random.randrange(1000,9999))
    if (checkreserved):
{'fraction_non_alphanumeric': 0.116405500479693, 'fraction_numerical': 0.013431403901503039, 'mean_word_length': 2.7915151515151515, 'pattern_counts': {'":': 6, '<': 9, '<?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': '4844344', 'n_tokens_mistral': 1045, 'n_tokens_neox': 1010, 'n_words': 296}