# -*- coding: utf-8 -*-
"""
Very simple script which gets a page and writes its contents to
standard output. This makes it possible to pipe the text to another
process.

Syntax: python get.py Title of the page

Example: python get.py Wikipedia | grep MediaWiki > results.txt
"""

# (C) Daniel Herding, 2005
#
# Distributed under the terms of the MIT license.

__version__ = '$Id$'



def main():
    singlePageTitleParts = []
    for arg in pywikibot.handleArgs():
        singlePageTitleParts.append(arg)

    pageTitle = " ".join(singlePageTitleParts)
    page = pywikibot.Page(pywikibot.getSite(), pageTitle)

    # TODO: catch exceptions
    pywikibot.output(page.get(), toStdout=True)

if __name__ == "__main__":
    try:
        main()
    finally:
        pywikibot.stopme()
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-2-712b756c0100> in <module>()
     32     try:
---> 33         main()
     34     finally:

<ipython-input-2-712b756c0100> in main()
     21     singlePageTitleParts = []
---> 22     for arg in pywikibot.handleArgs():
     23         singlePageTitleParts.append(arg)

NameError: name 'pywikibot' is not defined

During handling of the above exception, another exception occurred:

NameError                                 Traceback (most recent call last)
<ipython-input-2-712b756c0100> in <module>()
     33         main()
     34     finally:
---> 35         pywikibot.stopme()

NameError: name 'pywikibot' is not defined