Пример #1
0
    def test_loading_aspect(self):
        """Test that the aspect ratio of the loading screen is properly converted

        This test gives a "ResourceWarning: unclosed file" warning, see:
        https://github.com/python-imaging/Pillow/issues/477
        """

        input_directory = os.path.join(self.test_datadir, "loading_aspect/GameData/")
        output_directory = os.path.join(self.tmpdir, "loading_aspect")

        cfg = rfactortools.rFactorToGSC2013Config()
        converter = rfactortools.rFactorToGSC2013(input_directory, cfg)
        converter.convert_all(output_directory)

        # check that images that aren't 800x600 or 1024x768 are resized properly
        img = Image.open(os.path.join(output_directory,
                                      "GameData/Locations/TestTrack/TestTrack_loading.jpg"))
        self.assertEqual(img.size, (1024, 768))

        # check that images that already are 800x600 or 1024x768 stay untouched
        self.assertTrue(filecmp.cmp(os.path.join(input_directory,
                                                 "Locations/TestTrack2/TestTrack2_loading.jpg"),
                                    os.path.join(output_directory,
                                                 "GameData/Locations/TestTrack2/TestTrack2_loading.jpg")))

        self.assertTrue(filecmp.cmp(os.path.join(input_directory,
                                                 "Locations/TestTrack3/TestTrack3_loading.jpg"),
                                    os.path.join(output_directory,
                                                 "GameData/Locations/TestTrack3/TestTrack3_loading.jpg")))
Пример #2
0
    def convert(self, source_directory, target_directory, cfg):
        try:
            converter = rfactortools.rFactorToGSC2013(source_directory, cfg)
            converter.progress_cb = self.progress_callback
            converter.convert_all(target_directory)

        except Exception as e:
            logging.exception("conversion failed")
            self.progress_cb("error", e)
Пример #3
0
    def test_cmaps_dontfix(self):
        """Make sure that MASFile=cmaps.mas is not fixed when the cmaps is in another mod directory"""

        input_directory = os.path.join(self.test_datadir, "cmaps_dontfix/GameData/")
        output_directory = os.path.join(self.tmpdir, "cmap_dontfix")

        cfg = rfactortools.rFactorToGSC2013Config()
        converter = rfactortools.rFactorToGSC2013(input_directory, cfg)
        converter.convert_all(output_directory)

        with rfactortools.open_read(os.path.join(output_directory,
                                                 "GameData/Vehicles/TheMod/Subdir/graphics.gen")) as fin:
            self.assertEqual(fin.read(),
                             "MASFile=cmaps.mas\n")
Пример #4
0
    def test_cmaps_dontfix(self):
        """Make sure that MASFile=cmaps.mas is not fixed when the cmaps is in another mod directory"""

        input_directory = os.path.join(self.test_datadir,
                                       "cmaps_dontfix/GameData/")
        output_directory = os.path.join(self.tmpdir, "cmap_dontfix")

        cfg = rfactortools.rFactorToGSC2013Config()
        converter = rfactortools.rFactorToGSC2013(input_directory, cfg)
        converter.convert_all(output_directory)

        with rfactortools.open_read(
                os.path.join(
                    output_directory,
                    "GameData/Vehicles/TheMod/Subdir/graphics.gen")) as fin:
            self.assertEqual(fin.read(), "MASFile=cmaps.mas\n")
Пример #5
0
    def test_loading_aspect(self):
        """Test that the aspect ratio of the loading screen is properly converted

        This test gives a "ResourceWarning: unclosed file" warning, see:
        https://github.com/python-imaging/Pillow/issues/477
        """

        input_directory = os.path.join(self.test_datadir,
                                       "loading_aspect/GameData/")
        output_directory = os.path.join(self.tmpdir, "loading_aspect")

        cfg = rfactortools.rFactorToGSC2013Config()
        converter = rfactortools.rFactorToGSC2013(input_directory, cfg)
        converter.convert_all(output_directory)

        # check that images that aren't 800x600 or 1024x768 are resized properly
        img = Image.open(
            os.path.join(output_directory,
                         "GameData/Locations/TestTrack/TestTrack_loading.jpg"))
        self.assertEqual(img.size, (1024, 768))

        # check that images that already are 800x600 or 1024x768 stay untouched
        self.assertTrue(
            filecmp.cmp(
                os.path.join(input_directory,
                             "Locations/TestTrack2/TestTrack2_loading.jpg"),
                os.path.join(
                    output_directory,
                    "GameData/Locations/TestTrack2/TestTrack2_loading.jpg")))

        self.assertTrue(
            filecmp.cmp(
                os.path.join(input_directory,
                             "Locations/TestTrack3/TestTrack3_loading.jpg"),
                os.path.join(
                    output_directory,
                    "GameData/Locations/TestTrack3/TestTrack3_loading.jpg")))
Пример #6
0
    parser.add_argument('-v', '--verbose', action='store_true', default=False,
                        help="be more verbose")
    parser.add_argument('-q', '--quiet', action='store_true', default=False,
                        help="be less verbose")
    args = parser.parse_args()

    target_directory = args.output

    if args.verbose:
        logging.basicConfig(level=logging.DEBUG)
    elif args.quiet:
        logging.basicConfig(level=logging.ERROR)
    else:
        logging.basicConfig(level=logging.INFO)

    if args.info:
        for source_directory in args.DIRECTORY:
            converter = rfactortools.rFactorToGSC2013(source_directory, cfg)
            converter.print_info(sys.stdout)
    else:
        if not target_directory:
            raise Exception("--output DIR must be set")
        else:
            for source_directory in args.DIRECTORY:
                converter = rfactortools.rFactorToGSC2013(source_directory, cfg)
                converter.convert_all(target_directory)
                print("-- rfactor-to-gsc2013 conversion complete --")


# EOF #
Пример #7
0
                        '--quiet',
                        action='store_true',
                        default=False,
                        help="be less verbose")
    args = parser.parse_args()

    target_directory = args.output

    if args.verbose:
        logging.basicConfig(level=logging.DEBUG)
    elif args.quiet:
        logging.basicConfig(level=logging.ERROR)
    else:
        logging.basicConfig(level=logging.INFO)

    if args.info:
        for source_directory in args.DIRECTORY:
            converter = rfactortools.rFactorToGSC2013(source_directory, cfg)
            converter.print_info(sys.stdout)
    else:
        if not target_directory:
            raise Exception("--output DIR must be set")
        else:
            for source_directory in args.DIRECTORY:
                converter = rfactortools.rFactorToGSC2013(
                    source_directory, cfg)
                converter.convert_all(target_directory)
                print("-- rfactor-to-gsc2013 conversion complete --")

# EOF #