The cli tool as a built-in function.

    :param input_string: A string that should be converted to a set of facts.
    :type input_string: str.
    :param blocks_size: Optional block size of sentences (Default: 2).
    :type block_size: int.
556757
def converter(input_string, block_size=2):
    

    sentences = textprocessing.getSentences(input_string)
    blocks = textprocessing.getBlocks(sentences, block_size)
    parse.makeIdentifiers(blocks)
251280
def build_data_input(cls, name='input'):
        
        return cls(name, PortDirection.INPUT, type=PortType.DATA)
526397
def pad(self, data, block_size):
		
		padding_symbol = self.padding_symbol()

		blocks_count = (len(data) // block_size)
		if (len(data) % block_size) != 0:
			blocks_count += 1

		total_length = blocks_count * block_size
		return self._fill(data, total_length, padding_symbol)
520116
def input_int_default(question="", default=0):
    
    answer = input_string(question)
    if answer == "" or answer == "yes":
        return default
    else:
        return int(answer)
367827
def p_generate_block(self, p):
        ''
        p[0] = Block(p[2], lineno=p.lineno(1))
        p.set_lineno(0, p.lineno(1))
1151470
def input(prompt=""):
	""""""
	
	string = stdin_decode(raw_input(prompt))
	
	caller_frame = sys._getframe(1)
	globals = caller_frame.f_globals
	locals = caller_frame.f_locals
	
	return eval(string, globals, locals)
131411
def pad(text, block_size, zero=False):
    
    num = block_size - (len(text) % block_size)
    ch = b'\0' if zero else chr(num).encode('latin-1')
    return text + (ch * num)
351429
def _pad(string, size):
    
    strlen = len(string)
    if strlen == size:
        return string
    if strlen < size:
        return _padding[0:size-strlen] + string
    return string[-size:]
142283
def blocksize(self, input_totalframes):
        """"""

        blocksize = input_totalframes
        if self.pad:
            mod = input_totalframes % self.buffer_size
            if mod:
                blocksize += self.buffer_size - mod

        return blocksize
1081701
function processBlocks(textString, options, data) {

	var replacer = function replacer(match, $1, $2, $3, $4, $5, $6, offset, input) {
		var out = '',
			dataValue,
			type = String($2),
			key = String($3 || '').trim(),
			blockText = String($5),
			nestedBlocks;

		dataValue = _extract(key, data);

		if (options && typeof options === 'object' && options.strictKeys) {
			if(Number.isNaN(dataValue)) {
				return match;
			}
		}

		nestedBlocks = blockText.match(pattern);
		if (nestedBlocks) {
			blockText = blockText.replace(pattern, function(match, $1, $2, $3, $4, $5, $6, offset, input) {
				var index = match.indexOf($5);
				var length = $5.length;
				var body = $5.replace(/(?:\\*)\[(.+?)(?:\\*)\]/g, "\\[$1]");
				return match.substr(0, index) + body + match.substr(index + length);
			});
		}

		var obj = {}, proto = {}, KEY;
		if (typeof dataValue === 'object' && type === '#') {
			for(KEY in dataValue) {
				obj = {}, proto = {};
				proto.KEY = proto.INDEX = KEY;
				obj[KEY] = proto.VALUE = dataValue[KEY];
				obj.__proto__ = proto;
				if (typeof dataValue[KEY] === 'object' && !isNaN(parseInt(KEY))) {
					obj = dataValue[KEY];
					obj.__proto__ = proto;
				}
				out += renderData(blockText, options, obj, Boolean(options.prefix));
			}
			if (nestedBlocks) {
				out = processBlocks(out, options, data);
			}
		} else if (dataValue && (type === '~' || type === '#')) {
			// block logical truthy
			proto.KEY = proto.INDEX = key;
			proto.VALUE = Boolean(dataValue);
			obj = data;
			obj.__proto__ = proto;

			out += renderData(blockText, options, obj, Boolean(options.prefix));
			if (nestedBlocks) {
				out = processBlocks(out, options, data);
			}
		} else if (!dataValue && (type === '^' || type === '!')) {
			// block logical falsy
			proto.KEY = proto.INDEX = key;
			proto.VALUE = Boolean(dataValue);
			obj = data;
			obj.__proto__ = proto;

			out += renderData(blockText, options, obj, Boolean(options.prefix));
			if (nestedBlocks) {
				out = processBlocks(out, options, data);
			}
		}
		return out;
	};

	var pattern = new RegExp('(\\[\\s*(~|\\^|\\!|#)([^\\r\\n]+)\\s*\\])([\\s]?)([\\s\\S]*?)(\\[\\s*\\/\\3\\s*\\]\\4?)', 'mg');

	if(typeof data === 'object' && data !== null) {
		if (options && typeof options === 'object' && options.prefix) {
			pattern = new RegExp('(\\[\\s*(~|\\^|\\!|#)'+rxquote(String(options.prefix))+'[\\.\\-\\_]([^\\r\\n]+)\\s*\\])(\\s?)([\\s\\S]*?)(\\[\\s*\\/'+rxquote(String(options.prefix))+'[\\.\\-\\_]\\3\\s*\\]\\4?)', 'mg');
		}
		textString = textString.replace(pattern, replacer);
	}

	return textString;
}
1291050
def _bindlist(input_str):
    
    try:
        ip_port = input_str.split(':')
        if len(ip_port) == 1:
            _ip = ip_port[0]
            _port = None
        else:
            (_ip, _port) = ip_port
        if not _ip and not _port:
            raise AssertionError
        elif not _port:
            _port = '22'  # default port if not given
        return _ip, int(_port)
    except ValueError:
        raise argparse.ArgumentTypeError(
            'Address tuple must be of type IP_ADDRESS:PORT'
        )
    except AssertionError:
        raise argparse.ArgumentTypeError("Both IP:PORT can't be missing!")
967457
def ensure_block_device(block_device):
    '''
    
    '''
    _none = ['None', 'none', None]
    if (block_device in _none):
        error_out('prepare_storage(): Missing required input: block_device=%s.'
                  % block_device)

    if block_device.startswith('/dev/'):
        bdev = block_device
    elif block_device.startswith('/'):
        _bd = block_device.split('|')
        if len(_bd) == 2:
            bdev, size = _bd
        else:
            bdev = block_device
            size = DEFAULT_LOOPBACK_SIZE
        bdev = ensure_loopback_device(bdev, size)
    else:
        bdev = '/dev/%s' % block_device

    if not is_block_device(bdev):
        error_out('Failed to locate valid block device at %s' % bdev)

    return bdev
94672
def get_string(self, input_string):
        

        if input_string in ('--input', '--outname', '--framework'):

            # was the flag set?
            try:
                index = self.args.index(input_string) + 1
            except ValueError:
                # it wasn't, so if it's required, exit
                if input_string in self.required:
                    print("\n {flag} is required".format(input_string))
                    print_short_help()
                    sys.exit(1)
                # it wasn't, if its optional, return the default
                else:
                    return None

                    # the flag was set, so check if a value was set, otherwise exit
            try:
                if self.args[index] in self.flags:
                    print("\n {flag} was set but a value was not specified".format(flag=input_string))
                    print_short_help()
                    sys.exit(1)
            except IndexError:
                print("\n {flag} was set but a value was not specified".format(input_string))
                print_short_help()
                sys.exit(1)

            # a value was set, so check and assign the appropriate value or exit
            if input_string == '--input':
                return os.path.abspath(self.args[index])
            elif input_string == '--outname':
                return format(self.args[index])
528554
def quick_str_input(prompt, default_value):
        
        valid = False
        str_val = default_value
        while not valid:
            input_val = raw_input(prompt + "[{0}]: ".format(default_value))

            if input_val == "":
                str_val = default_value
                valid = True
            else:
                try:
                    str_val = text_type(input_val)
                    valid = True

                except ValueError:
                    print("ERROR: must be text.")
                    valid = False

        return str_val
936919
def add_input(self, input_):
        
        if not isinstance(input_, Input):
            raise TypeError('`input_` must be a Input instance')
        self.inputs.append(input_)
1280026
def validate(self, inputs=None):
        
        # if no blocks...
        if not len(self._blocks):
            #TODO: find better error than ReliureError ?
            raise ReliureError("There is no block in this engine")
        # it block should be ok with it-self
        for block in self:
            block.validate()
        # check the inputs and outputs
        # note: fornow only the first block can have user given input
        available = set()       # set of available data
        maybe_available = set() # data that are produced be not required blocks
        # add the first block input as available data
        if inputs is not None:
            for in_name in inputs:
                available.add(in_name)
        else:
            # no inputs given, then consider that the first block input will be given
            if self.in_name is not None:
                for in_name in self.in_name:
                    available.add(in_name)
            else:
                # default input name if nothing specified
                available.add(Engine.DEFAULT_IN_NAME)
        needed = self.needed_inputs()
        miss = needed.difference(available)
        if len(miss):
            raise ReliureError("The following inputs are needed and not given: %s" % (",".join("'%s'" % in_name for in_name in miss)))
        no_need = available.difference(needed)
        if len(no_need):
            raise ReliureError("The following inputs are given but not needed: %s" % (",".join("'%s'" % in_name for in_name in no_need)))
        return
965796
def _to_python(input_string):
    ''' '''
    python_string = ''
    for i in range(len(input_string)):
        if not python_string:
            python_string += input_string[i].lower()
        elif input_string[i].isupper():
            python_string += '_%s' % input_string[i].lower()
        else:
            python_string += input_string[i]
    return python_string