@@ -100,48 +100,6 @@ def size_on_disk(self):
100
100
FROM information_schema.tables WHERE table_schema='{db}'
101
101
""" .format (db = self .database )).fetchone ()[0 ])
102
102
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 \n schema = 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
-
145
103
def spawn_missing_classes (self , context = None ):
146
104
"""
147
105
Creates the appropriate python user relation classes from tables in the schema and places them
0 commit comments