Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- #
- # Copyright 2007 Doug Hellmann.
- #
- #
- # All Rights Reserved
- #
- # Permission to use, copy, modify, and distribute this software and
- # its documentation for any purpose and without fee is hereby
- # granted, provided that the above copyright notice appear in all
- # copies and that both that copyright notice and this permission
- # notice appear in supporting documentation, and that the name of Doug
- # Hellmann not be used in advertising or publicity pertaining to
- # distribution of the software without specific, written prior
- # permission.
- #
- # DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- # NO EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- #
- """Retrieving data when there is no ZIP archive involved.
- """
- #end_pymotw_header
- import os
- import example_package
- # Find the directory containing the imported
- # package and build the data filename from it.
- pkg_dir = os.path.dirname(example_package.__file__)
- data_filename = os.path.join(pkg_dir, 'README.txt')
- # Find the prefix of pkg_dir that represents
- # the portion of the path that does not need
- # to be displayed.
- dir_prefix = os.path.abspath(os.path.dirname(__file__) or os.getcwd())
- if data_filename.startswith(dir_prefix):
- display_filename = data_filename[len(dir_prefix)+1:]
- else:
- display_filename = data_filename
- # Read the file and show its contents.
- print display_filename, ':'
- print open(data_filename, 'r').read()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement