<s> import argparse <EOL> import os <EOL> import sys <EOL> from saml2 . metadata import entity_descriptor , metadata_tostring_fix <EOL> from saml2 . metadata import entities_descriptor <EOL> from saml2 . metadata import sign_entity_descriptor <EOL> from saml2 . sigver import security_context <EOL> from saml2 . validate import valid_instance <EOL> from saml2 . config import Config <EOL> parser = argparse . ArgumentParser ( ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( '<STR_LIT:-c>' , dest = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT:id>' , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT:name>' , default = "<STR_LIT>" ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT:path>' , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( dest = "<STR_LIT>" , nargs = "<STR_LIT:+>" ) <EOL> args = parser . parse_args ( ) <EOL> valid_for = <NUM_LIT:0> <EOL> nspair = { "<STR_LIT>" : "<STR_LIT>" } <EOL> paths = [ "<STR_LIT:.>" , "<STR_LIT>" ] <EOL> if args . valid : <EOL> valid_for = int ( args . valid ) * <NUM_LIT> <EOL> eds = [ ] <EOL> for filespec in args . config : <EOL> bas , fil = os . path . split ( filespec ) <EOL> if bas != "<STR_LIT>" : <EOL> sys . path . insert ( <NUM_LIT:0> , bas ) <EOL> if fil . endswith ( "<STR_LIT>" ) : <EOL> fil = fil [ : - <NUM_LIT:3> ] <EOL> cnf = Config ( ) . load_file ( fil , metadata_construction = True ) <EOL> if valid_for : <EOL> cnf . valid_for = valid_for <EOL> eds . append ( entity_descriptor ( cnf ) ) <EOL> conf = Config ( ) <EOL> conf . key_file = args . keyfile <EOL> conf . cert_file = args . cert <EOL> conf . debug = <NUM_LIT:1> <EOL> conf . xmlsec_binary = args . xmlsec <EOL> secc = security_context ( conf ) <EOL> if args . id : <EOL> desc , xmldoc = entities_descriptor ( eds , valid_for , args . name , args . id , <EOL> args . sign , secc ) <EOL> valid_instance ( desc ) <EOL> print desc . to_string ( nspair ) <EOL> else : <EOL> for eid in eds : <EOL> if args . sign : <EOL> assert conf . key_file <EOL> assert conf . cert_file <EOL> eid , xmldoc = sign_entity_descriptor ( eid , args . id , secc ) <EOL> else : <EOL> xmldoc = None <EOL> valid_instance ( eid ) <EOL> xmldoc = metadata_tostring_fix ( eid , nspair , xmldoc ) <EOL> print xmldoc </s>
