Generates packages names from name, data lists :param files: list of (name, data) :return: packagenames mapt to data lists (eg. urls)
(files)
| 18 | |
| 19 | |
| 20 | def parseNames(files): |
| 21 | """ Generates packages names from name, data lists |
| 22 | |
| 23 | :param files: list of (name, data) |
| 24 | :return: packagenames mapt to data lists (eg. urls) |
| 25 | """ |
| 26 | packs = {} |
| 27 | |
| 28 | endings = "\\.(3gp|7zip|7z|abr|ac3|aiff|aifc|aif|ai|au|avi|bin|bz2|cbr|cbz|ccf|cue|cvd|chm|dta|deb|divx|djvu|dlc|dmg|doc|docx|dot|eps|exe|ff|flv|f4v|gsd|gif|gz|iwd|iso|ipsw|java|jar|jpg|jpeg|jdeatme|load|mws|mw|m4v|m4a|mkv|mp2|mp3|mp4|mov|movie|mpeg|mpe|mpg|msi|msu|msp|nfo|npk|oga|ogg|ogv|otrkey|pkg|png|pdf|pptx|ppt|pps|ppz|pot|psd|qt|rmvb|rm|rar|ram|ra|rev|rnd|r\\d+|rpm|run|rsdf|rtf|sh(!?tml)|srt|snd|sfv|swf|tar|tif|tiff|ts|txt|viv|vivo|vob|wav|wmv|xla|xls|xpi|zeno|zip|z\\d+|_[_a-z]{2}|\\d+$)" |
| 29 | |
| 30 | rarPats = [re.compile("(.*)(\\.|_|-)pa?r?t?\\.?[0-9]+.(rar|exe)$", re.I), |
| 31 | re.compile("(.*)(\\.|_|-)part\\.?[0]*[1].(rar|exe)$", re.I), |
| 32 | re.compile("(.*)\\.rar$", re.I), |
| 33 | re.compile("(.*)\\.r\\d+$", re.I), |
| 34 | re.compile("(.*)(\\.|_|-)\\d+$", re.I)] |
| 35 | |
| 36 | zipPats = [re.compile("(.*)\\.zip$", re.I), |
| 37 | re.compile("(.*)\\.z\\d+$", re.I), |
| 38 | re.compile("(?is).*\\.7z\\.[\\d]+$", re.I), |
| 39 | re.compile("(.*)\\.a.$", re.I)] |
| 40 | |
| 41 | ffsjPats = [re.compile("(.*)\\._((_[a-z])|([a-z]{2}))(\\.|$)"), |
| 42 | re.compile("(.*)(\\.|_|-)[\\d]+(" + endings + "$)", re.I)] |
| 43 | |
| 44 | iszPats = [re.compile("(.*)\\.isz$", re.I), |
| 45 | re.compile("(.*)\\.i\\d{2}$", re.I)] |
| 46 | |
| 47 | pat1 = re.compile("(\\.?CD\\d+)", re.I) |
| 48 | pat2 = re.compile("(\\.?part\\d+)", re.I) |
| 49 | |
| 50 | pat3 = re.compile("(.+)[\\.\\-_]+$") |
| 51 | pat4 = re.compile("(.+)\\.\\d+\\.xtm$") |
| 52 | |
| 53 | for file, url in files: |
| 54 | patternMatch = False |
| 55 | |
| 56 | if file is None: |
| 57 | continue |
| 58 | |
| 59 | # remove trailing / |
| 60 | name = file.rstrip('/') |
| 61 | |
| 62 | # extract last path part .. if there is a path |
| 63 | split = name.rsplit("/", 1) |
| 64 | if len(split) > 1: |
| 65 | name = split.pop(1) |
| 66 | |
| 67 | #check if a already existing package may be ok for this file |
| 68 | # found = False |
| 69 | # for pack in packs: |
| 70 | # if pack in file: |
| 71 | # packs[pack].append(url) |
| 72 | # found = True |
| 73 | # break |
| 74 | # |
| 75 | # if found: continue |
| 76 | |
| 77 | # unrar pattern, 7zip/zip and hjmerge pattern, isz pattern, FFSJ pattern |
no test coverage detected