|
@@ 456-471 (lines=16) @@
|
| 453 |
|
return jdict |
| 454 |
|
|
| 455 |
|
def to_JSON(self): |
| 456 |
|
return json.dumps(self.to_JSON_dict(), sort_keys=True, indent=4) |
| 457 |
|
|
| 458 |
|
class TextWithURL(object): |
| 459 |
|
|
| 460 |
|
def __init__(self, text, url): |
| 461 |
|
self.text = text |
| 462 |
|
# TODO: throw exception if url is invalid |
| 463 |
|
self.url = url |
| 464 |
|
|
| 465 |
|
def to_JSON_dict(self): |
| 466 |
|
jdict = dict() |
| 467 |
|
jdict["text"] = self.text |
| 468 |
|
jdict["url"] = self.url |
| 469 |
|
return jdict |
| 470 |
|
|
| 471 |
|
def to_JSON(self): |
| 472 |
|
return json.dumps(self.to_JSON_dict(), sort_keys=True, indent=4) |
| 473 |
|
|
| 474 |
|
class DocumentWithRules(object): |
|
@@ 440-454 (lines=15) @@
|
| 437 |
|
|
| 438 |
|
############################################# |
| 439 |
|
# Containers for Odin data |
| 440 |
|
# transmitted to the server for processing |
| 441 |
|
############################################# |
| 442 |
|
|
| 443 |
|
class TextWithRules(object): |
| 444 |
|
|
| 445 |
|
def __init__(self, text, rules): |
| 446 |
|
self.text = text |
| 447 |
|
self.rules = rules |
| 448 |
|
|
| 449 |
|
def to_JSON_dict(self): |
| 450 |
|
jdict = dict() |
| 451 |
|
jdict["text"] = self.text |
| 452 |
|
jdict["rules"] = self.rules |
| 453 |
|
return jdict |
| 454 |
|
|
| 455 |
|
def to_JSON(self): |
| 456 |
|
return json.dumps(self.to_JSON_dict(), sort_keys=True, indent=4) |
| 457 |
|
|