From 876673902e5ea8d5336e144cad18d23fda613e94 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Tue, 19 Jul 2011 00:36:50 +0200 Subject: cleanup --- module/common/packagetools.py | 64 ++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 43 deletions(-) (limited to 'module/common') diff --git a/module/common/packagetools.py b/module/common/packagetools.py index 9912a3f95..200f29c2f 100644 --- a/module/common/packagetools.py +++ b/module/common/packagetools.py @@ -5,8 +5,6 @@ import re from urlparse import urlparse -from ..remote.thriftbackend.thriftgen.pyload.ttypes import OnlineStatus - def matchFirst(string, *args): """ matches against list of regexp and returns first match""" for patternlist in args: @@ -95,49 +93,29 @@ def parseNames(files): name = name.replace(r.group(0), "") patternMatch = True - # remove extension - index = name.rfind(".") - if index <= 0: - index = name.rfind("_") - if index > 0: - length = len(name) - index - if length <= 4: - name = name[:-length] - - # remove endings like . _ - - r = pat3.search(name) - if r is not None: - name = r.group(1) - - # replace . and _ with space - name = name.replace(".", " ") - name = name.replace("_", " ") - - name = name.strip() - - # special checks if no extension pattern matched - if patternMatch is False: - # checks if name could be a hash - if file.find("file/" + name) >= 0: - name = "" - - if file.find("files/" + name) >= 0: - name = "" - - r = re.search("^[0-9]+$", name, re.I) + # additional checks if extension pattern matched + if patternMatch: + # remove extension + index = name.rfind(".") + if index <= 0: + index = name.rfind("_") + if index > 0: + length = len(name) - index + if length <= 4: + name = name[:-length] + + # remove endings like . _ - + r = pat3.search(name) if r is not None: - name = "" + name = r.group(1) - r = re.search("^[0-9a-z]+$", name, re.I) - if r is not None: - r1 = re.search("[0-9]+.+[0-9]", name) - r2 = re.search("[a-z]+.+[a-z]+", name, re.I) - if r1 is not None and r2 is not None: - name = "" - - path = urlparse(file).path - if path == "/" + name or path == "/" + name + ".htm": - name = "" + # replace . and _ with space + name = name.replace(".", " ") + name = name.replace("_", " ") + + name = name.strip() + else: + name = "" # fallback: package by hoster if not name: -- cgit v1.2.3