Re: [Pythonmac-SIG] HFS versus POSIX paths (changed from fixing the documentation)
On Apr 21, 2006, at 3:06, has wrote: > Daniel Lord wrote: > >> I am writing an app combining excel and python/appscript to fetch >> quotes from the web and value stock portfolios . >> But I give up on using appscript with Excel--some things just >> don't work because I think the terminology is seriously warped if >> no broken. Applescriptworks but appscript doesn't. > > Please send examples of where breakage occurs so I can figure out why. I'll get around to this in a little while--I kind of shelved that project after I got tired of using hacks to bring Excel 'to heel' > >> I instead build a text Applescript from strings and use popen2 to >> invoke osascript like this example which reads in the stock >> symbols from a named range in an excel spreadsheet: > > The osax module provides a runscript() function that's easier to > use if you're just wanting to pass in parameters. (It's a simple > wrapper around Standard Additions' 'run script' command.) > > Or I can supply a rough version of osawrapper, which is a high- > level wrapper around CarbonX.OSA; gives you much more power/ > flexibility when using AS from Python. Just ask. Sure. Maybe I'll see if I can improve on it given you said it was rough. I need to learn a lot more about OSA, AE, etc. first though. Daniel ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] HFS versus POSIX paths (changed from fixing the documentation)
Daniel Lord wrote: >I am writing an app combining excel and python/appscript to fetch quotes from >the web and value stock portfolios . >But I give up on using appscript with Excel--some things just don't work >because I think the terminology is seriously warped if no broken. >Applescriptworks but appscript doesn't. Please send examples of where breakage occurs so I can figure out why. >I instead build a text Applescript from strings and use popen2 to invoke >osascript like this example which reads in the stock symbols from a named >range in an excel spreadsheet: The osax module provides a runscript() function that's easier to use if you're just wanting to pass in parameters. (It's a simple wrapper around Standard Additions' 'run script' command.) Or I can supply a rough version of osawrapper, which is a high-level wrapper around CarbonX.OSA; gives you much more power/flexibility when using AS from Python. Just ask. HTH has -- http://freespace.virgin.net/hamish.sanderson/ ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
[Pythonmac-SIG] HFS versus POSIX paths (changed from fixing the documentation)
I changed the topic so many can avoid it and we don't bore them to tears ;-)On Apr 20, 2006, at 2:02, has wrote:As for working with HFS paths (and a pox on scriptable apps that require them, btw, because they're fundamentally unreliable), you ought to be able to use Carbon.CF to translate between POSIX/Windows/HFS path styles. Unfortunately, I suspect getting in and out of there may be one of the areas that's broken.I am writing an app combining excel and python/appscript to fetch quotes from the web and value stock portfolios . But I give up on using appscript with Excel--some things just don't work because I think the terminology is seriously warped if no broken. Applescriptworks but appscript doesn't.I instead build a text Applescript from strings and use popen2 to invoke osascript like this example which reads in the stock symbols from a named range in an excel spreadsheet: def readSymbolList(self, workbook, worksheet, range): _getSymbolsScript = """tell app "Microsoft Excel" return Value of Range "%s" of Worksheet "%s" of Workbook "%s" end tell""" # read symbols from spreadsheet cout, cin = popen2.popen2( "/usr/bin/osascript -e \'%s\'" % \ (_getSymbolsScript % (range, worksheet, workbook))) symbols = cout.readline()[:-1] symbols = re.sub(",\s",",",symbols) if (self.DEBUG): print __module__, "::","symbols=", repr(symbols) # create symbolList symbolList = [] symbols = string.split(symbols, ",") if (self.DEBUG): print __module__, "::","stocks=", repr(symbols) for symbol in symbols: if (symbol != '0'): symbolList.append(symbol) cout.close() cin.close() return symbolList I wouldn't mind adding a makewithhfspath class method and hfspath instance method to macfile's Alias and File classes, but I'd want to be sure I had a correct implementation first, however, as it's not quite as trivial as it sounds on the surface (e.g. volume names are not a direct translation in either direction). If you really desire to you can but I just wrote a quick hack using re.sub() that correctly converts the paths I use so my needs are met.Daniel___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig