3
3
import enum
4
4
import gettext
5
5
import logging
6
- import pkg_resources
7
6
import re
8
7
import shutil
9
8
import sys
14
13
import requests
15
14
import termcolor
16
15
16
+ from importlib .resources import files
17
+ from packaging import version
17
18
from . import __version__ , CONFIG_LOADER
18
19
19
20
# Internationalization
20
- gettext .install ("submit50" , pkg_resources . resource_filename ( "submit50" , "locale" ))
21
+ gettext .install ("submit50" , str ( files ( "submit50" ). joinpath ( "locale" ) ))
21
22
22
23
SUBMIT_URL = "https://submit.cs50.io"
23
24
@@ -65,8 +66,8 @@ def check_version():
65
66
"Please visit our status page https://cs50.statuspage.io for more information." ))
66
67
67
68
# Check that latest version == version installed
68
- required_version = pkg_resources . parse_version (res .text .strip ())
69
- local_version = pkg_resources . parse_version (__version__ )
69
+ required_version = version . parse (res .text .strip ())
70
+ local_version = version . parse (__version__ )
70
71
71
72
if required_version > local_version :
72
73
raise Error (_ ("You have an outdated version of submit50. "
@@ -126,7 +127,7 @@ def prompt(honesty, included, excluded):
126
127
# If there's no honesty question, continue.
127
128
if not honesty :
128
129
return True
129
-
130
+
130
131
# Prompt for honesty
131
132
try :
132
133
# Show default message
@@ -138,17 +139,17 @@ def prompt(honesty, included, excluded):
138
139
# If a custom message is configured, show that instead
139
140
else :
140
141
honesty_question = str (honesty )
141
-
142
+
142
143
# Get the user's answer
143
144
answer = input (honesty_question )
144
145
except EOFError :
145
146
answer = None
146
147
print ()
147
-
148
+
148
149
# If no answer given, or yes is not given, don't continue
149
150
if not answer or not re .match (f"^\s*(?:{ _ ('y|yes' )} )\s*$" , answer , re .I ):
150
151
return False
151
-
152
+
152
153
# Otherwise, do continue
153
154
return True
154
155
@@ -199,12 +200,12 @@ def main():
199
200
'\n debug: adds the output of all commands run.' )
200
201
)
201
202
parser .add_argument (
202
- "-V" , "--version" ,
203
- action = "version" ,
203
+ "-V" , "--version" ,
204
+ action = "version" ,
204
205
version = f"%(prog)s { __version__ } "
205
206
)
206
207
parser .add_argument (
207
- "slug" ,
208
+ "slug" ,
208
209
help = _ ("prescribed identifier of work to submit" )
209
210
)
210
211
0 commit comments