Sorry, forgot the mailinglist.

KR D

________________________________
From: Balsiger Daniel, INI-EAI-INO <daniel.balsi...@swisscom.com>
Sent: Thursday, January 16, 2020 12:16 PM
To: SHOSTAK, MARK <ms7...@att.com>
Subject: Re: PDF->AS v0.3

Maybe the attachment was truncated I try to rename the file to pdftoas.py -> 
pdftoas.txt


________________________________
From: Balsiger Daniel, INI-EAI-INO <daniel.balsi...@swisscom.com>
Sent: Thursday, January 16, 2020 12:09 PM
To: SHOSTAK, MARK <ms7...@att.com>
Subject: Re: PDF->AS v0.3

Hi Mark

The file is attached, since inline email formatting was not very handy.
It should be clear how other data than IPMI password could be modified.

Best Regards, Daniel

As a last comment: Only having the PDF as input is definitely not enough to 
create the whole treasuremap tree. (e.g. no IP addresses contained in PDF, but 
required for treasuremap tree)

________________________________
From: SHOSTAK, MARK <ms7...@att.com>
Sent: Wednesday, January 15, 2020 5:40 PM
To: Balsiger Daniel, INI-EAI-INO <daniel.balsi...@swisscom.com>
Subject: PDF->AS v0.2


    import sys

    import ruamel.yaml

    import yaml

    ryaml = ruamel.yaml.YAML()

    ryaml.preserve_quotes = True

    ryaml.indent(mapping=4, sequence=6, offset=4)

    ryaml.explicit_start = True



###############################

# Source PDF



    pdf = "pod18.yaml" # set PDF filename here



    with open(pdf) as f:

        pdf_data = yaml.safe_load(f)







##########################

# Generic template

#

#

# Extract datum from PDF

#

#    target_data = pdf_data['jumphost']['remote_params']['pass']

#

##############

# Target

#

#    #Target file

#    target_file = "treasuremap_path_and_filename.yaml"

#

#    with open(target_file, 'r+') as tf:

#        target_yaml_struct = ryaml.load(f)

#

#        #The password in the ipmi_admin_password.yaml file is called "data" a 
bit confusing...

#        target_yaml_struct['target_object'] = target_data

#

#        with open(target_file, 'w') as tf:

#            ryaml.dump(target_file, tf)

#





###############################



# Extract datum from PDF



    target_data = pdf_data['jumphost']['remote_params']['pass']



##############

# Target



    #Target file

    target_file = "ipmi_admin_password.yaml"



    with open(target_file, 'r+') as tf:

        target_yaml_struct = ryaml.load(f)



        #The password in the ipmi_admin_password.yaml file is called "data" a 
bit confusing...

        target_yaml_struct['data'] = target_data



        with open(target_file, 'w') as tf:

            ryaml.dump(target_data, tf)


#!/usr/bin/env python3

# Original Code from agard...@linuxfoundation.org
# Some renaming for generic data from Mark Shostak ms7...@att.com 

import sys
import ruamel.yaml
import yaml

ryaml = ruamel.yaml.YAML()
ryaml.preserve_quotes = True
ryaml.indent(mapping=4, sequence=6, offset=4)
ryaml.explicit_start = True

##########################
# Open Source PDF File
pdf = "sample_pdf_from_UNH.yaml" # set PDF filename here
with open(pdf) as f:
    pdf_data = yaml.safe_load(f)

##########################
# Generic template
# Extract datum from PDF
target_data = pdf_data['jumphost']['remote_params']['pass']
#print(target_data)

##########################    
# Set Target Yaml File
#target_file = "treasuremap_path_and_filename.yaml"
# In this case the IPMI password file is set
target_file = "ipmi_admin_password.yaml"

##########################    
# Open Target Yaml File
with open(target_file, 'r+') as tf:
    target_yaml = ryaml.load(tf)

    # The password in the ipmi_admin_password.yaml file is called "data", which 
is a bit confusing...
#    target_yaml['data'] = target_data

    ##########################    
    # Modify Target Yaml File
    with open(target_file, 'w') as tf:
        ryaml.dump(target_yaml, tf)

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#23843): 
https://lists.opnfv.org/g/opnfv-tech-discuss/message/23843
Mute This Topic: https://lists.opnfv.org/mt/69745943/21656
Group Owner: opnfv-tech-discuss+ow...@lists.opnfv.org
Unsubscribe: https://lists.opnfv.org/g/opnfv-tech-discuss/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to