Beispiel #1
0
def gscholar_bio(me, WIDTH):
    """
        Create a panel with an overvio of my google scholar profile
    """
    bio = pi.Report(color=orange, dim=orange_dark)
    bio.width = WIDTH
    bio.tb.expand = True

    bio.add(f"[bold {orange_light}]{me['name']}")

    # Interests
    bio.add(f"[{grey}]{me['affiliation']}")
    bio.add(f"[dim i]Interests: " + "".join([i + " "
                                             for i in me["interests"]]))

    # Numbers
    bio.add(
        f"[{blue_grey_light}]Total citations: [{orange}]{me['citedby']}",
        justify="right",
    )
    bio.add(
        f"[{blue_grey_light}]H-index: [{orange}]{me['hindex']}",
        justify="right",
    )

    return Panel(
        bio.tb,
        expand=True,
        border_style=bio.dim,
        padding=(0, 2, 1, 2),
    )
Beispiel #2
0
    def __rich_console__(self, *args):
        """
            Print some useful characteristics to console.
        """
        rep = pi.Report(
            title=f"[b]brainrender.Actor: ",
            color=salmon,
            accent=orange,
        )

        rep.add(f"[b {orange}]name:[/b {orange}][{amber}] {self.name}")
        rep.add(f"[b {orange}]type:[/b {orange}][{amber}] {self.br_class}")
        rep.line()
        rep.add(
            f"[{orange}]center of mass:[/{orange}][{amber}] {self.mesh.centerOfMass().astype(np.int32)}"
        )
        rep.add(
            f"[{orange}]number of vertices:[/{orange}][{amber}] {len(self.mesh.points())}"
        )
        rep.add(
            f"[{orange}]dimensions:[/{orange}][{amber}] {np.array(self.mesh.bounds()).astype(np.int32)}"
        )
        rep.add(f"[{orange}]color:[/{orange}][{amber}] {self.mesh.color()}")

        yield "\n"
        yield rep
Beispiel #3
0
 def __rich_console__(self, console, dimension):
     actors = pi.Report("Scene actors",
                        accent=salmon,
                        dim=orange,
                        color=orange)
     for act in self.scene.clean_actors:
         try:
             points = len(act.points())
         except AttributeError:
             points = 0
         actors.add(
             f"[bold][{amber}]- {act.name}[/bold][{orange_darker}] (type: [{orange}]{act.br_class}[/{orange}]) - [white dim]points: {points}"
         )
     yield Panel(actors.tb)
Beispiel #4
0
    def list_actors(self):
        actors = pi.Report("Scene actors", accent=salmon)
        for act in self.actors:
            try:
                name = act.name
            except AttributeError:
                pass

            try:
                br_class = act._br_class
            except AttributeError:
                raise ValueError(
                    f'Actor {name} doesnt have a "br_class" attribute!')

            actors.add(f"[{orange}]- {name}[{mocassin}] (type: {br_class})")

        actors.print()
Beispiel #5
0
def cv(WIDTH):
    hs = f"bold {blue_light}"

    CV = pi.Report("Curriculum Vitae",
                   color=salmon,
                   accent=salmon_light,
                   dim=salmon)
    CV.width = WIDTH

    # ? education
    CV.add(f"[{hs}]         [underline]Education:")
    CV.spacer()
    CV.add(render.education(info.education, WIDTH), "rich")

    # ? extracurr education
    CV.spacer(2)
    CV.add(f"[{hs}]         [underline]Extracurricular education")
    CV.spacer()
    CV.add(render.extracurr_education(info.extracurr_education, WIDTH), "rich")

    # ? research experience
    CV.spacer(4)
    CV.add(f"[{hs}]         [underline]Research experience")
    CV.spacer()
    CV.add(render.experience(info.research_experience, WIDTH), "rich")

    # ? teaching experience
    CV.spacer(2)
    CV.add(f"[{hs}]         [underline]Teaching experience")
    CV.spacer()
    CV.add(render.teaching(info.teaching_experience, WIDTH), "rich")

    # ?  posters
    CV.spacer(2)
    CV.add(f"[{hs}]         [underline]Poster presentations")
    CV.spacer()
    CV.add(render.posters(info.posters, WIDTH), "rich")

    # ?  awards
    CV.spacer(4)
    CV.add(f"[{hs}]         [underline]Awards and fellowships")
    CV.spacer()
    CV.add(render.awards(info.awards, WIDTH), "rich")

    return CV
Beispiel #6
0
    def content(self):
        """
        Prints an overview of the Actors in the scene.
        """

        actors = pi.Report(
            "Scene actors", accent=salmon, dim=orange, color=orange
        )

        for act in self.actors:
            actors.add(
                f"[bold][{amber}]- {act.name}[/bold][{orange_darker}] (type: [{orange}]{act.br_class}[/{orange}])"
            )

        if "win32" != sys.platform:
            actors.print()
        else:
            print(pi.utils.stringify(actors, maxlen=-1))
