From b2665cad409db5bf83109b8ff120bc89e9395bde Mon Sep 17 00:00:00 2001 From: Sean DeNigris Date: Thu, 25 Mar 2021 16:20:17 -0400 Subject: [PATCH 1/2] Import From Statement E.g. `from fuzzywuzzy import process` can be written as `P3GImportFrom moduleNamed: 'fuzzywuzzy' names: #('process')` --- src/Python3Generator/P3GImportFrom.class.st | 37 +++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/Python3Generator/P3GImportFrom.class.st diff --git a/src/Python3Generator/P3GImportFrom.class.st b/src/Python3Generator/P3GImportFrom.class.st new file mode 100644 index 0000000..ef3425f --- /dev/null +++ b/src/Python3Generator/P3GImportFrom.class.st @@ -0,0 +1,37 @@ +Class { + #name : #P3GImportFrom, + #superclass : #P3GImport, + #instVars : [ + 'names' + ], + #category : #'Python3Generator-Core' +} + +{ #category : #'as yet unclassified' } +P3GImportFrom class >> moduleNamed: aString names: aCollection [ + ^ (self moduleNamed: aString) + names: aCollection; + yourself +] + +{ #category : #accessing } +P3GImportFrom >> names [ + ^ names ifNil: [ #() ] +] + +{ #category : #accessing } +P3GImportFrom >> names: anObject [ + names := anObject +] + +{ #category : #translating } +P3GImportFrom >> writePython3On: aStream [ + aStream + << 'from '. + self moduleIdentifier writePython3On: aStream. + aStream + << ' import '. + self names + do: [ :n | aStream << n ] + separatedBy: [ aStream << ', ' ] +] From 65a95074849e1f95e2701a395201e95f323a7045 Mon Sep 17 00:00:00 2001 From: Sean DeNigris Date: Thu, 25 Mar 2021 16:22:02 -0400 Subject: [PATCH 2/2] [doc]: method categorization --- src/Python3Generator/P3GImportFrom.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Python3Generator/P3GImportFrom.class.st b/src/Python3Generator/P3GImportFrom.class.st index ef3425f..e563a20 100644 --- a/src/Python3Generator/P3GImportFrom.class.st +++ b/src/Python3Generator/P3GImportFrom.class.st @@ -7,7 +7,7 @@ Class { #category : #'Python3Generator-Core' } -{ #category : #'as yet unclassified' } +{ #category : #'instance creation' } P3GImportFrom class >> moduleNamed: aString names: aCollection [ ^ (self moduleNamed: aString) names: aCollection;