Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
ropemacs with execfile
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Manuel Naranjo  
View profile  
 More options Oct 23 2012, 2:21 pm
From: Manuel Naranjo <naranjo.man...@gmail.com>
Date: Tue, 23 Oct 2012 11:21:57 -0700 (PDT)
Local: Tues, Oct 23 2012 2:21 pm
Subject: ropemacs with execfile

Hi there,

I'm rather new to rope and ropemacs, I have a Scons project I'm trying to
integrate with ropes so I can autocomplete while developing it from emacs.

Problem is that many of this scripts use the execfile fashion, we have a
function that will call execfile for each one of the config files we ask.
This execfile defines the local variable env to a
Scons.Environment.Environmnet(), which off course rope doesn't have a clue
how to solve.

My question would be is there a way to tell rope "if you find variable env,
and it's not defined in the code you're looking at then resolve it as
this?" I've been trying to solve this question my self for a few days all
ready but haven't found a clue, other than defining env my self when the
script starts.

Regards,
Manuel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ali Gholami Rudi  
View profile  
 More options Oct 27 2012, 12:37 am
From: Ali Gholami Rudi <aligr...@gmail.com>
Date: Sat, 27 Oct 2012 07:54:22 +0330
Local: Sat, Oct 27 2012 12:24 am
Subject: Re: ropemacs with execfile
Hi,

Manuel Naranjo <naranjo.man...@gmail.com> wrote:
> Problem is that many of this scripts use the execfile fashion, we have a
> function that will call execfile for each one of the config files we ask.
> This execfile defines the local variable env to a
> Scons.Environment.Environmnet(), which off course rope doesn't have a clue
> how to solve.

> My question would be is there a way to tell rope "if you find variable env,
> and it's not defined in the code you're looking at then resolve it as
> this?" I've been trying to solve this question my self for a few days all
> ready but haven't found a clue, other than defining env my self when the
> script starts.

Rope does not handle the execfile() function since it
is hard to analyze statistically.  The only way to make
it work, I think is adding an import statement (a "from
xyz import *" in the source scope).

        Ali


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Manuel Naranjo  
View profile  
 More options Oct 27 2012, 11:23 am
From: Manuel Naranjo <naranjo.man...@gmail.com>
Date: Sat, 27 Oct 2012 12:23:00 -0300
Subject: Re: ropemacs with execfile
Ali,

What about hacking it by hand? Where should I look for? I was thinking
having some project variables where I can tell "if you have this name of
variable, and you can't resolve it, then use this class"

Manuel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ali Gholami Rudi  
View profile  
 More options Oct 28 2012, 1:35 pm
From: Ali Gholami Rudi <aligr...@gmail.com>
Date: Sun, 28 Oct 2012 20:54:47 +0330
Local: Sun, Oct 28 2012 1:24 pm
Subject: Re: ropemacs with execfile
Hi Manuel,

Manuel Naranjo <naranjo.man...@gmail.com> wrote:
> > Rope does not handle the execfile() function since it
> > is hard to analyze statistically.  The only way to make
> > it work, I think is adding an import statement (a "from
> > xyz import *" in the source scope).

> What about hacking it by hand? Where should I look for? I was thinking
> having some project variables where I can tell "if you have this name of
> variable, and you can't resolve it, then use this class"

Have a look at the lookup() function of Scope in rope/base/pyscopes.py.
You can modify FunctionScope.get_names() to insert PyNames from other
scopes (PyNames reference PyObjects and scopes hold a dictionary from
variable names to PyNames) or you can use override FunctionScope's
lookup().

        Ali


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Manuel Naranjo  
View profile  
 More options Oct 29 2012, 10:54 am
From: Manuel Naranjo <naranjo.man...@gmail.com>
Date: Mon, 29 Oct 2012 11:54:12 -0300
Local: Mon, Oct 29 2012 10:54 am
Subject: Re: ropemacs with execfile
I figured out a way to make it work.

if 'env' not in locals():
        from SCons.Environment import Environment
        env = Environment()

I still can't figure (I know where it does it, I just don't understand
the code, or have time to go through it carefully enough), how it infers
the kind of arguments of a function that gets called from a different scope.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ali Gholami Rudi  
View profile  
 More options Oct 29 2012, 2:53 pm
From: Ali Gholami Rudi <aligr...@gmail.com>
Date: Mon, 29 Oct 2012 22:08:18 +0330
Local: Mon, Oct 29 2012 2:38 pm
Subject: Re: ropemacs with execfile

Manuel Naranjo <naranjo.man...@gmail.com> wrote:
> I figured out a way to make it work.

> if 'env' not in locals():
>    from SCons.Environment import Environment
>            env = Environment()

> I still can't figure (I know where it does it, I just don't understand
> the code, or have time to go through it carefully enough), how it infers
> the kind of arguments of a function that gets called from a different scope.

Just a short summary:

* Each reference (like python variable names) are represented as
  a PyName
* Each object (what PyNames point to) is stored as a PyObject
* A PyObject has a PyObject type which describes some of its attributes
* A Scope is just a mapping from strings to PyNames; it maps python
  references (variable names) to rope PyNames.

For instance in:

  class C(object):
      def f(self):
          pass
  c = C()

Here the name C (or equivalently the PyName mapped to C in the containing
scope) points to a class object.  In rope we usually want to know what
PyObjects a PyName points to.  Here, for instance, rope infers that
the PyName c points to a PyObject whose type is the PyObject of class C
(what C PyName points to).  The simplest way rope infers what PyNames
point to is following assignments.  For instance in your example, from:

        env = Environment()

rope infers that env can be a instance of the PyObject pointed by the
Environment PyName.  Besides assignments, rope uses follows function
calls to infer what a function returns based on its parameters and uses
static object analysis to infer the type of function parameters and the
objects inside built-in container types.

I hope this clarifies some of the internals of rope.

        Ali


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »