示例#1
0
 def test_loaded(self):
     spec = connection.generate_spec()
     self.assertIsInstance(spec, (list, tuple))
     self.assertGreater(len(spec), 0)
     for s in spec:
         print_(s)
         self.assertIsInstance(s, dict)
         self.assertDictContainsKeyWithValueType(s, 'model', string_types)
         self.assertDictContainsKeyWithValueType(s, 'element_type',
                                                 string_types)
         self.assertDictContainsKeyWithValueType(s, 'makeType',
                                                 string_types)
         self.assertDictContainsKeyWithValueType(s, 'properties', dict)
         for pk, pv in s['properties'].items():
             self.assertDictContainsKeyWithValueType(
                 pv, 'data_type', string_types)
             self.assertDictContainsKeyWithValueType(
                 pv, 'index_ext', string_types)
             self.assertDictContainsKeyWithValueType(
                 pv, 'uniqueness', string_types)
             self.assertDictContainsKeyWithValueType(pv, 'compiled', dict)
             self.assertDictContainsKeyWithValueType(
                 pv['compiled'], 'script', string_types)
             self.assertDictContainsKeyWithValueType(
                 pv['compiled'], 'params', dict)
             self.assertDictContainsKeyWithValueType(
                 pv['compiled'], 'transaction', bool)
示例#2
0
def write_specs_to_file(filename):  # pragma: no cover
    """ Generate and write a specification to file

    :param filename: The file to write to
    :type filename: basestring
    """
    print_("Generating Specification...")
    spec = connection.generate_spec()
    print_("Writing Specification to File %s ..." % filename)
    with open(filename, 'wb') as f:
        json.dump(spec, f)
    write_compiled_indices_to_file(filename + '.idx', spec=spec)
    write_compiled_indices_to_file(filename + '.idxdiff', spec=spec)
示例#3
0
文件: spec.py 项目: ZEROFAIL/mogwai
def write_specs_to_file(filename):  # pragma: no cover
    """ Generate and write a specification to file

    :param filename: The file to write to
    :type filename: basestring
    """
    print_("Generating Specification...")
    spec = connection.generate_spec()
    print_("Writing Specification to File %s ..." % filename)
    with open(filename, 'wb') as f:
        json.dump(spec, f)
    write_compiled_indices_to_file(filename+'.idx', spec=spec)
    write_compiled_indices_to_file(filename+'.idxdiff', spec=spec)
示例#4
0
文件: spec.py 项目: ZEROFAIL/mogwai
def write_compiled_indices_to_file(filename, spec=None):  # pragma: no cover
    """ Write the compile index specification to file

    :param filename: The file to write to
    :type filename: basestring
    """
    if not spec:
        print_("Generating Specification...")
        spec = connection.generate_spec()
    print_("Writing Compiled Indices to File %s ..." % filename)
    with open(filename, 'wb') as f:
        for s in spec:
            for pn, pv in s['properties'].items():
                f.writelines([json.dumps(pv['compiled']), ])
示例#5
0
def write_compiled_indices_to_file(filename, spec=None):  # pragma: no cover
    """ Write the compile index specification to file

    :param filename: The file to write to
    :type filename: basestring
    """
    if not spec:
        print_("Generating Specification...")
        spec = connection.generate_spec()
    print_("Writing Compiled Indices to File %s ..." % filename)
    with open(filename, 'wb') as f:
        for s in spec:
            for pn, pv in s['properties'].items():
                f.writelines([
                    json.dumps(pv['compiled']),
                ])
示例#6
0
文件: spec.py 项目: ZEROFAIL/mogwai
def write_diff_indices_to_file(filename, spec=None):  # pragma: no cover
    """ Preview of index diff specification to write to file

    :param filename: The file to write to
    :type filename: basestring
    """
    if not spec:
        print_("Generating Specification...")
        spec = connection.generate_spec()
    print_("Writing Compiled Diff Indices to File %s ..." % filename)
    vertex_indices, edge_indices = get_existing_indices()
    with open(filename, 'wb') as f:
        for s in spec:
            for pn, pv in s['properties'].items():
                if s['element_type'] == 'Edge' and pn not in edge_indices:
                    f.writelines([pv['compiled'], ])
                elif s['element_type'] == 'Vertex' and pn not in vertex_indices:
                    f.writeliness([json.dumps(pv['compiled']), ])
示例#7
0
 def test_loaded(self):
     spec = connection.generate_spec()
     self.assertIsInstance(spec, (list, tuple))
     self.assertGreater(len(spec), 0)
     for s in spec:
         print_(s)
         self.assertIsInstance(s, dict)
         self.assertDictContainsKeyWithValueType(s, 'model', string_types)
         self.assertDictContainsKeyWithValueType(s, 'element_type', string_types)
         self.assertDictContainsKeyWithValueType(s, 'makeType', string_types)
         self.assertDictContainsKeyWithValueType(s, 'properties', dict)
         for pk, pv in s['properties'].items():
             self.assertDictContainsKeyWithValueType(pv, 'data_type', string_types)
             self.assertDictContainsKeyWithValueType(pv, 'index_ext', string_types)
             self.assertDictContainsKeyWithValueType(pv, 'uniqueness', string_types)
             self.assertDictContainsKeyWithValueType(pv, 'compiled', dict)
             self.assertDictContainsKeyWithValueType(pv['compiled'], 'script', string_types)
             self.assertDictContainsKeyWithValueType(pv['compiled'], 'params', dict)
             self.assertDictContainsKeyWithValueType(pv['compiled'], 'transaction', bool)
示例#8
0
def write_diff_indices_to_file(filename, spec=None):  # pragma: no cover
    """ Preview of index diff specification to write to file

    :param filename: The file to write to
    :type filename: basestring
    """
    if not spec:
        print_("Generating Specification...")
        spec = connection.generate_spec()
    print_("Writing Compiled Diff Indices to File %s ..." % filename)
    vertex_indices, edge_indices = get_existing_indices()
    with open(filename, 'wb') as f:
        for s in spec:
            for pn, pv in s['properties'].items():
                if s['element_type'] == 'Edge' and pn not in edge_indices:
                    f.writelines([
                        pv['compiled'],
                    ])
                elif s['element_type'] == 'Vertex' and pn not in vertex_indices:
                    f.writeliness([
                        json.dumps(pv['compiled']),
                    ])