howfairis package

class howfairis.Checker(repo: howfairis.repo.Repo, user_config_filename: Optional[str] = None, repo_config_filename: str = '.howfairis.yml', ignore_repo_config: bool = False, is_quiet: bool = False)

Bases: howfairis.mixins.repository_mixin.RepositoryMixin, howfairis.mixins.license_mixin.LicenseMixin, howfairis.mixins.registry_mixin.RegistryMixin, howfairis.mixins.citation_mixin.CitationMixin, howfairis.mixins.checklist_mixin.ChecklistMixin

Check the repo against the five FAIR software recommendations using supplied config.

Parameters
  • repo – Repository to check

  • user_config_filename – Filename of configuration file on users local filesystem.

  • repo_config_filename – Filename of configuration file on the repository. Default is “.howfairis.yml”.

  • ignore_repo_config – If True then the configuration file on the repository is not loaded. Default is False.

  • is_quiet – If True then less verbose output is printed. Default is False.

Example

The registry compliance of the https://github.com/fair-software/howfairis repository can be checked with:

>>> from howfairis import Repo, Checker
>>> url = "https://github.com/fair-software/howfairis"
>>> repo = Repo(url)
>>> checker = Checker(repo, is_quiet=True)
...
>>> compliance = checker.check_five_recommendations()
>>> compliance.registry
True
repo

Object describing the properties of the target repository.

Type

repo.Repo

is_quiet

If True then less verbose output is printed. Default is False.

Type

bool

readme

Retrieved README from the repository.

Type

readme.Readme

The skip_*_checks_reason and Checker.ignore_commented_badges properties are set based on merger of

  1. the default configuration (see howfairis/data/.howfairis.yml),

  2. config file from repo and

  3. config file from users local filesystem.

check_five_recommendations()howfairis.compliance.Compliance

Check the repo against the five FAIR software recommendations

Returns: compliance result

property ignore_commented_badges

If True then any commented out badges in the README of the repository are ignored.

Type

bool

property skip_checklist_checks_reason

If True then checks for the checklist recommendation are skipped and the recommendation is marked as compliant

Type

bool

property skip_citation_checks_reason

If True then checks for the citation recommendation are skipped and the recommendation is marked as compliant

Type

bool

property skip_license_checks_reason

If True then checks for the license recommendation are skipped and the recommendation is marked as compliant

Type

bool

property skip_registry_checks_reason

If True then checks for the registry recommendation are skipped and the recommendation is marked as compliant

Type

bool

property skip_repository_checks_reason

If True then checks for the repository recommendation are skipped and the recommendation is marked as compliant

Type

bool

class howfairis.Compliance(repository: bool = False, license_: bool = False, registry: bool = False, citation: bool = False, checklist: bool = False)

Bases: object

Compliance of a repo against the 5 FAIR software recommendations

Parameters
  • repository – Whether repository is publicly accessible with version control

  • license – Whether repository has a license

  • registry – Whether code is in a registry

  • citation – Whether software is citable

  • checklist – Whether a software quality checklist is used

repository

Whether repository is publicly accessible with version control

Type

bool

license

Whether repository has a license

Type

bool

registry

Whether code is in a registry

Type

bool

citation

Whether software is citable

Type

bool

checklist

Whether a software quality checklist is used

Type

bool

COMPLIANT_SYMBOL = '●'
NONCOMPLIANT_SYMBOL = '○'
as_unicode()str

String representation of each 5 recommendations. Where a full dot means compliant with the recommendation and a open dot means not-compliant.

Returns: A string

calc_badge(readme_file_format: howfairis.readme_format.ReadmeFormat)Optional[str]

Calculate FAIR software badge image URL and URL in format of README.

Parameters

readme_file_format – Format of README.

Returns

Badge image link or None when format of README is unsupported.

count(value=True)int

Number of recommendations which are compliant or non-compliant

Parameters

value – If True then counts number of recommendations that are compliant.

Returns

Count

urlencode(separator: str = '%20%20')str

Encodes compliance into string which can be used in a URL.

Parameters

separator

Returns

String that can be used in a URL

class howfairis.Platform(value)

Bases: enum.Enum

Type of code repository platform

GITHUB = 1
GITLAB = 2
class howfairis.Readme(filename: Optional[str] = None, text: Optional[str] = None, file_format: Optional[howfairis.readme_format.ReadmeFormat] = None, ignore_commented_badges: bool = True)

Bases: object

Container for the README of a repository

Parameters
  • filename – Name of README

  • text – Content of README

  • file_format – Format of README. It is used to ignore commented out badges.

  • ignore_commented_badges – If False commented out badges will be considered.

filename

Name of README

Type

str, None

text

Content of README

Type

str, None

file_format

Format of README

Type

ReadmeFormat, None

COMPLIANT_SYMBOL = '%E2%97%8F'

this is a compliant symbol used in get_compliance()

NONCOMPLIANT_SYMBOL = '%E2%97%8B'

this is a non-compliant symbol used in get_compliance()

SEPARATOR = '%20%20'

this is a separator symbol used in get_compliance()

get_compliance()Optional[howfairis.compliance.Compliance]

Retrieve compliance from README based on presence of the FAIR Software badge.

Returns

Compliance object when badge is found otherwise None.

class howfairis.Repo(url: str, branch: Optional[str] = None, path: Optional[str] = None)

Bases: object

Representation of a source code repository.

Parameters
  • url – URL of a code repository such as https://github.com/fair-software/howfairis

  • branch – Branch to checkout. Defaults to default branch of the repository. Can also be a commit SHA-1 hash or tag.

  • path – Path inside repository. Defaults to root.

url

URL of a code repository,

Type

str

branch

Branch to checkout. If None then Repo.default_branch will be used.

Type

str, None

path

Path inside repository.

Type

str

platform

Detected code repository platform of repo.

Type

code_repository_platforms.Platform

owner

Owner of the repo.

Type

str

repo

Name of repo. Normally the last part of the url.

Type

str

api

API endpoint of code repository platform where info about repo can be fetched.

Type

str

default_branch

The default branch of the repo on the code repository platform.

Type

str, None

raw_url_format_string

URL where a file from repo can be downloaded. URL has single placeholder for filename.

Type

str

Subpackages