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 5855312 commit cd3c605
Showing 1 changed file with 28 additions and 30 deletions.
58 changes: 28 additions & 30 deletions ofscraper/utils/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,46 +233,44 @@ def create_parser(input=None):

def getargs(input=None):
global args
print(multiprocessing.parent_process())
if args and input==None:
return args
if "pytest" in sys.modules and input==None:
input=[]
elif input==None:
input=sys.argv[1:]
if multiprocessing.parent_process():
input=[]


print(input)
parser=create_parser(input)

args=parser.parse_args(input)


try:
print(input)
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)))



#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()


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()
return args


Expand Down

0 comments on commit cd3c605

Please sign in to comment.