Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

swh:1:snp:fd22f80b54ad40aa01ea8be83f3828c1228d614f
  • Code
  • Branches (1)
  • Releases (0)
    • Branches
    • Releases
    • HEAD
    • refs/heads/main
    No releases to show
  • 707fda0
  • /
  • gsdeformer
  • /
  • utils_ui.py
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
content badge
swh:1:cnt:7421c5e87e9dac35d367f10e5dbb883fb95e81cd
directory badge
swh:1:dir:5e59cb9591658b084a01b862dbe7631b767a4fd0
revision badge
swh:1:rev:2eb7f6d3bf60cacd4f3969a9d68949cb3a34da95
snapshot badge
swh:1:snp:fd22f80b54ad40aa01ea8be83f3828c1228d614f

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
Tip revision: 2eb7f6d3bf60cacd4f3969a9d68949cb3a34da95 authored by jhuangBU on 10 May 2026, 11:43:06 UTC
doc: revise README
Tip revision: 2eb7f6d
utils_ui.py
import asyncio
from typing import TypeVar, Generic, Callable, List, Coroutine

T = TypeVar("T")


class EventEmitter(Generic[T]):

    def __init__(self):
        self._callbacks = []

    def register(self, function: Callable[[T], None]) -> Callable[[], None]:
        self._callbacks.append(function)
        return lambda: self._callbacks.remove(function)

    def emit(self, val: T):
        for f in self._callbacks:
            f(val)


class ValueEmitter(EventEmitter[T]):

    def __init__(self, init_val: T):
        super().__init__()
        self._val = init_val

    @property
    def val(self) -> T:
        return self._val

    def emit(self, val: T):
        self._val = val
        for f in self._callbacks:
            f(val)

    def notify_inplace_mutation(self):
        self.emit(self.val)

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API