New search function on module library...abstracted a bit more here, recommend using with caution with high recursion counts...unfortunately through runtime exception with open recursion (at tree depth) for gi.repository libraries here, so implemented a counter to avoid run time error.
To implement function typically call at terminal you'd want to set modulepkg to instance object of the loaded module...e.g.,
>>a = gi.repository
if the searchword module file is saved as file searchword.py
>>searchword.searchword(a, 'Gtk', 3)
Searches the repository libraries at recursion depth of three levels at each top level directory paths.
def findresult(a, word):
results = []
for item in a:
if word in item:
results.append(item)
return results
def searchword(modulepkg, word, recursioncnt):
resultsa = []
a = dir(modulepkg)
asearch = findresult(a, word)
if recursioncnt > 0:
for item2 in a:
exception1 = False
exception2 = False
try:
modulename = eval('modulepkg.__name__')
#print(modulename)
exec('import ' + modulename)
except:
pass
try:
b = eval(modulename + '.' + item2)
except:
print('execption trying modulepkg.',item2)
exception1 = True
if exception1:
try:
b = eval('modulepkg.'+ item2)
except:
exception2 = True
pass
if not exception2:
results = searchword(b, word, recursioncnt-1)
for item2 in results:
strngpath = item + '.' + item2
asearch.append(strngpath)
return asearch
Subscribe to:
Post Comments (Atom)
Oblivion
Between the fascination of an upcoming pandemic ridden college football season, Taylor Swift, and Kim Kardashian, wildfires, crazier weathe...
-
For starters, as I've seen (pardon my ignorance if I am incorrect), it seems a common way to use path based animated motion for objects...
-
Okay so if you read into python scripting examples of moving vertices around in Blender, it seems whether using a bpy.context or bpy.data c...
-
Mesh face and vertex count much to high for game mesh and texture here (? possibly) but someday in the future may be found in textures and ...
No comments:
Post a Comment