1423
1424
def supports_mapi():
1424
1425
"""Return True if we can use MAPI to launch a mail client."""
1425
1426
return sys.platform == "win32"
1429
def resource_string(package, resource_name):
1430
"""Load a resource from a package and return it as a string.
1432
Note: Only packages that start with bzrlib are currently supported.
1434
This is designed to be a lightweight implementation of resource
1435
loading in a way which is API compatible with the same API from
1437
http://peak.telecommunity.com/DevCenter/PkgResources#basic-resource-access.
1438
If and when pkg_resources becomes a standard library, this routine
1441
# Check package name is within bzrlib
1442
if package == "bzrlib":
1443
resource_relpath = resource_name
1444
elif package.startswith("bzrlib."):
1445
package = package[len("bzrlib."):].replace('.', os.sep)
1446
resource_relpath = pathjoin(package, resource_name)
1448
raise errors.BzrError('resource package %s not in bzrlib' % package)
1450
# Map the resource to a file and read its contents
1451
base = dirname(bzrlib.__file__)
1452
if getattr(sys, 'frozen', None): # bzr.exe
1453
base = abspath(pathjoin(base, '..', '..'))
1454
filename = pathjoin(base, resource_relpath)
1455
return open(filename, 'rU').read()