Пример #1
0
 def test_addquery(self):
     url = 'https://github.com/jaideepcoder/ParseURL'
     parser = ParseURL(url)
     query = {'q': 'My+test+query'}
     parser.update_query(query)
     self.assertEqual({'q': 'My+test+query'}, parser.parsed_url.get_attr('query'))
     self.assertEqual('https://github.com/jaideepcoder/ParseURL?q=My+test+query', parser.url_unparse())
Пример #2
0
def check_for_updates(notifyHasLatest=False):
    '''Checks for an updated version online'''
    global latest_url
    global version
    try:
        latest = ParseURL.get_web_version(latest_url)
    except:
        return
    if float(latest) > version:
        msgBox = messagebox.askquestion(
            'New Version Found', 'New version found. Go to download page?')
        if msgBox == 'yes':
            r = requests.head(download_url)
            #Check for valid status codes. 200 for valid, 302 for redirect, 503 for service unavailable
            if r.status_code in [200, 302]:
                webbrowser.open_new(download_url)
            else:
                messagebox.showinfo(
                    'Nexus Page Unreachable',
                    'Nexus page unreachable. Opening Github download page instead.'
                )
                webbrowser.open_new(latest_url)
    elif notifyHasLatest:
        messagebox.showinfo('Up to Date',
                            'You have the latest version of the program.')
Пример #3
0
 def insertInput(self, index):
     url = askstring('New Mod at Index ' + str(index + 1),
                     'Input Nexus URL')
     info = None
     if (url is not None):
         info = ParseURL.parse_nexus_url(url)
     if info is not None:
         self.insert(index, info)
Пример #4
0
 def add_entry(self):
     '''adds a valid Nexus URL's mod data into the list'''
     url = self.url_entry.get()
     info = ParseURL.parse_nexus_url(url)
     #insert mod if parsed properly
     if info is not None:
         self.modlistbox.modlists[len(self.modlistbox.modlists) - 1].insert(
             END, info)
         #clear text after completion
         self.url_entry.delete(0, 'end')
Пример #5
0
 def insert(self, info_list):
     text = self.text.get('1.0', END)
     urls = text.splitlines()
     urls[:] = [x for x in urls if x != '']
     #Makes sure Nexus mods are correctly stripped
     for i in range(len(urls)):
         urls[i] = self.strip_nexus_mod(urls[i])
     infos = []
     if self.nexus:
         #Adds the information of only Nexus mods to the list
         for url in urls:
             info = ParseURL.parse_nexus_url(url, warning=False)
             if info is not None:
                 info_list.append(info)
     else:
         #Adds all the obtained urls to the list
         info_list += urls
     #Remove duplicates from the list
     info_list[:] = self.remove_dupes(info_list)
     if len(info_list) == 0:
         info_list.append(False)
     self.destroy()
Пример #6
0
 def test_unparse(self):
     url = 'https://github.com/jaideepcoder/ParseURL'
     parser = ParseURL(url)
     self.assertEqual(parser.url_unparse(), 'https://github.com/jaideepcoder/ParseURL')