Merge branch 'master' of ssh://www.ducamps.win:1020/volume1/git/python

merge for push
This commit is contained in:
vincent 2018-01-31 21:28:23 +01:00
commit e65b9e4be2

View File

@ -3,11 +3,13 @@ from bs4 import BeautifulSoup
import urllib.request
import json
import sys
import os
class Interface:
def __init__(self):
self.data = load_jsonfile('chaine.json')
self.datafilepath=os.path.dirname(sys.argv[0])+"/chaine.json"
self.data = load_jsonfile(self.datafilepath)
self.fenetre = Tk()
self.fenetre.title("recherche de chaine")
self.value = StringVar()
@ -51,14 +53,14 @@ class Interface:
self.value.set("")
def click_reset(self):
print("exit")
print("reset")
self.fenetre.quit
self.label2["text"] = ""
self.fenetre.mainloop
def click_update(self):
parsechaine()
self.data = load_jsonfile('chaine.json')
parsechaine(self.datafilepath)
self.data = load_jsonfile(self.datafilepath)
self.label2["text"] += "update chaine done"+"\r"
@ -77,7 +79,7 @@ def RepresentsInt(s):
return False
def parsechaine():
def parsechaine(file):
URL = 'https://fr.wikipedia.org/wiki/Liste_des_cha%C3%AEnes_de_Canal'
liste_chaine = {}
response = urllib.request.urlopen(URL)
@ -98,13 +100,15 @@ def parsechaine():
#print(firstTD.find_next().string)
liste_chaine[num] = firstTD.find_next().string
print(json.dumps(liste_chaine, indent=4))
with open('chaine.json', 'w', encoding='utf-8') as f:
with open(file, 'w', encoding='utf-8') as f:
json.dump(liste_chaine, f, indent=4)
interface = Interface()
if len(sys.argv) > 1:
arg = True