Skip to content

Commit

Permalink
base implmentation for #61
Browse files Browse the repository at this point in the history
  • Loading branch information
bensteUEM committed May 22, 2024
1 parent c1a11c9 commit 464e7f2
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 2 deletions.
4 changes: 2 additions & 2 deletions SngFile.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
"""This file is used to define SngFile class and somee helper methods related to it's usage."""

import logging
import logging.config
import re
from itertools import chain

import SNG_DEFAULTS
from sng_utils import generate_verse_marker_from_line, validate_suspicious_encoding_str
from SngFileHeaderValidationPart import SngFileHeaderValidation
from SngFileLanguagePart import SngFileLanguagePart
from SngFileParserPart import SngFileParserPart

logger = logging.getLogger(__name__)


class SngFile(SngFileParserPart, SngFileHeaderValidation):
class SngFile(SngFileParserPart, SngFileHeaderValidation, SngFileLanguagePart):
"""Main class that defines one single SongBeamer SNG file."""

def __init__(self, filename: str, songbook_prefix: str = "") -> None:
Expand Down
101 changes: 101 additions & 0 deletions SngFileLanguagePart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
"""This file is used to define SngFile class and somee helper methods related to it's usage."""

import abc
import logging

logger = logging.getLogger(__name__)


class SngFileLanguagePart(abc.Abc):
"""Part of SngFile class used with language specific actions.
Args:
abc: placeholder that this class can not be used on it's own - SngFile should be used instead
"""

def get_content(self, languages: list[str] | None = None) -> dict:
"""Gets content list of the file.
Arguments:
languages: optional - list of language lines to keep, defaults to all
Returns:
content dict with only the languages indicated in argument
"""
if not languages:
languages = [None, "##1", "##2", "##3", "##4"]
# TODO@benste: Implement
# https://github.com/bensteUEM/SongBeamerQS/issues/61
not_implemented_link = "https://github.com/bensteUEM/SongBeamerQS/issues/61"
raise NotImplementedError(not_implemented_link)

return self.content

def genereate_content_by_lang(self, content: list[list]) -> dict:
"""Generate a new content dict by joining multiple content blocks overwriting the language order.
This will not overwrite content but provide a new content which could be used
Args:
content: list of content blocks, language marker will be overwritten to position in list
Returns:
one content list which includes any provided content block with respective language markers
"""
# TODO@benste: Implement
# https://github.com/bensteUEM/SongBeamerQS/issues/61
not_implemented_link = "https://github.com/bensteUEM/SongBeamerQS/issues/61"
raise NotImplementedError(not_implemented_link)

return content

def get_content_unique_lang_markers(self) -> set:
"""Helper which gets the unique language markers explicitly used in the song.
* Can be None or any combination of ##1 ##2 ##3 ##4
* number of items equals the number of languages used
* ignores header LangCount option
Returns:
set of all language markers used within the song
"""
not_implemented_link = "https://github.com/bensteUEM/SongBeamerQS/issues/61"
raise NotImplementedError(not_implemented_link)
# TODO@benste: Implement
# https://github.com/bensteUEM/SongBeamerQS/issues/61

def validate_language_count(self, fix: bool = False) -> bool:
"""Validate the language count option in header.
* counts the number of languages explicitly used in content
* checks if LangCount matches
if fix LangCount header will be overwritten by number of identified languages
Args:
fix: should LangCount Header be overwritten? Defaults to False.
Returns:
if language_count is valid
"""
if fix:
pass
# TODO@benste: Implement
# https://github.com/bensteUEM/SongBeamerQS/issues/61
not_implemented_link = "https://github.com/bensteUEM/SongBeamerQS/issues/61"
raise NotImplementedError(not_implemented_link)

def validate_language_marker(self, fix: bool = False) -> bool:
"""Validate the language markers used in content.
Args:
fix: attempt to fix language marker usage Defaults to False.
Returns:
if language markers match LangCount header
"""
if fix:
pass
# TODO@benste: Implement
# https://github.com/bensteUEM/SongBeamerQS/issues/61
not_implemented_link = "https://github.com/bensteUEM/SongBeamerQS/issues/61"
raise NotImplementedError(not_implemented_link)

0 comments on commit 464e7f2

Please sign in to comment.