GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — add abc imports when defining interfaces · akumar5/java2python@daced34

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • java2python
    • compiler
      • visitor.py
    • config
      • default.py
    • mod
      • basic.py
  • test/configs
    • Class10.py
    • Interface1.py
    • defaults.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎java2python/compiler/visitor.py‎

Copy file name to clipboardExpand all lines: java2python/compiler/visitor.py
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,12 @@ def acceptType(self, node, memo):
129129
acceptAt = makeAcceptType('at')
130130
acceptClass = makeAcceptType('klass')
131131
acceptEnum = makeAcceptType('enum')
132-
acceptInterface = makeAcceptType('interface')
132+
_acceptInterface = makeAcceptType('interface')
133+
134+
def acceptInterface(self, node, memo):
135+
module = self.parents(lambda x:x.isModule).next()
136+
module.needsAbstractHelpers = True
137+
return self._acceptInterface(node, memo)
133138

134139

135140
class Module(TypeAcceptor, Base):
Collapse file

‎java2python/config/default.py‎

Copy file name to clipboardExpand all lines: java2python/config/default.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
basic.simpleDocString,
2727
'from __future__ import print_function',
2828
basic.maybeBsr,
29+
basic.maybeAbstractHelpers,
2930
basic.maybeSyncHelpers,
3031
]
3132

Collapse file

‎java2python/mod/basic.py‎

Copy file name to clipboardExpand all lines: java2python/mod/basic.py
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ def maybeAbstractMethod(method):
133133

134134
def maybeSynchronizedMethod(method):
135135
if 'synchronized' in method.modifiers:
136-
module = method.parents(lambda x:x.isModule).next()
137-
module.needsSyncHelpers = True
138136
yield '@synchronized'
139137

140138

@@ -160,6 +158,11 @@ def maybeBsr(module):
160158
yield line
161159

162160

161+
def maybeAbstractHelpers(module):
162+
if getattr(module, 'needsAbstractHelpers', False):
163+
yield 'from abc import ABCMeta, abstractmethod'
164+
165+
163166
def maybeSyncHelpers(module):
164167
if getattr(module, 'needsSyncHelpers', False):
165168
for line in getSyncHelpersSrc().split('\n'):
Collapse file

‎test/configs/Class10.py‎

Copy file name to clipboard
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
modulePrologueHandlers = [
22
'from java2python.mod.include.overloading import overloaded',
3-
'from abc import ABCMeta, abstractmethod',
43
]
Collapse file

‎test/configs/Interface1.py‎

Copy file name to clipboardExpand all lines: test/configs/Interface1.py
-3Lines changed: 0 additions & 3 deletions
This file was deleted.
Collapse file

‎test/configs/defaults.py‎

Copy file name to clipboardExpand all lines: test/configs/defaults.py
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
modulePrologueHandlers = [
44
'from java2python.mod.include.classmethod import classmethod_ as classmethod',
55
'from java2python.mod.include.overloading import overloaded',
6-
'from abc import ABCMeta, abstractmethod',
76
'import zope.interface',
87
]
98

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.