begin_unit
comment|'#!/usr/bin/env python'
nl|'\n'
nl|'\n'
name|'import'
name|'argparse'
newline|'\n'
name|'import'
name|'glob'
newline|'\n'
name|'import'
name|'os'
newline|'\n'
name|'import'
name|'subprocess'
newline|'\n'
nl|'\n'
DECL|variable|BASE
name|'BASE'
op|'='
string|"'nova/db/sqlalchemy/migrate_repo/versions'"
op|'.'
name|'split'
op|'('
string|"'/'"
op|')'
newline|'\n'
DECL|variable|API_BASE
name|'API_BASE'
op|'='
string|"'nova/db/sqlalchemy/api_migrations/migrate_repo/versions'"
op|'.'
name|'split'
op|'('
string|"'/'"
op|')'
newline|'\n'
nl|'\n'
name|'STUB'
op|'='
string|'"""\n#    Licensed under the Apache License, Version 2.0 (the "License"); you may\n#    not use this file except in compliance with the License. You may obtain\n#    a copy of the License at\n#\n#         http://www.apache.org/licenses/LICENSE-2.0\n#\n#    Unless required by applicable law or agreed to in writing, software\n#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n#    License for the specific language governing permissions and limitations\n#    under the License.\n\n# This is a placeholder for backports.\n# Do not use this number for new work.  New work starts after\n# all the placeholders.\n#\n# See this for more information:\n# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html\n\n\ndef upgrade(migrate_engine):\n    pass\n"""'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|get_last_migration
name|'def'
name|'get_last_migration'
op|'('
name|'base'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'path'
op|'='
name|'os'
op|'.'
name|'path'
op|'.'
name|'join'
op|'('
op|'*'
name|'tuple'
op|'('
name|'base'
op|'+'
op|'['
string|"'[0-9]*.py'"
op|']'
op|')'
op|')'
newline|'\n'
name|'migrations'
op|'='
name|'sorted'
op|'('
op|'['
name|'os'
op|'.'
name|'path'
op|'.'
name|'split'
op|'('
name|'fn'
op|')'
op|'['
op|'-'
number|'1'
op|']'
name|'for'
name|'fn'
name|'in'
name|'glob'
op|'.'
name|'glob'
op|'('
name|'path'
op|')'
op|']'
op|')'
newline|'\n'
name|'return'
name|'int'
op|'('
name|'migrations'
op|'['
op|'-'
number|'1'
op|']'
op|'.'
name|'split'
op|'('
string|"'_'"
op|')'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|reserve_migrations
dedent|''
name|'def'
name|'reserve_migrations'
op|'('
name|'base'
op|','
name|'number'
op|','
name|'git_add'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'last'
op|'='
name|'get_last_migration'
op|'('
name|'base'
op|')'
newline|'\n'
name|'for'
name|'i'
name|'in'
name|'range'
op|'('
name|'last'
op|'+'
number|'1'
op|','
name|'last'
op|'+'
name|'number'
op|'+'
number|'1'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'name'
op|'='
string|"'%03i_placeholder.py'"
op|'%'
name|'i'
newline|'\n'
name|'path'
op|'='
name|'os'
op|'.'
name|'path'
op|'.'
name|'join'
op|'('
op|'*'
name|'tuple'
op|'('
name|'base'
op|'+'
op|'['
name|'name'
op|']'
op|')'
op|')'
newline|'\n'
name|'with'
name|'open'
op|'('
name|'path'
op|','
string|"'w'"
op|')'
name|'as'
name|'f'
op|':'
newline|'\n'
indent|'            '
name|'f'
op|'.'
name|'write'
op|'('
name|'STUB'
op|')'
newline|'\n'
dedent|''
name|'print'
op|'('
string|"'Created %s'"
op|'%'
name|'path'
op|')'
newline|'\n'
name|'if'
name|'git_add'
op|':'
newline|'\n'
indent|'            '
name|'subprocess'
op|'.'
name|'call'
op|'('
string|"'git add %s'"
op|'%'
name|'path'
op|','
name|'shell'
op|'='
name|'True'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|main
dedent|''
dedent|''
dedent|''
name|'def'
name|'main'
op|'('
op|')'
op|':'
newline|'\n'
indent|'    '
name|'parser'
op|'='
name|'argparse'
op|'.'
name|'ArgumentParser'
op|'('
op|')'
newline|'\n'
name|'parser'
op|'.'
name|'add_argument'
op|'('
string|"'-n'"
op|','
string|"'--number'"
op|','
name|'default'
op|'='
number|'10'
op|','
nl|'\n'
name|'type'
op|'='
name|'int'
op|','
nl|'\n'
name|'help'
op|'='
string|"'Number of migrations to reserve'"
op|')'
newline|'\n'
name|'parser'
op|'.'
name|'add_argument'
op|'('
string|"'-g'"
op|','
string|"'--git-add'"
op|','
name|'action'
op|'='
string|"'store_const'"
op|','
nl|'\n'
name|'const'
op|'='
name|'True'
op|','
name|'default'
op|'='
name|'False'
op|','
nl|'\n'
name|'help'
op|'='
string|"'Automatically git-add new migrations'"
op|')'
newline|'\n'
name|'parser'
op|'.'
name|'add_argument'
op|'('
string|"'-a'"
op|','
string|"'--api'"
op|','
name|'action'
op|'='
string|"'store_const'"
op|','
nl|'\n'
name|'const'
op|'='
name|'True'
op|','
name|'default'
op|'='
name|'False'
op|','
nl|'\n'
name|'help'
op|'='
string|"'Reserve migrations for the API database'"
op|')'
newline|'\n'
name|'args'
op|'='
name|'parser'
op|'.'
name|'parse_args'
op|'('
op|')'
newline|'\n'
name|'if'
name|'args'
op|'.'
name|'api'
op|':'
newline|'\n'
indent|'        '
name|'base'
op|'='
name|'API_BASE'
newline|'\n'
dedent|''
name|'else'
op|':'
newline|'\n'
indent|'        '
name|'base'
op|'='
name|'BASE'
newline|'\n'
dedent|''
name|'reserve_migrations'
op|'('
name|'base'
op|','
name|'args'
op|'.'
name|'number'
op|','
name|'args'
op|'.'
name|'git_add'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
dedent|''
name|'if'
name|'__name__'
op|'=='
string|"'__main__'"
op|':'
newline|'\n'
indent|'    '
name|'main'
op|'('
op|')'
newline|'\n'
dedent|''
endmarker|''
end_unit

