本文整理汇总了Python中job.Job.validate方法的典型用法代码示例。如果您正苦于以下问题:Python Job.validate方法的具体用法?Python Job.validate怎么用?Python Job.validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类job.Job
的用法示例。
在下文中一共展示了Job.validate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: file
# 需要导入模块: from job import Job [as 别名]
# 或者: from job.Job import validate [as 别名]
parser.add_argument("infile", help="Tweet Input file (JSON)")
parser.add_argument("outfile", help="Cleaned Tweets output file")
args = parser.parse_args()
logging.basicConfig(filename='tweets_cleaned.log', filemode='w', level=logging.DEBUG)
# Instantiate a class that manages processes and resources
manager = Manager()
# use a+ so we can add the total number of tweets with unicode after the tweet-by-tweet processing
with open(args.infile) as input_fp, open(args.outfile, 'a+') as output_fp:
lines = input_fp.readlines()
# make sure output file is empty
output_fp.truncate()
# each line is a JSON formatted tweet
for line in lines:
# specify job id, job data and job type
job = Job(line)
job.clean_data()
job.validate()
if job.is_valid:
manager.put(job)
output_fp.write(str(manager.get()))
output_fp.write(manager.unicode_output())