try: # print '-----------------', onefile, '-----------------' # ast = parse_file(onefile, use_cpp=True) if onefile.endswith(".txt"): instream = open(onefile, 'r') text = instream.read() text = text.replace('\r\n', '\n') instream.close() # layers = InitNetbyText(text=text) layers = InitNetbyText(text=onefile) # layers = InitNetbyText('', filename=onefile) count += 1 # print 'count = ',count if count > 500: break directory = gl.targetdir + subdir if not os.path.exists(directory): os.makedirs(directory) serialize.serialize(layers, directory + '/seri_' + filename) except Exception as e: print '!!! error', e print 'ooooops, parsing error for', onefile continue print 'Done!!!!!!' print 'procount = ', procount
j = json.load(f) # print(j) for i, v in j.items(): directory = output_file + i + "\\" print(directory) if not os.path.exists(directory): os.makedirs(directory) for bugInfo in v: inPATH = input_file + bugInfo["bugID"] + '\\' # print(inDir) key_file = bugInfo["FileName"][0] print(inPATH, "!!!!!!!!!!!!!!!!!!!!!!!!!") try: layers = InitNetbyText(inPATH, key_file) print(directory + bugInfo["bugID"]) serialize.serialize(layers, directory + bugInfo["bugID"]) except: print 'ooooops, parsing error for', bugInfo["bugID"] continue # for subdir in os.listdir(gl.datadir): # if not subdir.endswith('/'): # subdir = subdir + '/' # # count = 0 # procount += 1 # print '!!!!!!!!!!!!!!!!!! procount = ', procount # # if procount >3: # # break # for onefile in os.listdir(gl.datadir + subdir): #