<commit_before># Parser for the OpenNSA command-line tool.
#
# Commands: reserve, provision, release, terminate, query
#
# Options:

# -f defaults file
# -w wsdl directory

# -h host (for callback)
# -o port (for callback)

# -u service url

# -t topology file
# -n network

# -p provider nsa
# -r requester nsa

# -c connection id
# -g global reservation id

# -s source stp
# -d dest stp

# -b bandwidth (megabits)

# Flags
# (none currently)

# Not all commands will accept all flags and some flags are mutally exclusive


from twisted.python import usage

from opennsa.cli import options


# parameters used for all commands

class DefaultsFileOption(usage.Options):
    optParameters = [ [ options.DEFAULTS_FILE, 'f', None, 'Service URL'] ]

class WSDLDirectoryOption(usage.Options):
    optParameters = [ [ options.WSDL_DIRECTORY, 'w', None, 'Service URL'] ]

class HostOption(usage.Options):
    optParameters = [ [ options.HOST, 'h', None, 'Host (for callback)'] ]

class PortOption(usage.Options):
    optParameters = [ [ options.PORT, 'o', None, 'Port (for callback)'] ]

# parameters which are only used for some commands

class ServiceURLOption(usage.Options):
    optParameters = [ [ options.SERVICE_URL, 'u', None, 'Service URL'] ]

class TopologyFileOption(usage.Options):
    optParameters = [ [ options.TOPOLOGY_FILE, 't', None, 'Topology File'] ]

class NetworkOption(usage.Options):
    optParameters = [ [ options.NETWORK, 'n', None, 'Provider Network'] ]

class ProviderNSAOption(usage.Options):
    optParameters = [ [ options.PROVIDER, 'p', None, 'Provider NSA Identity'] ]

class RequesterNSAOption(usage.Options):
    optParameters = [ [ options.REQUESTER, 'r', None, 'Requester NSA Identity'] ]

class SourceSTPOption(usage.Options):
    optParameters = [ [ options.SOURCE_STP, 's', None, 'Source STP'] ]

class DestSTPOption(usage.Options):
    optParameters = [ [ options.DEST_STP, 'd', None, 'Dest STP'] ]

class ConnectionIDOption(usage.Options):
    optParameters = [ [ options.CONNECTION_ID, 'c', None, 'Connection id'] ]

class GlobalIDOption(usage.Options):
    optParameters = [ [ options.GLOBAL_ID, 'g', None, 'Global id'] ]

class StartTimeOption(usage.Options):
    optParameters = [ [ options.START_TIME, 'a', None, 'Start time'] ]

class EndTimeOption(usage.Options):
    optParameters = [ [ options.END_TIME, 'e', None, 'End time'] ]

class BandwidthOption(usage.Options):
    optParameters = [ [ options.BANDWIDTH, 'b', None, 'Bandwidth (Megabits)'] ]


# command options


class NetworkCommandOptions(ServiceURLOption, TopologyFileOption, NetworkOption, ProviderNSAOption, RequesterNSAOption, ConnectionIDOption, GlobalIDOption):

    def postOptions(self):
        if self[options.SERVICE_URL] and (self[options.TOPOLOGY_FILE] or self[options.NETWORK]):
            raise usage.UsageError('Cannot set both service url while having topology file or network.')


class ReserveOptions(NetworkCommandOptions, SourceSTPOption, DestSTPOption, StartTimeOption, EndTimeOption, BandwidthOption):
    pass


class ProvisionReleaseTerminateOptions(NetworkCommandOptions):
    pass


class Options(DefaultsFileOption, WSDLDirectoryOption, HostOption, PortOption):
    subCommands = [
        ['reserve',     None,   ReserveOptions,   'Create a reservation'],
        ['provision',   None,   ProvisionReleaseTerminateOptions, 'Provision a connection.'],
        ['provision',   None,   ProvisionReleaseTerminateOptions, 'Release a connection.'],
        ['provision',   None,   ProvisionReleaseTerminateOptions, 'Terminate a connection.']
    ]

    optFlags = [
        [ options.VERBOSE, 'v', 'Print out more information']
    ]

    def postOptions(self):
        if self.subCommand is None:
            return usage.UsageError('No option specified')

    def opt_version(self):
        from twisted import copyright
        print "OpenNSA Development version. " + \
              "Running on Twisted version", copyright.version
        raise SystemExit
<commit_msg>actually add release and terminate commands to parser<commit_after># Parser for the OpenNSA command-line tool.
#
# Commands: reserve, provision, release, terminate, query
#
# Options:

