-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcphier.py
executable file
·33 lines (30 loc) · 929 Bytes
/
cphier.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python
import sys, os, shutil
if(len(sys.argv) > 1): target = sys.argv[1].rstrip('/')
else: target = os.path.expanduser('~/Dropbox/dev/misc')
for line in sys.stdin.readlines():
if not line.strip(): continue
fn = line.split()[-1].strip()
if (fn.startswith("cmake/") or
fn.endswith(".dylib") or
fn.endswith(".os") or
fn.endswith(".so") or
fn.endswith(".o") or
fn.endswith(".pyc") or
fn.endswith("~") or
os.path.split(fn)[1].startswith("._") or
fn.count("/.svn/")
):
continue
if os.path.isdir(fn): fn += '/'
newfn = target+"/"+fn
diffs = 1
if not os.path.exists(os.path.dirname(newfn)):
os.makedirs(os.path.dirname(newfn))
else:
diffs = int(os.popen("diff -rq %s %s|wc -l"%(fn,newfn)).read()) if os.path.exists(newfn) else -1
if diffs:
# print "copying %s to %s %i" % (fn,newfn,diffs)
cmd = "rsync --exclude .svn -a %s %s"%(fn,newfn)
print cmd
os.system(cmd)