Beispiel #1
0
def index() -> Results:
    from . import hpi
    import my.hypothesis as hyp
    for h in hyp.get_highlights():
        if isinstance(h, Exception):
            yield h
            continue
        hl = h.highlight
        ann = h.annotation
        tags = h.tags
        cparts = []
        if hl is not None:
            cparts.append(hl)
        if ann is not None:
            cparts.extend(['comment: ' + ann])
        if tags:
            cparts.append(" ".join(f"#{t}" for t in tags))
        yield Visit(
            url=h.url,
            dt=h.created,
            context='\n\n'.join(cparts),
            locator=Loc.make(
                title='hypothesis',
                href=h.hyp_link,
            )
        )
Beispiel #2
0
    def get_items(self):
        for t in filter(is_todo, get_highlights()):
            yield t.id, todo(
                dt=t.dt,
                heading=t.highlight,
                tags=['hyp2org', *t.tags],
                body=f'''
{t.annotation}
{link(title=t.page_title, url=t.page_link)}
{link(title="in context", url=t.hyp_link)}
'''.lstrip(),
            )
Beispiel #3
0
    def get_items(self):
        for t in get_highlights():
            if isinstance(t, Exception):
                # I guess there isn't much we can do here? will be spotted by other tools
                continue
            if not is_todo(t):
                continue
            yield t.hid, todo(
                dt=t.created,
                heading=t.highlight,
                tags=['hyp2org', *t.tags],
                body=f'''
{t.annotation}
{link(title=t.title, url=t.url)}
{link(title="in context", url=t.hyp_link)}
'''.lstrip(),
            )
Beispiel #4
0
def index() -> Results:
    from . import hpi
    import my.hypothesis as hyp

    for h in hyp.get_highlights():
        if isinstance(h, Exception):
            yield h
            continue
        hl = h.highlight
        ann = h.annotation
        tags = h.tags
        cparts = []
        if hl is not None:
            cparts.append(hl)
        if ann is not None:
            cparts.append(f"comment: {ann}")
        if tags:
            cparts.append(join_tags(tags))
        visit = Visit(
            url=h.url,
            dt=h.created,
            context="\n\n".join(cparts),
            locator=Loc.make(
                title="hypothesis",
                href=h.hyp_link,
            ),
        )

        yield visit

        in_text_visits = (
            (hl, "highlighted"),
            (ann, "comment"),
        )
        for text, part_name in in_text_visits:
            if text and text.strip():
                urls = extract_urls(text)
                for url in urls:
                    yield visit._replace(
                        url=url,
                        locator=visit.locator._replace(
                            title=f"hypothesis-{part_name}"),
                    )
Beispiel #5
0
def index() -> Results:
    import my.hypothesis as hyp
    logger = get_logger()

    for h in hyp.get_highlights():
        if isinstance(h, Exception):
            yield h
            continue
        # TODO FIXME need to make sure it's typechecked on CI... and also do coverage checks
        hl = h.highlight
        ann = h.annotation
        cparts = []
        if hl is not None:
            cparts.append(hl)
        if ann is not None:
            cparts.extend(['comment: ' + ann])
        yield Visit(url=h.url,
                    dt=h.created,
                    context='\n\n'.join(cparts),
                    locator=Loc.make(
                        title='hypothesis',
                        href=h.hyp_link,
                    ))