buildframework/helium/sf/python/pythoncore/lib/ats3/parsers.py
changeset 628 7c4a911dc066
parent 588 c7c26511138f
child 645 b8d81fa19e7d
equal deleted inserted replaced
588:c7c26511138f 628:7c4a911dc066
    19 #Description:
    19 #Description:
    20 #===============================================================================
    20 #===============================================================================
    21 
    21 
    22 """ The ATS related parsers """
    22 """ The ATS related parsers """
    23 
    23 
    24 
       
    25 # pylint: disable-msg=W0142,W0102
       
    26 # pylint: disable-msg=C0302
       
    27 # pylint: disable-msg=R0201,R0912,R0915,R0911,R0902
       
    28 
    24 
    29 #W0142 => * and ** were used
    25 #W0142 => * and ** were used
    30 #W0102 => Dangerous default value [] as argument
    26 #W0102 => Dangerous default value [] as argument
    31 #C0302 => Too many lines
    27 #C0302 => Too many lines
    32 #R* remove during refactoring
    28 #R* remove during refactoring
    68     """
    64     """
    69 
    65 
    70     def __init__(self):
    66     def __init__(self):
    71         self.path_to_build = ""
    67         self.path_to_build = ""
    72 
    68 
    73     def get_cpp_output(self, bld_path = None, output_parameter = "n", imacros = None):
    69     def get_cpp_output(self, bld_path = None, output_parameter = "n", imacros = None, bld_drive=None):
    74         """
    70         """
    75         To clean out conditionals from the compilation it is necessary to 
    71         To clean out conditionals from the compilation it is necessary to 
    76         use C preprocessing to clean out those.
    72         use C preprocessing to clean out those.
    77         
    73         
    78         If ('n' - normal) output is chosen, parser returns list of paths
    74         If ('n' - normal) output is chosen, parser returns list of paths
    88         if "bld.inf" in str(bld_path).lower():
    84         if "bld.inf" in str(bld_path).lower():
    89             os.chdir(os.path.normpath(os.path.join(bld_path, os.pardir)))
    85             os.chdir(os.path.normpath(os.path.join(bld_path, os.pardir)))
    90         else:
    86         else:
    91             os.chdir(os.path.normpath(os.path.join(bld_path)))
    87             os.chdir(os.path.normpath(os.path.join(bld_path)))
    92             
    88             
    93         if imacros is not None:
    89         if imacros and bld_drive:
    94             includedir = os.path.join(os.path.splitdrive(bld_path)[0] + os.sep, 'epoc32', 'include')
    90             includedir = os.path.join(bld_drive + os.sep, 'epoc32', 'include')
    95             command = r"cpp -imacros %s -I %s bld.inf" % (str(imacros), includedir)
    91             command = r"cpp -imacros %s -I %s bld.inf" % (str(imacros), includedir)
    96         else:
    92         else:
    97             command = u"cpp bld.inf"
    93             command = u"cpp bld.inf"
    98         
    94         
    99         process = subprocess.Popen(command, shell = True, stdout = subprocess.PIPE)
    95         process = subprocess.Popen(command, shell = True, stdout = subprocess.PIPE)
   196                 #if harness == "": harness = None
   192                 #if harness == "": harness = None
   197                 test_sets[t_case[1]]['content'][t_case[1]]['type'] = mmp_parser.get_dll_type(t_case[1])
   193                 test_sets[t_case[1]]['content'][t_case[1]]['type'] = mmp_parser.get_dll_type(t_case[1])
   198                 test_sets[t_case[1]]['content'][t_case[1]]['harness'] = harness
   194                 test_sets[t_case[1]]['content'][t_case[1]]['harness'] = harness
   199                 test_sets[t_case[1]]['content'][t_case[1]]['pkg_files'] = pkg_parser.get_pkg_files(t_case[1], False)
   195                 test_sets[t_case[1]]['content'][t_case[1]]['pkg_files'] = pkg_parser.get_pkg_files(t_case[1], False)
   200                 test_sets[t_case[1]]['content'][t_case[1]]['mmp_files'] = bld_parser.get_test_mmp_files(t_case[1], False)
   196                 test_sets[t_case[1]]['content'][t_case[1]]['mmp_files'] = bld_parser.get_test_mmp_files(t_case[1], False)
       
   197                 test_sets[t_case[1]]['content'][t_case[1]]['dll_files'] = mmp_parser.get_dll_files(t_case[1])
   201             else:
   198             else:
   202                 for key, value in test_sets.items():
   199                 for key, value in test_sets.items():
   203                     if t_case[0] in value['content'].keys():
   200                     if t_case[0] in value['content'].keys():
   204                         harness = mmp_parser.get_harness(t_case[1])
   201                         harness = mmp_parser.get_harness(t_case[1])
   205                         if harness is "" or harness in test_sets[key]['content'][t_case[0]]['harness']:
   202                         if harness is "" or harness in test_sets[key]['content'][t_case[0]]['harness']:
   206                             test_sets[key]['content'][t_case[1]] = {}
   203                             test_sets[key]['content'][t_case[1]] = {}
   207                             test_sets[key]['content'][t_case[1]]['type'] = mmp_parser.get_dll_type(t_case[1])
   204                             test_sets[key]['content'][t_case[1]]['type'] = mmp_parser.get_dll_type(t_case[1])
   208                             test_sets[key]['content'][t_case[1]]['harness'] = harness
   205                             test_sets[key]['content'][t_case[1]]['harness'] = harness
   209                             test_sets[key]['content'][t_case[1]]['pkg_files'] = pkg_parser.get_pkg_files(t_case[1], False)
   206                             test_sets[key]['content'][t_case[1]]['pkg_files'] = pkg_parser.get_pkg_files(t_case[1], False)
   210                             test_sets[key]['content'][t_case[1]]['mmp_files'] = bld_parser.get_test_mmp_files(t_case[1], False)
   207                             test_sets[key]['content'][t_case[1]]['mmp_files'] = bld_parser.get_test_mmp_files(t_case[1], False)
       
   208                             test_sets[key]['content'][t_case[1]]['dll_files'] = mmp_parser.get_dll_files(t_case[1])
   211                         else:
   209                         else:
   212                             test_sets[t_case[1]] = {}
   210                             test_sets[t_case[1]] = {}
   213                             test_sets[t_case[1]]['content'] = {}
   211                             test_sets[t_case[1]]['content'] = {}
   214                             test_sets[t_case[1]]['content'][t_case[1]] = {}
   212                             test_sets[t_case[1]]['content'][t_case[1]] = {}
   215                             test_sets[t_case[1]]['content'][t_case[1]]['type'] = mmp_parser.get_dll_type(t_case[1])
   213                             test_sets[t_case[1]]['content'][t_case[1]]['type'] = mmp_parser.get_dll_type(t_case[1])
   216                             test_sets[t_case[1]]['content'][t_case[1]]['harness'] = harness
   214                             test_sets[t_case[1]]['content'][t_case[1]]['harness'] = harness
   217                             test_sets[t_case[1]]['content'][t_case[1]]['pkg_files'] = pkg_parser.get_pkg_files(t_case[1], False)
   215                             test_sets[t_case[1]]['content'][t_case[1]]['pkg_files'] = pkg_parser.get_pkg_files(t_case[1], False)
   218                             test_sets[t_case[1]]['content'][t_case[1]]['mmp_files'] = bld_parser.get_test_mmp_files(t_case[1], False)
   216                             test_sets[t_case[1]]['content'][t_case[1]]['mmp_files'] = bld_parser.get_test_mmp_files(t_case[1], False)
       
   217                             test_sets[t_case[1]]['content'][t_case[1]]['dll_files'] = mmp_parser.get_dll_files(t_case[1])
   219 
   218 
   220         os.chdir(temp_path)
   219         os.chdir(temp_path)
   221         if test_sets == {}:
   220         if test_sets == {}:
   222             for itm in output_list:
   221             for itm in output_list:
   223                 _logger.debug(itm)
   222                 _logger.debug(itm)
   428         get_dll_type("c:\path\to\mmp")
   427         get_dll_type("c:\path\to\mmp")
   429         
   428         
   430         if mmp file is not given, the function will try to find the file(s) on the given location with extension ".mmp"
   429         if mmp file is not given, the function will try to find the file(s) on the given location with extension ".mmp"
   431         """
   430         """
   432         return self.read_information_from_mmp(path_to_mmp, 7)
   431         return self.read_information_from_mmp(path_to_mmp, 7)
       
   432     
       
   433     def get_dll_files(self, path_to_mmp = None):
       
   434         """
       
   435         Returns the dll files and their harness of the test component        
       
   436         """
       
   437         return self.read_information_from_mmp(path_to_mmp, 8)
       
   438 
       
   439     def get_mmp_harness(self, libraries=None):
       
   440         """
       
   441         Harness was actually calculated at the test component level, it has to be calculated at the
       
   442         mmp file level and it has to be stored as "dll file":"harness" in a dictionary so that while writing
       
   443         execute step in test.xml; the dlls which doesn't have any harness are skipped from being written. 
       
   444         
       
   445         This method identifies the harness from the given list of list libraries found in mmp file under LIBRARY tag(s)
       
   446         Returns the harness of the libraries in mmp file        
       
   447         """        
       
   448         stif = False
       
   449         eunit = False
       
   450         stifunit = False
       
   451         generic = False
       
   452         if libraries:
       
   453             if "stiftestinterface.lib" in libraries:
       
   454                 stif = True
       
   455             if "eunit.lib" in libraries or "qttest.lib" in libraries:
       
   456                 eunit = True
       
   457             if "stifunit.lib" in libraries:
       
   458                 stifunit = True
       
   459             elif "testexecuteutils.lib" in libraries or 'testframeworkclient.lib' in libraries or 'rtest' in libraries or 'symbianunittestfw.lib' in libraries:
       
   460                 generic = True
       
   461         
       
   462         return self.select_harness(generic, stif, eunit, stifunit)           
       
   463 
       
   464 
       
   465     def select_harness(self, generic, stif, eunit, stifunit):
       
   466         """
       
   467         return the harness based on the Test Framework
       
   468         """
       
   469         harness = ""
       
   470         if generic:
       
   471             harness = "GENERIC"
       
   472         elif stif and eunit:
       
   473             #_logger.warning("both eunit.lib and stiftestinterface.lib listed in mmp file - choosing STIF.")
       
   474             harness = "STIF"
       
   475         elif stif and not eunit:
       
   476             harness = "STIF"
       
   477         elif eunit and not stif:
       
   478             harness = "EUNIT"
       
   479         elif stifunit and not stif and not eunit:
       
   480             harness = "STIFUNIT"
       
   481 
       
   482         return harness
       
   483 
       
   484 
   433 
   485 
   434     def read_information_from_mmp(self, path_to_mmp, flag = 0):
   486     def read_information_from_mmp(self, path_to_mmp, flag = 0):
   435         """
   487         """
   436         Returns wanted information - user can define 
   488         Returns wanted information - user can define 
   437         the wanted information level by setting a flag
   489         the wanted information level by setting a flag
   442         3 - targetfilename
   494         3 - targetfilename
   443         4 - filetype
   495         4 - filetype
   444         5 - libraries
   496         5 - libraries
   445         6 - harness (in case of test component)
   497         6 - harness (in case of test component)
   446         7 - mmpfilename
   498         7 - mmpfilename
       
   499         8 - dictionary of dll files and their harness 
   447         """
   500         """
   448 
   501 
   449 
   502 
   450         filename = ""
   503         filename = ""
   451         filetype = ""
   504         filetype = ""
   452         dll_type = ""
   505         dll_type = ""
       
   506         libs = []
       
   507         dll_files = {}
   453         libraries = []
   508         libraries = []
   454         lst_mmp_paths = []
   509         lst_mmp_paths = []
   455         harness = ""
       
   456         stif = False
       
   457         eunit = False
       
   458         stifunit = False
       
   459         tef = False
       
   460         self.path_to_mmp = path_to_mmp
   510         self.path_to_mmp = path_to_mmp
   461         try:
   511         try:
   462             if isinstance(path_to_mmp, list):
   512             if isinstance(path_to_mmp, list):
   463                 lst_mmp_paths = self.path_to_mmp
   513                 lst_mmp_paths = self.path_to_mmp
   464             else:    
   514             else:    
   470                         lst_mmp_paths = lst_mmp_paths + self.mmp_files
   520                         lst_mmp_paths = lst_mmp_paths + self.mmp_files
   471                 else:
   521                 else:
   472                     lst_mmp_paths.append(self.path_to_mmp)
   522                     lst_mmp_paths.append(self.path_to_mmp)
   473 
   523 
   474             for mmp in lst_mmp_paths:
   524             for mmp in lst_mmp_paths:
       
   525                 mmp_harness = ""
   475                 mmp_file = open(mmp, 'r')
   526                 mmp_file = open(mmp, 'r')
   476                 for line in mmp_file:
   527                 for line in mmp_file:
   477                     if re.match(r"\A(target\s).*([.]\w+)", line.lower().strip()):
   528                     if re.match(r"\A(target\s).*([.]\w+)", line.lower().strip()):
   478                         found = re.findall(r"\Atarget[\s]*(\w+[.]\w+)", line.lower())
   529                         found = re.findall(r"\Atarget[\s]*(\w+[.]\w+)", line.lower())
   479                         if found:
   530                         if found:
   480                             filename = found[0]
   531                             filename = found[0]
   481                     elif re.match(r"\A(targettype\s).*", line.lower().strip()):
   532                     elif re.match(r"\A(targettype\s).*", line.lower().strip()):
   482                         found = re.findall(r"\Atargettype[\s]*(\w+)", line.lower())
   533                         found = re.findall(r"\Atargettype[\s]*(\w+)", line.lower())
   483                         if found:
   534                         if found:
   484                             filetype = found[0]                       
   535                             filetype = found[0]
   485 
   536                 libs = []                                       
   486                 libraries = libraries + re.findall(r"\b(\w+[.]lib)\b", mmp.text().lower())
   537                 libs = re.findall(r"\b(\w+[.]lib)\b", mmp.text().lower())       
       
   538                 # get harness for a mmp/dll file         
       
   539                 mmp_harness = self.get_mmp_harness(libs)
       
   540                 # store the harness of every dll file, later to be used while writing test.xml execute steps
       
   541                 dll_files[filename] = mmp_harness
       
   542                 libraries = libraries + libs
   487                 if '//rtest' in mmp.text().lower() or '* rtest' in mmp.text().lower() or '// rtest' in mmp.text().lower():
   543                 if '//rtest' in mmp.text().lower() or '* rtest' in mmp.text().lower() or '// rtest' in mmp.text().lower():
   488                     libraries.append('rtest')
   544                     libraries.append('rtest')
   489             
   545                     
   490             if libraries:
   546             # get harness for one (sub)component file
   491                 if "stiftestinterface.lib" in libraries:
   547             harness = self.get_mmp_harness(libraries)            
   492                     stif = True
       
   493                 if "eunit.lib" in libraries or "qttest.lib" in libraries:
       
   494                     eunit = True
       
   495                 if "stifunit.lib" in libraries:
       
   496                     stifunit = True
       
   497                 elif "testexecuteutils.lib" in libraries or 'testframeworkclient.lib' in libraries or 'rtest' in libraries:
       
   498                     tef = True
       
   499 
       
   500             if tef:
       
   501                 harness = "GENERIC"
       
   502             elif stif and eunit:
       
   503                 #_logger.warning("both eunit.lib and stiftestinterface.lib listed in mmp file - choosing STIF.")
       
   504                 harness = "STIF"
       
   505             elif stif and not eunit:
       
   506                 harness = "STIF"
       
   507             elif eunit and not stif:
       
   508                 harness = "EUNIT"
       
   509             elif stifunit and not stif and not eunit:
       
   510                 harness = "STIFUNIT"
       
   511 
   548 
   512             if harness is "":
   549             if harness is "":
   513                 dll_type = "dependent"
   550                 dll_type = "dependent"
   514             elif harness is "EUNIT":
   551             elif harness is "EUNIT":
   515                 dll_type = "executable"
   552                 dll_type = "executable"
   516             elif harness is "STIF":
   553             elif harness is "STIF":
   517                 dll_type = "executable"
   554                 dll_type = "executable"
   518 
   555 
   519         except:
   556         except:
   520             traceback.print_exc()
   557             traceback.print_exc()
   521         finally:
   558         else:
       
   559             returnvals = None
   522             if flag == 0:
   560             if flag == 0:
   523                 return (filename, filetype, libraries, harness)
   561                 returnvals = (filename, filetype, libraries, harness)
   524             elif flag == 1:
   562             elif flag == 1:
   525                 return (filename, filetype, libraries)
   563                 returnvals = (filename, filetype, libraries)
   526             elif flag == 2:
   564             elif flag == 2:
   527                 return (filename, filetype)
   565                 returnvals = (filename, filetype)
   528             elif flag == 3:
   566             elif flag == 3:
   529                 return filename
   567                 returnvals = filename
   530             elif flag == 4:
   568             elif flag == 4:
   531                 return filetype
   569                 returnvals = filetype
   532             elif flag == 5:
   570             elif flag == 5:
   533                 return libraries
   571                 returnvals = libraries
   534             elif flag == 6:
   572             elif flag == 6:
   535                 return harness
   573                 returnvals = harness
   536             elif flag == 7:
   574             elif flag == 7:
   537                 return dll_type
   575                 returnvals = dll_type
       
   576             elif flag == 8:
       
   577                 returnvals = dll_files
       
   578             return returnvals
   538 
   579 
   539 class PkgFileParser(object):
   580 class PkgFileParser(object):
   540     """
   581     """
   541     Parses .pkg files. Returns a list of:
   582     Parses .pkg files. Returns a list of:
   542       a. src path of the file
   583       a. src path of the file
   543       b. dst path on the phone
   584       b. dst path on the phone
   544       c. type of the file
   585       c. type of the file
   545     for every file in the pkg file
   586     for every file in the pkg file
   546     """
   587     """
   547 
   588 
   548     def __init__(self, bldpath, platform = None, specific_pkg = None, drive=''):
   589     def __init__(self, bldpath = None, platform = None, specific_pkg = None, drive=''):
   549         self.platform = platform
   590         self.platform = platform
   550         self.build_platform = None
   591         self.build_platform = None
       
   592         self.build_target = None
   551         if self.platform is not None and "_" in self.platform:
   593         if self.platform is not None and "_" in self.platform:
   552             plat_tar = re.search(r"(.*)_(.*).pkg", self.platform)
   594             plat_tar = re.search(r"(.*)_(.*).pkg", self.platform)
   553             self.build_platform, self.build_target = plat_tar.groups() 
   595             self.build_platform, self.build_target = plat_tar.groups() 
   554         self.drive = drive
   596         self.drive = drive
   555         self._files = []
   597         self._files = []
   617 
   659 
   618         self.drive = drive
   660         self.drive = drive
   619         self.exclude = exclude
   661         self.exclude = exclude
   620         self._files = []
   662         self._files = []
   621 
   663 
   622         if type(location) is not list:
   664         if type(location).__name__ != 'list':
   623             locations = [location]
   665             locations = [location]
   624         else:
   666         else:
   625             locations = location
   667             locations = location
   626         
   668         
   627         for _file_ in locations:
   669         for _file_ in locations:
   628             
   670             
   629             #if location is already a file
   671             #if location is already a file
   630             if ".pkg" in str(_file_).lower():
   672             if ".pkg" in str(_file_).lower():
   631                 self._files = _file_
   673                 self._files.append(_file_)
   632             else:
   674             else:
   633                 self.location = path(_file_)
   675                 self.location = path(_file_)
   634 
   676 
   635                 if not self.location.exists():
   677                 if not self.location.exists():
   636                     continue
   678                     continue
   655         #searches for the file path (src and dst) in the pkg file
   697         #searches for the file path (src and dst) in the pkg file
   656         #e.g.: "..\conf\VCXErrors.inc"-"C:\TestFramework\VCXErrors.inc"
   698         #e.g.: "..\conf\VCXErrors.inc"-"C:\TestFramework\VCXErrors.inc"
   657         result = re.search(r'^\s*"(.*?)".*?-.*?"(.*?)"', pkg_line)
   699         result = re.search(r'^\s*"(.*?)".*?-.*?"(.*?)"', pkg_line)
   658 
   700 
   659         if result is None:
   701         if result is None:
       
   702             if pkg_line.startswith('"'):
       
   703                 _logger.warning(pkg_line.strip() + ' line not valid pkg format in ' + pkg_file)
   660             return None
   704             return None
   661         val1, val2 = result.groups()
   705         val1, val2 = result.groups()
   662 
   706 
   663         if val1 != "":
   707         if val1 != "":
   664             
       
   665             #replacing delimiters (${platform} and ${target}) in PKG file templates, 
   708             #replacing delimiters (${platform} and ${target}) in PKG file templates, 
   666             #for instance, QT tests PKG files have delimeters 
   709             #for instance, QT tests PKG files have delimeters 
   667             if "$(platform)" in val1.lower() and self.build_platform is not None:
   710             if "$(platform)" in val1.lower() and self.build_platform is not None:
   668                 val1 = val1.lower().replace("$(platform)", self.build_platform)
   711                 val1 = val1.lower().replace("$(platform)", self.build_platform)
   669             if "$(target)" in val1.lower() and self.build_target is not None:
   712             if "$(target)" in val1.lower() and self.build_target is not None:
   670                 val1 = val1.lower().replace("$(target)", self.build_target)
   713                 val1 = val1.lower().replace("$(target)", self.build_target)
   671 
   714 
   672             if path.isabs(path(val1).normpath()):
   715             #For MATTI PKG files in which location of the data files are unknown or can be changed
   673                 map_src = os.path.normpath(os.path.join(self.drive, val1))
   716             if "[PKG_LOC]" in val1.upper():
   674             elif re.search(r"\A\w", val1, 1):
   717                 val1 = val1.replace("[PKG_LOC]", self.pkg_file_path)
   675                 map_src = str(path.joinpath(self.pkg_file_path + os.sep, os.path.normpath(val1)).normpath())
   718 
       
   719             if os.path.exists(val1):
       
   720                 map_src = os.path.abspath(val1)
   676             else:
   721             else:
   677                 map_src = str(path.joinpath(self.pkg_file_path, path(val1)).normpath())
   722                 if os.path.isabs(os.path.normpath(val1)):
   678             map_dst = str(path(val2).normpath())
   723                     map_src = os.path.normpath(os.path.join(self.drive, val1))
       
   724                 elif re.search(r"\A\w", val1, 1):
       
   725                     map_src = os.path.normpath(os.path.join(self.pkg_file_path + os.sep, os.path.normpath(val1)))
       
   726                 else:
       
   727                     map_src = os.path.normpath(os.path.join(self.pkg_file_path, val1))
       
   728             map_dst = os.path.normpath(val2)
   679         else:
   729         else:
   680             map_src, map_dst = val1, val2
   730             map_src, map_dst = val1, val2
   681         map_src = map_src.strip()
   731         map_src = map_src.strip()
   682         
   732         
   683         #replaces the characters with the drive letters
   733         #replaces the characters with the drive letters
   708                 file_type = "data" + ":%s" % _test_type_
   758                 file_type = "data" + ":%s" % _test_type_
   709             else:
   759             else:
   710                 if "qttest.lib" in _libraries_:
   760                 if "qttest.lib" in _libraries_:
   711                     file_type = "data" + ":qt:dependent" 
   761                     file_type = "data" + ":qt:dependent" 
   712                 else:
   762                 else:
   713                     file_type = "testmodule"
   763                     if 'symbianunittestfw.lib' in _libraries_:
       
   764                         file_type = "testmodule:sut"
       
   765                     else:
       
   766                         file_type = "testmodule"
   714                     
   767                     
   715         elif ext == 'exe' and 'rtest' in _libraries_:
   768         elif ext == 'exe' and 'rtest' in _libraries_:
   716             file_type = "testmodule:rtest"
   769             file_type = "testmodule:rtest"
   717         elif ext == "exe":
   770         elif ext == "exe":
   718             if _test_type_ == "dependent":
   771             if _test_type_ == "dependent":
   729             file_type = "trace_init"
   782             file_type = "trace_init"
   730         elif ext == "pmd":
   783         elif ext == "pmd":
   731             file_type = "pmd"
   784             file_type = "pmd"
   732         elif ext == "script":
   785         elif ext == "script":
   733             if "testframeworkclient.lib" in _libraries_:
   786             if "testframeworkclient.lib" in _libraries_:
   734                 file_type = "testscript:mtf"
   787                 file_type = "testscript:mtf:testframework.exe"
   735             else:
   788             else:
   736                 file_type = "testscript"
   789                 file_type = "testscript:testexecute.exe"
       
   790             if ',' in pkg_line:
       
   791                 exename = pkg_line.split(',')[1].strip()
       
   792                 if exename == 'install_only':
       
   793                     file_type = "data"
       
   794                 elif exename == 'testframework.exe':
       
   795                     file_type = "testscript:mtf:" + exename
       
   796                 elif exename == 'testexecute.exe':
       
   797                     file_type = "testscript:" + exename
       
   798                 else:
       
   799                     if "testframeworkclient.lib" in _libraries_:
       
   800                         file_type = "testscript:mtf:" + exename
       
   801                     else:
       
   802                         file_type = "testscript:" + exename
   737         else:
   803         else:
   738             file_type = "data"
   804             file_type = "data"
   739 
   805 
   740         if not map_src or map_src == "." or not map_dst or map_dst == ".":
   806         if not map_src or map_src == "." or not map_dst or map_dst == ".":
   741             return None
   807             return None
   745         return path(map_src).normpath(), path(map_dst).normpath(), file_type, pkg_file
   811         return path(map_src).normpath(), path(map_dst).normpath(), file_type, pkg_file
   746 
   812 
   747     def read_pkg_file(self, pkg_files):
   813     def read_pkg_file(self, pkg_files):
   748         """Reads contents of PKG file"""
   814         """Reads contents of PKG file"""
   749         pkg_paths = []
   815         pkg_paths = []
       
   816         if type(pkg_files).__name__ != "list":
       
   817             pkg_files = [pkg_files]
       
   818             
   750         for pkg_file in pkg_files:
   819         for pkg_file in pkg_files:
   751             if not os.path.exists( pkg_file ):
   820             if not os.path.exists( pkg_file ):
   752                 _logger.error("No PKG -file in path specified")
   821                 _logger.error("No PKG -file in path specified")
   753                 continue
   822                 continue
   754             else:
   823             else:
   756                 try:
   825                 try:
   757                     lines = file1.readlines()
   826                     lines = file1.readlines()
   758                 except UnicodeError:
   827                 except UnicodeError:
   759                     file1 = open(pkg_file, 'r')
   828                     file1 = open(pkg_file, 'r')
   760                     lines = file1.readlines()
   829                     lines = file1.readlines()
   761                 pkg_file_path = path(os.path.dirname(pkg_file))
   830 
       
   831                 pkg_file_path = path((pkg_file.rsplit(os.sep, 1))[0])
   762                 for line in lines:
   832                 for line in lines:
   763                     pkg_path = self.__map_pkg_path(line, pkg_file_path, os.path.basename(pkg_file))
   833                     pkg_path = self.__map_pkg_path(line, pkg_file_path, os.path.basename(pkg_file))
   764                     if pkg_path is None:
   834                     if pkg_path is None:
   765                         continue
   835                         continue
   766                     else:
   836                     else: