Ejemplo n.º 1
0
 def TimeInstruct(self, evt):
     """
         Function to open instructions for time string
     """
     webbrowseropen(u''.join([
         u'https://docs.python.org/3.5/library/datetime.html',
         u'#strftime-and-strptime-behavior'
     ]))
def choosechant(monastery):
    if not monastery.mp3list:
        anything_returned = monastery.getmp3list()
        if anything_returned:  # returns 'MainMenu' if not connected to internet and don't want to retry
            return anything_returned
    # some display about how many mp3s/blogposts were found
    border = "#"
    mp3detectstring = " " + str(len(monastery.mp3list)) + " mp3s detected."
    if monastery.bloglist:
        blogdetectstring = " " + str(len(
            monastery.bloglist)) + " blog posts detected."
        maxdetectstring = max([len(mp3detectstring), len(blogdetectstring)])
    else:
        maxdetectstring = len(mp3detectstring)
    for i in range(maxdetectstring):
        border += "#"
    print(border)
    print(mp3detectstring)
    if monastery.bloglist: print(blogdetectstring)
    print(border)
    # asks the user what he wants to play
    # the loop breaks when something is played;
    # this if-structure informs user of blog posts
    if monastery.bloglist: blog_keypress = 'Or see [B]log posts? '
    else: blog_keypress = ''
    for i in range(len(monastery.mp3list)):
        print("")
        response = input(" Hear " + monastery.mp3list[i][4] +
                         "? [Y/N] \n Or input the mp3's number? " +
                         blog_keypress + "Or Main [M]enu?\n >")
        # 'tries' to turn response into an integer
        try:
            int(response)
        # if it gets an error (i.e. not an integer) it does this:
        except ValueError:
            response = response.lower()
            if response == "y":
                webbrowseropen(monastery.mp3list[i][0])
                break
            elif response == "m":
                break  #breaks out of the mp3 choosing loop and goes back to main menu
            elif response == "b" and monastery.bloglist:
                result_from_display_blogs = display_blogs(monastery)
                if result_from_display_blogs:
                    blog_number = int(result_from_display_blogs) - 1
                    webbrowseropen(monastery.bloglist[blog_number][0])
                break
        # if it doesn't get an error (i.e. is an integer) it does this:
        else:
            if int(response) > 0 and int(response) <= len(monastery.mp3list):
                print("")
                response2 = input(" Hear " +
                                  monastery.mp3list[int(response) - 1][4] +
                                  "? [Y/N] \n >")
                if response2 == "Y" or response2 == "y":
                    webbrowseropen(monastery.mp3list[int(response) - 1][0])
                    break
            else:
                print(" Sorry, that recording is not available!")
Ejemplo n.º 3
0
def choosechant(monastery):
    if not monastery.mp3list:
        anything_returned = monastery.getmp3list()
        if anything_returned: # returns 'MainMenu' if not connected to internet and don't want to retry
            return anything_returned
    # some display about how many mp3s/blogposts were found
    border = "#"
    mp3detectstring = " " + str(len(monastery.mp3list)) + " mp3s detected."
    if monastery.bloglist:
        blogdetectstring = " " + str(len(monastery.bloglist)) + " blog posts detected."
        maxdetectstring = max([len(mp3detectstring), len(blogdetectstring)])
    else: maxdetectstring = len(mp3detectstring)
    for i in range(maxdetectstring):
        border += "#"
    print(border)
    print(mp3detectstring)
    if monastery.bloglist: print(blogdetectstring)
    print(border)
    # asks the user what he wants to play
    # the loop breaks when something is played;
    # this if-structure informs user of blog posts
    if monastery.bloglist: blog_keypress = 'Or see [B]log posts? '
    else: blog_keypress = ''
    for i in range(len(monastery.mp3list)):
        print("")
        response = input(" Hear " + monastery.mp3list[i][4] + "? [Y/N] \n Or input the mp3's number? " + blog_keypress + "Or Main [M]enu?\n >")
        # 'tries' to turn response into an integer
        try:
            int(response)
        # if it gets an error (i.e. not an integer) it does this:
        except ValueError:
            response = response.lower()
            if response == "y":
                webbrowseropen(monastery.mp3list[i][0])
                break
            elif response == "m":
                break #breaks out of the mp3 choosing loop and goes back to main menu
            elif response == "b" and monastery.bloglist:
                result_from_display_blogs = display_blogs(monastery)
                if result_from_display_blogs:
                    blog_number = int(result_from_display_blogs) - 1
                    webbrowseropen(monastery.bloglist[blog_number][0])
                break
        # if it doesn't get an error (i.e. is an integer) it does this:
        else:
            if int(response) > 0 and int(response) <= len(monastery.mp3list):
                print("")
                response2 = input(" Hear " + monastery.mp3list[int(response)-1][4] + "? [Y/N] \n >")
                if response2 == "Y" or response2 == "y":
                    webbrowseropen(monastery.mp3list[int(response) - 1][0])
                    break
            else:
                print(" Sorry, that recording is not available!")
