python - TypeError: 'NoneType' object is not iterable -


i error in maya 2012 , not sure how fix, trying have python ignore init file when searching other files within folder. suggestions appreciated.

error: 'nonetype' object not iterable traceback (most recent call last):   file "<maya console>", line 18, in <module>   file "e:/3d/maya/2012-x64/scripts/riggingtool/modules\system\blueprint_ui.py" line 28, in __init__     self.initialisemoduletab(tabheight, tabwidth)   file "e:/3d/maya/2012-x64/scripts/riggingtool/modules\system\blueprint_ui.py", line 50, in initialisemoduletab     module in utils.findallmodules("modules/blueprint"):   file "e:/3d/maya/2012-x64/scripts/riggingtool/modules\system\utils.py", line 8, in findallmodules     file in allpyfiles: typeerror: 'nonetype' object not iterable 

main code is

import maya.cmds cmds  import system.utils utils reload(utils)  class blueprint_ui:     def __init__(self):         # store ui elements in dictionary         self.uielements = {}          if cmds.window("blueprint_ui_window", exists=true):             cmds.deleteui("blueprint_ui_window")          windowwidth = 400         windowheight = 598          self.uielements["window"] = cmds.window("blueprint_ui_window", width=windowwidth, height=windowheight, title="blueprint module ui", sizeable=false)          self.uielements["toplevelcolumn"] = cmds.columnlayout(adjustablecolumn=true, columnalign="center")          # setup tabs         tabheight = 500         self.uielements["tabs"] = cmds.tablayout(height=tabheight, innermarginwidth=5, innermarginheight=5)          tabwidth = cmds.tablayout(self.uielements["tabs"], q=true, width=true)         self.scrollwidth = tabwidth - 40          self.initialisemoduletab(tabheight, tabwidth)          cmds.tablayout(self.uielements["tabs"], edit=true, tablabelindex=([1, "modules"]))           # display window         cmds.showwindow( self.uielements["window"] )      def initialisemoduletab(self, tabheight, tabwidth):         scrollheight = tabheight # temp value          self.uielements["modulecolumn"] = cmds.columnlayout(adj=true, rs=3)          self.uielements["moduleframelayout"] = cmds.framelayout(height=scrollheight, collapsable=false, bordervisible=false, labelvisible=false)          self.uielements["modulelist_scroll"] = cmds.scrolllayout(hst=0)          self.uielements["modulelist_column"] = cmds.columnlayout(columnwidth = self.scrollwidth, adj=true, rs=2)          # first separator         cmds.separator()          module in utils.findallmodules("modules/blueprint"):                 print module 

the code searches files within folder:

def findallmodules(relativedirectory):     # search relative directory available modules     # return list of module names (excluding ".py" extension)     allpyfiles = findallfiles(relativedirectory, ".py")       returnmodules = []      file in allpyfiles:         if file != "__init__":             returnmodules.append(file)      return returnmodules       def findallfiles(relativedirectory, fileextension):     # search relative directory files given extension     # return list of file names, excluding file extension     import os      filedirectory = os.environ["rigging_tool_root"] + "/" + relativedirectory + "/"      allfiles = os.listdir(filedirectory)      # refine files, listing of specified file extension     returnfiles = []     f in allfiles:         splitstring = str(f).rpartition(fileextension)          if not splitstring[1] == "" , splitstring[2] == "":             returnfiles.append(splitstring[0])         print returnfiles 

when add code within main breaks

  module in utils.findallmodules("modules/blueprint"): 

also within __init__ file search code if add bottom code error

returnmodules = []  file in allpyfiles:     if file != "__init__":         returnmodules.append(file)  return returnmodules 

i'm not sure how getting nonetype error because bottom 2 codes correct me can please?

change print returnfiles return returnfiles.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -