def Search_Genre_Unread():
    Search_Get_Genres()
    print "\n"
    print "Searching for Unread Books by Genre"
    print "Enter \"+++\" to exit without saving anytime.\n\n"
    NewEntry = Book()
    NewEntry.Genre = raw_input("Genre: ")
    if NewEntry.Author_First == "+++":
        return
    print "\n\n\n\n"

    os.chdir("Records")
    for FileName in glob.glob("*"):
            os.chdir(FileName)
            for SeriesName in glob.glob("*.txt"):
                SeriesName_p = SeriesName.split('.')
                fid = open(SeriesName,'r')
                for line in fid:
                    line_p = line.split(',')
                    if line_p[4] == "00000000\n" and line_p[1] == NewEntry.Genre:
                        print line_p[0] + ", " + line_p[3] + " " + line_p[2]        
                fid.close()
            os.chdir("..")
    os.chdir("..")
    print "\n\n"
def Search_Author_Series_Read():
    print "\n\n\n\n\n\n\n"
    print "Searching for Books Read by Author name"
    print "Enter \"+++\" to exit without saving anytime.\n\n"
    NewEntry = Book()
    NewEntry.Author_First = raw_input("Author First Name: ")
    if NewEntry.Author_First == "+++":
        return
    NewEntry.Author_Last = raw_input("Author Last Name: ")
    if NewEntry.Author_Last == "+++":
        return

    print "\n\n\n\n"
    os.chdir("Records")
    SearchString = NewEntry.Author_Last + "_" + NewEntry.Author_First
    for FileName in glob.glob("*"):
        if FileName == SearchString:
            os.chdir(FileName)
            for SeriesName in glob.glob("*.txt"):
                SeriesName_p = SeriesName.split('.')
                PrintList = []
                fid = open(SeriesName,'r')
                for line in fid:
                    line_p = line.split(',')
                    if line_p[4] != "00000000\n":
                        PrintList.append(line)
                fid.close()
                if PrintList:
                    AuthorName = FileName.split('_')
                    print SeriesName_p[0] + ",  " + AuthorName[1] + " " + AuthorName[0]
                    for line in PrintList:
                        line_p = line.split(',')
                        print "\t" + line_p[0]
                    print
            os.chdir("..")
    os.chdir("..")

    print "\n\n"
def Search_Author_Series():
    print "\n\n\n\n\n\n\n"
    print "Searching for Series by Author name"
    print "Enter \"+++\" to exit without saving anytime.\n\n"
    NewEntry = Book()
    NewEntry.Author_First = raw_input("Author First Name: ")
    if NewEntry.Author_First == "+++":
        return
    NewEntry.Author_Last = raw_input("Author Last Name: ")
    if NewEntry.Author_Last == "+++":
        return

    print "\n\n\n\n"
    os.chdir("Records")
    SearchString = NewEntry.Author_Last + "_" + NewEntry.Author_First
    for FileName in glob.glob("*"):
        if FileName == SearchString:
            os.chdir(FileName)
            for SeriesName in glob.glob("*.txt"):
                ForPrint = SeriesName.split(".")
                print ForPrint[0]
            os.chdir("..")
    os.chdir("..")
    print "\n\n"
Exemple #4
0
def Add_New_Book():
    print "\n\n\n\n\n\n\n"
    print "Adding New Book"
    print "Enter date in \"YYYYMMDD\" format. Use \"0\" if not read yet, and \"9\" if unknown date."
    print "Enter \"+++\" to exit without saving anytime.\n\n"
    NewEntry = Book()
    NewEntry.Title = raw_input("Book Title: ")
    if NewEntry.Title == "+++":
        return
    NewEntry.Author_First = raw_input("Author First Name: ")
    if NewEntry.Author_First == "+++":
        return
    NewEntry.Author_Last = raw_input("Author Last Name: ")
    if NewEntry.Author_Last == "+++":
        return
    NewEntry.Series = raw_input("Book Series: ")
    if NewEntry.Series == "+++":
        return
    NewEntry.Date = raw_input("Date: ")
    if NewEntry.Date == "+++":
        return
    if not NewEntry.Date:
        NewEntry.Date = "99999999"
    if NewEntry.Date == "0":
        NewEntry.Date = "00000000"
    if NewEntry.Date == "9":
        NewEntry.Date = "99999999"
    NewEntry.Genre = raw_input("Genre: ")
    if NewEntry.Genre == "+++":
        return

    print "\n\n\n\n\n\n\n"
    print "Verify your entry:"
    print "Title: " + NewEntry.Title
    print "Author First: " + NewEntry.Author_First
    print "Author Last: " + NewEntry.Author_Last
    print "Series: " + NewEntry.Series
    print "Date: " + NewEntry.Date
    print "Genre: " + NewEntry.Genre

    Ver = raw_input("\nCorrect (y/n): ")
    while not (Ver == "y") and not (Ver == "n"):
        Ver = raw_input("\nCorrect (y/n): ")

    if Ver == "n":
        return

    os.chdir("Records")
    SearchString = NewEntry.Author_Last + "_" + NewEntry.Author_First
    NewAuthor = 1
    for FileName in glob.glob("*"):
        if FileName == SearchString:
            os.chdir(FileName)
            NewAuthor = 0
            break
    #### Easy one, make a new folder and entry
    if NewAuthor == 1:
        os.mkdir(SearchString)
        os.chdir(SearchString)
        fid = open(NewEntry.Series + ".txt", 'w')
        fid.write(NewEntry.Title + "," + NewEntry.Genre + "," + NewEntry.Author_Last + ","\
             + NewEntry.Author_First + "," + NewEntry.Date + "\n")
        fid.close()
        os.chdir("..")
        os.chdir("..")
        return

    #### Harder one, have to check if this entry exists
    for FileName in glob.glob("*.txt"):
        ### Check if this series is already started
        if FileName == (NewEntry.Series + ".txt"):
            ### Yep, now check if this entry exists
            fid = open(FileName, 'r')
            UserInput = "z"
            LineCount = 0
            for line in fid:
                LineCount = LineCount + 1
                Existing = line.split(',')
                if Existing[0] == NewEntry.Title and Existing[
                        1] == NewEntry.Genre:
                    print "WARNING: An entry exists under this author, series, and title:"
                    print line
                    UserInput = raw_input(
                        "\nAdd Another Entry (a), Overwrite Entry (o), Do Nothing (n): "
                    )
                    while not (UserInput == "a") and not (
                            UserInput == "o") and not (UserInput == "n"):
                        UserInput = raw_input(
                            "\nAdd Another Entry (a), Overwrite Entry (o), Do Nothing (n): "
                        )
                    break
            fid.close()
            if UserInput == "n":
                os.chdir("..")
                os.chdir("..")
                return
            elif UserInput == "a":
                fid = open(FileName, 'a')
                fid.write(NewEntry.Title + "," + NewEntry.Genre + "," + NewEntry.Author_Last +\
                     "," + NewEntry.Author_First + "," + NewEntry.Date + "\n")
                fid.close()
                os.chdir("..")
                os.chdir("..")
                return
            elif UserInput == "o":
                LineCount2 = 0
                fid = open(FileName, 'r')
                OldData = fid.readlines()
                fid.close
                fid = open(FileName, 'w')
                for line in OldData:
                    LineCount2 = LineCount2 + 1
                    if LineCount2 == LineCount:
                        fid.write(NewEntry.Title + "," + NewEntry.Genre + "," + NewEntry.Author_Last\
                             + "," + NewEntry.Author_First + "," + NewEntry.Date + "\n")
                    else:
                        fid.write(line)
                fid.close
                os.chdir("..")
                os.chdir("..")
                return

            else:
                fid = open(FileName, 'a')
                fid.write(NewEntry.Title + "," + NewEntry.Genre + "," + NewEntry.Author_Last\
                     + "," + NewEntry.Author_First + "," + NewEntry.Date + "\n")
                fid.close()
                os.chdir("..")
                os.chdir("..")
                return

    ###If we're here, this series doesn't exist for this author
    fid = open(NewEntry.Series + ".txt", 'w')
    fid.write(NewEntry.Title + "," + NewEntry.Genre + "," + NewEntry.Author_Last + ","\
         + NewEntry.Author_First + "," + NewEntry.Date + "\n")
    fid.close()
    os.chdir("..")
    os.chdir("..")
    return
