Advertisement
Guest User

Untitled

a guest
May 22nd, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. #!/usr/bin/env python
  2. #
  3. # Copyright 2007 Doug Hellmann.
  4. #
  5. #
  6. # All Rights Reserved
  7. #
  8. # Permission to use, copy, modify, and distribute this software and
  9. # its documentation for any purpose and without fee is hereby
  10. # granted, provided that the above copyright notice appear in all
  11. # copies and that both that copyright notice and this permission
  12. # notice appear in supporting documentation, and that the name of Doug
  13. # Hellmann not be used in advertising or publicity pertaining to
  14. # distribution of the software without specific, written prior
  15. # permission.
  16. #
  17. # DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  18. # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
  19. # NO EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  20. # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
  21. # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  22. # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  23. # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  24. #
  25.  
  26. """Retrieving data when there is no ZIP archive involved.
  27.  
  28. """
  29. #end_pymotw_header
  30.  
  31. import os
  32. import example_package
  33.  
  34. # Find the directory containing the imported
  35. # package and build the data filename from it.
  36. pkg_dir = os.path.dirname(example_package.__file__)
  37. data_filename = os.path.join(pkg_dir, 'README.txt')
  38.  
  39. # Find the prefix of pkg_dir that represents
  40. # the portion of the path that does not need
  41. # to be displayed.
  42. dir_prefix = os.path.abspath(os.path.dirname(__file__) or os.getcwd())
  43. if data_filename.startswith(dir_prefix):
  44. display_filename = data_filename[len(dir_prefix)+1:]
  45. else:
  46. display_filename = data_filename
  47.  
  48. # Read the file and show its contents.
  49. print display_filename, ':'
  50. print open(data_filename, 'r').read()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement