Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/calculate.py
diff options
context:
space:
mode:
Diffstat (limited to 'calculate.py')
-rw-r--r--calculate.py41
1 files changed, 21 insertions, 20 deletions
diff --git a/calculate.py b/calculate.py
index 0c9e861..6b79e90 100644
--- a/calculate.py
+++ b/calculate.py
@@ -113,7 +113,7 @@ class Equation:
if l[2].startswith("<svg>"):
l[2] = SVGImage(data=base64.b64decode(l[2][5:]))
-# Should figure out how to use MathLib directly in a non-hacky way
+ # Should figure out how to use MathLib directly in a non-hacky way
else:
try:
l[2] = Decimal(l[2])
@@ -484,8 +484,8 @@ class Calculate(ShareableActivity):
res = RuntimeError(_('Can not assign label: will cause recursion'),
lastpos)
-# If parsing went ok, see if we have to replace the previous answer
-# to get a (more) exact result
+ # If parsing went ok, see if we have to replace the previous answer
+ # to get a (more) exact result
if self.ans_inserted and not isinstance(res, ParserError) \
and not isinstance(res, SVGImage):
ansvar = self.format_insert_ans()
@@ -562,9 +562,9 @@ class Calculate(ShareableActivity):
self.clear()
return True
-##########################################
-# Journal functions
-##########################################
+ ##########################################
+ # Journal functions
+ ##########################################
def write_file(self, file_path):
"""Write journal entries, Calculate Journal Version (cjv) 1.0"""
@@ -580,7 +580,7 @@ class Calculate(ShareableActivity):
sel = (pos, pos)
f.write("%s;%d;%d;%d\n" % (self.text_entry.get_text(), pos, sel[0], sel[1]))
-# In reverse order
+ # In reverse order
for eq in self.old_eqs:
f.write(str(eq))
@@ -623,9 +623,9 @@ class Calculate(ShareableActivity):
_logger.error('Unable to read journal entry, unknown version (%s)', version)
return False
-##########################################
-# User interaction functions
-##########################################
+ ##########################################
+ # User interaction functions
+ ##########################################
def remove_character(self, dir):
pos = self.text_entry.get_position()
@@ -670,7 +670,7 @@ class Calculate(ShareableActivity):
def tab_complete(self):
-# Get start of variable name
+ # Get start of variable name
str = self.text_entry.get_text()
if len(str) == 0:
return
@@ -688,17 +688,17 @@ class Calculate(ShareableActivity):
partial_name = str[start_ofs:end_ofs]
_logger.debug('tab-completing %s...', partial_name)
-# Lookup matching variables
+ # Lookup matching variables
vars = self.parser.get_names(start=partial_name)
if len(vars) == 0:
return False
-# Nothing selected, select first match
+ # Nothing selected, select first match
if len(sel) == 0:
name = vars[0]
self.text_entry.set_text(str[:start_ofs] + name + str[end_ofs:])
-# Select next matching variable
+ # Select next matching variable
else:
full_name = str[start_ofs:sel[1]]
if full_name not in vars:
@@ -712,10 +712,10 @@ class Calculate(ShareableActivity):
self.select_reason = self.SELECT_TAB
return True
-# Selection related functions
+ # Selection related functions
def expand_selection(self, dir):
-# _logger.info('Expanding selection in dir %d', dir)
+ #_logger.info('Expanding selection in dir %d', dir)
sel = self.text_entry.get_selection_bounds()
slen = len(self.text_entry.get_text())
pos = self.text_entry.get_position()
@@ -723,7 +723,8 @@ class Calculate(ShareableActivity):
sel = (pos, pos)
if dir < 0:
newpos = max(0, sel[0] + dir)
- self.text_entry.set_position(newpos) # apparently no such thing as a cursor position during select
+ # apparently no such thing as a cursor position during select
+ self.text_entry.set_position(newpos)
self.text_entry.select_region(newpos, sel[1])
elif dir > 0:
newpos = min(sel[1] + dir, slen)
@@ -734,7 +735,7 @@ class Calculate(ShareableActivity):
def text_copy(self):
str = self.text_entry.get_text()
sel = self.text_entry.get_selection_bounds()
- # _logger.info('text_copy, sel: %r, str: %s', sel, str)
+ #_logger.info('text_copy, sel: %r, str: %s', sel, str)
if len(sel) == 2:
(start, end) = sel
self.clipboard.set_text(str[start:end])
@@ -801,12 +802,12 @@ class Calculate(ShareableActivity):
def add_text(self, input_str):
self.button_pressed(self.TYPE_TEXT, input_str)
-# This function should be split up properly
+ # This function should be split up properly
def button_pressed(self, str_type, input_str):
sel = self.text_entry.get_selection_bounds()
pos = self.text_entry.get_position()
-# If selection by tab completion just manipulate end
+ # If selection by tab completion just manipulate end
if len(sel) == 2 and self.select_reason != self.SELECT_SELECT:
pos = sel[1]
sel = ()