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
1459b5d1
Commit
1459b5d1
authored
Oct 05, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHP namespace is not placed on a separate line
parent
c2b2219f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
9 deletions
+7
-9
TODO.txt
TODO.txt
+1
-1
generate.py
generate.py
+6
-8
No files found.
TODO.txt
View file @
1459b5d1
- Add has-many-and-belongs-to relation.
- Add
support for
has-many-and-belongs-to relation.
generate.py
View file @
1459b5d1
...
...
@@ -7,7 +7,6 @@ from itertools import combinations
PRIMARY_KEY
=
'id'
TAB
=
'
\
t
'
MODEL_NAMESPACE
=
''
def
php_value
(
data
,
indent
=
0
):
...
...
@@ -187,14 +186,14 @@ class Model(object):
php_value
(
self
.
accessible_attr
))
def
generate_php
(
self
,
add_php_block
=
False
):
# PHP delimiters
php
=
'<?php
\
n
\
n
%s
\
n
\
n
?>'
# Class definition
classname
=
self
.
classname
()
if
self
.
options
.
get
(
'namespace'
):
classname
=
options
[
'namespace'
]
+
'
\
\
'
+
classname
namespace
=
'namespace %s;
\
n
\
n
'
%
self
.
options
[
'namespace'
]
#classname = options['namespace'] + '\\' + classname
else
:
namespace
=
''
classdef
=
'class %s extends ActiveRecord
\
\
Model {
\
n
%%s
\
n
}'
%
classname
...
...
@@ -212,8 +211,8 @@ class Model(object):
if
self
.
options
.
get
(
'create_accessible'
,
True
):
lines
.
append
(
self
.
php_attr_accessible
())
php
=
classdef
%
'
\
n
'
.
join
([
TAB
+
line
for
line
in
lines
if
line
is
not
None
]
)
inner_lines
=
[
TAB
+
line
for
line
in
lines
if
line
is
not
None
]
php
=
namespace
+
classdef
%
'
\
n
'
.
join
(
inner_lines
)
return
php_block
(
php
)
if
add_php_block
else
php
...
...
@@ -322,7 +321,6 @@ if __name__ == '__main__': # pragma: nocover
parser
.
add_argument
(
'-s'
,
'--spaces'
,
nargs
=
'?'
,
const
=
4
,
type
=
int
,
help
=
'use spaces instead of tabs (4 by default)'
)
args
=
parser
.
parse_args
()
print
args
options
=
{}
for
arg
,
value
in
args
.
_get_kwargs
():
...
...
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