#!/usr/bin/env python
# encoding=utf-8

# Copyright 2009 Patrick Näf
# 
# This file is part of mkroesti
#
# mkroesti is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# mkroesti is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with mkroesti. If not, see <http://www.gnu.org/licenses/>.


# Compatibility Python 2.6
from __future__ import print_function

# PSL
import sys
import os.path

# mkroesti
import mkroesti.main
import mkroesti.errorhandling


try:
    if __name__ == "__main__":
        scriptName = os.path.basename(sys.argv[0])
        mkroesti.main.main()
except (mkroesti.errorhandling.MKRoestiError,
        mkroesti.errorhandling.DuplicateAlgorithmError,
        mkroesti.errorhandling.DuplicateAliasError,
        mkroesti.errorhandling.DuplicateProviderError) as errorInstance:
    print(scriptName + ": error: " + errorInstance.message)
    exit(1)
except mkroesti.errorhandling.UnknownAlgorithmError as errorInstance:
    print(scriptName + ": " + errorInstance.message)
    exit(1)
except mkroesti.errorhandling.UnavailableAlgorithmError as errorInstance:
    print(scriptName + ": " + errorInstance.message)
    exit(1)
except mkroesti.errorhandling.UnknownAliasError as errorInstance:
    print(scriptName + ": unknown alias: " + errorInstance.message)
    exit(1)
except mkroesti.errorhandling.ConversionError as errorInstance:
    print(scriptName + ": conversion error: " + errorInstance.message)

