Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
0a504a18
Commit
0a504a18
authored
Nov 30, 2000
by
Michel Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated to use new interface methods
parent
47341875
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
27 deletions
+12
-27
lib/python/Interface/pprint.py
lib/python/Interface/pprint.py
+12
-27
No files found.
lib/python/Interface/pprint.py
View file @
0a504a18
...
...
@@ -2,8 +2,9 @@ import string
""" Pretty-Print an Interface object as structured text (Yum) """
def
justify_and_indent
(
text
,
level
,
munge
=
0
,
width
=
72
):
"""
strip newlines, indent and justify text
"""
"""
indent and justify text, rejustify (munge) if specified
"""
lines
=
[]
...
...
@@ -31,47 +32,31 @@ def justify_and_indent(text, level, munge=0, width=72):
return
string
.
join
(
lines
,
"
\
n
"
)
def
build_signature
(
meth
):
""" this is a lot of work just to build a signature... """
sig
=
"("
for
v
in
meth
.
positional
:
sig
=
sig
+
v
if
v
in
meth
.
optional
.
keys
():
sig
=
sig
+
"=%s"
%
`meth.optional[v]`
sig
=
sig
+
", "
if
meth
.
varargs
:
sig
=
sig
+
"*args, "
if
meth
.
kwargs
:
sig
=
sig
+
"**kws, "
# slice off the last comma and space
if
meth
.
positional
or
meth
.
varargs
or
meth
.
kwargs
:
sig
=
sig
[:
-
2
]
sig
=
sig
+
")"
return
sig
def
interface_as_stx
(
I
,
munge
=
0
):
""" Output structured text format. Note, this will wack any existing
'structured' format of the text. """
outp
=
"%s
\
n
\
n
"
%
I
.
__name__
outp
=
"%s
\
n
\
n
"
%
I
.
getName
()
level
=
1
if
I
.
__doc__
:
if
I
.
getDoc
()
:
outp
=
outp
+
justify_and_indent
(
I
.
__doc__
,
level
)
+
"
\
n
\
n
"
if
I
.
__bases__
:
if
I
.
getBases
()
:
outp
=
outp
+
(
" "
*
level
)
+
"This interface extends:
\
n
\
n
"
level
=
level
+
1
for
b
in
I
.
__bases__
:
item
=
"o %s"
%
b
.
__name__
for
b
in
I
.
getBases
()
:
item
=
"o %s"
%
b
.
getName
()
outp
=
outp
+
justify_and_indent
(
item
,
level
,
munge
)
+
"
\
n
\
n
"
level
=
level
-
1
level
=
level
+
1
for
name
,
desc
in
I
.
namesAndDescriptions
():
item
=
"%s%s -- %s"
%
(
name
,
build_signature
(
desc
),
desc
.
__doc__
)
if
desc
.
isMethod
():
item
=
"%s%s -- %s"
%
(
desc
.
getName
(),
desc
.
getSignatureRepr
(),
desc
.
getDoc
())
elif
desc
.
isAttr
():
item
=
"%s -- %s"
%
(
desc
.
getName
(),
desc
.
getDoc
())
outp
=
outp
+
justify_and_indent
(
item
,
level
,
munge
)
+
"
\
n
\
n
"
return
outp
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment