Ejemplo n.º 1
0
Archivo: gql.py Proyecto: ryanlayer/gql
def main():
	curr_path = determine_path()
	json_data=open(curr_path + '/config/gql.conf')
	gqltools.config = json.load(json_data)

	gqllexer    = lex.lex(module=gqltokens)
	#gqlparser   = yacc.yacc(module=gqlgrammar,write_tables=0,debug=0)
	global_env = (None, {})

	history_file = expanduser("~/.gql_history")
	readline.set_completer(SimpleCompleter(gqltokens.reserved).complete)

	readline.parse_and_bind("tab: complete")

	if len(sys.argv) == 1:
		try:
			readline.read_history_file(history_file)
		except IOError:
			pass

		while True:
			try:
				data = raw_input('> ')
				if data != '':
					readline.write_history_file(history_file)
					#gqlast = None;
					try:
						gqlast = gqlparser.parse(data,\
												 lexer=gqllexer,\
												 tracking=True)
						if (gqlast != None):
							result = gqlinterp.interpret_cmdline(gqlast,\
																 global_env)
					except Exception as e:
						print str(e)
			except KeyboardInterrupt:
				print ''
				break
			except EOFError:
				print
				break
		gqltools.clear_tmp_files()
	else:
		f = open(sys.argv[1], 'r')
		data = f.read()
		f.close()
		gqlast = gqlparser.parse(data,lexer=gqllexer,tracking=True)
		result = gqlinterp.interpret(gqlast)
		gqltools.clear_tmp_files()
Ejemplo n.º 2
0
    def test_tempfile_management(self):
        R_file_name = gqltools.get_temp_file_name(pybedtools.get_tempdir(), "unittest", "tmp")
        r = random.randint(1, sys.maxint)
        f = open(R_file_name, "w")
        f.write(str(r))
        f.close()

        # test to see if the file was created
        self.assertTrue(os.path.isfile(R_file_name))

        R = gqltypes.BED6(R_file_name, True)

        gqltools.add_tmp_file(R)

        gqltools.clear_tmp_files()

        self.assertEqual(os.path.isfile(R_file_name), False)
Ejemplo n.º 3
0
 def tearDown(self):
     gqltools.clear_tmp_files()