1 | # create an HTML page from the tutorials in GSASIIctrlGUI.tutorialCatalog |
---|
2 | |
---|
3 | from __future__ import print_function |
---|
4 | import os |
---|
5 | |
---|
6 | import GSASIIpath |
---|
7 | GSASIIpath.SetBinaryPath() |
---|
8 | import GSASIIctrlGUI as G2G |
---|
9 | G2BaseURL = G2G.G2BaseURL |
---|
10 | tutorialIndex = G2G.tutorialIndex |
---|
11 | tutURL = G2BaseURL +'/Tutorials' |
---|
12 | outname = os.path.join(GSASIIpath.path2GSAS2,'help','Tutorials.html') |
---|
13 | |
---|
14 | dirList = [l[0] for l in tutorialIndex if len(l) == 3] |
---|
15 | |
---|
16 | # loop through directories in Tutorials repository |
---|
17 | dirs = [d[:-1] for d in GSASIIpath.svnList(tutURL,False).split('\n') if d and d[-1] == '/'] |
---|
18 | for d in dirs: |
---|
19 | if d not in dirList: print(u"missing: "+d) |
---|
20 | |
---|
21 | #import sys |
---|
22 | #out = sys.stdout |
---|
23 | out = open(outname,'w') |
---|
24 | print('<!-- Do not edit this file. It is created by makeTutorial.py from info in GSASIIctrlGUI.py --!>',file=out) |
---|
25 | print('<h2>List of GSAS-II tutorials</H2><UL>',file=out) |
---|
26 | print(''' |
---|
27 | <p> A list of available tutorials appears below. Each tutorial is a |
---|
28 | web page that can be opened using the link below, but most tutorials also need |
---|
29 | to have example data files downloaded. This can also be done with links included below, |
---|
30 | but it can be easier to access tutorials using |
---|
31 | <b>Help/Tutorials</b> menu item. |
---|
32 | When this menu entry is used from inside GSAS-II (unless "browse tutorial on web" is selected), |
---|
33 | the data files are downloaded to a local directory and GSAS-II will start from that directory |
---|
34 | for most file open commands. |
---|
35 | </p>''',file=out) |
---|
36 | |
---|
37 | for 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 | |
---|
59 | print('</UL>\n<A name=prereq>* Indented tutorials require the previous unindented tutorial as a prerequisite',file=out) |
---|
60 | out.close() |
---|