mirror of
https://github.com/robmcmullen/atrcopy.git
synced 2024-06-09 15:29:27 +00:00
Added slice support for binary file writing
This commit is contained in:
parent
5438fa8dce
commit
d50ee6639c
|
@ -164,8 +164,24 @@ def assemble(image, source_files, data_files):
|
||||||
raise AtrError("Data files must include a load address specified with the @ char")
|
raise AtrError("Data files must include a load address specified with the @ char")
|
||||||
name, addr = name.rsplit("@", 1)
|
name, addr = name.rsplit("@", 1)
|
||||||
first = text_to_int(addr)
|
first = text_to_int(addr)
|
||||||
|
subset = slice(0, -1)
|
||||||
|
if "[" in name and "]" in name:
|
||||||
|
name, slicetext = name.rsplit("[", 1)
|
||||||
|
if ":" in slicetext:
|
||||||
|
start, end = slicetext.split(":", 1)
|
||||||
|
try:
|
||||||
|
start = int(start)
|
||||||
|
except:
|
||||||
|
start = 0
|
||||||
|
if end.endswith("]"):
|
||||||
|
end = end[:-1]
|
||||||
|
try:
|
||||||
|
end = int(end)
|
||||||
|
except:
|
||||||
|
end = None
|
||||||
|
subset = slice(start, end)
|
||||||
with open(name, 'rb') as fh:
|
with open(name, 'rb') as fh:
|
||||||
data = fh.read()
|
data = fh.read()[subset]
|
||||||
s = segments.add_segment(data, first)
|
s = segments.add_segment(data, first)
|
||||||
print s.name
|
print s.name
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user