diff options
author | Ben Connors <benconnors@outlook.com> | 2019-01-28 12:44:15 -0500 |
---|---|---|
committer | Ben Connors <benconnors@outlook.com> | 2019-01-28 22:36:11 -0500 |
commit | 152d81de2ffc45db2e36ae263ccdcc67216f885a (patch) | |
tree | 8145dfe03d20cb755ee522512759b35861ae8dd5 | |
parent | a9c15b92d5ec6e88bca57a75fb0cbd3cd6b3fd76 (diff) |
Fix resolving audio paths
- Previously resolved relative to current working dir, now resolved
based on the directory containing the workspace file
-rwxr-xr-x | blc/workspace.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/blc/workspace.py b/blc/workspace.py index 03141e4..ac095ed 100755 --- a/blc/workspace.py +++ b/blc/workspace.py @@ -101,9 +101,10 @@ of single-shot chasers presently. Additionally, time is reset to 0 at the start from abc import ABC, abstractmethod import json +import logging from multiprocessing.pool import ThreadPool +import os.path import subprocess as subp -import logging import xml.etree.ElementTree as etree ## BEGIN Constants @@ -435,7 +436,7 @@ class Chaser(Function, Advanceable): Since they essentially do the same thing (Chaser being more general), they have only one class here.""" - repr_attr = ("id", "name", ("steps", lambda s: ",".join((i.id for i in s)))) + repr_attr = ("id", "name", ("steps", lambda s: ",".join((str(i.id) for i in s)))) class ChaserData: """Current state of a chaser.""" def __init__(self, step_data, obey_loop): @@ -781,7 +782,7 @@ class Workspace: Should be created using Workspace.load and is assumed to be immutable. """ @classmethod - def load(cls, fname, audio_length=ffprobe_audio_length): + def load(cls, wfname, audio_length=ffprobe_audio_length): """Load a QLC+ workspace. This function returns the created Workspace object. @@ -791,8 +792,10 @@ class Workspace: audio_length: a function accepting an audio filename and returning the length of that audio file in milliseconds. """ - a = etree.parse(fname) + a = etree.parse(wfname) ws = a.getroot() + + wdir = os.path.dirname(os.path.abspath(wfname)) creator = ws.find(QXW+"Creator") self = cls(creator.find(QXW+"Name").text, creator.find(QXW+"Version").text, @@ -854,7 +857,10 @@ class Workspace: bad = True break elif typ == AUDIO: - audio_fnames.append(f.find(QXW+"Source").text) + fname = f.find(QXW+"Source").text + if not os.path.isabs(fname): + fname = os.path.join(wdir, fname) + audio_fnames.append(fname) if bad: todo.append(f) else: @@ -909,6 +915,8 @@ class Workspace: func = Scene(sid, name, values, hidden=hidden) elif ftype == AUDIO: fname = func.find(QXW+"Source").text + if not os.path.isabs(fname): + fname = os.path.join(wdir, fname) func = Audio(sid, name, fname, fin, fout, audio_lengths[fname], run_order=ro, hidden=hidden) elif ftype == SEQUENCE: |