Fix docstring display.

This commit is contained in:
Neil Booth 2015-12-12 18:11:07 +09:00
parent 34955bd0f5
commit 36aaad392d
2 changed files with 17 additions and 16 deletions

View File

@ -2583,11 +2583,14 @@ class ElectrumWindow(QMainWindow, PrintError):
nz.valueChanged.connect(on_nz) nz.valueChanged.connect(on_nz)
gui_widgets.append((nz_label, nz)) gui_widgets.append((nz_label, nz))
def fmt_docs(key, klass):
lines = [ln.lstrip(" ") for ln in klass.__doc__.split("\n")]
return '\n'.join([key, "", " ".join(lines)])
choosers = sorted(COIN_CHOOSERS.keys()) choosers = sorted(COIN_CHOOSERS.keys())
chooser_name = self.wallet.coin_chooser_name(self.config) chooser_name = self.wallet.coin_chooser_name(self.config)
msg = _('Choose coin (UTXO) selection method. The following are available:\n\n') msg = _('Choose coin (UTXO) selection method. The following are available:\n\n')
msg += '\n\n'.join(key + ": " + klass.__doc__ msg += '\n\n'.join(fmt_docs(*item) for item in COIN_CHOOSERS.items())
for key, klass in COIN_CHOOSERS.items())
chooser_label = HelpLabel(_('Coin selection') + ':', msg) chooser_label = HelpLabel(_('Coin selection') + ':', msg)
chooser_combo = QComboBox() chooser_combo = QComboBox()
chooser_combo.addItems(choosers) chooser_combo.addItems(choosers)

View File

@ -117,10 +117,9 @@ class CoinChooserBase(PrintError):
return tx return tx
class CoinChooserClassic(CoinChooserBase): class CoinChooserClassic(CoinChooserBase):
''' '''The classic electrum algorithm. Chooses coins starting with the
The classic electrum algorithm. Chooses coins starting with oldest that are sufficient to cover the spent amount, and then
the oldest that are sufficient to cover the spent amount, and removes any unneeded starting with the smallest in value.'''
then removes any unneeded starting with the smallest in value.'''
def keys(self, coins): def keys(self, coins):
return [coin['prevout_hash'] + ':' + str(coin['prevout_n']) return [coin['prevout_hash'] + ':' + str(coin['prevout_n'])
@ -179,19 +178,18 @@ class CoinChooserRandom(CoinChooserBase):
return winner return winner
class CoinChooserPrivacy(CoinChooserRandom): class CoinChooserPrivacy(CoinChooserRandom):
''' '''Attempts to better preserve user privacy. First, if any coin is
Attempts to better preserve user privacy. First, if any coin is
spent from a user address, all coins are. Compared to spending spent from a user address, all coins are. Compared to spending
from other addresses to make up an amount, this reduces from other addresses to make up an amount, this reduces
information leakage about sender holdings. It also helps to information leakage about sender holdings. It also helps to
reduce blockchain UTXO bloat, and reduce future privacy loss reduce blockchain UTXO bloat, and reduce future privacy loss that
that would come from reusing that address' remaining UTXOs. would come from reusing that address' remaining UTXOs. Second, it
Second, it penalizes change that is quite different to the sent penalizes change that is quite different to the sent amount.
amount. Third, it penalizes change that is too big. Fourth, it Third, it penalizes change that is too big. Fourth, it breaks
breaks large change up into amounts comparable to the spent large change up into amounts comparable to the spent amount.
amount. Finally, change is rounded to similar precision to Finally, change is rounded to similar precision to sent amounts.
sent amounts. Extra change outputs and rounding might raise Extra change outputs and rounding might raise the transaction fee
the transaction fee slightly''' slightly.'''
def keys(self, coins): def keys(self, coins):
return [coin['address'] for coin in coins] return [coin['address'] for coin in coins]