Browse Source

Add labels

pull/1310/head
Hironsan 3 years ago
parent
commit
afb97b5db0
1 changed files with 18 additions and 0 deletions
  1. 18
      app/api/views/upload/labels.py

18
app/api/views/upload/labels.py

@ -0,0 +1,18 @@
from typing import Dict, List, Optional
from .label import Label
class Labels:
def __init__(self, labels: List[Label]):
self.labels = labels
def replace_label(self, mapping: Optional[Dict[str, int]] = None):
if not mapping:
return self
labels = [label.replace(mapping) for label in self.labels]
return Labels(labels)
def dict(self) -> List[dict]:
return [label.dict() for label in self.labels]
Loading…
Cancel
Save