-
Notifications
You must be signed in to change notification settings - Fork 2
/
utils.py
49 lines (43 loc) · 1.41 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This file is part of Uxie.
Uxie - Pokemon Showdown's usage stats database builder
Copyright (C) 2016-2017 Kewin Dousse (Protectator)
Licensed under the MIT License. See file LICENSE in the project root for license information.
"""
import re
def filter(file, filters):
if (filters['year'] and (file.year not in filters['year'])):
return False
if (filters['month']and (file.month not in filters['month'])):
return False
if (filters['gxe'] and (file.elo not in filters['gxe'])):
return False
if (filters['format'] and (file.meta not in filters['format'])):
return False
if (filters['type']):
type = typeoffolder(file.folders)
return type in filters['type']
return True
def filterFolder(folder, filters):
matchs = re.search('^/?(\d+)-(\d+)', folder)
year = int(matchs.groups()[0])
month = int(matchs.groups()[1])
if (filters['year'] and (year not in filters['year'])):
return False
if (filters['month']and (month not in filters['month'])):
return False
return True
def typeoffolder(folders):
if folders is None:
return "usage"
elif "leads" in folders:
return "leads"
elif "metagame" in folders:
return "metagame"
elif "moveset" in folders:
return "moveset"
elif "chaos" in folders:
return "chaos"
return "usage"