+def __exec_sat__(file, args):
+ """Executes SAT solver and returns configuration."""
+ picosat_cmd = [sf(conf.picosat), file]
+ picosat_cmd += conf.picosat_args
+ stdout = utils.callsubprocess('picosat', conf.picosat_cmd, conf.picosat_output, ".")
+
+ rtn = []
+ solut = []
+ for line in stdout:
+ if line[0] == 's':
+ try:
+ solut.remove(0)
+ rtn.append(solut)
+ except ValueError:
+ pass
+ solut = []
+ if not line.rstrip() == 's SATISFIABLE':
+ raise exceptions.NoSolution()
+ elif line[0] == 'v':
+ for sl in line[2:].split():
+ solut.append(int(sl))
+ return rtn
+
+def __write_temp_config_file__(conf):
+ # Ensure smap existence
+ utils.build_symbol_map()
+ # Load variable count
+ with open(sf(conf.variable_count_file)) as f:
+ f.readline()
+ var_num = int(f,readline())
+ # Write temporally file
+ wfile = tempfile.NamedTemporaryFile(delete=False)
+ for s in conf:
+ if s < 0:
+ nt = True
+ s *= -1
+ else:
+ nt = False
+ if s > var_num:
+ break;
+ if 'NONAMEGEN' in utils.smap[s]: # ignore generated names
+ continue
+ wfile.write('CONFIG_' + utils.smap[s] + '=')
+ if not nt:
+ wfile.write('y')
+ else:
+ wfile.write('n')
+ wfile.write('\n')
+ wfile.close()
+ return wfile.name
+
+def __load_config_file__(file):
+ rtn = dict()
+ with open(file, 'r') as f:
+ for ln in f:
+ if ln[0] == '#' or not '=' in ln:
+ continue
+ indx = ln.index('=')
+ if (ln[indx + 1] == 'y'):
+ rtn[line[7:indx]] = True
+ else:
+ rtn[line[7:indx]] = True
+ return rtn