Merge lp:~barry/quickly/585617-userdirs into lp:quickly

Proposed by Barry Warsaw
Status: Merged
Merged at revision: 521
Proposed branch: lp:~barry/quickly/585617-userdirs
Merge into: lp:quickly
Diff against target: 47 lines (+22/-6)
2 files modified
quickly.1 (+14/-4)
quickly/tools.py (+8/-2)
To merge this branch: bzr merge lp:~barry/quickly/585617-userdirs
Reviewer Review Type Date Requested Status
Didier Roche-Tolomelli Approve
John C Barstow (community) Approve
Review via email: mp+26000@code.launchpad.net

Description of the change

Add support for $QUICKLY_TEMPLATES environment variable for user defined template directories.

To post a comment you must log in.
Revision history for this message
John C Barstow (jbowtie) wrote :

This looks like a reasonable implementation. I would be happier if there was some documentation included as part of the patch.

Revision history for this message
Barry Warsaw (barry) wrote :

Good point. It's not beautiful (manpages are not my favorite thing to write :), but here's an updated quickly.1 that documents $QUICKLY_TEMPLATES

r509

lp:~barry/quickly/585617-userdirs updated
509. By Barry Warsaw

Add an ENVIRONMENT section describing $QUICKLY and $QUICKLY_TEMPLATES

Revision history for this message
John C Barstow (jbowtie) wrote :

Looks good to me. Hopefully Didier and Rick agree.

review: Approve
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

For a more generic approach (in any case, I'll merge it next week as I want to branch 0.4.3 first and this will land in 0.6), can you remove my two lines:
     if os.path.exists(os.path.expanduser('~/quickly-templates')):
          template_directories.append(os.path.expanduser('~/quickly-templates'))

and prepend QUICKLY_TEMPLATE by ~/quickly-template please? (just to have a common template path detection code). If you don't have the time to do it, I'll do it when merging :)

Thanks a lot Barry!

review: Needs Fixing
Revision history for this message
Barry Warsaw (barry) wrote :

Hi Didier, sorry I don't quite understand. Do you mean you want to remove the hardcoding of ~/quickly-templates and just let the environment variable define it? I'm not sure what you mean by "prepend QUICKLY_TEMPLATE by ~/quickly-template"; do you intend for there to be no user-specific template path unless they modify their environment?

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

No, just remove:
32 if os.path.exists(os.path.expanduser('~/quickly-templates')):
33 template_directories.append(os.path.expanduser('~/quickly-templates'))

And replace:
36 + user_paths = os.environ.get('QUICKLY_TEMPLATES')
37 + if user_paths is not None:

by:
user_paths = os.environ.get('QUICKLY_TEMPLATES')
user_paths = '~/quickly-templates:' + user_paths

so that the code to insert an template template path is common.

lp:~barry/quickly/585617-userdirs updated
510. By Barry Warsaw

As per comment on merge proposal, use a common path for adding
~/quickly-templates

Revision history for this message
Barry Warsaw (barry) wrote :

On May 28, 2010, at 06:47 AM, Didier Roche wrote:

>No, just remove:
>32 if os.path.exists(os.path.expanduser('~/quickly-templates')):
>33 template_directories.append(os.path.expanduser('~/quickly-templates'))
>
>And replace:
>36 + user_paths = os.environ.get('QUICKLY_TEMPLATES')
>37 + if user_paths is not None:
>
>by:
>user_paths = os.environ.get('QUICKLY_TEMPLATES')
>user_paths = '~/quickly-templates:' + user_paths
>
>so that the code to insert an template template path is common.

I see now, thanks. r510 in my branch has a slightly modified approach.

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

Sweet, I'll merge in 0.5.X branch as soon as 0.4.3 is out!
Thanks a lot Barry

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'quickly.1'
2--- quickly.1 2010-02-18 16:04:34 +0000
3+++ quickly.1 2010-05-28 17:28:31 +0000
4@@ -90,8 +90,18 @@
5 Get some help on a command. If no template is provided and you are outside any quickly project, you are only able to get some help from builtin commands.
6 If you specify a template (or use quickly help -t template command, or you are in a quickly project directory), you will get some help from the current template context.
7
8-.SH NOTES
9-\fBQUICKLY\fP environment variable can contain multiple tags. The separator is \fB":"\fP.
10-.P
11-For instance: \fBQUICKLY=staging:verbose\fP
12+.SH ENVIRONMENT
13+
14+.TP
15+.B QUICKLY
16+The \fBQUICKLY\fP environment variable can contain multiple tags. The separator is \fB":"\fP.
17+
18+For example: \fBQUICKLY=staging:verbose\fP
19+
20+.TP
21+.B QUICKLY_TEMPLATES
22+This variable contains additional template paths, separated by \fB":"\fP much
23+like the \fBPATH\fP environment variable.
24+
25+E.g.: \fBQUICKLY_TEMPLATES=/home/foo/.quickly/templates:/home/foo/projects/mynewtemplate\fP
26
27
28=== modified file 'quickly/tools.py'
29--- quickly/tools.py 2010-03-28 17:45:12 +0000
30+++ quickly/tools.py 2010-05-28 17:28:31 +0000
31@@ -95,8 +95,14 @@
32 # default to looking up templates in the current dir
33 invalid_data_path = None
34 template_directories = []
35- if os.path.exists(os.path.expanduser('~/quickly-templates')):
36- template_directories.append(os.path.expanduser('~/quickly-templates'))
37+
38+ # Add user defined, and hard-coded template directories.
39+ user_paths = os.environ.get('QUICKLY_TEMPLATES', '').split(':')
40+ user_paths.insert(0, '~/quickly-templates')
41+ for path in user_paths:
42+ path = os.path.expanduser(path)
43+ if os.path.exists(path):
44+ template_directories.append(path)
45
46 # retrieve from trunk or installed version
47 try:

Subscribers

People subscribed via source and target branches