# Path: bufferkdtree/util/url.py
# def download_from_url(url, fname):
#     """ Downloads data from a given url.
#     
#     Parameters
#     ----------
#     url : str
#         The target url from which the data
#         shall be downloaded
#     fname : str
#         The local filename; if the corresponding 
#         directory does not exists, it will be created
#     """
#     
#     # create directory if needed
#     d = os.path.dirname(fname)
#     if not os.path.exists(d):
#         os.makedirs(d)
# 
#     # open local file
#     f = open(fname, 'wb')
# 
#     # get data from url; based on 
#     # http://stackoverflow.com/questions/22676/how-do-i-download-a-file-over-http-using-python
#     u = urllib2.urlopen(url)
#     meta = u.info()
#     fsize = int(meta.getheaders("Content-Length")[0])
#     print("Downloading from %s (%i bytes) ... \n" % (url, fsize))
# 
#     fsize_current = 0
#     block_size = 8192
# 
#     print("Progress")
#     while True:
# 
#         buff = u.read(block_size)
#         if not buff:
#             break
# 
#         fsize_current += len(buff)
#         f.write(buff)
#         
#         percent = fsize_current * 100. / fsize
#         
#         sys.stdout.flush()        
#         sys.stdout.write("\r%2d%%" % percent)
#                 
#         sys.stdout.flush()        
# 
#     print("\n")
#     f.close()
# 
# Path: bufferkdtree/util/input.py
# def ask_question(question):
#     """ Helper function to ask user for yes/no 
#     input given a particular question.
#     
#     Parameters
#     ----------
#     question : str
#         The question for which the user shall
#         provide the input
#     """
#     
#     yes_set = set(['yes', 'y'])
#     no_set = set(['no', 'n'])
# 
#     while True:
# 
#         sys.stdout.write(question + " ")
#         user_input = raw_input().lower()
#         
#         if user_input in yes_set:
#             return True
#         
#         elif user_input in no_set:
#             return False
#         
#         else:
#             
#             sys.stdout.write("Only the following answers are allowed: " + unicode(list(yes_set)) + " or " + unicode(list(no_set)) + "\n")


import os
import sys
import numpy
from bufferkdtree.util.url import download_from_url
from bufferkdtree.util.input import ask_question
    q = "\nAdditional data need to be downloaded from:\n%s\n(to the current directory, about 2GB).\n\nDo you wish to continue? [y/n] " % url


    ack = """\n
    Funding for the SDSS and SDSS-II has been provided by the Alfred 
    P. Sloan Foundation, the Participating Institutions, the National 
    Science Foundation, the U.S. Department of Energy, the National 
    Aeronautics and Space Administration, the Japanese Monbukagakusho, 
    the Max Planck Society, and the Higher Education Funding Council 
    for England. The SDSS Web Site is http://www.sdss.org/.


    The SDSS is managed by the Astrophysical Research Consortium for the 
    Participating Institutions. The Participating Institutions are 
    the American Museum of Natural History, Astrophysical Institute 
    Potsdam, University of Basel, University of Cambridge, Case 
    Western Reserve University, University of Chicago, Drexel 
    University, Fermilab, the Institute for Advanced Study, the Japan 
    Participation Group, Johns Hopkins University, the Joint Institute 
    for Nuclear Astrophysics, the Kavli Institute for Particle 
    Astrophysics and Cosmology, the Korean Scientist Group, the 
    Chinese Academy of Sciences (LAMOST), Los Alamos National 
    Laboratory, the Max-Planck-Institute for Astronomy (MPIA), the 
    Max-Planck-Institute for Astrophysics (MPA), New Mexico State 
    University, Ohio State University, University of Pittsburgh, 
    University of Portsmouth, Princeton University, the United States 
    Naval Observatory, and the University of Washington.\n\n
    """

    if not os.path.isfile(fname) or os.path.getsize(fname) != 1790285720:

