Share and Money Management  0.16
Classes | Functions | Variables
gui.helper Namespace Reference

Functions to support GUI functions e.g. More...

Classes

class  ReverseDict
 A dictionary which can lookup values by key, and keys by value. More...

Functions

def formatShareNotesShort
 Returns additional note to a share - short formatted.
def formatShareNotesLong
 Returns additional note to a share - long formatted.
def formatCurrencySign
 Returns the sign of a currency or an empty string.
def formatCurrencyShort
 Returns the currency sign or code or an empty string.
def formatCurrencyLong
 Returns the formatted currency or an empty string.
def formatDate
 Returns the formatted date or an empty string.
def formatDecimal
 Returns the formatted decimal value or an empty string.
def formatDuration
 Returns the given duration formatted.
def formatDailyQuoteEvent
 Returns the DailyQuote.event formatted.
def formatExchange
 Returns the formatted exchange or an empty string.
def formatMoney
 Returns the formatted decimal value incl.
def formatPercent
 Returns the formatted decimal value incl.
def formatPosition
 Returns the formatted position or an empty string.
def formatShare
 Returns the formatted share or an empty string.
def formatShareShort
 Returns the formatted share or an empty string.
def formatShareKind
 Returns the type of the share or an empty string.
def formatTransactionKind
 Returns the transaction type as a string or an empty string.
def moneyfmt
 Convert Decimal to a money formatted string.
def wxdate2pydate
 Convert a date from wxDateTime to Python datetime.date.
def pydate2wxdate
 Convert a date from Python datetime.date to wxDateTime.
def formatTransactionElements
 Format all attributes of a Transaction for showing and sorting.

Variables

tuple RE_WHITESPACES = re.compile(r'\s{2,}|[\r\n]')
 Precompiled RE pattern to match two or more white spaces or single linebreak characters.
tuple DAYS_PER_YEAR = decimal.Decimal('365')
 Number of days in a year.

Detailed Description

Functions to support GUI functions e.g.

to format values

Author
Carsten Grohmann <mail (at) carstengrohmann (dot) de>
License:
GPL version 2.0

Function Documentation

def gui.helper.formatCurrencyLong (   currency)

Returns the formatted currency or an empty string.

See Also
smm.objects.Currency
formatCurrencySign()
formatCurrencyShort()
def gui.helper.formatCurrencyShort (   currency)

Returns the currency sign or code or an empty string.

See Also
smm.objects.Currency.sign
formatCurrencySign()
formatCurrencyLong()

Referenced by gui.helper.formatMoney().

Here is the caller graph for this function:

def gui.helper.formatCurrencySign (   currency)

Returns the sign of a currency or an empty string.

See Also
smm.objects.Currency.sign
formatCurrencyShort()
formatCurrencyLong()
def gui.helper.formatDailyQuoteEvent (   quote)

Returns the DailyQuote.event formatted.

def gui.helper.formatDate (   date,
  fmt = '%d.%m.%Y' 
)

Returns the formatted date or an empty string.

Referenced by gui.helper.formatPosition(), and gui.helper.formatTransactionElements().

Here is the caller graph for this function:

def gui.helper.formatDecimal (   value,
  places = 2,
  grouping = True 
)

Returns the formatted decimal value or an empty string.

Formatting will be done automatically using the database of the local conventions

Parameters
valueThe decimal value
placesRequired number of places after the decimal point
groupingGrouping part before decimal point
Returns
Formatted decimal values or an empty Unicode string for non-decimal values

References gui.helper.moneyfmt().

Referenced by gui.helper.formatTransactionElements().

Here is the call graph for this function:

Here is the caller graph for this function:

def gui.helper.formatDuration (   duration)

Returns the given duration formatted.

Parameters
durationDuration in days as a decimal.Decimal.
See Also
DAYS_PER_YEAR

Referenced by gui.helper.formatTransactionElements().

Here is the caller graph for this function:

def gui.helper.formatExchange (   exchange)

Returns the formatted exchange or an empty string.

Referenced by gui.helper.formatTransactionElements().

Here is the caller graph for this function:

def gui.helper.formatMoney (   value,
  currency,
  places = 3,
  grouping = True 
)

Returns the formatted decimal value incl.

the currency or an empty string

Formatting will be done automatically using the database of the local conventions

Parameters
valueThe decimal value
currencyA smm.objects.Currency instance
placesRequired number of places after the decimal point
groupingGrouping part before decimal point
Returns
Formatted decimal values or an empty Unicode string for non-decimal values

References gui.helper.formatCurrencyShort(), and gui.helper.moneyfmt().

Referenced by gui.helper.formatTransactionElements().

Here is the call graph for this function:

Here is the caller graph for this function:

def gui.helper.formatPercent (   value,
  places = 3 
)

Returns the formatted decimal value incl.

percent sign or an empty string

Parameters
valueThe decimal value
placesRequired number of places after the decimal point

References gui.helper.moneyfmt().

Here is the call graph for this function:

