'Detect the language of a given file, or list of files. Uses
language_map, and language_order to do the job.'

def detect_language(self, sources):

    if (not isinstance(sources, list)):
        sources = [sources]
    lang = None
    index = len(self.language_order)
    for source in sources:
        (base, ext) = os.path.splitext(source)
        extlang = self.language_map.get(ext)
        try:
            extindex = self.language_order.index(extlang)
            if (extindex < index):
                lang = extlang
                index = extindex
        except ValueError:
            pass
    return lang