# Path: bufferkdtree/util/url.py
# def download_from_url(url, fname):
#     """ Downloads data from a given url.
#     
#     Parameters
#     ----------
#     url : str
#         The target url from which the data
#         shall be downloaded
#     fname : str
#         The local filename; if the corresponding 
#         directory does not exists, it will be created
#     """
#     
#     # create directory if needed
#     d = os.path.dirname(fname)
#     if not os.path.exists(d):
#         os.makedirs(d)
# 
#     # open local file
#     f = open(fname, 'wb')
# 
#     # get data from url; based on 
#     # http://stackoverflow.com/questions/22676/how-do-i-download-a-file-over-http-using-python
#     u = urllib2.urlopen(url)
#     meta = u.info()
#     fsize = int(meta.getheaders("Content-Length")[0])
#     print("Downloading from %s (%i bytes) ... \n" % (url, fsize))
# 
#     fsize_current = 0
#     block_size = 8192
# 
#     print("Progress")
#     while True:
# 
#         buff = u.read(block_size)
#         if not buff:
#             break
# 
#         fsize_current += len(buff)
#         f.write(buff)
#         
#         percent = fsize_current * 100. / fsize
#         
#         sys.stdout.flush()        
#         sys.stdout.write("\r%2d%%" % percent)
#                 
#         sys.stdout.flush()        
# 
#     print("\n")
#     f.close()
# 
# Path: bufferkdtree/util/input.py
# def ask_question(question):
#     """ Helper function to ask user for yes/no 
#     input given a particular question.
#     
#     Parameters
#     ----------
#     question : str
#         The question for which the user shall
#         provide the input
#     """
#     
#     yes_set = set(['yes', 'y'])
#     no_set = set(['no', 'n'])
# 
#     while True:
# 
#         sys.stdout.write(question + " ")
#         user_input = raw_input().lower()
#         
#         if user_input in yes_set:
#             return True
#         
#         elif user_input in no_set:
#             return False
#         
#         else:
#             
#             sys.stdout.write("Only the following answers are allowed: " + unicode(list(yes_set)) + " or " + unicode(list(no_set)) + "\n")


# Path: examples/generate.py
import os
import sys
import numpy
from bufferkdtree.util.url import download_from_url
from bufferkdtree.util.input import ask_question

    q = "\nAdditional data need to be downloaded from:\n%s\n(to the current directory, about 2GB).\n\nDo you wish to continue? [y/n] " % url


    ack = """\n
    Funding for the SDSS and SDSS-II has been provided by the Alfred 
    P. Sloan Foundation, the Participating Institutions, the National 
    Science Foundation, the U.S. Department of Energy, the National 
    Aeronautics and Space Administration, the Japanese Monbukagakusho, 
    the Max Planck Society, and the Higher Education Funding Council 
    for England. The SDSS Web Site is http://www.sdss.org/.


    The SDSS is managed by the Astrophysical Research Consortium for the 
    Participating Institutions. The Participating Institutions are 
    the American Museum of Natural History, Astrophysical Institute 
    Potsdam, University of Basel, University of Cambridge, Case 
    Western Reserve University, University of Chicago, Drexel 
    University, Fermilab, the Institute for Advanced Study, the Japan 
    Participation Group, Johns Hopkins University, the Joint Institute 
    for Nuclear Astrophysics, the Kavli Institute for Particle 
    Astrophysics and Cosmology, the Korean Scientist Group, the 
    Chinese Academy of Sciences (LAMOST), Los Alamos National 
    Laboratory, the Max-Planck-Institute for Astronomy (MPIA), the 
    Max-Planck-Institute for Astrophysics (MPA), New Mexico State 
    University, Ohio State University, University of Pittsburgh, 
    University of Portsmouth, Princeton University, the United States 
    Naval Observatory, and the University of Washington.\n\n
    """

    if not os.path.isfile(fname) or os.path.getsize(fname) != 1790285720:

        answer = ask_question(q)