From: Alex T. <al...@tw...> - 2004-09-16 22:12:12
|
At 14:46 16/09/2004 -0700, Kevin Altis wrote: >I'm glad you were able to work this out. I haven't had resourceEditor >support in findfiles previously, because usually I want to edit the >.rsrc.py files using the codeEditor to make some quick change. However, I >think it would be a good option that could be toggled on and off, so I'll >look at adding that. In the meantime, all you need to do is a simple >string check, in fact, I'm not sure why I'm not doing this in the existing >code, except maybe the current way seemed cleaner than >filename.endswith('.py) or filename.endswith('.pyw'). Well, os.path goes to all the trouble of giving us a splitext function, so it may be a good idea to use it. Some day, someone may find a file system that uses something other than "." as the separator .... > if filename.endswith('.rsrc.py'): > program = os.path.join("..", "resourceEditor", > "resourceEditor.py") > elif os.path.splitext(filename)[-1] in ['.py', '.pyw']: > ... >Obviously, you can put the additional code in to check for a >resourceEditor.pyw file, but the main thing is to just use the endswith >string method and make sure that check is done before the .py/.pyw check. You could go one step further and do name,ext = os.path.splitext(filename) if ext in ['py', 'pyw]]: if name.endswith(".rsrc") then resource editor else: code editor else: text editor (Hmmm - or get really carried away and put in a table of file types and programs to use to open them with - with a menu option to create/edit associations, and .... :) Which brings me to a real question ... why .rsrc.py rather than .rsrc ? That way you could have associated .rsrc with the resource editor in the OS. -- Alex. |