string literal fixes: deprecated escapes, et al.

This commit is contained in:
The MMGen Project 2022-01-06 20:24:20 +00:00
commit 4ce1701de2
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
9 changed files with 21 additions and 21 deletions

View file

@ -210,7 +210,7 @@ def decode(rlp, sedes=None, strict=True, recursive_cache=False, **kwargs):
:param sedes: an object implementing a function ``deserialize(code)`` which will be applied
after decoding, or ``None`` if no deserialization should be performed
:param \*\*kwargs: additional keyword arguments that will be passed to the deserializer
:param **kwargs: additional keyword arguments that will be passed to the deserializer
:param strict: if false inputs that are longer than necessary don't cause an exception
:returns: the decoded and maybe deserialized Python object
:raises: :exc:`rlp.DecodingError` if the input string does not end after the root item and

View file

@ -974,7 +974,7 @@ class IPPort(str,Hilite,InitErrors,MMGenObject):
if type(s) == cls:
return s
try:
m = re.fullmatch('{q}\.{q}\.{q}\.{q}:(\d{{1,10}})'.format(q=r'([0-9]{1,3})'),s)
m = re.fullmatch(r'{q}\.{q}\.{q}\.{q}:(\d{{1,10}})'.format(q=r'([0-9]{1,3})'),s)
assert m is not None, f'{s!r}: invalid IP:HOST specifier'
for e in m.groups():
if len(e) != 1 and e[0] == '0':

View file

@ -29,7 +29,7 @@ from mmgen.devtools import *
def strip_ansi_escapes(s):
import re
return re.sub('\x1b\[[;0-9]+?m','',s)
return re.sub('\x1b' + r'\[[;0-9]+?m','',s)
ascii_uc = ''.join(map(chr,list(range(65,91)))) # 26 chars
ascii_lc = ''.join(map(chr,list(range(97,123)))) # 26 chars

View file

@ -70,7 +70,7 @@ class MMGenPexpect(object):
self.expect('Check key-to-address validity? (y/N): ',('n','y')[check])
def view_tx(self,view):
self.expect('View.* transaction.*\? .*: ',view,regex=True)
self.expect(r'View.* transaction.*\? .*: ',view,regex=True)
if view not in 'n\n':
self.expect('to continue: ','\n')

View file

