|
|
@@ -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():
|