1 # -*- coding: utf-8 -*-
3 #-------------------------------------------------------------------------
7 # Copyright (c) 2016 Google Inc.
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
13 # http://www.apache.org/licenses/LICENSE-2.0
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
21 #-------------------------------------------------------------------------
24 from fnmatch import fnmatch
26 STATEMENT_PATTERN = "STATEMENT-*"
27 TEST_LOG_PATTERN = "*.qpa"
28 GIT_STATUS_PATTERN = "*git-status.txt"
29 GIT_LOG_PATTERN = "*git-log.txt"
30 PATCH_PATTERN = "*.patch"
31 SUMMARY_PATTERN = "cts-run-summary.xml"
33 class PackageDescription:
34 def __init__ (self, basePath, statement, testLogs, gitStatus, gitLog, patches, summary, conformVersion, conformOs, otherItems):
35 self.basePath = basePath
36 self.statement = statement
37 self.testLogs = testLogs
38 self.gitStatus = gitStatus
40 self.patches = patches
41 self.summary = summary
42 self.otherItems = otherItems
43 self.conformVersion = conformVersion
44 self.conformOs = conformOs
46 def getPackageDescription (packagePath):
47 allItems = os.listdir(packagePath)
59 if fnmatch(item, STATEMENT_PATTERN):
60 assert statement == None
62 elif fnmatch(item, TEST_LOG_PATTERN):
64 elif fnmatch(item, GIT_STATUS_PATTERN):
65 gitStatus.append(item)
66 elif fnmatch(item, GIT_LOG_PATTERN):
67 gitLog.append((item, '.'))
68 elif fnmatch(item, PATCH_PATTERN):
70 elif fnmatch(item, SUMMARY_PATTERN):
71 assert summary == None
74 otherItems.append(item)
76 return PackageDescription(packagePath, statement, testLogs, gitStatus, gitLog, patches, summary, conformVersion, conformOs, otherItems)