33import enum
44import gettext
55import logging
6- import pkg_resources
76import re
87import shutil
98import sys
1413import requests
1514import termcolor
1615
16+ from importlib .resources import files
17+ from packaging import version
1718from . import __version__ , CONFIG_LOADER
1819
1920# Internationalization
20- gettext .install ("submit50" , pkg_resources . resource_filename ( "submit50" , "locale" ))
21+ gettext .install ("submit50" , str ( files ( "submit50" ). joinpath ( "locale" ) ))
2122
2223SUBMIT_URL = "https://submit.cs50.io"
2324
@@ -65,8 +66,8 @@ def check_version():
6566 "Please visit our status page https://cs50.statuspage.io for more information." ))
6667
6768 # 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__ )
7071
7172 if required_version > local_version :
7273 raise Error (_ ("You have an outdated version of submit50. "
@@ -126,7 +127,7 @@ def prompt(honesty, included, excluded):
126127 # If there's no honesty question, continue.
127128 if not honesty :
128129 return True
129-
130+
130131 # Prompt for honesty
131132 try :
132133 # Show default message
@@ -138,17 +139,17 @@ def prompt(honesty, included, excluded):
138139 # If a custom message is configured, show that instead
139140 else :
140141 honesty_question = str (honesty )
141-
142+
142143 # Get the user's answer
143144 answer = input (honesty_question )
144145 except EOFError :
145146 answer = None
146147 print ()
147-
148+
148149 # If no answer given, or yes is not given, don't continue
149150 if not answer or not re .match (f"^\s*(?:{ _ ('y|yes' )} )\s*$" , answer , re .I ):
150151 return False
151-
152+
152153 # Otherwise, do continue
153154 return True
154155
@@ -199,12 +200,12 @@ def main():
199200 '\n debug: adds the output of all commands run.' )
200201 )
201202 parser .add_argument (
202- "-V" , "--version" ,
203- action = "version" ,
203+ "-V" , "--version" ,
204+ action = "version" ,
204205 version = f"%(prog)s { __version__ } "
205206 )
206207 parser .add_argument (
207- "slug" ,
208+ "slug" ,
208209 help = _ ("prescribed identifier of work to submit" )
209210 )
210211
0 commit comments