source: trunk/makeTutorial.py @ 3135

Last change on this file since 3135 was 3135, checked in by toby, 4 years ago

create tutorials list from info in GSASIIctrlGUI.py

  • Property svn:eol-style set to native
File size: 2.4 KB
RevLine 
[3135]1# create an HTML page from the tutorials in GSASIIctrlGUI.tutorialCatalog
2
3from __future__ import print_function
4import os
5
6import GSASIIpath
7GSASIIpath.SetBinaryPath()
8import GSASIIctrlGUI as G2G
9G2BaseURL = G2G.G2BaseURL
10tutorialIndex = G2G.tutorialIndex
11tutURL = G2BaseURL +'/Tutorials'
12outname = os.path.join(GSASIIpath.path2GSAS2,'help','Tutorials.html')
13
14dirList = [l[0] for l in tutorialIndex if len(l) == 3]
15
16# loop through directories in Tutorials repository
17dirs = [d[:-1] for d in GSASIIpath.svnList(tutURL,False).split('\n') if d and d[-1] == '/']   
18for d in dirs:
19    if d not in dirList: print(u"missing: "+d)
20
21#import sys
22#out = sys.stdout
23out = open(outname,'w')
24print('<!-- Do not edit this file. It is created by makeTutorial.py from info in GSASIIctrlGUI.py --!>',file=out)
25print('<h2>List of GSAS-II tutorials</H2><UL>',file=out)
26print('''
27<p> A list of available tutorials appears below. Each tutorial is a
28web page that can be opened using the link below, but most tutorials also need
29to have example data files downloaded. This can also be done with links included below,
30but it can be easier to access tutorials using
31<b>Help/Tutorials</b> menu item.
32When this menu entry is used from inside GSAS-II (unless "browse tutorial on web" is selected),
33the data files are downloaded to a local directory and GSAS-II will start from that directory
34for most file open commands.
35</p>''',file=out)
36
37for l in tutorialIndex:
38    if len(l) == 1:
39        print("</UL><h4>{}</H4><UL>".format(l[0]),file=out)
40    else:
41        pageURL = tutURL+'/'+l[0]+'/'+l[1]
42        dataURL = tutURL+'/'+l[0]+'/data'
43        suffix = ''
44        if l[2][0] == ' ':
45            suffix = ' <A href="#prereq">*</A>'
46        if suffix: 
47            print('<UL><LI><A href="{}">{}</A>{}'.format(pageURL,l[2].strip(),suffix),file=out)
48        else:
49            print('<LI><A href="{}">{}</A>'.format(pageURL,l[2].strip()),file=out)
50           
51        if GSASIIpath.svnList(dataURL,False):
52            print(' [link: <A href="{}">Exercise files</A>].'.format(dataURL),file=out)
53        else:
54            print(' [No exercise files].',file=out)
55        if suffix: print('</UL>',file=out)
56#        if l[2][0] == ' ':
57#            print(' (Note that this tutorial requires previous as prerequisite)',file=out)
58
59print('</UL>\n<A name=prereq>* Indented tutorials require the previous unindented tutorial as a prerequisite',file=out)
60out.close()
Note: See TracBrowser for help on using the repository browser.