def read_json_flag(fobj):
<EOL>if isinstance(fobj, string_types):<EOL><INDENT>with open(fobj, '<STR_LIT:r>') as fobj2:<EOL><INDENT>return read_json_flag(fobj2)<EOL><DEDENT><DEDENT>txt = fobj.read()<EOL>if isinstance(txt, bytes):<EOL><INDENT>txt = txt.decode('<STR_LIT:utf-8>')<EOL><DEDENT>data = json.loads(txt)<EOL>name = '<STR_LIT>'.format(**data)<EOL>out = DataQualityFlag(name, active=data['<STR_LIT>'],<EOL>known=data['<STR_LIT>'])<EOL>try:<EOL><INDENT>out.description = data['<STR_LIT>'].get('<STR_LIT>', None)<EOL><DEDENT>except KeyError:  <EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>out.isgood = not data['<STR_LIT>'].get(<EOL>'<STR_LIT>', False)<EOL><DEDENT>return out<EOL>
Read a `DataQualityFlag` from a segments-web.ligo.org JSON file