# -f defaults file
# -w wsdl directory

# -h host (for callback)
# -o port (for callback)

# -u service url

# -t topology file
# -n network

# -p provider nsa
# -r requester nsa

# -c connection id
# -g global reservation id

# -s source stp
# -d dest stp

# -b bandwidth (megabits)

# Flags
# (none currently)

# Not all commands will accept all flags and some flags are mutally exclusive


from twisted.python import usage

from opennsa.cli import options


# parameters used for all commands

class DefaultsFileOption(usage.Options):
    optParameters = [ [ options.DEFAULTS_FILE, 'f', None, 'Service URL'] ]

class WSDLDirectoryOption(usage.Options):
    optParameters = [ [ options.WSDL_DIRECTORY, 'w', None, 'Service URL'] ]

class HostOption(usage.Options):
    optParameters = [ [ options.HOST, 'h', None, 'Host (for callback)'] ]

class PortOption(usage.Options):
    optParameters = [ [ options.PORT, 'o', None, 'Port (for callback)'] ]

# parameters which are only used for some commands

class ServiceURLOption(usage.Options):
    optParameters = [ [ options.SERVICE_URL, 'u', None, 'Service URL'] ]

class TopologyFileOption(usage.Options):
    optParameters = [ [ options.TOPOLOGY_FILE, 't', None, 'Topology File'] ]

class NetworkOption(usage.Options):
    optParameters = [ [ options.NETWORK, 'n', None, 'Provider Network'] ]

class ProviderNSAOption(usage.Options):
    optParameters = [ [ options.PROVIDER, 'p', None, 'Provider NSA Identity'] ]

class RequesterNSAOption(usage.Options):
    optParameters = [ [ options.REQUESTER, 'r', None, 'Requester NSA Identity'] ]

class SourceSTPOption(usage.Options):
    optParameters = [ [ options.SOURCE_STP, 's', None, 'Source STP'] ]

class DestSTPOption(usage.Options):
    optParameters = [ [ options.DEST_STP, 'd', None, 'Dest STP'] ]

class ConnectionIDOption(usage.Options):
    optParameters = [ [ options.CONNECTION_ID, 'c', None, 'Connection id'] ]

class GlobalIDOption(usage.Options):
    optParameters = [ [ options.GLOBAL_ID, 'g', None, 'Global id'] ]

class StartTimeOption(usage.Options):
    optParameters = [ [ options.START_TIME, 'a', None, 'Start time'] ]

class EndTimeOption(usage.Options):
    optParameters = [ [ options.END_TIME, 'e', None, 'End time'] ]

class BandwidthOption(usage.Options):
    optParameters = [ [ options.BANDWIDTH, 'b', None, 'Bandwidth (Megabits)'] ]


# command options


class NetworkCommandOptions(ServiceURLOption, TopologyFileOption, NetworkOption, ProviderNSAOption, RequesterNSAOption, ConnectionIDOption, GlobalIDOption):

    def postOptions(self):
        if self[options.SERVICE_URL] and (self[options.TOPOLOGY_FILE] or self[options.NETWORK]):
            raise usage.UsageError('Cannot set both service url while having topology file or network.')


class ReserveOptions(NetworkCommandOptions, SourceSTPOption, DestSTPOption, StartTimeOption, EndTimeOption, BandwidthOption):
    pass


class ProvisionReleaseTerminateOptions(NetworkCommandOptions):
    pass


class Options(DefaultsFileOption, WSDLDirectoryOption, HostOption, PortOption):
    subCommands = [
        ['reserve',     None,   ReserveOptions,   'Create a reservation'],
        ['provision',   None,   ProvisionReleaseTerminateOptions, 'Provision a connection.'],
        ['release',     None,   ProvisionReleaseTerminateOptions, 'Release a connection.'],
        ['terminate',   None,   ProvisionReleaseTerminateOptions, 'Terminate a connection.']
    ]

    optFlags = [
        [ options.VERBOSE, 'v', 'Print out more information']
    ]

    def postOptions(self):
        if self.subCommand is None:
            return usage.UsageError('No option specified')

    def opt_version(self):
        from twisted import copyright
        print "OpenNSA Development version. " + \
              "Running on Twisted version", copyright.version
        raise SystemExit

{'fraction_non_alphanumeric': 0.1154228855721393, 'fraction_numerical': 0.0, 'mean_word_length': 4.134738186462324, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '197148', 'n_tokens_mistral': 2399, 'n_tokens_neox': 2358, 'n_words': 671}