Skip to content

load

bytes.load

                                                                                
 Documentation                                                                  
                          -- n/a --                                             
                                                                                
 Origin                                                                         
                          Authors   Markus Binsteiner (markus@frkl.io)          
                                                                                
 Context                                                                        
                          Tags         bytes, serialization, core               
                          Labels       package: kiara_modules.core              
                          References   source_repo:                             
                                       https://github.com/DHARPA-Project/kia…   
                                       documentation:                           
                                       https://dharpa.org/kiara_modules.core/   
                                       module_doc:                              
                                       https://dharpa.org/kiara_modules.core…   
                                       source_url:                              
                                       https://github.com/DHARPA-Project/kia…   
                                                                                
 Module config                                                                  
                          Field       Type     Description           Required   
                         ─────────────────────────────────────────────────────  
                          constants   object   Value constants for   no         
                                               this module.                     
                          defaults    object   Value defaults for    no         
                                               this module.                     
                                                                                
 Module config          -- no config --                                         
 Python class                                                                   
                          class_name    LoadBytesModule                         
                          module_name   kiara_modules.core.bytes                
                          full_name     kiara_modules.core.bytes.LoadBytesMo…   
                                                                                
 Processing source code  ─────────────────────────────────────────────────────  
                          def process(self, inputs: ValueSet, outputs: Value…   
                                                                                
                              path = inputs.get_value_data("path")              
                                                                                
                              if not os.path.exists(path):                      
                                  raise KiaraProcessingException(               
                                      f"Can't read file, path does not exist…   
                                  )                                             
                                                                                
                              with open(path, "rb") as f:                       
                                  content = f.read()                            
                                                                                
                              outputs.set_value("bytes", content)               
                                                                                
                         ─────────────────────────────────────────────────────