[gen] CSS improvements; bugfix: parsing now works even if encoding is declared at the beginning of the Python file; a default layout for Boolean fields, including a description, is now available in Boolean.dLayouts.

This commit is contained in:
Gaetan Delannay 2012-05-31 17:29:06 +02:00
parent ede29fb6c1
commit e3b7f5364f
3 changed files with 12 additions and 4 deletions

View file

@ -79,10 +79,15 @@ class AstClass:
class Ast:
'''Python AST.'''
classPattern = (symbol.stmt, symbol.compound_stmt, symbol.classdef)
utf8prologue = '# -*- coding: utf-8 -*-'
def __init__(self, pyFile):
f = file(pyFile)
fContent = f.read()
f.close()
# For some unknown reason, when an UTF-8 encoding is declared, parsing
# does not work.
if fContent.startswith(self.utf8prologue):
fContent = fContent[len(self.utf8prologue):]
fContent = fContent.replace('\r', '')
ast = parser.suite(fContent).totuple()
# Get all the classes defined within this module.