Exemple #5
0
def Add_New_Books_By_Series_Existing_Author():
    print "\n\n\n\n\n\n\n"
    print "Adding New Books to Existing Series"
    print "Enter date in \"YYYYMMDD\" format. Use \"0\" if not read yet, and \"9\" if unknown date."
    print "Enter \"+++\" to exit without saving anytime.\n\n"
    NewEntry = Book()
    NewEntry.Author_First = raw_input("Author First Name: ")
    if NewEntry.Author_First == "+++":
        return
    NewEntry.Author_Last = raw_input("Author Last Name: ")
    if NewEntry.Author_Last == "+++":
        return
    #NewEntry.Series = raw_input("Book Series: ")
    #if NewEntry.Series == "+++":
    #    return
    #NewEntry.Genre = raw_input("Genre: ")
    #if NewEntry.Genre == "+++":
    #    return

    print "\n\n\n\n"

    os.chdir("Records")
    SearchString = NewEntry.Author_Last + "_" + NewEntry.Author_First
    NewAuthor = 1
    for FileName in glob.glob("*"):
        if FileName == SearchString:
            NewAuthor = 0
            break

    #### If this author doesn't exist
    if NewAuthor == 1:
        print "That author doesn't exist!!!"
        os.chdir("..")
        return

    #### List the series available for the author
    SeriesList = Search_Records.Search_Author_Series_Return(SearchString)
    c = 1
    print "(0) Series Not Started"
    for Name in SeriesList:
        print "(" + str(c) + ") " + Name
        c = c + 1

    UserEntry = raw_input("Choose series: ")
    if UserEntry == "+++" or UserEntry == "0":
        os.chdir("..")
        return

    NewEntry.Title = raw_input("Title: ")
    if NewEntry.Title == "+++":
        os.chdir("..")
        return

    NewEntry.Date = raw_input("Date: ")
    if NewEntry.Date == "+++":
        fid.close()
        os.chdir("..")
        return
    if not NewEntry.Date:
        NewEntry.Date = "99999999"
    if NewEntry.Date == "0":
        NewEntry.Date = "00000000"
    if NewEntry.Date == "9":
        NewEntry.Date = "99999999"

    os.chdir(SearchString)

    ### Yep, now check if this entry exists
    FileName = SeriesList[int(UserEntry) - 1] + ".txt"

    if FileName == "Misc.txt":
        NewEntry.Genre = raw_input("Genre: ")
        if NewEntry.Genre == "+++":
            fid.close()
            os.chdir("..")
            return

    fid = open(FileName, 'r')
    UserInput = "z"
    LineCount = 0
    for line in fid:
        LineCount = LineCount + 1
        Existing = line.split(',')
        if not NewEntry.Genre:
            NewEntry.Genre = Existing[1]
        if Existing[0] == NewEntry.Title and Existing[1] == NewEntry.Genre:
            print "WARNING: An entry exists under this author, series, and title:"
            print line
            UserInput = raw_input(
                "\nAdd Another Entry (a), Overwrite Entry (o), Do Nothing (n): "
            )
            while not (UserInput == "a") and not (UserInput == "o") and not (
                    UserInput == "n"):
                UserInput = raw_input(
                    "\nAdd Another Entry (a), Overwrite Entry (o), Do Nothing (n): "
                )
            break
    fid.close()
    if UserInput == "n":
        print "No changes made"
    elif UserInput == "a":
        fid = open(FileName, 'a')
        fid.write(NewEntry.Title + "," + NewEntry.Genre + "," + NewEntry.Author_Last +\
            "," + NewEntry.Author_First + "," + NewEntry.Date + "\n")
        fid.close()
    elif UserInput == "o":
        LineCount2 = 0
        fid = open(FileName, 'r')
        OldData = fid.readlines()
        fid.close()
        fid = open(FileName, 'w')
        for line in OldData:
            LineCount2 = LineCount2 + 1
            if LineCount2 == LineCount:
                fid.write(NewEntry.Title + "," + NewEntry.Genre + "," + NewEntry.Author_Last\
                  + "," + NewEntry.Author_First + "," + NewEntry.Date + "\n")
            else:
                fid.write(line)
        fid.close()

    else:
        fid = open(FileName, 'a')
        fid.write(NewEntry.Title + "," + NewEntry.Genre + "," + NewEntry.Author_Last\
            + "," + NewEntry.Author_First + "," + NewEntry.Date + "\n")
        fid.close()

    os.chdir("..")
    os.chdir("..")
    return
