freeDSP / freeDSP-aurora

freeDSP ADAU1452 with 8 analog input, 8 analog outputs, S/P-DIF I/O, ADAT I/O, USB Audio Class2, WiFi, Bluetooth
Creative Commons Attribution Share Alike 4.0 International
176 stars 55 forks source link

Rework sigma2aurora.py script #92

Closed zas closed 2 years ago

zas commented 2 years ago
zas commented 2 years ago

@dspverden I wonder about:

split_path = path_sigmastudioproject.rsplit("\\", 1)
filename = os.path.basename(split_path[0])
projectname = filename.split(".")[0]

At least, it should use os.path.sep instead of "\\", but I'm not sure about what's in path_sigmastudioproject, a full path?

If it does what I think it does it should be equivalent to:

filename = os.path.basename(os.path.dirname(path_sigmastudioproject))
dspverden commented 2 years ago

@zas While you were working on your pull request I have made a change to the python script. Can you please crosscheck for conflicts with your pull request?

Regarding the split_path: path_sigmastudioproject the path to the sigma studio file, e.g. 8channels.dspproj including the file name. It can be a full path or relative to current working directory.

zas commented 2 years ago

@zas While you were working on your pull request I have made a change to the python script. Can you please crosscheck for conflicts with your pull request?

Done.

EDIT: I rebased on your change, but please do not edit anymore until this is merged, the PEP8 changes are heavy. BTW, I recommend you to use autopep8 and configure your editor for Python. Python style is somehow free, but it's a good practice to conform to PEP8, to ease collaboration with other devs.

Regarding the split_path: path_sigmastudioproject the path to the sigma studio file, e.g. 8channels.dspproj including the file name. It can be a full path or relative to current working directory.

So if path_sigmastudioproject path is dir1/dir2/8channels.dspproj, you expect projectname to be "8channels", right ? I don't understand the split_path = path_sigmastudioproject.rsplit("\\", 1), is "\\" the file path separator here? but if you're on mac, it should be "/" like on linux.

dspverden commented 2 years ago

So if path_sigmastudioproject path is dir1/dir2/8channels.dspproj, you expect projectname to be "8channels", right ? I don't understand the split_path = path_sigmastudioproject.rsplit("\\", 1), is "\\" the file path separator here? but if you're on mac, it should be "/" like on linux.

Yes, I expect projectname to be "8channels". You can see later in the script how it is used to build the special filenames created by the system file export of Sigma Studio. split_path = path_sigmastudioproject.rsplit("\\", 1): Actually, I am not really sure, why I made this but I remember that there was some difficulties with the path splitting.

zas commented 2 years ago

Yes, I expect projectname to be "8channels". You can see later in the script how it is used to build the special filenames created by the system file export of Sigma Studio. split_path = path_sigmastudioproject.rsplit("\\", 1): Actually, I am not really sure, why I made this but I remember that there was some difficulties with the path splitting.

IMHO, it was buggy, and did nothing:

>>> import os
>>> path_sigmastudioproject = os.path.join('dir1', 'dir2', '8channels.dspproj')
>>> split_path = path_sigmastudioproject.rsplit("\\", 1)
>>> split_path
['dir1/dir2/8channels.dspproj']
>>> filename = os.path.basename(split_path[0])
>>> filename
'8channels.dspproj'
>>> projectname = filename.split(".")[0]
>>> projectname
'8channels'

So I think we can replace those 3 lines with:

>>> projectname = os.path.splitext(os.path.basename(path_sigmastudioproject))[0]
>>> projectname
'8channels'

It will work on all platforms.

I did it in 88eb497, can you test?

dspverden commented 2 years ago

I will test it tomorrow. Thank you for your work.