Commits

Ville Suoranta authored 389df936b7b
Cherry pick 55f9467b977 from master to release/5.1.0

Merge pull request #268 in CASA/casa from bugfix/CAS-10739 to master * commit '010b6731fa40f8004e05fc0aaa7c662a91208fd6': add file:// fix to earlier "if", and substitute version path for "stable" Add missing path to the webbrowser call in init_docs Prefix parametrized webbrowser call regardless of platform Fix parametrized webbrowser doc call on Macs

gcwrap/python/scripts/init_docs.py

Modified
13 13 def __init__( self ):
14 14 self.local_toc = None
15 15 self.remote_toc = None
16 16 version = "casa-%d.%d.%d" % tuple(cu.version( )[:3])
17 17 self.remote_source_url = "https://casa.nrao.edu/casadocs/%s" % version
18 18 self.remote_source_url_components = urlparse(self.remote_source_url)
19 19 self.remote_toc_url = 'https://%s/PloneResource/%s/toc.xml' % (self.remote_source_url_components[1],version)
20 20
21 21 self.local_toc_url = None if casa['dirs']['doc'] is None else casa['dirs']['doc'] + '/casa.nrao.edu/casadocs/toc.xml'
22 22 self.local_start_path = "usingcasa/starting-casa.html"
23 + self.local_base = "/casadocs/%s/" % version
23 24
24 25 def __welcome( self, welcome="\nOpening packaged documentation.\n" ):
25 26 if welcome is not None:
26 27 print welcome
27 28 print "The most recent version of all CASA documentation is available online from:"
28 29 print "\thttps://casa.nrao.edu/casadocs/\n"
29 30
30 31 def __call__( self, sec=None ):
31 32 "open browser with documentation, try \"doc('toc')\""
32 33
77 78 if self.local_toc_url is not None:
78 79 self.local_toc = reduce( entry_to_dict, ET.ElementTree(file=urllib2.urlopen("file://" + self.local_toc_url)).getroot( ).getchildren( ), { } )
79 80 else:
80 81 print "local documentation tree not found..."
81 82 self.__welcome(None)
82 83 return False
83 84 if sec == 'toc':
84 85 show_toc(self.local_toc)
85 86 elif sec == 'start':
86 87 self.__welcome( )
87 - return webbrowser.open(path + "/casadocs/stable/" + self.local_start_path)
88 + return webbrowser.open("file://" + path + self.local_base + self.local_start_path)
88 89 elif self.local_toc.has_key(sec):
89 90 self.__welcome( )
90 - return webbrowser.open(path + "/casadocs/stable/" + self.local_toc[sec]['path'])
91 + return webbrowser.open("file://" + path + self.local_base + self.local_toc[sec]['path'])
91 92 else:
92 93 self.__welcome(None)
93 94 print "Sorry '%s' is not a recognized section..." % sec
94 95 print "------------------------------------------------------------------------------"
95 96 show_toc(self.local_toc)
96 97
97 98
98 99 def fetch( self ):
99 100 if casa['dirs']['doc'] is None:
100 101 print "casa['dirs']['doc'] has not been set..."

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut