Created
August 25, 2016 20:32
-
-
Save felipsmartins/ddcc831cad40cfda345c08c8e35801ce to your computer and use it in GitHub Desktop.
Convert campos de "decribe <table>" para propriedade de classes PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import sys | |
| path = '/tmp/campos.txt' | |
| campos = [l.strip().split(',') for l in open(path).readlines()] | |
| attrs = ['type', 'null', 'key', 'default', 'extra'] | |
| doc_template = """ | |
| /** | |
| * {} | |
| * | |
| * @var | |
| */ | |
| protected ${}; | |
| """ | |
| for props in campos: | |
| this_props = [p.replace("'", "") for p in props] | |
| this_attrs = [":".join(x) for x in zip(attrs, this_props[1:])] | |
| this_attrs = "; ".join(this_attrs) | |
| print doc_template.format(this_attrs, this_props[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment