| Tor Norbye | 3a2425a | 2013-11-04 10:16:08 -0800 | [diff] [blame^] | 1 | #!/usr/bin/python |
| 2 | ''' |
| 3 | @author Radim Kubacki |
| 4 | ''' |
| 5 | import importsTipper |
| 6 | import traceback |
| 7 | import StringIO |
| 8 | import sys |
| 9 | import urllib |
| 10 | import pycompletionserver |
| 11 | |
| 12 | |
| 13 | #======================================================================================================================= |
| 14 | # GetImports |
| 15 | #======================================================================================================================= |
| 16 | def GetImports(module_name): |
| 17 | try: |
| 18 | processor = pycompletionserver.Processor() |
| 19 | data = urllib.unquote_plus(module_name) |
| 20 | def_file, completions = importsTipper.GenerateTip(data) |
| 21 | return processor.formatCompletionMessage(def_file, completions) |
| 22 | except: |
| 23 | s = StringIO.StringIO() |
| 24 | exc_info = sys.exc_info() |
| 25 | |
| 26 | traceback.print_exception(exc_info[0], exc_info[1], exc_info[2], limit=None, file=s) |
| 27 | err = s.getvalue() |
| 28 | pycompletionserver.dbg('Received error: ' + str(err), pycompletionserver.ERROR) |
| 29 | raise |
| 30 | |
| 31 | |
| 32 | #======================================================================================================================= |
| 33 | # main |
| 34 | #======================================================================================================================= |
| 35 | if __name__ == '__main__': |
| 36 | mod_name = sys.argv[1] |
| 37 | |
| 38 | print(GetImports(mod_name)) |
| 39 | |