1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-13 02:30:11 +01:00

remove all references to optparse (deprecated since Python 3.2)

This commit is contained in:
Hans-Christoph Steiner 2024-05-02 14:08:28 +02:00
parent 717df09be0
commit 1e5699e90c
24 changed files with 115 additions and 93 deletions

View File

@ -182,7 +182,7 @@ def main():
"can not be specified at the same time."))
sys.exit(1)
# Trick optparse into displaying the right usage when --help is used.
# Trick argparse into displaying the right usage when --help is used.
sys.argv[0] += ' ' + command
del sys.argv[1]

View File

@ -4,7 +4,6 @@
import inspect
import logging
import optparse
import os
import shutil
import sys
@ -1104,15 +1103,17 @@ class BuildTest(unittest.TestCase):
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))
parser = optparse.OptionParser()
parser.add_option(
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Spew out even more information than normal",
)
(fdroidserver.common.options, args) = parser.parse_args(['--verbose'])
fdroidserver.common.options = parser.parse_args(['--verbose'])
newSuite = unittest.TestSuite()
newSuite.addTest(unittest.makeSuite(BuildTest))

View File

@ -3,7 +3,6 @@
# http://www.drdobbs.com/testing/unit-testing-with-python/240165163
import logging
import optparse
import os
import sys
import unittest
@ -336,15 +335,17 @@ class CheckupdatesTest(unittest.TestCase):
if __name__ == "__main__":
parser = optparse.OptionParser()
parser.add_option(
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Spew out even more information than normal",
)
(fdroidserver.common.options, args) = parser.parse_args(['--verbose'])
fdroidserver.common.options = parser.parse_args(['--verbose'])
newSuite = unittest.TestSuite()
newSuite.addTest(unittest.makeSuite(CheckupdatesTest))

View File

@ -9,7 +9,6 @@ import importlib
import inspect
import json
import logging
import optparse
import os
import re
import ruamel.yaml
@ -22,6 +21,7 @@ import unittest
import textwrap
import yaml
import gzip
from argparse import ArgumentParser
from zipfile import BadZipFile, ZipFile
from unittest import mock
from pathlib import Path
@ -3294,15 +3294,15 @@ class ConfigOptionsScopeTest(unittest.TestCase):
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))
parser = optparse.OptionParser()
parser.add_option(
parser = ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Spew out even more information than normal",
)
(fdroidserver.common.options, args) = parser.parse_args(['--verbose'])
fdroidserver.common.options = parser.parse_args(['--verbose'])
newSuite = unittest.TestSuite()
newSuite.addTest(unittest.makeSuite(CommonTest))

View File

@ -2,7 +2,6 @@
import inspect
import logging
import optparse
import os
import sys
import tempfile
@ -390,15 +389,17 @@ class DeployTest(unittest.TestCase):
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))
parser = optparse.OptionParser()
parser.add_option(
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Spew out even more information than normal",
)
(fdroidserver.common.options, args) = parser.parse_args(['--verbose'])
fdroidserver.common.options = parser.parse_args(['--verbose'])
newSuite = unittest.TestSuite()
newSuite.addTest(unittest.makeSuite(DeployTest))

View File

@ -3,7 +3,6 @@
# http://www.drdobbs.com/testing/unit-testing-with-python/240165163
import inspect
import optparse
import os
import sys
import unittest
@ -57,15 +56,17 @@ class ExceptionTest(unittest.TestCase):
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))
parser = optparse.OptionParser()
parser.add_option(
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Spew out even more information than normal",
)
(fdroidserver.exception.options, args) = parser.parse_args(['--verbose'])
fdroidserver.exception.options = parser.parse_args(['--verbose'])
fdroidserver.common.options = fdroidserver.exception.options
newSuite = unittest.TestSuite()

View File

@ -3,7 +3,6 @@
import inspect
import json
import logging
import optparse
import os
import shutil
import sys
@ -75,15 +74,17 @@ class GpgsignTest(unittest.TestCase):
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))
parser = optparse.OptionParser()
parser.add_option(
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Spew out even more information than normal",
)
(common.options, args) = parser.parse_args(['--verbose'])
common.options = parser.parse_args(['--verbose'])
newSuite = unittest.TestSuite()
newSuite.addTest(unittest.makeSuite(GpgsignTest))

View File

