add Program.from_file
This commit is contained in:
parent
679feb8e21
commit
ce01b8c10f
1 changed files with 7 additions and 0 deletions
|
|
@ -502,6 +502,13 @@ class Program: # pylint: disable=too-few-public-methods
|
|||
|
||||
self.debuginfo = (linemap, text_program) if build_debuginfo else None
|
||||
|
||||
@classmethod
|
||||
def from_file(cls, filename: str, **kwargs) -> "Program":
|
||||
"""Assemble a PIO program in a file"""
|
||||
with open(filename, "r", encoding="utf-8") as i:
|
||||
program = i.read()
|
||||
return cls(program, **kwargs)
|
||||
|
||||
def print_c_program(self, name: str, qualifier: str = "const") -> None:
|
||||
"""Print the program into a C program snippet"""
|
||||
if self.debuginfo is None:
|
||||
|
|
|
|||
Loading…
Reference in a new issue