source: trunk/makeTutorial.py @ 3344

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

add more publication plot options

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