Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(20)  |  Call(20)  |  Derive(0)  |  Import(0)
Build a <a href='...'>...</a> tag to link to a resource

'resource' can be a URL or a string, or a Canary document
element (typically a Section) which supplies an 'id()'
method.

'text' specifies the text for the link. If no text is supplied
then the text defaults to the resource name or URL.

Optional parameter 'relative_link' specifies whether links should(more...)

        def MakeLink(resource,text=None,title=None,relative_link=False,
             new_window=False):
    """Build a ... tag to link to a resource

    'resource' can be a URL or a string, or a Canary document
    element (typically a Section) which supplies an 'id()'
    method.

    'text' specifies the text for the link. If no text is supplied
    then the text defaults to the resource name or URL.

    Optional parameter 'relative_link' specifies whether links should
    be left as they are or else where possible converted to
    relative links (relative to the current working directory).

    Optional parameter 'title' specifies text that will be added
    to the title attribute for the link.

    Optional parameter 'new_window' specifies whether the link will be
    opened in the same window (default) or a new window.

    Basic usage examples:

    MakeLink('http://www.yoyodyne.com/')
    => http://www.yoyodyne.com/

    MakeLink('http://www.yoyodyne.com/','Yoyodyne homepage')
    => Yoyodyne homepage

    yoyodyne = doc.addSection("About Yoyodyne")
    MakeLink(yoyodyne,'Read more about Yoyodyne here')
    => Read more about Yoyodyne here"""

    # Obtain the resource URL
    try:
        # Try to get the resource id
        url = '#'+str(resource.id())
    except AttributeError:
        # Doesn't have an id method
        url = str(resource)
    # Deal with relative links
    if relative_link:
        # Determine if URL is in or below the current directory
        # and convert if necessary
        pwd = os.getcwd()
        common_prefix = os.path.commonprefix([pwd,url])
        if url == pwd:
            # URL is the current working directory
            url = '.'
        elif common_prefix == pwd:
            # URL is relative to cwd - strip off cwd and return
            url = str(url).replace(common_prefix,'',1).lstrip(os.sep)
    # Obtain the link text
    link_text = None
    if not text:
        try:
            link_text = str(resource)
        except AttributError:
            # No str method support
            link_text = url
    else:
        link_text = str(text)
    # Build and return the link
    html = ""
    return html
        


src/e/d/edna-HEAD/libraries/EDNA2html-0.0.10a/EDNA2html.py   edna(Download)
            for edna_run in edna_runs:
                diag = self.addFailureDiagnostics(edna_run)
                run_list.addItem(Canary.MakeLink(diag))
        # Add the footer (time, version numbers etc)
        addFooter(self.__doc)
    if edna_run.run_basename:
        section.addPara("Base directory for this run: " +
                        Canary.MakeLink(edna_run.run_basename))
    # Input files
    section.addPara("The following files were used as input:")
    row = ["Indexing result", str(edna_run.has_indexing_result)]
    if edna_run.mosflm_indexing_log:
        row.append(Canary.MakeLink(edna_run.mosflm_indexing_log,
                                   "Mosflm indexing log"))
    else:
    integration_logs = []
    for log_file in edna_run.mosflm_integration_logs:
        integration_logs.append(Canary.MakeLink(log_file,
                                                "Mosflm integration log"))
    if integration_logs:
    row = ["Strategy result", str(edna_run.has_strategy_result)]
    if edna_run.best_log:
        row.append(Canary.MakeLink(edna_run.best_log,
                                   "Best log"))
    else: