Generate more condensed Javascript to save bits in encryption

This commit is contained in:
RunasSudo 2017-12-07 17:35:38 +10:30
parent fd9e18a311
commit 9fc9d08fb4
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
4 changed files with 6 additions and 10 deletions

View File

@ -132,8 +132,6 @@ class PreferentialAnswer(Answer):
choices = ListField(IntField()) choices = ListField(IntField())
class RawResult(Result): class RawResult(Result):
_ver = StringField(default='0.2')
plaintexts = ListField(EmbeddedObjectListField()) plaintexts = ListField(EmbeddedObjectListField())
answers = EmbeddedObjectListField() answers = EmbeddedObjectListField()
@ -149,8 +147,6 @@ class RawResult(Result):
return combined return combined
class Election(TopLevelObject): class Election(TopLevelObject):
_ver = StringField(default='0.2')
_id = UUIDField() _id = UUIDField()
workflow = EmbeddedObjectField(Workflow) # Once saved, we don't care what kind of workflow it is workflow = EmbeddedObjectField(Workflow) # Once saved, we don't care what kind of workflow it is
name = StringField() name = StringField()

View File

@ -222,7 +222,7 @@ class EosObject(metaclass=EosObjectType):
@staticmethod @staticmethod
def to_json(value): def to_json(value):
if is_python: if is_python:
return json.dumps(value, sort_keys=True) return json.dumps(value, sort_keys=True, separators=(',', ':'))
else: else:
return lib.stringify(value) return lib.stringify(value)
@ -337,7 +337,7 @@ class DocumentObjectType(EosObjectType):
return cls return cls
class DocumentObject(EosObject, metaclass=DocumentObjectType): class DocumentObject(EosObject, metaclass=DocumentObjectType):
_ver = StringField(default='0.1') _ver = StringField(default='0.3')
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__() super().__init__()

View File

@ -53,7 +53,7 @@ function stringify(parent, key, node, level) {
var item = stringify(node, i, node[i], level+1) || JSON.stringify(null); var item = stringify(node, i, node[i], level+1) || JSON.stringify(null);
out.push(item); out.push(item);
} }
return '[' + out.join(', ') + ']'; return '[' + out.join(',') + ']';
} else { } else {
if (seen.indexOf(node) !== -1) { if (seen.indexOf(node) !== -1) {
throw new TypeError('Converting circular structure to JSON'); throw new TypeError('Converting circular structure to JSON');
@ -71,11 +71,11 @@ function stringify(parent, key, node, level) {
continue; continue;
} }
var keyValue = JSON.stringify(key) + ': ' + value; var keyValue = JSON.stringify(key) + ':' + value;
out.push(keyValue); out.push(keyValue);
} }
seen.splice(seen.indexOf(node), 1); seen.splice(seen.indexOf(node), 1);
return '{' + out.join(', ') + '}'; return '{' + out.join(',') + '}';
} }
}; };

View File

@ -96,7 +96,7 @@ class ObjectTestCase(EosTestCase):
def test_serialise(self): def test_serialise(self):
person1 = self.Person(name='John', address='Address 1') person1 = self.Person(name='John', address='Address 1')
expect1 = {'_ver': '0.1', 'name': 'John', 'address': 'Address 1'} expect1 = {'_ver': person1._ver, 'name': 'John', 'address': 'Address 1'}
#expect1a = {'type': 'eos.core.tests.ObjectTestCase.setUpClass.<locals>.Person', 'value': expect1} #expect1a = {'type': 'eos.core.tests.ObjectTestCase.setUpClass.<locals>.Person', 'value': expect1}
expect1a = {'type': 'eos.core.tests.Person', 'value': expect1} expect1a = {'type': 'eos.core.tests.Person', 'value': expect1}