def tvnamer(paths): """Main tvnamer function, takes an array of paths, does stuff. """ print "#" * 20 print "# Starting tvnamer" episodes_found = [] for cfile in findFiles(paths): parser = FileParser(cfile) try: episode = parser.parse() except InvalidFilename: warn("Invalid filename %s" % cfile) else: episodes_found.append(episode) if len(episodes_found) == 0: raise NoValidFilesFoundError() print "# Found %d episodes" % len(episodes_found) tvdb_instance = Tvdb( interactive=not Config['selectfirst'], debug = Config['verbose'], search_all_languages = Config['search_all_languages'], language = Config['language']) for episode in episodes_found: processFile(tvdb_instance, episode) print print "#" * 20 print "# Done"
def tvnamer(paths): """Main tvnamer function, takes an array of paths, does stuff. """ # Warn about move_files function if Config['move_files_enable']: import warnings warnings.warn("The move_files feature is still under development. " "Be very careful with it.\n" "It has not been heavily tested, and is not recommended for " "general use yet.") if Config['force_name'] is not None: import warnings warnings.warn("The --name argument is a temporary solution, and will" "be removed at some point in the future. Do no depend on it") p("#" * 20) p("# Starting tvnamer") episodes_found = [] for cfile in findFiles(paths): parser = FileParser(cfile) try: episode = parser.parse() except InvalidFilename, e: warn("Invalid filename: %s" % e) else: if episode.seriesname is None: warn("Parsed filename did not contain series name, skipping: %s" % cfile) else: episodes_found.append(episode)
def tvnamer(paths): """Main tvnamer function, takes an array of paths, does stuff. """ # Warn about move_files function if Config['move_files_enable']: import warnings warnings.warn( "The move_files feature is still under development. " "Be very careful with it.\n" "It has not been heavily tested, and is not recommended for " "general use yet.") p("#" * 20) p("# Starting tvnamer") episodes_found = [] for cfile in findFiles(paths): parser = FileParser(cfile) try: episode = parser.parse() except InvalidFilename, e: warn("Invalid filename: %s" % e) else: if episode.seriesname is None: warn( "Parsed filename did not contain series name, skipping: %s" % cfile) else: episodes_found.append(episode)
def tvnamer(paths): """Main tvnamer function, takes an array of paths, does stuff. """ # Warn about move_files function if Config["move_files_enable"]: import warnings warnings.warn( "The move_files feature is still under development. " "Be very careful with it.\n" "It has not been heavily tested, and is not recommended for " "general use yet." ) p("#" * 20) p("# Starting tvnamer") episodes_found = [] for cfile in findFiles(paths): parser = FileParser(cfile) try: episode = parser.parse() except InvalidFilename: warn("Invalid filename %s" % cfile) else: episodes_found.append(episode) if len(episodes_found) == 0: raise NoValidFilesFoundError() p("# Found %d episode" % len(episodes_found) + ("s" * (len(episodes_found) > 1))) # Sort episodes by series name, season and episode number episodes_found.sort(key=lambda x: x.sortable_info()) tvdb_instance = Tvdb( interactive=not Config["select_first"], search_all_languages=Config["search_all_languages"], language=Config["language"], ) for episode in episodes_found: processFile(tvdb_instance, episode) p("") p("#" * 20) p("# Done")
def comicnamer(paths): """Main comicnamer function, takes an array of paths, does stuff. """ # Warn about move_files function if Config['move_files_enable']: import warnings warnings.warn("The move_files feature is still under development. " "Be very careful with it.\n" "It has not been heavily tested, and is not recommended for " "general use yet.") p("#" * 20) p("# Starting comicnamer") issues_found = [] for cfile in findFiles(paths): cfile = cfile.decode("utf-8") parser = FileParser(cfile) try: issue = parser.parse() except InvalidFilename: warn("Invalid filename %s" % cfile) else: issues_found.append(issue) if len(issues_found) == 0: raise NoValidFilesFoundError() p("# Found %d issue" % len(issues_found) + ("s" * (len(issues_found) > 1))) # Sort issues by volume name and issue number issues_found.sort(key = lambda x: (x.volumename, x.issuenumbers)) comicvine_instance = Comicvine( interactive=not Config['select_first']) for issue in issues_found: processFile(comicvine_instance, issue) p('') p("#" * 20) p("# Done")
def comicnamer(paths): """Main comicnamer function, takes an array of paths, does stuff. """ # Warn about move_files function if Config['move_files_enable']: import warnings warnings.warn( "The move_files feature is still under development. " "Be very careful with it.\n" "It has not been heavily tested, and is not recommended for " "general use yet.") p("#" * 20) p("# Starting comicnamer") issues_found = [] for cfile in findFiles(paths): cfile = cfile.decode("utf-8") parser = FileParser(cfile) try: issue = parser.parse() except InvalidFilename: warn("Invalid filename %s" % cfile) else: issues_found.append(issue) if len(issues_found) == 0: raise NoValidFilesFoundError() p("# Found %d issue" % len(issues_found) + ("s" * (len(issues_found) > 1))) # Sort issues by series name and issue number issues_found.sort(key=lambda x: (x.seriesname, x.issuenumbers)) comicvine_instance = Comicvine(interactive=not Config['select_first']) for issue in issues_found: processFile(comicvine_instance, issue) p('') p("#" * 20) p("# Done")
def tvnamer(paths): """Main tvnamer function, takes an array of paths, does stuff. """ p("#" * 20) p("# Starting tvnamer") episodes_found = [] for cfile in findFiles(paths): parser = FileParser(cfile) try: episode = parser.parse() except InvalidFilename, e: warn("Invalid filename: %s" % e) else: if episode.seriesname is None and Config['force_name'] is None: warn("Parsed filename did not contain series name (and --name not specified), skipping: %s" % cfile) else: episodes_found.append(episode)
def tvnamer(paths): """Main tvnamer function, takes an array of paths, does stuff. """ p("#" * 20) p("# Starting tvnamer") episodes_found = [] for cfile in findFiles(paths): parser = FileParser(cfile) try: episode = parser.parse() except InvalidFilename, e: warn("Invalid filename: %s" % e) else: if episode.seriesname is None and Config['force_name'] is None and Config['series_id'] is None: warn("Parsed filename did not contain series name (and --name or --series-id not specified), skipping: %s" % cfile) else: episodes_found.append(episode)
################# ## MAIN SCRIPT ## ################# # Get .txt path text = input('Enter file to read: ') while not os.path.exists(text): print('ERROR: File does not exist...') text = input('Enter file to read: ') # Utilize FileParser f_parser = FileParser(text) f_parser.parse_file() main_dict = f_parser.words_dict # Sort words by value main_dict = sorted(main_dict.items(), key=lambda x: x[1], reverse=True) # Get length LENGTH = -1 while LENGTH < 0: try: LENGTH = int(input('Enter number of words: '))