def get_available_services(): '''Load available services from json file and initialize list of parcel_services''' available_services, update_at = get_newest( read_file(filename=SERVICES_FILE)) parcel_services = [] for service in available_services: parcel_services.append(ParcelService(service)) return parcel_services
def crawl(target_file=DEFAULT_TARGET_FILE, init=False): process = CrawlerProcess(settings={ "FEEDS": { target_file: { "format": "jsonlines", "encoding": "utf8" }, }, }) data = jr.get_newest(jr.read_file(DEFAULT_TARGET_FILE))[0] copied_entries = [] if init == False: for i in data: if (i['update'] in SPIDERS): process.crawl(SPIDERS[i['update']]) else: copied_entries.append(i) else: for i in SPIDERS: print(i) process.crawl(SPIDERS[i]) #add timestamp if init == False: time = {'time': datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S")} with open(target_file, 'a') as f: json.dump(time, f) f.write('\n') process.start() if copied_entries: for i in copied_entries: with open(target_file, 'a') as f: json.dump(i, f) f.write('\n')
import tkinter as tk import json_reader import parcelServiceOption data = json_reader.read_file() new_data, update_from = json_reader.get_newest(data) parcelservices = [] lst = json_reader.create_info_list(new_data) for i in lst: parcelservices.append(parcelServiceOption.ParcelService(i)) ps = parcelservices[1] # border_effects = { # "flat": tk.FLAT, # "sunken": tk.SUNKEN, # "raised": tk.RAISED, # "groove": tk.GROOVE, # "ridge": tk.RIDGE, # } # for relief_name, relief in border_effects.items(): # frame = tk.Frame(master=window, relief=relief, borderwidth=5) # frame.pack(side=tk.LEFT) # label = tk.Label(master=frame, text=relief_name) # label.pack() def get_strsize_limit(size_limit): limits = [] for i in size_limit: