<s> """<STR_LIT>""" <EOL> import sys <EOL> from ecohydrolib . command . base import Command <EOL> from ecohydrolib . command . exceptions import MetadataException <EOL> from ecohydrolib . command . exceptions import RunException <EOL> from ecohydrolib . metadata import GenericMetadata <EOL> from ecohydrolib . hydroshare import create_hydroshare_resource <EOL> class HydroShareCreateResource ( Command ) : <EOL> def __init__ ( self , projectDir , configFile = None , outfp = sys . stdout ) : <EOL> """<STR_LIT>""" <EOL> super ( HydroShareCreateResource , self ) . __init__ ( projectDir , configFile , outfp ) <EOL> def checkMetadata ( self , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> super ( HydroShareCreateResource , self ) . checkMetadata ( args , kwargs ) <EOL> overwrite = kwargs . get ( '<STR_LIT>' , False ) <EOL> self . hydroshare = GenericMetadata . readHydroShareEntries ( self . context ) <EOL> if not overwrite and '<STR_LIT>' in self . hydroshare : <EOL> raise MetadataException ( "<STR_LIT>" ) <EOL> def run ( self , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> auth = kwargs . get ( '<STR_LIT>' , None ) <EOL> if auth is None : <EOL> raise RunException ( "<STR_LIT>" ) <EOL> title = kwargs . get ( '<STR_LIT:title>' , None ) <EOL> if title is None : <EOL> raise RunException ( "<STR_LIT>" ) <EOL> hydroshare_host = kwargs . get ( '<STR_LIT>' , None ) <EOL> hydroshare_port = kwargs . get ( '<STR_LIT>' , None ) <EOL> use_https = kwargs . get ( '<STR_LIT>' , False ) <EOL> resource_type = kwargs . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> abstract = kwargs . get ( '<STR_LIT>' , None ) <EOL> keywords = kwargs . get ( '<STR_LIT>' , None ) <EOL> create_callback = kwargs . get ( '<STR_LIT>' , None ) <EOL> verbose = kwargs . get ( '<STR_LIT>' , False ) <EOL> overwrite = kwargs . get ( '<STR_LIT>' , False ) <EOL> self . checkMetadata ( overwrite = overwrite ) <EOL> resource_id = create_hydroshare_resource ( self . context , auth , title , <EOL> hydroshare_host = hydroshare_host , <EOL> hydroshare_port = hydroshare_port , use_https = use_https , <EOL> resource_type = resource_type , abstract = abstract , <EOL> keywords = keywords , create_callback = create_callback , <EOL> verbose = verbose ) <EOL> cmdline = GenericMetadata . getCommandLine ( ) <EOL> GenericMetadata . writeHydroShareEntry ( self . context , '<STR_LIT>' , resource_id ) <EOL> GenericMetadata . appendProcessingHistoryItem ( self . context , cmdline ) </s>
