Commit 1459b5d1 authored by Taddeus Kroes's avatar Taddeus Kroes

PHP namespace is not placed on a separate line

parent c2b2219f
- Add has-many-and-belongs-to relation.
- Add support for has-many-and-belongs-to relation.
......@@ -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():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment