1) The hash line only works if it is the first line in the file.
2) The names of functions and variables are usually allocated only at the bottom, not camelCase.
3) Dockstones usually use triple quotation marks, even for single-line dockers.
4) Your coding style is very functional, with many lambdas, maps, abbreviations, etc. and one copy of a four-line three-pole list comprehension. I find it difficult to understand this style and definitely deploy some of them.
5) , (4), , - :
match = [regex.match(str) for regex in episodeRegExes if regex.match(str)]
def getEpisodeTuple(iterable):
episodeTuple = [episodeChunk(chunk)
for chunk in iterable
if episodeChunk(chunk)]
if episodeTuple:
assert len(episodeTuple) == 1
return episodeTuple[0]
else:
return None
, (chunk) , , .
() (b) , , . :
def getEpisodeTuple(iterable):
for chunk in iterable:
echunk = episodeChunk(chunk)
if echunk:
return echunk
6) . , :
def splitWithAny(string, delimiters):
"Splits the string with any of the strings of delimiters"
return reduce(
lambda iterable, delim: reduce(
lambda lst,chunk: lst + chunk.split(delim),
iterable,
[]),
delimiters,
[string])
def splitName(fileName):
"Splits the fileName into smaller and hopefully significant chunks"
delimiters = [" ", ".", "_", "-"]
return filter(None, splitWithAny(fileName, delimiters))
( , - ( ( ()))) ..) :
def splitName(fileName):
return re.split("[ ._-]+", fileName)