Created
June 4, 2012 18:08
-
-
Save davidnuon/2869932 to your computer and use it in GitHub Desktop.
python script to generate a class for a wordpress post, just change the fields to make it into anything you want.
This file contains 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
fields = """wp_posts | |
id | |
post_author | |
post_date | |
post_date_gmt | |
post_content | |
post_title | |
post_category | |
post_excerpt | |
post_status | |
comment_status | |
ping_status | |
post_password | |
post_name | |
to_ping | |
pinged | |
post_modified | |
post_modified_gmt | |
post_content_filtered | |
post_parent | |
guid | |
menu_order | |
post_type | |
post_mime_type | |
comment_count""" | |
fields = fields.split("\n") | |
print "class WP_Post:" | |
for n in fields: | |
print " " + n + " = None" | |
print " def __init__(self, " + ",".join(fields) + "):" | |
for n in fields: | |
print " " + "self." + n + " = " + n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment