Show More
@@ -1,34 +1,42 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | """ |
|
3 | 3 | Add %p4 magic for pythonic p4 (Perforce) usage. |
|
4 | 4 | """ |
|
5 | 5 | |
|
6 | 6 | import IPython.ipapi |
|
7 | 7 | ip = IPython.ipapi.get() |
|
8 | 8 | |
|
9 | 9 | import os,sys,marshal |
|
10 | 10 | |
|
11 | 11 | import ipy_stock_completers |
|
12 | 12 | |
|
13 | 13 | def p4_f(self, parameter_s=''): |
|
14 | 14 | cmd = 'p4 -G ' + parameter_s |
|
15 | return marshal.load(os.popen(cmd)) | |
|
15 | fobj = os.popen(cmd) | |
|
16 | out = [] | |
|
17 | while 1: | |
|
18 | try: | |
|
19 | out.append(marshal.load(fobj)) | |
|
20 | except EOFError: | |
|
21 | break | |
|
22 | ||
|
23 | return out | |
|
16 | 24 | |
|
17 | 25 | ip.expose_magic('p4', p4_f) |
|
18 | 26 | |
|
19 | 27 | p4_commands = """\ |
|
20 | 28 | add admin annotate branch branches change changes changelist |
|
21 | 29 | changelists client clients counter counters delete depot depots |
|
22 | 30 | describe diff diff2 dirs edit filelog files fix fixes flush fstat |
|
23 | 31 | group groups have help info integrate integrated job jobs jobspec |
|
24 | 32 | label labels labelsync lock logger login logout monitor obliterate |
|
25 | 33 | opened passwd print protect rename reopen resolve resolved revert |
|
26 | 34 | review reviews set submit sync tag tickets triggers typemap unlock |
|
27 | 35 | user users verify workspace workspaces where""" |
|
28 | 36 | |
|
29 | 37 | def p4_completer(self,event): |
|
30 | 38 | return ipy_stock_completers.vcs_completer(p4_commands, event) |
|
31 | 39 | |
|
32 | 40 | ip.set_hook('complete_command', p4_completer, str_key = '%p4') |
|
33 | ||
|
41 | ip.set_hook('complete_command', p4_completer, str_key = 'p4') | |
|
34 | 42 |
General Comments 0
You need to be logged in to leave comments.
Login now