예제 #1
0
    def from_args(self, args):
        name = args.command

        if name == 'get':
            return GetCommand()
        elif name == 'set':
            return OperationCommand(SetOperation(args.__dict__))
        elif name == 'rename':
            template = FreiTemplate(args.format)
            return OperationCommand(RenameOperation(template))
        elif name == 'extract':
            template = FreiTemplate(args.format)
            return OperationCommand(ExtractOperation(template))
        elif name == 'humanize':
            return OperationCommand(HumanizeOperation())
예제 #2
0
 def __init__(self, template=FreiTemplate(DEFAULT_FORMAT)):
     self.template = template
예제 #3
0
 def run(self, args):
     songs = self.get_songs(args.files)
     template = FreiTemplate(args.format)
     for song in songs:
         print template.format(song)
예제 #4
0
    def test_extract(self):
        template = FreiTemplate('%tracknumber %title.mp3')
        string = '01 Hello World.mp3'
        tags = {'tracknumber': '01', 'title': 'Hello World'}

        self.assertEquals(tags, template.extract(string))
예제 #5
0
 def test_format(self):
     tags = {'artist': 'Bob Marley', 'title': 'One Love'}
     template = FreiTemplate('   %artist - %title   ')
     self.assertEquals('Bob Marley - One Love', template.format(tags))
예제 #6
0
    def test_extract(self):
        template = FreiTemplate('%tracknumber %title.mp3')
        string = '01 Hello World.mp3'
        tags = {'tracknumber': '01', 'title': 'Hello World'}

        self.assertEquals(tags, template.extract(string))
예제 #7
0
 def test_format(self):
     tags = {'artist': 'Bob Marley', 'title': 'One Love'}
     template = FreiTemplate('   %artist - %title   ')
     self.assertEquals('Bob Marley - One Love', template.format(tags))