install.py

changeset 1115
3032cc87dee2
parent 945
8cd4d08fa9f6
child 1130
3e9f0330f833
equal deleted inserted replaced
1114:a4dad1fff348 1115:3032cc87dee2
202 os.chmod(wname, 0o755) 202 os.chmod(wname, 0o755)
203 203
204 return wname 204 return wname
205 205
206 206
207 def copyTree(src, dst, filters, excludeDirs=[]): 207 def copyTree(src, dst, filters, excludeDirs=[], excludePatterns=[]):
208 """ 208 """
209 Copy Python, translation, documentation, wizards configuration, 209 Copy Python, translation, documentation, wizards configuration,
210 designer template files and DTDs of a directory tree. 210 designer template files and DTDs of a directory tree.
211 211
212 @param src name of the source directory 212 @param src name of the source directory
213 @param dst name of the destination directory 213 @param dst name of the destination directory
214 @param filters list of filter pattern determining the files to be copied 214 @param filters list of filter pattern determining the files to be copied
215 @param excludeDirs list of (sub)directories to exclude from copying 215 @param excludeDirs list of (sub)directories to exclude from copying
216 @keyparam excludePatterns list of filter pattern determining the files to be skipped
216 """ 217 """
217 try: 218 try:
218 names = os.listdir(src) 219 names = os.listdir(src)
219 except OSError: 220 except OSError:
220 return # ignore missing directories (most probably the i18n directory) 221 return # ignore missing directories (most probably the i18n directory)
221 222
222 for name in names: 223 for name in names:
223 srcname = os.path.join(src, name) 224 skipIt = False
224 dstname = os.path.join(dst, name) 225 for excludePattern in excludePatterns:
225 for filter in filters: 226 if fnmatch.fnmatch(name, excludePattern):
226 if fnmatch.fnmatch(srcname, filter): 227 skipIt = True
227 if not os.path.isdir(dst):
228 os.makedirs(dst)
229 shutil.copy2(srcname, dstname)
230 break 228 break
231 else: 229 if not skipIt:
232 if os.path.isdir(srcname) and not srcname in excludeDirs: 230 srcname = os.path.join(src, name)
233 copyTree(srcname, dstname, filters) 231 dstname = os.path.join(dst, name)
232 for filter in filters:
233 if fnmatch.fnmatch(srcname, filter):
234 if not os.path.isdir(dst):
235 os.makedirs(dst)
236 shutil.copy2(srcname, dstname)
237 break
238 else:
239 if os.path.isdir(srcname) and not srcname in excludeDirs:
240 copyTree(srcname, dstname, filters, excludePatterns=excludePatterns)
234 241
235 242
236 def createGlobalPluginsDir(): 243 def createGlobalPluginsDir():
237 """ 244 """
238 Create the global plugins directory, if it doesn't exist. 245 Create the global plugins directory, if it doesn't exist.
383 if os.path.exists(configName + 'c'): 390 if os.path.exists(configName + 'c'):
384 shutil.copy(configName + 'c', modDir) 391 shutil.copy(configName + 'c', modDir)
385 392
386 # copy the various parts of eric5 393 # copy the various parts of eric5
387 copyTree(sourceDir, cfg['ericDir'], ['*.py', '*.pyc', '*.pyo', '*.pyw'], 394 copyTree(sourceDir, cfg['ericDir'], ['*.py', '*.pyc', '*.pyo', '*.pyw'],
388 ['{1}{0}Examples'.format(os.sep, sourceDir)]) 395 ['{1}{0}Examples'.format(os.sep, sourceDir)],
396 excludePatterns=["eric5config.py*"])
389 copyTree(sourceDir, cfg['ericDir'], ['*.rb'], 397 copyTree(sourceDir, cfg['ericDir'], ['*.rb'],
390 ['{1}{0}Examples'.format(os.sep, sourceDir)]) 398 ['{1}{0}Examples'.format(os.sep, sourceDir)])
391 copyTree('{1}{0}Plugins'.format(os.sep, sourceDir), 399 copyTree('{1}{0}Plugins'.format(os.sep, sourceDir),
392 '{0}{1}Plugins'.format(cfg['ericDir'], os.sep), 400 '{0}{1}Plugins'.format(cfg['ericDir'], os.sep),
393 ['*.png', '*.style']) 401 ['*.png', '*.style'])

eric ide

mercurial