Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pystache_custom
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
pystache_custom
Commits
4b8c7a70
Commit
4b8c7a70
authored
Dec 31, 2011
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjusted Locator.get_object_directory() to handle modules without '__file__'.
parent
921cd282
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
pystache/locator.py
+8
-3
No files found.
pystache/locator.py
View file @
4b8c7a70
...
@@ -48,12 +48,17 @@ class Locator(object):
...
@@ -48,12 +48,17 @@ class Locator(object):
"""
"""
Return the directory containing an object's defining class.
Return the directory containing an object's defining class.
Returns None if there is no such directory, for example if the
class was defined in an interactive Python session, or in a
doctest that appears in a text file (rather than a Python file).
"""
"""
module
=
sys
.
modules
[
obj
.
__module__
]
module
=
sys
.
modules
[
obj
.
__module__
]
# TODO: should we handle the case of __file__ not existing, for
if
not
hasattr
(
module
,
'__file__'
):
# example when using the interpreter or using a module in the
# TODO: add a unit test for this case.
# standard library)?
return
None
path
=
module
.
__file__
path
=
module
.
__file__
return
os
.
path
.
dirname
(
path
)
return
os
.
path
.
dirname
(
path
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment