Fix a few coding style nits in Buck build Python scripts

- Prefix regex strings with `r`
- Remove unused imports
- Rename variables and parameters to avoid redefinition of
  built-in types `dir` and `type`

Change-Id: Ia21667b89631c751f241dd6499a2e460e3435697
diff --git a/Documentation/replace_macros.py b/Documentation/replace_macros.py
index 076cb49..b070062 100755
--- a/Documentation/replace_macros.py
+++ b/Documentation/replace_macros.py
@@ -14,13 +14,12 @@
 # limitations under the License.
 
 from optparse import OptionParser
-import os
 import re
 import sys
 
-PAT_GERRIT = re.compile('^GERRIT')
-PAT_INCLUDE = re.compile('^(include::.*)(\[\])$')
-PAT_GET = re.compile('^get::([^ \t\n]*)')
+PAT_GERRIT = re.compile(r'^GERRIT')
+PAT_INCLUDE = re.compile(r'^(include::.*)(\[\])$')
+PAT_GET = re.compile(r'^get::([^ \t\n]*)')
 
 GERRIT_UPLINK = """
 
diff --git a/tools/eclipse/project.py b/tools/eclipse/project.py
index 884d0ff..e20798e 100755
--- a/tools/eclipse/project.py
+++ b/tools/eclipse/project.py
@@ -117,8 +117,8 @@
       continue
 
     for env in ['main', 'test']:
-      for type in ['java', 'resources']:
-        p = path.join(s, 'src', env, type)
+      for srctype in ['java', 'resources']:
+        p = path.join(s, 'src', env, srctype)
         if path.exists(p):
           classpathentry('src', p)
 
diff --git a/tools/maven/mvn.py b/tools/maven/mvn.py
index fefc5b3..bdf5d01 100644
--- a/tools/maven/mvn.py
+++ b/tools/maven/mvn.py
@@ -53,11 +53,11 @@
   exit(1)
 
 for spec in args.s:
-  artifact, type, src = spec.split(':')
+  artifact, packaging_type, src = spec.split(':')
   try:
     check_output(cmd + [
       '-DartifactId=%s' % artifact,
-      '-Dpackaging=%s' % type,
+      '-Dpackaging=%s' % packaging_type,
       '-Dfile=%s' % src,
     ])
   except Exception as e:
diff --git a/tools/pack_war.py b/tools/pack_war.py
index 0ba802b..4c5cd89 100755
--- a/tools/pack_war.py
+++ b/tools/pack_war.py
@@ -28,8 +28,8 @@
 root = war[:war.index('buck-out')]
 jars = set()
 
-def link_jars(libs, dir):
-  makedirs(dir)
+def link_jars(libs, directory):
+  makedirs(directory)
   cp = check_output(['buck', 'audit', 'classpath'] + libs)
   for j in cp.strip().splitlines():
     if j not in jars:
@@ -37,7 +37,7 @@
       n = path.basename(j)
       if j.startswith('buck-out/gen/gerrit-'):
         n = j.split('/')[2] + '-' + n
-      symlink(path.join(root, j), path.join(dir, n))
+      symlink(path.join(root, j), path.join(directory, n))
 
 if args.lib:
   link_jars(args.lib, path.join(war, 'WEB-INF', 'lib'))