3
3
# Copyright (c) Jupyter Development Team.
4
4
# Distributed under the terms of the Modified BSD License.
5
5
import importlib
6
- import re
7
6
import math
8
7
import random
8
+ import re
9
9
import warnings
10
10
11
11
@@ -77,107 +77,111 @@ def match_url_to_resource(url, regex_mapping=None):
77
77
if pattern .fullmatch (url ):
78
78
return auth_resource
79
79
80
+
80
81
# From https://en.wikipedia.org/wiki/Moons_of_Jupiter
81
82
moons_of_jupyter = [
82
- ' Metis' ,
83
- ' Adrastea' ,
84
- ' Amalthea' ,
85
- ' Thebe' ,
86
- 'Io' ,
87
- ' Europa' ,
88
- ' Ganymede' ,
89
- ' Callisto' ,
90
- ' Themisto' ,
91
- ' Leda' ,
92
- ' Ersa' ,
93
- ' Pandia' ,
94
- ' Himalia' ,
95
- ' Lysithea' ,
96
- ' Elara' ,
97
- ' Dia' ,
98
- ' Carpo' ,
99
- ' Valetudo' ,
100
- ' Euporie' ,
101
- ' Eupheme' ,
83
+ " Metis" ,
84
+ " Adrastea" ,
85
+ " Amalthea" ,
86
+ " Thebe" ,
87
+ "Io" ,
88
+ " Europa" ,
89
+ " Ganymede" ,
90
+ " Callisto" ,
91
+ " Themisto" ,
92
+ " Leda" ,
93
+ " Ersa" ,
94
+ " Pandia" ,
95
+ " Himalia" ,
96
+ " Lysithea" ,
97
+ " Elara" ,
98
+ " Dia" ,
99
+ " Carpo" ,
100
+ " Valetudo" ,
101
+ " Euporie" ,
102
+ " Eupheme" ,
102
103
# 'S/2003 J 18',
103
104
# 'S/2010 J 2',
104
- ' Helike' ,
105
+ " Helike" ,
105
106
# 'S/2003 J 16',
106
107
# 'S/2003 J 2',
107
- ' Euanthe' ,
108
+ " Euanthe" ,
108
109
# 'S/2017 J 7',
109
- ' Hermippe' ,
110
- ' Praxidike' ,
111
- ' Thyone' ,
112
- ' Thelxinoe' ,
110
+ " Hermippe" ,
111
+ " Praxidike" ,
112
+ " Thyone" ,
113
+ " Thelxinoe" ,
113
114
# 'S/2017 J 3',
114
- ' Ananke' ,
115
- ' Mneme' ,
115
+ " Ananke" ,
116
+ " Mneme" ,
116
117
# 'S/2016 J 1',
117
- ' Orthosie' ,
118
- ' Harpalyke' ,
119
- ' Iocaste' ,
118
+ " Orthosie" ,
119
+ " Harpalyke" ,
120
+ " Iocaste" ,
120
121
# 'S/2017 J 9',
121
122
# 'S/2003 J 12',
122
123
# 'S/2003 J 4',
123
- ' Erinome' ,
124
- ' Aitne' ,
125
- ' Herse' ,
126
- ' Taygete' ,
124
+ " Erinome" ,
125
+ " Aitne" ,
126
+ " Herse" ,
127
+ " Taygete" ,
127
128
# 'S/2017 J 2',
128
129
# 'S/2017 J 6',
129
- ' Eukelade' ,
130
- ' Carme' ,
130
+ " Eukelade" ,
131
+ " Carme" ,
131
132
# 'S/2003 J 19',
132
- ' Isonoe' ,
133
+ " Isonoe" ,
133
134
# 'S/2003 J 10',
134
- ' Autonoe' ,
135
- ' Philophrosyne' ,
136
- ' Cyllene' ,
137
- ' Pasithee' ,
135
+ " Autonoe" ,
136
+ " Philophrosyne" ,
137
+ " Cyllene" ,
138
+ " Pasithee" ,
138
139
# 'S/2010 J 1',
139
- ' Pasiphae' ,
140
- ' Sponde' ,
140
+ " Pasiphae" ,
141
+ " Sponde" ,
141
142
# 'S/2017 J 8',
142
- ' Eurydome' ,
143
+ " Eurydome" ,
143
144
# 'S/2017 J 5',
144
- ' Kalyke' ,
145
- ' Hegemone' ,
146
- ' Kale' ,
147
- ' Kallichore' ,
145
+ " Kalyke" ,
146
+ " Hegemone" ,
147
+ " Kale" ,
148
+ " Kallichore" ,
148
149
# 'S/2011 J 1',
149
150
# 'S/2017 J 1',
150
- ' Chaldene' ,
151
- ' Arche' ,
152
- ' Eirene' ,
153
- ' Kore' ,
151
+ " Chaldene" ,
152
+ " Arche" ,
153
+ " Eirene" ,
154
+ " Kore" ,
154
155
# 'S/2011 J 2',
155
156
# 'S/2003 J 9',
156
- ' Megaclite' ,
157
- ' Aoede' ,
157
+ " Megaclite" ,
158
+ " Aoede" ,
158
159
# 'S/2003 J 23',
159
- ' Callirrhoe' ,
160
- ' Sinope'
160
+ " Callirrhoe" ,
161
+ " Sinope" ,
161
162
]
162
163
164
+
163
165
def get_anonymous_username () -> str :
164
166
"""
165
167
Get a random user-name based on the moons of Jupyter.
166
168
This function returns names like "Anonymous Io" or "Anonymous Metis".
167
169
"""
168
- return moons_of_jupyter [random .randint (0 , len (moons_of_jupyter )- 1 )]
170
+ return moons_of_jupyter [random .randint (0 , len (moons_of_jupyter ) - 1 )]
171
+
169
172
170
173
# Using JupyterLab CSS variable because the colors may change with the theme
171
174
user_colors = [
172
- ' var(--jp-collaborator-color1)' ,
173
- ' var(--jp-collaborator-color2)' ,
174
- ' var(--jp-collaborator-color3)' ,
175
- ' var(--jp-collaborator-color4)' ,
176
- ' var(--jp-collaborator-color5)' ,
177
- ' var(--jp-collaborator-color6)' ,
178
- ' var(--jp-collaborator-color7)'
175
+ " var(--jp-collaborator-color1)" ,
176
+ " var(--jp-collaborator-color2)" ,
177
+ " var(--jp-collaborator-color3)" ,
178
+ " var(--jp-collaborator-color4)" ,
179
+ " var(--jp-collaborator-color5)" ,
180
+ " var(--jp-collaborator-color6)" ,
181
+ " var(--jp-collaborator-color7)" ,
179
182
]
180
183
184
+
181
185
def get_random_color () -> str :
182
- """ Get a random color from the list of colors. """
183
- return user_colors [random .randint (0 , len (user_colors )- 1 )];
186
+ """Get a random color from the list of colors."""
187
+ return user_colors [random .randint (0 , len (user_colors ) - 1 )]
0 commit comments