Merge lp:~maddevelopers/mg5amcnlo/path_completion into lp:~madteam/mg5amcnlo/trunk

Proposed by Olivier Mattelaer
Status: Merged
Merge reported by: Olivier Mattelaer
Merged at revision: not available
Proposed branch: lp:~maddevelopers/mg5amcnlo/path_completion
Merge into: lp:~madteam/mg5amcnlo/trunk
Diff against target: 70 lines (+17/-10)
1 file modified
madgraph/interface/cmd_interface.py (+17/-10)
To merge this branch: bzr merge lp:~maddevelopers/mg5amcnlo/path_completion
Reviewer Review Type Date Requested Status
Johan Alwall (community) Approve
Review via email: mp+49802@code.launchpad.net

Description of the change

change the path completion which was not working before (at least on my mac)

for example in
import model
or in
history

This is not a blokker so I propose to merge it in the trunk but not creating a release for this very minor point.

To post a comment you must log in.
Revision history for this message
Johan Alwall (johan-alwall) wrote :

I did bin/mg5 and tried
import model ./<tab>
and got
./heft ./mssm ./sm ./triplet_diquarks ./uutt_sch_4fermion ./uutt_tch_4fermion
./uutt_tch_scalar ./sextet_diquarks
which is not what I would have expected - I would expect ./ to mean "this directory", i.e., the mg5 root directory in this case. Is that the behavior you had planned?

review: Needs Information
79. By Olivier Mattelaer

fix also import model (the fix for history didn't fix it for import model)

Revision history for this message
Olivier Mattelaer (olivier-mattelaer) wrote :

Thanks this is corrected.

Revision history for this message
Johan Alwall (johan-alwall) wrote :

Great job Olivier, this works fine now. In the long run, since we keep coming back to the completion issues, we (meaning you of course ;-)) should probably create some tests for it.

Johan

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'madgraph/interface/cmd_interface.py'
2--- madgraph/interface/cmd_interface.py 2011-01-27 12:30:18 +0000
3+++ madgraph/interface/cmd_interface.py 2011-03-02 22:48:27 +0000
4@@ -984,16 +984,22 @@
5
6 if base_dir is None:
7 base_dir = os.getcwd()
8+
9+ prefix, text = os.path.split(text)
10+ base_dir = os.path.join(base_dir, prefix)
11+ if prefix:
12+ prefix += os.path.sep
13+
14
15 if only_dirs:
16- completion = [f
17+ completion = [prefix + f
18 for f in os.listdir(base_dir)
19 if f.startswith(text) and \
20 os.path.isdir(os.path.join(base_dir, f)) and \
21 (not f.startswith('.') or text.startswith('.'))
22 ]
23 else:
24- completion = [f
25+ completion = [ prefix + f
26 for f in os.listdir(base_dir)
27 if f.startswith(text) and \
28 os.path.isfile(os.path.join(base_dir, f)) and \
29@@ -1001,15 +1007,15 @@
30 ]
31
32 completion = completion + \
33- [f + os.path.sep
34+ [prefix + f + os.path.sep
35 for f in os.listdir(base_dir)
36 if f.startswith(text) and \
37 os.path.isdir(os.path.join(base_dir, f)) and \
38 (not f.startswith('.') or text.startswith('.'))
39 ]
40
41- completion += [f for f in ['.'+os.path.sep, '..'+os.path.sep] if \
42- f.startswith(text)]
43+ completion += [prefix + f for f in ['.'+os.path.sep, '..'+os.path.sep] if \
44+ f.startswith(text) and not prefix.startswith('.')]
45
46 return completion
47
48@@ -1265,16 +1271,17 @@
49 return self.list_completion(text, self._import_formats)
50
51 # Directory continuation
52- if args[-1].endswith(os.path.sep):
53+ if os.path.sep in args[-1] + text:
54 if args[1].startswith('model'):
55- return self.path_completion(text,
56- os.path.join('.',*[a for a in args if \
57- a.endswith(os.path.sep)]),
58- only_dirs = True)
59+ # Directory continuation
60+ return self.path_completion(text, os.path.join('.',*[a for a in args \
61+ if a.endswith(os.path.sep)]),
62+ only_dirs = True)
63 else:
64 return self.path_completion(text,
65 os.path.join('.',*[a for a in args if \
66 a.endswith(os.path.sep)]))
67+
68 # Model directory name if directory is not given
69 if len(split_arg(line[0:begidx])) == 2:
70 if args[1] == 'model':

Subscribers

People subscribed via source and target branches