def analyseArgs(args): """ 检测传入的参数,返回字典形式的参数列表,如果有检测失败的则返回None :param args: 参数 :return: 无 """ if args.url is None: print('error: the following arguments are required: URL') return None Configuration.url = args.url Configuration.name = args.name Configuration.thread = args.thread Configuration.outPath = args.outpath Configuration.begin = args.begin Configuration.end = args.end Configuration.slice = args.slice Configuration.timeout = args.timeout Configuration.temp = args.temp # 简单判断一下url if not TextUtil.isUrl(Configuration.url): print('error: "%s" is not a correct URL' % Configuration.url) print('please check the link for incorrect input') return None # 名字 if Configuration.name is None: Configuration.name = 'index.ts' pass # 路径 if Configuration.outPath is None: Configuration.outPath = OSUtil.getPath() pass elif not TextUtil.isPath(Configuration.outPath): print('error: "%s" is not a correct path' % Configuration.outPath) return None pass # 线程数 if not 0 < Configuration.thread < 256: print( 'error: the number of threads must be greater than 0 and less than or equal to 256' ) return None pass
def analyseArgs(args): dit = { 'url': args.url[0], 'name': args.name, 'thread': args.thread, 'path': args.output } # 简单判断一下url if not TextUtil.isUrl(dit['url']): print('error: "%s" is not a correct URL' % dit['url']) print('please check the link for incorrect input') return None # 名字 if dit['name'] is None: dit['name'] = 'index.ts' pass # 路径 if dit['path'] is None: dit['path'] = OSUtil.getPath() pass elif not TextUtil.isPath(dit['path']): print('error: "%s" is not a correct path' % dit['path']) return None pass # 线程数 if not 0 < dit['thread'] < 129: print( 'error: the number of threads must be greater than 0 and less than or equal to 128' ) return None return dit