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
app completion in django_bash_completion - testing please
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
  5 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
 
Rob Hudson  
View profile  
 More options Feb 22 2007, 3:18 pm
From: "Rob Hudson" <treborhud...@gmail.com>
Date: Thu, 22 Feb 2007 20:18:52 -0000
Local: Thurs, Feb 22 2007 3:18 pm
Subject: app completion in django_bash_completion - testing please
I implemented app completion and would like comments and testing for
those on *nix.

What's the easiest way to provide a patch?  Open a new ticket and
attached?  Or attach it to the original bash_completion ticket here:
http://code.djangoproject.com/ticket/1240 ?  I'm pasting the diff
below so people can test for now.

A couple notes:

* My patch uses sed, grep, and tr instead of the previous patch which
uses Python.  The Python way does seem nice since Django already knows
about its own apps.  But Adrian made a comment on the ticket above
that it didn't work for him.

* Depends on settings.py being named "settings.py" and depends on the
user being in the project root directory (where settings.py is).  The
previous patch had this dependency too.

* This essentially does the following (each command):

  1. Filters settings.py and prints everything in INSTALLED_APPS
  2. Strips any lines with django in them
  3. Does pattern matching to get the app name.
  4. Finally, tr merges the separate lines into a single line with
apps separated by spaces.

It's working on my Mac.  If I type "./manage.py sql " and press tab
twice, I get a list of apps and starting to type one does tab
completion.

Comments appreciated.

-Rob

Index: extras/django_bash_completion
===================================================================
--- extras/django_bash_completion       (revision 4557)
+++ extras/django_bash_completion       (working copy)
@@ -79,10 +79,12 @@
             adminindex|install|reset| \
             sql|sqlall|sqlclear|sqlindexes| \
             sqlinitialdata|sqlreset|sqlsequencereset)
-            # App completion isn't yet implemented, but here's where
that
-            # would go.
-            # COMPREPLY=( $(compgen -W "auth core" -- ${cur}) )
-            COMPREPLY=()
+            # App completion
+            apps=`sed -n '/INSTALLED_APPS = (/,/)/p' settings.py | \
+                  grep -v django |
+                  sed -n "s/^[ ]*'.*\.\(.*\)'.*$/\1 /pg" | \
+                  tr -d '\n'`
+            COMPREPLY=( $(compgen -W "${apps}" -- ${cur}) )
             return 0
             ;;


 
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.
Rob Hudson  
View profile  
 More options Feb 23 2007, 12:04 pm
From: "Rob Hudson" <treborhud...@gmail.com>
Date: Fri, 23 Feb 2007 17:04:11 -0000
Local: Fri, Feb 23 2007 12:04 pm
Subject: Re: app completion in django_bash_completion - testing please
I re-opened bug 1240 and added my patch there:
http://code.djangoproject.com/ticket/1240

 
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.
Simon G.  
View profile  
 More options Feb 24 2007, 6:28 am
From: "Simon G." <d...@simon.net.nz>
Date: Sat, 24 Feb 2007 03:28:09 -0800
Local: Sat, Feb 24 2007 6:28 am
Subject: Re: app completion in django_bash_completion - testing please
Hi Rob,

This looks good, thanks. I've triage'd that ticket on to "Ready to
checkin" and we'll let one of the core developers check it out and see
if it meets their approval :-)

-Simon G.

On Feb 24, 6:04 am, "Rob Hudson" <treborhud...@gmail.com> wrote:


 
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.
paolo  
View profile  
 More options Feb 24 2007, 7:48 am
From: "paolo" <paolop...@gmail.com>
Date: Sat, 24 Feb 2007 04:48:24 -0800
Local: Sat, Feb 24 2007 7:48 am
Subject: Re: app completion in django_bash_completion - testing please
Hi Rob, your patch works pretty well, thanks! Finally the script
supports full completion of names ;-)

Just a couple of things.

I'd like to change the "grep -v django" line with "grep -v
django.contrib" so that applications containing "django" as a part of
their name (ex. djangotestproject.appname) are not discarded.

Then I'd like that completion script would support names as 'appname'
instead of 'projectname.appname'. I got this work for myself using
s/^[ ]*'\(.*\.\)*\(.*\)'.*$/\2 /pg as regular expression in sed.

Regards


 
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.
Rob Hudson  
View profile  
 More options Feb 24 2007, 12:57 pm
From: "Rob Hudson" <treborhud...@gmail.com>
Date: Sat, 24 Feb 2007 09:57:03 -0800
Local: Sat, Feb 24 2007 12:57 pm
Subject: Re: app completion in django_bash_completion - testing please
This morning I'm working on a few things with this...

> I'd like to change the "grep -v django" line with "grep -v
> django.contrib" so that applications containing "django" as a part of
> their name (ex. djangotestproject.appname) are not discarded.

Good point, I'll add it in to the next patch.

> Then I'd like that completion script would support names as 'appname'
> instead of 'projectname.appname'. I got this work for myself using
> s/^[ ]*'\(.*\.\)*\(.*\)'.*$/\2 /pg as regular expression in sed.

Right, another good point.  I added in support for stuff after the
closing quote because in our settings.py we usually set PROJECT_NAME
near the top and re-use it in our script, so our installed apps look
like this:

  '%s.appname' % PROJECT_NAME,

And this supports that.  I'll update it to support just 'appname' as
well.

I'm also adding checks for the environment variable
DJANGO_SETTINGS_MODULE so this doesn't have to be in the same
directory to work.

I'll post an updated patch.

Thanks,
Rob


 
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 »