1 | # -*- coding: utf-8 -*- |
---|
2 | #makeTutorial.py |
---|
3 | ########### SVN repository information ################### |
---|
4 | # $Date: 2023-05-11 23:08:12 +0000 (Thu, 11 May 2023) $ |
---|
5 | # $Author: vondreele $ |
---|
6 | # $Revision: 5577 $ |
---|
7 | # $URL: trunk/makeTutorial.py $ |
---|
8 | # $Id: makeTutorial.py 5577 2023-05-11 23:08:12Z vondreele $ |
---|
9 | ########### SVN repository information ################### |
---|
10 | ''' |
---|
11 | ''' |
---|
12 | |
---|
13 | from __future__ import print_function |
---|
14 | import os |
---|
15 | #import requests |
---|
16 | import GSASIIpath |
---|
17 | #import GSASIIctrl as G2G |
---|
18 | onlineVideos = [] |
---|
19 | '''a list of videos that are in box.com, since I don't know |
---|
20 | how to retrieve this automatically any more. |
---|
21 | ''' |
---|
22 | |
---|
23 | if __name__ == '__main__': |
---|
24 | for url in ''' |
---|
25 | https://anl.box.com/v/CalibrationofanareadetectorinG |
---|
26 | https://anl.box.com/v/CalibrationTutorial |
---|
27 | https://anl.box.com/v/CalibrationofaTOFpowderdiffrac |
---|
28 | https://anl.box.com/v/Combinedrefinement |
---|
29 | https://anl.box.com/v/TOFcombinedXNRietveldrefinemen |
---|
30 | https://anl.box.com/v/NeutronCWPowderData |
---|
31 | https://anl.box.com/v/FindProfParamCW |
---|
32 | https://anl.box.com/v/DeterminingWavelength |
---|
33 | https://anl.box.com/v/FitPeaks---- |
---|
34 | https://anl.box.com/v/LaboratoryX- |
---|
35 | https://anl.box.com/v/FittingSmallAngleScatteringDat |
---|
36 | https://anl.box.com/v/FitBkgTut--- |
---|
37 | https://anl.box.com/v/SmallAngleImageProcessing |
---|
38 | https://anl.box.com/v/Integrationofareadetectordatai |
---|
39 | https://anl.box.com/v/MerohedraltwinrefinementinGSAS |
---|
40 | https://anl.box.com/v/ParametricFitting |
---|
41 | https://anl.box.com/v/SequentialRefinementofSmallAng |
---|
42 | https://anl.box.com/v/SequentialTutorial |
---|
43 | https://anl.box.com/v/SimpleMagnetic |
---|
44 | https://anl.box.com/v/SimTutorial- |
---|
45 | https://anl.box.com/v/SmallAngleSizeDistribution |
---|
46 | https://anl.box.com/v/StackingFaults-I |
---|
47 | https://anl.box.com/v/StartingGSAS |
---|
48 | https://anl.box.com/v/Strainfittingof2DdatainGSAS-II |
---|
49 | https://anl.box.com/v/Textureanalysisof2DdatainGSAS- |
---|
50 | https://anl.box.com/v/TOFSequentialSinglePeakFit |
---|
51 | https://anl.box.com/v/RigidBodyRef |
---|
52 | '''.split(): onlineVideos.append(url) |
---|
53 | |
---|
54 | GSASIIpath.SetBinaryPath() |
---|
55 | import GSASIIctrlGUI as G2G |
---|
56 | G2BaseURL = G2G.G2BaseURL |
---|
57 | tutorialIndex = G2G.tutorialIndex |
---|
58 | tutURL = G2BaseURL +'/Tutorials' |
---|
59 | outname = os.path.join(GSASIIpath.path2GSAS2,'help','Tutorials.html') |
---|
60 | |
---|
61 | dirList = [l[0] for l in tutorialIndex if len(l) >= 3] |
---|
62 | |
---|
63 | # loop through directories in Tutorials repository |
---|
64 | dirs = [d[:-1] for d in GSASIIpath.svnList(tutURL,False).split('\n') if d and d[-1] == '/'] |
---|
65 | for d in dirs: |
---|
66 | if d not in dirList: print(u"Tutorial directory not in GSASIIctrlGUI.tutorialIndex: "+d) |
---|
67 | |
---|
68 | #import sys |
---|
69 | #out = sys.stdout |
---|
70 | out = open(outname,'w') |
---|
71 | print('<!-- Do not edit this file. It is created by makeTutorial.py from info in GSASIIctrlGUI.py --!>',file=out) |
---|
72 | print('<h2>List of GSAS-II tutorials</H2><UL>',file=out) |
---|
73 | print(''' |
---|
74 | <p> A list of available tutorials appears below. Each tutorial is a |
---|
75 | web page that can be opened using the link below, but most tutorials also need |
---|
76 | to have example data files downloaded. This can also be done with links included below, |
---|
77 | but it can be easier to access tutorials using |
---|
78 | <b>Help/Tutorials</b> menu item. |
---|
79 | When this menu entry is used from inside GSAS-II (unless "browse tutorial on web" is selected), |
---|
80 | the data files are downloaded to a local directory and GSAS-II will start from that directory |
---|
81 | for most file open commands. Most tutorials have also been recorded as videos of the computer screen |
---|
82 | along with naration. Links are provided below where videos are available. |
---|
83 | </p>''',file=out) |
---|
84 | novideo = '' |
---|
85 | videocount = 0 |
---|
86 | tutorialcount = 0 |
---|
87 | videolist = '<UL>' |
---|
88 | for l in tutorialIndex: |
---|
89 | print('.', end='', flush=True) |
---|
90 | if len(l) == 1: |
---|
91 | print("</UL><h4>{}</H4><UL>".format(l[0]),file=out) |
---|
92 | else: |
---|
93 | tutorialcount += 1 |
---|
94 | pageURL = tutURL+'/'+l[0]+'/'+l[1] |
---|
95 | dataURL = tutURL+'/'+l[0]+'/data' |
---|
96 | suffix = '' |
---|
97 | if l[2][0] == ' ': |
---|
98 | suffix = ' <A href="#prereq">*</A>' |
---|
99 | if suffix: |
---|
100 | print('<UL><LI><A href="{}">{}</A>{}'.format(pageURL,l[2].strip(),suffix),file=out) |
---|
101 | else: |
---|
102 | print('<LI><A href="{}">{}</A>'.format(pageURL,l[2].strip()),file=out) |
---|
103 | |
---|
104 | # check for video tutorial |
---|
105 | videoName = '{:-<12s}'.format( |
---|
106 | os.path.splitext(l[1])[0].replace(' ','')[:30]) |
---|
107 | vname = 'https://anl.box.com/v/{}'.format(videoName) |
---|
108 | #if requests.get(vname).status_code == 200: |
---|
109 | if vname in onlineVideos: |
---|
110 | videocount += 1 |
---|
111 | video = '<A href="{}">video</A>'.format(vname) |
---|
112 | #print(' [link: <A href="{}">video</A>]'.format(vname),file=out) |
---|
113 | #print('Found video',vname) |
---|
114 | videolist += '<LI><A href="{}">{}</A></LI>\n'.format(vname,l[2].strip()) |
---|
115 | else: |
---|
116 | video ='' |
---|
117 | novideo += '\n{:45s}{}'.format(videoName,l[2]) |
---|
118 | # check for data |
---|
119 | if GSASIIpath.svnList(dataURL,False): |
---|
120 | exampledata = '<A href="{}">Exercise files</A>'.format(dataURL) |
---|
121 | #print(' [link: <A href="{}">Exercise files</A>].'.format(dataURL),file=out) |
---|
122 | else: |
---|
123 | exampledata = '' |
---|
124 | #print(' [No exercise files].',file=out) |
---|
125 | if video and exampledata: |
---|
126 | print(' [links: {}, {}].'.format(video, exampledata),file=out) |
---|
127 | elif exampledata: |
---|
128 | print(' [link: {}].'.format(exampledata),file=out) |
---|
129 | elif video: |
---|
130 | print(' [link: {}, no example data].'.format(video),file=out) |
---|
131 | else: |
---|
132 | print(' [no example data or video].',file=out) |
---|
133 | |
---|
134 | if len(l) > 3: |
---|
135 | print("<blockquote><I>"+l[3]+"</I></blockquote>",file=out) |
---|
136 | if suffix: print('</UL>',file=out) |
---|
137 | # if l[2][0] == ' ': |
---|
138 | # print(' (Note that this tutorial requires previous as prerequisite)',file=out) |
---|
139 | |
---|
140 | videolist += '</UL>\n' |
---|
141 | print('</UL>\n<A name=prereq>* Indented tutorials require the previous unindented tutorial as a prerequisite',file=out) |
---|
142 | print('<h3>Tutorials with video-recorded examples</H3>', file=out) |
---|
143 | print(videolist, file=out) |
---|
144 | print("<P>The video tutorials are also <A href=https://pan.baidu.com/s/1C1jq1amfuVmcY2n91cQcsg> mirrored in China</A></P>", |
---|
145 | file=out) |
---|
146 | out.close() |
---|
147 | print("\nTutorials without videos",novideo) |
---|
148 | |
---|
149 | print("\nStatistics: {} total tutorials, {} with videos" |
---|
150 | .format(tutorialcount,videocount)) |
---|