IDEs provide code completion and code analysis by actually having a backend
specific to the language the editor is set to.  Thats actually one of the
main difference between a text editor (sublime) and an IDE (eclipse).  The
editor does not just consider the text as a suite of words but as a
language and so understand what you write.

To implement such thing, you will need basically to do the job of the
python engine (minus compilation/interpreter step).  Meaning, use an ast
generator and write python specifics.

The actual parser generator used internally by the CPython implementation
is exposed in the std library under the name pgen2 (do a grep for seeing
its usage).  Because this is just a parser generator, you will need then a
way to get and manipulate the ast the parser will generate for ya.
fortunately, there is a bunch of modules that provide exactly what you need
(ast, keyword, ...) that let you go further in the code exploration.
(pgen2 and parser/ast/keyword/... are two separate things with two
different usages, dont mix them up)

Thats about python, for the softimage libraries, you're on the right way :)
--jon






2013/1/31 Alan Fregtman <alan.fregt...@gmail.com>

> I've generated autocompletions, but it seems (and kinda makes sense) that
> I cannot really know what class someone is coding for to show the methods
> filtered by that class alone, so in its current state I will autocomplete
> both global commands AND all methods. That said, for methods I put "[blabla
> class]" after them so you know which one it's for. I still think it's
> useful, but I wish it could be better.
>
> Anyone have any bright ideas for somehow knowing what class someone is
> coding for? (...because Sublime won't load Softimage's Python environment
> to actually know what is what, what with the dynamic dispatching and all.)
>
> By the way, once you tab to choose one, I autocomplete all the arguments
> as a "snippet" and you can tab through the named arguments to write your
> own variables or delete them.
>
>
>
>
> On Wed, Jan 30, 2013 at 10:56 PM, Alan Fregtman 
> <alan.fregt...@gmail.com>wrote:
>
>> Okay... Getting somewhere!
>>
>> import sysimport os.pathfrom win32com.client import makepy
>>
>> tlbs = 
>> ['/path/to/Softimage_2013_SP1/Application/bin/Converter.tlb','/path/to/Softimage_2013_SP1/Application/bin/LightRig.tlb','/path/to/Softimage_2013_SP1/Application/bin/XSIDial.tlb','/path/to/Softimage_2013_SP1/Application/bin/dotXSI_ie.tlb','/path/to/Softimage_2013_SP1/Application/bin/dsauto.tlb','/path/to/Softimage_2013_SP1/Application/bin/enums.tlb','/path/to/Softimage_2013_SP1/Application/bin/ophelper.tlb','/path/to/Softimage_2013_SP1/Application/bin/si3dobjectmodel.tlb','/path/to/Softimage_2013_SP1/Application/bin/si3dobjectmodel10.tlb','/path/to/Softimage_2013_SP1/Application/bin/siobjectmodel.tlb','/path/to/Softimage_2013_SP1/Application/bin/xsiutils.tlb']
>> for path in tlbs:
>>     baseFolder = r'/path/somewhere/to/save/pyfiles/'
>>     sys.argv = ["makepy", "-o", "%s/%s.py" % (baseFolder, 
>> os.path.basename(path).split('.')[0]), path]
>>     makepy.main()
>>
>>
>> This gets me some files I can introspect for methods and such.
>>
>>
>>
>> On Wed, Jan 30, 2013 at 10:20 PM, Alan Fregtman 
>> <alan.fregt...@gmail.com>wrote:
>>
>>> Reviving this old thread out of interest...
>>>
>>> So, with that sample code, we can introspect predefined global objects
>>> like Application and XSIUtils. That's cool, but for example, another object
>>> type like... "Parameter".... that's a class but I can't create it. I can't
>>> do win32com.client.Dispatch("Parameter") and
>>> XSIFactory.CreateObject("Parameter") won't work either.
>>>
>>> Is there any way I can somehow create the object on the fly, knowing its
>>> class type, some other way so that I can query its methods and properties?
>>>
>>>
>>> ps: Raff, could you elaborate how you AL guys got your introspection
>>> going for non-predefined globals?
>>>
>>>
>>>
>>> On Fri, Jan 4, 2013 at 6:15 AM, Andy Nicholas <a...@andynicholas.com>wrote:
>>>
>>>>  You guys should check this out. It might give you a good start...
>>>>
>>>>
>>>> http://xsisupport.com/2012/10/06/saturday-snippet-getting-a-list-of-properties-and-methods-with-python-introspection/
>>>>
>>>>
>>>>
>>>> On 04 January 2013 at 00:54 jo benayoun <jobenay...@gmail.com> wrote:
>>>>
>>>>
>>>> > The Softimage API (object model) is not visible because its all about
>>>> dynamic
>>>> > dispatching at runtime.  This is like thinking your editor will be
>>>> natively
>>>> > enough smart to detect attributes you would add dynamically when
>>>> overriding
>>>> > the __getattr__ method of a class.
>>>> >  Happily for us the dispatching is cached somewhere and even
>>>> introspectable by
>>>> > using the pythoncom/pywin32 API.  With a little effort and sticking
>>>> with
>>>> > python, one would have no problem in developing a plugin for this
>>>> text editor
>>>> > specially if sublime API is as convenient as it is claimed.  The
>>>> first step is
>>>> > to learn how to use correctly the pywin32 package and what it does
>>>> under the
>>>> > hood to fully understand what the 'ultimate' solution could be.
>>>> >  --jo
>>>> >
>>>> >
>>>> >
>>>> >
>>>> >
>>>> >  2013/1/3 César Sáez <cesa...@gmail.com <mailto:cesa...@gmail.com> >
>>>> >    > > You're right, sublime/any-other-editor can't see that softimage
>>>> >    > > variables.
>>>> > >    If you're using 'Application' (or any 'implicit variable' like
>>>> that) your
>>>> > > script will fail on import, sipyutils module (or your own version
>>>> of it) is
>>>> > > the way to go IMHO.
>>>> > >
>>>> > >
>>>> > >    On Thu, Jan 3, 2013 at 9:18 PM, Alan Fregtman <
>>>> alan.fregt...@gmail.com
>>>> > > <mailto:alan.fregt...@gmail.com> > wrote:
>>>> > >      > > > But it won't be able to find global XSI objects just
>>>> like that,
>>>> > >      > > > right? "Application" is defined by the axscript module,
>>>> but I
>>>> > >      > > > feel like SI internally dispatches it in a way I don't
>>>> think
>>>> > >      > > > Sublime could "see" it.
>>>> > > >
>>>> > > >
>>>> > > >
>>>> > > >      On Thu, Jan 3, 2013 at 1:40 PM, César Sáez <
>>>> cesa...@gmail.com
>>>> > > > <mailto:cesa...@gmail.com> > wrote:
>>>> > > >        > > > > You have to add your environment paths to the
>>>> 'env' tag in
>>>> > > >        > > > > your python.sublime-build config file, this way if
>>>> you have
>>>> > > >        > > > > a shortcuts module it will instrospect it.
>>>> > > > >        El 03/01/2013 17:34, "Gene Crucean" <
>>>> emailgeneonthel...@gmail.com
>>>> > > > > <mailto:emailgeneonthel...@gmail.com> > escribió:
>>>> > > > >          > > > > > Hehe I was trying to figure out the same
>>>> thing.
>>>> > > > > >
>>>> > > > > >          On Thu, Jan 3, 2013 at 8:09 AM, Alan Fregtman
>>>> > > > > > <alan.fregt...@gmail.com <mailto:alan.fregt...@gmail.com> >
>>>> wrote:
>>>> > > > > >            > > > > > > I use SublimeCodeIntel too but it's
>>>> not aware
>>>> > > > > >            > > > > > > of XSI globals like Application,
>>>> XSIUtils and
>>>> > > > > >            > > > > > > so on, so it won't introspect them.
>>>> > > > > > >            How would one hack it to be more aware of such?
>>>> > > > > > >
>>>> > > > > > >
>>>> > > > > > >
>>>> > > > > > >
>>>> > > > > > >            On Wed, Jan 2, 2013 at 9:19 PM, César Sáez
>>>> > > > > > > <cesa...@gmail.com <mailto:cesa...@gmail.com> > wrote:
>>>> > > > > > >              > > > > > > > SublimeCodeIntel does a great job
>>>> > > > > > >              > > > > > > > autocompleting python modules
>>>> and import
>>>> > > > > > >              > > > > > > > statements (via introspoction,
>>>> works with
>>>> > > > > > >              > > > > > > > your own modules too), it's not
>>>> softimage
>>>> > > > > > >              > > > > > > > specific but helps alot.
>>>> > > > > > > >
>>>> > > > > > > >              Another cool package is the SublimeLinter, it
>>>> > > > > > > > highlight potential errors in your code (IDE-like). I
>>>> have no idea
>>>> > > > > > > > how far I was from PEP8 until I start using it, now my
>>>> code is way
>>>> > > > > > > > cleaner and easy to the eyes :)
>>>> > > > > > > >
>>>> > > > > > > >
>>>> > > > > > > >
>>>> > > > > > > >              On Thu, Jan 3, 2013 at 12:22 AM, Raffaele
>>>> Fragapane
>>>> > > > > > > > <raffsxsil...@googlemail.com <mailto:
>>>> raffsxsil...@googlemail.com>
>>>> > > > > > > > > wrote:
>>>> > > > > > > >                > > > > > > > > You actually can introspect
>>>> > > > > > > >                > > > > > > > > recursively almost the
>>>> entirety of
>>>> > > > > > > >                > > > > > > > > the scripting API and
>>>> generate a
>>>> > > > > > > >                > > > > > > > > dummy set of libraries
>>>> from there.
>>>> > > > > > > >                > > > > > > > > That will offer
>>>> autocompletion in
>>>> > > > > > > >                > > > > > > > > most IDEs.
>>>> > > > > > > > >
>>>> > > > > > > > >                We've had that running here in AL for a
>>>> while
>>>> > > > > > > > > thanks to Aloys' efforts a long time ago and it's
>>>> worked without
>>>> > > > > > > > > a hitch for years.
>>>> > > > > > > > >
>>>> > > > > > > > >                On Thu, Jan 3, 2013 at 10:18 AM, Gene
>>>> Crucean
>>>> > > > > > > > > <emailgeneonthel...@gmail.com
>>>> > > > > > > > > <mailto:emailgeneonthel...@gmail.com> > wrote:
>>>> > > > > > > > >                  > > > > > > > > > It would be
>>>> completely
>>>> > > > > > > > >                  > > > > > > > > > bitchin if it
>>>> autocompleted
>>>> > > > > > > > >                  > > > > > > > > > the entire sdk...
>>>> and not
>>>> > > > > > > > >                  > > > > > > > > > just simple commonly
>>>> used
>>>> > > > > > > > >                  > > > > > > > > > snippets.
>>>> > > > > > > > > >                > > > > > > > >
>>>> > > > > > > > >
>>>> > > > > > > > >              > > > > > > >
>>>> > > > > > > >
>>>> > > > > > > >
>>>> > > > > > > >            > > > > > >
>>>> > > > > > >
>>>> > > > > > >
>>>> > > > > > >          > > > > >
>>>> > > > > >
>>>> > > > > >
>>>> > > > > >          --
>>>> > > > > >          Gene Crucean - Emmy winning - Oscar nominated VFX
>>>> Supervisor
>>>> > > > > > / iOS-OSX Developer / Filmmaker / Photographer
>>>> > > > > >          ** Freelance for hire **
>>>> > > > > >          www.genecrucean.com <http://www.genecrucean.com>
>>>> > > > > >
>>>> > > > > >          ~~ Please use my website's contact form on
>>>> > > > > > www.genecrucean.com <http://www.genecrucean.com/>  for any
>>>> personal
>>>> > > > > > emails. Thanks. I may not get them at this address. ~~
>>>> > > > > >
>>>> > > > > >
>>>> > > > > >        > > > >
>>>> > > > >
>>>> > > > >      > > >
>>>> > > >
>>>> > > >
>>>> > > >    > >
>>>> > >
>>>> > >
>>>> > >  >
>>>>
>>>>
>>>
>>
>

Reply via email to