API

glotter_core.project

Enumerations

class glotter_core.project.AcronymScheme(value)[source]

The acronym scheme overrides the naming scheme (NamingScheme). Each project word is checked against a list of acronyms. If there is a match, then the acronym scheme applies.

Variables:
  • lower – acronym word is lowercase

  • upper – acronym word is uppercase

  • two_letter_limit – acronym word is uppercase if the naming scheme is camel or pascal

class glotter_core.project.NamingScheme(value)[source]

Naming scheme for project filename. This defines how the project words are converted to a filename.

Variables:
  • hyphen – all words are separated by a hyphen (e.g., hello-world)

  • underscore – all words are separated by underscore (e.g., hello_world)

  • camel – the first word is lowercase, the remaining words are title case, and all words are joined together (e.g., helloWorld)

  • pascal – all words are title case and joined together (e.g., HelloWorld)

  • lower – all words are lowercase and joined together (e.g., helloworld)

Classes

class glotter_core.project.CoreProject(project_dict: dict[str, Any])[source]

Project information. This class uses CoreProjectMixin to implement its functionality

Parameters:

project_dict – Project dictionary

Raises:

ValueError if invalid acronym scheme

Variables:
  • project_dict (dict[str, Any]) – Project dictionary

  • words (list[str]) – Project words

  • acronyms (list[str]) – Optional project acronyms. Default is no acronyms

  • acronym_scheme (AcronymScheme) – Optional project acronym scheme. Default is AcronymScheme.two_letter_limit

class glotter_core.project.CoreProjectMixin[source]

Mixin that can be used in a parent class to get to get project information.

The parent class must contain the following instance variables:

Variables:
  • words (str) – Project words

  • acronyms (list[str]) – Project acronyms

  • acronym_scheme (AcronymScheme) – Acronym scheme

property display_name: str

Get display name for the project. The project words are separated by an spaces, subject to the acronym scheme – e.g., hello world).

Returns:

Display name

get_project_name_by_scheme(naming: str | NamingScheme) str[source]

Get project name by on the specified naming scheme, the acronym scheme, the project words, and the project acronyms

Parameters:

naming – Naming scheme

Returns:

Project name

Raises:

ValueError if invalid naming scheme

glotter_core.testinfo

Container, folder, and test information

class glotter_core.testinfo.ContainerInfo(image: str = '', tag: str = '', cmd: str = '', build: str | None = None)[source]

Configuration for a container to run for a directory

Variables:
  • image – the image to run

  • tag – the tag of the image to run

  • cmd – the command to run the source inside the container

  • build – an optional command to run to build the source before running the command

classmethod from_dict(dictionary: dict[str, str | None]) ContainerInfo[source]

Create a ContainerInfo object from a dictionary

Parameters:

dictionary – the dictionary representing ContainerInfo

Returns:

a new ContainerInfo object

class glotter_core.testinfo.FolderInfo(extension: str, naming: str)[source]

Metadata about sources in a directory

Parameters:
  • extension – the file extension that is considered as source

  • naming (str) – string containing the naming scheme for files in the directory

Raises:

ValueError if invalid naming scheme

Variables:
  • extension – the file extension that is considered as source

  • naming (NamingScheme) – the naming scheme for files in the directory

classmethod from_dict(dictionary: dict[str, str]) FolderInfo[source]

Create a FileInfo from a dictionary

Parameters:

dictionary – the dictionary representing FileInfo

Returns:

a new FileInfo

get_project_mappings(projects: dict[str, CoreProjectMixin], include_extension: bool = False) dict[str, str][source]

Uses the naming scheme to generate the expected source names in the directory and create a mapping from project type to source name

Parameters:
  • project – dictionary whose key is a project type and whose value is information about the project

  • include_extension – whether to include the extension in the source name

Returns:

a dict where the key is a project type and the value is the source name

