From e0aa6007ffe5c14a7a834c8d4fa5cfd636a0f9ac Mon Sep 17 00:00:00 2001 From: Gra Date: Tue, 9 Jun 2009 14:26:13 +0200 Subject: [PATCH] UNIX commands replaced by Python code for portability. --- pl.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/pl.py b/pl.py index 2c5e7db..be80846 100755 --- a/pl.py +++ b/pl.py @@ -161,16 +161,11 @@ def main(): else: print "Everything is OK." elif action == 'create': - command = "find %(find_dir)s -type f | grep -e '%(regex)s' | " + \ - "sed -e 's#^%(replace_dir)s/#%(prefix)s#g' | sort >> %(pl)s" - command = command % \ - dict(find_dir=options.target, - replace_dir=options.target, - pl=playlists[0], - prefix=options.prefix, - regex=r"\.\(%s\)$" % r'\|'.join(MUSIC_EXT)) - # print command - os.system(command) + pl_list = music_files_list(options.target) + pl_list = [elt.replace(options.target, options.prefix) \ + for elt in pl_list] + pl_file = open(playlists[0], 'a') + pl_file.write('\n' + '\n'.join(pl_list)) else: print "This unknown action should have been caught as an error." print "Please report this bug precising '%s not implemented'." % action -- 2.45.1