38.1. gensuitemodule — Generate OSA stub packages - Python 2.7.18 documentation 编辑

The gensuitemodule module creates a Python package implementing stub code for the AppleScript suites that are implemented by a specific application, according to its AppleScript dictionary.

It is usually invoked by the user through the PythonIDE, but it can also be run as a script from the command line (pass --help for help on the options) or imported from Python code. For an example of its use see Mac/scripts/genallsuites.py in a source distribution, which generates the stub packages that are included in the standard library.

It defines the following public functions:

gensuitemodule.is_scriptable(application)

Returns true if application, which should be passed as a pathname, appears to be scriptable. Take the return value with a grain of salt: Internet Explorer appears not to be scriptable but definitely is.

gensuitemodule.processfile(application[, output, basepkgname, edit_modnames, creatorsignature, dump, verbose])

Create a stub package for application, which should be passed as a full pathname. For a .app bundle this is the pathname to the bundle, not to the executable inside the bundle; for an unbundled CFM application you pass the filename of the application binary.

This function asks the application for its OSA terminology resources, decodes these resources and uses the resultant data to create the Python code for the package implementing the client stubs.

output is the pathname where the resulting package is stored, if not specified a standard “save file as” dialog is presented to the user. basepkgname is the base package on which this package will build, and defaults to StdSuites. Only when generating StdSuites itself do you need to specify this. edit_modnames is a dictionary that can be used to change modulenames that are too ugly after name mangling. creator_signature can be used to override the 4-char creator code, which is normally obtained from the PkgInfo file in the package or from the CFM file creator signature. When dump is given it should refer to a file object, and processfile will stop after decoding the resources and dump the Python representation of the terminology resources to this file. verbose should also be a file object, and specifying it will cause processfile to tell you what it is doing.

gensuitemodule.processfile_fromresource(application[, output, basepkgname, edit_modnames, creatorsignature, dump, verbose])

This function does the same as processfile, except that it uses a different method to get the terminology resources. It opens application as a resource file and reads all "aete" and "aeut" resources from this file.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:61 次

字数:3198

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文