luminoso_api/v4_upload.py
def main():
    """
    Handle command line arguments, to upload a file to a Luminoso project
    as a script.
    """
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('filename')
    parser.add_argument('account')
    parser.add_argument('project_name')
    parser.add_argument(
        '--append',
        help=("If append flag is used, upload documents to existing project, "
              "rather than creating a new project."),
        action="store_true"
    )
    parser.add_argument(
        '-s', '--stage',
        help="If stage flag is used, just upload docs, don't recalculate.",
        action="store_true"
    )
    parser.add_argument(
        '-a', '--api-url',
        help="Specify an alternate API url",
        default=URL_BASE
    )
    parser.add_argument(
        '-l', '--language',
        help=("Two-letter language code to use when recalculating (e.g. 'en' "
              "or 'ja')")
    )
    parser.add_argument(
        '-u', '--username', default=None,
        help="username (defaults to your username on your computer)"
    )
    parser.add_argument(
        '-p', '--password', default=None,
        help="password (you can leave this out and type it in later)"
    )
    parser.add_argument(
        '-d', '--date-format', default='iso',
        help=("format string for parsing dates, following "
              "http://strftime.org/.  Default is 'iso', which is "
              "'%%Y-%%m-%%dT%%H:%%M:%%S+00:00'.  Other shortcuts are 'epoch' "
              "for epoch time or 'us-standard' for '%%m/%%d/%%y'")
     )
    args = parser.parse_args()

    # Implement some human-understandable shortcuts for date_format
    date_format_lower = args.date_format.lower()
    if date_format_lower == 'iso':
        date_format = '%Y-%m-%dT%H:%M:%S+00:00'
    elif date_format_lower in ['unix', 'epoch']:
        date_format = 'epoch'
    elif date_format_lower == 'us-standard':
        date_format = '%m/%d/%y'
    else:
        date_format = args.date_format

    upload_file(args.filename, args.api_url, args.account, args.project_name,
                language=args.language,
                username=args.username, password=args.password,
                append=args.append, stage=args.stage,
                date_format=date_format)
def main():
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('filename')
    parser.add_argument('account')
    parser.add_argument('project_name')
    parser.add_argument(
        '--append',
        help=("If append flag is used, upload documents to existing project, "
              "rather than creating a new project."),
        action="store_true"
    )
    parser.add_argument(
        '-s', '--stage',
        help="If stage flag is used, just upload docs, don't recalculate.",
        action="store_true"
    )
    parser.add_argument(
        '-a', '--api-url',
        help="Specify an alternate API url",
        default=URL_BASE
    )
    parser.add_argument(
        '-l', '--language',
        help=("Two-letter language code to use when recalculating (e.g. 'en' "
              "or 'ja')")
    )
    parser.add_argument(
        '-u', '--username', default=None,
        help="username (defaults to your username on your computer)"
    )
    parser.add_argument(
        '-p', '--password', default=None,
        help="password (you can leave this out and type it in later)"
    )
    parser.add_argument(
        '-d', '--date-format', default='iso',
        help=("format string for parsing dates, following "
              "http://strftime.org/.  Default is 'iso', which is "
              "'%%Y-%%m-%%dT%%H:%%M:%%S+00:00'.  Other shortcuts are 'epoch' "
              "for epoch time or 'us-standard' for '%%m/%%d/%%y'")
     )
    args = parser.parse_args()

    # Implement some human-understandable shortcuts for date_format
    date_format_lower = args.date_format.lower()
    if date_format_lower == 'iso':
        date_format = '%Y-%m-%dT%H:%M:%S+00:00'
    elif date_format_lower in ['unix', 'epoch']:
        date_format = 'epoch'
    elif date_format_lower == 'us-standard':
        date_format = '%m/%d/%y'
    else:
        date_format = args.date_format

    upload_file(args.filename, args.api_url, args.account, args.project_name,
                language=args.language,
                username=args.username, password=args.password,
                append=args.append, stage=args.stage,
                date_format=date_format)
def main ( ) : import argparse parser = argparse . ArgumentParser ( ) parser . add_argument ( 'filename' ) parser . add_argument ( 'account' ) parser . add_argument ( 'project_name' ) parser . add_argument ( '--append' , help = ( "If append flag is used, upload documents to existing project, " "rather than creating a new project." ) , action = "store_true" ) parser . add_argument ( '-s' , '--stage' , help = "If stage flag is used, just upload docs, don't recalculate." , action = "store_true" ) parser . add_argument ( '-a' , '--api-url' , help = "Specify an alternate API url" , default = URL_BASE ) parser . add_argument ( '-l' , '--language' , help = ( "Two-letter language code to use when recalculating (e.g. 'en' " "or 'ja')" ) ) parser . add_argument ( '-u' , '--username' , default = None , help = "username (defaults to your username on your computer)" ) parser . add_argument ( '-p' , '--password' , default = None , help = "password (you can leave this out and type it in later)" ) parser . add_argument ( '-d' , '--date-format' , default = 'iso' , help = ( "format string for parsing dates, following " "http://strftime.org/.  Default is 'iso', which is " "'%%Y-%%m-%%dT%%H:%%M:%%S+00:00'.  Other shortcuts are 'epoch' " "for epoch time or 'us-standard' for '%%m/%%d/%%y'" ) ) args = parser . parse_args ( ) # Implement some human-understandable shortcuts for date_format date_format_lower = args . date_format . lower ( ) if date_format_lower == 'iso' : date_format = '%Y-%m-%dT%H:%M:%S+00:00' elif date_format_lower in [ 'unix' , 'epoch' ] : date_format = 'epoch' elif date_format_lower == 'us-standard' : date_format = '%m/%d/%y' else : date_format = args . date_format upload_file ( args . filename , args . api_url , args . account , args . project_name , language = args . language , username = args . username , password = args . password , append = args . append , stage = args . stage , date_format = date_format )
Handle command line arguments, to upload a file to a Luminoso project
    as a script.
Handle command line arguments to upload a file to a Luminoso project as a script .