Пример #1
0
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)
Пример #2
0
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")
Пример #3
0
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)
Пример #4
0
#################
## 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: '))