def __ValidateDirectoryInternal(logger, path, baseRelativePath, includedFileList, throwExceptionForUnsupportedFiles, videos, additionalFiles): entries = os.listdir(path) for entry in entries: absolutePath = os.path.join(path, entry) relativePath = entry if len(baseRelativePath) > 0: relativePath = baseRelativePath + u"/" + entry if os.path.isdir(absolutePath): ReleaseExtractor.__ValidateDirectoryInternal( logger, absolutePath, relativePath, includedFileList, throwExceptionForUnsupportedFiles, videos, additionalFiles) elif os.path.isfile(absolutePath): if Settings.HasValidVideoExtensionToUpload(entry): videos.append(absolutePath) # Here we are checking the IncludedFileList for included files because with that it is possible to include unsupported files. elif Settings.HasValidAdditionalExtensionToUpload( entry) or includedFileList.IsIncluded(relativePath): additionalFiles.append(absolutePath) elif throwExceptionForUnsupportedFiles: raise PtpUploaderException( "File '%s' has unsupported extension." % absolutePath)
def __GetDefaultState(self): path = self.Name.lower() # Ignore special root directories. # !sample is used in HDBits releases. # Extras must be uploaded separately on PTP. if path.startswith("proof/") or path.startswith( "sample/") or path.startswith("!sample/") or path.startswith( "samples/") or path.startswith( "extra/") or path.startswith("extras/"): return IncludedFileItemState.Ignore name = os.path.basename(path) if Settings.IsFileOnIgnoreList(name): return IncludedFileItemState.Ignore if Settings.HasValidVideoExtensionToUpload( name) or Settings.HasValidAdditionalExtensionToUpload(name): return IncludedFileItemState.Include elif Unrar.IsFirstRar(name): return IncludedFileItemState.Include else: return IncludedFileItemState.Ignore