X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=lib%2Fconfigure.py;h=83e2ce7c0c07f6f2b74736c0e72fc1cf2650016a;hb=febbc3537a7f86413253b77c2bd306b4bb6fe695;hp=9b2fceb4379ed749fb23de9972a91fa82392f869;hpb=a450797b2ab160f5953922d59298e6ff6472f8e4;p=lyx.git diff --git a/lib/configure.py b/lib/configure.py index 9b2fceb437..83e2ce7c0c 100644 --- a/lib/configure.py +++ b/lib/configure.py @@ -1402,25 +1402,34 @@ def checkLatexConfig(check_config, bool_docbook): classname = file.split(os.sep)[-1].split('.')[0] decline = "" catline = "" - for line in open(file, 'r', encoding='utf8').readlines(): - if not empty.match(line) and line[0] != '#'[0]: - if decline == "": - logger.warning("Failed to find valid \Declare line " - "for layout file `%s'.\n\t=> Skipping this file!" % file) - nodeclaration = True - # A class, but no category declaration. Just break. + try: + for line in open(file, 'r', encoding='utf8').readlines(): + if not empty.match(line) and line[0] != '#'[0]: + if decline == "": + logger.warning("Failed to find valid \Declare line " + "for layout file `%s'.\n\t=> Skipping this file!" % file) + nodeclaration = True + # A class, but no category declaration. Just break. + break + if declare.match(line) != None: + decline = "\\TestDocClass{%s}{%s}" % (classname, line[1:].strip()) + testclasses.append(decline) + elif category.match(line) != None: + catline = ("\\DeclareCategory{%s}{%s}" + % (classname, category.match(line).groups()[0])) + testclasses.append(catline) + if catline == "" or decline == "": + continue break - if declare.match(line) != None: - decline = "\\TestDocClass{%s}{%s}" % (classname, line[1:].strip()) - testclasses.append(decline) - elif category.match(line) != None: - catline = ("\\DeclareCategory{%s}{%s}" - % (classname, category.match(line).groups()[0])) - testclasses.append(catline) - if catline == "" or decline == "": + if nodeclaration: continue - break - if nodeclaration: + except UnicodeDecodeError: + logger.warning("**************************************************\n" + "Layout file '%s'\n" + "cannot be decoded in utf-8.\n" + "Please check if the file has the correct encoding.\n" + "Skipping this file!\n" + "**************************************************" % file) continue testclasses.sort() cl = open('chklayouts.tex', 'w', encoding='utf8')