mirror of
https://github.com/csd4ni3l/loginween.git
synced 2026-01-01 04:23:48 +01:00
Remove PyPi build, convert project to not be a python module, add Docker build and files, update README,
This commit is contained in:
22
pattern.py
Normal file
22
pattern.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import json
|
||||
|
||||
class Pattern():
|
||||
def __init__(self, data: list[tuple]):
|
||||
self.data: list[tuple] = data
|
||||
|
||||
@classmethod
|
||||
def from_str(cls, string):
|
||||
return cls([tuple(map(int, pos.split(","))) for pos in json.loads(string)])
|
||||
|
||||
@classmethod
|
||||
def from_json_str(cls, data):
|
||||
return cls(list(map(tuple, json.loads(data))))
|
||||
|
||||
def to_json_str(self):
|
||||
return json.dumps(self.data)
|
||||
|
||||
def __eq__(self, value):
|
||||
if not isinstance(value, Pattern):
|
||||
return False
|
||||
|
||||
return set(self.data) == set(value.data)
|
||||
Reference in New Issue
Block a user