File: python-startup.py

package info (click to toggle)
dia 0.97.3%2Bgit20160930-9
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 54,372 kB
  • sloc: ansic: 155,065; xml: 16,326; python: 6,641; cpp: 4,935; makefile: 3,833; sh: 540; perl: 137; sed: 19
file content (34 lines) | stat: -rw-r--r-- 981 bytes parent folder | download | duplicates (3)
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
34
import sys, os
import dia

# Please don't include pygtk or gtk here. There
# are quite some PyDia plug-ins which don't require
# i.e. dont have any (Py)Gtk code

loaded = []

def load(plugindir):
	global loaded
	if os.path.isdir(plugindir):
		sys.path.insert(0, plugindir)
		for file in os.listdir(plugindir):
			if file[-3:] == '.py' and file[:-3] not in loaded:
				try:
					__import__(file[:-3])
					loaded.append(file[:-3])
				except Exception as e:
					sys.stderr.write('could not import %s [%s]\n' % (file, e))

# import any python plugins from the user ...
if not os.environ.has_key('HOME'):
	os.environ['HOME'] = os.pathsep + 'tmp'
# import all plugins found in user plugin dir
load(os.path.join(os.environ['HOME'], '.dia', 'python'))

# find system python plugin dir
curdir = os.path.dirname(__file__)
plugindir = os.path.join(curdir, 'python')
#If we're running from source there is no plugin dir
if not os.path.exists(plugindir):
	plugindir = curdir
load(plugindir)