mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-25 11:37:43 -10:00
Backed out changeset 056d9515483c (bug 1568277) Backed out changeset 632d943c947b (bug 1568277) Backed out changeset d7e8f80e2c85 (bug 1568277) Backed out changeset 7b59ed5d703d (bug 1568277) Backed out changeset f8b41cbaaf8e (bug 1568277) Backed out changeset 391a90f3f02b (bug 1568277) Backed out changeset d2b1d6c0a732 (bug 1568277) Backed out changeset cb35fd836621 (bug 1568277) Backed out changeset c8f797a19731 (bug 1568277) Backed out changeset 9b89f970d46b (bug 1568277)
28 lines
916 B
Python
28 lines
916 B
Python
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
from __future__ import absolute_import, print_function, unicode_literals
|
|
|
|
|
|
def find_object(path):
|
|
"""
|
|
Find a Python object given a path of the form <modulepath>:<objectpath>.
|
|
Conceptually equivalent to
|
|
|
|
def find_object(modulepath, objectpath):
|
|
import <modulepath> as mod
|
|
return mod.<objectpath>
|
|
"""
|
|
if path.count(':') != 1:
|
|
raise ValueError(
|
|
'python path {!r} does not have the form "module:object"'.format(path))
|
|
|
|
modulepath, objectpath = path.split(':')
|
|
obj = __import__(modulepath)
|
|
for a in modulepath.split('.')[1:]:
|
|
obj = getattr(obj, a)
|
|
for a in objectpath.split('.'):
|
|
obj = getattr(obj, a)
|
|
return obj
|