Skip to content

Commit 0e9b38f

Browse files
committed
Officially 4.1
Extension system has been added to the core and tested
1 parent ea601f7 commit 0e9b38f

File tree

1 file changed

+35
-33
lines changed

1 file changed

+35
-33
lines changed

pyrevitlib/pyrevit/__init__.py

+35-33
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,41 @@
88

99
# noinspection PyUnresolvedReferences
1010
from System.Diagnostics import Process
11+
# noinspection PyUnresolvedReferences
12+
from System.IO import IOException
13+
14+
15+
PYREVIT_ADDON_NAME = 'pyRevit'
16+
VERSION_MAJOR = 4
17+
VERSION_MINOR = 1
18+
19+
20+
# ----------------------------------------------------------------------------------------------------------------------
21+
# Base Exceptions
22+
# ----------------------------------------------------------------------------------------------------------------------
23+
TRACEBACK_TITLE = 'Traceback:'
24+
25+
26+
# General Exceptions
27+
class PyRevitException(Exception):
28+
"""Base class for all pyRevit Exceptions.
29+
Parameters args and message are derived from Exception class.
30+
"""
31+
def __str__(self):
32+
sys.exc_type, sys.exc_value, sys.exc_traceback = sys.exc_info()
33+
try:
34+
tb_report = traceback.format_tb(sys.exc_traceback)[0]
35+
if self.args:
36+
message = self.args[0]
37+
return '{}\n\n{}\n{}'.format(message, TRACEBACK_TITLE, tb_report)
38+
else:
39+
return '{}\n{}'.format(TRACEBACK_TITLE, tb_report)
40+
except:
41+
return Exception.__str__(self)
42+
43+
44+
class PyRevitIOError(PyRevitException):
45+
pass
1146

1247

1348
# ----------------------------------------------------------------------------------------------------------------------
@@ -165,12 +200,6 @@ def _find_home_directory():
165200
# default extension extensions folder
166201
EXTENSIONS_DEFAULT_DIR = op.join(HOME_DIR, 'extensions')
167202

168-
169-
PYREVIT_ADDON_NAME = 'pyRevit'
170-
VERSION_MAJOR = 4
171-
VERSION_MINOR = 0
172-
173-
174203
# user env paths
175204
USER_ROAMING_DIR = os.getenv('appdata')
176205
USER_SYS_TEMP = os.getenv('temp')
@@ -194,30 +223,3 @@ def _find_home_directory():
194223
PYREVIT_FILE_PREFIX = '{}_{}_{}'.format(PYREVIT_ADDON_NAME, HOST_APP.version, HOST_APP.username)
195224
PYREVIT_FILE_PREFIX_STAMPED = '{}_{}_{}_{}'.format(PYREVIT_ADDON_NAME,
196225
HOST_APP.version, HOST_APP.username, HOST_APP.proc_id)
197-
198-
# ----------------------------------------------------------------------------------------------------------------------
199-
# Base Exceptions
200-
# ----------------------------------------------------------------------------------------------------------------------
201-
TRACEBACK_TITLE = 'Traceback:'
202-
203-
204-
# General Exceptions
205-
class PyRevitException(Exception):
206-
"""Base class for all pyRevit Exceptions.
207-
Parameters args and message are derived from Exception class.
208-
"""
209-
def __str__(self):
210-
sys.exc_type, sys.exc_value, sys.exc_traceback = sys.exc_info()
211-
try:
212-
tb_report = traceback.format_tb(sys.exc_traceback)[0]
213-
if self.args:
214-
message = self.args[0]
215-
return '{}\n\n{}\n{}'.format(message, TRACEBACK_TITLE, tb_report)
216-
else:
217-
return '{}\n{}'.format(TRACEBACK_TITLE, tb_report)
218-
except:
219-
return Exception.__str__(self)
220-
221-
222-
class PyRevitIOError(PyRevitException):
223-
pass

0 commit comments

Comments
 (0)