class glotter_core.testinfo.TestInfo(container_info: ~glotter_core.testinfo.ContainerInfo, file_info: ~glotter_core.testinfo.FolderInfo, language_display_name: str, notes: list[str] = <factory>)[source]

An object representation of a testinfo file

Parameters:
  • container_info – ContainerInfo object

  • file_info – FolderInfo object

  • language_display_name – string indicating the display name of the language

  • notes – a list of notes about the language

Variables:
  • container_info – ContainerInfo object

  • file_info – FolderInfo object

  • language_display_name – string indicating the display name of the language

  • notes – a list of notes about the language

classmethod from_dict(dictionary: dict[str, Any], language: str) TestInfo[source]

Create a TestInfo object from a dictionary

Parameters:
  • dictionary – the dictionary representing a TestInfo object

  • language – language of source object

Returns:

a new TestInfo object

classmethod from_string(string: str, source) TestInfo[source]

Create a TestInfo from a string. Modify the string using Jinja2 templating. Then parse it as yaml

Parameters:
  • string – contents of a testinfo file

  • source – a source object to use for jinja2 template parsing

  • language – language of source

Returns:

a new TestInfo

property is_testable: bool

Indicate if language is testable

Returns:

True if language is testable, False otherwise

glotter_core.source

Source information

class glotter_core.source.CoreLanguage(sources: list[CoreSource], test_info: TestInfo, test_info_path: Path)[source]

Information about a language

Variables:
  • sources – list of source objects

  • test_info – TestInfo object

  • path – Path to TestInfo object file

class glotter_core.source.CoreSource(filename: str, language: str, path: str, test_info: str, project_type: str)[source]

Metadata about a source file

Parameters:
  • filename – filename including extension

  • language – the language of the source

  • path – path to the file excluding name

  • test_info (str) – a string in yaml format containing testinfo for a directory

  • project_type – name of project for this source

  • project_type – name of project for this source

Variables:
  • filename – filename including extension

  • language – the language of the source

  • path – path to the file excluding name

  • test_info (TestInfo) – TestInfo object

property extension: str

Returns the extension of the source

property full_path: str

Returns the full path to the source including filename and extension

property name: str

Returns the name of the source excluding the extension

class glotter_core.source.CoreSourceCategories(testable_by_project: dict[str, list[~glotter_core.source.CoreSource]] = <factory>, by_language: dict[str, list[~glotter_core.source.CoreLanguage]] = <factory>, bad_sources: list[str] = <factory>)[source]

Categories for sources

Variables:
  • testable_by_project – dictionary whose key is the project type and whose value is a list of testable source object

  • by_language – dictionary whose key is the language and whose value is a CoreLanguage object

  • bad_sources – list of filenames that do not belong to a project

glotter_core.source.categorize_sources(path: str, projects: dict[str, CoreProjectMixin], source_cls: type) CoreSourceCategories[source]

Categorize sources

Parameters:
  • path – path to source directory

  • projects – dictionary whose key is a project type and whose value is a CoreProjectMixin object

  • source_cls – source object class

Returns:

CoreSourceCategories object containing information of the source categories

glotter_core.settings

Project settings

class glotter_core.settings.CoreSettings[source]

Global project settings

Raises:

ValueError if invalid settings

Variables:
  • project_root (str) – Root directory of project

  • source_root (src) – Root directory for source files

  • acronym_scheme (AcronymScheme) – Optional project acronym scheme. Default is AcronymScheme.two_letter_limit

  • projects – Dictionary whose key is the project name and whose value is the project information

projects

alias of dict

class glotter_core.settings.CoreSettingsParser(project_root)[source]

Parse the settings file (.glotter.yml)

Parameters:

project_root – Root directory of project

Raises:

ValueError if setting file does not contain a dictionary

Variables:
  • project_root (str) – Root directory of project

  • yml_path (str | None) – Path to .glotter.yml file

  • yml (dict[str, Any]) – Contents of .glotter.yml file