@@ -1388,21 +1388,6 @@ def add(self, name1, name2=None, symbols=None):
1388
1388
... 'Decimal', 'GUID', 'COMMETHOD', 'DISPMETHOD', 'IUnknown',
1389
1389
... 'dispid', 'CoClass', 'BSTR', 'DISPPROPERTY'
1390
1390
... }
1391
- >>> print(imports.getvalue(for_stub=True))
1392
- from ctypes import *
1393
- import datetime
1394
- from decimal import Decimal as Decimal
1395
- from comtypes import (
1396
- BSTR as BSTR,
1397
- CoClass as CoClass,
1398
- COMMETHOD as COMMETHOD,
1399
- dispid as dispid,
1400
- DISPMETHOD as DISPMETHOD,
1401
- DISPPROPERTY as DISPPROPERTY,
1402
- GUID as GUID,
1403
- IUnknown as IUnknown,
1404
- )
1405
- import ctypes.wintypes
1406
1391
"""
1407
1392
if name2 is None :
1408
1393
import_ = name1
@@ -1448,25 +1433,19 @@ def get_symbols(self) -> Set[str]:
1448
1433
names .add (key )
1449
1434
return names
1450
1435
1451
- def _make_line (self , from_ , imports , for_stub ):
1452
- if for_stub :
1453
- import_ = ", " .join ("%s as %s" % (n , n ) for n in imports )
1454
- else :
1455
- import_ = ", " .join (imports )
1436
+ def _make_line (self , from_ , imports ):
1437
+ import_ = ", " .join (imports )
1456
1438
code = "from %s import %s" % (from_ , import_ )
1457
1439
if len (code ) <= 80 :
1458
1440
return code
1459
- if for_stub :
1460
- import_ = "\n " .join (" %s as %s," % (n , n ) for n in imports )
1461
- else :
1462
- wrapper = textwrap .TextWrapper (
1463
- subsequent_indent = " " , initial_indent = " " , break_long_words = False
1464
- )
1465
- import_ = "\n " .join (wrapper .wrap (import_ ))
1441
+ wrapper = textwrap .TextWrapper (
1442
+ subsequent_indent = " " , initial_indent = " " , break_long_words = False
1443
+ )
1444
+ import_ = "\n " .join (wrapper .wrap (import_ ))
1466
1445
code = "from %s import (\n %s\n )" % (from_ , import_ )
1467
1446
return code
1468
1447
1469
- def getvalue (self , for_stub = False ):
1448
+ def getvalue (self ):
1470
1449
ns = {}
1471
1450
lines = []
1472
1451
for key , val in self .data .items ():
@@ -1481,7 +1460,7 @@ def getvalue(self, for_stub=False):
1481
1460
lines .append ("import %s" % key )
1482
1461
else :
1483
1462
names = sorted (val , key = lambda s : s .lower ())
1484
- lines .append (self ._make_line (key , names , for_stub = for_stub ))
1463
+ lines .append (self ._make_line (key , names ))
1485
1464
return "\n " .join (lines )
1486
1465
1487
1466
0 commit comments