Esempio n. 1
0
def printThread(thread, prefs):
	textWidth = prefs['termWidth']
	replyIndent = prefs['replyIndent']
	imgEnable = prefs['asciiImagesEnable']
	
	for post in thread:
		postNum = post['no']
		postTimeDate = post['now']

		if imgEnable and 'tim' in post:
			imgUrl = "http://i.4cdn.org/" + thread.getBoard() + "/src/" + str(post['tim']) + post['ext']
			print aaFuncs.urlToAscii(imgUrl, prefs)

		print TermColor.cyan + "No. " + str(postNum) + ' ' + TermColor.purple + postTimeDate + TermColor.reset

		if 'com' in post:
			postTextRaw = post['com']
			postTextClean = cleanCommentData(postTextRaw)
		else:
			postTextClean = "< no text >"

		print wrap(postTextClean, textWidth) + '\n' + TermColor.reset
Esempio n. 2
0
def printThread(thread, prefs):
	textWidth = prefs['termWidth']
	replyIndent = prefs['replyIndent']
	imgEnable = prefs['asciiImagesEnable']
	
	for post in thread:
		postNum = post['no']
		postTimeDate = post['now']

		if imgEnable and 'tim' in post:
			imgUrl = "http://images.4chan.org/" + thread.getBoard() + "/src/" + str(reply['tim']) + reply['ext']
			print aaFuncs.urlToAscii(imgUrl, prefs)

		print TermColor.cyan + "No. " + str(postNum) + ' ' + TermColor.purple + postTimeDate + TermColor.reset

		if 'com' in post:
			postTextRaw = post['com']
			postTextClean = cleanCommentData(postTextRaw)
		else:
			postTextClean = "< no text >"

		print wrap(postTextClean, textWidth) + '\n' + TermColor.reset
Esempio n. 3
0
def printIndex(index, prefs):
	textWidth = prefs['termWidth']
	replyIndent = prefs['replyIndent']
	imgEnable = prefs['asciiImagesEnable']
	ignoreReplies = prefs['ignoreReplies']
	threadCount = 0

	for thread in index:
		threadCount += 1
		op = thread.getOp()
		opNum = op['no']
		opTimeDate = op['now']
		
		if 'sub' in op:
			opSubject = ' ' + op['sub']
		else:
			opSubject = ""

		textPostsOmitted = ""
		if 'omitted_posts' in op:
			textPostsOmitted += TermColor.blue + str(op['omitted_posts'])
			if op['omitted_posts'] == 1:
				textPostsOmitted += " post "
			else:
				textPostsOmitted += " posts "
			if imgEnable and 'omitted_images' in op:
				if op['omitted_images'] > 0:
					textPostsOmitted += "and " + str(op['omitted_images'])
					if op['omitted_images'] == 1:
						textPostsOmitted += " image reply "
					else:
						textPostsOmitted += " image replies "
			textPostsOmitted += "omitted." + TermColor.reset + "\n"
		
		if 'com' in op:
			opTextRaw = op['com']
			opTextClean = cleanCommentData(opTextRaw)
		else:
			opTextClean = "< no text >"
		
		if imgEnable and 'tim' in op:
			imgUrl = "http://i.4cdn.org/" + thread.getBoard() + "/src/" + str(op['tim']) + op['ext']
			print aaFuncs.urlToAscii(imgUrl, prefs)
		
		print wrap( \
			TermColor.cyan + TermColor.bold + str(threadCount) + ":" + TermColor.yellow + opSubject + TermColor.reset + TermColor.cyan + " No. " + str(opNum) + ' ' + TermColor.purple + opTimeDate + TermColor.reset + '\n' \
			+ opTextClean + '\n' + textPostsOmitted \
			, textWidth)

		if not ignoreReplies:
			for reply in thread.getReplies():
				indent = prefs['replyIndent']
				replyNum = reply['no']
				replyTimeDate = reply['now']

				if imgEnable and 'tim' in reply:
					imgUrl = "http://i.4cdn.org/" + thread.getBoard() + "/src/" + str(reply['tim']) + reply['ext']
					print indentText(aaFuncs.urlToAscii(imgUrl, prefs, indent = True), indent)

				print getSpaces(indent) + TermColor.cyan + "No. " + str(replyNum) + ' ' + TermColor.purple + replyTimeDate + TermColor.reset
			
				if 'com' in reply:
					replyTextRaw = reply['com']
					replyTextClean = cleanCommentData(replyTextRaw)
				else:
					replyTextClean = "< no text >"
			
				print indentText(wrap(replyTextClean, textWidth - indent), indent) + '\n' + TermColor.reset
Esempio n. 4
0
def printIndex(index, prefs):
    textWidth = prefs['termWidth']
    replyIndent = prefs['replyIndent']
    imgEnable = prefs['asciiImagesEnable']
    ignoreReplies = prefs['ignoreReplies']
    threadCount = 0

    for thread in index:
        threadCount += 1
        op = thread.getOp()
        opNum = op['no']
        opTimeDate = op['now']

        if 'sub' in op:
            opSubject = ' ' + op['sub']
        else:
            opSubject = ""

        textPostsOmitted = ""
        if 'omitted_posts' in op:
            textPostsOmitted += TermColor.blue + str(op['omitted_posts'])
            if op['omitted_posts'] == 1:
                textPostsOmitted += " post "
            else:
                textPostsOmitted += " posts "
            if imgEnable and 'omitted_images' in op:
                if op['omitted_images'] > 0:
                    textPostsOmitted += "and " + str(op['omitted_images'])
                    if op['omitted_images'] == 1:
                        textPostsOmitted += " image reply "
                    else:
                        textPostsOmitted += " image replies "
            textPostsOmitted += "omitted." + TermColor.reset + "\n"

        if 'com' in op:
            opTextRaw = op['com']
            opTextClean = cleanCommentData(opTextRaw)
        else:
            opTextClean = "< no text >"

        if imgEnable and 'tim' in op:
            imgUrl = "http://i.4cdn.org/" + thread.getBoard() + "/src/" + str(
                op['tim']) + op['ext']
            print aaFuncs.urlToAscii(imgUrl, prefs)

        print wrap( \
         TermColor.cyan + TermColor.bold + str(threadCount) + ":" + TermColor.yellow + opSubject + TermColor.reset + TermColor.cyan + " No. " + str(opNum) + ' ' + TermColor.purple + opTimeDate + TermColor.reset + '\n' \
         + opTextClean + '\n' + textPostsOmitted \
         , textWidth)

        if not ignoreReplies:
            for reply in thread.getReplies():
                indent = prefs['replyIndent']
                replyNum = reply['no']
                replyTimeDate = reply['now']

                if imgEnable and 'tim' in reply:
                    imgUrl = "http://i.4cdn.org/" + thread.getBoard(
                    ) + "/src/" + str(reply['tim']) + reply['ext']
                    print indentText(
                        aaFuncs.urlToAscii(imgUrl, prefs, indent=True), indent)

                print getSpaces(indent) + TermColor.cyan + "No. " + str(
                    replyNum
                ) + ' ' + TermColor.purple + replyTimeDate + TermColor.reset

                if 'com' in reply:
                    replyTextRaw = reply['com']
                    replyTextClean = cleanCommentData(replyTextRaw)
                else:
                    replyTextClean = "< no text >"

                print indentText(wrap(replyTextClean, textWidth - indent),
                                 indent) + '\n' + TermColor.reset