259 # detectlimit = form.get("detectlimit", "1")
260
261 # pylint: disable=abstract-class-instantiated
262 tmpfn = "td_%s.xlsx" % (263 datetime.datetime.utcnow().strftime("%Y%m%d%H%M%S"),
264 )
265 writer = pd.ExcelWriter(f"/tmp/{tmpfn}", engine="xlsxwriter")
45 .execute()
46 )
47 else:
48 print("%s %s" % (item["title"], ",".join(owners)))49
50
51if __name__ == "__main__":
33 for item in res["items"]:
34 owners = [a["emailAddress"] for a in item["owners"]]
35 if len(owners) == 1 and owners[0] == SA:
36 print("Updating %s" % (item["title"],))37 body = {
38 "value": "[email protected]",
39 "role": "owner",
29 SA = config["service_account"]
30
31 res = drive.files().list(q="'%s' in owners", maxResults=999).execute()
32 print("Query found %s items" % (len(res["items"]),))33 for item in res["items"]:
34 owners = [a["emailAddress"] for a in item["owners"]]
35 if len(owners) == 1 and owners[0] == SA:
76 for nit in trt["NIT"]:
77 for lnd in trt["LND"]:
78 for rep in range(1, trt["REPS"] + 1):
79 thisID = "%s||%s||%s||%s||%s||%s" % ( 80 get_just_code(
81 treatment_names.get(till, "")
82 ),
f-strings are the fastest way to format strings as compared to the following methods:
%
format()
str.join
+
operator to concatinate stringTemplate.substitute
Some less preferred ways to format strings are the following:
from string import Template
menu = ('eggs', 'spam', 42.4)
old_order = "%s and %s: %.2f ¤" % menu # [consider-using-f-string]
beginner_order = menu[0] + " and " + menu[1] + ": " + str(menu[2]) + " ¤"
joined_order = " and ".join(menu[:2])
format_order = "{} and {}: {:0.2f} ¤".format(menu[0], menu[1], menu[2])
named_format_order = "{eggs} and {spam}: {price:0.2f} ¤".format(eggs=menu[0], spam=menu[1], price=menu[2])
template_order = Template('$eggs and $spam: $price ¤').substitute(eggs=menu[0], spam=menu[1], price=menu[2])
Consider using f-strings as shown below:
menu = ('eggs', 'spam', 42.4)
f_string_order = f"{menu[0]} and {menu[1]}: {menu[2]:0.2f} ¤"