示例#1
0
    def setup_wizard(self):
        print('Setup wizard for %s' % self.get_alias())
        while True:
            owner = console.string(
                'Name of the redditor who curates the MultiReddit')
            if owner is None:
                print('Aborting setup.')
                return False
            if 'u/' in owner:
                print(
                    'Please only include the subreddit name, after the "/u/".')
                continue
            self.data['owner'] = owner
            break
        mr = console.string("Enter the name of this user's multireddit")
        if not mr:
            print("Setup canceled.")
            return False
        self.data['multi_name'] = mr

        order = console.prompt_list(
            'How would you like to sort these Submissions?',
            [(r[0], r) for r in reddit.post_orders()])
        self.data['order'] = order[0]
        self.data['time'] = 'all'
        if order[1]:
            self.data['time'] = console.prompt_list(
                'Select a time span to filter by:', reddit.time_filters())
        self.data['limit'] = console.number(
            'How many would you like to download? (0 for no limit)')
        return True
 def setup_wizard(self):
     print('Setup wizard for %s' % self.get_alias())
     order = console.prompt_list(
         'How would you like to sort these Submissions?',
         [(r[0], r) for r in reddit.post_orders()])
     self.data['order'] = order[0]
     self.data['time'] = 'all'
     if order[1]:
         self.data['time'] = console.prompt_list(
             'Select a time span to filter by:', reddit.time_filters())
     self.data['limit'] = console.number(
         'How many would you like to download? (0 for no limit)')
     return True
示例#3
0
def interact(settings):
    """ Used only after base setup to simplify managing Sources and their Filters. Can be run at any time. """
    print(
        "Source wizard launched.\n"
        'ABOUT: "Sources" are the places this downloader pulls Submissions or Comments from.\n'
        "\tThere are many different places on Reddit that you may want to pull posts from.\n"
        "\tThis wizard is built to help you easily manage them.\n")
    while True:
        su.print_color(Fore.GREEN, '=== Config Wizard Home ===')
        opt = console.prompt_list(
            'What would you like to do?',
            [('Edit my saved account information', 'account'),
             ('Add a new Source', 'add'),
             ('Edit my current Sources (%s)' % len(settings.get_sources()),
              'edit_source'), ("Save & Exit", "exit")])
        print('\n\n')

        if opt == 'exit':
            settings.save()
            print('Wizard completed.')
            sys.exit(0)

        if opt == 'add':
            _add_source(settings)

        if opt == 'edit_source':
            _edit_sources(settings)

        if opt == 'account':
            _edit_account(settings)

        print('\n\n')
 def _remove_filter(self):
     filters = self.source.get_filters()
     if len(filters) == 0:
         print('No Filters to remove.')
         return
     rem = console.prompt_list('Select a Filter to remove:',
                               [(str(fi), fi) for fi in filters],
                               allow_none=True)
     if rem is None:
         print("Removing nothing.")
         return
     self.source.remove_filter(rem)
     wizard_functions.save_source(self.settings, self.source)
 def _add_filter(self):
     print(
         'To create a filter, select the field to filter by, how it should be compared, '
         'and then the value to compare against.')
     new_filter = console.prompt_list(
         "What do you want to filter this source's Posts by?",
         [("%s" % fi.get_description(), fi) for fi in filter.get_filters()],
         allow_none=True)
     if new_filter is None:
         print('Not adding Filter.')
         return
     if new_filter.accepts_operator:
         comp = console.prompt_list(
             'How should we compare this field to the value you set?',
             [(fv.value.replace('.', ''), fv) for fv in filter.Operators])
         new_filter.set_operator(comp)
     limit = console.string('Value to compare to', auto_strip=False)
     if limit is None:
         print('Aborted filter setup.')
         return
     new_filter.set_limit(limit)
     self.source.add_filter(new_filter)
     wizard_functions.save_source(self.settings, self.source)
	def setup_wizard(self):
		print('Setup wizard for %s' % self.get_alias())
		while True:
			sub = console.string('Name of the subreddit to scan')
			if sub is None:
				print('Aborting setup.')
				return False
			if 'r/' in sub:
				print('Please only include the subreddit name, after the "/r/".')
				continue
			self.data['subreddit'] = sub
			break
		print("Selected: %s" % sub)
		order = console.prompt_list(
			'How would you like to sort these Submissions?',
			[(r[0], r) for r in reddit.post_orders()]
		)
		self.data['order'] = order[0]
		self.data['time'] = 'all'
		if order[1]:
			self.data['time'] = console.prompt_list('Select a time span to filter by:', reddit.time_filters())
		self.data['limit'] = console.number('How many would you like to download? (0 for no limit)')
		return True