Exemple #6
0
def Add_New_Book():
    print "\n\n\n\n\n\n\n"
    print "Adding New Book"
    print "Enter date in \"YYYYMMDD\" format. Use \"0\" if not read yet, and \"9\" if unknown date."
    print "Enter \"+++\" to exit without saving anytime.\n\n"
    NewEntry = Book()
    NewEntry.Title = raw_input("Book Title: ")
    if NewEntry.Title == "+++":
        return
    NewEntry.Author_First = raw_input("Author First Name: ")
    if NewEntry.Author_First == "+++":
        return
    NewEntry.Author_Last = raw_input("Author Last Name: ")
    if NewEntry.Author_Last == "+++":
        return
    NewEntry.Series = raw_input("Book Series: ")
    if NewEntry.Series == "+++":
        return
    NewEntry.Date = raw_input("Date: ")
    if NewEntry.Date == "+++":
        return
    if not NewEntry.Date:
        NewEntry.Date = "99999999"
    if NewEntry.Date == "0":
        NewEntry.Date = "00000000"
    if NewEntry.Date == "9":
        NewEntry.Date = "99999999"
    NewEntry.Genre = raw_input("Genre: ")
    if NewEntry.Genre == "+++":
        return
    

    print "\n\n\n\n\n\n\n"
    print "Verify your entry:"
    print "Title: " + NewEntry.Title
    print "Author First: " + NewEntry.Author_First
    print "Author Last: " + NewEntry.Author_Last
    print "Series: " + NewEntry.Series
    print "Date: " + NewEntry.Date
    print "Genre: " + NewEntry.Genre

    Ver = raw_input("\nCorrect (y/n): ")
    while not (Ver == "y")  and not (Ver == "n"):
        Ver = raw_input("\nCorrect (y/n): ")
    
    if Ver == "n":
        return
    
    os.chdir("Records")
    SearchString = NewEntry.Author_Last + "_" + NewEntry.Author_First
    NewAuthor = 1
    for FileName in glob.glob("*"):
        if FileName == SearchString:
            os.chdir(FileName)
            NewAuthor = 0
            break
    #### Easy one, make a new folder and entry
    if NewAuthor == 1:
        os.mkdir(SearchString)
        os.chdir(SearchString)
        fid = open(NewEntry.Series + ".txt",'w')
        fid.write(NewEntry.Title + "," + NewEntry.Genre + "," + NewEntry.Author_Last + ","\
             + NewEntry.Author_First + "," + NewEntry.Date + "\n")
        fid.close()
        os.chdir("..")
        os.chdir("..")
        return 
        
    #### Harder one, have to check if this entry exists 
    for FileName in glob.glob("*.txt"):
        ### Check if this series is already started 
        if FileName == (NewEntry.Series+".txt"):
            ### Yep, now check if this entry exists
            fid = open(FileName,'r')
            UserInput = "z"
            LineCount = 0
            for line in fid:
                LineCount = LineCount + 1
                Existing = line.split(',')
                if Existing[0] == NewEntry.Title and Existing[1] == NewEntry.Genre:
                    print "WARNING: An entry exists under this author, series, and title:"
                    print line
                    UserInput = raw_input("\nAdd Another Entry (a), Overwrite Entry (o), Do Nothing (n): ")
                    while not (UserInput == "a") and not (UserInput == "o") and not (UserInput == "n"):
                        UserInput = raw_input("\nAdd Another Entry (a), Overwrite Entry (o), Do Nothing (n): ")
                    break
            fid.close()
            if UserInput == "n":
                os.chdir("..")
                os.chdir("..")
                return
            elif UserInput == "a":
                fid = open(FileName,'a')
                fid.write(NewEntry.Title + "," + NewEntry.Genre + "," + NewEntry.Author_Last +\
                     "," + NewEntry.Author_First + "," + NewEntry.Date + "\n")
                fid.close()
                os.chdir("..")
                os.chdir("..")
                return
            elif UserInput == "o":
                LineCount2 = 0;
                fid = open(FileName,'r')
                OldData = fid.readlines()
                fid.close
                fid = open(FileName,'w')
                for line in OldData:
                    LineCount2 = LineCount2 + 1
                    if LineCount2 == LineCount:
                        fid.write(NewEntry.Title + "," + NewEntry.Genre + "," + NewEntry.Author_Last\
                             + "," + NewEntry.Author_First + "," + NewEntry.Date + "\n")
                    else: 
                        fid.write(line)
                fid.close
                os.chdir("..")
                os.chdir("..")
                return

            else:
                fid = open(FileName,'a')
                fid.write(NewEntry.Title + "," + NewEntry.Genre + "," + NewEntry.Author_Last\
                     + "," + NewEntry.Author_First + "," + NewEntry.Date + "\n")
                fid.close()
                os.chdir("..")
                os.chdir("..")
                return

    ###If we're here, this series doesn't exist for this author
    fid = open(NewEntry.Series + ".txt",'w')
    fid.write(NewEntry.Title + "," + NewEntry.Genre + "," + NewEntry.Author_Last + ","\
         + NewEntry.Author_First + "," + NewEntry.Date + "\n")
    fid.close()
    os.chdir("..")
    os.chdir("..")
    return
