Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.url = question_url
self.answer_text = AnswerText(answers)
self.screenHeight, screenWidth = subprocess.check_output(['stty', 'size']).split()
self.question_text = urwid.BoxAdapter(QuestionDescription(question_desc), int(max(1, (int(self.screenHeight) - 9) / 2)))
answer_frame = urwid.Frame(
header= urwid.Pile( [
header_for_display,
QuestionTitle(question_title),
self.question_text,
QuestionStats(question_stats),
urwid.Divider('-')
]),
body=self.answer_text,
footer= urwid.Pile([
QuestionURL(question_url),
UnicodeText(u'p: previous answer, n: next answer, o: open in browser, b: back')
])
)
return answer_frame
"""
self.content = self.description.strip("\n").split("\n")
self._w = ScrollableTextBox(self.content)
def __len__(self):
""" return number of rows in this widget """
return len(self.content)
class QuestionStats(UnicodeText):
""" Stats of the question,"""
def __init__(self, stats):
text = ["\n", ('metadata', stats)]
UnicodeText.__init__(self, text)
class QuestionURL(UnicodeText):
""" url of the question """
def __init__(self, url):
text = ["\n", ('heading', 'Question URL: '), url]
UnicodeText.__init__(self, text)
def format_str(str, color):
return "{0}{1}{2}".format(color, str, colorama.Style.RESET_ALL)
def print_header(str):
print(format_str(str, colorama.Fore.MAGENTA))
def print_blue(str):
print(format_str(str, colorama.Fore.BLUE))
self.set_description()
def set_description(self):
"""
We must use a box adapter to get the text to scroll when this widget is already in
a Pile from the main question page. Scrolling is necessary for long questions which are longer
than the length of the terminal.
"""
self.content = self.description.strip("\n").split("\n")
self._w = ScrollableTextBox(self.content)
def __len__(self):
""" return number of rows in this widget """
return len(self.content)
class QuestionStats(UnicodeText):
""" Stats of the question,"""
def __init__(self, stats):
text = ["\n", ('metadata', stats)]
UnicodeText.__init__(self, text)
class QuestionURL(UnicodeText):
""" url of the question """
def __init__(self, url):
text = ["\n", ('heading', 'Question URL: '), url]
UnicodeText.__init__(self, text)
def format_str(str, color):
return "{0}{1}{2}".format(color, str, colorama.Style.RESET_ALL)
def set_description(self):
"""
We must use a box adapter to get the text to scroll when this widget is already in
a Pile from the main question page. Scrolling is necessary for long questions which are longer
than the length of the terminal.
"""
self.content = self.description.strip("\n").split("\n")
self._w = ScrollableTextBox(self.content)
def __len__(self):
""" return number of rows in this widget """
return len(self.content)
class QuestionStats(UnicodeText):
""" Stats of the question,"""
def __init__(self, stats):
text = ["\n", ('metadata', stats)]
UnicodeText.__init__(self, text)
class QuestionURL(UnicodeText):
""" url of the question """
def __init__(self, url):
text = ["\n", ('heading', 'Question URL: '), url]
UnicodeText.__init__(self, text)
self.screenHeight, screenWidth = subprocess.check_output(
['stty', 'size']).split()
self.question_text = urwid.BoxAdapter(QuestionDescription(question_desc),
int(max(1, (int(self.screenHeight) - 9) / 2)))
answer_frame = urwid.Frame(
header=urwid.Pile([
display_header,
QuestionTitle(question_title),
self.question_text,
QuestionStats(question_stats),
urwid.Divider('-')
]),
body=self.answer_text,
footer=urwid.Pile([
QuestionURL(question_url),
UnicodeText(
u'\u2191: previous answer, \u2193: next answer, o: open in browser, \u2190: back, q: quit')
])
)
return answer_frame
def set_answer(self):
"""
We must use a box adapter to get the text to scroll when this widget is already in
a Pile from the main question page. Scrolling is necessary for long answers which are longer
than the length of the terminal.
"""
self.content = [('less-important', 'Answer: ')] + self.answers[self.index].split("\n")
self._w = ScrollableTextBox(self.content)
def set_description(self):
"""
We must use a box adapter to get the text to scroll when this widget is already in
a Pile from the main question page. Scrolling is necessary for long questions which are longer
than the length of the terminal.
"""
self.content = self.description.strip("\n").split("\n")
self._w = ScrollableTextBox(self.content)
question_post = QuestionPage((answers, question_title, question_desc, question_stats, url))
self.cachedQuestions[index] = question_post
LOOP.widget = question_post
global header_for_display
global question_page
global LOOP
header_for_display = Header()
try:
if google_search:
questions = get_questions_for_query_google(query)
else:
questions = get_questions_for_query(query)
question_page = SelectQuestionPage(questions)
LOOP = EditedMainLoop(question_page, palette)
LOOP.run()
except UnicodeEncodeError:
print_warning("\n\nEncoding error: Use \"chcp 65001\" command before using socli...")
sys.exit(0)
except requests.exceptions.ConnectionError as e:
print_fail("Please check your internet connectivity...")
except Exception as e:
showerror(e)
print("exiting...")
sys.exit(0)
global question_post
if self.cachedQuestions[index] != None:
question_post = self.cachedQuestions[index]
LOOP.widget = question_post
else:
if not google_search:
url = sourl + url
question_title, question_desc, question_stats, answers = get_question_stats_and_answer(url)
question_post = QuestionPage((answers, question_title, question_desc, question_stats, url))
self.cachedQuestions[index] = question_post
LOOP.widget = question_post
global header_for_display
global question_page
global LOOP
header_for_display = Header()
try:
if google_search:
questions = get_questions_for_query_google(query)
else:
questions = get_questions_for_query(query)
question_page = SelectQuestionPage(questions)
LOOP = EditedMainLoop(question_page, palette)
LOOP.run()
except UnicodeEncodeError:
print_warning("\n\nEncoding error: Use \"chcp 65001\" command before using socli...")
sys.exit(0)
except requests.exceptions.ConnectionError as e:
print_fail("Please check your internet connectivity...")
except Exception as e:
def set_description(self):
"""
We must use a box adapter to get the text to scroll when this widget is already in
a Pile from the main question page. Scrolling is necessary for long questions which are longer
than the length of the terminal.
"""
self.content = self.description.strip("\n").split("\n")
self._w = ScrollableTextBox(self.content)