Skip to content

Instantly share code, notes, and snippets.

@davidnuon
Created June 4, 2012 18:08
Show Gist options
  • Save davidnuon/2869932 to your computer and use it in GitHub Desktop.
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.
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