log
graph
tags
bookmarks
branches
changeset
browse
file
latest
diff
comparison
annotate
file log
raw
help
Mercurial
>
hg
>
config
annotate python/dotpath.py @ 767:
35f8751c0930
Find changesets by keywords (author, files, the commit message), revision number or hash, or
revset expression
.
it is very annoying to have ones overrides overridden; see also http://stackoverflow.com/questions/25381304/why-type-cd-on-mac-os-states-that-cd-is-a-function
author
Jeff Hammel <k0scist@gmail.com>
date
Thu, 28 Jan 2016 14:02:17 -0800 (2016-01-28)
parents
03fc1f76db91
children
Ignore whitespace changes -
Everywhere:
Within whitespace:
At end of lines:
rev
line source
20
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
1
#!/usr/bin/env python
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
2
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
3
import sys
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
4
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
5
def filename(dotpath):
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
6
path = dotpath.split('.')
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
7
while path:
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
8
try:
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
9
module = __import__('.'.join(path))
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
10
return module.__file__.rstrip('c')
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
11
except ImportError:
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
12
path.pop()
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
13
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
14
def main(args=sys.argv[1:]):
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
15
for arg in args:
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
16
try:
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
17
_filename = filename(arg)
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
18
except Exception, e:
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
19
print e
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
20
continue
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
21
print _filename
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
22
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
23
if __name__ == '__main__':
03fc1f76db91
adding dotpath python helper
k0s <k0scist@gmail.com>
parents:
diff
changeset
+
−
24
main()