Esempio n. 1
0
def main():
    '''
    standard command-line processing
    '''
    import argparse
    parser = argparse.ArgumentParser(description='test nxdl2rst code')
    parser.add_argument('nxdl_file', help='name of NXDL file')
    results = parser.parse_args()
    nxdl_file = results.nxdl_file

    if not os.path.exists(nxdl_file):
        print('Cannot find %s' % nxdl_file)
        exit()

    print_rst_from_nxdl(nxdl_file)

    # if the NXDL has a subdirectory,
    # copy that subdirectory (quietly) to the pwd, such as:
    #  contributed/NXcanSAS.nxdl.xml: cp -a contributed/canSAS ./
    category = os.path.basename(os.getcwd())
    path = os.path.join('../../../../', category)
    basename = os.path.basename(nxdl_file)
    corename = basename[2:].split('.')[0]
    source = os.path.join(path, corename)
    if os.path.exists(source):
        target = os.path.join('.', corename)
        replicate(source, target)
def update(source_path, target_path):
    '''
    duplicate directory from source_path to target_path
    
    :param source_path str: source directory (NeXus definitions dir)
    :param target_path str: target directory is specified for build product
    '''
    # TODO: what about file items in target_path that are not in source_path?
    source_path = os.path.abspath(source_path)
    target_path = os.path.abspath(target_path)
    qualify_inputs(source_path, target_path)
    
    paths, files = get_source_items(REPLICATED_RESOURCES, source_path)
    local_utilities.printf('source has  %d directories   and   %d files\n', len(paths), len(files))
    
    # create all the directories / subdirectories
    for source in sorted(paths):
        relative_name = source[len(source_path):].lstrip(os.sep)
        target = standardize_name(target_path, relative_name)
        if not os.path.exists(target):
            local_utilities.printf('create directory %s\n', target)
            os.mkdir(target, os.stat(source_path).st_mode)
    # check if the files need to be updated
    for source in sorted(files):
        relative_name = source[len(source_path):].lstrip(os.sep)
        target = standardize_name(target_path, relative_name)
        if not identical(source, target):
            local_utilities.printf('update file %s\n', target)
            local_utilities.replicate(source, target)
Esempio n. 3
0
def main():
    '''
    standard command-line processing
    '''
    import argparse
    parser = argparse.ArgumentParser(description='test nxdl2rst code')
    parser.add_argument('nxdl_file', help='name of NXDL file')
    results = parser.parse_args()
    nxdl_file = results.nxdl_file

    if not os.path.exists(nxdl_file):
        print( 'Cannot find %s' % nxdl_file )
        exit()

    print_rst_from_nxdl(nxdl_file)

    # if the NXDL has a subdirectory,
    # copy that subdirectory (quietly) to the pwd, such as:
    #  contributed/NXcanSAS.nxdl.xml: cp -a contributed/canSAS ./
    category = os.path.basename(os.getcwd())
    path = os.path.join('../../../../', category)
    basename = os.path.basename(nxdl_file)
    corename = basename[2:].split('.')[0]
    source = os.path.join(path, corename)
    if os.path.exists(source):
        target = os.path.join('.', corename)
        replicate(source, target)
Esempio n. 4
0
def update(source_path, target_path):
    '''
    duplicate directory from source_path to target_path
    
    :param source_path str: source directory (NeXus definitions dir)
    :param target_path str: target directory is specified for build product
    '''
    # TODO: what about file items in target_path that are not in source_path?
    source_path = os.path.abspath(source_path)
    target_path = os.path.abspath(target_path)
    qualify_inputs(source_path, target_path)

    paths, files = get_source_items(REPLICATED_RESOURCES, source_path)
    local_utilities.printf('source has  %d directories   and   %d files\n',
                           len(paths), len(files))

    # create all the directories / subdirectories
    for source in sorted(paths):
        relative_name = source[len(source_path):].lstrip(os.sep)
        target = standardize_name(target_path, relative_name)
        if not os.path.exists(target):
            local_utilities.printf('create directory %s\n', target)
            os.mkdir(target, os.stat(source_path).st_mode)
    # check if the files need to be updated
    for source in sorted(files):
        relative_name = source[len(source_path):].lstrip(os.sep)
        target = standardize_name(target_path, relative_name)
        if not identical(source, target):
            local_utilities.printf('update file %s\n', target)
            local_utilities.replicate(source, target)