source: trunk/makeTutorial.py @ 3187

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

misc docs cleanups; add 1-ID metadata reader & new config variable

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