Beispiel #7
0
def projs(WIDTH):
    def sort_items(item):
        return git.get_repo(item[1]).stargazers_count

    # Use github API
    git = Github("FedeClaudi", secrets.gh_pswd)

    projs = pi.Report("Open source projects",
                      color=green,
                      accent=green,
                      dim=green_dark)
    projs.width = WIDTH
    projs.tb.expand = True

    # Sort projs by github stars
    sorted_projs = sorted(info.open_source_projs)

    # Make report
    for name in sorted_projs:
        descr, github, url = info.open_source_projs[name]

        projs.add(f"[{green}]" + name)
        projs.add(descr)

        projs.spacer()
        projs.add(
            f"[{blue_grey}]Github url:[/{blue_grey}] [dim]https://github.com/{github}",
            justify="right",
        )

        if url is not None:
            projs.add(
                f"[{blue_grey}]Documentation:[/{blue_grey}] [dim]{url}",
                justify="right",
            )

        repo = git.get_repo(github)
        projs.add(
            f"[{blue_grey_light}]Stars: [{orange}]{repo.stargazers_count}",
            justify="right",
        )
        projs.spacer(2)

    return projs
Beispiel #8
0
    def list_actors(self, extensive=False):
        actors = pi.Report("Scene actors",
                           accent=salmon,
                           dim=orange,
                           color=orange)

        for act in self.actors + self.actors_labels:
            try:
                name = f"[b]{act.name}"

                if name is None:
                    name = str(act)

            except AttributeError:
                name = "noname"

            try:
                br_class = act.br_class
            except AttributeError:
                if isinstance(act, Actor):
                    print(
                        f'Actor {name} does not have a "br_class" attribute!\n{act}'
                    )
                else:
                    continue

            if not extensive:
                actors.add(
                    f"[b {mocassin}]- {name}[/b][{dimorange}] (type: [{orange}]{br_class}[/{orange}])"
                )
            else:
                actors.add(
                    f"[b {mocassin}]- {name}[/b][{dimorange}] (type: [{orange}]{br_class}[/{orange}]) | is transformed: [blue]{act._is_transformed}"
                )

        if "win" not in sys.platform:
            actors.print()
        else:
            print(pi.utils.stringify(actors, maxlen=-1))
Beispiel #9
0
def test_report():
    pi.whats_pi()  # tests both Report and Nested Report

    rep = pi.Report()
    rep.add(inspect.getfile(pi.Report), "code file")
Beispiel #10
0
def pubs(WIDTH):
    def sort_items(item):
        """Sort special variables first, then alphabetically."""
        try:
            return int(item["bib"]["pub_year"])
        except KeyError:
            return 0

    myid = "8eDOmAQAAAAJ"  # google scholar ID
    me = scholarly.search_author_id(myid, filled=True)

    pubs = pi.Report("Publications", accent=orange, dim=amber)
    pubs.width = WIDTH

    pubs.add(gscholar_bio(me, WIDTH), "rich")
    pubs.spacer(2)

    year = None
    for n, pub in enumerate(
            sorted(me["publications"], key=sort_items, reverse=True)):
        cites = pub["num_citations"]
        pub = scholarly.fill(pub)["bib"]

        if "pub_year" not in pub.keys():
            continue

        # Mark year
        if pub["pub_year"] != year:

            if n > 0:
                pubs.line(amber)
                pubs.spacer()

            pubs.add(f'[bold {salmon_light}]{pub["pub_year"]}',
                     justify="center")
            year = pub["pub_year"]
            pubs.spacer()

        # add title
        pubs.add(f"[bold italic {orange_light}]" + pub["title"])

        # add authors
        try:
            auths = pub["author"].replace(" and", ",")
        except KeyError:
            auths = ""

        names = ["F Claudi", "Federico Claudi", "F. Claudi"]
        formatted_auths = ""
        for author in auths.split(","):
            if author.strip() in names:
                formatted_auths += f"[bold {pink}]{author}[/bold {pink}],"
            else:
                formatted_auths += f"[{blue_grey}]{author}[/{blue_grey}],"

        pubs.add(formatted_auths)

        # Add journal
        if "eprint" in pub.keys():
            url = pub["eprint"]
        elif "url" in pub.keys():
            url = pub["url"]
        else:
            url = ""

        try:
            journal = pub["journal"]
        except KeyError:
            journal = ""

        pubs.add(f"[i {blue_grey_light}]" + journal +
                 f"[/i {blue_grey_light}]" + "[dim]\n" + url)

        # Add citations
        pubs.add(
            f"[{blue_grey_light}]Citations: [{orange}]{cites}",
            justify="right",
        )

        pubs.spacer()

    return pubs