]> git.parisson.com Git - telemeta.git/commitdiff
Made options optional. Closes: #10
authoryomguy <>
Tue, 1 May 2007 02:09:54 +0000 (02:09 +0000)
committeryomguy <>
Tue, 1 May 2007 02:09:54 +0000 (02:09 +0000)
telemeta/export/core.py
telemeta/export/flac.py
telemeta/export/mp3.py
telemeta/export/ogg.py
telemeta/export/wav.py
tests/export_test.py

index ef0ddadfcc27288bba34e10e647f3fee6fc4e238..fffd0d9c0f0e641c04c14b95c03960315c40c4dc 100644 (file)
@@ -96,7 +96,8 @@ class ExporterCore(Component):
                xml.dom.ext.PrettyPrint(doc, xml_file)
                xml_file.close()
 
-       def pre_process(self, item_id, source, metadata, ext, cache_dir, options):
+       def pre_process(self, item_id, source, metadata, ext, 
+                                       cache_dir, options=None):
                """ Pre processing of the core. Prepare the export path and
                return it"""
                self.item_id = str(item_id)
@@ -104,7 +105,6 @@ class ExporterCore(Component):
                file_name = get_file_name(self.source)
                file_name_wo_ext, file_ext = split_file_name(file_name)
                self.cache_dir = cache_dir
-               self.options = options
 
                self.metadata = metadata
                #self.collection = self.metadata['Collection']
@@ -145,11 +145,13 @@ class ExporterCore(Component):
                return self.dest
 
 
-       def post_process(self, item_id, source, metadata, ext, cache_dir, options):
+       def post_process(self, item_id, source, metadata, ext, 
+                                        cache_dir, options=None):
                """ Post processing of the Core. Print infos, etc..."""
-               if 'verbose' in self.options and self.options['verbose'] != '0':
-                       print self.dest
-                       print self.get_file_info()
+               if not options is None:
+                       if 'verbose' in self.options and self.options['verbose'] != '0':
+                               print self.dest
+                               print self.get_file_info()
 
 
 # External functions
index 5b163b50533530dd14182103d859ac8656a698e1..def184adacee8a13f17db83d053193dd7d05d71a 100644 (file)
@@ -83,22 +83,25 @@ class FlacExporter(ExporterCore):
                                media[tag] = str(self.metadata[tag])
                media.save()
                
-       def process(self, item_id, source, metadata, options):
+       def process(self, item_id, source, metadata, options=None):
                self.item_id = item_id
                self.source = source
                self.metadata = metadata
-               self.options = options
-
-               if 'flac_quality' in self.options and \
-                  self.options['flac_quality'] != '':
-                       args = '-f -V -'+self.options['flac_quality']
-               else:
-                       args = '-f -V -'+self.quality_default
-
-               if 'verbose' in self.options and self.options['verbose'] != '0':
-                       args = args
+               args = ''
+               
+               if not options is None:
+                       self.options = options
+                       if 'verbose' in self.options and self.options['verbose'] != '0':
+                               args = args
+                       else:
+                               args = args + ' -s '
+                               
+                       if 'flac_quality' in self.options:
+                               args = args+' -f -V -'+self.options['flac_quality']
+                       else:
+                               args = args+' -f -V -'+self.quality_default
                else:
-                       args = args+' -s '
+                       args = args+' -s -f -V -'+self.quality_default
        
                try:
                        # Pre-proccessing (core)
index ebcc82d677ce2be3717383ded261b499aca346cf..de6171ec3abdf8a45e593b8b8d181f6624e3152a 100644 (file)
@@ -88,23 +88,29 @@ class Mp3Exporter(ExporterCore):
                                id3.add(frame)
                id3.save()
                
-       def process(self, item_id, source, metadata, options):
+       def process(self, item_id, source, metadata, options=None):
                self.item_id = item_id
                self.source = source
                self.metadata = metadata
