File: scribes.in

package info (click to toggle)
scribes 0.3.3.3-4
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 6,512 kB
  • ctags: 4,045
  • sloc: python: 24,125; sh: 3,358; xml: 2,224; makefile: 255
file content (79 lines) | stat: -rw-r--r-- 2,617 bytes parent folder | download
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2005 Lateef Alabi-Oki
#
# This file is part of Scribes.
#
# Scribes is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Scribes is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Scribes; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

"""
This module initializes the text editor's server.

@author: Lateef Alabi-Oki
@organiation: The Scribes Project
@copyright: Copyright © 2005 Lateef Alabi-Oki
@license: GNU GPLv2 or Later
@contact: mystilleef@gmail.com
"""

# The Python library path is generated at build time.
INTERVAL = -1
RECURSIONLIMITMULTIPLIER = 1000000

def __set_vm_properties():
	"""
	Set virtual machine's (Python) system properties.
	"""
	from sys import setcheckinterval, getrecursionlimit, setrecursionlimit, setdlopenflags
	try:
		from dl import RTLD_LAZY, RTLD_GLOBAL
		setdlopenflags(RTLD_LAZY|RTLD_GLOBAL)
	except ImportError:
		pass
	global INTERVAL, RECURSIONLIMITMULTIPLIER
	setcheckinterval(INTERVAL)
	setrecursionlimit(getrecursionlimit() * RECURSIONLIMITMULTIPLIER)
	return

from sys import argv, path, settrace
__set_vm_properties()
python_path = "@python_path@"
path.insert(0, python_path)
from SCRIBES.Main import main

def traceit(frame, event, arg):
	from operator import ne
	if ne(event, "line"): return traceit
	try:
		lineno = frame.f_lineno
		filename = frame.f_globals["__file__"]
		if filename.endswith(".pyc") or filename.endswith(".pyo"):
			filename = filename[:-1]

		name = frame.f_globals["__name__"]
		if name.startswith("sre_") or name.startswith("posixpath") or name.startswith("gettext") \
			or name.startswith("locale") or name.startswith("re") or name.startswith("encoding") \
			or name.startswith("opcode") or name.startswith("token") or name.startswith("tokenize") \
			or name.startswith("UserDict") or name.startswith("problem_report"): return traceit
		from linecache import getline
		line = getline(filename, lineno)
		print "%s:%s: %s" % (name, lineno, line.rstrip())
	except KeyError:
		print "Keyerror"
	return traceit

if __name__ == "__main__":
	#settrace(traceit)
	main(argv[1:])