luminoso_api/v5_download.py
def download_docs(client, output_filename=None, expanded=False):
    """
    Given a LuminosoClient pointing to a project and a filename to write to,
    retrieve all its documents in batches, and write them to a JSON lines
    (.jsons) file with one document per line.
    """
    if output_filename is None:
        # Find a default filename to download to, based on the project name.
        projname = _sanitize_filename(client.get()['name'])
        output_filename = '{}.jsons'.format(projname)

        # If the file already exists, add .1, .2, ..., after the project name
        # to unobtrusively get a unique filename.
        counter = 0
        while os.access(output_filename, os.F_OK):
            counter += 1
            output_filename = '{}.{}.jsons'.format(projname, counter)

        print('Downloading project to {!r}'.format(output_filename))

    with open(output_filename, 'w', encoding='utf-8') as out:
        for doc in iterate_docs(client, expanded=expanded, progress=True):
            print(json.dumps(doc, ensure_ascii=False), file=out)
def download_docs(client, output_filename=None, expanded=False):
    """
    Given a LuminosoClient pointing to a project and a filename to write to,
    retrieve all its documents in batches, and write them to a JSON lines
    (.jsons) file with one document per line.
    """
    if output_filename is None:
        # Find a default filename to download to, based on the project name.
        projname = _sanitize_filename(client.get()['name'])
        output_filename = '{}.jsons'.format(projname)

        # If the file already exists, add .1, .2, ..., after the project name
        # to unobtrusively get a unique filename.
        counter = 0
        while os.access(output_filename, os.F_OK):
            counter += 1
            output_filename = '{}.{}.jsons'.format(projname, counter)

        print('Downloading project to {!r}'.format(output_filename))

    with open(output_filename, 'w', encoding='utf-8') as out:
        for doc in iterate_docs(client, expanded=expanded, progress=True):
            print(json.dumps(doc, ensure_ascii=False), file=out)
def download_docs ( client , output_filename = None , expanded = False ) : if output_filename is None : # Find a default filename to download to, based on the project name. projname = _sanitize_filename ( client . get ( ) [ 'name' ] ) output_filename = '{}.jsons' . format ( projname ) # If the file already exists, add .1, .2, ..., after the project name # to unobtrusively get a unique filename. counter = 0 while os . access ( output_filename , os . F_OK ) : counter += 1 output_filename = '{}.{}.jsons' . format ( projname , counter ) print ( 'Downloading project to {!r}' . format ( output_filename ) ) with open ( output_filename , 'w' , encoding = 'utf-8' ) as out : for doc in iterate_docs ( client , expanded = expanded , progress = True ) : print ( json . dumps ( doc , ensure_ascii = False ) , file = out )
Given a LuminosoClient pointing to a project and a filename to write to,
    retrieve all its documents in batches, and write them to a JSON lines
    (.jsons) file with one document per line.
Given a LuminosoClient pointing to a project and a filename to write to retrieve all its documents in batches and write them to a JSON lines ( . jsons ) file with one document per line .