def gui.helper.formatPosition (   pos)

Returns the formatted position or an empty string.

See Also
smm.objects.Position

References gui.helper.formatDate(), and gui.helper.formatShare().

Here is the call graph for this function:

def gui.helper.formatShare (   share)

Returns the formatted share or an empty string.

See Also
smm.objects.Share
formatShareKind()

Referenced by gui.helper.formatPosition(), gui.helper.formatTransactionElements(), and gui.helper.formatTransactionKind().

Here is the caller graph for this function:

def gui.helper.formatShareKind (   share)

Returns the type of the share or an empty string.

See Also
smm.objects.Share.kind
formatShare()
def gui.helper.formatShareNotesLong (   share)

Returns additional note to a share - long formatted.

See Also
smm.objects.Share.notes
formatShareNotesShort()
def gui.helper.formatShareNotesShort (   share,
  max_len = 25 
)

Returns additional note to a share - short formatted.

Parameters
shareThe smm.objects.Share object
max_lenLength of the note
See Also
smm.objects.Share.notes
formatShareNotesLong()
def gui.helper.formatShareShort (   share)

Returns the formatted share or an empty string.

See Also
smm.objects.Share
formatShareKind()
def gui.helper.formatTransactionElements (   transaction)

Format all attributes of a Transaction for showing and sorting.

Example:
>>> tr
<Transaction object at 0xa3445ec -- #1 (date: 2007-06-15, count: -90, ...>
>>> import pprint
>>> pprint.pprint(res)
{'count_show': u'90.000',
'count_sort': Decimal('-90'),
'date_show': u'15.06.2007',
'date_sort': '2007-06-15',
'exchange_show': u'XETRA, Germany',
'exchange_sort': u'xetra, germany',
'fee_show': u'5,19 \u20ac',
'fee_sort': Decimal('5.19'),
'holding_period_show': u'',
'holding_period_sort': -1,
'kind_show': u'Verkauf',
'kind_sort': u'verkauf',
'share_show': u'Ahlers Vz',
'share_sort': u'ahlers vz',
'value_show': u'13,300 \u20ac',
'value_sort': Decimal('13.30'),
'volume_show': u'1197,000 \u20ac',
'volume_sort': Decimal('-1197.00')}
Returns
Dictionary with formatted elements

References gui.helper.formatDate(), gui.helper.formatDecimal(), gui.helper.formatDuration(), gui.helper.formatExchange(), gui.helper.formatMoney(), gui.helper.formatShare(), and gui.helper.formatTransactionKind().

Here is the call graph for this function:

def gui.helper.formatTransactionKind (   transaction)

Returns the transaction type as a string or an empty string.

See Also
smm.objects.Transaction.kind

References gui.helper.formatShare(), and gui.helper.moneyfmt().

Referenced by gui.helper.formatTransactionElements().

Here is the call graph for this function:

Here is the caller graph for this function:

def gui.helper.moneyfmt (   value,
  places = 2,
  curr = '',
  sep = ',
  dp = '.',
  pos = '',
  neg = '-',
  trailneg = '' 
)

Convert Decimal to a money formatted string.

Parameters
valuethe decimal value
placesrequired number of places after the decimal point
curroptional currency symbol before the sign (may be blank)
sepoptional grouping separator (comma, period, space, or blank)
dpdecimal point indicator (comma or period) only specify as blank when places is zero
posoptional sign for positive numbers: '+', space or blank
negoptional sign for negative numbers: '-', '(', space or blank
trailnegoptional trailing minus indicator: '-', ')', space or blank
Example:
>>> d = Decimal('-1234567.8901')
>>> moneyfmt(d, curr='$')
'-$1,234,567.89'
>>> moneyfmt(d, places=0, sep='.', dp='', neg='', trailneg='-')
'1.234.568-'
>>> moneyfmt(d, curr='$', neg='(', trailneg=')')
'($1,234,567.89)'
>>> moneyfmt(Decimal(123456789), sep=' ')
'123 456 789.00'
>>> moneyfmt(Decimal('-0.02'), neg='<', trailneg='>')
'<0.02>'
Source:
Receipes of the Python decimal module

Referenced by gui.helper.formatDecimal(), gui.helper.formatMoney(), gui.helper.formatPercent(), and gui.helper.formatTransactionKind().

Here is the caller graph for this function:

def gui.helper.pydate2wxdate (   pydate)

Convert a date from Python datetime.date to wxDateTime.

See Also
wxdate2pydate()
def gui.helper.wxdate2pydate (   wxdate)

Convert a date from wxDateTime to Python datetime.date.

See Also
pydate2wxdate()

Variable Documentation

tuple gui.helper.DAYS_PER_YEAR = decimal.Decimal('365')

Number of days in a year.

See Also
formatDuration()
tuple gui.helper.RE_WHITESPACES = re.compile(r'\s{2,}|[\r\n]')

Precompiled RE pattern to match two or more white spaces or single linebreak characters.