def choosechant(choice):	
    global expression
    
    # gets the text of the feed website as a weird object
    text = urlopen(choice.website)
    
    linelist = []
    mp3list = []

    # makes a list called linelist
    # each item in the list is a line of text from the site
    # it also makes a list called mp3list
    # and it checks each item in linelist for a url
    # it then adds the urls to mp3list
    for line in text:
        linelist.append(line)
        if search(expression, line):
            result = findall(expression, line)
            for i in range(len(result)):
                result[i] = sub('enclosure url="', '', result[i])
                mp3list.append(result[i])
    
    # just formats the ###s to fit nicely around the text
    #OLD METHOD:
    #digits = len(str(len(linelist)))
    #border = "##############################################"
    border = "#"
    textlinestring = " " + str(len(linelist)) + " lines of text at " + choice.website + "."
    mp3detectstring = " " + str(len(mp3list)) + " mp3s detected."
    for i in range(len(textlinestring)):
        border += "#"
    print border
    print textlinestring
    print mp3detectstring
    print border
    
    # asks the user what he wants to play
    # the loop breaks when something is played
    for i in range(len(mp3list)):
        mp3name = getmp3name(i, mp3list)
        print ""
        response = raw_input(" Hear " + getofficenamedate(mp3name, linelist) + "? [Y/N] \n Or input the mp3's number? Or Main [M]enu?\n >")
        # 'tries' to turn response into an integer
        try:
            int(response)
        # if it gets an error (i.e. not an integer) it does this:
        except ValueError:
            if response == "Y" or response == "y":
                webbrowseropen(mp3list[i])
                break
            elif response == "M" or response == "m":
                break #breaks out of the mp3 choosing loop and goes back to main menu
        # if it doesn't get an error (i.e. is an integer) it does this:
        else:
            if int(response) > 0 and int(response) <= len(mp3list):
                mp3name = getmp3name(int(response) - 1, mp3list)
                print ""
                response2 = raw_input(" Hear " + getofficenamedate(mp3name, linelist) + "? [Y/N] \n >")
                if response2 == "Y" or response2 == "y":
                    webbrowseropen(mp3list[int(response) - 1])
                    break
            else:
                print " Sorry, that recording is not available!"
Ejemplo n.º 5
0
def choosechant(choice):
    global expression

    # gets the text of the feed website as a weird object
    text = urlopen(choice.website)

    linelist = []
    mp3list = []

    # makes a list called linelist
    # each item in the list is a line of text from the site
    # it also makes a list called mp3list
    # and it checks each item in linelist for a url
    # it then adds the urls to mp3list
    for line in text:
        linelist.append(line)
        if search(expression, line):
            result = findall(expression, line)
            for i in range(len(result)):
                result[i] = sub('enclosure url="', '', result[i])
                mp3list.append(result[i])

    # just formats the ###s to fit nicely around the text
    #OLD METHOD:
    #digits = len(str(len(linelist)))
    #border = "##############################################"
    border = "#"
    textlinestring = " " + str(
        len(linelist)) + " lines of text at " + choice.website + "."
    mp3detectstring = " " + str(len(mp3list)) + " mp3s detected."
    for i in range(len(textlinestring)):
        border += "#"
    print border
    print textlinestring
    print mp3detectstring
    print border

    # asks the user what he wants to play
    # the loop breaks when something is played
    for i in range(len(mp3list)):
        mp3name = getmp3name(i, mp3list)
        print ""
        response = raw_input(
            " Hear " + getofficenamedate(mp3name, linelist) +
            "? [Y/N] \n Or input the mp3's number? Or Main [M]enu?\n >")
        # 'tries' to turn response into an integer
        try:
            int(response)
        # if it gets an error (i.e. not an integer) it does this:
        except ValueError:
            if response == "Y" or response == "y":
                webbrowseropen(mp3list[i])
                break
            elif response == "M" or response == "m":
                break  #breaks out of the mp3 choosing loop and goes back to main menu
        # if it doesn't get an error (i.e. is an integer) it does this:
        else:
            if int(response) > 0 and int(response) <= len(mp3list):
                mp3name = getmp3name(int(response) - 1, mp3list)
                print ""
                response2 = raw_input(" Hear " +
                                      getofficenamedate(mp3name, linelist) +
                                      "? [Y/N] \n >")
                if response2 == "Y" or response2 == "y":
                    webbrowseropen(mp3list[int(response) - 1])
                    break
            else:
                print " Sorry, that recording is not available!"