-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathLePythonBridgeSettings.class.st
More file actions
87 lines (70 loc) · 2.47 KB
/
Copy pathLePythonBridgeSettings.class.st
File metadata and controls
87 lines (70 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
"
LePythonBridgeSettings provides a wrapper around the DB properties to group PythonBridge settings together.
"
Class {
#name : #LePythonBridgeSettings,
#superclass : #Object,
#instVars : [
'dbProperties'
],
#category : 'Lepiter-Python-Settings'
}
{ #category : #accessing }
LePythonBridgeSettings >> dbProperties [
^ dbProperties
]
{ #category : #accessing }
LePythonBridgeSettings >> dbProperties: anObject [
dbProperties := anObject
]
{ #category : #'accessing - db properties' }
LePythonBridgeSettings >> directory [
"Answer the FileReference where PythonBridge should be located for this database"
<return: #FileReference or: nil>
^ dbProperties pythonBridge at: #directory
ifPresent: [ :aString | aString asFileReference ]
ifAbsent: [ nil ]
]
{ #category : #'accessing - db properties' }
LePythonBridgeSettings >> directory: aFileReferenceStringOrNil [
"Store the directory as a string."
self updateProperty: #directory
value: (dbProperties fileReferenceString: aFileReferenceStringOrNil)
]
{ #category : #'accessing - db properties' }
LePythonBridgeSettings >> pipenvPath [
"Answer the FileReference where pipenv is located"
<return: #FileReference or: nil>
^ dbProperties pythonBridge at: #pipenvPath
ifPresent: [ :aString | aString asFileReference ]
ifAbsent: [ nil ]
]
{ #category : #'accessing - db properties' }
LePythonBridgeSettings >> pipenvPath: aFileReferenceStringOrNil [
self updateProperty: #pipenvPath
value: (dbProperties fileReferenceString: aFileReferenceStringOrNil)
]
{ #category : #accessing }
LePythonBridgeSettings >> serverDebugMode [
"Answer a boolean indicating whether the server should be started in debug mode"
<return: #Boolean>
^ dbProperties pythonBridge at: #serverDebugMode
ifPresent: [ :aBoolean | aBoolean ]
ifAbsent: [ false ]
]
{ #category : #accessing }
LePythonBridgeSettings >> serverDebugMode: aBooleanOrNil [
"Set a boolean indicating whether the server should be started in debug mode"
^ self updateProperty: #serverDebugMode value: aBooleanOrNil
]
{ #category : #private }
LePythonBridgeSettings >> updateProperty: propertyName value: aJSONObject [
| pbDictionary |
pbDictionary := self dbProperties pythonBridge copy.
aJSONObject ifNil:
[ pbDictionary removeKey: propertyName ifAbsent: [ ].
^ dbProperties pythonBridge: pbDictionary ].
(pbDictionary at: propertyName ifAbsent: [nil]) = aJSONObject ifTrue: [ ^ self ].
pbDictionary at: propertyName put: aJSONObject.
dbProperties pythonBridge: pbDictionary.
]