Passport.py
def export_yaml(self) -> None:
        """makes a unit passport and dumps it in a form of a YAML file"""

        # since unit passport will be published to IPFS, employee name is replaced with
        # "employee passport code" - an SHA256 checksum of a string, which is a space-separated
        # combination of employee's ID, name and position. since this data is unique for every
        # employee, it is safe to assume, that collision is impossible.

        # generate employee passport code
        employee_passport_string = " ".join(self._employee_db_entry)
        employee_passport_string_encoded = employee_passport_string.encode()
        employee_passport_code = hashlib.sha256(employee_passport_string_encoded).hexdigest()

        logging.debug(f"self.session_start_time = {self.session_start_time}")

        passport_dict = {
            "Уникальный номер паспорта изделия": self.passport_id,
            "Модель изделия": self.product_type,
            "Комплектация": self.additional_info,
            "Начало сборки": self.session_start_time,
            "Окончание сборки": self.session_end_time,
            "Этап производства": self.workplace_data,
            "Изготовил": employee_passport_code,
            "Видеозаписи процесса сборки в IPFS": self.video_ipfs_hash
        }

        logging.debug(f"raw passport_dict = {passport_dict}")

        # make directory if it is missing
        if not os.path.isdir("unit-passports"):
            os.mkdir("unit-passports")

        # save into a file and save the filename
        self.filename = f"unit-passports/unit-passport-{self.passport_id}.yaml"
        with open(self.filename, "w") as passport_file:
            yaml.dump(
                passport_dict,
                passport_file,
                allow_unicode=True,
                sort_keys=False
            )

        logging.info(f"Unit passport with UUID {self.passport_id} has been dumped successfully")

        # upload passport file into IPFS and pin it to Pinata, publish hash to Robonomics
        self.passport_ipfs_hash = ipfs.send(
            filename=self.filename,
            config=self.config
        )

        # also save passport IPFS hash locally in case Robonomics datalog is not written
        with open("issued_passports.csv", "a") as file:
            file.writelines(
                f"{self.passport_id};{self.passport_ipfs_hash}\n"
            )
makes a unit passport and dumps it in a form of a YAML file
makes a unit passport and dumps it in a form of a YAML file
makes a unit passport and dumps it in a form of a YAML file
def export_yaml(self) -> None:
        employee_passport_string = " ".join(self._employee_db_entry)
        employee_passport_string_encoded = employee_passport_string.encode()
        employee_passport_code = hashlib.sha256(employee_passport_string_encoded).hexdigest()
        logging.debug(f"self.session_start_time = {self.session_start_time}")
        passport_dict = {
            "Уникальный номер паспорта изделия": self.passport_id,
            "Модель изделия": self.product_type,
            "Комплектация": self.additional_info,
            "Начало сборки": self.session_start_time,
            "Окончание сборки": self.session_end_time,
            "Этап производства": self.workplace_data,
            "Изготовил": employee_passport_code,
            "Видеозаписи процесса сборки в IPFS": self.video_ipfs_hash
        }
        logging.debug(f"raw passport_dict = {passport_dict}")
        if not os.path.isdir("unit-passports"):
            os.mkdir("unit-passports")
        self.filename = f"unit-passports/unit-passport-{self.passport_id}.yaml"
        with open(self.filename, "w") as passport_file:
            yaml.dump(
                passport_dict,
                passport_file,
                allow_unicode=True,
                sort_keys=False
            )
        logging.info(f"Unit passport with UUID {self.passport_id} has been dumped successfully")
        self.passport_ipfs_hash = ipfs.send(
            filename=self.filename,
            config=self.config
        )
        with open("issued_passports.csv", "a") as file:
            file.writelines(
                f"{self.passport_id};{self.passport_ipfs_hash}\n"
            )
def export_yaml ( self ) -> None : employee_passport_string = " " . join ( self . _employee_db_entry ) employee_passport_string_encoded = employee_passport_string . encode ( ) employee_passport_code = hashlib . sha256 ( employee_passport_string_encoded ) . hexdigest ( ) logging . debug ( f"self.session_start_time = {self.session_start_time}" ) passport_dict = { "Уникальный номер паспорта изделия": self.passport_id, "Модель изделия": self.produc t type , "Комплектация": self.addit i nal_ i nfo, "Начало сборки": self.sessi o _sta r t_time, "Окончание сборки": self.session_ e d_ti m e, "Этап производства": self.workplace _ ata, "Изготовил": employe e passport_code, "Видеозаписи процесса сборки в IPFS": self.video_ipfs_hash } logging . debug ( f"raw passport_dict = {passport_dict}" ) if not os . path . isdir ( "unit-passports" ) : os . mkdir ( "unit-passports" ) self . filename = f"unit-passports/unit-passport-{self.passport_id}.yaml" with open ( self . filename , "w" ) as passport_file : yaml . dump ( passport_dict , passport_file , allow_unicode = True , sort_keys = False ) logging . info ( f"Unit passport with UUID {self.passport_id} has been dumped successfully" ) self . passport_ipfs_hash = ipfs . send ( filename = self . filename , config = self . config ) with open ( "issued_passports.csv" , "a" ) as file : file . writelines ( f"{self.passport_id};{self.passport_ipfs_hash}\n" )
makes a unit passport and dumps it in a form of a YAML file
makes a unit passport and dumps it in a form of a YAML file
"""makes a unit passport and dumps it in a form of a YAML file""" # since unit passport will be published to IPFS, employee name is replaced with # "employee passport code" - an SHA256 checksum of a string, which is a space-separated # combination of employee's ID, name and position. since this data is unique for every # employee, it is safe to assume, that collision is impossible. # generate employee passport code # make directory if it is missing # save into a file and save the filename # upload passport file into IPFS and pin it to Pinata, publish hash to Robonomics # also save passport IPFS hash locally in case Robonomics datalog is not written
self