示例#1
0
def load_tool_elements_from_path(path, recursive, register_load_errors=False):
    return loader_directory.load_tool_elements_from_path(
        path,
        _load_exception_handler,
        recursive=recursive,
        register_load_errors=register_load_errors,
    )
示例#2
0
def load_tool_elements_from_path(path, recursive, register_load_errors=False):
    """Generator for tool XML elements on a path."""
    return loader_directory.load_tool_elements_from_path(
        path,
        _load_exception_handler,
        recursive=recursive,
        register_load_errors=register_load_errors,
    )
示例#3
0
def collect_conda_targets(path, found_tool_callback=None, conda_context=None):
    conda_targets = []
    for (tool_path, tool_xml) in load_tool_elements_from_path(path):
        if found_tool_callback:
            found_tool_callback(tool_path)
        requirements, containers = parse_requirements_from_xml(tool_xml)
        conda_targets.extend(conda_util.requirements_to_conda_targets(requirements))
    return conda_targets
示例#4
0
def collect_conda_targets(path, found_tool_callback=None, conda_context=None):
    conda_targets = []
    for (tool_path, tool_xml) in load_tool_elements_from_path(path):
        if found_tool_callback:
            found_tool_callback(tool_path)
        requirements, containers = parse_requirements_from_xml(tool_xml)
        conda_targets.extend(conda_util.requirements_to_conda_targets(requirements))
    return conda_targets
示例#5
0
文件: tools.py 项目: natefoo/planemo
def load_tool_elements_from_path(path, recursive, register_load_errors=False):
    """Generator for tool XML elements on a path."""
    return loader_directory.load_tool_elements_from_path(
        path,
        _load_exception_handler,
        recursive=recursive,
        register_load_errors=register_load_errors,
    )
def load_one_dir( path ):
    tools_in_dir = []
    tool_elems = load_tool_elements_from_path( path )
    if tool_elems:
        for elem in tool_elems:
            root = elem[1].getroot()
            if root.tag == 'tool':
                tool = {}
                if root.find( 'help' ) is not None:
                    tool.update( dict( help=root.find( 'help' ).text ) )
                if root.find( 'description' ) is not None:
                    tool.update( dict( description=root.find( 'description' ).text ) )
                tool.update( dict( id=root.attrib.get( 'id' ),
                                   name=root.attrib.get( 'name' ),
                                   version=root.attrib.get( 'version' ) ) )
                tools_in_dir.append( tool )
    return tools_in_dir
def load_one_dir(path):
    tools_in_dir = []
    tool_elems = load_tool_elements_from_path(path)
    if tool_elems:
        for elem in tool_elems:
            root = elem[1].getroot()
            if root.tag == 'tool':
                tool = {}
                if root.find('help') is not None:
                    tool.update(dict(help=root.find('help').text))
                if root.find('description') is not None:
                    tool.update(
                        dict(description=root.find('description').text))
                tool.update(
                    dict(id=root.attrib.get('id'),
                         name=root.attrib.get('name'),
                         version=root.attrib.get('version')))
                tools_in_dir.append(tool)
    return tools_in_dir
示例#8
0
def cli(ctx, path, brew=None):
    """Install tool requirements using brew. (**Experimental**)

    An experimental approach to versioning brew recipes will be used.
    See full discussion on the homebrew-science issues page here -
    https://github.com/Homebrew/homebrew-science/issues/1191. Information
    on the implementation can be found at
    https://github.com/jmchilton/platform-brew
    until a more permanent project home is setup.
    """
    for (tool_path, tool_xml) in load_tool_elements_from_path(path):
        ctx.log('Brewing requirements from tool %s',
                click.format_filename(tool_path))
        mock_args = bunch.Bunch(brew=brew)
        brew_context = brew_exts.BrewContext(mock_args)
        requirements, containers = parse_requirements_from_xml(tool_xml)

        for recipe_context in brew_util.requirements_to_recipe_contexts(
                requirements, brew_context):
            brew_exts.versioned_install(recipe_context)
示例#9
0
def cli(ctx, path, brew=None):
    """Install tool requirements using brew. (**Experimental**)

    An experimental approach to versioning brew recipes will be used.
    See full discussion on the homebrew-science issues page here -
    https://github.com/Homebrew/homebrew-science/issues/1191. Information
    on the implementation can be found at
    https://github.com/jmchilton/platform-brew
    until a more permanent project home is setup.
    """
    for (tool_path, tool_xml) in load_tool_elements_from_path(path):
        ctx.log('Brewing requirements from tool %s',
                click.format_filename(tool_path))
        mock_args = bunch.Bunch(brew=brew)
        brew_context = brew_exts.BrewContext(mock_args)
        requirements, containers = parse_requirements_from_xml(tool_xml)

        for recipe_context in brew_util.requirements_to_recipe_contexts(
            requirements,
            brew_context
        ):
            brew_exts.versioned_install(recipe_context)
示例#10
0
def get_repos( sa_session, path_to_repositories ):
    """
    Load repos from DB and included tools from .xml configs.
    """
    results = []
    for repo in sa_session.query( model.Repository ).filter_by( deleted=False ).filter_by( deprecated=False ).filter( model.Repository.type != 'tool_dependency_definition' ):

        repo_id = repo.id
        name = repo.name
        description = repo.description
        long_description = repo.long_description
        homepage_url = repo.homepage_url
        remote_repository_url = repo.remote_repository_url

        times_downloaded = repo.times_downloaded
        if not isinstance( times_downloaded, ( int, long ) ):
            times_downloaded = 0

        repo_owner_username = ''
        if repo.user_id is not None:
            user = sa_session.query( model.User ).filter( model.User.id == repo.user_id ).one()
            repo_owner_username = user.username

        approved = 'no'
        for review in repo.reviews:
            if review.approved == 'yes':
                approved = 'yes'
                break

        #  Format the time since last update to be nicely readable.
        last_updated = pretty_print_time_interval( repo.update_time )
        full_last_updated = repo.update_time.strftime( "%Y-%m-%d %I:%M %p" )

        #  Parse all the tools within repo for separate index.
        tools_list = []
        path = os.path.join( path_to_repositories, *model.directory_hash_id( repo.id ))
        path = os.path.join( path, "repo_%d" % repo.id )
        if os.path.exists(path):
            tool_elems = load_tool_elements_from_path(path)
            if tool_elems:
                for elem in tool_elems:
                    root = elem[1].getroot()
                    if root.tag == 'tool':
                        tool = {}
                        if root.find('help') is not None:
                            tool.update( dict( help=root.find( 'help' ).text ) )
                        if root.find('description') is not None:
                            tool.update( dict( description=root.find( 'description' ).text ) )
                        tool.update( dict( id=root.attrib.get('id'),
                                           name=root.attrib.get('name'),
                                           version=root.attrib.get('version') ) )

                        tools_list.append( tool )

        results.append(dict( id=repo_id,
                             name=name,
                             description=description,
                             long_description=long_description,
                             homepage_url=homepage_url,
                             remote_repository_url=remote_repository_url,
                             repo_owner_username=repo_owner_username,
                             times_downloaded=times_downloaded,
                             approved=approved,
                             last_updated=last_updated,
                             full_last_updated=full_last_updated,
                             tools_list=tools_list ) )
    return results
示例#11
0
def load_tool_elements_from_path(path, recursive):
    return loader_directory.load_tool_elements_from_path(
        path,
        load_exception_handler,
        recursive,
    )