-               self.options = options
-
-               if 'mp3_bitrate' in self.options:
-                       args = '-b '+self.options['mp3_bitrate']
-               else:
-                       args = '-b '+self.bitrate_default
+               args = ''
+               
+               if not options is None:
+                       self.options = options
                        
-               args = args + '-c -o '
-
-               if 'verbose' in self.options and self.options['verbose'] != '0':
-                       args = args
+                       if 'verbose' in self.options and self.options['verbose'] != '0':
+                               args = args
+                       else:
+                               args= args + '-S '      
+                       
+                       if 'mp3_bitrate' in self.options:
+                               args = args+'-b '+self.options['mp3_bitrate']
+                       else:
+                               args = args+'-b '+self.bitrate_default
+                               
+                               #Copyrights, etc..
+                       args = args + ' -c -o '
                else:
-                       args = args + '-S '
+                       args = args + ' -S -c -o '
                
                if os.path.exists(self.source) and not iswav16(self.source):
                        self.source = self.decode()
index 207e66393ce984ce773322fe231195b7ec84b219..5f5ea2ba08f1829e3e4e8579778eb6f7b413f712 100644 (file)
@@ -72,24 +72,28 @@ class OggExporter(ExporterCore):
                        media[tag] = str(self.metadata[tag])
                media.save()
                
-       def process(self, item_id, source, metadata, options):
+       def process(self, item_id, source, metadata, options=None):
                self.item_id = item_id
                self.source = source
                self.metadata = metadata
-               self.options = options
+               args = ''
+               
+               if not options is None:
+                       self.options = options
+                       if 'verbose' in self.options and self.options['verbose'] != '0':
+                               args = args
+                       else:
+                               args = args + ' -Q '
+                       if 'ogg_bitrate' in self.options:
+                               args = '-b '+self.options['ogg_bitrate']
+                       elif 'ogg_quality' in self.options:
+                               args = '-q '+self.options['ogg_quality']
+                       else:
+                               args = '-b '+self.bitrate_default
 
-               if 'ogg_bitrate' in self.options:
-                       args = '-b '+self.options['ogg_bitrate']
-               elif 'ogg_quality' in self.options:
-                       args = '-q '+self.options['ogg_quality']
                else:
-                       args = '-b '+self.bitrate_default
+                       args = '-Q -b '+self.bitrate_default
 
-               if 'verbose' in self.options and self.options['verbose'] != '0':
-                       args = args
-               else:
-                       args = args + ' -Q '
-               
                if os.path.exists(self.source) and not iswav16(self.source):
                        self.source = self.decode()
                        
index 5da55895990ee10d2387f4d490e1e6a356d62afc..88e2b89a39769188c0df3cef12e44d924fccd25e 100644 (file)
@@ -97,12 +97,12 @@ class WavExporter(ExporterCore):
                except IOError:
                        return 'Exporter error: Cannot create the par2 key...'
 
-       def process(self, item_id, source, metadata, options):
+       def process(self, item_id, source, metadata, options=None):
                self.item_id = item_id
                self.source = source
                self.metadata = metadata
-               self.options = options
-
+               if not options is None:
+                       self.options = options
                try:
                        # Pre-proccessing (core)
                        self.ext = self.get_file_extension()
index 24b25719f997bdba336ed636352ef15298c61e59..b8cd33be64e5393da31d2a538f9b0f0d1cc4632f 100644 (file)
@@ -33,14 +33,16 @@ class ExportTest(Component):
        exporters = ExtensionPoint(IExporter)
 
        def run(self):
+               verbose = '1'
                for exporter in self.exporters:
                        format = exporter.get_format()
-                       if 'verbose' in options and options['verbose'] != '0':
+                       if verbose != '0':
                                print "\n+------------------------------------------"
                                print '| Testing exporter format: ' + format
                                print "+------------------------------------------"
                        exporter.set_cache_dir(cache_dir)
                        exporter.process(item_id,source,metadata,options)
+                       #exporter.process(item_id,source,metadata)
 
 
 compmgr = ComponentManager()