MetaDataParser.py revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
## @file
# This file is used to define common parser functions for meta-data
#
# Copyright (c) 2008, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
import os
from CommonDataClass.DataClass import *
from EccToolError import *
import EccGlobalData
import re
## Get the inlcude path list for a source file
#
# 1. Find the source file belongs to which inf file
# 2. Find the inf's package
# 3. Return the include path list of the package
#
IncludeList = []
SqlCommand = """
select Value1, FullPath from Inf, File where Inf.Model = %s and Inf.BelongsToFile in(
select distinct B.BelongsToFile from File as A left join Inf as B
where A.ID = B.BelongsToFile and B.Model = %s and (A.Path || '%s' || B.Value1) = '%s')
and Inf.BelongsToFile = File.ID""" \
SqlCommand = """select Value1 from Dec where BelongsToFile =
(select ID from File where FullPath = '%s') and Model = %s""" \
if InfPath not in IncludeList:
for NewRecord in NewRecordSet:
if IncludePath not in IncludeList:
return IncludeList
## Get the file list
#
# Search table file and find all specific type files
#
FileList = []
return FileList
## Get the table list
#
# Search table file and find all small tables
#
TableList = []
return TableList
## ParseHeaderCommentSection
#
# Parse Header comment section lines, extract Abstract, Description, Copyright
# , License lines
#
# @param CommentList: List of (Comment, LineNumber)
# @param FileName: FileName of the comment
#
Abstract = ''
Description = ''
Copyright = ''
License = ''
EndOfLine = "\n"
STR_HEADER_COMMENT_START = "@file"
#
# used to indicate the state of processing header comment section of dec,
# inf files
#
#
# first find the last copyright line
#
Last = 0
if _IsCopyrightLine(Line):
break
for Item in CommentList:
Msg = 'Comment must start with #'
#
# if there are blank lines between License or Description, keep them as they would be
# indication of different block; or in the position that Abstract should be, also keep it
# as it indicates that no abstract
#
continue
else:
else:
#
# in case there is no abstract and description
#
if not Comment:
Abstract = ''
elif _IsCopyrightLine(Comment):
else:
#
# in case there is no description
#
if _IsCopyrightLine(Comment):
else:
if _IsCopyrightLine(Comment):
else:
#
# Contents after copyright line are license, those non-copyright lines in between
# copyright line will be discarded
#
if License:
else:
continue
if not Copyright:
Msg = 'Header comment section must have copyright information'
if not License:
Msg = 'Header comment section must have license information'
## _IsCopyrightLine
# check whether current line is copyright line, the criteria is whether there is case insensitive keyword "Copyright"
# followed by zero or more white space characters followed by a "(" character
#
# @param LineContent: the line need to be checked
# @return: True if current line is copyright line, False else
#
def _IsCopyrightLine (LineContent):
return Result
## CleanString2
#
# Split comments in a string
# Remove spaces
#
# @param Line: The string to be cleaned
# @param CommentCharacter: Comment char, used to ignore comment content,
# default is DataType.TAB_COMMENT_SPLIT
#
#
# remove whitespace
#
#
# Replace EDK1's comment character
#
#
# separate comments and statements
#
#
# remove whitespace again
#
#
# Remove prefixed and trailing comment characters
#
Start = 0
Start += 1
End -= 1
else:
Comment = ''