Matt and Aaron,

Thanks for the discussion.  With Matt's latest edit it now works on my mac.


Comer

On Mon, Aug 13, 2012 at 5:42 PM, Aaron Meurer <[email protected]> wrote:

> On Mon, Aug 13, 2012 at 11:30 AM, Matthew Rocklin <[email protected]>
> wrote:
> >> def grep_stream(location):
> >>     return os.popen(
> >>     'find %s -name "*.py" | xargs  grep -h -P "^class
> >> \w+\([\s\w,]+\)"'%location)
> >>
> >> Alas, looking at the man page for xargs it seems apparent that the -P
> >> argument is meant for xargs whereas the -h argument is meant for grep,
> >> right?  So, I moved the -P arg to just after xargs and made it have a
> '1'
> >> (otherwise xargs complains) and left the -h arg as is.
> >
> >
> > The file works on my machine without complaint. I'm unfortunately not
> very
> > familiar with unix commands. I'm not sure I'll be able to diagnose this
> > issue. I find it odd that these commands aren't machine independent.
>
> The base level command and options are specified by POSIX, but many
> operating systems add extensions which are OS dependent.  I believe -P
> is a GNU extension (see
> http://www.gnu.org/software/grep/manual/grep.html#grep-Programs, and
> compare to http://ss64.com/bash/grep.html), so won't be included in
> non-GNU grep, such as the one that comes with Mac OS X.  If you want
> to use perl extensions, I would recommend just using perl, or
> alternately, use Python's re module, which supports many of the same
> extensions.  It's not clear to me what part of your regular expression
> requires it, though.
>
> >
> >>  When I run the script it finishes without complaints. However, the
> >> mats.dot file and the mats.pdf are essentially nothing:  mats.dot is
> >>
> >> homelap-3:sympy comerduncan$ cat mats.dot
> >> strict digraph G {
> >> rankdir=LR;
> >> overlap=false;
> >> }
> >
> >
> > It looks like the find+grep combination didn't pick anything up. You
> could
> > try this command in the shell and see what you get. You should get a
> bunch
> > of strings like the following to dump to the screen
> > class Expr(Basic):
> >
> >> So,  what gives? Perhaps I am simply not using it correctly?
> >>
> >> I am running with python2.7 on my mac (Mountain Lion). All needed
> routines
> >> are installed (macports is great).
> >
> >
> > Again, my guess is that the behavior of the unix tools is slightly
> different
> > between MacOSX and Debian/Ubuntu. This surprises me. If anyone is more
> > familiar with these tools I'd be happy to swap out what I have with
> > something a bit more robust.
> >
> > I'd also be very happy if someone was able to replace this python script
> > with a pure bash one. I suspect this program can be further simplified.
>
> IMHO, a better solution would be one that uses Python to find the
> modules using Python introspection.  You can get the superclasses of a
> class using __bases__ (like Expr.__bases__).  This will handle more
> pathological cases like false positives of classes defined in a
> docstring, and false negatives of classes defined by non-standard
> means, and it will be more robust than a regular expression even for
> the normal cases.
>
> Aaron Meurer
>
> >
> >> This little script is cute and probably useful when one is trying to
> sort
> >> out the class dependencies in a given project or just in general trying
> to
> >> understand how things are hung together.
> >>
> >> Thanks for making this little tool.
> >
> >
> > Thanks for using it.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "sympy" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> > http://groups.google.com/group/sympy?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to