@fiss_cmd<EOL>def attr_fill_null(args):
NULL_SENTINEL = "<STR_LIT>"<EOL>attrs = args.attributes<EOL>if not attrs:<EOL><INDENT>print("<STR_LIT>")<EOL>return <NUM_LIT:1><EOL><DEDENT>if '<STR_LIT>' in attrs or '<STR_LIT>' in attrs:<EOL><INDENT>print("<STR_LIT>")<EOL>return <NUM_LIT:1><EOL><DEDENT>if args.entity_type is not None:<EOL><INDENT>print("<STR_LIT>")<EOL>entities = _entity_paginator(args.project, args.workspace,<EOL>args.entity_type,<EOL>page_size=<NUM_LIT:1000>, filter_terms=None,<EOL>sort_direction="<STR_LIT>")<EOL>orig_attrs = list(attrs)<EOL>if args.entity_type == "<STR_LIT>":<EOL><INDENT>attrs.insert(<NUM_LIT:0>, "<STR_LIT>")<EOL><DEDENT>header = "<STR_LIT>" + args.entity_type + "<STR_LIT>" + "<STR_LIT:\t>".join(attrs)<EOL>attr_update_counts = {a : <NUM_LIT:0> for a in orig_attrs}<EOL>entity_data = []<EOL>for entity_dict in entities:<EOL><INDENT>name = entity_dict['<STR_LIT:name>']<EOL>etype = entity_dict['<STR_LIT>']<EOL>e_attrs = entity_dict['<STR_LIT>']<EOL>line = name<EOL>altered = False<EOL>for attr in attrs:<EOL><INDENT>if attr == "<STR_LIT>":<EOL><INDENT>line += "<STR_LIT:\t>" + e_attrs['<STR_LIT>']['<STR_LIT>']<EOL>continue <EOL><DEDENT>if attr not in e_attrs:<EOL><INDENT>altered = True<EOL>attr_update_counts[attr] += <NUM_LIT:1><EOL><DEDENT>line += "<STR_LIT:\t>" + str(e_attrs.get(attr, NULL_SENTINEL))<EOL><DEDENT>if altered:<EOL><INDENT>entity_data.append(line)<EOL><DEDENT><DEDENT>num_entities = len(entities)<EOL>prompt = "<STR_LIT>"<EOL>for attr in orig_attrs:<EOL><INDENT>if num_entities == attr_update_counts[attr]:<EOL><INDENT>message = "<STR_LIT>".format(<EOL>args.entity_type, attr<EOL>)<EOL>if not args.yes and not _confirm_prompt(message, prompt):<EOL><INDENT>return<EOL><DEDENT><DEDENT><DEDENT>if not any(c != <NUM_LIT:0> for c in itervalues(attr_update_counts)):<EOL><INDENT>print("<STR_LIT>")<EOL>return <NUM_LIT:0><EOL><DEDENT>if args.to_loadfile:<EOL><INDENT>print("<STR_LIT>" + args.to_loadfile)<EOL>with open(args.to_loadfile, "<STR_LIT:w>") as f:<EOL><INDENT>f.write(header + '<STR_LIT:\n>')<EOL>f.write("<STR_LIT:\n>".join(entity_data))<EOL><DEDENT>return <NUM_LIT:0><EOL><DEDENT>updates_table = "<STR_LIT>"<EOL>for attr in sorted(attr_update_counts):<EOL><INDENT>count = attr_update_counts[attr]<EOL>updates_table += "<STR_LIT>".format(count, attr)<EOL><DEDENT>message = "<STR_LIT>""<STR_LIT>" + updates_table<EOL>if not args.yes and not _confirm_prompt(message):<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>print("<STR_LIT>" + str(len(entity_data)) + "<STR_LIT>")<EOL>chunk_len = <NUM_LIT><EOL>total = int(len(entity_data) / chunk_len) + <NUM_LIT:1><EOL>batch = <NUM_LIT:0><EOL>for i in range(<NUM_LIT:0>, len(entity_data), chunk_len):<EOL><INDENT>batch += <NUM_LIT:1><EOL>print("<STR_LIT>".format(<EOL>i+<NUM_LIT:1>, min(i+chunk_len, len(entity_data)), batch, total<EOL>))<EOL>this_data = header + '<STR_LIT:\n>' + '<STR_LIT:\n>'.join(entity_data[i:i+chunk_len])<EOL>r = fapi.upload_entities(args.project, args.workspace, this_data)<EOL>fapi._check_response_code(r, <NUM_LIT:200>)<EOL><DEDENT>return <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>print("<STR_LIT>")<EOL>return <NUM_LIT:1><EOL><DEDENT>
Assign the null sentinel value for all entities which do not have a value
for the given attributes.

see gs://broad-institute-gdac/GDAC_FC_NULL for more details