Exemple #7
0
def Add_New_Books_By_Series_Existing_Author():
    print "\n\n\n\n\n\n\n"
    print "Adding New Books to Existing Series"
    print "Enter date in \"YYYYMMDD\" format. Use \"0\" if not read yet, and \"9\" if unknown date."
    print "Enter \"+++\" to exit without saving anytime.\n\n"
    NewEntry = Book()
    NewEntry.Author_First = raw_input("Author First Name: ")
    if NewEntry.Author_First == "+++":
        return
    NewEntry.Author_Last = raw_input("Author Last Name: ")
    if NewEntry.Author_Last == "+++":
        return
    #NewEntry.Series = raw_input("Book Series: ")
    #if NewEntry.Series == "+++":
    #    return
    #NewEntry.Genre = raw_input("Genre: ")
    #if NewEntry.Genre == "+++":
    #    return
    

    print "\n\n\n\n"
    
    os.chdir("Records")
    SearchString = NewEntry.Author_Last + "_" + NewEntry.Author_First
    NewAuthor = 1
    for FileName in glob.glob("*"):
        if FileName == SearchString:
            NewAuthor = 0
            break
    
    #### If this author doesn't exist
    if NewAuthor == 1:
        print "That author doesn't exist!!!"
        os.chdir("..")
        return
   
   
    #### List the series available for the author
    SeriesList = Search_Records.Search_Author_Series_Return(SearchString)
    c = 1
    print "(0) Series Not Started"
    for Name in SeriesList:
       print "("+str(c)+") " + Name 
       c = c+1
    
    
    UserEntry = raw_input("Choose series: ")
    if UserEntry == "+++" or UserEntry == "0":
        os.chdir("..")
        return

    NewEntry.Title = raw_input("Title: ")
    if NewEntry.Title == "+++":
        os.chdir("..")
        return
    
        
    NewEntry.Date = raw_input("Date: ")
    if NewEntry.Date == "+++":
        fid.close()
        os.chdir("..")
        return
    if not NewEntry.Date:
        NewEntry.Date = "99999999"
    if NewEntry.Date == "0":
        NewEntry.Date = "00000000"
    if NewEntry.Date == "9":
        NewEntry.Date = "99999999"

    os.chdir(SearchString)

    ### Yep, now check if this entry exists
    FileName = SeriesList[int(UserEntry)-1]+".txt"

    if FileName == "Misc.txt":
        NewEntry.Genre = raw_input("Genre: ")
        if NewEntry.Genre == "+++":
            fid.close()
            os.chdir("..")
            return

    fid = open(FileName,'r')
    UserInput = "z"
    LineCount = 0
    for line in fid:
        LineCount = LineCount + 1
        Existing = line.split(',')
        if not NewEntry.Genre:
            NewEntry.Genre = Existing[1]
        if Existing[0] == NewEntry.Title and Existing[1] == NewEntry.Genre:
            print "WARNING: An entry exists under this author, series, and title:"
            print line
            UserInput = raw_input("\nAdd Another Entry (a), Overwrite Entry (o), Do Nothing (n): ")
            while not (UserInput == "a") and not (UserInput == "o") and not (UserInput == "n"):
                UserInput = raw_input("\nAdd Another Entry (a), Overwrite Entry (o), Do Nothing (n): ")
            break
    fid.close()
    if UserInput == "n":
        print "No changes made"
    elif UserInput == "a":
        fid = open(FileName,'a')
        fid.write(NewEntry.Title + "," + NewEntry.Genre + "," + NewEntry.Author_Last +\
            "," + NewEntry.Author_First + "," + NewEntry.Date + "\n")
        fid.close()
    elif UserInput == "o":
        LineCount2 = 0;
        fid = open(FileName,'r')
        OldData = fid.readlines()
        fid.close()
        fid = open(FileName,'w')
        for line in OldData:
            LineCount2 = LineCount2 + 1
            if LineCount2 == LineCount:
                fid.write(NewEntry.Title + "," + NewEntry.Genre + "," + NewEntry.Author_Last\
                  + "," + NewEntry.Author_First + "," + NewEntry.Date + "\n")
            else: 
                fid.write(line)
        fid.close()

    else:
        fid = open(FileName,'a')
        fid.write(NewEntry.Title + "," + NewEntry.Genre + "," + NewEntry.Author_Last\
            + "," + NewEntry.Author_First + "," + NewEntry.Date + "\n")
        fid.close()

    os.chdir("..")
    os.chdir("..")
    return