From a2dfcd6bc261cd8a5aa1aab24b9a0a1e1ed750ab Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Wed, 15 Aug 2012 15:05:35 -0400 Subject: [PATCH] Revert "cc-4232: changed bit formatter to give empty string when bitrate is set to 0" This reverts commit 4e25a5ff442258c13f366a4557ca22181cdfac02. --- .../application/models/formatters/BitrateFormatter.php | 8 ++------ python_apps/media-monitor2/media/monitor/metadata.py | 2 +- python_apps/media-monitor2/media/monitor/pure.py | 8 ++++---- python_apps/media-monitor2/tests/test_pure.py | 5 ----- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/airtime_mvc/application/models/formatters/BitrateFormatter.php b/airtime_mvc/application/models/formatters/BitrateFormatter.php index db64a4048..00828a672 100644 --- a/airtime_mvc/application/models/formatters/BitrateFormatter.php +++ b/airtime_mvc/application/models/formatters/BitrateFormatter.php @@ -19,10 +19,6 @@ class BitrateFormatter { { $Kbps = bcdiv($this->_bitrate, 1000, 0); - if($Kbps == 0) { - return ""; - } else { - return "{$Kbps} Kbps"; - } + return "{$Kbps} Kbps"; } -} +} \ No newline at end of file diff --git a/python_apps/media-monitor2/media/monitor/metadata.py b/python_apps/media-monitor2/media/monitor/metadata.py index 931ab52da..2a209d2bd 100644 --- a/python_apps/media-monitor2/media/monitor/metadata.py +++ b/python_apps/media-monitor2/media/monitor/metadata.py @@ -51,7 +51,7 @@ airtime_special = { "MDATA_KEY_DURATION" : lambda m: format_length(getattr(m.info, u'length', 0.0)), "MDATA_KEY_BITRATE" : - lambda m: getattr(m.info, "bitrate", ''), + lambda m: getattr(m.info, "bitrate", 0), "MDATA_KEY_SAMPLERATE" : lambda m: getattr(m.info, u'sample_rate', 0), "MDATA_KEY_MIME" : diff --git a/python_apps/media-monitor2/media/monitor/pure.py b/python_apps/media-monitor2/media/monitor/pure.py index cc70a2f1e..81843e8bd 100644 --- a/python_apps/media-monitor2/media/monitor/pure.py +++ b/python_apps/media-monitor2/media/monitor/pure.py @@ -209,12 +209,12 @@ def parse_int(s): >>> parse_int("123saf") 123 >>> parse_int("asdf") - '' + 0 """ if s.isdigit(): return s else: - try : return str(reduce(op.add, takewhile(lambda x: x.isdigit(), s))) - except: return '' + try : return reduce(op.add, takewhile(lambda x: x.isdigit(), s)) + except: return 0 def normalized_metadata(md, original_path): """ @@ -241,10 +241,10 @@ def normalized_metadata(md, original_path): # could possibly lead to subtle bugs down the road. Plus the following # approach gives us the flexibility to use different defaults for different # attributes - new_md = remove_whitespace(new_md) new_md = apply_rules_dict(new_md, format_rules) new_md = default_to(dictionary=new_md, keys=['MDATA_KEY_TITLE'], default=no_extension_basename(original_path)) + new_md = remove_whitespace(new_md) new_md = default_to(dictionary=new_md, keys=path_md, default=u'') new_md = default_to(dictionary=new_md, keys=['MDATA_KEY_FTYPE'], diff --git a/python_apps/media-monitor2/tests/test_pure.py b/python_apps/media-monitor2/tests/test_pure.py index 81918fd10..c3b08f874 100644 --- a/python_apps/media-monitor2/tests/test_pure.py +++ b/python_apps/media-monitor2/tests/test_pure.py @@ -67,9 +67,4 @@ class TestMMP(unittest.TestCase): self.assertTrue( mmp.sub_path(d1, f1) ) self.assertTrue( mmp.sub_path(d2, f1) ) - def test_parse_int(self): - self.assertEqual( mmp.parse_int("123"), "123" ) - self.assertEqual( mmp.parse_int("123asf"), "123" ) - self.assertEqual( mmp.parse_int("asdf"), "" ) - if __name__ == '__main__': unittest.main()