22from typing import Optional , List
33
44from .base import BaseSubAPI
5- from ..lua import LuaExpr , lua_string
5+ from ..lua import lua_string
66from ..rproc import boolean , string , integer , nil , array_string , option_string , fact_scheme_dict
77
88
1414}, {})
1515
1616
17- class BaseHandle (BaseSubAPI , LuaExpr ):
18- def __init__ (self , cc , var ):
19- super ().__init__ (cc )
20- self ._API = var
21-
22- def get_expr_code (self ):
23- return self ._API
24-
25-
26- class ReadHandle (BaseHandle ):
17+ class ReadHandle (BaseSubAPI ):
2718 async def read (self , count : int ) -> Optional [str ]:
2819 return option_string (await self ._send ('read' , count ))
2920
@@ -43,7 +34,7 @@ async def __anext__(self):
4334 return line
4435
4536
46- class WriteHandle (BaseHandle ):
37+ class WriteHandle (BaseSubAPI ):
4738 async def write (self , text : str ):
4839 return nil (await self ._send ('write' , text ))
4940
@@ -55,8 +46,6 @@ async def flush(self):
5546
5647
5748class FSAPI (BaseSubAPI ):
58- _API = 'fs'
59-
6049 async def list (self , path : str ) -> List [str ]:
6150 return array_string (await self ._send ('list' , path ))
6251
@@ -111,7 +100,7 @@ async def open(self, path: str, mode: str):
111100 fid = self ._cc ._new_task_id ()
112101 var = 'temp[{}]' .format (lua_string (fid ))
113102 await self ._cc .eval_coro ('{} = fs.open({}, {})' .format (
114- var , * map ( lua_string , [ path , mode ] )))
103+ var , lua_string ( path ), lua_string ( mode )))
115104 try :
116105 yield (ReadHandle if 'r' in mode else WriteHandle )(self ._cc , var )
117106 finally :
@@ -133,7 +122,7 @@ async def complete(
133122 self , partialName : str , path : str , includeFiles : bool = None , includeDirs : bool = None ,
134123 ) -> List [str ]:
135124 return array_string (await self ._send (
136- 'complete' , partialName , path , includeFiles , includeDirs , omit_nulls = False ))
125+ 'complete' , partialName , path , includeFiles , includeDirs ))
137126
138127 async def attributes (self , path : str ) -> dict :
139128 return attribute (await self ._send ('attributes' , path ))
0 commit comments