Move argparser into mains function body

feature-admin-split
Darksider3 5 years ago
parent a17d0ed30f
commit 65c7bb6b3f

@ -7,12 +7,6 @@ import configparser
import lib.uis.default as default_cmd # Follows -u, -a, -f flags
default_cmd.argparser.description += " - Backups Tilde Users to stdout or a file."
args = default_cmd.argparser.parse_args()
config = configparser.ConfigParser()
config.read(args.config)
class Backup:
filename: str
quoting: int
@ -52,6 +46,10 @@ class Backup:
if __name__ == "__main__":
default_cmd.argparser.description += " - Backups Tilde Users to stdout or a file."
args = default_cmd.argparser.parse_args()
config = configparser.ConfigParser()
config.read(args.config)
try:
L = ListUsers.ListUsers(config['DEFAULT']['applications_db'],
unapproved=args.unapproved, approved=args.approved)

@ -6,16 +6,6 @@ import configparser
import lib.UserExceptions
import lib.uis.config_ui # dont go to default, just following -c flag
ArgParser = lib.uis.config_ui.argparser
ArgParser.description += "- Imports a CSV file consisting of user specific details to the database"
ArgParser.add_argument('-f', '--file', default="stdout",
type=str, help='Import from CSV file', required=True)
ArgParser.add_argument('--Import', default=False, action="store_true",
help="Import Users.", required=True)
args = ArgParser.parse_args()
config = configparser.ConfigParser()
config.read(args.config)
def ImportFromFile(fname: str, db: str, userids: tuple = tuple([])):
if not os.path.isfile(fname):
@ -75,6 +65,16 @@ def ImportFromFile(fname: str, db: str, userids: tuple = tuple([])):
if __name__ == "__main__":
ArgParser = lib.uis.config_ui.argparser
ArgParser.description += "- Imports a CSV file consisting of user specific details to the database"
ArgParser.add_argument('-f', '--file', default="stdout",
type=str, help='Import from CSV file', required=True)
ArgParser.add_argument('--Import', default=False, action="store_true",
help="Import Users.", required=True)
args = ArgParser.parse_args()
config = configparser.ConfigParser()
config.read(args.config)
try:
if not args.Import:
print("Error, need the import flag")

@ -8,6 +8,8 @@ import lib.System
import lib.UserExceptions
import sqlite3
if __name__ == "__main__":
lib.uis.config_ui.argparser.description += " - Edit Tilde Users"
ArgParser = lib.uis.config_ui.argparser
ArgParser.add_argument('--user', type=str,
@ -34,9 +36,6 @@ ArgParser.add_argument('--status', type=int, default=None,
args = ArgParser.parse_args()
config = configparser.ConfigParser()
config.read(args.config)
if __name__ == "__main__":
try:
db = config['DEFAULT']['applications_db']
if not args.sshpubkey and not args.name and not args.username and not args.email and args.status is None \

Loading…
Cancel
Save