Welcome to mirror list, hosted at ThFree Co, Russian Federation.

reloader.py « utils « mcf « modules « python « intern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2d7e2591ed2bcb7114e799bd084545ed0cfa8af1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import sys, string

class Reloader:
	'''
	Class allows for reloading all modules imported
	after the instance is created. Normally you will
	use this by doing:
		import <anything you don't want reloaded>
		from mcf.utils import reloader
		<do testing and rewriting>
		reloader.go()
	'''
	def __init__(self):
		self.keys = sys.modules.keys()
	def __call__(self, *args, **namedargs):
		done = []
		for key, val in sys.modules.items():
			if key not in self.keys:
				try:
					reload( val )
					done.append( key )
				except (ImportError):
					print '''Couldn't reload module:''', key
				except (TypeError): # for None's
					# is a flag to prevent reloading
					pass
		if done:
			print '''Reloaded:''', string.join( done, ', ')
		else:
			print '''No modules reloaded'''

# the default reloader...
go = Reloader()