Commits
Darrell Schiebel authored 78a81c01734
1 1 | import urllib2 |
2 2 | import re |
3 3 | import webbrowser |
4 4 | |
5 5 | class __doc(object): |
6 6 | "command-line Plone help" |
7 7 | |
8 8 | def __init__( self ): |
9 9 | |
10 10 | version = "%d.%d.%d" % tuple(cu.version( )[:3]) |
11 11 | |
12 - | self.task_url = "https://casa.nrao.edu/PloneResource/casa-" + version + "/taskXml/" |
13 - | self.tool_url = "https://casa.nrao.edu/PloneResource/casa-" + version + "/toolXml/" |
14 - | self.toc_url = "https://casa.nrao.edu/casadocs/casa-" + version + "/global-task-list" |
15 - | self.start_url = "https://casa.nrao.edu/casadocs/casa-" + version |
12 + | self.__task_url = "https://casa.nrao.edu/PloneResource/casa-" + version + "/taskXml/" |
13 + | self.__tool_url = "https://casa.nrao.edu/PloneResource/casa-" + version + "/toolXml/" |
14 + | self.__toc_url = "https://casa.nrao.edu/casadocs/casa-" + version + "/global-task-list" |
15 + | self.__start_url = "https://casa.nrao.edu/casadocs/casa-" + version |
16 16 | |
17 - | self.task_prefix = "https://casa.nrao.edu/casadocs/casa-" + version + "/global-task-list/task_" |
18 - | self.tool_prefix = "https://casa.nrao.edu/casadocs/casa-" + version + "/global-tool-list/tool_" |
17 + | self.__task_prefix = "https://casa.nrao.edu/casadocs/casa-" + version + "/global-task-list/task_" |
18 + | self.__tool_prefix = "https://casa.nrao.edu/casadocs/casa-" + version + "/global-tool-list/tool_" |
19 19 | |
20 - | self.tasklist = [ ] |
21 - | self.toollist = [ ] |
20 + | self.__task_list = [ ] |
21 + | self.__tool_list = [ ] |
22 22 | |
23 23 | def __call__( self, topic=None ): |
24 24 | "open browser with documentation, try \"doc('toc')\"" |
25 25 | |
26 - | if len(self.tasklist) == 0: |
26 + | if len(self.__task_list) == 0: |
27 27 | try: |
28 - | self.tasklist = re.findall("\w+.xml", urllib2.urlopen(self.task_url).read().decode()) |
28 + | self.__task_list = re.findall("\w+.xml", urllib2.urlopen(self.__task_url).read().decode()) |
29 29 | except: |
30 - | self.tasklist = [ ] |
30 + | self.__task_list = [ ] |
31 31 | |
32 - | if len(self.toollist) == 0: |
32 + | if len(self.__tool_list) == 0: |
33 33 | try: |
34 - | self.toollist = re.findall("\w+.xml", urllib2.urlopen(self.tool_url).read().decode()) |
34 + | self.__tool_list = re.findall("\w+.xml", urllib2.urlopen(self.__tool_url).read().decode()) |
35 35 | except: |
36 - | self.toollist = [ ] |
36 + | self.__tool_list = [ ] |
37 37 | |
38 38 | if type(topic) != str or topic == "toc": |
39 - | webbrowser.open_new_tab(self.toc_url) |
39 + | webbrowser.open_new_tab(self.__toc_url) |
40 40 | elif topic == "start": |
41 - | webbrowser.open_new_tab(self.start_url) |
42 - | elif topic+'.xml' in self.tasklist: |
43 - | webbrowser.open_new_tab(self.task_prefix+topic+"/parameters") |
44 - | elif topic+'.xml' in self.toollist: |
45 - | webbrowser.open_new_tab(self.tool_prefix+topic+"/methods") |
41 + | webbrowser.open_new_tab(self.__start_url) |
42 + | elif topic+'.xml' in self.__task_list: |
43 + | webbrowser.open_new_tab(self.__task_prefix+topic+"/parameters") |
44 + | elif topic+'.xml' in self.__tool_list: |
45 + | webbrowser.open_new_tab(self.__tool_prefix+topic+"/methods") |
46 46 | else: |
47 - | webbrowser.open_new_tab(self.toc_url) |
47 + | webbrowser.open_new_tab(self.__toc_url) |
48 48 | |
49 49 | doc = __doc( ) |