Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
ss1.FormulaCell Class Reference
Inheritance diagram for ss1.FormulaCell:
Inheritance graph
[legend]
Collaboration diagram for ss1.FormulaCell:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def reset
def recalc
def format
def xml
def renumber

Public Attributes

 formula
 translated
 fmt
 alignment
 value

Detailed Description

Definition at line 391 of file ss1.py.


Constructor & Destructor Documentation

def ss1.FormulaCell.__init__ (   self,
  formula,
  fmt = "%s",
  alignment = RIGHT 
)

Definition at line 393 of file ss1.py.

00393 
00394     def __init__(self, formula, fmt="%s", alignment=RIGHT):
00395         assert alignment in (LEFT, CENTER, RIGHT)
00396         self.formula = formula
00397         self.translated = translate(self.formula)
00398         self.fmt = fmt
00399         self.alignment = alignment
00400         self.reset()

Here is the caller graph for this function:


Member Function Documentation

def ss1.FormulaCell.format (   self)

Definition at line 417 of file ss1.py.

00417 
00418     def format(self):
00419         try:
00420             text = self.fmt % self.value
00421         except:
00422             text = str(self.value)
00423         return text, self.alignment

Here is the caller graph for this function:

def ss1.FormulaCell.recalc (   self,
  ns 
)

Definition at line 404 of file ss1.py.

00404 
00405     def recalc(self, ns):
00406         if self.value is None:
00407             try:
00408                 # A hack to evaluate expressions using true division
00409                 self.value = eval(self.translated, ns)
00410             except:
00411                 exc = sys.exc_info()[0]
00412                 if hasattr(exc, "__name__"):
00413                     self.value = exc.__name__
00414                 else:
00415                     self.value = str(exc)
00416         return self.value

def ss1.FormulaCell.renumber (   self,
  x1,
  y1,
  x2,
  y2,
  dx,
  dy 
)

Definition at line 430 of file ss1.py.

00430 
00431     def renumber(self, x1, y1, x2, y2, dx, dy):
00432         out = []
00433         for part in re.split('(\w+)', self.formula):
00434             m = re.match('^([A-Z]+)([1-9][0-9]*)$', part)
00435             if m is not None:
00436                 sx, sy = m.groups()
00437                 x = colname2num(sx)
00438                 y = int(sy)
00439                 if x1 <= x <= x2 and y1 <= y <= y2:
00440                     part = cellname(x+dx, y+dy)
00441             out.append(part)
00442         return FormulaCell("".join(out), self.fmt, self.alignment)

Here is the call graph for this function:

def ss1.FormulaCell.reset (   self)

Definition at line 401 of file ss1.py.

00401 
00402     def reset(self):
00403         self.value = None

Here is the caller graph for this function:

def ss1.FormulaCell.xml (   self)

Definition at line 424 of file ss1.py.

00424 
00425     def xml(self):
00426         return '<formula align="%s" format="%s">%s</formula>' % (
00427             align2xml[self.alignment],
00428             self.fmt,
00429             self.formula)


Member Data Documentation

Definition at line 398 of file ss1.py.

Definition at line 397 of file ss1.py.

Definition at line 395 of file ss1.py.

Definition at line 396 of file ss1.py.

Definition at line 402 of file ss1.py.


The documentation for this class was generated from the following file: