source: trunk/makeTutorial.py @ 3246

Last change on this file since 3246 was 3246, checked in by toby, 5 years ago

cif export: use sig for x,x,x positions etc; column order for seq table atom positions; misc Py3 fixes

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