diff -r 7685cec9fd3c -r f2ddfa555b0f doc/api/python/archive.tools-pysrc.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/api/python/archive.tools-pysrc.html Fri Sep 11 11:54:49 2009 +0100 @@ -0,0 +1,905 @@ + + + + + archive.tools + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + Package archive :: + Module tools + + + + + + +
[hide private]
[frames] | no frames]
+
+

Source Code for Module archive.tools

+
+  1  #============================================================================  
+  2  #Name        : tools.py  
+  3  #Part of     : Helium  
+  4   
+  5  #Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+  6  #All rights reserved. 
+  7  #This component and the accompanying materials are made available 
+  8  #under the terms of the License "Eclipse Public License v1.0" 
+  9  #which accompanies this distribution, and is available 
+ 10  #at the URL "http://www.eclipse.org/legal/epl-v10.html". 
+ 11  # 
+ 12  #Initial Contributors: 
+ 13  #Nokia Corporation - initial contribution. 
+ 14  # 
+ 15  #Contributors: 
+ 16  # 
+ 17  #Description: 
+ 18  #=============================================================================== 
+ 19   
+ 20  """ Archiving operations. """ 
+ 21  import os 
+ 22  import logging 
+ 23  import buildtools 
+ 24  import codecs 
+ 25   
+ 26  _logger = logging.getLogger('archive') 
+ 27  #_logger.addHandler(logging.FileHandler('archive.log')) 
+ 28  #logging.basicConfig(level=logging.DEBUG) 
+ 29  logging.basicConfig() 
+ 30   
+
31 -class Tool(object): +
32 """ Tool abstract class. """ +
33 - def extension(self): +
34 """ This method should return the extension of the generated file. """ + 35 raise NotImplementedError() +
36 +
37 - def create_command(self, path, filename, manifests=None): +
38 """ This method should return an array of buildtools.Command. + 39 That list will get use to generate a build file (e.g make, ant). + 40 The list of command should support in parallel calling. + 41 """ + 42 raise NotImplementedError() +
43 + 44 +
45 -class SevenZipArchiver(Tool): +
46 """ Creates task definitions for executing 7zip archive operations.""" + 47 +
48 - def __init__(self): +
49 Tool.__init__(self) +
50 +
51 - def extension(self): +
52 """ Always return '.zip'. """ + 53 return '.zip' +
54 +
55 - def create_command(self, path, name, manifests=None): +
56 """ Returns a list of one command that will use 7za to archive the content.""" + 57 cmd = buildtools.Command('7za', path) + 58 cmd.addArg('a') + 59 cmd.addArg('-tzip') + 60 # Include all in the current directory by default, assuming that + 61 # an include file or specific includes will be given + 62 cmd.addArg(name + self.extension()) + 63 for manifest in manifests: + 64 cmd.addArg('@' + os.path.normpath(manifest)) + 65 return [cmd] +
66 + 67 +
68 -class ZipArchiver(Tool): +
69 """ Creates task definitions for executing zip archive operations.""" + 70 +
71 - def __init__(self): +
72 Tool.__init__(self) +
73 +
74 - def extension(self): +
75 """ Always return '.zip'. """ + 76 return '.zip' +
77 +
78 - def create_command(self, path, name, manifests=None): +
79 """ Returns a list of one command that will use zip to archive the content.""" + 80 cmd = buildtools.Command('zip', path) + 81 cmd.addArg('-R') + 82 cmd.addArg(name + self.extension()) + 83 # Include all in the current directory by default, assuming that + 84 # an include file or specific includes will be given + 85 cmd.addArg('.') + 86 for manifest in manifests: + 87 cmd.addArg('-i@' + os.path.normpath(manifest)) + 88 return [cmd] +
89 + 90 +
91 -class Remover(Tool): +
92 """ Creates task definitions for executing zip archive operations.""" +
93 - def __init__(self): +
94 Tool.__init__(self) +
95 +
96 - def extension(self): +
97 """ Always return '' """ + 98 return '' +
99 +
100 - def create_command(self, dummy_path, dummy_filename, manifests=None): +
101 """ Returns a list of one command that will use zip to archive the content.""" +102 cmds = [] +103 for manifest in manifests: +104 file_input = codecs.open(manifest, 'r', "utf-8" ) +105 for line in file_input.readlines(): +106 if line.strip() != "": +107 cmds.append(buildtools.Delete(filename=line.strip())) +108 file_input.close() +109 return cmds +
110 +111 +
112 -def get_tool(name): +
113 """ Return a tool using its id name. """ +114 constructor = TOOL_CONSTRUCTORS[name] +115 return constructor() +
116 +117 +118 TOOL_CONSTRUCTORS = {'zip': ZipArchiver, +119 '7za': SevenZipArchiver, +120 'remover': Remover} +121 +
+
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + +