Skip to content

Commit

Permalink
shiftload: loadData is an static method of Computer
Browse files Browse the repository at this point in the history
  • Loading branch information
vokimon committed Jan 10, 2022
1 parent 23b1e7d commit 1ef06f4
Showing 1 changed file with 43 additions and 42 deletions.
85 changes: 43 additions & 42 deletions tomatic/shiftload.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,54 +294,55 @@ def increaseUntilFullLoad(fullLoad, shifts, limits, credits):
return result


def loadData(config):
step('Generant càrrega...')
step(" Carregant dades...")

step(" Llegint festius...")
businessDays = busy.laborableWeekDays(config.monday)
class ShiftLoadComputer():

step(" Llegint carrega ideal...")
idealLoad = ns.load(config.idealshifts)
persons=list(idealLoad.keys())
@staticmethod
def loadData(config):
step('Generant càrrega...')
step(" Carregant dades...")

step(" Llegint vacances...")
daysoffcontent = Path('indisponibilitats-vacances.conf').read_text(encoding='utf8').split("\n")
daysoff = list(busy.parseBusy(daysoffcontent, error))
step(" Llegint festius...")
businessDays = busy.laborableWeekDays(config.monday)

step(" Llegint baixes...")
leaves = Path('leaves.conf').read_text(encoding='utf8').split()
step(" Llegint carrega ideal...")
idealLoad = ns.load(config.idealshifts)
persons=list(idealLoad.keys())

step(" Llegint altres indisponibilitats...")
busyTable = busy.BusyTable(
days=businessDays,
nhours=busy.nturns,
persons=persons,
)
busyFiles = config.get('busyFiles', [
'oneshot.conf',
'indisponibilitats.conf',
'indisponibilitats-vacances.conf',
])
for busyfile in busyFiles:
busyTable.load(busyfile,
monday = config.monday,
errorHandler = error,
justRequired = config.ignoreOptionalAbsences,
)
step(" Llegint credits i deutes (bossa d'hores)...")
formerCredit = ns.load('shiftcredit.yaml')
return ns(
leaves = leaves,
daysoff = daysoff,
busyTable = busyTable,
businessDays = businessDays,
idealLoad = idealLoad,
formerCredit = formerCredit,
)
step(" Llegint vacances...")
daysoffcontent = Path('indisponibilitats-vacances.conf').read_text(encoding='utf8').split("\n")
daysoff = list(busy.parseBusy(daysoffcontent, error))

step(" Llegint baixes...")
leaves = Path('leaves.conf').read_text(encoding='utf8').split()

class ShiftLoadComputer():
step(" Llegint altres indisponibilitats...")
busyTable = busy.BusyTable(
days=businessDays,
nhours=busy.nturns,
persons=persons,
)
busyFiles = config.get('busyFiles', [
'oneshot.conf',
'indisponibilitats.conf',
'indisponibilitats-vacances.conf',
])
for busyfile in busyFiles:
busyTable.load(busyfile,
monday = config.monday,
errorHandler = error,
justRequired = config.ignoreOptionalAbsences,
)
step(" Llegint credits i deutes (bossa d'hores)...")
formerCredit = ns.load('shiftcredit.yaml')
return ns(
leaves = leaves,
daysoff = daysoff,
busyTable = busyTable,
businessDays = businessDays,
idealLoad = idealLoad,
formerCredit = formerCredit,
)

def __init__(self,
nlines,
Expand Down Expand Up @@ -655,7 +656,7 @@ def main():
step("Baixant bossa d'hores del tomatic...")
downloadShiftCredit(config)

setup = loadData(config)
setup = ShiftLoadComputer.loadData(config)

computer = ShiftLoadComputer(
nlines = config.nTelefons,
Expand Down

0 comments on commit 1ef06f4

Please sign in to comment.