Changeset 3246 for trunk/makeTutorial.py


Ignore:
Timestamp:
Jan 28, 2018 8:56:19 PM (5 years ago)
Author:
toby
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/makeTutorial.py

    r3236 r3246  
    1919from __future__ import print_function
    2020import os
     21import GSASIIpath
    2122
    22 import GSASIIpath
    23 GSASIIpath.SetBinaryPath()
    24 import GSASIIctrlGUI as G2G
    25 G2BaseURL = G2G.G2BaseURL
    26 tutorialIndex = G2G.tutorialIndex
    27 tutURL = G2BaseURL +'/Tutorials'
    28 outname = os.path.join(GSASIIpath.path2GSAS2,'help','Tutorials.html')
     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')
    2930
    30 dirList = [l[0] for l in tutorialIndex if len(l) == 3]
     31    dirList = [l[0] for l in tutorialIndex if len(l) == 3]
    3132
    32 # loop through directories in Tutorials repository
    33 dirs = [d[:-1] for d in GSASIIpath.svnList(tutURL,False).split('\n') if d and d[-1] == '/']   
    34 for d in dirs:
    35     if d not in dirList: print(u"makeTutorial: Listed tutorial is missing: "+d)
     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)
    3637
    37 #import sys
    38 #out = sys.stdout
    39 out = open(outname,'w')
    40 print('<!-- Do not edit this file. It is created by makeTutorial.py from info in GSASIIctrlGUI.py --!>',file=out)
    41 print('<h2>List of GSAS-II tutorials</H2><UL>',file=out)
    42 print('''
    43 <p> A list of available tutorials appears below. Each tutorial is a
    44 web page that can be opened using the link below, but most tutorials also need
    45 to have example data files downloaded. This can also be done with links included below,
    46 but it can be easier to access tutorials using
    47 <b>Help/Tutorials</b> menu item.
    48 When this menu entry is used from inside GSAS-II (unless "browse tutorial on web" is selected),
    49 the data files are downloaded to a local directory and GSAS-II will start from that directory
    50 for most file open commands.
    51 </p>''',file=out)
     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)
    5253
    53 for 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)
     54    for l in tutorialIndex:
     55        if len(l) == 1:
     56            print("</UL><h4>{}</H4><UL>".format(l[0]),file=out)
    6457        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)
     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)
    7467
    75 print('</UL>\n<A name=prereq>* Indented tutorials require the previous unindented tutorial as a prerequisite',file=out)
    76 out.close()
     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 TracChangeset for help on using the changeset viewer.