]> git.parisson.com Git - timeside.git/commitdiff
cleanup cores, fix max_level id
authoryomguy <yomguy@parisson.com>
Wed, 17 Feb 2010 15:27:17 +0000 (15:27 +0000)
committeryomguy <yomguy@parisson.com>
Wed, 17 Feb 2010 15:27:17 +0000 (15:27 +0000)
analyze/max_level.py
decode/core.py
encode/core.py

index c40ae4d2083a7086dfdf5f6518b1049c73b8d505..af6c4a0780618840d267a8155b82bd74178d23ef 100644 (file)
@@ -30,9 +30,10 @@ class MaxLevelAnalyzer(AudioProcessor):
 
     @staticmethod
     def id():
-        return "maxlevel"
+        return "max_level"
 
-    def name(self):
+    @staticmethod
+    def name():
         return "Maximum peak level"
 
     def unit(self):
index 99d3900789836ae6bfef1d41851ee0f9524a0fe5..d82d6b9ef282c19e1d8953398698698d894f8ab0 100644 (file)
@@ -78,99 +78,3 @@ class DecoderCore(Processor):
 
 
 
-# External functions
-
-def get_type(value):
-    """ Return a String with the type of value """
-    types = {bool : 'bool', int : 'int', str : 'str'}
-    # 'bool' type must be placed *before* 'int' type, otherwise booleans are
-    # detected as integers
-    for type in types.keys():
-        if isinstance(value, type) :
-            return types[type]
-    raise TypeError(str(value) + ' has an unsupported type')
-
-def get_cast(value, type) :
-    """ Return value, casted into type """
-    if type == 'bool' :
-        if value == 'True' :
-            return True
-        return False
-    elif type == 'int' :
-        return int(value)
-    elif type == 'str' :
-        return str(value)
-    raise TypeError(type + ' is an unsupported type')
-
-def get_file_mime_type(path):
-    """ Return the mime type of a file """
-    try:
-        file_out1, file_out2 = os.popen4('file -i "'+path+'"')
-        for line in file_out2.readlines():
-            line_split = line.split(': ')
-            mime = line_split[len(line_split)-1]
-            return mime[:len(mime)-1]
-    except:
-        raise IOError('DecoderError: path does not exist.')
-
-def get_file_type_desc(path):
-    """ Return the type of a file given by the 'file' command """
-    try:
-        file_out1, file_out2 = os.popen4('file "'+path+'"')
-        for line in file_out2.readlines():
-            description = line.split(': ')
-            description = description[1].split(', ')
-            return description
-    except:
-        raise IOError('DecoderError: path does not exist.')
-
-def iswav(path):
-    """ Tell if path is a WAV """
-    try:
-        mime = get_file_mime_type(path)
-        return mime == 'audio/x-wav'
-    except:
-        raise IOError('DecoderError: path does not exist.')
-
-def iswav16(path):
-    """ Tell if path is a 16 bit WAV """
-    try:
-        file_type_desc = get_file_type_desc(path)
-        return iswav(path) and '16 bit' in file_type_desc
-    except:
-        raise IOError('DecoderError: path does not exist.')
-
-def get_file_name(path):
-    """ Return the file name targeted in the path """
-    return os.path.split(path)[1]
-
-def split_file_name(file):
-    """ Return main file name and its extension """
-    try:
-        return os.path.splitext(file)
-    except:
-        raise IOError('DecoderError: path does not exist.')
-
-def clean_word(word) :
-    """ Return the word without excessive blank spaces, underscores and
-    characters causing problem to decodeers"""
-    word = re.sub("^[^\w]+","",word)    #trim the beginning
-    word = re.sub("[^\w]+$","",word)    #trim the end
-    word = re.sub("_+","_",word)        #squeeze continuous _ to one _
-    word = re.sub("^[^\w]+","",word)    #trim the beginning _
-    #word = string.replace(word,' ','_')
-    #word = string.capitalize(word)
-    dict = '&[];"*:,'
-    for letter in dict:
-        word = string.replace(word,letter,'_')
-    return word
-
-def recover_par_key(path):
-    """ Recover a file with par2 key """
-    os.system('par2 r "'+path+'"')
-
-def verify_par_key(path):
-    """ Verify a par2 key """
-    os.system('par2 v "'+path+'.par2"')
-
-
index fbcf35f8afa68bd904fd07478a3535e4210daf06..3dc6391a195937c0e50dfc7aedfade1ba5d56170 100644 (file)
@@ -68,99 +68,5 @@ class EncoderCore(Processor):
                 break
             yield __chunk
 
-# External functions
-
-def get_type(value):
-    """ Return a String with the type of value """
-    types = {bool : 'bool', int : 'int', str : 'str'}
-    # 'bool' type must be placed *before* 'int' type, otherwise booleans are
-    # detected as integers
-    for type in types.keys():
-        if isinstance(value, type) :
-            return types[type]
-    raise TypeError(str(value) + ' has an unsupported type')
-
-def get_cast(value, type) :
-    """ Return value, casted into type """
-    if type == 'bool' :
-        if value == 'True' :
-            return True
-        return False
-    elif type == 'int' :
-        return int(value)
-    elif type == 'str' :
-        return str(value)
-    raise TypeError(type + ' is an unsupported type')
-
-def get_file_mime_type(path):
-    """ Return the mime type of a file """
-    try:
-        file_out1, file_out2 = os.popen4('file -i "'+path+'"')
-        for line in file_out2.readlines():
-            line_split = line.split(': ')
-            mime = line_split[len(line_split)-1]
-            return mime[:len(mime)-1]
-    except:
-        raise IOError('EncoderError: path does not exist.')
-
-def get_file_type_desc(path):
-    """ Return the type of a file given by the 'file' command """
-    try:
-        file_out1, file_out2 = os.popen4('file "'+path+'"')
-        for line in file_out2.readlines():
-            description = line.split(': ')
-            description = description[1].split(', ')
-            return description
-    except:
-        raise IOError('EncoderError: path does not exist.')
-
-def iswav(path):
-    """ Tell if path is a WAV """
-    try:
-        mime = get_file_mime_type(path)
-        return mime == 'audio/x-wav'
-    except:
-        raise IOError('EncoderError: path does not exist.')
-
-def iswav16(path):
-    """ Tell if path is a 16 bit WAV """
-    try:
-        file_type_desc = get_file_type_desc(path)
-        return iswav(path) and '16 bit' in file_type_desc
-    except:
-        raise IOError('EncoderError: path does not exist.')
-
-def get_file_name(path):
-    """ Return the file name targeted in the path """
-    return os.path.split(path)[1]
-
-def split_file_name(file):
-    """ Return main file name and its extension """
-    try:
-        return os.path.splitext(file)
-    except:
-        raise IOError('EncoderError: path does not exist.')
-
-def clean_word(word) :
-    """ Return the word without excessive blank spaces, underscores and
-    characters causing problem to encodeers"""
-    word = re.sub("^[^\w]+","",word)    #trim the beginning
-    word = re.sub("[^\w]+$","",word)    #trim the end
-    word = re.sub("_+","_",word)        #squeeze continuous _ to one _
-    word = re.sub("^[^\w]+","",word)    #trim the beginning _
-    #word = string.replace(word,' ','_')
-    #word = string.capitalize(word)
-    dict = '&[];"*:,'
-    for letter in dict:
-        word = string.replace(word,letter,'_')
-    return word
-
-def recover_par_key(path):
-    """ Recover a file with par2 key """
-    os.system('par2 r "'+path+'"')
-
-def verify_par_key(path):
-    """ Verify a par2 key """
-    os.system('par2 v "'+path+'.par2"')