RhetTbull / autofile

Mac command line app to automatically move or copy files based on metadata associated with the files. For example, file your photos based on EXIF metadata or use MP3 tags to file your music files.
MIT License
22 stars 0 forks source link

Pull out the MTL parser into a separate class so it can easily be reused #14

Open RhetTbull opened 3 years ago

RhetTbull commented 3 years ago

The MLT parser is used today in osxphotos, exif2findertags and autofile. I'll likely use it again. Rather than maintain 3 separate versions, the common parser engine could be pulled out into it's own package, mtlparser

class MTLParser:

    def __init__(self, get_field_value: Callable):
        ...

get_field_value would get passed the current field,subfield, default, options and return the field value so that could be implemented separately from the parser.

common things like punctuation and filters would be part of the parser class but could be overridden to implement custom filters, etc.

RhetTbull commented 3 years ago
class MTLParser:
    def __init__(self, 
        get_field_value: Callable,
        sanitize: Optional[Callable], # sanitize fully rendered string
        sanitize_value: Optional[Callable], # sanitize each value from get_field_value,
        ):
        ...