Skip to content

Commit 29ca4c9

Browse files
remove make_module_code for lack of potential use, tagging this commit with "make_module_code"
1 parent 10f7393 commit 29ca4c9

File tree

2 files changed

+0
-43
lines changed

2 files changed

+0
-43
lines changed

datajoint/schema.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -100,48 +100,6 @@ def size_on_disk(self):
100100
FROM information_schema.tables WHERE table_schema='{db}'
101101
""".format(db=self.database)).fetchone()[0])
102102

103-
def _make_module_code(self):
104-
"""
105-
Generate the code to recreate the schema as a module.
106-
This method is in preparation for a future release and is not officially supported.
107-
:return: a string containing the body of a complete Python module defining this schema.
108-
"""
109-
110-
module_count = itertools.count()
111-
# add virtual modules for referenced modules with names vmod0, vmod1, ...
112-
module_lookup = collections.defaultdict(lambda: 'vmod' + str(next(module_count)))
113-
db = self.database
114-
115-
def make_class_definition(table):
116-
tier = _get_tier(table).__name__
117-
class_name = table.split('.')[1].strip('`')
118-
indent = ''
119-
if tier == 'Part':
120-
class_name = class_name.split('__')[1]
121-
indent += ' '
122-
class_name = to_camel_case(class_name)
123-
124-
def repl(s):
125-
d, tab = s.group(1), s.group(2)
126-
return ('' if d == db else (module_lookup[d]+'.')) + to_camel_case(tab)
127-
128-
return ('' if tier == 'Part' else '@schema\n') + \
129-
'{indent}class {class_name}(dj.{tier}):\n{indent} definition = """\n{indent} {defi}"""'.format(
130-
class_name=class_name,
131-
indent=indent,
132-
tier=tier,
133-
defi=re.sub(
134-
r'`([^`]+)`.`([^`]+)`', repl,
135-
FreeTable(self.connection, table).describe(printout=False).replace('\n', '\n ' + indent)))
136-
137-
erd = ERD(self)
138-
body = '\n\n\n'.join(make_class_definition(table) for table in erd.topological_sort())
139-
return '\n\n\n'.join((
140-
'"""This module was auto-generated by datajoint from an existing schema"""',
141-
"import datajoint as dj\n\nschema = dj.schema('{db}')".format(db=db),
142-
'\n'.join("{module} = dj.create_virtual_module('{module}', '{schema_name}')".format(module=v, schema_name=k)
143-
for k, v in module_lookup.items()), body))
144-
145103
def spawn_missing_classes(self, context=None):
146104
"""
147105
Creates the appropriate python user relation classes from tables in the schema and places them

tests/test_blob2.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import numpy as np
2-
import os
32
import datajoint as dj
43
from nose.tools import assert_equal, assert_true, assert_list_equal, assert_tuple_equal, assert_false
54

0 commit comments

Comments
 (0)