@ -4,7 +4,6 @@
import git
import logging
import optparse
import os
import shutil
import sys
@ -161,15 +160,17 @@ class ImportTest(unittest.TestCase):
if __name__ == "__main__":
parser = optparse.OptionParser()
parser.add_option(
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Spew out even more information than normal",
)
(fdroidserver.common.options, args) = parser.parse_args(['--verbose'])
fdroidserver.common.options = parser.parse_args(['--verbose'])
newSuite = unittest.TestSuite()
newSuite.addTest(unittest.makeSuite(ImportTest))

View File

@ -5,7 +5,6 @@ import datetime
import glob
import inspect
import logging
import optparse
import os
import sys
import unittest
@ -942,15 +941,17 @@ class AltstoreIndexTest(unittest.TestCase):
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))
parser = optparse.OptionParser()
parser.add_option(
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Spew out even more information than normal",
)
(options, args) = parser.parse_args(["--verbose"])
options = parser.parse_args(["--verbose"])
Options.verbose = options.verbose
newSuite = unittest.TestSuite()

View File

@ -5,7 +5,6 @@
import inspect
import logging
import os
import optparse
import shutil
import sys
import unittest
@ -75,15 +74,17 @@ class InitTest(unittest.TestCase):
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))
parser = optparse.OptionParser()
parser.add_option(
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Spew out even more information than normal",
)
(fdroidserver.init.options, args) = parser.parse_args(['--verbose'])
fdroidserver.init.options = parser.parse_args(['--verbose'])
newSuite = unittest.TestSuite()
newSuite.addTest(unittest.makeSuite(InitTest))

View File

@ -3,7 +3,6 @@
# http://www.drdobbs.com/testing/unit-testing-with-python/240165163
import inspect
import optparse
import os
import sys
import unittest
@ -38,15 +37,17 @@ class InstallTest(unittest.TestCase):
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))
parser = optparse.OptionParser()
parser.add_option(
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Spew out even more information than normal",
)
(fdroidserver.install.options, args) = parser.parse_args(['--verbose'])
fdroidserver.install.options = parser.parse_args(['--verbose'])
fdroidserver.common.options = fdroidserver.install.options
newSuite = unittest.TestSuite()

View File

@ -3,7 +3,6 @@
# http://www.drdobbs.com/testing/unit-testing-with-python/240165163
import logging
import optparse
import os
import ruamel.yaml
import shutil
@ -527,15 +526,17 @@ class LintAntiFeaturesTest(unittest.TestCase):
if __name__ == "__main__":
parser = optparse.OptionParser()
parser.add_option(
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Spew out even more information than normal",
)
(fdroidserver.lint.options, args) = parser.parse_args(['--verbose'])
fdroidserver.lint.options = parser.parse_args(['--verbose'])
fdroidserver.common.options = fdroidserver.lint.options
newSuite = unittest.TestSuite()

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python3
import inspect
import optparse
import os
import sys
import pkgutil
@ -265,15 +264,17 @@ class MainTest(unittest.TestCase):
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))
parser = optparse.OptionParser()
parser.add_option(
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Spew out even more information than normal",
)
(common.options, args) = parser.parse_args(['--verbose'])
common.options = parser.parse_args(['--verbose'])
newSuite = unittest.TestSuite()
newSuite.addTest(unittest.makeSuite(MainTest))

View File

@ -3,7 +3,6 @@
import copy
import io
import logging
import optparse
import os
import random
import ruamel.yaml
@ -2447,15 +2446,17 @@ class PostMetadataParseTest(unittest.TestCase):
if __name__ == "__main__":
parser = optparse.OptionParser()
parser.add_option(
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Spew out even more information than normal",
)
(fdroidserver.common.options, args) = parser.parse_args(['--verbose'])
fdroidserver.common.options = parser.parse_args(['--verbose'])
newSuite = unittest.TestSuite()
newSuite.addTest(unittest.makeSuite(MetadataTest))

View File

@ -2,7 +2,6 @@
import inspect
import logging
import optparse
import os
import random
import requests
@ -126,15 +125,17 @@ class NetTest(unittest.TestCase):
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))
parser = optparse.OptionParser()
parser.add_option(
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Spew out even more information than normal",
)
(common.options, args) = parser.parse_args(['--verbose'])
common.options = parser.parse_args(['--verbose'])
newSuite = unittest.TestSuite()
newSuite.addTest(unittest.makeSuite(NetTest))

View File

