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