|
5 | 5 | import re |
6 | 6 | from urlparse import urlparse |
7 | 7 |
|
8 | | -from ..remote.thriftbackend.thriftgen.pyload.ttypes import OnlineStatus |
9 | | - |
10 | 8 | def matchFirst(string, *args): |
11 | 9 | """ matches against list of regexp and returns first match""" |
12 | 10 | for patternlist in args: |
@@ -95,49 +93,29 @@ def parseNames(files): |
95 | 93 | name = name.replace(r.group(0), "") |
96 | 94 | patternMatch = True |
97 | 95 |
|
98 | | - # remove extension |
99 | | - index = name.rfind(".") |
100 | | - if index <= 0: |
101 | | - index = name.rfind("_") |
102 | | - if index > 0: |
103 | | - length = len(name) - index |
104 | | - if length <= 4: |
105 | | - name = name[:-length] |
106 | | - |
107 | | - # remove endings like . _ - |
108 | | - r = pat3.search(name) |
109 | | - if r is not None: |
110 | | - name = r.group(1) |
111 | | - |
112 | | - # replace . and _ with space |
113 | | - name = name.replace(".", " ") |
114 | | - name = name.replace("_", " ") |
115 | | - |
116 | | - name = name.strip() |
117 | | - |
118 | | - # special checks if no extension pattern matched |
119 | | - if patternMatch is False: |
120 | | - # checks if name could be a hash |
121 | | - if file.find("file/" + name) >= 0: |
122 | | - name = "" |
123 | | - |
124 | | - if file.find("files/" + name) >= 0: |
125 | | - name = "" |
126 | | - |
127 | | - r = re.search("^[0-9]+$", name, re.I) |
| 96 | + # additional checks if extension pattern matched |
| 97 | + if patternMatch: |
| 98 | + # remove extension |
| 99 | + index = name.rfind(".") |
| 100 | + if index <= 0: |
| 101 | + index = name.rfind("_") |
| 102 | + if index > 0: |
| 103 | + length = len(name) - index |
| 104 | + if length <= 4: |
| 105 | + name = name[:-length] |
| 106 | + |
| 107 | + # remove endings like . _ - |
| 108 | + r = pat3.search(name) |
128 | 109 | if r is not None: |
129 | | - name = "" |
| 110 | + name = r.group(1) |
130 | 111 |
|
131 | | - r = re.search("^[0-9a-z]+$", name, re.I) |
132 | | - if r is not None: |
133 | | - r1 = re.search("[0-9]+.+[0-9]", name) |
134 | | - r2 = re.search("[a-z]+.+[a-z]+", name, re.I) |
135 | | - if r1 is not None and r2 is not None: |
136 | | - name = "" |
137 | | - |
138 | | - path = urlparse(file).path |
139 | | - if path == "/" + name or path == "/" + name + ".htm": |
140 | | - name = "" |
| 112 | + # replace . and _ with space |
| 113 | + name = name.replace(".", " ") |
| 114 | + name = name.replace("_", " ") |
| 115 | + |
| 116 | + name = name.strip() |
| 117 | + else: |
| 118 | + name = "" |
141 | 119 |
|
142 | 120 | # fallback: package by hoster |
143 | 121 | if not name: |
|
0 commit comments