if six.PY2:<EOL><INDENT>p[<NUM_LIT:0>] = p[<NUM_LIT:1>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL><DEDENT>


p[<NUM_LIT:0>] = utils.NoAssert()<EOL>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_lic_text(self.document, value)<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>'].format(p.lineno(<NUM_LIT:1>))<EOL>self.logger.log(msg)<EOL>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_lic_id(self.document, value)<EOL><DEDENT>except SPDXValueError:<EOL><INDENT>self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>'].format(p.lineno(<NUM_LIT:1>))<EOL>self.logger.log(msg)<EOL><DEDENT>


self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>'].format(p[<NUM_LIT:1>], p.lineno(<NUM_LIT:1>))<EOL>self.logger.log(msg)<EOL>


pass<EOL>

file_artifact : prj_name_art file_art_rest
                         | prj_name_art


self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>'].format(p.lineno(<NUM_LIT:2>))<EOL>self.logger.log(msg)<EOL>


pass<EOL>

file_art_rest : prj_home_art prj_uri_art
                         | prj_uri_art prj_home_art
                         | prj_home_art
                         | prj_uri_art


try:<EOL><INDENT>self.builder.set_file_atrificat_of_project(self.document,<EOL>'<STR_LIT>', utils.UnKnown())<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_file_atrificat_of_project(self.document, '<STR_LIT>', value)<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


try:<EOL><INDENT>self.builder.set_file_atrificat_of_project(self.document, '<STR_LIT>', p[<NUM_LIT:2>])<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_file_atrificat_of_project(self.document, '<STR_LIT:name>', value)<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>'].format(p.lineno())<EOL>self.logger.log(msg)<EOL>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.add_file_dep(self.document, value)<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.add_file_contribution(self.document, value)<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_file_notice(self.document, value)<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


try:<EOL><INDENT>self.builder.set_file_copyright(self.document, p[<NUM_LIT:2>])<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>

file_cr_text : FILE_CR_TEXT file_cr_value


p[<NUM_LIT:0>] = utils.SPDXNone()<EOL>


p[<NUM_LIT:0>] = utils.NoAssert()<EOL>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_file_license_comment(self.document, value)<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>

file_lics_comment : FILE_LICS_COMMENT TEXT


file_lics_comment : FILE_LICS_COMMENT error


try:<EOL><INDENT>self.builder.set_file_license_in_file(self.document, p[<NUM_LIT:2>])<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except SPDXValueError:<EOL><INDENT>self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>'].format(p.lineno(<NUM_LIT:1>))<EOL>self.logger.log(msg)<EOL><DEDENT>

file_lics_info : FILE_LICS_INFO file_lic_info_value


if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:1>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:1>]<EOL><DEDENT>p[<NUM_LIT:0>] = document.License.from_identifier(value)<EOL>


if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:1>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:1>]<EOL><DEDENT>ref_re = re.compile('<STR_LIT>', re.UNICODE)<EOL>if (p[<NUM_LIT:1>] in config.LICENSE_MAP.keys()) or (ref_re.match(p[<NUM_LIT:1>]) is not None):<EOL><INDENT>p[<NUM_LIT:0>] = document.License.from_identifier(value)<EOL><DEDENT>else:<EOL><INDENT>p[<NUM_LIT:0>] = self.license_list_parser.parse(value)<EOL><DEDENT>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_file_name(self.document, value)<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>'].format(p.lineno(<NUM_LIT:1>))<EOL>self.logger.log(msg)<EOL>


if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>if not self.builder.doc_spdx_id_set:<EOL><INDENT>self.builder.set_doc_spdx_id(self.document, value)<EOL><DEDENT>else:<EOL><INDENT>self.builder.set_file_spdx_id(self.document, value)<EOL><DEDENT>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_file_comment(self.document, value)<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


try:<EOL><INDENT>self.builder.set_file_type(self.document, p[<NUM_LIT:2>])<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_file_chksum(self.document, value)<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


try:<EOL><INDENT>self.builder.set_concluded_license(self.document, p[<NUM_LIT:2>])<EOL><DEDENT>except SPDXValueError:<EOL><INDENT>self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>'].format(p.lineno(<NUM_LIT:1>))<EOL>self.logger.log(msg)<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


if six.PY2:<EOL><INDENT>p[<NUM_LIT:0>] = p[<NUM_LIT:1>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL><DEDENT>

file_type_value : OTHER
                           | SOURCE
                           | ARCHIVE
                           | BINARY


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_pkg_desc(self.document, value)<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_pkg_summary(self.document, value)<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


try:<EOL><INDENT>self.builder.set_pkg_cr_text(self.document, p[<NUM_LIT:2>])<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>

pkg_cr_text : PKG_CPY_TEXT pkg_cr_text_value


p[<NUM_LIT:0>] = utils.SPDXNone()<EOL>


p[<NUM_LIT:0>] = utils.NoAssert()<EOL>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_pkg_license_comment(self.document, value)<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


pkg_lic_comment : PKG_LICS_COMMENT error


try:<EOL><INDENT>self.builder.set_pkg_license_declared(self.document, p[<NUM_LIT:2>])<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except SPDXValueError:<EOL><INDENT>self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>'].format(p.lineno(<NUM_LIT:1>))<EOL>self.logger.log(msg)<EOL><DEDENT>

pkg_lic_decl : PKG_LICS_DECL conc_license


try:<EOL><INDENT>self.builder.set_pkg_license_from_file(self.document, p[<NUM_LIT:2>])<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except SPDXValueError:<EOL><INDENT>self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>'].format(p.lineno(<NUM_LIT:1>))<EOL>self.logger.log(msg)<EOL><DEDENT>

pkg_lic_ff : PKG_LICS_FFILE pkg_lic_ff_value


try:<EOL><INDENT>self.builder.set_pkg_licenses_concluded(self.document, p[<NUM_LIT:2>])<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except SPDXValueError:<EOL><INDENT>self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>'].format(p.lineno(<NUM_LIT:1>))<EOL>self.logger.log(msg)<EOL><DEDENT>

pkg_lic_conc : PKG_LICS_CONC conc_license


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_pkg_source_info(self.document, value)<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_pkg_chk_sum(self.document, value)<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_pkg_verif_code(self.document, value)<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except SPDXValueError:<EOL><INDENT>self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>'].format(p.lineno(<NUM_LIT:1>))<EOL>self.logger.log(msg)<EOL><DEDENT>


self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>'].format(p.lineno(<NUM_LIT:1>))<EOL>self.logger.log(msg)<EOL>


try:<EOL><INDENT>self.builder.set_pkg_down_location(self.document, p[<NUM_LIT:2>])<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>']<EOL>self.logger.log(msg)<EOL>


pkg_down_location : PKG_DOWN pkg_down_value


try:<EOL><INDENT>self.builder.set_pkg_originator(self.document, p[<NUM_LIT:2>])<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except SPDXValueError:<EOL><INDENT>self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>'].format(p.lineno(<NUM_LIT:1>))<EOL>self.logger.log(msg)<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


try:<EOL><INDENT>self.builder.set_pkg_supplier(self.document, p[<NUM_LIT:2>])<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except SPDXValueError:<EOL><INDENT>self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>'].format(p.lineno(<NUM_LIT:1>))<EOL>self.logger.log(msg)<EOL><DEDENT>

pkg_supplier : PKG_SUPPL pkg_supplier_values


p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_pkg_file_name(self.document, value)<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_pkg_vers(self.document, value)<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.create_package(self.document, value)<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


self.builder.add_reviewer(self.document, p[<NUM_LIT:2>])<EOL>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.add_review_date(self.document, value)<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.add_review_comment(self.document, value)<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


self.builder.add_annotator(self.document, p[<NUM_LIT:2>])<EOL>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.add_annotation_date(self.document, value)<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.add_annotation_comment(self.document, value)<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>

annotation_comment : ANNOTATION_COMMENT TEXT


annotation_comment : ANNOTATION_COMMENT error


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.add_annotation_type(self.document, value)<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except SPDXValueError:<EOL><INDENT>self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>'].format(p.lineno(<NUM_LIT:1>))<EOL>self.logger.log(msg)<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>'].format(<EOL>p.lineno(<NUM_LIT:1>))<EOL>self.logger.log(msg)<EOL>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_annotation_spdx_id(self.document, value)<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except OrderError:<EOL><INDENT>self.order_error('<STR_LIT>', '<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>

annotation_spdx_id : ANNOTATION_SPDX_ID LINE


annotation_spdx_id : ANNOTATION_SPDX_ID error


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_lics_list_ver(self.document, value)<EOL><DEDENT>except SPDXValueError:<EOL><INDENT>self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>'].format(<EOL>p[<NUM_LIT:2>], p.lineno(<NUM_LIT:2>))<EOL>self.logger.log(msg)<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>'].format(p.lineno(<NUM_LIT:1>))<EOL>self.logger.log(msg)<EOL>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_doc_comment(self.document, value)<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_doc_namespace(self.document, value)<EOL><DEDENT>except SPDXValueError:<EOL><INDENT>self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>'].format(p[<NUM_LIT:2>], p.lineno(<NUM_LIT:2>))<EOL>self.logger.log(msg)<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_doc_data_lics(self.document, value)<EOL><DEDENT>except SPDXValueError:<EOL><INDENT>self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>'].format(p[<NUM_LIT:2>], p.lineno(<NUM_LIT:2>))<EOL>self.logger.log(msg)<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_doc_name(self.document, value)<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>doc_ref_id = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL>doc_uri = p[<NUM_LIT:3>].decode(encoding='<STR_LIT:utf-8>')<EOL>ext_doc_chksum = p[<NUM_LIT:4>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>doc_ref_id = p[<NUM_LIT:2>]<EOL>doc_uri = p[<NUM_LIT:3>]<EOL>ext_doc_chksum = p[<NUM_LIT:4>]<EOL><DEDENT>self.builder.add_ext_doc_refs(self.document, doc_ref_id, doc_uri,<EOL>ext_doc_chksum)<EOL><DEDENT>except SPDXValueError:<EOL><INDENT>self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>'].format(p.lineno(<NUM_LIT:2>))<EOL>self.logger.log(msg)<EOL><DEDENT>

ext_doc_ref : EXT_DOC_REF DOC_REF_ID DOC_URI EXT_DOC_REF_CHKSUM


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_doc_version(self.document, value)<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>except SPDXValueError:<EOL><INDENT>self.error = True<EOL>msg = ERROR_MESSAGES['<STR_LIT>'].format(p[<NUM_LIT:2>], p.lineno(<NUM_LIT:1>))<EOL>self.logger.log(msg)<EOL><DEDENT>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_creation_comment(self.document, value)<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


self.builder.add_creator(self.document, p[<NUM_LIT:2>])<EOL>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:2>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:2>]<EOL><DEDENT>self.builder.set_created_date(self.document, value)<EOL><DEDENT>except CardinalityError:<EOL><INDENT>self.more_than_one_error('<STR_LIT>', p.lineno(<NUM_LIT:1>))<EOL><DEDENT>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:1>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:1>]<EOL><DEDENT>p[<NUM_LIT:0>] = self.builder.build_tool(self.document, value)<EOL><DEDENT>except SPDXValueError:<EOL><INDENT>msg = ERROR_MESSAGES['<STR_LIT>'].format(p[<NUM_LIT:1>], p.lineno(<NUM_LIT:1>))<EOL>self.logger.log(msg)<EOL>self.error = True<EOL>p[<NUM_LIT:0>] = None<EOL><DEDENT>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:1>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:1>]<EOL><DEDENT>p[<NUM_LIT:0>] = self.builder.build_org(self.document, value)<EOL><DEDENT>except SPDXValueError:<EOL><INDENT>msg = ERROR_MESSAGES['<STR_LIT>'].format(p[<NUM_LIT:1>], p.lineno(<NUM_LIT:1>))<EOL>self.logger.log(msg)<EOL>self.error = True<EOL>p[<NUM_LIT:0>] = None<EOL><DEDENT>


