コード例 #1
0
ファイル: down-qterm.py プロジェクト: yindian/myutils
def return_to_list(lp):
	lineno = qterm.caretY(lp)
	if lineno == lastlineno:	# already in article mode
		send_char(lp, 'q')
		if qterm.caretY(lp) == lastlineno:	# still in article mode, press q again
			send_char(lp, 'q')
		if qterm.caretY(lp) == lastlineno:	# still in article mode, not expected
			return False
	elif lineno < 3:	# in reply or post mode
		return False
	return True
コード例 #2
0
ファイル: down-qterm.py プロジェクト: yindian/myutils
def wait_until_stable(lp):
	xpos = qterm.caretX(lp)
	ypos = qterm.caretY(lp)
	small_sleep()
	x = qterm.caretX(lp)
	y = qterm.caretY(lp)
	while x != xpos or y != ypos:
		xpos = x
		ypos = y
		small_sleep()
		x = qterm.caretX(lp)
		y = qterm.caretY(lp)
コード例 #3
0
ファイル: down-qterm.py プロジェクト: yindian/myutils
def wait_until_change(lp):
	xpos = qterm.caretX(lp)
	ypos = qterm.caretY(lp)
	line = qterm.getText(lp, ypos)
	small_sleep()
	x = qterm.caretX(lp)
	y = qterm.caretY(lp)
	str = qterm.getText(lp, y)
	t = maxtry
	while x == xpos and y == ypos and str == line and t > 0:
		small_sleep()
		x = qterm.caretX(lp)
		y = qterm.caretY(lp)
		str = qterm.getText(lp, y)
		t -= 1
コード例 #4
0
ファイル: down-qterm.py プロジェクト: yindian/myutils
def get_title_list_ready(lp):
	global lastlineno
	if not return_to_list(lp):
		return
	lineno = qterm.caretY(lp)
	line = qterm.getText(lp, lineno)
	# try digest list
	exp = r'^(?:->|\s*>)\s*(\d+)\s*\[(.+?)\]\s*(.*?)\s*$'
	matchobj = re.match(exp, line)
	if matchobj:
		return 1, matchobj.group(1), matchobj.group(2), matchobj.group(3)
	else:	# try normal article list
		exp = r'^(?:>)\s*(\S+)\s*(?:[+*NmMgGbBrRoO.])?\s+(\S+)\s*(\w+)\s*(\d+)(?:\.)?\s*(?:x|@)?(¡ñ|¡ô|¡ï|Re:|©À) (.*?)\s*$'
		print 'maybe article'
		matchobj = re.match(exp, line)
		if matchobj:
			if matchobj.group(5) == 'Re:' or matchobj.group(5) == '©À':
				reply = 'Re: '
			else:
				reply = ''
			return 0, matchobj.group(1), matchobj.group(2), reply + matchobj.group(6)
		else:
			print 'line %s not matched' % line