Exemplo n.º 1
0
def handle_post(args):
    """ Handle the arguments to call the 'create gist' functionality. """

    # Get the 'secret' argument if exists, otherwise take it from configuration
    # file. If 'secret' can not be loaded, raise an exception
    if args.secret:
        credential = args.secret
    else:
        credential = config.getConfigToken()
    if not credential:
        print literals.CREDENTIAL_NOT_FOUND
        sys.exit()

    # Define public or private
    if args.private:
        public = False
    else:
        public = True

    # Define the source file
    if args.filename:
        if args.input_dir:
            source_file = os.path.join(args.input_dir, args.filename)
        else:
            source_file = os.path.join("./", args.filename)
    else:
        source_file = None

    return (public, args.filename, source_file, args.description,
        utils.GithubFacade(args.user, credential))
Exemplo n.º 2
0
def handle_list(args):
    """ Handle the arguments to call the 'list gists' functionality. """

    # Get the 'user' argument if exists, otherwise take it from configuration
    # file. If 'user' can not be loaded, raise an exception
    if args.user:
        username = args.user
    else:
        username = config.getConfigUser()
    if not username:
        print literals.USER_NOT_FOUND
        sys.exit()

    # If '--private' option, password becomes mandatory. Load it. """
    if args.private:
        # Get the 'secret' argument if exists, otherwise take it from
        # configuration file. If 'secret' can not be loaded, raise an exception
        if args.secret:
            credential = args.secret
        else:
            credential = config.getConfigToken()
            if not credential:
                print literals.CREDENTIAL_NOT_FOUND
                sys.exit()
    else:
        credential = None

    return username, utils.GithubFacade(args.user, credential)
Exemplo n.º 3
0
def handle_update(args):
    """ Handle the arguments to call the 'update gist' functionality. """
    if not args.input_dir:
        args.input_dir = "./"

    return (args.gist_id, args.description, args.filenames,
            args.input_dir, args.new, args.remove,
            utils.GithubFacade(args.user, get_credentials(args)))
Exemplo n.º 4
0
def handle_post(args):
    """ Handle the arguments to call the 'create gist' functionality. """

    # Define public or private
    if args.private:
        public = False
    else:
        public = True

    if not args.input_dir:
        args.input_dir = "./"

    return (public, args.filenames, args.input_dir, args.description,
            utils.GithubFacade(args.user, get_credentials(args)))
Exemplo n.º 5
0
def handle_fork(args):
    """ Handle the arguments to call the 'fork' gists functionality. """

    # Get the 'secret' argument if exists, otherwise take it from configuration
    # file. If 'secret' can not be loaded, raise an exception
    if args.secret:
        credential = args.secret
    else:
        credential = config.getConfigToken()
    if not credential:
        print literals.CREDENTIAL_NOT_FOUND
        sys.exit()

    return args.gist_id, utils.GithubFacade(args.user, credential)
Exemplo n.º 6
0
def handle_list(args):
    """ Handle the arguments to call the 'list gists' functionality. """

    # Get the 'user' argument if exists, otherwise take it from configuration
    # file. If 'user' can not be loaded, raise an exception
    if args.user:
        username = args.user
    else:
        username = config.getConfigUser()
    if not username:
        print literals.USER_NOT_FOUND
        sys.exit()

    # If '--private' or '--starred' options, password becomes mandatory.
    # Load it.
    if args.private or args.starred:
        # Get the 'credentials' argument if exists, otherwise take it from
        # configuration file. If 'secret' can not be loaded, raise an exception
        credential = get_credentials(args)
    else:
        credential = None

    return (username, utils.GithubFacade(args.user, credential),
            args.starred)
Exemplo n.º 7
0
def handle_get(args):
    """ Handle the arguments to call the 'get' gists functionality. """
    return args.gist_id, args.filename, args.output_dir, utils.GithubFacade()
Exemplo n.º 8
0
def handle_show(args):
    """ Handle the arguments to call the 'show' gists functionality. """
    return args.gist_id, args.filename, utils.GithubFacade()
Exemplo n.º 9
0
def handle_star(args):
    """ Handle the arguments to call the 'star' and 'unstar' gists
    functionality. """
    return args.gist_id, utils.GithubFacade(args.user, get_credentials(args))
Exemplo n.º 10
0
def handle_authorize(args):
    """ Handle the arguments to call the 'authorize' gists functionality. """
    password = get_credentials(args)
    return utils.GithubFacade(args.user, password),
Exemplo n.º 11
0
def handle_authorize(args):
    """ Handle the arguments to call the 'authorize' gists functionality. """
    return (utils.GithubFacade(args.user, args.secret),)