try:<EOL><INDENT>if six.PY2:<EOL><INDENT>value = p[<NUM_LIT:1>].decode(encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>value = p[<NUM_LIT:1>]<EOL><DEDENT>p[<NUM_LIT:0>] = self.builder.build_person(self.document, value)<EOL><DEDENT>except SPDXValueError:<EOL><INDENT>msg = ERROR_MESSAGES['<STR_LIT>'].format(p[<NUM_LIT:1>], p.lineno(<NUM_LIT:1>))<EOL>self.logger.log(msg)<EOL>self.error = True<EOL>p[<NUM_LIT:0>] = None<EOL><DEDENT>


<EOL>CHECKSUM_RE = re.compile('<STR_LIT>', re.UNICODE)<EOL>match = CHECKSUM_RE.match(value)<EOL>if match:<EOL><INDENT>return checksum.Algorithm(identifier='<STR_LIT>', value=match.group(<NUM_LIT:1>))<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>

Return an spdx.checksum.Algorithm instance representing the SHA1
checksum or None if does not match CHECKSUM_RE.


REGEX = re.compile('<STR_LIT>', re.UNICODE)<EOL>match = REGEX.match(text)<EOL>if match:<EOL><INDENT>return match.group(<NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>

Return content of a free form text block as a string.


if not self.doc_version_set:<EOL><INDENT>self.doc_version_set = True<EOL>m = self.VERS_STR_REGEX.match(value)<EOL>if m is None:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>doc.version = version.Version(major=int(m.group(<NUM_LIT:1>)),<EOL>minor=int(m.group(<NUM_LIT:2>)))<EOL>return True<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Set the document version.
Raise SPDXValueError if malformed value, CardinalityError
if already defined


if not self.doc_data_lics_set:<EOL><INDENT>self.doc_data_lics_set = True<EOL>if validations.validate_data_lics(lics):<EOL><INDENT>doc.data_license = document.License.from_identifier(lics)<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Sets the document data license.
        Raises value error if malformed value, CardinalityError
        if already defined.


if not self.doc_name_set:<EOL><INDENT>doc.name = name<EOL>self.doc_name_set = True<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Sets the document name.
        Raises CardinalityError if already defined.


def set_doc_spdx_id(self, doc, doc_spdx_id_line):

if not self.doc_spdx_id_set:<EOL><INDENT>if doc_spdx_id_line == '<STR_LIT>':<EOL><INDENT>doc.spdx_id = doc_spdx_id_line<EOL>self.doc_spdx_id_set = True<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Sets the document SPDX Identifier.
        Raises value error if malformed value, CardinalityError
        if already defined.


def set_doc_comment(self, doc, comment):

if not self.doc_comment_set:<EOL><INDENT>self.doc_comment_set = True<EOL>if validations.validate_doc_comment(comment):<EOL><INDENT>doc.comment = str_from_text(comment)<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Sets document comment, Raises CardinalityError if
        comment already set.
        Raises SPDXValueError if comment is not free form text.


def set_doc_namespace(self, doc, namespace):

if not self.doc_namespace_set:<EOL><INDENT>self.doc_namespace_set = True<EOL>if validations.validate_doc_namespace(namespace):<EOL><INDENT>doc.namespace = namespace<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Sets the document namespace.
        Raise SPDXValueError if malformed value, CardinalityError
        if already defined.


<EOL>self.doc_version_set = False<EOL>self.doc_comment_set = False<EOL>self.doc_namespace_set = False<EOL>self.doc_data_lics_set = False<EOL>self.doc_name_set = False<EOL>self.doc_spdx_id_set = False<EOL>

Resets the state to allow building new documents


def set_ext_doc_id(self, doc, ext_doc_id):

doc.add_ext_document_reference(<EOL>ExternalDocumentRef(<EOL>external_document_id=ext_doc_id))<EOL>

Sets the `external_document_id` attribute of the `ExternalDocumentRef`
object.


def set_spdx_doc_uri(self, doc, spdx_doc_uri):

if validations.validate_doc_namespace(spdx_doc_uri):<EOL><INDENT>doc.ext_document_references[-<NUM_LIT:1>].spdx_document_uri = spdx_doc_uri<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT>

Sets the `spdx_document_uri` attribute of the `ExternalDocumentRef`
object.


doc.ext_document_references[-<NUM_LIT:1>].check_sum = checksum_from_sha1(<EOL>chksum)<EOL>

Sets the `check_sum` attribute of the `ExternalDocumentRef`
object.


match = self.tool_re.match(entity)<EOL>if match and validations.validate_tool_name(match.group(self.TOOL_NAME_GROUP)):<EOL><INDENT>name = match.group(self.TOOL_NAME_GROUP)<EOL>return creationinfo.Tool(name)<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT>

Builds a tool object out of a string representation.
        Returns built tool. Raises SPDXValueError if failed to extract
        tool name or name is malformed


match = self.org_re.match(entity)<EOL>if match and validations.validate_org_name(match.group(self.ORG_NAME_GROUP)):<EOL><INDENT>name = match.group(self.ORG_NAME_GROUP).strip()<EOL>email = match.group(self.ORG_EMAIL_GROUP)<EOL>if (email is not None) and (len(email) != <NUM_LIT:0>):<EOL><INDENT>return creationinfo.Organization(name=name, email=email.strip())<EOL><DEDENT>else:<EOL><INDENT>return creationinfo.Organization(name=name, email=None)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT>

Builds an organization object of of a string representation.
        Returns built organization. Raises SPDXValueError if failed to extract
        name.


match = self.person_re.match(entity)<EOL>if match and validations.validate_person_name(match.group(self.PERSON_NAME_GROUP)):<EOL><INDENT>name = match.group(self.PERSON_NAME_GROUP).strip()<EOL>email = match.group(self.PERSON_EMAIL_GROUP)<EOL>if (email is not None) and (len(email) != <NUM_LIT:0>):<EOL><INDENT>return creationinfo.Person(name=name, email=email.strip())<EOL><DEDENT>else:<EOL><INDENT>return creationinfo.Person(name=name, email=None)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT>


if validations.validate_creator(creator):<EOL><INDENT>doc.creation_info.add_creator(creator)<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT>

Adds a creator to the document's creation info.
        Returns true if creator is valid.
        Creator must be built by an EntityBuilder.
        Raises SPDXValueError if not a creator type.


def set_created_date(self, doc, created):

if not self.created_date_set:<EOL><INDENT>self.created_date_set = True<EOL>date = utils.datetime_from_iso_format(created)<EOL>if date is not None:<EOL><INDENT>doc.creation_info.created = date<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Sets created date, Raises CardinalityError if
        created date already set.
        Raises SPDXValueError if created is not a date.


def set_creation_comment(self, doc, comment):

if not self.creation_comment_set:<EOL><INDENT>self.creation_comment_set = True<EOL>if validations.validate_creation_comment(comment):<EOL><INDENT>doc.creation_info.comment = str_from_text(comment)<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Sets creation comment, Raises CardinalityError if
        comment already set.
        Raises SPDXValueError if not free form text.


def set_lics_list_ver(self, doc, value):

if not self.lics_list_ver_set:<EOL><INDENT>self.lics_list_ver_set = True<EOL>vers = version.Version.from_str(value)<EOL>if vers is not None:<EOL><INDENT>doc.creation_info.license_list_version = vers<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Sets the license list version, Raises CardinalityError if
        already set, SPDXValueError if incorrect value.


<EOL>self.created_date_set = False<EOL>self.creation_comment_set = False<EOL>self.lics_list_ver_set = False<EOL>

Resets builder state to allow building new creation info.


<EOL>self.review_date_set = False<EOL>self.review_comment_set = False<EOL>

Resets the builder's state to allow building new reviews.


Adds a reviewer to the SPDX Document.
        Reviwer is an entity created by an EntityBuilder.
        Raises SPDXValueError if not a valid reviewer type.


def add_review_date(self, doc, reviewed):

if len(doc.reviews) != <NUM_LIT:0>:<EOL><INDENT>if not self.review_date_set:<EOL><INDENT>self.review_date_set = True<EOL>date = utils.datetime_from_iso_format(reviewed)<EOL>if date is not None:<EOL><INDENT>doc.reviews[-<NUM_LIT:1>].review_date = date<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise OrderError('<STR_LIT>')<EOL><DEDENT>

Sets the review date. Raises CardinalityError if
        already set. OrderError if no reviewer defined before.
        Raises SPDXValueError if invalid reviewed value.


def add_review_comment(self, doc, comment):

if len(doc.reviews) != <NUM_LIT:0>:<EOL><INDENT>if not self.review_comment_set:<EOL><INDENT>self.review_comment_set = True<EOL>if validations.validate_review_comment(comment):<EOL><INDENT>doc.reviews[-<NUM_LIT:1>].comment = str_from_text(comment)<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise OrderError('<STR_LIT>')<EOL><DEDENT>

Sets the review comment. Raises CardinalityError if
        already set. OrderError if no reviewer defined before.
        Raises SPDXValueError if comment is not free form text.


<EOL>self.annotation_date_set = False<EOL>self.annotation_comment_set = False<EOL>self.annotation_type_set = False<EOL>self.annotation_spdx_id_set = False<EOL>

Resets the builder's state to allow building new annotations.


def add_annotator(self, doc, annotator):

Adds an annotator to the SPDX Document.
        Annotator is an entity created by an EntityBuilder.
        Raises SPDXValueError if not a valid annotator type.


def add_annotation_date(self, doc, annotation_date):

if len(doc.annotations) != <NUM_LIT:0>:<EOL><INDENT>if not self.annotation_date_set:<EOL><INDENT>self.annotation_date_set = True<EOL>date = utils.datetime_from_iso_format(annotation_date)<EOL>if date is not None:<EOL><INDENT>doc.annotations[-<NUM_LIT:1>].annotation_date = date<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise OrderError('<STR_LIT>')<EOL><DEDENT>

Sets the annotation date. Raises CardinalityError if
        already set. OrderError if no annotator defined before.
        Raises SPDXValueError if invalid value.


def add_annotation_comment(self, doc, comment):

if len(doc.annotations) != <NUM_LIT:0>:<EOL><INDENT>if not self.annotation_comment_set:<EOL><INDENT>self.annotation_comment_set = True<EOL>if validations.validate_annotation_comment(comment):<EOL><INDENT>doc.annotations[-<NUM_LIT:1>].comment = str_from_text(comment)<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise OrderError('<STR_LIT>')<EOL><DEDENT>

Sets the annotation comment. Raises CardinalityError if
        already set. OrderError if no annotator defined before.
        Raises SPDXValueError if comment is not free form text.


def add_annotation_type(self, doc, annotation_type):

if len(doc.annotations) != <NUM_LIT:0>:<EOL><INDENT>if not self.annotation_type_set:<EOL><INDENT>self.annotation_type_set = True<EOL>if validations.validate_annotation_type(annotation_type):<EOL><INDENT>doc.annotations[-<NUM_LIT:1>].annotation_type = annotation_type<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise OrderError('<STR_LIT>')<EOL><DEDENT>

Sets the annotation type. Raises CardinalityError if
        already set. OrderError if no annotator defined before.
        Raises SPDXValueError if invalid value.


def set_annotation_spdx_id(self, doc, spdx_id):

if len(doc.annotations) != <NUM_LIT:0>:<EOL><INDENT>if not self.annotation_spdx_id_set:<EOL><INDENT>self.annotation_spdx_id_set = True<EOL>doc.annotations[-<NUM_LIT:1>].spdx_id = spdx_id<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise OrderError('<STR_LIT>')<EOL><DEDENT>

Sets the annotation SPDX Identifier.
        Raises CardinalityError if already set. OrderError if no annotator
        defined before.


<EOL>self.package_set = False<EOL>self.package_vers_set = False<EOL>self.package_file_name_set = False<EOL>self.package_supplier_set = False<EOL>self.package_originator_set = False<EOL>self.package_down_location_set = False<EOL>self.package_home_set = False<EOL>self.package_verif_set = False<EOL>self.package_chk_sum_set = False<EOL>self.package_source_info_set = False<EOL>self.package_conc_lics_set = False<EOL>self.package_license_declared_set = False<EOL>self.package_license_comment_set = False<EOL>self.package_cr_text_set = False<EOL>self.package_summary_set = False<EOL>self.package_desc_set = False<EOL>

Resets the builder's state in order to build new packages.


if not self.package_set:<EOL><INDENT>self.package_set = True<EOL>doc.package = package.Package(name=name)<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Creates a package for the SPDX Document.
        name - any string.
        Raises CardinalityError if package already defined.


self.assert_package_exists()<EOL>if not self.package_vers_set:<EOL><INDENT>self.package_vers_set = True<EOL>doc.package.version = version<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Sets package version, if not already set.
        version - Any string.
        Raises CardinalityError if already has a version.
        Raises OrderError if no package previously defined.


self.assert_package_exists()<EOL>if not self.package_file_name_set:<EOL><INDENT>self.package_file_name_set = True<EOL>doc.package.file_name = name<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Sets the package file name, if not already set.
        name - Any string.
        Raises CardinalityError if already has a file_name.
        Raises OrderError if no pacakge previously defined.


def set_pkg_supplier(self, doc, entity):

self.assert_package_exists()<EOL>if not self.package_supplier_set:<EOL><INDENT>self.package_supplier_set = True<EOL>if validations.validate_pkg_supplier(entity):<EOL><INDENT>doc.package.supplier = entity<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Sets the package supplier, if not already set.
        entity - Organization, Person or NoAssert.
        Raises CardinalityError if already has a supplier.
        Raises OrderError if no package previously defined.


def set_pkg_originator(self, doc, entity):

self.assert_package_exists()<EOL>if not self.package_originator_set:<EOL><INDENT>self.package_originator_set = True<EOL>if validations.validate_pkg_originator(entity):<EOL><INDENT>doc.package.originator = entity<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Sets the package originator, if not already set.
        entity - Organization, Person or NoAssert.
        Raises CardinalityError if already has an originator.
        Raises OrderError if no package previously defined.


def set_pkg_down_location(self, doc, location):

self.assert_package_exists()<EOL>if not self.package_down_location_set:<EOL><INDENT>self.package_down_location_set = True<EOL>doc.package.download_location = location<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Sets the package download location, if not already set.
        location - A string
        Raises CardinalityError if already defined.
        Raises OrderError if no package previously defined.


self.assert_package_exists()<EOL>if not self.package_home_set:<EOL><INDENT>self.package_home_set = True<EOL>if validations.validate_pkg_homepage(location):<EOL><INDENT>doc.package.homepage = location<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Sets the package homepage location if not already set.
        location - A string or None or NoAssert.
        Raises CardinalityError if already defined.
        Raises OrderError if no package previously defined.
        Raises SPDXValueError if location has incorrect value.


def set_pkg_verif_code(self, doc, code):

self.assert_package_exists()<EOL>if not self.package_verif_set:<EOL><INDENT>self.package_verif_set = True<EOL>match = self.VERIF_CODE_REGEX.match(code)<EOL>if match:<EOL><INDENT>doc.package.verif_code = match.group(self.VERIF_CODE_CODE_GRP)<EOL>if match.group(self.VERIF_CODE_EXC_FILES_GRP) is not None:<EOL><INDENT>doc.package.verif_exc_files = match.group(self.VERIF_CODE_EXC_FILES_GRP).split('<STR_LIT:U+002C>')<EOL><DEDENT>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Sets the package verification code, if not already set.
        code - A string.
        Raises CardinalityError if already defined.
        Raises OrderError if no package previously defined.
        Raises Value error if doesn't match verifcode form


def set_pkg_chk_sum(self, doc, chk_sum):

self.assert_package_exists()<EOL>if not self.package_chk_sum_set:<EOL><INDENT>self.package_chk_sum_set = True<EOL>doc.package.check_sum = checksum_from_sha1(chk_sum)<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Sets the package check sum, if not already set.
        chk_sum - A string
        Raises CardinalityError if already defined.
        Raises OrderError if no package previously defined.


def set_pkg_source_info(self, doc, text):

self.assert_package_exists()<EOL>if not self.package_source_info_set:<EOL><INDENT>self.package_source_info_set = True<EOL>if validations.validate_pkg_src_info(text):<EOL><INDENT>doc.package.source_info = str_from_text(text)<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Sets the package's source information, if not already set.
        text - Free form text.
        Raises CardinalityError if already defined.
        Raises OrderError if no package previously defined.
        SPDXValueError if text is not free form text.


def set_pkg_licenses_concluded(self, doc, licenses):

self.assert_package_exists()<EOL>if not self.package_conc_lics_set:<EOL><INDENT>self.package_conc_lics_set = True<EOL>if validations.validate_lics_conc(licenses):<EOL><INDENT>doc.package.conc_lics = licenses<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Sets the package's concluded licenses.
        licenses - License info.
        Raises CardinalityError if already defined.
        Raises OrderError if no package previously defined.
        Raises SPDXValueError if data malformed.


def set_pkg_license_from_file(self, doc, lic):

Adds a license from a file to the package.
        Raises SPDXValueError if data malformed.
        Raises OrderError if no package previously defined.


def set_pkg_license_declared(self, doc, lic):

self.assert_package_exists()<EOL>if not self.package_license_declared_set:<EOL><INDENT>self.package_license_declared_set = True<EOL>if validations.validate_lics_conc(lic):<EOL><INDENT>doc.package.license_declared = lic<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Sets the package's declared license.
        Raises SPDXValueError if data malformed.
        Raises OrderError if no package previously defined.
        Raises CardinalityError if already set.


def set_pkg_license_comment(self, doc, text):

self.assert_package_exists()<EOL>if not self.package_license_comment_set:<EOL><INDENT>self.package_license_comment_set = True<EOL>if validations.validate_pkg_lics_comment(text):<EOL><INDENT>doc.package.license_comment = str_from_text(text)<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Sets the package's license comment.
        Raises OrderError if no package previously defined.
        Raises CardinalityError if already set.
        Raises SPDXValueError if text is not free form text.


self.assert_package_exists()<EOL>if not self.package_cr_text_set:<EOL><INDENT>self.package_cr_text_set = True<EOL>if validations.validate_pkg_cr_text(text):<EOL><INDENT>if isinstance(text, string_types):<EOL><INDENT>doc.package.cr_text = str_from_text(text)<EOL><DEDENT>else:<EOL><INDENT>doc.package.cr_text = text  <EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Sets the package's copyright text.
        Raises OrderError if no package previously defined.
        Raises CardinalityError if already set.
        Raises value error if text is not one of [None, NOASSERT, TEXT].


self.assert_package_exists()<EOL>if not self.package_summary_set:<EOL><INDENT>self.package_summary_set = True<EOL>if validations.validate_pkg_summary(text):<EOL><INDENT>doc.package.summary = str_from_text(text)<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Set's the package summary.
        Raises SPDXValueError if text is not free form text.
        Raises CardinalityError if summary already set.
        Raises OrderError if no package previously defined.


self.assert_package_exists()<EOL>if not self.package_desc_set:<EOL><INDENT>self.package_desc_set = True<EOL>if validations.validate_pkg_desc(text):<EOL><INDENT>doc.package.description = str_from_text(text)<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT>

Set's the package's description.
        Raises SPDXValueError if text is not free form text.
        Raises CardinalityError if description already set.
        Raises OrderError if no package previously defined.


if self.has_package(doc):<EOL><INDENT>doc.package.files.append(file.File(name))<EOL>self.reset_file_stat()<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise OrderError('<STR_LIT>')<EOL><DEDENT>

Raises OrderError if no package defined.


def set_file_spdx_id(self, doc, spdx_id):

if self.has_package(doc) and self.has_file(doc):<EOL><INDENT>if not self.file_spdx_id_set:<EOL><INDENT>self.file_spdx_id_set = True<EOL>if validations.validate_file_spdx_id(spdx_id):<EOL><INDENT>self.file(doc).spdx_id = spdx_id<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise OrderError('<STR_LIT>')<EOL><DEDENT>

Sets the file SPDX Identifier.
Raises OrderError if no package or no file defined.
Raises SPDXValueError if malformed value.
Raises CardinalityError if more than one spdx_id set.


if self.has_package(doc) and self.has_file(doc):<EOL><INDENT>if not self.file_comment_set:<EOL><INDENT>self.file_comment_set = True<EOL>if validations.validate_file_comment(text):<EOL><INDENT>self.file(doc).comment = str_from_text(text)<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise OrderError('<STR_LIT>')<EOL><DEDENT>

Raises OrderError if no package or no file defined.
Raises CardinalityError if more than one comment set.
Raises SPDXValueError if text is not free form text.


def set_file_type(self, doc, type_value):

type_dict = {<EOL>'<STR_LIT>': file.FileType.SOURCE,<EOL>'<STR_LIT>': file.FileType.BINARY,<EOL>'<STR_LIT>': file.FileType.ARCHIVE,<EOL>'<STR_LIT>': file.FileType.OTHER<EOL>}<EOL>if self.has_package(doc) and self.has_file(doc):<EOL><INDENT>if not self.file_type_set:<EOL><INDENT>self.file_type_set = True<EOL>if type_value in type_dict.keys():<EOL><INDENT>self.file(doc).type = type_dict[type_value]<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise OrderError('<STR_LIT>')<EOL><DEDENT>

Raises OrderError if no package or file defined.
Raises CardinalityError if more than one type set.
Raises SPDXValueError if type is unknown.


if self.has_package(doc) and self.has_file(doc):<EOL><INDENT>if not self.file_chksum_set:<EOL><INDENT>self.file_chksum_set = True<EOL>self.file(doc).chk_sum = checksum_from_sha1(chksum)<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise OrderError('<STR_LIT>')<EOL><DEDENT>

Raises OrderError if no package or file defined.
Raises CardinalityError if more than one chksum set.


def set_concluded_license(self, doc, lic):

if self.has_package(doc) and self.has_file(doc):<EOL><INDENT>if not self.file_conc_lics_set:<EOL><INDENT>self.file_conc_lics_set = True<EOL>if validations.validate_lics_conc(lic):<EOL><INDENT>self.file(doc).conc_lics = lic<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise OrderError('<STR_LIT>')<EOL><DEDENT>

Raises OrderError if no package or file defined.
Raises CardinalityError if already set.
Raises SPDXValueError if malformed.


def set_file_license_in_file(self, doc, lic):

if self.has_package(doc) and self.has_file(doc):<EOL><INDENT>if validations.validate_file_lics_in_file(lic):<EOL><INDENT>self.file(doc).add_lics(lic)<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise OrderError('<STR_LIT>')<EOL><DEDENT>

Raises OrderError if no package or file defined.
Raises SPDXValueError if malformed value.


def set_file_license_comment(self, doc, text):

if self.has_package(doc) and self.has_file(doc):<EOL><INDENT>if not self.file_license_comment_set:<EOL><INDENT>self.file_license_comment_set = True<EOL>if validations.validate_file_lics_comment(text):<EOL><INDENT>self.file(doc).license_comment = str_from_text(text)<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise OrderError('<STR_LIT>')<EOL><DEDENT>

Raises OrderError if no package or file defined.
Raises SPDXValueError if text is not free form text.
Raises CardinalityError if more than one per file.


def set_file_copyright(self, doc, text):

if self.has_package(doc) and self.has_file(doc):<EOL><INDENT>if not self.file_copytext_set:<EOL><INDENT>self.file_copytext_set = True<EOL>if validations.validate_file_cpyright(text):<EOL><INDENT>if isinstance(text, string_types):<EOL><INDENT>self.file(doc).copyright = str_from_text(text)<EOL><DEDENT>else:<EOL><INDENT>self.file(doc).copyright = text  <EOL><DEDENT>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise OrderError('<STR_LIT>')<EOL><DEDENT>

Raises OrderError if no package or file defined.
        Raises SPDXValueError if not free form text or NONE or NO_ASSERT.
        Raises CardinalityError if more than one.


if self.has_package(doc) and self.has_file(doc):<EOL><INDENT>if not self.file_notice_set:<EOL><INDENT>self.file_notice_set = True<EOL>if validations.validate_file_notice(text):<EOL><INDENT>self.file(doc).notice = str_from_text(text)<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise OrderError('<STR_LIT>')<EOL><DEDENT>

Raises OrderError if no package or file defined.
        Raises SPDXValueError if not free form text.
        Raises CardinalityError if more than one.


def add_file_contribution(self, doc, value):

if self.has_package(doc) and self.has_file(doc):<EOL><INDENT>self.file(doc).add_contrib(value)<EOL><DEDENT>else:<EOL><INDENT>raise OrderError('<STR_LIT>')<EOL><DEDENT>

Raises OrderError if no package or file defined.


if self.has_package(doc) and self.has_file(doc):<EOL><INDENT>self.file(doc).add_depend(value)<EOL><DEDENT>else:<EOL><INDENT>raise OrderError('<STR_LIT>')<EOL><DEDENT>


def set_file_atrificat_of_project(self, doc, symbol, value):

if self.has_package(doc) and self.has_file(doc):<EOL><INDENT>self.file(doc).add_artifact(symbol, value)<EOL><DEDENT>else:<EOL><INDENT>raise OrderError('<STR_LIT>')<EOL><DEDENT>

Sets a file name, uri or home artificat.
        Raises OrderError if no package or file defined.


return doc.package.files[-<NUM_LIT:1>]<EOL>

Returns the last file in the document's package's file list.


return len(doc.package.files) != <NUM_LIT:0><EOL>

Returns true if the document's package has at least one file.
        Does not test if the document has a package.


return doc.package is not None<EOL>

Returns true if the document has a package.


<EOL>self.file_spdx_id_set = False<EOL>self.file_comment_set = False<EOL>self.file_type_set = False<EOL>self.file_chksum_set = False<EOL>self.file_conc_lics_set = False<EOL>self.file_license_comment_set = False<EOL>self.file_notice_set = False<EOL>self.file_copytext_set = False<EOL>

Resets the builder's state to enable building new files.


return doc.extracted_licenses[-<NUM_LIT:1>]<EOL>

Retrieves last license in extracted license list


Adds a new extracted license to the document.
        Raises SPDXValueError if data format is incorrect.


if self.has_extr_lic(doc):<EOL><INDENT>if not self.extr_text_set:<EOL><INDENT>self.extr_text_set = True<EOL>if validations.validate_is_free_form_text(text):<EOL><INDENT>self.extr_lic(doc).text = str_from_text(text)<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise OrderError('<STR_LIT>')<EOL><DEDENT>

Sets license extracted text.
        Raises SPDXValueError if text is not free form text.
        Raises OrderError if no license ID defined.


if self.has_extr_lic(doc):<EOL><INDENT>if not self.extr_lic_name_set:<EOL><INDENT>self.extr_lic_name_set = True<EOL>if validations.validate_extr_lic_name(name):<EOL><INDENT>self.extr_lic(doc).full_name = name<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise OrderError('<STR_LIT>')<EOL><DEDENT>

Sets license name.
        Raises SPDXValueError if name is not str or utils.NoAssert
        Raises OrderError if no license id defined.


def set_lic_comment(self, doc, comment):

if self.has_extr_lic(doc):<EOL><INDENT>if not self.extr_lic_comment_set:<EOL><INDENT>self.extr_lic_comment_set = True<EOL>if validations.validate_is_free_form_text(comment):<EOL><INDENT>self.extr_lic(doc).comment = str_from_text(comment)<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise SPDXValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise CardinalityError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise OrderError('<STR_LIT>')<EOL><DEDENT>

Sets license comment.
        Raises SPDXValueError if comment is not free form text.
        Raises OrderError if no license ID defined.


if self.has_extr_lic(doc):<EOL><INDENT>self.extr_lic(doc).add_xref(ref)<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>raise OrderError('<STR_LIT>')<EOL><DEDENT>

Adds a license cross reference.
        Raises OrderError if no License ID defined.


<EOL>self.reset_creation_info()<EOL>self.reset_document()<EOL>self.reset_package()<EOL>self.reset_file_stat()<EOL>self.reset_reviews()<EOL>self.reset_annotations()<EOL>self.reset_extr_lics()<EOL>

Resets builder's state for building new documents.
        Must be called between usage with different documents.


t.lexer.text_start = t.lexer.lexpos - len('<STR_LIT>')<EOL>t.lexer.begin('<STR_LIT:text>')<EOL>


t.type = '<STR_LIT>'<EOL>t.value = t.lexer.lexdata[<EOL>t.lexer.text_start:t.lexer.lexpos]<EOL>t.lexer.lineno += t.value.count('<STR_LIT:\n>')<EOL>t.value = t.value.strip()<EOL>t.lexer.begin('<STR_LIT>')<EOL>return t<EOL>


pass<EOL>


t.value = t.value[<NUM_LIT:1>:].strip()<EOL>return t<EOL>


t.value = t.value.strip()<EOL>return t<EOL>


t.type = self.reserved.get(t.value, '<STR_LIT>')<EOL>t.value = t.value.strip()<EOL>return t<EOL>


t.value = t.value[<NUM_LIT:1>:].strip()<EOL>if t.value in self.reserved.keys():<EOL><INDENT>t.type = self.reserved[t.value]<EOL><DEDENT>else:<EOL><INDENT>t.type = '<STR_LIT>'<EOL><DEDENT>return t<EOL>


t.lexer.lineno += len(t.value)<EOL>


return "<STR_LIT>".format(<EOL>date.year, date.month, date.day, date.hour,<EOL>date.minute, date.second)<EOL>

Return an ISO-8601 representation of a datetime object.


Return a datetime object from an iso 8601 representation.
Return None if string is non conforming.


return t<EOL>


self.lexer.input(data)<EOL>


return self.lexer.token()<EOL>

Get the next token or None if exhausted input.


self.lexer = lex.lex(module=self, **kwargs)<EOL>

Build lexer, must be called before input or token methods.
        Only need to build once.


p[<NUM_LIT:0>] = document.LicenseDisjunction(p[<NUM_LIT:1>], p[<NUM_LIT:3>])<EOL>

disjunction : disjunction OR conjunction


p[<NUM_LIT:0>] = p[<NUM_LIT:1>]<EOL>


p[<NUM_LIT:0>] = document.LicenseConjunction(p[<NUM_LIT:1>], p[<NUM_LIT:3>])<EOL>

conjunction : conjunction AND license_atom


p[<NUM_LIT:0>] = document.License.from_identifier(p[<NUM_LIT:1>])<EOL>


p[<NUM_LIT:0>] = p[<NUM_LIT:2>]<EOL>


self.yacc = yacc.yacc(module=self, **kwargs)<EOL>


try:<EOL><INDENT>return self.yacc.parse(data, lexer=self.lex)<EOL><DEDENT>except:<EOL><INDENT>return None<EOL><DEDENT>

Parses a license list and returns a License or None if it failed.


messages = self.validate_annotator(messages)<EOL>messages = self.validate_annotation_date(messages)<EOL>messages = self.validate_annotation_type(messages)<EOL>messages = self.validate_spdx_id(messages)<EOL>return messages<EOL>

Returns True if all the fields are valid.
        Appends any error messages to messages parameter.


def decorate(newfunc):<EOL><INDENT>if hasattr(func, '<STR_LIT>'):<EOL><INDENT>name = func.compat_func_name<EOL><DEDENT>else:<EOL><INDENT>name = func.__name__<EOL><DEDENT>newfunc.__dict__ = func.__dict__<EOL>newfunc.__doc__ = func.__doc__<EOL>newfunc.__module__ = func.__module__<EOL>if not hasattr(newfunc, '<STR_LIT>'):<EOL><INDENT>newfunc.compat_co_firstlineno = six.get_function_code(func).co_firstlineno<EOL><DEDENT>try:<EOL><INDENT>newfunc.__name__ = name<EOL><DEDENT>except TypeError:<EOL><INDENT>newfunc.compat_func_name = name<EOL><DEDENT>return newfunc<EOL><DEDENT>return decorate<EOL>

Wraps a test decorator so as to properly replicate metadata
of the decorated function, including nose's additional stuff
(namely, setup and teardown).


valid = '<STR_LIT>'.join([e.__name__ for e in exceptions])<EOL>def decorate(func):<EOL><INDENT>name = func.__name__<EOL>def newfunc(*arg, **kw):<EOL><INDENT>try:<EOL><INDENT>func(*arg, **kw)<EOL><DEDENT>except exceptions:<EOL><INDENT>pass<EOL><DEDENT>except:<EOL><INDENT>raise<EOL><DEDENT>else:<EOL><INDENT>message = "<STR_LIT>" % (name, valid)<EOL>raise AssertionError(message)<EOL><DEDENT><DEDENT>newfunc = make_decorator(func)(newfunc)<EOL>return newfunc<EOL><DEDENT>return decorate<EOL>

Test must raise one of expected exceptions to pass.

    Example use::

      @raises(TypeError, ValueError)
      def test_raises_type_error():
          raise TypeError("This test passes")

      @raises(Exception)
      def test_that_fails_by_passing():
          pass

    If you want to test many assertions about exceptions in a single test,
    you may want to use `assert_raises` instead.


if extension and not extension.startswith('<STR_LIT:.>'):<EOL><INDENT>extension = '<STR_LIT:.>' + extension<EOL><DEDENT>file_name = '<STR_LIT>' + extension<EOL>temp_dir = tempfile.mkdtemp()<EOL>return os.path.join(temp_dir, file_name)<EOL>

Return a unique new temporary file location to a non-existing
temporary file that can safely be created without a risk of name
collision.


with open(file_name, mode='<STR_LIT:rb>') as infile:<EOL><INDENT>rdfparser = RDFParser(RDFBuilder(), StandardLogger())<EOL>return rdfparser.parse(infile)<EOL><DEDENT>


with open(file_name, mode='<STR_LIT:r>') as infile:<EOL><INDENT>tvparser = TVParser(TVBuilder(), StandardLogger())<EOL>tvparser.build()<EOL>return tvparser.parse(infile.read())<EOL><DEDENT>


path = path.replace(posixpath.sep, os.path.sep)<EOL>path = path.replace(ntpath.sep, os.path.sep)<EOL>path = path.rstrip(os.path.sep)<EOL>return path<EOL>

Normalize a path to use the native OS path separator.


replace_nid = re.compile('<STR_LIT>').sub<EOL>rdf_text = replace_nid('<STR_LIT>', rdf_text)<EOL>replace_creation = re.compile('<STR_LIT>', re.DOTALL).sub<EOL>rdf_text = replace_creation('<STR_LIT>', rdf_text)<EOL>replace_pcc = re.compile('<STR_LIT>', re.DOTALL).sub<EOL>rdf_text = replace_pcc('<STR_LIT>', rdf_text)<EOL>return rdf_text<EOL>

Return rdf_text stripped from variable parts such as rdf nodeids


content = codecs.open(location, encoding='<STR_LIT:utf-8>').read()<EOL>content = strip_variable_text(content)<EOL>data = xmltodict.parse(content, dict_constructor=dict)<EOL>return sort_nested(data)<EOL>

Return plain Python nested data for the SPDX RDF file at location
suitable for comparison. The file content is cleaned from variable
parts such as dates, generated UUIDs and versions

NOTE: we use plain dicts to avoid ordering issues in XML. the SPDX
tool and lxml do not seem to return a consistent ordering that is
needed for tests.


if isinstance(data, dict):<EOL><INDENT>new_data = {}<EOL>for k, v in data.items():<EOL><INDENT>if isinstance(v, list):<EOL><INDENT>v = sorted(v)<EOL><DEDENT>if isinstance(v, dict):<EOL><INDENT>v = sort_nested(v)<EOL><DEDENT>new_data[k] = v<EOL><DEDENT>return new_data<EOL><DEDENT>elif isinstance(data, list):<EOL><INDENT>new_data = []<EOL>for v in sorted(data):<EOL><INDENT>if isinstance(v, list):<EOL><INDENT>v = sort_nested(v)<EOL><DEDENT>if isinstance(v, dict):<EOL><INDENT>v = sort_nested(v)<EOL><DEDENT>new_data.append(v)<EOL><DEDENT>return new_data<EOL><DEDENT>

Return a new dict with any nested list sorted recursively.


def check_rdf_scan(expected_file, result_file, regen=False):

import json<EOL>result = load_and_clean_rdf(result_file)<EOL>if regen:<EOL><INDENT>expected = result<EOL>with codecs.open(expected_file, '<STR_LIT:w>', encoding='<STR_LIT:utf-8>') as o:<EOL><INDENT>json.dump(expected, o, indent=<NUM_LIT:2>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>with codecs.open(expected_file, '<STR_LIT:r>', encoding='<STR_LIT:utf-8>') as i:<EOL><INDENT>expected = sort_nested(json.load(i))<EOL><DEDENT><DEDENT>assert expected == result<EOL>

Check that expected and result_file are equal.
Both are paths to SPDX RDF XML files, UTF-8 encoded.


content = codecs.open(location, encoding='<STR_LIT:utf-8>').read()<EOL>content = [l for l in content.splitlines(False)<EOL>if l and l.strip() and not l.startswith(('<STR_LIT>', '<STR_LIT>',))]<EOL>return '<STR_LIT:\n>'.join(content)<EOL>

Return a mapping for the SPDX TV file at location suitable for
comparison. The file content is cleaned from variable parts such as
dates, generated UUIDs and versions


def check_tv_scan(expected_file, result_file, regen=False):

result = load_and_clean_tv(result_file)<EOL>if regen:<EOL><INDENT>with codecs.open(expected_file, '<STR_LIT:w>', encoding='<STR_LIT:utf-8>') as o:<EOL><INDENT>o.write(result)<EOL><DEDENT><DEDENT>expected = load_and_clean_tv(expected_file)<EOL>assert expected == result<EOL>

Check that expected and result_file are equal.
Both are paths to plain SPDX tv text files, UTF-8 encoded.


self._default_args = default_args<EOL>

:param default_args: default arguments
:type default_args: string or list of string


if args is None:<EOL><INDENT>args = self._default_args<EOL><DEDENT>if isinstance(args, six.string_types):<EOL><INDENT>args = shlex.split(args)<EOL><DEDENT>return args<EOL>

:param args: arguments
:type args: None or string or list of string
:return: formatted arguments if specified else ``self.default_args``
:rtype: list of string


return self._default_args<EOL>

:return: default arguments given on ``init``.
:rtype: string or list of string


self._ref = weakref.ref(vim)<EOL>self._list = self.parse(vim.command('<STR_LIT>'))<EOL>

:param vim: ``Vim`` object which owns this object.
:type vim: Vim


self._list.insert(index, value)<EOL>self._sync()<EOL>

Insert object before index.

:param int index: index to insert in
:param string value: path to insert


values = '<STR_LIT:U+002C>'.join(list)<EOL>return '<STR_LIT>' + values<EOL>

Format list to runtime path representation.

:param list: list of paths to format
:type list: list of string
:return: *Vim* style runtime path string representation
:rtype: string


var, eq, values = string.strip().partition('<STR_LIT:=>')<EOL>assert var == '<STR_LIT>'<EOL>assert eq == '<STR_LIT:=>'<EOL>return values.split('<STR_LIT:U+002C>')<EOL>

Parse runtime path representation to list.

:param string string: runtime path string
:return: list of runtime paths
:rtype: list of string


return Vim(**kwargs)<EOL>

A factory function to open new ``Vim`` object.
``with`` statement can be used for this.


parser = arguments.Parser(self.default_args)<EOL>args = parser.parse(args)<EOL>self._process = process.Process(executable, args, env)<EOL>self._encoding = encoding<EOL>self._screen = pyte.Screen(*size)<EOL>self._stream = pyte.Stream()<EOL>self._stream.attach(self._screen)<EOL>self._timeout = timeout<EOL>self._tempfile = tempfile.NamedTemporaryFile(mode='<STR_LIT:r>')<EOL>self._runtimepath = None<EOL>self.wait()<EOL>

:param string executable: command name to execute *Vim*
:param args: arguments to execute *Vim*
:type args: None or string or list of string
:param env: environment variables to execute *Vim*
:type env: None or dict of (string, string)
:param string encoding: internal encoding of *Vim*
:param size: (lines, columns) of a screen connected to *Vim*
:type size: (int, int)
:param float timeout: seconds to wait I/O


self._tempfile.close()<EOL>self._process.terminate()<EOL>if self._process.is_alive():<EOL><INDENT>self._process.kill()<EOL><DEDENT>


return self._process.is_alive()<EOL>

Check if the background *Vim* process is alive.

:return: True if the process is alive, else False
:rtype: boolean


return '<STR_LIT:\n>'.join(self.display_lines())<EOL>

Shows the terminal screen connecting to *Vim*.

Example:

>>> import headlessvim
>>> with headlessvim.open(size=(64, 16)) as vim: # doctest: +SKIP
...     print(vim.display())
...
~
~                          VIM - Vi IMproved
~
~                           version 7.4.52
~                      by Bram Moolenaar et al.
~
~             Vim is open source and freely distributable
~
~                      Sponsor Vim development!
~           type  :help sponsor<Enter>    for information
~
~           type  :q<Enter>               to exit
~           type  :help<Enter>  or  <F1>  for on-line help
~           type  :help version7<Enter>   for version info
~
~

:return: screen as a text
:rtype: string


return self._screen.display<EOL>

Shows the terminal screen splitted by newlines.

Almost equals to ``self.display().splitlines()``

:return: screen as a list of strings
:rtype: list of string


self._process.stdin.write(bytearray(keys, self._encoding))<EOL>self._process.stdin.flush()<EOL>if wait:<EOL><INDENT>self.wait()<EOL><DEDENT>

Send a raw key sequence to *Vim*.

.. note:: *Vim* style key sequence notation (like ``<Esc>``)
          is not recognized.
          Use escaped characters (like ``'\033'``) instead.

Example:

>>> import headlessvim
>>> with headlessvim.open() as vim:
...     vim.send_keys('ispam\033')
...     str(vim.display_lines()[0].strip())
...
'spam'

:param strgin keys: key sequence to send
:param boolean wait: whether if wait a response


if timeout is None:<EOL><INDENT>timeout = self._timeout<EOL><DEDENT>while self._process.check_readable(timeout):<EOL><INDENT>self._flush()<EOL><DEDENT>

Wait for response until timeout.
If timeout is specified to None, ``self.timeout`` is used.

:param float timeout: seconds to wait I/O


def install_plugin(self, dir, entry_script=None):

self.runtimepath.append(dir)<EOL>if entry_script is not None:<EOL><INDENT>self.command('<STR_LIT>'.format(entry_script), False)<EOL><DEDENT>

Install *Vim* plugin.

:param string dir: the root directory contains *Vim* script
:param string entry_script: path to the initializing script


def command(self, command, capture=True):

if capture:<EOL><INDENT>self.command('<STR_LIT>'.format(self._tempfile.name), False)<EOL><DEDENT>self.set_mode('<STR_LIT>')<EOL>self.send_keys('<STR_LIT>'.format(command))<EOL>if capture:<EOL><INDENT>self.command('<STR_LIT>', False)<EOL>return self._tempfile.read().strip('<STR_LIT:\n>')<EOL><DEDENT>

Execute command on *Vim*.
.. warning:: Do not use ``redir`` command if ``capture`` is ``True``.
It's already enabled for internal use.

If ``capture`` argument is set ``False``,
the command execution becomes slightly faster.

Example:

>>> import headlessvim
>>> with headlessvim.open() as vim:
...     vim.command('echo 0')
...
'0'
>>> with headlessvim.open() as vim:
...     vim.command('let g:spam = "ham"', False)
...     vim.echo('g:spam')
...
'ham'

:param string command: a command to execute
:param boolean capture: ``True`` if command's output needs to be
                        captured, else ``False``
:return: the output of the given command
:rtype: string


return self.command('<STR_LIT>'.format(expr))<EOL>

Execute ``:echo`` command on *Vim*.

.. note:: The given string is passed to *Vim* as it is.
          Make sure to quote bare words.

Example:

>>> import headlessvim
>>> with headlessvim.open() as vim:
...     vim.echo('0')
...
'0'
>>> with headlessvim.open() as vim:
...     vim.echo('"spam"')
...
'spam'

:param string expr: a expr to ``:echo``
:return: the result of ``:echo`` command
:rtype: string


keys = '<STR_LIT>'<EOL>if mode == '<STR_LIT>':<EOL><INDENT>pass<EOL><DEDENT>elif mode == '<STR_LIT>':<EOL><INDENT>keys += '<STR_LIT:i>'<EOL><DEDENT>elif mode == '<STR_LIT>':<EOL><INDENT>keys += '<STR_LIT::>'<EOL><DEDENT>elif mode == '<STR_LIT>':<EOL><INDENT>keys += '<STR_LIT:v>'<EOL><DEDENT>elif mode == '<STR_LIT>':<EOL><INDENT>keys += '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(mode))<EOL><DEDENT>self.send_keys(keys)<EOL>

Set *Vim* mode to ``mode``.
Supported modes:

* ``normal``
* ``insert``
* ``command``
* ``visual``
* ``visual-block``

This method behave as setter-only property.

Example:

>>> import headlessvim
>>> with headlessvim.open() as vim:
...     vim.set_mode('insert')
...     vim.mode = 'normal' # also accessible as property
...

:param string mode: *Vim* mode to set
:raises ValueError: if ``mode`` is not supported


return self._process.executable<EOL>

:return: the absolute path to the process.
:rtype: string


return self._process.args<EOL>

:return: arguments for the process.
:rtype: list of string


return self._encoding<EOL>

:return: internal encoding of *Vim*.
:rtype: string


return self._swap(self._screen.size)<EOL>

:return: (lines, columns) tuple of a screen connected to *Vim*.
:rtype: (int, int)


if self.screen_size != size:<EOL><INDENT>self._screen.resize(*self._swap(size))<EOL><DEDENT>

:param size: (lines, columns) tuple of a screen connected to *Vim*.
:type size: (int, int)


return self._timeout<EOL>

:return: seconds to wait I/O.
:rtype: float


self._timeout = timeout<EOL>

:param float timeout: seconds to wait I/O.


if self._runtimepath is None:<EOL><INDENT>self._runtimepath = runtimepath.RuntimePath(self)<EOL><DEDENT>return self._runtimepath<EOL>

:return: runtime path of *Vim*
:rtype: runtimepath.RuntimePath


def __init__(self, executable, args, env):

self._executable = distutils.spawn.find_executable(executable)<EOL>self._args = args<EOL>self._env = env<EOL>self._open_process()<EOL>

:param str executable: command name to execute *Vim*
:param args: arguments to execute *Vim*
:type args: None or string or list of string
:param env: environment variables to execute *Vim*
:type env: None or dict of (string, string)


with self._close():<EOL><INDENT>self._process.terminate()<EOL><DEDENT>

Terminate this process.
Use this method rather than ``self.kill``.


with self._close():<EOL><INDENT>self._process.kill()<EOL><DEDENT>

Kill this process.
Use this only when the process seems to be hanging up.


rlist, wlist, xlist = select.select([self._stdout], [], [], timeout)<EOL>return bool(len(rlist))<EOL>

Poll ``self.stdout`` and return True if it is readable.

:param float timeout: seconds to wait I/O
:return: True if readable, else False
:rtype: boolean


return self._process.poll() is None<EOL>

Check if the process is alive.

:return: True if the process is alive, else False
:rtype: boolean


return self._executable<EOL>

:return: the absolute path to the process.
:rtype: strIng


return self._args<EOL>

:return: launch arguments of the process.
:rtype: string or list of string


return self._stdin<EOL>

:return: file-like object representing the standard input
         of the process
:rtype: flie-like object


return self._stdout<EOL>

:return: non blocking file-like object
         representing the standard output of the process
:rtype: file-like object


run_once = True<EOL>while (run_once or self._threaded) and self.end is False:<EOL><INDENT>self.service_tx_queue()<EOL>self.parse_messages()<EOL>run_once = False<EOL>if self._threaded:<EOL><INDENT>time.sleep(self._timeout)<EOL><DEDENT><DEDENT>if self._threaded:<EOL><INDENT>logger.info('<STR_LIT>')<EOL><DEDENT>

Receives the serial data into the self._raw buffer
:return:


message = message if isinstance(message, list) else [message]<EOL>length = len(message)<EOL>length_high_byte = (length & <NUM_LIT>) >> <NUM_LIT:8><EOL>length_low_byte = length & <NUM_LIT><EOL>message_with_length = [length_low_byte, length_high_byte] + message<EOL>sum1, sum2 = self._fletcher16_checksum(message_with_length)<EOL>message_with_length.append(sum1)<EOL>message_with_length.append(sum2)<EOL>message = [self._START_OF_FRAME]<EOL>for b in message_with_length:<EOL><INDENT>if b in [self._START_OF_FRAME, self._END_OF_FRAME, self._ESC]:<EOL><INDENT>message.append(self._ESC)<EOL>message.append(b ^ self._ESC_XOR)<EOL><DEDENT>else:<EOL><INDENT>message.append(b)<EOL><DEDENT><DEDENT>message.append(self._END_OF_FRAME)<EOL>self._port.write(message)<EOL>

Transmit a series of bytes
:param message: a list of bytes to send
:return: None


if not self._threaded:<EOL><INDENT>self.run()<EOL><DEDENT>try:<EOL><INDENT>return tuple(self._messages.pop(<NUM_LIT:0>))<EOL><DEDENT>except IndexError:<EOL><INDENT>return None<EOL><DEDENT>

Receive a series of bytes that have been verified
:return: a series of bytes as a tuple or None if empty


if self._START_OF_FRAME in self._raw and self._END_OF_FRAME in self._raw:<EOL><INDENT>while self._raw[<NUM_LIT:0>] != self._START_OF_FRAME and len(self._raw) > <NUM_LIT:0>:<EOL><INDENT>self._raw.pop(<NUM_LIT:0>)<EOL><DEDENT>if self._raw[<NUM_LIT:0>] == self._START_OF_FRAME:<EOL><INDENT>self._raw.pop(<NUM_LIT:0>)<EOL><DEDENT>eof_index = self._raw.index(self._END_OF_FRAME)<EOL>raw_message = self._raw[:eof_index]<EOL>self._raw = self._raw[eof_index:]<EOL>logger.debug('<STR_LIT>'.format(raw_message))<EOL>message = self._remove_esc_chars(raw_message)<EOL>logger.debug('<STR_LIT>'.format(message))<EOL>expected_checksum = (message[-<NUM_LIT:1>] << <NUM_LIT:8>) | message[-<NUM_LIT:2>]<EOL>logger.debug('<STR_LIT>'.format(expected_checksum))<EOL>message = message[:-<NUM_LIT:2>]  <EOL>logger.debug('<STR_LIT>'.format(message))<EOL>sum1, sum2 = self._fletcher16_checksum(message)<EOL>calculated_checksum = (sum2 << <NUM_LIT:8>) | sum1<EOL>if expected_checksum == calculated_checksum:<EOL><INDENT>message = message[<NUM_LIT:2>:]  <EOL>logger.debug('<STR_LIT>'.format(message))<EOL>self._messages.append(message)<EOL><DEDENT>else:<EOL><INDENT>logger.warning('<STR_LIT>'.format(message))<EOL>logger.debug('<STR_LIT>'.format(expected_checksum, calculated_checksum))<EOL><DEDENT><DEDENT>try:<EOL><INDENT>while self._raw[<NUM_LIT:0>] != self._START_OF_FRAME and len(self._raw) > <NUM_LIT:0>:<EOL><INDENT>self._raw.pop(<NUM_LIT:0>)<EOL><DEDENT><DEDENT>except IndexError:<EOL><INDENT>pass<EOL><DEDENT>

Parses the incoming data and determines if it is valid.  Valid
data gets placed into self._messages
:return: None


sum1 = <NUM_LIT:0><EOL>sum2 = <NUM_LIT:0><EOL>for i, b in enumerate(data):<EOL><INDENT>sum1 += b<EOL>sum1 &= <NUM_LIT>  <EOL>sum2 += sum1<EOL>sum2 &= <NUM_LIT><EOL><DEDENT>logger.debug('<STR_LIT>'.format(sum1, sum2))<EOL>return sum1, sum2<EOL>

Calculates a fletcher16 checksum for the list of bytes
:param data: a list of bytes that comprise the message
:return:


message = []<EOL>escape_next = False<EOL>for c in raw_message:<EOL><INDENT>if escape_next:<EOL><INDENT>message.append(c ^ self._ESC_XOR)<EOL>escape_next = False<EOL><DEDENT>else:<EOL><INDENT>if c == self._ESC:<EOL><INDENT>escape_next = True<EOL><DEDENT>else:<EOL><INDENT>message.append(c)<EOL><DEDENT><DEDENT><DEDENT>return message<EOL>

Removes any escape characters from the message
:param raw_message: a list of bytes containing the un-processed data
:return: a message that has the escaped characters appropriately un-escaped


run_once = True<EOL>while run_once or self._threaded:<EOL><INDENT>waiting = self._port.in_waiting<EOL>if waiting > <NUM_LIT:0>:<EOL><INDENT>temp = [int(c) for c in self._port.read(waiting)]<EOL>self._raw += temp<EOL><DEDENT>self._parse_raw_data()<EOL>run_once = False<EOL>if self._threaded:<EOL><INDENT>time.sleep(self._timeout)<EOL><DEDENT><DEDENT>


<EOL>if os.path.isfile(pidfile):<EOL><INDENT>pidfile_handle = open(pidfile, '<STR_LIT:r>')<EOL>try:<EOL><INDENT>pid = int(pidfile_handle.read())<EOL>pidfile_handle.close()<EOL>if check_pid(pid, debug):<EOL><INDENT>return True<EOL><DEDENT><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>os.unlink(pidfile)<EOL><DEDENT>pid = str(os.getpid())<EOL>open(pidfile, '<STR_LIT:w>').write(pid)<EOL>return False<EOL>

Check that a process is not running more than once, using PIDFILE


try:<EOL><INDENT>os.kill(pid, <NUM_LIT:0>)<EOL>if debug > <NUM_LIT:1>:<EOL><INDENT>print("<STR_LIT>")<EOL><DEDENT>return True<EOL><DEDENT>except OSError:<EOL><INDENT>if debug > <NUM_LIT:1>:<EOL><INDENT>print("<STR_LIT>")<EOL><DEDENT>return False<EOL><DEDENT>

This function will check whether a PID is currently running


return time.strftime('<STR_LIT>')<EOL>

This function gets the local time with local timezone offset


try:<EOL><INDENT>ret_val = int(value)<EOL>return ret_val, True<EOL><DEDENT>except ValueError:<EOL><INDENT>return <NUM_LIT:0>, False<EOL><DEDENT>


try:<EOL><INDENT>ret_val = float(value)<EOL>return ret_val, True<EOL><DEDENT>except ValueError:<EOL><INDENT>return <NUM_LIT:0.0>, False<EOL><DEDENT>


return convert_words_to_uint(high_word, low_word)<EOL>

Convert two words to a 32 bit unsigned integer


try:<EOL><INDENT>low_num = int(low_word)<EOL>if low_num < <NUM_LIT:0>:<EOL><INDENT>low_num = abs(low_num) + <NUM_LIT:2>**<NUM_LIT:15><EOL><DEDENT>number = (int(high_word) << <NUM_LIT:16>) | low_num<EOL>return number, True<EOL><DEDENT>except:<EOL><INDENT>return <NUM_LIT:0>, False<EOL><DEDENT>


number, retval = convert_words_to_uint(high_word, low_word)<EOL>if not retval:<EOL><INDENT>return <NUM_LIT:0.0>, False<EOL><DEDENT>try:<EOL><INDENT>packed_float = struct.pack('<STR_LIT>', number)<EOL>return struct.unpack('<STR_LIT>', packed_float)[<NUM_LIT:0>], True<EOL><DEDENT>except:<EOL><INDENT>return <NUM_LIT:0.0>, False<EOL><DEDENT>


<EOL>pid = os.getpid()<EOL>cgroup_file = "<STR_LIT>" + str(pid) + "<STR_LIT>"<EOL>try:<EOL><INDENT>infile = open(cgroup_file, "<STR_LIT:r>")<EOL><DEDENT>except IOError:<EOL><INDENT>print("<STR_LIT>", cgroup_file)<EOL>return False<EOL><DEDENT>for line in infile:<EOL><INDENT>if line.find("<STR_LIT>") == -<NUM_LIT:1>:<EOL><INDENT>continue<EOL><DEDENT>line = line.replace("<STR_LIT>", "<STR_LIT>")<EOL>items_list = line.split('<STR_LIT::>')<EOL>accounts = items_list[<NUM_LIT:1>]<EOL>dir_str = accounts + "<STR_LIT>"<EOL>if not accounts:<EOL><INDENT>continue<EOL><DEDENT>full_dir = "<STR_LIT>" + dir_str<EOL>if not os.path.exists(full_dir):<EOL><INDENT>os.makedirs(full_dir)<EOL>if debug >= <NUM_LIT:1>:<EOL><INDENT>print("<STR_LIT>", full_dir)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if debug >= <NUM_LIT:1>:<EOL><INDENT>print("<STR_LIT>", full_dir)<EOL><DEDENT><DEDENT>full_path = full_dir + "<STR_LIT>"<EOL>prog_list = ["<STR_LIT>", str(pid), "<STR_LIT:>>", full_path]<EOL>run_program(prog_list, debug, True)<EOL>if accounts.find("<STR_LIT:U+002C>") != -<NUM_LIT:1>:<EOL><INDENT>acct_list = accounts.split('<STR_LIT:U+002C>')<EOL>accounts = acct_list[<NUM_LIT:1>] + "<STR_LIT:U+002C>" + acct_list[<NUM_LIT:0>]<EOL>dir_str = accounts + "<STR_LIT>"<EOL>full_dir = "<STR_LIT>" + dir_str<EOL>try:<EOL><INDENT>if not os.path.exists(full_dir):<EOL><INDENT>os.makedirs(full_dir)<EOL><DEDENT><DEDENT>except:<EOL><INDENT>continue<EOL><DEDENT>full_path = full_dir + "<STR_LIT>"<EOL>prog_list = ["<STR_LIT>", str(pid), "<STR_LIT:>>", full_path]<EOL>run_program(prog_list, debug, True)<EOL><DEDENT><DEDENT>infile.close()<EOL>if debug >= <NUM_LIT:1>:<EOL><INDENT>prog_list = ["<STR_LIT>", cgroup_file]<EOL>run_program(prog_list, debug, False)<EOL><DEDENT>prog_list = ["<STR_LIT>", "<STR_LIT>", "<STR_LIT>", cgroup_file]<EOL>if run_program(prog_list, debug, False):<EOL><INDENT>return False<EOL><DEDENT>return True<EOL>

This function will disown, so the Ardexa service can be restarted


def run_program(prog_list, debug, shell):

try:<EOL><INDENT>if not shell:<EOL><INDENT>process = Popen(prog_list, stdout=PIPE, stderr=PIPE)<EOL>stdout, stderr = process.communicate()<EOL>retcode = process.returncode<EOL>if debug >= <NUM_LIT:1>:<EOL><INDENT>print("<STR_LIT>", "<STR_LIT:U+0020>".join(prog_list))<EOL>print("<STR_LIT>", retcode)<EOL>print("<STR_LIT>", stdout)<EOL>print("<STR_LIT>", stderr)<EOL><DEDENT>return bool(retcode)<EOL><DEDENT>else:<EOL><INDENT>command = "<STR_LIT:U+0020>".join(prog_list)<EOL>os.system(command)<EOL>return True<EOL><DEDENT><DEDENT>except:<EOL><INDENT>return False<EOL><DEDENT>

Run a  program and check program return code Note that some commands don't work
    well with Popen.  So if this function is specifically called with 'shell=True',
    then it will run the old 'os.system'. In which case, there is no program output


for addr in addrs.split('<STR_LIT:U+002C>'):<EOL><INDENT>elem = addr.split('<STR_LIT:->')<EOL>if len(elem) == <NUM_LIT:1>: <EOL><INDENT>yield int(elem[<NUM_LIT:0>])<EOL><DEDENT>elif len(elem) == <NUM_LIT:2>: <EOL><INDENT>start, end = list(map(int, elem))<EOL>for i in range(start, end+<NUM_LIT:1>):<EOL><INDENT>yield i<EOL><DEDENT><DEDENT>else: <EOL><INDENT>raise ValueError('<STR_LIT>' % addr)<EOL><DEDENT><DEDENT>

Yield each integer from a complex range string like "1-9,12,15-20,23"

    >>> list(parse_address_list('1-9,12,15-20,23'))
    [1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 15, 16, 17, 18, 19, 20, 23]

    >>> list(parse_address_list('1-9,12,15-20,2-3-4'))
    Traceback (most recent call last):
        ...
    ValueError: format error in 2-3-4


old_values = {}<EOL>nonexistent = set()<EOL>for key in kwargs:<EOL><INDENT>if key not in os.environ:<EOL><INDENT>nonexistent.add(key)<EOL><DEDENT>else:<EOL><INDENT>old_values[key] = os.environ[key]<EOL><DEDENT>os.environ[key] = kwargs[key]<EOL><DEDENT>try:<EOL><INDENT>yield<EOL><DEDENT>finally:<EOL><INDENT>for key in old_values:<EOL><INDENT>os.environ[key] = old_values[key]<EOL><DEDENT>for key in nonexistent:<EOL><INDENT>os.environ.pop(key)<EOL><DEDENT><DEDENT>

Context manager to tempolrarily change environment variables. On exit all
variables are set to their original value.


self.records.append(record)<EOL>


def contains(self, logger, level, message, is_regex=False):

for record in self.records:<EOL><INDENT>if record.name != logger or record.levelno != level:<EOL><INDENT>continue<EOL><DEDENT>if is_regex:<EOL><INDENT>if re.search(message, (record.msg % record.args)):<EOL><INDENT>return True<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if message in (record.msg % record.args):<EOL><INDENT>return True<EOL><DEDENT><DEDENT><DEDENT>return False<EOL>

Checks whether a message has been logged to a specific logger with a
specific level.

:param logger: The logger.
:param level: The log level.
:param messgae: The message contents.
:param is_regex: Whether the expected message is a regex or not.
    Non-regex messages are simply tested for inclusion.


def get_new_call(group_name, app_name, search_path, filename, require_load,<EOL>version, secure):<EOL>

new_call_kwargs = {<EOL>'<STR_LIT>': group_name,<EOL>'<STR_LIT:filename>': filename<EOL>}  <EOL>new_call_lookup_options = {}  <EOL>new_call_lookup_options['<STR_LIT>'] = secure<EOL>if search_path:<EOL><INDENT>new_call_lookup_options['<STR_LIT>'] = search_path<EOL><DEDENT>if require_load:<EOL><INDENT>new_call_lookup_options['<STR_LIT>'] = require_load<EOL><DEDENT>if version:<EOL><INDENT>new_call_lookup_options['<STR_LIT:version>'] = version<EOL><DEDENT>if new_call_lookup_options:<EOL><INDENT>new_call_kwargs['<STR_LIT>'] = new_call_lookup_options<EOL><DEDENT>output = build_call_str('<STR_LIT>', (app_name,), new_call_kwargs)<EOL>return output<EOL>

Build a call to use the new ``get_config`` function from args passed to
``Config.__init__``.


def build_call_str(prefix, args, kwargs):<EOL>

kwargs_str = '<STR_LIT:U+002CU+0020>'.join(['<STR_LIT>' % (key, value) for key, value in<EOL>kwargs.items()])<EOL>args_str = '<STR_LIT:U+002CU+0020>'.join([repr(arg) for arg in args])<EOL>output = [prefix, '<STR_LIT:(>']<EOL>if args:<EOL><INDENT>output.append(args_str)<EOL><DEDENT>if args and kwargs:<EOL><INDENT>output.append('<STR_LIT:U+002CU+0020>')<EOL><DEDENT>if kwargs:<EOL><INDENT>output.append(kwargs_str)<EOL><DEDENT>output.append('<STR_LIT:)>')<EOL>return '<STR_LIT>'.join(output)<EOL>

Build a callable Python string for a function call. The output will be
combined similar to this template::

    <prefix>(<args>, <kwargs>)

Example::

    >>> build_call_str('foo', (1, 2), {'a': '10'})
    "foo(1, 2, a='10')"


config_dirs = getenv('<STR_LIT>', '<STR_LIT>')<EOL>if config_dirs:<EOL><INDENT>self._log.debug('<STR_LIT>', config_dirs)<EOL>output = []<EOL>for path in reversed(config_dirs.split('<STR_LIT::>')):<EOL><INDENT>output.append(join(path, self.group_name, self.app_name))<EOL><DEDENT>return output<EOL><DEDENT>return ['<STR_LIT>' % (self.group_name, self.app_name)]<EOL>

Returns a list of paths specified by the XDG_CONFIG_DIRS environment
variable or the appropriate default.

The list is sorted by precedence, with the most important item coming
*last* (required by the existing config_resolver logic).


config_home = getenv('<STR_LIT>', '<STR_LIT>')<EOL>if config_home:<EOL><INDENT>self._log.debug('<STR_LIT>', config_home)<EOL>return expanduser(join(config_home, self.group_name, self.app_name))<EOL><DEDENT>return expanduser('<STR_LIT>' % (self.group_name, self.app_name))<EOL>

Returns the value specified in the XDG_CONFIG_HOME environment variable
or the appropriate default.


<EOL>config_filename = '<STR_LIT>'<EOL>if self.filename:<EOL><INDENT>config_filename = self.filename<EOL><DEDENT>env_filename = getenv(self.env_filename_name)<EOL>if env_filename:<EOL><INDENT>self._log.info('<STR_LIT>'<EOL>'<STR_LIT>',<EOL>env_filename,<EOL>self.env_filename_name)<EOL>config_filename = env_filename<EOL><DEDENT>return config_filename<EOL>

Returns the filename which is effectively used by the application. If
overridden by an environment variable, it will return that filename.


<EOL>path = (['<STR_LIT>' % (self.group_name, self.app_name)] +<EOL>self.get_xdg_dirs() +<EOL>[expanduser('<STR_LIT>' % (self.group_name, self.app_name)),<EOL>self.get_xdg_home(),<EOL>join(getcwd(), '<STR_LIT>'.format(self.group_name), self.app_name)])<EOL>if self.search_path:<EOL><INDENT>path = self.search_path.split(pathsep)<EOL><DEDENT>env_path = getenv(self.env_path_name)<EOL>if env_path and env_path.startswith('<STR_LIT:+>'):<EOL><INDENT>additional_paths = env_path[<NUM_LIT:1>:].split(pathsep)<EOL>self._log.info('<STR_LIT>'<EOL>'<STR_LIT>',<EOL>additional_paths,<EOL>self.env_path_name)<EOL>path.extend(additional_paths)<EOL><DEDENT>elif env_path:<EOL><INDENT>self._log.info("<STR_LIT>"<EOL>"<STR_LIT>",<EOL>env_path,<EOL>self.env_path_name)<EOL>path = env_path.split(pathsep)<EOL><DEDENT>return path<EOL>

Returns a list of paths to search for config files in reverse order of
precedence.  In other words: the last path element will override the
settings from the first one.


if not exists(filename):<EOL><INDENT>return False<EOL><DEDENT>new_config = ConfigResolverBase()<EOL>new_config.read(filename)<EOL>if self.version and not new_config.has_option('<STR_LIT>', '<STR_LIT:version>'):<EOL><INDENT>raise NoVersionError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>".format(filename,<EOL>self.version))<EOL><DEDENT>elif not self.version and new_config.has_option('<STR_LIT>', '<STR_LIT:version>'):<EOL><INDENT>self.version = StrictVersion(new_config.get('<STR_LIT>', '<STR_LIT:version>'))<EOL>self._log.info('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>',<EOL>filename, self.version)<EOL><DEDENT>elif self.version:<EOL><INDENT>file_version = new_config.get('<STR_LIT>', '<STR_LIT:version>')<EOL>major, minor, _ = StrictVersion(file_version).version<EOL>expected_major, expected_minor, _ = self.version.version<EOL>if expected_major != major:<EOL><INDENT>self._log.error(<EOL>'<STR_LIT>',<EOL>abspath(filename),<EOL>str(self.version),<EOL>file_version)<EOL>return False<EOL><DEDENT>if expected_minor != minor:<EOL><INDENT>self._log.warning(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>',<EOL>abspath(filename),<EOL>str(self.version),<EOL>file_version)<EOL>return True<EOL><DEDENT><DEDENT>return True<EOL>

Check if ``filename`` can be read. Will return boolean which is True if
the file can be read, False otherwise.


def get(self, section, option, **kwargs):  <EOL>

if "<STR_LIT:default>" in kwargs:<EOL><INDENT>default = kwargs.pop("<STR_LIT:default>")<EOL>new_kwargs = {'<STR_LIT>': default}<EOL>new_kwargs.update(kwargs)<EOL>new_call = build_call_str('<STR_LIT>', (section, option), new_kwargs)<EOL>warn('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % new_call,<EOL>DeprecationWarning,<EOL>stacklevel=<NUM_LIT:2>)<EOL>have_default = True<EOL><DEDENT>else:<EOL><INDENT>have_default = False<EOL><DEDENT>try:<EOL><INDENT>value = super(Config, self).get(section, option, **kwargs)<EOL>return value<EOL><DEDENT>except (NoSectionError, NoOptionError) as exc:<EOL><INDENT>if have_default:<EOL><INDENT>self._log.debug("<STR_LIT>", exc, default)<EOL>return default<EOL><DEDENT>else:<EOL><INDENT>raise<EOL><DEDENT><DEDENT>

Overrides :py:meth:`configparser.ConfigParser.get`.

In addition to ``section`` and ``option``, this call takes an optional
``default`` value. This behaviour works in *addition* to the
:py:class:`configparser.ConfigParser` default mechanism. Note that
a default value from ``ConfigParser`` takes precedence.

The reason this additional functionality is added, is because the
defaults of :py:class:`configparser.ConfigParser` are not dependent
on sections. If you specify a default for the option ``test``, then
this value will be returned for both ``section1.test`` and for
``section2.test``. Using the default on the ``get`` call gives you more
fine-grained control over this.

Also note, that if a default value was used, it will be logged with
level ``logging.DEBUG``.

:param section: The config file section.
:param option: The option name.
:param kwargs: These keyword args are passed through to
               :py:meth:`configparser.ConfigParser.get`.


def load(self, reload=False, require_load=False):<EOL>

if reload:  <EOL><INDENT>self.config = None<EOL><DEDENT>if self.config:  <EOL><INDENT>self._log.debug('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>return<EOL><DEDENT>path = self._effective_path()<EOL>config_filename = self._effective_filename()<EOL>self._active_path = [join(_, config_filename) for _ in path]<EOL>for dirname in path:<EOL><INDENT>conf_name = join(dirname, config_filename)<EOL>readable = self.check_file(conf_name)<EOL>if readable:<EOL><INDENT>action = '<STR_LIT>' if self._loaded_files else '<STR_LIT>'<EOL>self._log.info('<STR_LIT>', action, conf_name)<EOL>self.read(conf_name)<EOL>if conf_name == expanduser("<STR_LIT>" % (<EOL>self.group_name, self.app_name, self.filename)):<EOL><INDENT>self._log.warning(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>", expanduser("<STR_LIT>"), self.group_name,<EOL>self.app_name, expanduser("<STR_LIT>"), self.group_name,<EOL>self.app_name)<EOL><DEDENT>self._loaded_files.append(conf_name)<EOL><DEDENT><DEDENT>if not self._loaded_files and not require_load:<EOL><INDENT>self._log.warning(<EOL>"<STR_LIT>",<EOL>config_filename,<EOL>path)<EOL><DEDENT>elif not self._loaded_files and require_load:<EOL><INDENT>raise IOError("<STR_LIT>"<EOL>"<STR_LIT>" % (config_filename, path))<EOL><DEDENT>

Searches for an appropriate config file. If found, loads the file into
the current instance. This method can also be used to reload a
configuration. Note that you may want to set ``reload`` to ``True`` to
clear the configuration before loading in that case.  Without doing
that, values will remain available even if they have been removed from
the config files.

:param reload: if set to ``True``, the existing values are cleared
               before reloading.
:param require_load: If set to ``True`` this will raise a
                     :py:exc:`IOError` if no config file has been found
                     to load.


can_read = super(SecuredConfig, self).check_file(filename)<EOL>if not can_read:<EOL><INDENT>return False<EOL><DEDENT>mode = get_stat(filename).st_mode<EOL>if (mode & stat.S_IRGRP) or (mode & stat.S_IROTH):<EOL><INDENT>msg = "<STR_LIT>"<EOL>self._log.warning(msg, filename)<EOL>return False<EOL><DEDENT>return True<EOL>


_validate_sample_rates(input_filepath_list, combine_type)<EOL>if combine_type == '<STR_LIT>':<EOL><INDENT>_validate_num_channels(input_filepath_list, combine_type)<EOL><DEDENT>

Validate that combine method can be performed with given files.
    Raises IOError if input file formats are incompatible.


sample_rates = [<EOL>file_info.sample_rate(f) for f in input_filepath_list<EOL>]<EOL>if not core.all_equal(sample_rates):<EOL><INDENT>raise IOError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>.format(combine_type)<EOL>)<EOL><DEDENT>

Check if files in input file list have the same sample rate


channels = [<EOL>file_info.channels(f) for f in input_filepath_list<EOL>]<EOL>if not core.all_equal(channels):<EOL><INDENT>raise IOError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>.format(combine_type)<EOL>)<EOL><DEDENT>

Check if files in input file list have the same number of channels