HUGE refactor, creating lots of modules, no code changes though!
This commit is contained in:
34
src/order.py
Normal file
34
src/order.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class Order(Enum):
|
||||
FromTo = 0
|
||||
ToFrom = 1
|
||||
Any = 2
|
||||
|
||||
@staticmethod
|
||||
def new(order):
|
||||
if order is None:
|
||||
return Order.Any
|
||||
elif order == "to-from":
|
||||
return Order.ToFrom
|
||||
elif order == "from-to":
|
||||
return Order.FromTo
|
||||
else:
|
||||
raise NotImplementedError("What kind of ordering is: {}".format(order))
|
||||
|
||||
|
||||
def match(self, from_w, to_w):
|
||||
if self is Order.Any:
|
||||
return True
|
||||
|
||||
fi = from_w.int_id
|
||||
ti = to_w.int_id
|
||||
|
||||
if self is Order.FromTo:
|
||||
return fi < ti
|
||||
elif self is Order.ToFrom:
|
||||
return ti < fi
|
||||
else:
|
||||
raise NotImplementedError("Should not be here: Order match")
|
||||
|
||||
Reference in New Issue
Block a user