Better Python script support; update samples.json

This commit is contained in:
Ted Nyman
2013-07-07 14:33:18 -07:00
parent 6a15ae47ee
commit 62ad763933
2 changed files with 129 additions and 31 deletions

View File

@@ -309,6 +309,9 @@
"wisp": [ "wisp": [
".wisp" ".wisp"
], ],
"XC": [
".xc"
],
"XML": [ "XML": [
".ant", ".ant",
".ivy", ".ivy",
@@ -380,8 +383,8 @@
".gemrc" ".gemrc"
] ]
}, },
"tokens_total": 359968, "tokens_total": 360152,
"languages_total": 425, "languages_total": 427,
"tokens": { "tokens": {
"ABAP": { "ABAP": {
"*/**": 1, "*/**": 1,
@@ -32447,16 +32450,16 @@
"Python": { "Python": {
"from": 33, "from": 33,
"__future__": 2, "__future__": 2,
"import": 40, "import": 42,
"unicode_literals": 1, "unicode_literals": 1,
"copy": 1, "copy": 1,
"sys": 1, "sys": 2,
"functools": 1, "functools": 1,
"update_wrapper": 2, "update_wrapper": 2,
"future_builtins": 1, "future_builtins": 1,
"zip": 3, "zip": 3,
"django.db.models.manager": 1, "django.db.models.manager": 1,
"#": 10, "#": 13,
"Imported": 1, "Imported": 1,
"to": 4, "to": 4,
"register": 1, "register": 1,
@@ -32465,13 +32468,13 @@
"django.conf": 1, "django.conf": 1,
"settings": 1, "settings": 1,
"django.core.exceptions": 1, "django.core.exceptions": 1,
"(": 487, "(": 508,
"ObjectDoesNotExist": 2, "ObjectDoesNotExist": 2,
"MultipleObjectsReturned": 2, "MultipleObjectsReturned": 2,
"FieldError": 4, "FieldError": 4,
"ValidationError": 8, "ValidationError": 8,
"NON_FIELD_ERRORS": 3, "NON_FIELD_ERRORS": 3,
")": 498, ")": 519,
"django.core": 1, "django.core": 1,
"validators": 1, "validators": 1,
"django.db.models.fields": 1, "django.db.models.fields": 1,
@@ -32514,7 +32517,7 @@
"class": 14, "class": 14,
"ModelBase": 4, "ModelBase": 4,
"type": 4, "type": 4,
"def": 59, "def": 63,
"__new__": 2, "__new__": 2,
"cls": 32, "cls": 32,
"name": 39, "name": 39,
@@ -32524,29 +32527,29 @@
"super": 2, "super": 2,
".__new__": 1, ".__new__": 1,
"parents": 8, "parents": 8,
"[": 62, "[": 66,
"b": 9, "b": 9,
"for": 49, "for": 52,
"in": 68, "in": 72,
"if": 140, "if": 144,
"isinstance": 11, "isinstance": 11,
"]": 62, "]": 66,
"not": 64, "not": 64,
"return": 50, "return": 53,
"module": 6, "module": 6,
"attrs.pop": 2, "attrs.pop": 2,
"new_class": 9, "new_class": 9,
"{": 24, "{": 24,
"}": 24, "}": 24,
"attr_meta": 5, "attr_meta": 5,
"None": 84, "None": 86,
"abstract": 3, "abstract": 3,
"getattr": 30, "getattr": 30,
"False": 28, "False": 28,
"meta": 12, "meta": 12,
"else": 29, "else": 30,
"base_meta": 2, "base_meta": 2,
"is": 28, "is": 29,
"model_module": 1, "model_module": 1,
"sys.modules": 1, "sys.modules": 1,
"new_class.__module__": 1, "new_class.__module__": 1,
@@ -32584,7 +32587,7 @@
"attrs.items": 1, "attrs.items": 1,
"new_fields": 2, "new_fields": 2,
"new_class._meta.local_fields": 3, "new_class._meta.local_fields": 3,
"+": 7, "+": 15,
"new_class._meta.local_many_to_many": 2, "new_class._meta.local_many_to_many": 2,
"new_class._meta.virtual_fields": 1, "new_class._meta.virtual_fields": 1,
"field_names": 5, "field_names": 5,
@@ -32592,7 +32595,7 @@
"f.name": 5, "f.name": 5,
"f": 19, "f": 19,
"base": 13, "base": 13,
"parent": 4, "parent": 5,
"parent._meta.abstract": 1, "parent._meta.abstract": 1,
"parent._meta.fields": 1, "parent._meta.fields": 1,
"raise": 22, "raise": 22,
@@ -32661,7 +32664,7 @@
"opts.order_with_respect_to.rel.to": 1, "opts.order_with_respect_to.rel.to": 1,
"cls.__doc__": 3, "cls.__doc__": 3,
"cls.__name__": 1, "cls.__name__": 1,
".join": 2, ".join": 3,
"f.attname": 5, "f.attname": 5,
"opts.fields": 1, "opts.fields": 1,
"cls.get_absolute_url": 3, "cls.get_absolute_url": 3,
@@ -32684,7 +32687,7 @@
"args": 8, "args": 8,
"self._state": 1, "self._state": 1,
"args_len": 2, "args_len": 2,
"len": 8, "len": 9,
"self._meta.fields": 5, "self._meta.fields": 5,
"IndexError": 2, "IndexError": 2,
"fields_iter": 4, "fields_iter": 4,
@@ -32784,7 +32787,7 @@
"._update": 1, "._update": 1,
"meta.order_with_respect_to": 2, "meta.order_with_respect_to": 2,
"order_value": 2, "order_value": 2,
"*": 8, "*": 9,
".count": 1, ".count": 1,
"self._order": 1, "self._order": 1,
"fields": 10, "fields": 10,
@@ -32858,7 +32861,7 @@
"unique_togethers.append": 1, "unique_togethers.append": 1,
"model_class": 11, "model_class": 11,
"unique_together": 2, "unique_together": 2,
"check": 3, "check": 4,
"break": 2, "break": 2,
"unique_checks.append": 2, "unique_checks.append": 2,
"fields_with_class": 2, "fields_with_class": 2,
@@ -32927,7 +32930,7 @@
"ordered_obj._meta.order_with_respect_to.rel.field_name": 2, "ordered_obj._meta.order_with_respect_to.rel.field_name": 2,
"order_name": 4, "order_name": 4,
"ordered_obj._meta.order_with_respect_to.name": 2, "ordered_obj._meta.order_with_respect_to.name": 2,
"i": 2, "i": 7,
"j": 2, "j": 2,
"enumerate": 1, "enumerate": 1,
"ordered_obj.objects.filter": 2, "ordered_obj.objects.filter": 2,
@@ -32964,8 +32967,8 @@
"decorate": 2, "decorate": 2,
"based": 1, "based": 1,
"views": 1, "views": 1,
"the": 4, "the": 5,
"of": 2, "of": 3,
"as_view": 1, "as_view": 1,
".": 1, ".": 1,
"However": 1, "However": 1,
@@ -33042,8 +33045,38 @@
"Person": 1, "Person": 1,
"_message.Message": 1, "_message.Message": 1,
"_reflection.GeneratedProtocolMessageType": 1, "_reflection.GeneratedProtocolMessageType": 1,
"SHEBANG#!python": 2, "SHEBANG#!python": 3,
"print": 1, "print": 6,
"os": 1,
"main": 2,
"usage": 3,
"string": 1,
"command": 4,
"sys.argv": 2,
"<": 1,
"sys.exit": 1,
"printDelimiter": 4,
"get": 1,
"a": 1,
"list": 1,
"git": 1,
"directories": 1,
"specified": 1,
"gitDirectories": 2,
"getSubdirectories": 2,
"isGitDirectory": 2,
"gitDirectory": 2,
"os.chdir": 1,
"os.getcwd": 1,
"os.system": 1,
"directory": 9,
"filter": 3,
"os.path.abspath": 1,
"subdirectories": 3,
"os.walk": 1,
".next": 1,
"os.path.isdir": 1,
"__name__": 1,
"absolute_import": 1, "absolute_import": 1,
"division": 1, "division": 1,
"with_statement": 1, "with_statement": 1,
@@ -37640,6 +37673,22 @@
"input": 1, "input": 1,
"text": 1 "text": 1
}, },
"XC": {
"int": 2,
"main": 1,
"(": 1,
")": 1,
"{": 2,
"x": 3,
";": 4,
"chan": 1,
"c": 3,
"par": 1,
"<:>": 1,
"0": 1,
"}": 2,
"return": 1
},
"XML": { "XML": {
"<?xml>": 3, "<?xml>": 3,
"version=": 4, "version=": 4,
@@ -38816,7 +38865,7 @@
"PowerShell": 12, "PowerShell": 12,
"Processing": 74, "Processing": 74,
"Prolog": 4040, "Prolog": 4040,
"Python": 4088, "Python": 4248,
"R": 14, "R": 14,
"Racket": 360, "Racket": 360,
"Ragel in Ruby Host": 593, "Ragel in Ruby Host": 593,
@@ -38841,6 +38890,7 @@
"VimL": 20, "VimL": 20,
"Visual Basic": 345, "Visual Basic": 345,
"wisp": 1363, "wisp": 1363,
"XC": 24,
"XML": 5622, "XML": 5622,
"XProc": 22, "XProc": 22,
"XQuery": 801, "XQuery": 801,
@@ -38916,7 +38966,7 @@
"PowerShell": 2, "PowerShell": 2,
"Processing": 1, "Processing": 1,
"Prolog": 6, "Prolog": 6,
"Python": 5, "Python": 6,
"R": 1, "R": 1,
"Racket": 3, "Racket": 3,
"Ragel in Ruby Host": 3, "Ragel in Ruby Host": 3,
@@ -38941,6 +38991,7 @@
"VimL": 2, "VimL": 2,
"Visual Basic": 1, "Visual Basic": 1,
"wisp": 1, "wisp": 1,
"XC": 1,
"XML": 3, "XML": 3,
"XProc": 1, "XProc": 1,
"XQuery": 1, "XQuery": 1,
@@ -38948,5 +38999,5 @@
"Xtend": 2, "Xtend": 2,
"YAML": 1 "YAML": 1
}, },
"md5": "d233899b021f2ee7af2d7ff73c37a2b3" "md5": "06f04376114dadff4923b1138204a240"
} }

View File

@@ -0,0 +1,47 @@
#!/usr/bin/env python
import os
import sys
def main():
# usage string
usage = 'usage: gitall command'
# command check
if len(sys.argv) < 2:
sys.exit(usage)
command = 'git ' + ' '.join(sys.argv[1:])
printDelimiter()
print 'Running command:', command
# get a list of git directories in the specified parent
gitDirectories = getSubdirectories('.', isGitDirectory)
for gitDirectory in gitDirectories:
os.chdir(gitDirectory)
printDelimiter()
print 'Current respository location:', os.getcwd()
os.system(command)
printDelimiter()
def getSubdirectories(directory, filter = None):
directory = os.path.abspath(directory)
subdirectories = os.walk(directory).next()[1]
if filter is None:
return [directory + '/' + i for i in subdirectories]
else:
return [directory + '/' + i for i in subdirectories if filter(directory + '/' + i)]
def isGitDirectory(directory):
return os.path.isdir(directory + '/.git/')
def printDelimiter():
print '\033[91m'
print ('#' * 80)
print '\033[0m'
if __name__ == '__main__':
main()