Move from optparse (deprecated) to argparse
This commit is contained in:
parent
7826511abb
commit
d723cec5eb
1 changed files with 7 additions and 7 deletions
|
@ -15,7 +15,7 @@ DEFSECTION = "Poezio"
|
|||
from configparser import RawConfigParser, NoOptionError, NoSectionError
|
||||
from os import environ, makedirs, path
|
||||
from shutil import copy2
|
||||
from optparse import OptionParser
|
||||
from argparse import ArgumentParser
|
||||
|
||||
class Config(RawConfigParser):
|
||||
"""
|
||||
|
@ -192,12 +192,12 @@ if not path.isfile(path.join(CONFIG_PATH, 'poezio.cfg')):
|
|||
copy2(path.join(path.dirname(__file__), '../data/default_config.cfg'), path.join(CONFIG_PATH, 'poezio.cfg'))
|
||||
firstrun = True
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option("-f", "--file", dest="filename", default=path.join(CONFIG_PATH, 'poezio.cfg'),
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument("-f", "--file", dest="filename", default=path.join(CONFIG_PATH, 'poezio.cfg'),
|
||||
help="The config file you want to use", metavar="CONFIG_FILE")
|
||||
parser.add_option("-d", "--debug", dest="debug",
|
||||
parser.add_argument("-d", "--debug", dest="debug",
|
||||
help="The file where debug will be written", metavar="DEBUG_FILE")
|
||||
(options, args) = parser.parse_args()
|
||||
options = parser.parse_args()
|
||||
config = Config(options.filename)
|
||||
if firstrun:
|
||||
config.set('firstrun', True)
|
||||
|
|
Loading…
Reference in a new issue