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

  • e2bf985
  • /
  • srctx
  • /
  • strip-comments
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
content badge
swh:1:cnt:e7e9ca2b1844294f16bf84af31252ea1bcdd8d72
directory badge
swh:1:dir:93807834d98089fa6ad8b30e43c7caee01586e4a

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
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
strip-comments
#! /usr/bin/env python3

# --------------------------------------------------------------------
import sys, os, re, StringIO as sio

# --------------------------------------------------------------------
def _main():
    contents = sys.stdin.read()
    output   = sio.StringIO()
    depth    = 0

    while contents:
        m = re.search(r'^(.*?)(\(\*|\*\))', contents, re.S)
        if m is None: break
        if depth == 0:
            output.write(m.group(1))
        if m.group(2) == '(*':
            depth += 1
        else:
            if depth > 0:
                depth -= 1
            else:
                output.write(m.group(2))
        contents = contents[len(m.group(0)):]

    if depth == 0:
        output.write(contents)
    output = [x.rstrip() for x in output.getvalue().splitlines()]
    while output and not output[0]:
        output.pop(0)
    while output and not output[-1]:
        output.pop()
    i = 0
    while i < len(output):
        if not output[i]:
            while i+1 < len(output) and not output[i+1]:
                output.pop(i+1)
        i += 1

    print('\n'.join(output) + '\n')

# --------------------------------------------------------------------
if __name__ == '__main__':
    _main()

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