Skip to content

Commit

Permalink
Put __future__.division into effect for rockmeter expressions.
Browse files Browse the repository at this point in the history
  • Loading branch information
stump committed Apr 10, 2011
1 parent 8b2ae37 commit 90fb655
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Rockmeter.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@

from __future__ import with_statement

# So we don't get future division in effect but can get the flag for
# compiling the rockmeter expressions with it in effect.
import __future__
FUTURE_DIVISION = __future__.division.compiler_flag

from LinedConfigParser import LinedConfigParser
import os

Expand Down Expand Up @@ -86,15 +91,15 @@ def getexpr(self, value, default=None):
if self.config.has_option(self.section, value):
filename, lineno = self.config.getlineno(self.section, value)
expr = self.config.get(self.section, value)
return compile('\n' * (lineno - 1) + expr, filename, 'eval')
return compile(default, '<string>', 'eval')
return compile('\n' * (lineno - 1) + expr, filename, 'eval', FUTURE_DIVISION)
return compile(default, '<string>', 'eval', FUTURE_DIVISION)

def getexprs(self, value, default=None, separator='|'):
if self.config.has_option(self.section, value):
filename, lineno = self.config.getlineno(self.section, value)
exprs = self.config.get(self.section, value).split(separator)
return [compile('\n' * (lineno - 1) + expr, filename, 'eval') for expr in exprs]
return [compile(expr, '<string>', 'eval') for expr in default.split(separator)]
return [compile('\n' * (lineno - 1) + expr, filename, 'eval', FUTURE_DIVISION) for expr in exprs]
return [compile(expr, '<string>', 'eval', FUTURE_DIVISION) for expr in default.split(separator)]


# A graphical rockmeter layer
Expand Down

0 comments on commit 90fb655

Please sign in to comment.