Browse files

Add some comments and gitignore

  • Loading branch information...
1 parent 0c0ca92 commit 4560f2edb08279f27ffac1283132eff398839ed7 @jamezp committed Nov 4, 2011
Showing with 22 additions and 5 deletions.
  1. +8 −0 .gitignore
  2. +5 −4 MessageChecker.py
  3. +1 −0 MessageIdGenerator.py
  4. +8 −1 README
View
8 .gitignore
@@ -0,0 +1,8 @@
+#Ignore Intellij files
+*.iml
+*.iws
+*.ipr
+.idea/
+
+#Ignore Mac files
+.DS_Store
View
9 MessageChecker.py
@@ -31,11 +31,15 @@ def processFile(file):
lines = []
for line in current:
trimmedLine = line.strip()
+ # Skip comments
if trimmedLine.startswith("//") == False and trimmedLine.startswith("*") == False:
+ # Check for exceptions being thrown.
if trimmedLine.find("throw new") != -1 and search('"[^"\\\r\n]*(?:\\.[^"\\\r\n]*)*"', trimmedLine) != None:
lines.append(trimmedLine)
+ # Check for text that has at least one space.
if trimmedLine.startswith("@Message") == False and search('"[^"\\\r\n]*\w\s.*(?:\\.[^"\\\r\n]*)*"', trimmedLine) != None:
lines.append(trimmedLine)
+ # Check to see if lines were found and print
if len(lines) > 0:
print(str(file) + ":")
for line in lines:
@@ -51,17 +55,14 @@ def processDir(dir):
elif path.isdir(file_path):
processDir(file_path)
+# Parse the incoming parameters
parser = argparse.ArgumentParser(description="Check messages")
parser.add_argument("-f", "--file", metavar="FILE", type=str, dest="filename", help="The file or directory to scan messages for.")
-
args = parser.parse_args()
if not path.exists(args.filename):
raise Exception("File '" + args.filename + "' not found.")
-
-#filename = "/home/jperkins/projects/jboss-as/controller/src/main/java"
-#filename = "/home/jperkins/projects/jboss-as/controller/src/main/java/org/jboss/as/controller/parsing/CommonXml.java"
if path.isdir(args.filename):
processDir(args.filename)
elif path.isfile(args.filename):
View
1 MessageIdGenerator.py
@@ -47,6 +47,7 @@ def generateIds(filename, i):
# Move new file
move(temp_path, filename)
+# Parse the incoming parameters
parser = argparse.ArgumentParser(description="Generate message id's")
parser.add_argument("-f", "--file", metavar="FILE", type=str, dest="filename", help="The file to generate the id's for.")
parser.add_argument("-id", metavar="N", type=int, dest="i", help="The starting id.")
View
9 README
@@ -1 +1,8 @@
-This file was created by IntelliJ IDEA 10.5.2 for binding GitHub repository
+Simple python scripts for helping with logging tools tasks.
+
+MessageChecker: A very crude check of source files to see if there is any plain text or exceptions being thrown that
+ could need i18n translations.
+
+MessageIdGenerator: This simply updates a source file and adds id's to any line that starts with "@Message(v". If the
+ line starts with that text the next sequential line, based on the -id passed in, is added to the
+ line.

0 comments on commit 4560f2e

Please sign in to comment.