sforkowany z mirror/rnsutils
Robustify instrument saving
rodzic
9b7f03062b
commit
8dc4316fda
|
@ -1,3 +1,6 @@
|
|||
### Changed
|
||||
- robustify instrument saving (creating temporary file and renaming it on success)
|
||||
|
||||
## [0.8.0] - 2016-02-02
|
||||
### Added
|
||||
- added xrnicomment CLI
|
||||
|
|
|
@ -150,7 +150,9 @@ class RenoiseInstrument(object):
|
|||
logging.error("Destination file %s exists and overwrite was not forced", filename)
|
||||
return
|
||||
|
||||
with ZipFile(filename, 'w', compression=ZIP_DEFLATED) as z:
|
||||
temp_filename = filename + '.part'
|
||||
|
||||
with ZipFile(temp_filename, 'w', compression=ZIP_DEFLATED) as z:
|
||||
objectify.deannotate(self.root, cleanup_namespaces=True, xsi_nil=True)
|
||||
z.writestr("Instrument.xml", etree.tostring(self.root, pretty_print=True))
|
||||
for sample_idx, sample in enumerate(self.sample_data):
|
||||
|
@ -159,6 +161,8 @@ class RenoiseInstrument(object):
|
|||
guesstimate_audio_extension(sample) or "wav"),
|
||||
sample)
|
||||
|
||||
os.rename(temp_filename, filename)
|
||||
|
||||
@property
|
||||
def samples(self):
|
||||
return list(self.root.SampleGenerator.Samples.Sample)
|
||||
|
|
Ładowanie…
Reference in New Issue