Skip to content

Commit

Permalink
Added file type check in dsc file
Browse files Browse the repository at this point in the history
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1234 7335b38e-4728-0410-8992-fb3ffe349368
  • Loading branch information
jwang36 committed May 16, 2008
1 parent e9405d8 commit 86cefc4
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 126 deletions.
36 changes: 20 additions & 16 deletions Source/Python/Common/Misc.py
Expand Up @@ -250,14 +250,18 @@ def DataRestore(File):
return Data

## Check if gvien file exists or not
#
#
# @param File File name or path to be checked
# @param Dir The directory the file is relative to
#
#
# @retval True if file exists
# @retval False if file doesn't exists
#
def ValidFile(File, Dir='.'):
#
def ValidFile(File, Ext=None, Dir='.'):
if Ext != None:
Dummy, FileExt = os.path.splitext(File)
if FileExt.lower() != Ext.lower():
return False
Wd = os.getcwd()
os.chdir(Dir)
if not os.path.exists(File):
Expand All @@ -267,13 +271,13 @@ def ValidFile(File, Dir='.'):
return True

## Get GUID value from given packages
#
#
# @param CName The CName of the GUID
# @param PackageList List of packages looking-up in
#
#
# @retval GuidValue if the CName is found in any given package
# @retval None if the CName is not found in all given packages
#
#
def GuidValue(CName, PackageList):
for P in PackageList:
if CName in P.Guids:
Expand Down Expand Up @@ -466,11 +470,11 @@ def __len__(self):
## "in" test support
def __contains__(self, key):
return key in self._key_list

## indexof support
def index(self, key):
return self._key_list.index(key)

## insert support
def insert(self, key, newkey, newvalue, order):
index = self._key_list.index(key)
Expand All @@ -487,7 +491,7 @@ def append(self, sdict):
if key not in self._key_list:
self._key_list.append(key)
IterableUserDict.__setitem__(self, key, sdict[key])

def has_key(self, key):
return key in self._key_list

Expand Down Expand Up @@ -565,7 +569,7 @@ def __init__(self, KeyList):
## []= operator
def __setitem__(self, key, value):
if key not in self:
EdkLogger.error("RestrictedDict", ATTRIBUTE_SET_FAILURE, "Key [%s] is not allowed" % key,
EdkLogger.error("RestrictedDict", ATTRIBUTE_SET_FAILURE, "Key [%s] is not allowed" % key,
ExtraData=", ".join(dict.keys(self)))
dict.__setitem__(self, key, value)

Expand Down Expand Up @@ -604,7 +608,7 @@ def __init__(self, _Single_=False, _Level_=2):
self._Level_ = _Level_
self.data = {}
self._Single_ = _Single_

# =[] operator
def __getitem__(self, key):
KeyType = type(key)
Expand Down Expand Up @@ -699,7 +703,7 @@ def __setitem__(self, key, value):

if FirstKey in self._ValidWildcardList:
FirstKey = self._Wildcard

if FirstKey not in self.data and self._Level_ > 0:
self.data[FirstKey] = tdict(self._Single_, self._Level_ - 1)

Expand All @@ -721,7 +725,7 @@ def SetSingleMode(self):
self.data[Key].SetSingleMode()

## Boolean chain list
#
#
class Blist(UserList):
def __init__(self, initlist=None):
UserList.__init__(self, initlist)
Expand All @@ -746,7 +750,7 @@ def ParseConsoleLog(Filename):
if Line.find('.efi') > -1:
Line = Line[Line.rfind(' ') : Line.rfind('.efi')].strip()
Opw.write('%s\n' % Line)

Opr.close()
Opw.close()

Expand All @@ -764,7 +768,7 @@ def ParseConsoleLog(Filename):
# d['IA32', 'DXE_CORE', 'C'] = 3
#
# print d['IA32', 'DXE_CORE', 'C']

# s = sdict()
# s[1] = 1
# s[3] = 3
Expand Down

0 comments on commit 86cefc4

Please sign in to comment.