Changeset 153b75a in sasview for docs/sphinx-docs/build_sphinx.py


Ignore:
Timestamp:
Sep 4, 2018 11:37:06 AM (6 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, unittest-saveload
Children:
170b251
Parents:
5d43213
Message:

doc build linting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • docs/sphinx-docs/build_sphinx.py

    rdf72475 r153b75a  
    88from __future__ import print_function 
    99 
    10 import subprocess 
     10import sys 
    1111import os 
    1212from os.path import join as joinpath, abspath, dirname, isdir, exists, relpath 
    13 import sys 
    14 import fnmatch 
    1513import shutil 
     14import subprocess 
    1615import imp 
    17  
    1816from glob import glob 
    1917from distutils.dir_util import copy_tree 
     
    2119from distutils.spawn import find_executable 
    2220 
    23 from shutil import copy 
    24 from os import listdir 
    25  
    26 platform = '.%s-%s'%(get_platform(),sys.version[:3]) 
     21PLATFORM = '.%s-%s'%(get_platform(), sys.version[:3]) 
    2722 
    2823# sphinx paths 
     
    3530SASVIEW_ROOT = joinpath(SPHINX_ROOT, '..', '..') 
    3631SASVIEW_DOCS = joinpath(SPHINX_ROOT, "source") 
    37 SASVIEW_BUILD = abspath(joinpath(SASVIEW_ROOT, "build", "lib"+platform)) 
     32SASVIEW_BUILD = abspath(joinpath(SASVIEW_ROOT, "build", "lib"+PLATFORM)) 
    3833SASVIEW_MEDIA_SOURCE = joinpath(SASVIEW_ROOT, "src", "sas") 
    3934SASVIEW_DOC_TARGET = joinpath(SASVIEW_BUILD, "doc") 
     
    6560 
    6661def inplace_change(filename, old_string, new_string): 
    67 # Thanks to http://stackoverflow.com/questions/4128144/replace-string-within-file-contents 
    68         s=open(filename).read() 
    69         if old_string in s: 
    70                 print('Changing "{old_string}" to "{new_string}"'.format(**locals())) 
    71                 s=s.replace(old_string, new_string) 
    72                 f=open(filename, 'w') 
    73                 f.write(s) 
    74                 f.flush() 
    75                 f.close() 
    76         else: 
    77                 print('No occurences of "{old_string}" found.'.format(**locals())) 
     62    # Thanks to http://stackoverflow.com/questions/4128144/replace-string-within-file-contents 
     63    s = open(filename).read() 
     64    if old_string in s: 
     65        print('Changing "{old_string}" to "{new_string}"'.format(**locals())) 
     66        s = s.replace(old_string, new_string) 
     67        with open(filename, 'w') as f: 
     68            f.write(s) 
     69    else: 
     70        print('No occurences of "{old_string}" found.'.format(**locals())) 
    7871 
    7972def _remove_dir(dir_path): 
     
    241234        finally: 
    242235            fd_in.close() 
    243     with ZipFile(cache_path) as zip: 
    244         zip.extractall(destination) 
     236    with ZipFile(cache_path) as archive: 
     237        archive.extractall(destination) 
    245238 
    246239def convert_katex(): 
Note: See TracChangeset for help on using the changeset viewer.