# Buggy code
def main():
    """ "Initialize settings (not implemented) and create main window/application."""

    parser = argparse.ArgumentParser(
        description="OpenShot version " + info.SETUP["version"]
    )
    parser.add_argument(
        "-l",
        "--lang",
        action="store",
        help="language code for interface (overrides "
        "preferences and system environment)",
    )
    parser.add_argument(
        "--list-languages",
        dest="list_languages",
        action="store_true",
        help="List all language codes supported by OpenShot",
    )
    parser.add_argument(
        "--path",
        dest="py_path",
        action="append",
        help="Additional locations to search for modules "
        "(PYTHONPATH). Can be used multiple times.",
    )
    parser.add_argument(
        "--test-models",
        dest="modeltest",
        action="store_true",
        help="Load Qt's QAbstractItemModelTester into data models (requires Qt 5.11+)",
    )
    parser.add_argument(
        "-d", "--debug", action="store_true", help="Enable debugging output"
    )
    parser.add_argument(
        "--debug-file", action="store_true", help="Debugging output (logfile only)"
    )
    parser.add_argument(
        "--debug-console", action="store_true", help="Debugging output (console only)"
    )
    parser.add_argument("-V", "--version", action="store_true")
    parser.add_argument("remain", nargs=argparse.REMAINDER, help=argparse.SUPPRESS)

    args = parser.parse_args()

    # Display version and exit (if requested)
    if args.version:
        print("OpenShot version %s" % info.SETUP["version"])
        sys.exit()

    # Set up debugging log level to requested streams
    if args.debug or args.debug_file:
        info.LOG_LEVEL_FILE = "DEBUG"
    if args.debug or args.debug_console:
        info.LOG_LEVEL_CONSOLE = "DEBUG"

    if args.list_languages:
        from classes.language import get_all_languages

        print("Supported Languages:")
        for lang in get_all_languages():
            print("  {:>12}  {}".format(lang[0], lang[1]))
        sys.exit()

    if args.py_path:
        for p in args.py_path:
            try:
                if os.path.exists(os.path.realpath(p)):
                    sys.path.insert(0, os.path.realpath(p))
                    print("Added {} to PYTHONPATH".format(os.path.realpath(p)))
                else:
                    print("{} does not exist".format(os.path.realpath(p)))
            except TypeError as ex:
                print("Bad path {}: {}".format(p, ex))
                continue

    if args.modeltest:
        info.MODEL_TEST = True
        # Set default logging rules, if the user didn't
        if os.getenv("QT_LOGGING_RULES") is None:
            os.putenv("QT_LOGGING_RULES", "qt.modeltest.debug=true")

    if args.lang:
        if args.lang in info.SUPPORTED_LANGUAGES:
            info.CMDLINE_LANGUAGE = args.lang
        else:
            print("Unsupported language '{}'! (See --list-languages)".format(args.lang))
            sys.exit(-1)

    # Normal startup, print module path and lauch application
    print("Loaded modules from: %s" % info.PATH)

    # Create Qt application, pass any unprocessed arguments
    from classes.app import OpenShotApp

    argv = [sys.argv[0]]
    for arg in args.remain:
        argv.append(arg)
    app = OpenShotApp(argv)

    # Run and return result
    sys.exit(app.run())


# Traceback (TypeError)
Loaded modules from: /home/chiller/Desktop/git-extern/openshot-qt/src
app:INFO ------------------------------------------------
app:INFO             Wed Aug 26 17:21:17 2020
app:INFO               Starting new session
app:INFO ------------------------------------------------
app:INFO          OpenShot (version 2.5.1-dev2)
app:INFO ------------------------------------------------
app:INFO openshot-qt version: 2.5.1-dev2
app:INFO libopenshot version: 0.2.5-dev2
app:INFO platform: Linux-4.19.0-10-amd64-x86_64-with-debian-10.5
app:INFO processor:
app:INFO machine: x86_64
app:INFO python version: 3.7.3
app:INFO qt5 version: 5.11.3
app:INFO pyqt5 version: 5.11.3
language:INFO Qt Detected Languages: ['en-US']
language:INFO LANG Environment Variable: en_US.UTF-8
language:INFO LOCALE Environment Variable:
language:INFO OpenShot Preference Language: Default
project_data:INFO Setting default profile to HD 720p 30 fps
app:INFO Setting font to /home/chiller/Desktop/git-extern/openshot-qt/src/images/fonts/Ubuntu-R.ttf
logger_libopenshot:INFO Connecting to libopenshot with debug port: 5556
app:INFO Setting custom dark theme
exceptions:ERROR Unhandled Exception
Traceback (most recent call last):
File "src/launch.py", line 143, in <module>
main()
File "src/launch.py", line 136, in main
app = OpenShotApp(argv)
File "/home/chiller/Desktop/git-extern/openshot-qt/src/classes/app.py", line 242, in __init__
from windows.main_window import MainWindow
File "/home/chiller/Desktop/git-extern/openshot-qt/src/windows/main_window.py", line 45, in <module>
from windows.views.timeline_webview import TimelineWebView
File "/home/chiller/Desktop/git-extern/openshot-qt/src/windows/views/timeline_webview.py", line 154, in <module>
class TimelineWebView(TimelineMixin, updates.UpdateInterface):
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

