FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python/Tools/scripts/ptags.py at master · jtashk/python · GitHub
jtashk
/
python
Public
forked from
glix/python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
python
/
Tools
/
scripts
/
ptags.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
53 lines (45 loc) · 1.2 KB
Breadcrumbs
python
/
Tools
/
scripts
/
ptags.py
Copy path
File metadata and controls
executable file
·
53 lines (45 loc) · 1.2 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
44
45
46
47
48
49
50
51
52
53
#! /usr/bin/env python
# ptags
#
# Create a tags file for Python programs, usable with vi.
# Tagged are:
# - functions (even inside other defs or classes)
# - classes
# - filenames
# Warns about files it cannot open.
# No warnings about duplicate tags.
import
sys
,
re
,
os
tags
=
[]
# Modified global variable!
def
main
():
args
=
sys
.
argv
[
1
:]
for
filename
in
args
:
treat_file
(
filename
)
if
tags
:
fp
=
open
(
'tags'
,
'w'
)
tags
.
sort
()
for
s
in
tags
:
fp
.
write
(
s
)
expr
=
'^[
\t
]*(def|class)[
\t
]+([a-zA-Z0-9_]+)[
\t
]*[:\(]'
matcher
=
re
.
compile
(
expr
)
def
treat_file
(
filename
):
try
:
fp
=
open
(
filename
,
'r'
)
except
:
sys
.
stderr
.
write
(
'Cannot open %s
\n
'
%
filename
)
return
base
=
os
.
path
.
basename
(
filename
)
if
base
[
-
3
:]
==
'.py'
:
base
=
base
[:
-
3
]
s
=
base
+
'
\t
'
+
filename
+
'
\t
'
+
'1
\n
'
tags
.
append
(
s
)
while
1
:
line
=
fp
.
readline
()
if
not
line
:
break
m
=
matcher
.
match
(
line
)
if
m
:
content
=
m
.
group
(
0
)
name
=
m
.
group
(
2
)
s
=
name
+
'
\t
'
+
filename
+
'
\t
/^'
+
content
+
'/
\n
'
tags
.
append
(
s
)
if
__name__
==
'__main__'
:
main
()
Back
|
FazBrowse Home
|
New Git URL