@ -2,7 +2,6 @@
import inspect
import logging
import optparse
import os
import requests
import shutil
@ -364,15 +363,17 @@ class NightlyTest(unittest.TestCase):
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))
parser = optparse.OptionParser()
parser.add_option(
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Spew out even more information than normal",
)
(common.options, args) = parser.parse_args(['--verbose'])
common.options = parser.parse_args(['--verbose'])
newSuite = unittest.TestSuite()
newSuite.addTest(unittest.makeSuite(NightlyTest))

View File

@ -13,7 +13,6 @@
import inspect
import json
import logging
import optparse
import os
import shutil
import sys
@ -413,15 +412,17 @@ class PublishTest(unittest.TestCase):
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))
parser = optparse.OptionParser()
parser.add_option(
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Spew out even more information than normal",
)
(common.options, args) = parser.parse_args(['--verbose'])
common.options = parser.parse_args(['--verbose'])
newSuite = unittest.TestSuite()
newSuite.addTest(unittest.makeSuite(PublishTest))

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python3
import logging
import optparse
import os
import sys
import unittest
@ -265,15 +264,17 @@ class RewriteMetaTest(unittest.TestCase):
if __name__ == "__main__":
parser = optparse.OptionParser()
parser.add_option(
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Spew out even more information than normal",
)
(common.options, args) = parser.parse_args(['--verbose'])
common.options = parser.parse_args(['--verbose'])
newSuite = unittest.TestSuite()
newSuite.addTest(unittest.makeSuite(RewriteMetaTest))

View File

@ -3,7 +3,6 @@
import glob
import inspect
import logging
import optparse
import os
import re
import shutil
@ -815,15 +814,17 @@ class Test_main(unittest.TestCase):
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))
parser = optparse.OptionParser()
parser.add_option(
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Spew out even more information than normal",
)
(fdroidserver.common.options, args) = parser.parse_args(['--verbose'])
fdroidserver.common.options = parser.parse_args(['--verbose'])
newSuite = unittest.TestSuite()
newSuite.addTests(

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python3
import inspect
import optparse
import os
import sys
import unittest
@ -59,15 +58,17 @@ class SignaturesTest(unittest.TestCase):
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))
parser = optparse.OptionParser()
parser.add_option(
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Spew out even more information than normal",
)
(common.options, args) = parser.parse_args(['--verbose'])
common.options = parser.parse_args(['--verbose'])
newSuite = unittest.TestSuite()
newSuite.addTest(unittest.makeSuite(SignaturesTest))

View File

@ -3,7 +3,6 @@
import inspect
import json
import logging
import optparse
import os
import shutil
import subprocess
@ -193,15 +192,17 @@ class SignindexTest(unittest.TestCase):
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))
parser = optparse.OptionParser()
parser.add_option(
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Spew out even more information than normal",
)
(common.options, args) = parser.parse_args(['--verbose'])
common.options = parser.parse_args(['--verbose'])
newSuite = unittest.TestSuite()
newSuite.addTest(unittest.makeSuite(SignindexTest))

View File

@ -9,7 +9,6 @@ import hashlib
import inspect
import json
import logging
import optparse
import os
import random
import shutil
@ -2271,15 +2270,17 @@ class TestParseFromPbxproj(unittest.TestCase):
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))
parser = optparse.OptionParser()
parser.add_option(
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Spew out even more information than normal",
)
(fdroidserver.common.options, args) = parser.parse_args(['--verbose'])
fdroidserver.common.options = parser.parse_args(['--verbose'])
newSuite = unittest.TestSuite()
newSuite.addTest(unittest.makeSuite(UpdateTest))

View File

@ -4,7 +4,6 @@
import inspect
import logging
import optparse
import os
import sys
import unittest
@ -88,15 +87,17 @@ class VCSTest(unittest.TestCase):
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))
parser = optparse.OptionParser()
parser.add_option(
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Spew out even more information than normal",
)
(fdroidserver.common.options, args) = parser.parse_args(['--verbose'])
fdroidserver.common.options = parser.parse_args(['--verbose'])
newSuite = unittest.TestSuite()
newSuite.addTest(unittest.makeSuite(VCSTest))

View File

@ -3,7 +3,6 @@
import inspect
import json
import logging
import optparse
import os
import shutil
import sys
@ -94,15 +93,17 @@ class VerifyTest(unittest.TestCase):
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))
parser = optparse.OptionParser()
parser.add_option(
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
default=False,
help="Spew out even more information than normal",
)
(common.options, args) = parser.parse_args(['--verbose'])
common.options = parser.parse_args(['--verbose'])
newSuite = unittest.TestSuite()
newSuite.addTest(unittest.makeSuite(VerifyTest))