Esempio n. 1
0
    def scan(self):
        """populates the "files" array with all *.lyx files """
        if self.cli_args.verbose:
            Print.scanning_directory(self.cli_args.path)

        for root, dirs, files in os.walk(self.cli_args.path):
            for name in files:
                if not name.endswith('.lyx'):
                    continue
                f = LyxFile(os.path.join(root, name))
                self.files.append(f)
Esempio n. 2
0
    def print_report(self):
        """prints how many files were scanned, and how many of those were not
        exported yet or are outdated"""
        Print.num_files_scanned(len(self.files))

        if len(self.notexported_files) > 0:
            Print.num_not_exported(len(self.notexported_files))
        if len(self.outdated_files) > 0:
            Print.num_outdated(len(self.outdated_files))
        if len(self.notexported_files) == 0 and len(self.outdated_files) == 0:
            Print.everything_up_to_date()

        Print.linebreak()
Esempio n. 3
0
def main():
    platform_check()
    cli_args = parse_args(sys.argv[1:])

    if cli_args.version:
        Print.version()
        sys.exit(0)

    try:
        scanner = Scanner(cli_args)
    except NotADirectoryError:
        Print.invalid_directory()
        sys.exit(1)

    scanner.scan()
    scanner.check_exports()
    scanner.print_report()
    scanner.prompt_export()
Esempio n. 4
0
    def check_exports(self):
        """checks the "files" array for Lyx files that were not exported to PDF
        and PDFs that are older than the Lyx file"""
        if len(self.files) == 0:
            Print.no_lyx_files_found()
            sys.exit()

        for filename in self.files:
            if not filename.is_exported():
                Print.not_exported(str(filename))
                self.notexported_files.append(filename)
            elif filename.is_outdated():
                Print.is_outdated(str(filename))
                self.outdated_files.append(filename)
            elif self.cli_args.verbose:
                Print.up_to_date(str(filename))
Esempio n. 5
0
 def test_format_invalid_color(self):
     message = Print.format("some text", color='notacolor')
     self.assertEqual(message, "some text")
Esempio n. 6
0
 def test_format_no_formatting(self):
     message = Print.format("some text")
     self.assertEqual(message, "some text")
Esempio n. 7
0
 def test_format_blue_bold_underline(self):
     message = Print.format("text", color='BLUE', bold=True, underline=True)
     self.assertAlmostEqual(message, "\033[4m\033[1m\033[94mtext\033[0m")
Esempio n. 8
0
 def test_format_underline(self):
     message = Print.format("text", underline=True)
     self.assertAlmostEqual(message, "\033[4mtext\033[0m")
Esempio n. 9
0
 def test_format_bold(self):
     message = Print.format("text", bold=True)
     self.assertAlmostEqual(message, "\033[1mtext\033[0m")
Esempio n. 10
0
 def test_format_color_red(self):
     message = Print.format("text", color='ReD')
     self.assertAlmostEqual(message, "\033[91mtext\033[0m")