all: Fix Python comparison to None and True, and use "not in".
These are basic PEP8 recommendations.
This commit is contained in:
parent
f3a596db7d
commit
4376c969f6
@ -45,7 +45,7 @@ def transfer_file(args):
|
|||||||
if "250" in ftp.cwd("/flash"):
|
if "250" in ftp.cwd("/flash"):
|
||||||
if not ftp_directory_exists(ftp, "sys"):
|
if not ftp_directory_exists(ftp, "sys"):
|
||||||
print("/flash/sys directory does not exist")
|
print("/flash/sys directory does not exist")
|
||||||
if not "550" in ftp.mkd("sys"):
|
if "550" not in ftp.mkd("sys"):
|
||||||
print("/flash/sys directory created")
|
print("/flash/sys directory created")
|
||||||
else:
|
else:
|
||||||
print("Error: cannot create /flash/sys directory")
|
print("Error: cannot create /flash/sys directory")
|
||||||
|
|||||||
@ -120,13 +120,13 @@ class PowerUp3:
|
|||||||
return int(self.char_batt_lvl.read()[0])
|
return int(self.char_batt_lvl.read()[0])
|
||||||
|
|
||||||
def speed(self, new_speed=None):
|
def speed(self, new_speed=None):
|
||||||
if new_speed == None:
|
if new_speed is None:
|
||||||
return int(self.char_control_speed.read()[0])
|
return int(self.char_control_speed.read()[0])
|
||||||
else:
|
else:
|
||||||
self.char_control_speed.write(bytearray([new_speed]))
|
self.char_control_speed.write(bytearray([new_speed]))
|
||||||
|
|
||||||
def angle(self, new_angle=None):
|
def angle(self, new_angle=None):
|
||||||
if new_angle == None:
|
if new_angle is None:
|
||||||
return int(self.char_control_angle.read()[0])
|
return int(self.char_control_angle.read()[0])
|
||||||
else:
|
else:
|
||||||
self.char_control_angle.write(bytearray([new_angle]))
|
self.char_control_angle.write(bytearray([new_angle]))
|
||||||
|
|||||||
@ -116,7 +116,7 @@ class PIOASMEmit:
|
|||||||
if label is None:
|
if label is None:
|
||||||
label = 0
|
label = 0
|
||||||
else:
|
else:
|
||||||
if not label in self.labels:
|
if label not in self.labels:
|
||||||
raise PIOASMError("unknown label {}".format(label))
|
raise PIOASMError("unknown label {}".format(label))
|
||||||
label = self.labels[label]
|
label = self.labels[label]
|
||||||
self.prog[_PROG_DATA].append(instr | label)
|
self.prog[_PROG_DATA].append(instr | label)
|
||||||
|
|||||||
@ -94,7 +94,7 @@ def compute_pll2(hse, sys, relax_pll48):
|
|||||||
fallback = None
|
fallback = None
|
||||||
for P in mcu.range_p:
|
for P in mcu.range_p:
|
||||||
# VCO_OUT must be between 192MHz and 432MHz
|
# VCO_OUT must be between 192MHz and 432MHz
|
||||||
if not sys * P in mcu.range_vco_out:
|
if sys * P not in mcu.range_vco_out:
|
||||||
continue
|
continue
|
||||||
NbyM = float(sys * P) / hse # float for Python 2
|
NbyM = float(sys * P) / hse # float for Python 2
|
||||||
# scan M
|
# scan M
|
||||||
|
|||||||
@ -122,9 +122,9 @@ def do_filesystem(state, args):
|
|||||||
if command == "cat":
|
if command == "cat":
|
||||||
# Don't be verbose by default when using cat, so output can be
|
# Don't be verbose by default when using cat, so output can be
|
||||||
# redirected to something.
|
# redirected to something.
|
||||||
verbose = args.verbose == True
|
verbose = args.verbose is True
|
||||||
else:
|
else:
|
||||||
verbose = args.verbose != False
|
verbose = args.verbose is not False
|
||||||
|
|
||||||
if command == "cp" and args.recursive:
|
if command == "cp" and args.recursive:
|
||||||
if paths[-1] != ":":
|
if paths[-1] != ":":
|
||||||
|
|||||||
@ -85,9 +85,9 @@ def convert_from_uf2(buf):
|
|||||||
if datalen > 476:
|
if datalen > 476:
|
||||||
assert False, "Invalid UF2 data size at " + ptr
|
assert False, "Invalid UF2 data size at " + ptr
|
||||||
newaddr = hd[3]
|
newaddr = hd[3]
|
||||||
if (hd[2] & 0x2000) and (currfamilyid == None):
|
if (hd[2] & 0x2000) and (currfamilyid is None):
|
||||||
currfamilyid = hd[7]
|
currfamilyid = hd[7]
|
||||||
if curraddr == None or ((hd[2] & 0x2000) and hd[7] != currfamilyid):
|
if curraddr is None or ((hd[2] & 0x2000) and hd[7] != currfamilyid):
|
||||||
currfamilyid = hd[7]
|
currfamilyid = hd[7]
|
||||||
curraddr = newaddr
|
curraddr = newaddr
|
||||||
if familyid == 0x0 or familyid == hd[7]:
|
if familyid == 0x0 or familyid == hd[7]:
|
||||||
@ -111,7 +111,7 @@ def convert_from_uf2(buf):
|
|||||||
families_found[hd[7]] = newaddr
|
families_found[hd[7]] = newaddr
|
||||||
else:
|
else:
|
||||||
families_found[hd[7]] = newaddr
|
families_found[hd[7]] = newaddr
|
||||||
if prev_flag == None:
|
if prev_flag is None:
|
||||||
prev_flag = hd[2]
|
prev_flag = hd[2]
|
||||||
if prev_flag != hd[2]:
|
if prev_flag != hd[2]:
|
||||||
all_flags_same = False
|
all_flags_same = False
|
||||||
@ -234,7 +234,7 @@ def convert_from_hex_to_uf2(buf):
|
|||||||
break
|
break
|
||||||
elif tp == 0:
|
elif tp == 0:
|
||||||
addr = upper + ((rec[1] << 8) | rec[2])
|
addr = upper + ((rec[1] << 8) | rec[2])
|
||||||
if appstartaddr == None:
|
if appstartaddr is None:
|
||||||
appstartaddr = addr
|
appstartaddr = addr
|
||||||
i = 4
|
i = 4
|
||||||
while i < len(rec) - 1:
|
while i < len(rec) - 1:
|
||||||
@ -419,7 +419,7 @@ def main():
|
|||||||
)
|
)
|
||||||
if args.convert or ext != "uf2":
|
if args.convert or ext != "uf2":
|
||||||
drives = []
|
drives = []
|
||||||
if args.output == None:
|
if args.output is None:
|
||||||
args.output = "flash." + ext
|
args.output = "flash." + ext
|
||||||
else:
|
else:
|
||||||
drives = get_drives()
|
drives = get_drives()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user