FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpython/Tools/scripts/findlinksto.py at 2.7 · python-emscripten/cpython · GitHub
python-emscripten
cpython
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpython
/
Tools
/
scripts
/
findlinksto.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
43 lines (38 loc) · 1.04 KB
Breadcrumbs
cpython
/
Tools
/
scripts
/
findlinksto.py
Copy path
File metadata and controls
executable file
·
43 lines (38 loc) · 1.04 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
34
35
36
37
38
39
40
41
42
43
#! /usr/bin/env python
# findlinksto
#
# find symbolic links to a path matching a regular expression
import
os
import
sys
import
re
import
getopt
def
main
():
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
''
)
if
len
(
args
)
<
2
:
raise
getopt
.
GetoptError
(
'not enough arguments'
,
None
)
except
getopt
.
GetoptError
,
msg
:
sys
.
stdout
=
sys
.
stderr
print
msg
print
'usage: findlinksto pattern directory ...'
sys
.
exit
(
2
)
pat
,
dirs
=
args
[
0
],
args
[
1
:]
prog
=
re
.
compile
(
pat
)
for
dirname
in
dirs
:
os
.
path
.
walk
(
dirname
,
visit
,
prog
)
def
visit
(
prog
,
dirname
,
names
):
if
os
.
path
.
islink
(
dirname
):
names
[:]
=
[]
return
if
os
.
path
.
ismount
(
dirname
):
print
'descend into'
,
dirname
for
name
in
names
:
name
=
os
.
path
.
join
(
dirname
,
name
)
try
:
linkto
=
os
.
readlink
(
name
)
if
prog
.
search
(
linkto
)
is
not
None
:
print
name
,
'->'
,
linkto
except
os
.
error
:
pass
if
__name__
==
'__main__'
:
main
()
Back
|
FazBrowse Home
|
New Git URL