def getExtension(filename, nDots=None):
    """
    Get file extension.

    Inputs:
    -> filename;
    -> nDots: the maximum number of dots extesions should have.
  """
    filename = filename.split('.')
    lParts = len(filename)
    if nDots is None:
        nDots = lParts - 1
    nDots = -nDots
    if nDots <= -lParts:
        nDots = -(lParts - 1)
    if nDots > -1:
        return ''
    return '.'.join(filename[nDots:])