begin_unit
comment|'#!/usr/bin/env python'
nl|'\n'
nl|'\n'
name|'import'
name|'argparse'
newline|'\n'
name|'import'
name|'glob'
newline|'\n'
name|'import'
name|'os'
newline|'\n'
name|'import'
name|'subprocess'
newline|'\n'
nl|'\n'
DECL|variable|BASE
name|'BASE'
op|'='
string|"'nova/db/sqlalchemy/migrate_repo/versions'"
op|'.'
name|'split'
op|'('
string|"'/'"
op|')'
newline|'\n'
DECL|variable|API_BASE
name|'API_BASE'
op|'='
string|"'nova/db/sqlalchemy/api_migrations/migrate_repo/versions'"
op|'.'
name|'split'
op|'('
string|"'/'"
op|')'
newline|'\n'
nl|'\n'
name|'STUB'
op|'='
string|'"""\n#    Licensed under the Apache License, Version 2.0 (the "License"); you may\n#    not use this file except in compliance with the License. You may obtain\n#    a copy of the License at\n#\n#         http://www.apache.org/licenses/LICENSE-2.0\n#\n#    Unless required by applicable law or agreed to in writing, software\n#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n#    License for the specific language governing permissions and limitations\n#    under the License.\n\n# This is a placeholder for backports.\n# Do not use this number for new work.  New work starts after\n# all the placeholders.\n#\n# See this for more information:\n# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html\n\n\ndef upgrade(migrate_engine):\n    pass\n"""'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|get_last_migration
name|'def'
name|'get_last_migration'
op|'('
name|'base'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'path'
op|'='
name|'os'
op|'.'
name|'path'
op|'.'
name|'join'
op|'('
op|'*'
name|'tuple'
op|'('
name|'base'
op|'+'
op|'['
string|"'[0-9]*.py'"
op|']'
op|')'
op|')'
newline|'\n'
name|'migrations'
op|'='
name|'sorted'
op|'('
op|'['
name|'os'
op|'.'
name|'path'
op|'.'
name|'split'
op|'('
name|'fn'
op|')'
op|'['
op|'-'
number|'1'
op|']'
name|'for'
name|'fn'
name|'in'
name|'glob'
op|'.'
name|'glob'
op|'('
name|'path'
op|')'
op|']'
op|')'
newline|'\n'
name|'return'
name|'int'
op|'('
name|'migrations'
op|'['
op|'-'
number|'1'
op|']'
op|'.'
name|'split'
op|'('
string|"'_'"
op|')'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|reserve_migrations
dedent|''
name|'def'
name|'reserve_migrations'
op|'('
name|'base'
op|','
name|'number'
op|','
name|'git_add'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'last'
op|'='
name|'get_last_migration'
op|'('
name|'base'
op|')'
newline|'\n'
name|'for'
name|'i'
name|'in'
name|'range'
op|'('
name|'last'
op|'+'
number|'1'
op|','
name|'last'
op|'+'
name|'number'
op|'+'
number|'1'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'name'
op|'='
string|"'%03i_placeholder.py'"
op|'%'
name|'i'
newline|'\n'
name|'path'
op|'='
name|'os'
op|'.'
name|'path'
op|'.'
name|'join'
op|'('
op|'*'
name|'tuple'
op|'('
name|'base'
op|'+'
op|'['
name|'name'
op|']'
op|')'
op|')'
newline|'\n'
name|'with'
name|'open'
op|'('
name|'path'
op|','
string|"'w'"
op|')'
name|'as'
name|'f'
op|':'
newline|'\n'
indent|'            '
name|'f'
op|'.'
name|'write'
op|'('
name|'STUB'
op|')'
newline|'\n'
dedent|''
name|'print'
op|'('
string|"'Created %s'"
op|'%'
name|'path'
op|')'
newline|'\n'
name|'if'
name|'git_add'
op|':'
newline|'\n'
indent|'            '
name|'subprocess'
op|'.'
name|'call'
op|'('
string|"'git add %s'"
op|'%'
name|'path'
op|','
name|'shell'
op|'='
name|'True'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|main
dedent|''
dedent|''
dedent|''
name|'def'
name|'main'
op|'('
op|')'
op|':'
newline|'\n'
indent|'    '
name|'parser'
op|'='
name|'argparse'
op|'.'
name|'ArgumentParser'
op|'('
op|')'
newline|'\n'
name|'parser'
op|'.'
name|'add_argument'
op|'('
string|"'-n'"
op|','
string|"'--number'"
op|','
name|'default'
op|'='
number|'10'
op|','
nl|'\n'
name|'type'
op|'='
name|'int'
op|','
nl|'\n'
name|'help'
op|'='
string|"'Number of migrations to reserve'"
op|')'
newline|'\n'
name|'parser'
op|'.'
name|'add_argument'
op|'('
string|"'-g'"
op|','
string|"'--git-add'"
op|','
name|'action'
op|'='
string|"'store_const'"
op|','
nl|'\n'
name|'const'
op|'='
name|'True'
op|','
name|'default'
op|'='
name|'False'
op|','
nl|'\n'
name|'help'
op|'='
string|"'Automatically git-add new migrations'"
op|')'
newline|'\n'
name|'parser'
op|'.'
name|'add_argument'
op|'('
string|"'-a'"
op|','
string|"'--api'"
op|','
name|'action'
op|'='
string|"'store_const'"
op|','
nl|'\n'
name|'const'
op|'='
name|'True'
op|','
name|'default'
op|'='
name|'False'
op|','
nl|'\n'
name|'help'
op|'='
string|"'Reserve migrations for the API database'"
op|')'
newline|'\n'
name|'args'
op|'='
name|'parser'
op|'.'
name|'parse_args'
op|'('
op|')'
newline|'\n'
name|'if'
name|'args'
op|'.'
name|'api'
op|':'
newline|'\n'
indent|'        '
name|'base'
op|'='
name|'API_BASE'
newline|'\n'
dedent|''
name|'else'
op|':'
newline|'\n'
indent|'        '
name|'base'
op|'='
name|'BASE'
newline|'\n'
dedent|''
name|'reserve_migrations'
op|'('
name|'base'
op|','
name|'args'
op|'.'
name|'number'
op|','
name|'args'
op|'.'
name|'git_add'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
dedent|''
name|'if'
name|'__name__'
op|'=='
string|"'__main__'"
op|':'
newline|'\n'
indent|'    '
name|'main'
op|'('
op|')'
newline|'\n'
dedent|''
endmarker|''
end_unit

\n#    Licensed under the Apache License, Version 2.0 (the "License"); you may\n#    not use this file except in compliance with the License. You may obtain\n#    a copy of the License at\n#\n#         http://www.apache.org/licenses/LICENSE-2.0\n#\n#    Unless required by applicable law or agreed to in writing, software\n#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n#    License for the specific language governing permissions and limitations\n#    under the License.\n\n# This is a placeholder for backports.\n# Do not use this number for new work.  New work starts after\n# all the placeholders.\n#\n# See this for more information:\n# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html\n\n\ndef upgrade(migrate_engine):\n    pass\n