def setUp(self): self.screen_name = 'example_screen_name' self.parser = argparse.ArgumentParser(description='desc', parents=[args.parent()]) self.args = self.parser.parse_args(['-n', '-v']) self.txtfile = os.path.join(os.path.dirname(__file__), 'data', 'tweets.txt') self.archive = os.path.dirname(__file__)
def setUp(self): self.api = tweepy.API() self.status = tweepy.Status.parse(self.api, TWEET) parent = args.parent(version='1.2.3') self.parser = argparse.ArgumentParser(description='desc', parents=[parent]) sys.argv = ['test', '--dry-run', '-v', '-c', self.yaml] self.args = self.parser.parse_args()
def main(): parser = argparse.ArgumentParser('twittermarkov', description='Tweet with a markov bot, or teach it from a twitter archive.') parser.add_argument('-V', '--version', action='version', version="%(prog)s " + __version__) subparsers = parser.add_subparsers() tweet = subparsers.add_parser( 'tweet', parents=[tbu.parent()], description='Post markov chain ("ebooks") tweets to Twitter', usage='%(prog)s [options] SCREEN_NAME') tweet.add_argument('-r', '--reply', action='store_const', const='reply', dest='action', help='tweet responses to recent mentions') tweet.add_argument('--brain', dest='brains', metavar='BRAIN', type=str, help='cobe .brain file') tweet.add_argument('--no-learn', dest='learn', action='store_false', help='skip learning') tweet.add_argument('screen_name', type=str, metavar='SCREEN_NAME', help='User who will be tweeting') tweet.set_defaults(prog='tweet', action='tweet') learnparser = subparsers.add_parser( 'learn', description='Teach a Cobe brain the contents of a Twitter archive', usage="%(prog)s [options] ARCHIVEPATH NEWBRAIN") add_learn_subparser_arguments(learnparser) args = parser.parse_args() argdict = vars(args) # Tweet if args.prog == 'tweet': tbu.add_logger(args.screen_name, args.verbose) logger = logging.getLogger(args.screen_name) tm = Twitter_markov(**argdict) if args.tweet: logger.debug('tweeting...') tm.tweet() if args.reply: logger.debug('replying to all') tm.reply_all() # Learn elif args.prog == 'learn': if not args.quiet: print("Reading from " + args.archive, file=sys.stderr) print("Teaching " + args.brain, file=sys.stderr) if args.brain[-6:] == '.brain': brainpath = args.brain else: brainpath = args.brain + '.brain' count = learn(args.archive, brainpath, **argdict) if not args.quiet: print("Taught {0} tweets".format(count))
def setUp(self): self.api = tweepy.API() self.status = tweepy.Status.parse(self.api, TWEET) self.yaml = os.path.join(os.path.dirname(__file__), "data/test.yaml") self.screen_name = "example_screen_name" parent = args.parent() self.parser = argparse.ArgumentParser(description="desc", parents=[parent]) self.arg_input = ["--consumer-key", "123", "-n", "-v"] self.args = self.parser.parse_args(self.arg_input) self.txtfile = os.path.join(os.path.dirname(__file__), "data/tweets.txt") self.archive = os.path.dirname(__file__)
def setUp(self): self.api = tweepy.API() self.status = tweepy.Status.parse(self.api, TWEET) self.yaml = os.path.join(os.path.dirname(__file__), 'data', 'test.yaml') self.screen_name = 'example_screen_name' parent = args.parent(version='1.2.3') self.parser = argparse.ArgumentParser(description='desc', parents=[parent]) sys.argv = ['test', '--dry-run', '-v', '-c', self.yaml] self.args = self.parser.parse_args() self.txtfile = os.path.join(os.path.dirname(__file__), 'data', 'tweets.txt') self.archive = os.path.dirname(__file__)