예제 #1
0
파일: create.py 프로젝트: Derfirm/rvidmaker
def main(profile_path, output_dir, censor_path=None, block_path=None):
    if not os.path.isfile(profile_path):
        print('"{}" is not a file'.format(profile_path))
        return
    if censor_path and not os.path.isfile(censor_path):
        print('"{}" is not a file'.format(censor_path))
        return
    if block_path and not os.path.isfile(block_path):
        print('"{}" is not a file'.format(block_path))
        return

    reddit = RedditVideoCompSuite()
    try:
        if censor_path:
            censor = Profanity()
            censor.load_censor_words_from_file(censor_path)
        else:
            censor = None
        if block_path:
            blocker = Profanity()
            blocker.load_censor_words_from_file(block_path)
        else:
            blocker = None
        reddit.config(profile_path, censor, blocker)
    except SuiteConfigException as e:
        print("Failed to configure suite: {}".format(e))
        return
    try:
        reddit.generate(output_dir)
    except SuiteGenerateException as e:
        print("Failed to generate video: {}".format(e))
        return
예제 #2
0
def main(profile_path, output_dir, censor_path=None, block_path=None):
    if not os.path.isfile(profile_path):
        print('"{}" is not a file'.format(profile_path), file=stderr)
        sys.exit(1)
    if censor_path and not os.path.isfile(censor_path):
        print('"{}" is not a file'.format(censor_path), file=stderr)
        sys.exit(1)
    if block_path and not os.path.isfile(block_path):
        print('"{}" is not a file'.format(block_path), file=stderr)
        sys.exit(1)

    reddit = RedditVideoCompSuite()
    print("Configuring editor...")
    try:
        if censor_path:
            censor = Profanity()
            censor.load_censor_words_from_file(censor_path)
        else:
            censor = None
        if block_path:
            blocker = Profanity()
            blocker.load_censor_words_from_file(block_path)
        else:
            blocker = None
        reddit.config(profile_path, censor, blocker)
    except SuiteConfigException as e:
        print("Failed to configure suite: {}".format(e), file=stderr)
        sys.exit(1)
    try:
        print("Generating video...")
        start = datetime.now()
        reddit.generate(output_dir)
        elapsed = datetime.now() - start
        print("Generated in {}".format(elapsed))
    except SuiteGenerateException as e:
        print("Failed to generate video: {}".format(e), file=stderr)
        sys.exit(1)
예제 #3
0
 def test_init_wordlist_not_found(self):
     with self.assertRaises(FileNotFoundError):
         Profanity("not_found_file.txt")
예제 #4
0
 def test_init_with_bad_type(self):
     with self.assertRaises(TypeError):
         Profanity(123)
     with self.assertRaises(TypeError):
         Profanity(False)
예제 #5
0
 def test_init_with_list(self):
     custom_badwords = ["happy", "jolly", "merry"]
     Profanity(custom_badwords)
     Profanity(set(custom_badwords))
     Profanity(tuple(custom_badwords))