示例#7
0
def _edit_sources(settings):
    """ Called when the User should be promtped for a Source to edit. """
    print()
    sources = settings.get_sources()
    if len(sources) == 0:
        print('You have no sources to edit!')
        return
    targ = console.prompt_list('Which source would you like to edit?',
                               [('"%s" :: %s' %
                                 (s.get_alias(), s.get_config_summary()), s)
                                for s in sources],
                               allow_none=True)
    if targ is None:
        return
    print('Selected Source: %s' % targ.get_alias())
    _source_editor(settings, targ)
    def run(self):
        """ The editor screen for a specific Source. """
        while True:
            print('\n\n\n')
            su.print_color(
                su.Fore.GREEN, 'Editing Source: "%s" -> %s' %
                (self.source.get_alias(), self.source.get_config_summary()))
            filters = self.source.get_filters()
            if len(filters) > 0:
                for f in filters:
                    print('\t-%s' % f)

            choice = console.prompt_list(
                'What would you like to do with this Source?',
                [('Edit this Source', 'edit'), ('Rename', 'rename'),
                 ('Delete this Source', 'delete'),
                 ('Add a Filter', 'add_filter'),
                 ('Remove a Filter', 'remove_filter'), ('Nothing', 'exit')])
            print('\n')

            if choice == 'edit':
                self._edit_source()

            if choice == 'rename':
                self._rename()

            if choice == 'delete':
                if self._delete():
                    break

            if choice == 'add_filter':
                self._add_filter()

            if choice == 'remove_filter':
                self._remove_filter()

            if choice == 'exit':
                break
    def setup_wizard(self):
        print('Setup wizard for %s' % self.get_alias())
        user = console.string('Name of the User to scan')
        if user is None:
            print('Aborting setup.')
            return False
        self.data['user'] = user

        choice = console.prompt_list(
            'Would you like to scan their Submissions or Comments?',
            [('Only Submissions', 0), ('Only Comments', 1),
             ('Both Submissions & Comments', 2)])
        self.data['scan_submissions'] = (choice == 0 or choice == 2)
        self.data['scan_comments'] = (choice == 1 or choice == 2)
        feeds = ""
        if self.data['scan_comments']:
            feeds += "Comments"
        if self.data['scan_submissions']:
            if len(feeds) > 0:
                feeds += " & "
            feeds += "Submissions"
        self.data['vanity'] = feeds
        return True
示例#10
0
    def setup_wizard(self):
        print('Setup wizard for %s' % self.get_alias())
        user = console.string('Name of the User to scan')
        if user is None:
            print('Aborting setup.')
            return False
        self.data['user'] = user

        choice = console.prompt_list(
            'Would you like to scan the Posts they\'ve Upvoted or Saved?',
            [('Only Upvoted Posts', 0), ('Only Saved Posts', 1),
             ('Both Upvoted & Saved Posts', 2)])
        self.data['scan_upvoted'] = (choice == 0 or choice == 2)
        self.data['scan_saved'] = (choice == 1 or choice == 2)
        feeds = ""
        if self.data['scan_upvoted']:
            feeds += "Upvoted"
        if self.data['scan_saved']:
            if len(feeds) > 0:
                feeds += " & "
            feeds += "Saved"
        self.data['vanity'] = feeds
        return True
示例#11
0
def _add_source(settings):
    """ Prompts the user for a new Source to add. """
    from classes.sources import source
    all_sources = source.get_sources()
    choice = console.prompt_list("What would you like to download?",
                                 [(s.description, s.type)
                                  for s in all_sources],
                                 allow_none=True)
    print('\n')
    for s in all_sources:
        if s.type == choice:
            if s.setup_wizard():
                print('\nAdding new source...')
                name = wizard_functions.get_unique_alias(settings)
                if not name:
                    print('Aborted building Source at User request.')
                    return
                s.set_alias(name)
                settings.add_source(s)
                _source_editor(settings, s)
            else:
                print("Setup failed. Not adding Source.")
            return
    print('Invalid selection.')