# Fixed code
def main():
    """ "Initialize settings (not implemented) and create main window/application."""

    parser = argparse.ArgumentParser(
        description="OpenShot version " + info.SETUP["version"]
    )
    parser.add_argument(
        "-l",
        "--lang",
        action="store",
        help="language code for interface (overrides "
        "preferences and system environment)",
    )
    parser.add_argument(
        "--list-languages",
        dest="list_languages",
        action="store_true",
        help="List all language codes supported by OpenShot",
    )
    parser.add_argument(
        "--path",
        dest="py_path",
        action="append",
        help="Additional locations to search for modules "
        "(PYTHONPATH). Can be used multiple times.",
    )
    parser.add_argument(
        "--test-models",
        dest="modeltest",
        action="store_true",
        help="Load Qt's QAbstractItemModelTester into data models (requires Qt 5.11+)",
    )
    parser.add_argument(
        "-b",
        "--web-backend",
        action="store",
        choices=["auto", "webkit", "webengine"],
        default="auto",
        help="Web backend to use for Timeline",
    )
    parser.add_argument(
        "-d", "--debug", action="store_true", help="Enable debugging output"
    )
    parser.add_argument(
        "--debug-file", action="store_true", help="Debugging output (logfile only)"
    )
    parser.add_argument(
        "--debug-console", action="store_true", help="Debugging output (console only)"
    )
    parser.add_argument("-V", "--version", action="store_true")
    parser.add_argument("remain", nargs=argparse.REMAINDER, help=argparse.SUPPRESS)

    args = parser.parse_args()

    # Display version and exit (if requested)
    if args.version:
        print("OpenShot version %s" % info.SETUP["version"])
        sys.exit()

    # Set up debugging log level to requested streams
    if args.debug or args.debug_file:
        info.LOG_LEVEL_FILE = "DEBUG"
    if args.debug or args.debug_console:
        info.LOG_LEVEL_CONSOLE = "DEBUG"

    if args.list_languages:
        from classes.language import get_all_languages

        print("Supported Languages:")
        for lang in get_all_languages():
            print("  {:>12}  {}".format(lang[0], lang[1]))
        sys.exit()

    if args.py_path:
        for p in args.py_path:
            try:
                if os.path.exists(os.path.realpath(p)):
                    sys.path.insert(0, os.path.realpath(p))
                    print("Added {} to PYTHONPATH".format(os.path.realpath(p)))
                else:
                    print("{} does not exist".format(os.path.realpath(p)))
            except TypeError as ex:
                print("Bad path {}: {}".format(p, ex))
                continue

    if args.modeltest:
        info.MODEL_TEST = True
        # Set default logging rules, if the user didn't
        if os.getenv("QT_LOGGING_RULES") is None:
            os.putenv("QT_LOGGING_RULES", "qt.modeltest.debug=true")
    if args.web_backend:
        info.WEB_BACKEND = args.web_backend.lower()
    if args.lang:
        if args.lang in info.SUPPORTED_LANGUAGES:
            info.CMDLINE_LANGUAGE = args.lang
        else:
            print("Unsupported language '{}'! (See --list-languages)".format(args.lang))
            sys.exit(-1)

    # Normal startup, print module path and lauch application
    print("Loaded modules from: %s" % info.PATH)

    # Create Qt application, pass any unprocessed arguments
    from classes.app import OpenShotApp

    argv = [sys.argv[0]]
    for arg in args.remain:
        argv.append(arg)
    app = OpenShotApp(argv)

    # Run and return result
    sys.exit(app.run())