@ -90,26 +90,26 @@ bals = {
('98831F3A:E:2','23.45495'),
('98831F3A:E:11','1.234'),
('98831F3A:E:21','2.345'),
(burn_addr + '\s+Non-MMGen',amt1)],
(burn_addr + r'\s+Non-MMGen',amt1)],
'8': [ ('98831F3A:E:1','0'),
('98831F3A:E:2','23.45495'),
('98831F3A:E:11',vbal1,'a1'),
('98831F3A:E:12','99.99895'),
('98831F3A:E:21','2.345'),
(burn_addr + '\s+Non-MMGen',amt1)],
(burn_addr + r'\s+Non-MMGen',amt1)],
'9': [ ('98831F3A:E:1','0'),
('98831F3A:E:2','23.45495'),
('98831F3A:E:11',vbal1,'a1'),
('98831F3A:E:12',vbal2),
('98831F3A:E:21','2.345'),
(burn_addr + '\s+Non-MMGen',amt1)],
(burn_addr + r'\s+Non-MMGen',amt1)],
'10': [ ('98831F3A:E:1','0'),
('98831F3A:E:2','23.0218'),
('98831F3A:E:3','0.4321'),
('98831F3A:E:11',vbal1,'a1'),
('98831F3A:E:12',vbal2),
('98831F3A:E:21','2.345'),
(burn_addr + '\s+Non-MMGen',amt1)]
(burn_addr + r'\s+Non-MMGen',amt1)]
}
token_bals = {
@ -120,18 +120,18 @@ token_bals = {
('98831F3A:E:12','1.23456','0')],
'4': [ ('98831F3A:E:11','110.654317776666555545',vbal1,'a1'),
('98831F3A:E:12','1.23456','0'),
(burn_addr + '\s+Non-MMGen',amt2,amt1)],
(burn_addr + r'\s+Non-MMGen',amt2,amt1)],
'5': [ ('98831F3A:E:11','110.654317776666555545',vbal1,'a1'),
('98831F3A:E:12','1.23456','99.99895'),
(burn_addr + '\s+Non-MMGen',amt2,amt1)],
(burn_addr + r'\s+Non-MMGen',amt2,amt1)],
'6': [ ('98831F3A:E:11','110.654317776666555545',vbal1,'a1'),
('98831F3A:E:12','0',vbal2),
('98831F3A:E:13','1.23456','0'),
(burn_addr + '\s+Non-MMGen',amt2,amt1)],
(burn_addr + r'\s+Non-MMGen',amt2,amt1)],
'7': [ ('98831F3A:E:11','67.444317776666555545',vbal9,'a2'),
('98831F3A:E:12','43.21',vbal2),
('98831F3A:E:13','1.23456','0'),
(burn_addr + '\s+Non-MMGen',amt2,amt1)]
(burn_addr + r'\s+Non-MMGen',amt2,amt1)]
}
token_bals_getbalance = {
'1': (vbal4,'999999.12345689012345678'),
@ -696,7 +696,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
addr,_amt1,_amt2,adj = b if len(b) == 4 else b + (False,)
if adj and self.proto.coin == 'ETC':
_amt2 = str(Decimal(_amt2) + Decimal(adj[1]) * self.bal_corr)
pat = rf'{addr}\b.*\D{_amt1}\D.*\b{_amt2}\D'
pat = fr'{addr}\b.*\D{_amt1}\D.*\b{_amt2}\D'
assert re.search(pat,text), pat
ss = 'Total MM1:'
assert re.search(ss,text),ss
@ -723,7 +723,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
def chk_label(self,lbl_pat,addr='98831F3A:E:3'):
t = self.spawn('mmgen-tool', self.eth_args + ['listaddresses','all_labels=1'])
t.expect(rf'{addr}\b.*\S{{30}}\b.*{lbl_pat}\b',regex=True)
t.expect(fr'{addr}\b.*\S{{30}}\b.*{lbl_pat}\b',regex=True)
return t
def add_label1(self): return self.add_label(lbl=tw_label_zh)
@ -1084,7 +1084,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
t.expect(' main menu): ',n+'\n')
t.expect('Is this what you want? (y/N): ','y')
t.expect('[R]efresh balance:\b','q')
t.expect(f'Total unspent:.*\D{total}\D.*{total_coin}',regex=True)
t.expect(rf'Total unspent:.*\D{total}\D.*{total_coin}',regex=True)
t.read()
return t

View file

@ -497,7 +497,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared):
([],['--rbf'])[self.proto.cap('rbf')] +
['-f',self.tx_fee,'-B'] + add_args + cmd_args + txdo_args)
if t.expect([('Get','Unsigned transac')[cmdline_inputs],'Unable to connect to \S+'],regex=True) == 1:
if t.expect([('Get','Unsigned transac')[cmdline_inputs],r'Unable to connect to \S+'],regex=True) == 1:
raise TestSuiteException('\n'+t.p.after)
if cmdline_inputs:
@ -665,7 +665,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared):
t.expect_getend('Incog Wallet ID: ')
wcls = Wallet.fmt_code_to_type(in_fmt)
t.hash_preset(wcls.desc,'1')
t.passphrase(f'{wcls.desc} \w{{8}}',self.wpasswd)
t.passphrase(rf'{wcls.desc} \w{{8}}',self.wpasswd)
vmsg('Comparing generated checksum with checksum from address file')
chk = t.expect_getend(r'Checksum for address data .*?: ',regex=True)
verify_checksum_or_exit(self._get_addrfile_checksum(),chk)

View file

@ -150,7 +150,7 @@ class TestSuiteShared(object):
def txsign_end(self,t,tnum=None,has_label=False):
t.expect('Signing transaction')
t.do_comment(False,has_label=has_label)
t.expect('Save signed transaction.*?\? \(Y/n\): ','y',regex=True)
t.expect(r'Save signed transaction.*?\? \(Y/n\): ','y',regex=True)
t.written_to_file('Signed transaction' + (' #' + tnum if tnum else ''), oo=True)
return t

View file

@ -377,11 +377,11 @@ class TestSuiteXMRWallet(TestSuiteBase):
if op == 'sweep':
t.expect(
'Create new {} .* \(y/N\): '.format(('address','account')[',' in arg2]),
r'Create new {} .* \(y/N\): '.format(('address','account')[',' in arg2]),
('y','n')[reuse_acct],
regex=True )
if reuse_acct:
t.expect( 'to last existing account .* \(y/N\): ','y', regex=True )
t.expect( r'to last existing account .* \(y/N\): ','y', regex=True )
if return_amt:
amt = XMRAmt(strip_ansi_escapes(t.expect_getend('Amt: ')).replace('XMR','').strip())

View file

@ -56,7 +56,7 @@ def md5_hash(s):
def md5_hash_strip(s):
import re
s = re.sub('\x1b\[[;0-9]+?m','',s) # strip ANSI color sequences
s = re.sub('\x1b' + r'\[[;0-9]+?m','',s) # strip ANSI color sequences
s = s.replace(NL,'\n') # fix DOS newlines
return md5_hash(s.strip())