Commits

Darrell Schiebel authored 948bcb7a7aa
add banner about online documentation
No tags

gcwrap/python/scripts/init_docs.py

Modified
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 23
24 + def __welcome( self, welcome="\nOpening packaged documentation.\n" ):
25 + if welcome is not None:
26 + print welcome
27 + print "The most recent version of all CASA documentation is available online from:"
28 + print "\thttps://casa.nrao.edu/casadocs/\n"
29 +
24 30 def __call__( self, sec=None ):
25 31 "open browser with documentation, try \"doc('toc')\""
26 32
27 33 ## for now, access to the plone site is turned off
28 34 remote=False
29 35 def show_toc( toc_dict ):
30 36 width = max(len(key) for key in toc_dict.keys( ))+3
31 37 for i in sorted(toc_dict.iterkeys( )):
32 38 if "external" in toc_dict[i]['visibility']:
33 39 print "".join([i.ljust(width),toc_dict[i]['desc'].replace('\n','')])
53 59 return webbrowser.open("https://casa.nrao.edu/casadocs/stable/" + self.remote_toc[sec]['path'])
54 60 else:
55 61 print "Sorry '%s' is not a recognized section..." % sec
56 62 print "------------------------------------------------------------------------------"
57 63 show_toc(self.remote_toc)
58 64 else:
59 65 path = casa['dirs']['doc'] + "/casa.nrao.edu"
60 66 if sec is None:
61 67 homepage = "%s%s.html" % (path,self.remote_source_url_components[2])
62 68 if os.path.exists(path):
69 + self.__welcome( )
63 70 return webbrowser.open("file://" + homepage)
64 71 else:
65 72 print "local documentation tree not found..."
73 + self.__welcome(None)
66 74 return False
67 75 else:
68 76 if self.local_toc is None:
69 77 if self.local_toc_url is not None:
70 78 self.local_toc = reduce( entry_to_dict, ET.ElementTree(file=urllib2.urlopen("file://" + self.local_toc_url)).getroot( ).getchildren( ), { } )
71 79 else:
72 80 print "local documentation tree not found..."
81 + self.__welcome(None)
73 82 return False
74 83 if sec == 'toc':
75 84 show_toc(self.local_toc)
76 85 elif sec == 'start':
86 + self.__welcome( )
77 87 return webbrowser.open(path + "/casadocs/stable/" + self.local_start_path)
78 88 elif self.local_toc.has_key(sec):
89 + self.__welcome( )
79 90 return webbrowser.open(path + "/casadocs/stable/" + self.local_toc[sec]['path'])
80 91 else:
92 + self.__welcome(None)
81 93 print "Sorry '%s' is not a recognized section..." % sec
82 94 print "------------------------------------------------------------------------------"
83 95 show_toc(self.local_toc)
84 96
85 97
86 98 def fetch( self ):
87 99 if casa['dirs']['doc'] is None:
88 100 print "casa['dirs']['doc'] has not been set..."
89 101 return False
90 102 if not os.path.exists(casa['dirs']['doc']):

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

Add shortcut