Skip to content

Instantly share code, notes, and snippets.

@schmalliso
Last active August 10, 2016 13:50
Show Gist options
  • Save schmalliso/72b1e29c74d3cebc9d87b8697c315286 to your computer and use it in GitHub Desktop.
Save schmalliso/72b1e29c74d3cebc9d87b8697c315286 to your computer and use it in GitHub Desktop.
driver docs migration script
import os
# os.walk identifies all of the files in the specified repo
# your repo is probably not the same as mine, so you'll need to tweak that
for dirpath, dirs, files in os.walk('/Users/allison/docs-php-library/source/'):
for file in files:
# cuts off the first chunk of the directory path so you just have the
# paths you actually care about
filename = os.path.join(dirpath,file).split('source')[1]
# build/php-driver is where I'm importing the mongo-php-driver repo to
# (specified in the migrations of build_conf), so I need to prepend that
# to the filenames for the migrations.yaml file
sourcepath = "build/php-driver/docs" + filename
print "source: " + sourcepath
print "target: " + filename
print('---')
# I am way too lazy to bother with 'if this is the last itm, print `...` instead'
print "You need to clean up the last line of YAML now!!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment