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

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
content badge
swh:1:cnt:e3fe4cd2cafaac7f908fe0a9a4a5145d4e98bdcd

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
(requires biblatex-software package)
Generating citation ...
import datetime
import os
import shutil


def save_useful_info(dest_path) -> None:
    dst = os.path.join(dest_path, "code")
    if not os.path.exists(dst):
        shutil.copytree(
            os.getcwd(), dst,
        )


def flatten_dict(dd, separator="_", prefix=""):
    return (
        {
            prefix + separator + k if prefix else k: v
            for kk, vv in dd.items()
            for k, v in flatten_dict(vv, separator, kk).items()
        }
        if isinstance(dd, dict)
        else {prefix: dd}
    )


def split_by_ratio(length, ratio):
    assert sum(ratio) == 1.0
    se = [0, 0]
    split = []
    for r in ratio:
        l = r * length
        s = int(se[-1])
        e = int(se[-1] + l)
        se = [s, e]
        split.append(se)
    split[-1][-1] = length
    return split


def percent_bar(ratio=1.0, width=30, empty=' ', done='#', parts=' -=>'):
    if ratio == 1.0:
        return done * width
    else:
        return (
                (done * width)[:int((100 * ratio) // (100 / width))] +
                (parts)[int(len(parts) * (((100 * ratio) / (100 / width)) % 1.0))] +
                (empty * width)[:max(width - int((100 * ratio) // (100 / width)) - 1, 0)])


def progress(ei, ii, bi, train_err, iter_num, start_time):
    percent = (float(bi) + 1) / (iter_num)
    curr_time = datetime.datetime.now()
    eta_time = start_time + (1.0 / (percent + 1e-10)) * (curr_time - start_time)

    return ("| %5i | %6i | [%s] %6.2f%% | % 8.4f | %s |" %
            (ei, ii, percent_bar(percent), 100 * percent, train_err, str(eta_time)[11:19]))

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