Skip to content

Instantly share code, notes, and snippets.

@narusemotoki
Created November 11, 2012 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save narusemotoki/4054341 to your computer and use it in GitHub Desktop.
Save narusemotoki/4054341 to your computer and use it in GitHub Desktop.
GitHubから各環境用の.gitignoreを取得して書き出します
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import urllib2
def write(ignore):
"""
引数を.gitignoreに書き込みます.
"""
f = open(".gitignore", "w")
f.write(ignore)
f.close()
def help():
print(u'引数でAndroidやDjangoを与えてください.')
print(u'https://github.com/github/gitignore に対応しています.')
if __name__ == '__main__':
# 引数が0個の場合にヘルプを表示する.
if 2 > len(sys.argv):
help()
else:
try:
url = 'https://raw.github.com/github/gitignore/master/' + sys.argv[1] + '.gitignore'
res = urllib2.urlopen(url)
except urllib2.URLError, e:
print(u'error: ' + str(e.code))
else:
write(res.read())
print(u'完了しました')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment