Skip to content

Commit 6f6f0ad

Browse files
author
bender
committed
updates
1 parent d9e86f3 commit 6f6f0ad

File tree

5 files changed

+19
-21
lines changed

5 files changed

+19
-21
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
desc: Deprecated ``$lib.text()`` to instead use ``()`` syntax.
3+
prs: []
4+
type: feat
5+
...

synapse/lib/stormtypes.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,7 @@ class LibBase(Lib):
13071307
cli> storm if $lib.false { $lib.print('Is True') } else { $lib.print('Is False') }
13081308
Is False''',
13091309
'type': 'boolean', },
1310-
{'name': 'text', 'desc': 'Get a Storm Text object. This is deprecated; please use ``$lib.str()`` instead.',
1310+
{'name': 'text', 'desc': 'Get a Storm Text object. This is deprecated; please use ``()`` instead.',
13111311
'deprecated': {'eolvers': '3.0.0'},
13121312
'type': {'type': 'function', '_funcname': '_text',
13131313
'args': (
@@ -1685,10 +1685,10 @@ async def _list(self, *vals):
16851685

16861686
@stormfunc(readonly=True)
16871687
async def _text(self, *args):
1688-
s_common.deprecated('$lib.text()', curv='2.193.0')
1688+
s_common.deprecated('$lib.text()', curv='2.194.0')
16891689
runt = s_scope.get('runt')
16901690
if runt:
1691-
await runt.snap.warnonce('$lib.text() is deprecated. Use $lib.str() instead.')
1691+
await runt.snap.warnonce('$lib.text() is deprecated. Use () instead.')
16921692
valu = ''.join(args)
16931693
return Text(valu)
16941694

synapse/tests/test_cortex.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5460,7 +5460,7 @@ async def test_storm_ifstmt(self):
54605460
self.len(1, nodes)
54615461

54625462
async def test_storm_order(self):
5463-
q = '''[test:str=foo :hehe=bar] $tvar=$lib.text() $tvar.add(1) $tvar.add(:hehe) $lib.print($tvar.str()) '''
5463+
q = '''[test:str=foo :hehe=bar] $tvar=() $tvar.append(1) $tvar.append(:hehe) $lib.print($lib.str.join('', $tvar)) '''
54645464
async with self.getTestCore() as core:
54655465
mesgs = await core.stormlist(q)
54665466
self.stormIsInPrint('1bar', mesgs)

synapse/tests/test_lib_ast.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,11 @@ async def test_ast_runtsafe_bug(self):
292292
async with self.getTestCore() as core:
293293
q = '''
294294
[test:str=another :hehe=asdf]
295-
$s = $lib.text("Foo")
295+
$s = ("Foo")
296296
$newvar=:hehe
297297
-.created
298-
$s.add("yar {x}", x=$newvar)
299-
$lib.print($s.str())
298+
$s.append("yar {x}", x=$newvar)
299+
$lib.print($lib.str.join('', $s))
300300
'''
301301
mesgs = await core.stormlist(q)
302302
prints = [m[1]['mesg'] for m in mesgs if m[0] == 'print']

synapse/tests/test_lib_stormtypes.py

+7-14
Original file line numberDiff line numberDiff line change
@@ -1571,23 +1571,18 @@ async def test_storm_lib_list(self):
15711571
self.eq(ret, ('bar', 'baz', 'foo',))
15721572

15731573
# Sort a few text objects
1574-
q = '$foo=$lib.text(foo) $bar=$lib.text(bar) $baz=$lib.text(baz) $v=($foo, $bar, $baz) $v.sort() return ($v)'
1574+
q = '$foo=("foo") $bar=("bar") $baz=("baz") $v=($foo, $bar, $baz) $v.sort() return ($v)'
15751575
ret = await core.callStorm(q)
15761576
self.eq(ret, ('bar', 'baz', 'foo',))
15771577

15781578
# incompatible sort types
15791579
with self.raises(s_exc.StormRuntimeError):
15801580
await core.callStorm('$v=(foo,bar,(1)) $v.sort() return ($v)')
15811581

1582-
# mix Prims and heavy objects
1583-
with self.raises(s_exc.StormRuntimeError):
1584-
q = '$foo=$lib.text(foo) $bar=$lib.text(bar) $v=($foo, aString, $bar,) $v.sort() return ($v)'
1585-
await core.callStorm(q)
1586-
15871582
q = '$l = (1, 2, (3), 4, 1, (3), 3, asdf) return ( $l.unique() )'
15881583
self.eq(['1', '2', 3, '4', '3', 'asdf'], await core.callStorm(q))
15891584

1590-
q = '$a=$lib.text(hehe) $b=$lib.text(haha) $c=$lib.text(hehe) $foo=($a, $b, $c) return ($foo.unique())'
1585+
q = '$a=("hehe") $b=("haha") $c=("hehe") $foo=($a, $b, $c) return ($foo.unique())'
15911586
self.eq(['hehe', 'haha'], await core.callStorm(q))
15921587

15931588
await core.addUser('lowuser1')
@@ -1805,13 +1800,13 @@ async def test_storm_csv(self):
18051800
async def test_storm_text(self):
18061801
async with self.getTestCore() as core:
18071802
nodes = await core.nodes('''
1808-
[ test:int=10 ] $text=$lib.text(hehe) { +test:int>=10 $text.add(haha) }
1809-
[ test:str=$text.str() ] +test:str''')
1803+
[ test:int=10 ] $text=() $text.append(hehe) { +test:int>=10 $text.append(haha) }
1804+
[ test:str=$lib.str.join('', $text) ] +test:str''')
18101805
self.len(1, nodes)
18111806
self.eq(nodes[0].ndef, ('test:str', 'hehehaha'))
18121807

1813-
q = '''$t=$lib.text(beepboop) $lib.print($lib.len($t))
1814-
$t.add("more!") $lib.print($lib.len($t))
1808+
q = '''$t=() $t.append(beepboop) $lib.print($lib.len($lib.str.join('',$t)))
1809+
$t.append("more!") $lib.print($lib.len($lib.str.join('',$t)))
18151810
'''
18161811
msgs = await core.stormlist(q)
18171812
self.stormIsInPrint('8', msgs)
@@ -2216,7 +2211,7 @@ def __eq__(self, othr):
22162211

22172212
# text
22182213
q = '''
2219-
$text = $lib.text(beepboopgetthejedi)
2214+
$text = () $text.append(beepboopgetthejedi)
22202215
$set = $lib.set($text)
22212216
'''
22222217
msgs = await core.stormlist(q)
@@ -3431,8 +3426,6 @@ async def test_storm_lib_vars_type(self):
34313426
self.eq('telepath:proxy:method', await core.callStorm('return( $lib.vars.type($lib.telepath.open($url).getCellInfo) )', opts))
34323427
self.eq('telepath:proxy:genrmethod', await core.callStorm('return( $lib.vars.type($lib.telepath.open($url).storm) )', opts))
34333428

3434-
self.eq('text', await core.callStorm('return ( $lib.vars.type($lib.text(hehe)) )'))
3435-
34363429
self.eq('node', await core.callStorm('[test:str=foo] return ($lib.vars.type($node))'))
34373430
self.eq('node:props', await core.callStorm('[test:str=foo] return ($lib.vars.type($node.props))'))
34383431
self.eq('node:data', await core.callStorm('[test:str=foo] return ($lib.vars.type($node.data))'))

0 commit comments

Comments
 (0)