Exemple #1
0
def process_cli_args():
    args = docopt(__doc__)
    if len(sys.argv) > 1:
        print('Logging in...')
        prompted = False
    else:  # No cli arguments
        prompted = True
        main_command = None
        user_input = None

    # Direct command line arguments
    if url_or_str := args['<link>']:
        # Link given, no mode specified
        if 'users' in url_or_str:
            user_input, main_command = pure.process_user_url(url_or_str)

        elif 'artworks' in url_or_str or 'illust_id' in url_or_str:
            user_input, main_command = pure.process_artwork_url(url_or_str)

        # Assume you won't search for '3' or 'f'
        elif url_or_str == '3' or url_or_str == 'f':
            main_command = '3'
            user_input = None

        # Assume you won't search for '5' or 'n'
        elif url_or_str == '5' or url_or_str == 'n':
            main_command = '5'
            user_input = None

        else:  # Mode 4, string to search for artists
            user_input = url_or_str
            main_command = '4'
Exemple #2
0
def parse_mode_given(args: 'docopt.Dict[str, str]'):
    url_or_id = args['<link_or_id>']

    if args['1'] or args['a']:
        return main.ArtistModeLoop(pure.process_user_url(url_or_id)).start()

    elif args['2'] or args['i']:
        return main.ViewPostModeLoop(
            pure.process_artwork_url(url_or_id)).start()

    elif args['3'] or args['f']:
        return main.following_users_mode()
Exemple #3
0
def parse_no_mode(url_or_str: str):
    if 'users' in url_or_str:
        return main.ArtistModeLoop(pure.process_user_url(url_or_str)).start()

    elif 'artworks' in url_or_str or 'illust_id' in url_or_str:
        return main.ViewPostModeLoop(
            pure.process_artwork_url(url_or_str)).start()

    # Assume you won't search for '3' or 'f'
    elif url_or_str == '3' or url_or_str == 'f':
        return main.following_users_mode()

    # Assume you won't search for '5' or 'n'
    elif url_or_str == '5' or url_or_str == 'n':
        return main.illust_follow_mode()

    # Assume you won't search for '6' or 'r'
    elif url_or_str == '6' or url_or_str == 'r':
        return main.illust_recommended_mode()

    elif url_or_str == 'q':
        return main.frequent()

    return main.SearchUsersModeLoop(url_or_str).start()
Exemple #4
0
        # Assume you won't search for '3' or 'f'
        elif url_or_str == '3' or url_or_str == 'f':
            main_command = '3'
            user_input = None

        # Assume you won't search for '5' or 'n'
        elif url_or_str == '5' or url_or_str == 'n':
            main_command = '5'
            user_input = None

        else:  # Mode 4, string to search for artists
            user_input = url_or_str
            main_command = '4'

    elif url_or_id := args['<link_or_id>']:
        # Mode specified, argument can be link or id
        if args['1'] or args['a']:
            user_input, main_command = pure.process_user_url(url_or_id)

        elif args['2'] or args['i']:
            user_input, main_command = pure.process_artwork_url(url_or_id)

        elif args['3'] or args['f']:
            user_input, main_command = pure.process_user_url(url_or_id)
            main_command = '3'

    elif user_input := args['<searchstr>']:
        main_command = '4'

    return prompted, main_command, user_input
Exemple #5
0
 def _process_raw_answer(self) -> str:
     """Process self._raw_answer here into self._user_input"""
     self._user_input = pure.process_user_url(self._raw_answer)
Exemple #6
0
def test_process_user_url():
    assert pure.process_user_url(
        'https://www.pixiv.net/en/users/2232374') == '2232374'
    assert pure.process_user_url('2232374') == '2232374'