示例#1
0
文件: main.py 项目: jakegold/NYU
def main():
    input_file = 'test.txt'  # CHANGE ME!!!

    # Call a driver to get rid of single line comments
    driver(input_file)
    file_name = make_file_name(input_file, 'driver')
    # Scanner
    scanner(file_name)
    file_name = make_file_name(file_name, 'scanner')
    # Parser
    parser(file_name)
示例#2
0
	def do_sendrecv(self):
		buf = ''
		sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

		ssl_sock = ssl.wrap_socket(sock)
 		self.ssl_sock = ssl_sock

		ssl_sock.connect((self.host, self.port))
		print 'conneted'
		ssl_sock.send("USER abcd abcd abcd :abcd\r\n")
		ssl_sock.send("NICK " +  self.nick +"\r\n")
		#ssl_sock.send("JOIN #teamnop\r\n")
		while True:
			result = ssl_sock.recv(4086)
			if result.__len__() == 0 :
				break
			buf += result.replace('\r','')

			while True:
				nextpos = buf.find('\n')
				if nextpos == -1:
					break

				parseinfo = parser.parser(buf[:nextpos])

				try:
					func = getattr( ircservice, 'on_' + parseinfo.get_command().lower())
					func(self,*parseinfo.get_all())
				except AttributeError:
					pass
				print parseinfo.get_command(), parseinfo.get_all()
				buf = buf[nextpos+1:]
		ssl_sock.close()
		print 'closed'
 def stringLoad (self, string):
     middle = self.findMiddleOfBoard ()
     filename = 'Patterns/' + string + '.cells'
     if os.path.exists (filename):
         self.board = parser.parser (filename, middle)
         self.msg ='%s Loaded' % filename
     else:
         self.msg = "File Doesn't Exist"
示例#4
0
文件: main.py 项目: jakegold/NYU
def main():
    input_file = 'test_decl_x.c'  # CHANGE ME!!!

    # Call a driver to get rid of single line comments
    driver(input_file)
    file_name = make_file_name(input_file, 'driver')
    # Scanner
    scanner(file_name)
    file_name = make_file_name(file_name, 'scanner')
    # Parser
    return_values = parser(file_name)
    # Semantic Checker
    semantic_check(file_name, return_values)
示例#5
0
文件: main.py 项目: jakegold/NYU
def main():
    input_file = 'test.txt'  # CHANGE ME!!!

    # Call a driver to get rid of single line comments
    driver(input_file)
    file_name = make_file_name(input_file, 'driver')
    # Scanner
    scanner(file_name)
    file_name = make_file_name(file_name, 'scanner')
    # Parser
    return_values = parser(file_name)
    # Semantic Checker
    semantic_check(file_name, return_values)
    # Code Generator
    MASS = generate_code(return_values, input_file)
    with open('output.txt', 'w') as f:
        f.write(MASS + '\n')
示例#6
0
	def send_recv_loop(self):
		while True:
			recvdata = self.sslconn.recv(4086)
			if type(recvdata) == type(int) and recvdata <= 0:
				# 소켓 error or disconnect
				self.init()
				break
			self.recvdata += recvdata
			self.recvdata = self.recvdata.replace('\r','')
			while True:			
				nextpos = self.recvdata.find('\n')
				if nextpos == -1:
					break
				parseinfo = parser.parser(self.recvdata[:nextpos])
				try:
					func = getattr(IRC, 'on_' + parseinfo.get_command().lower())
					func(self,*parseinfo.get_all())
				except:
					pass
				print parseinfo.get_all()
				self.recvdata = self.recvdata[nextpos+1:]
import urllib


from config import config
from parser.parser import parser
from parser.makeDict import makeDict

getDetails = lambda year,grade : urllib.urlopen(config.url, urllib.urlencode({'rno':year,'grade':grade,'submit':'submit'})).read()






raw_list=[ getDetails(year,grade) for year in config.years for grade in config.grades ]

for no,i in enumerate(raw_list):
	dictionary=makeDict(parser(i))
	print dictionary
#print raw_list




示例#8
0
		'./data/training_data/SemEval2015-Task3-CQA-QL-train-reformatted-excluding-2016-questions-cleansed.xml',
		'./data/training_data/SemEval2016-Task3-CQA-QL-train-part1.xml',
		'./data/training_data/SemEval2016-Task3-CQA-QL-train-part2.xml'
		]
datalist['dev'] = [
		'./data/training_data/SemEval2016-Task3-CQA-QL-dev.xml'
		]
datalist['test'] = [
		'./data/training_data/SemEval2016-Task3-CQA-QL-test.xml'
		]



		
for dtype in ['train','dev','test']:
	dataloader = parser(datalist[dtype],task)
	
	f = open("./BIMPM-pytorch/data/semeval/{0}_{1}.in".format(task,dtype),'w')
	idx = 0

	for data in dataloader.iterator():
		title = remove(data['Subject']) + ' ' + remove(data['Body'])

		if("Comment" in data):
			for comment in data["Comment"]:
				text = remove(remove(comment["Text"]))
				if('RELEVANCE2RELQ' in comment):
					rel = comment["RELEVANCE2RELQ"]
				elif('RELEVANCE2ORGQ' in comment):
					rel = comment["RELEVANCE2ORGQ"]
				if(rel=='Good'):
示例#9
0
    def check_port(self):
	if os.path.exists("/dev/ttyACM0"):
	    return '/dev/ttyACM0'
	if os.path.exists("/dev/ttyACM1"):
	    return '/dev/ttyACM1'
	if os.path.exists("/dev/ttyACM2"):
	    return '/dev/ttyACM2'
	else:
	    return False   

log=hwlog()
#try:
log.serial_connect()
s=sql()
p=parser()

try:
    while True:
        if log.check_port() == False:
            logging.error( u'Устройство не подключено' )
            sleep(60)
        else:   
            s.insert(p.data_parser(log.serial_getdata()))
            sleep(60)
except Exception,e:
    print str(e)



示例#10
0
import urllib

from config import config
from parser.parser import parser
from parser.makeDict import makeDict

getDetails = lambda year, grade: urllib.urlopen(
    config.url,
    urllib.urlencode({
        'rno': year,
        'grade': grade,
        'submit': 'submit'
    })).read()

raw_list = [
    getDetails(year, grade) for year in config.years for grade in config.grades
]

for no, i in enumerate(raw_list):
    dictionary = makeDict(parser(i))
    print dictionary
#print raw_list