Closed proItheus closed 5 months ago
Took me a while to see what you mean. This problem pops up only when self.directory
contains, for instance, a dir called [abcd]
. If it's a subdir of self.directory
, no problem.
I'm going to pass the blame on to glob.glob
. glob.escape
ing the string first solves the issues.
But maybe I've found a good excuse to switch to Pathlib:
> a = "/Users/brent/tmp/[abcd]" # this is a dir I created for this test.
> os.path.exists(a)
True
> glob.glob(a+'/*')
[]
> glob.glob(r""+a+'/*') # a trick pulled from some SO post, which should hopefully let glob know to not interpret `[]` as special chars
[]
> list(Path(a).glob('*'))
[PosixPath('/Users/brent/tmp/[abcd]/11 - Rubber Bullets.m4a'), PosixPath('/Users/brent/tmp/[abcd]/11 - Rubber Bullets.m4a.vol000+100.par2'), PosixPath('/Users/brent/tmp/[abcd]/11 - Rubber Bullets.m4a.par2')]
Ah, by escape
I mean using glob.escape("[abcd]")
.
It will turn [abcd]
into [[]abcd]
.
The program can't properly handle directory with special chars (in glob) like
[abcd]
.I think it's because you've forgotten escaping
self.directory
inpar2deep.py
.https://github.com/brenthuisman/par2deep/blob/ae275e6930fa8592331e3a0f9dd499f196df6e12/par2deep/par2deep.py#L146