Skip to content

Commit ce01b8c

Browse files
committed
add Program.from_file
1 parent 679feb8 commit ce01b8c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

adafruit_pioasm.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,13 @@ def parse_rxfifo_brackets(arg, fifo_dir):
502502

503503
self.debuginfo = (linemap, text_program) if build_debuginfo else None
504504

505+
@classmethod
506+
def from_file(cls, filename: str, **kwargs) -> "Program":
507+
"""Assemble a PIO program in a file"""
508+
with open(filename, "r", encoding="utf-8") as i:
509+
program = i.read()
510+
return cls(program, **kwargs)
511+
505512
def print_c_program(self, name: str, qualifier: str = "const") -> None:
506513
"""Print the program into a C program snippet"""
507514
if self.debuginfo is None:

0 commit comments

Comments
 (0)