|
Revision 79
(checked in by stevegt, 6 years ago)
|
finish adding rudimentary Publish button
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
def XXXroundp(self, f): |
|---|
| 3 |
'''round off price f to basket_price/100 precision''' |
|---|
| 4 |
precision = math.log10(self.basket_price/100) * -1 |
|---|
| 5 |
return round(f, precision) |
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
class RoundedFloat(float): |
|---|
| 11 |
|
|---|
| 12 |
def __new__(cls, f): |
|---|
| 13 |
'''convert to float and round off price f to 1/1000 precision''' |
|---|
| 14 |
if f is None: |
|---|
| 15 |
return None |
|---|
| 16 |
val = round(float(f), 3) |
|---|
| 17 |
self = float.__new__(cls, val) |
|---|
| 18 |
return self |
|---|
| 19 |
|
|---|
| 20 |
class Price(RoundedFloat): |
|---|
| 21 |
|
|---|
| 22 |
def __str__(self): |
|---|
| 23 |
return "%.2f" % self |
|---|
| 24 |
|
|---|
| 25 |
class Size(RoundedFloat): |
|---|
| 26 |
|
|---|
| 27 |
def __str__(self): |
|---|
| 28 |
return "%.1f" % self |
|---|
| 29 |
|
|---|