r"""
The Magic of the Path Module, by Rory Geoghegan (r.geoghegan@gmail.com)
>>> presentation_name = "The magic of the path module"
>>> import path
>>> here = path.path('.')
>>> print here
.
>>> here = here.abspath()
>>> print here
/Users/rorygeoghegan/Documents/python.ie/2009.06
>>> len(here)
48
>>> here.endswith('2009.06')
True
>>> there = here / 'friends'
>>> there.exists()
False
>>> there.mkdir()
>>> there.listdir()
[]
>>> mick = there / 'mick'
>>> mick.open('w').write('I work with him.\n')
>>> vish = there / 'vish'
>>> vish.open('w').write('I think he owes me a pint.\n'
>>> there.listdir()
[path('/Users/rorygeoghegan/Documents/python.ie/2009.06/friends/mick'), path('/Users/rorygeoghegan/Documents/python.ie/2009.06/friends/vish')]
>>> vish = there.listdir()[1]
>>> vish.isfile()
True
>>> vish.getsize()
27L
>>> newvish = there / "vishal"
>>> newvish
path('/Users/rorygeoghegan/Documents/python.ie/2009.06/friends/vishal')
>>> vish.move(newvish)
>>> there.rmdir()
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/doctest.py", line 1212, in __run
    compileflags, 1) in test.globs
  File "<doctest path_demo[16]>", line 1, in <module>
    there.rmdir()
  File "/Users/rorygeoghegan/.python/site-packages/path.py", line 905, in rmdir
    os.rmdir(self)
OSError: [Errno 66] Directory not empty: '/Users/rorygeoghegan/Documents/python.ie/2009.06/friends'
>>> there.rmtree()
>>> import urllib2
>>> page = urllib2.urlopen(
...     "http://github.com/rgeoghegan/path"
... )
>>>
"""

if __name__ == "__main__":
    import doctest
    doctest.testmod()
