UoC-Radio / flow-dashboard

A GUI editor of the radio station's on-air schedule.
GNU General Public License v3.0
12 stars 3 forks source link

Proper way for filename extraction #5

Closed ggalan87 closed 4 years ago

ggalan87 commented 4 years ago

The implementation below is wrong as filenames may include dots.

https://github.com/UoC-Radio/flow-dashboard/blob/43048e3500c4f9b31925cc52e3ae7401a8bfd286/helpers.py#L49-L50

Need to implement it as suggested in https://stackoverflow.com/questions/678236/how-to-get-the-filename-without-the-extension-from-a-path-in-python

panos-stavrianos commented 4 years ago

Something like this seems to work

def getPlaylistNameFromPath(playlistPath):
    name_split = basename(playlistPath).split('.')
    name_split.pop()
    return ' '.join(name_split)
elias-pap commented 4 years ago

Something like this seems to work

def getPlaylistNameFromPath(playlistPath):
    name_split = basename(playlistPath).split('.')
    name_split.pop()
    return ' '.join(name_split)

Last line should probably be "return '.'.join(name_split)". Please follow the suggestion of the above stackoverflow link, combine with basename function and submit a pull request.