install.py

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

eric ide

mercurial