-
Notifications
You must be signed in to change notification settings - Fork 1
/
FileSystem.py
80 lines (58 loc) · 2.3 KB
/
FileSystem.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 23 16:10:38 2014
@author: Gaspard
"""
import os
from utils import *
class FileSystem:
def __init__(self,infoReader):
self.folder = infoReader.readLine()
self.matchesFolder = infoReader.readLine()
self.ranksFolder = infoReader.readLine()
self.cleanFolder = infoReader.readLine()
try: os.stat( self.folder)
except: os.mkdir(self.folder)
try: os.stat( self.matchesFolder)
except: os.mkdir(self.matchesFolder)
try: os.stat( self.ranksFolder)
except: os.mkdir(self.ranksFolder)
try: os.stat( self.cleanFolder)
except: os.mkdir(self.cleanFolder)
self.tournaments_codes = self.folder + "tournamentCodes.csv"
self.tournamentsPath = self.folder + "tournaments.csv"
self.playerCodesPath = self.folder + "playerCodes.csv"
self.playerPath = self.folder + "players.csv"
self.treated_path = self.folder + "treated.csv"
self.matchesPath = self.folder + "matches.csv"
self.rankingsSave = self.folder + "rankingsSave.csv"
self.cleanPlayerPath = self.cleanFolder + "players.csv"
self.cleanTournamentsPath= self.cleanFolder + "tournaments.csv"
self.cleanMatchesPath = self.cleanFolder + "matches.csv"
self.debugOut = self.folder + "debug.txt"
class InfoReader:
def __init__(self, path):
with open(path, 'rb') as f:
self.lines = f.readlines()
self.i = 0
def readLine(self):
res = self.lines[ self.i ]
self.i += 1
return cleanLine(res)
def readInt(self):
self.readLine()
return int( self.readLine() )
def readBool(self):
self.readLine()
return getBool( self.readLine() )
def readIntList(self):
self.readLine()
return [ int(e) for e in self.readLine().split(',') ]
def start(self, nbIterations):
self.total = nbIterations
self.absoluteTotal = self.total
self.strTotal = str( self.absoluteTotal )
self.i = 0
self.previous = 0
self.startTime = time.time()
self.previousTime = self.startTime