From bd20814d3c2b2358bb597863adf77fcb169ec22d Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Sat, 29 Jun 2024 12:22:31 -0700 Subject: [PATCH] Doing some reimplementation of the parser code --- mfbatch/__main__.py | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/mfbatch/__main__.py b/mfbatch/__main__.py index 75edddd..616edeb 100644 --- a/mfbatch/__main__.py +++ b/mfbatch/__main__.py @@ -12,51 +12,19 @@ from string import Template from typing import Set - from mfbatch.util import readline_with_escaped_newlines +from mfbathc.commands import BatchfileParser, CommandEnv from tqdm import tqdm # import readline # MFBATCH COMMAND FILE -# Every line is processed, the first character decides the kind of command -# in the style of mtree. -# [a-z] Line is a command -# : Line is a file -# # is a comment - -# Commands are: -# set KEY VAL + -# KEY in each subsequent file is set to VAL. $-keys in VAL will be -# substituted. -# d VAL + -# An alias for :set DESCRIPTION -# unset KEY -# KEY in each subsequent file will be unset. -# unset * -# No keys in each subsequent file will be set. -# set+ KEY INITIAL -# KEY in next file will be set to INITIAL which will be incremented by -# one for each file processed. - -# Commands to be implemented are: -# set1 KEY VAL -# KEY in the next file (and only the next file) is set to VAL. METAFLAC_PATH = '/opt/homebrew/bin/metaflac' COMMAND_LEADER = ':' COMMENT_LEADER = '#' -class CommandEnv: - metadatums: dict - incr: Set[str] - - def __init__(self) -> None: - self.metadatums = dict() - self.incr = set() - - def render_substitutions(env: CommandEnv, in_str: str) -> str: template = Template(in_str) return template.substitute(env.metadatums)