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
72d40b85
Commit
72d40b85
authored
Nov 30, 2000
by
Michel Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored, added new method interface methods
parent
942b9c96
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
1 deletion
+61
-1
lib/python/Interface/Method.py
lib/python/Interface/Method.py
+61
-1
No files found.
lib/python/Interface/Method.py
View file @
72d40b85
...
...
@@ -3,6 +3,8 @@
import
Exceptions
from
Attr
import
Attribute
sig_traits
=
[
'positional'
,
'required'
,
'optional'
,
'varargs'
,
'kwargs'
]
class
MethodClass
:
def
fromFunction
(
self
,
func
,
interface
=
''
):
...
...
@@ -28,6 +30,10 @@ class MethodClass:
m
.
interface
=
interface
return
m
def
fromMethod
(
self
,
meth
,
interface
=
''
):
func
=
meth
.
im_func
return
self
.
fromFunction
(
func
,
interface
)
class
Method
(
Attribute
):
"""Method interfaces
...
...
@@ -36,6 +42,7 @@ class Method(Attribute):
"""
fromFunction
=
MethodClass
().
fromFunction
fromMethod
=
MethodClass
().
fromMethod
interface
=
''
def
__init__
(
self
,
__name__
=
None
,
__doc__
=
None
):
...
...
@@ -46,5 +53,58 @@ class Method(Attribute):
def
__call__
(
self
,
*
args
,
**
kw
):
raise
Exceptions
.
BrokenImplementation
(
self
.
interface
,
self
.
__name__
)
def
isMethod
(
self
):
return
1
def
getSignatureInfo
(
self
):
info
=
{}
for
t
in
sig_traits
:
info
[
t
]
=
getattr
(
self
,
t
)
return
info
def
getSignatureRepr
(
self
):
sig
=
"("
for
v
in
self
.
positional
:
sig
=
sig
+
v
if
v
in
self
.
optional
.
keys
():
sig
=
sig
+
"=%s"
%
`self.optional[v]`
sig
=
sig
+
", "
if
self
.
varargs
:
sig
=
sig
+
"*args, "
if
self
.
kwargs
:
sig
=
sig
+
"**kws, "
# slice off the last comma and space
if
self
.
positional
or
self
.
varargs
or
self
.
kwargs
:
sig
=
sig
[:
-
2
]
sig
=
sig
+
")"
return
sig
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