@@ -39,7 +39,7 @@ class Name(expr):
3939def writeModule (astModule : ast .Module , moduleIdentifier : str ) -> None :
4040 ast .fix_missing_locations (astModule )
4141 pythonSource : str = ast .unparse (astModule )
42- if moduleIdentifier in { 'ClassIsAndAttribute' , 'DOT' , 'Grab' } :
42+ if 'ClassIsAndAttribute' in moduleIdentifier or 'DOT' in moduleIdentifier or 'Grab' in moduleIdentifier :
4343 pythonSource = "# ruff: noqa: F403, F405\n " + pythonSource
4444 # if 'ClassIsAndAttribute' in moduleIdentifier:
4545 # listTypeIgnore: list[ast.TypeIgnore] = []
@@ -180,7 +180,69 @@ def makeToolBe():
180180 del ClassDef
181181
182182def makeToolDOT ():
183- pass
183+ list4ClassDefBody : list [ast .stmt ] = [ClassDefDocstringDOT ]
184+
185+ dictionaryToolElements : dict [str , dict [str , dict [str , int | str ]]] = getElementsDOT ()
186+
187+ # Process each attribute group to generate overloaded methods and implementations
188+ for attribute , attributeDictionary in dictionaryToolElements .items ():
189+ # print(attribute)
190+ listElementsHARDCODED = ['attribute' , 'TypeAliasSubcategory' , 'attributeVersionMinorMinimum' , 'ast_exprType' ]
191+ for TypeAliasSubcategory , Z0Z_tired in attributeDictionary .items ():
192+ # print('\t', TypeAliasSubcategory)
193+ ast_exprType = cast (ast .Attribute , eval (Z0Z_tired ['ast_exprType' ])) # pyright: ignore[reportArgumentType]
194+ # print('\t\t', ast_exprType)
195+ attributeVersionMinorMinimum : int = Z0Z_tired ['attributeVersionMinorMinimum' ] # pyright: ignore[reportAssignmentType]
196+ # print('\t\t', attributeVersionMinorMinimum)
197+ # continue
198+
199+ ast_stmt = ast .FunctionDef (
200+ name = attribute ,
201+ args = ast .arguments (
202+ posonlyargs = [],
203+ args = [ast .arg ('node' , ast .Name ('hasDOT' + attribute ))],
204+ vararg = None ,
205+ kwonlyargs = [],
206+ kw_defaults = [],
207+ kwarg = None ,
208+ defaults = []
209+ ),
210+ body = [ast .Expr (ast .Constant (value = ...))],
211+ decorator_list = [astName_staticmethod , astName_overload ],
212+ returns = ast_exprType
213+ )
214+
215+ if attributeVersionMinorMinimum > pythonVersionMinorMinimum :
216+ ast_stmt = ast .If (test = ast .Compare (
217+ left = ast .Attribute (ast .Name ('sys' ), 'version_info' ),
218+ ops = [ast .GtE ()],
219+ comparators = [ast .Tuple (
220+ elts = [ast .Constant (3 ), ast .Constant (attributeVersionMinorMinimum )],
221+ ctx = ast .Load ()
222+ )]
223+ ),
224+ body = [ast_stmt ],
225+ orelse = [])
226+
227+ list4ClassDefBody .append (ast_stmt )
228+
229+ ClassDefDOT = ast .ClassDef (name = 'DOT' , bases = [], keywords = [], body = list4ClassDefBody , decorator_list = [])
230+
231+ ClassDef = ClassDefDOT
232+ writeModule (ast .Module (
233+ body = [docstringWarning
234+ , ast .ImportFrom (module = 'astToolkit' , names = [ast .alias (name = 'ast_Identifier' ), ast .alias (name = 'ast_expr_Slice' ), ast .alias (name = 'astDOTtype_param' )], level = 0 )
235+ , ast .ImportFrom (module = 'astToolkit._astTypes' , names = [ast .alias (name = '*' )], level = 0 )
236+ , ast .ImportFrom (module = 'collections.abc' , names = [ast .alias (name = 'Sequence' )], level = 0 )
237+ , ast .ImportFrom (module = 'typing' , names = [ast .alias (name = 'Any' ), ast .alias (name = 'Literal' ), ast .alias (name = 'overload' )], level = 0 )
238+ , ast .Import (names = [ast .alias (name = 'ast' )])
239+ , ast .Import (names = [ast .alias (name = 'sys' )])
240+ , ClassDef
241+ ],
242+ type_ignores = []
243+ )
244+ , moduleIdentifierPrefix + ClassDef .name )
245+ del ClassDef
184246
185247def makeToolMake ():
186248 list4ClassDefBody : list [ast .stmt ] = [ClassDefDocstringMake ]
@@ -228,5 +290,6 @@ def makeToolMake():
228290 del ClassDef
229291
230292if __name__ == "__main__" :
231- makeTypeAlias ()
232- makeToolBe ()
293+ # makeToolBe()
294+ makeToolDOT ()
295+ # makeTypeAlias()
0 commit comments