mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
LC: Add code base (don't working).
This commit is contained in:
1 parent
41fa0f403b
commit
115d84d436
14 files changed
+1959
-1
No files matched your search
@@ -0,0 +1,94 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from copy import copy
|
||||
from tools import trace, timer
|
||||
|
||||
from Model.Except import NotImplementedMethodeError
|
||||
|
||||
from Model.LateralContribution.LateralContributionTypes import (
|
||||
NotDefined,
|
||||
PonctualContribution,
|
||||
TimeOverZ, TimeOverDebit, ZOverDebit
|
||||
)
|
||||
|
||||
class LateralContributionList(object):
|
||||
def __init__(self):
|
||||
super(LateralContributionList, self).__init__()
|
||||
|
||||
self._tabs = {
|
||||
"liquid" : [],
|
||||
"solid" : [],
|
||||
"suspenssion" : []
|
||||
}
|
||||
|
||||
def len(self, lst):
|
||||
return len(self._tabs[lst])
|
||||
|
||||
def get_tab(self, lst):
|
||||
return self._tabs[lst].copy()
|
||||
|
||||
def get(self, lst, row):
|
||||
return self._tabs[lst][row]
|
||||
|
||||
def set(self, lst, row, new):
|
||||
self._tabs[lst][row] = new
|
||||
|
||||
def new(self, lst, index):
|
||||
n = NotDefined()
|
||||
self._tabs[lst].insert(index, n)
|
||||
return n
|
||||
|
||||
def insert(self, lst, index, new):
|
||||
self._tabs[lst].insert(index, new)
|
||||
|
||||
def delete(self, lst, bcs):
|
||||
for bc in bcs:
|
||||
self._tabs[lst].remove(bc)
|
||||
|
||||
def delete_i(self, lst, indexes):
|
||||
bcs = list(
|
||||
map(
|
||||
lambda x: x[1],
|
||||
filter(
|
||||
lambda x: x[0] in indexes,
|
||||
enumerate(self._tabs[lst])
|
||||
)
|
||||
)
|
||||
)
|
||||
self.delete(lst, bcs)
|
||||
|
||||
def sort(self, lst, reverse=False, key=None):
|
||||
self._tabs[lst].sort(reverse=reverse, key=key)
|
||||
|
||||
def move_up(self, lst, index):
|
||||
if index < len(self._tabs[lst]):
|
||||
next = index - 1
|
||||
|
||||
l = self._tabs[lst]
|
||||
l[index], l[next] = l[next], l[index]
|
||||
|
||||
def move_down(self, lst, index):
|
||||
if index >= 0:
|
||||
prev = index + 1
|
||||
|
||||
l = self._tabs[lst]
|
||||
l[index], l[prev] = l[prev], l[index]
|
||||
|
||||
def __copy__(self):
|
||||
new = LateralContributionList()
|
||||
|
||||
for l in self._tabs:
|
||||
new.tabs[l] = self._tabs[l].copy()
|
||||
|
||||
return new
|
||||
|
||||
def __deepcopy__(self):
|
||||
new = LateralContributionList()
|
||||
|
||||
for l in self._tabs:
|
||||
new.tabs[l] = self._tabs[l].deepcopy()
|
||||
|
||||
return new
|
||||
|
||||
def copy(self):
|
||||
return copy(self)
|
||||
Reference in new issue
Block a user