Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
modelgen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
modelgen
Commits
9baebe79
Commit
9baebe79
authored
Jun 15, 2013
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup
parent
6f0117ce
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
generate.py
generate.py
+9
-5
No files found.
generate.py
View file @
9baebe79
#!/usr/bin/env python
#!/usr/bin/env python
import
os
import
re
import
re
import
MySQLdb
as
mysql
import
MySQLdb
as
mysql
from
singplur
import
singularize
from
itertools
import
combinations
from
itertools
import
combinations
from
argparse
import
ArgumentParser
from
singplur
import
singularize
PRIMARY_KEY
=
'id'
PRIMARY_KEY
=
'id'
TAB
=
'
\
t
'
TAB
=
'
\
t
'
...
@@ -291,10 +293,7 @@ def partition(callback, iterable):
...
@@ -291,10 +293,7 @@ def partition(callback, iterable):
return
a
,
b
return
a
,
b
if
__name__
==
'__main__'
:
# pragma: nocover
def
parse_options
():
import
os
from
argparse
import
ArgumentParser
parser
=
ArgumentParser
(
description
=
'Generate PHPActiveRecord models.'
)
parser
=
ArgumentParser
(
description
=
'Generate PHPActiveRecord models.'
)
parser
.
add_argument
(
'dbname'
,
help
=
'database name'
)
parser
.
add_argument
(
'dbname'
,
help
=
'database name'
)
parser
.
add_argument
(
'-H'
,
'--host'
,
metavar
=
'ADDRESS'
,
default
=
'localhost'
,
parser
.
add_argument
(
'-H'
,
'--host'
,
metavar
=
'ADDRESS'
,
default
=
'localhost'
,
...
@@ -333,6 +332,11 @@ if __name__ == '__main__': # pragma: nocover
...
@@ -333,6 +332,11 @@ if __name__ == '__main__': # pragma: nocover
if
args
.
spaces
:
if
args
.
spaces
:
TAB
=
args
.
spaces
*
' '
TAB
=
args
.
spaces
*
' '
return
args
,
options
if
__name__
==
'__main__'
:
# pragma: nocover
args
,
options
=
parse_options
()
conn
=
mysql
.
connect
(
args
.
host
,
args
.
user
,
args
.
password
,
args
.
dbname
)
conn
=
mysql
.
connect
(
args
.
host
,
args
.
user
,
args
.
password
,
args
.
dbname
)
models
=
create_models
(
conn
,
options
)
models
=
create_models
(
conn
,
options
)
conn
.
close
()
conn
.
close
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment