Skip to content

Commit

Permalink
Update args.py
Browse files Browse the repository at this point in the history
  • Loading branch information
datawhores authored Nov 23, 2023
1 parent 006f202 commit c69db2f
Showing 1 changed file with 29 additions and 26 deletions.
55 changes: 29 additions & 26 deletions ofscraper/utils/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,33 +242,36 @@ def getargs(input=None):




parser=create_parser(input)

args=parser.parse_args(input)


#fix args
args.posts=list(set(args.posts or []))
args.excluded_post=list(set(args.excluded_posts or []))
args.username=set(args.username or [])
args.excluded_username=set( args.excluded_username or [])
args.label=set(args.label) if args.label else args.label
args.black_list=set(list(map(lambda x:x.lower(),args.black_list)))
if len(args.user_list)==0:args.user_list={constants.OFSCRAPER_RESERVED_LIST}
else:args.user_list=set(list(map(lambda x:x.lower(),args.user_list)))

try:
parser=create_parser(input)



if args.command in set(["post_check","msg_check"])and not (args.url or args.file):
raise argparse.ArgumentTypeError("error: argument missing --url or --file must be specified )")
elif args.command in set(["story_check","paid_check"])and not (args.username or args.file):
raise argparse.ArgumentTypeError("error: argument missing --username or --file must be specified )")
elif args.command in set(["manual"])and not (args.url or args.file):
raise argparse.ArgumentTypeError("error: argument missing --url or --file must be specified )")
print(args)
sys.exit()
args=parser.parse_args(input)


#fix args
args.posts=list(set(args.posts or []))
args.excluded_post=list(set(args.excluded_posts or []))
args.username=set(args.username or [])
args.excluded_username=set( args.excluded_username or [])
args.label=set(args.label) if args.label else args.label
args.black_list=set(list(map(lambda x:x.lower(),args.black_list)))
if len(args.user_list)==0:args.user_list={constants.OFSCRAPER_RESERVED_LIST}
else:args.user_list=set(list(map(lambda x:x.lower(),args.user_list)))




if args.command in set(["post_check","msg_check"])and not (args.url or args.file):
raise argparse.ArgumentTypeError("error: argument missing --url or --file must be specified )")
elif args.command in set(["story_check","paid_check"])and not (args.username or args.file):
raise argparse.ArgumentTypeError("error: argument missing --username or --file must be specified )")
elif args.command in set(["manual"])and not (args.url or args.file):
raise argparse.ArgumentTypeError("error: argument missing --url or --file must be specified )")
print(args)
sys.exit()
except Exception as E:
print(E)
sys.exit()
return args


Expand Down

0 comments on commit c69db2f

Please sign in to comment.