Please Read our FAQ
kody@marsplanet:~$ nautilus-pyextensionsTraceback (most recent call last): File "/usr/bin/nautilus-pyextensions", line 370, in <module> if __name__ == "__main__": main() File "/usr/bin/nautilus-pyextensions", line 365, in main store = InfoModel() File "/usr/bin/nautilus-pyextensions", line 46, in __init__ icon_path = self.get_icon_path(self.get_icon_name(pyextension_path)) File "/usr/bin/nautilus-pyextensions", line 85, in get_icon_name return match.group(0)AttributeError: 'NoneType' object has no attribute 'group'kody@marsplanet:~$
def get_icon_name(self, pyextension_path): """Returns the name of the icon associated to the given pyextension""" pyextension_file = open(pyextension_path, 'r') pyextension_file_string = pyextension_file.read() pyextension_file.close() # regular expression: search for a string preceeded by "'NautilusPython::" and followed by "'" match = re.search("(?<='NautilusPython::).*?(?=')", pyextension_file_string) if match == None: match = re.search('(?<="NautilusPython::).*?(?=")', pyextension_file_string) if match: return match.group(0) return None def get_icon_path(self, icon_name): """Returns the path of the icon from the icon name""" try: for dirpath, dirnames, filenames in os.walk('/usr/share/icons/hicolor'): for filename in filenames: if os.path.splitext(filename)[0] == icon_name: print "Found: ", icon_name return os.path.join(dirpath, filename) for dirpath, dirnames, filenames in os.walk('/usr/share/icons/gnome'): for filename in filenames: if os.path.splitext(filename)[0] == icon_name: print "Found: ", icon_name return os.path.join(dirpath, filename) except: return None
kody@marsplanet:~/untitled/nautilus-pyextensions_0.2$ ./nautilus-pyextensionsFound: terminalFound: gtk-copyFound: preferences-desktop-wallpaper./nautilus-pyextensions:150: GtkWarning: Theme directory 32x32/emotexs of theme Aqua-Glade_PNG has no size field self.window.show_all()
icon_path = self.get_icon_path(self.get_icon_name(pyextension_path))
match = re.search('(?<="NautilusPython::).*?(?=")', pyextension_file_string) return match.group(0)
def get_icon_name(self, pyextension_path): """Returns the name of the icon associated to the given pyextension""" pyextension_file = open(pyextension_path, 'r') pyextension_file_string = pyextension_file.read() pyextension_file.close() # regular expression: search for a string preceeded by "'NautilusPython::" and followed by "'" match = re.search("(?<=['\"]NautilusPython::).*?(?=['\"])", pyextension_file_string) return match.group(0) if match else None def get_icon_path(self, icon_name): """Returns the path of the icon from the icon name""" for dirpath, dirnames, filenames in os.walk('/usr/share/icons/hicolor'): for filename in filenames: if os.path.splitext(filename)[0] == icon_name: return os.path.join(dirpath, filename) for dirpath, dirnames, filenames in os.walk('/usr/share/icons/gnome'): for filename in filenames: if os.path.splitext(filename)[0] == icon_name: return os.path.join(dirpath, filename) return None