Table Of Contents
Table Of Contents

quilt_lang package

Module contents

This is the one and only Quilt Lang file.

class quilt_lang.DictObject(_dict)

Bases: object

Fancier way of converting nested dictionary to an object!

Parameters:_dict (dictionary) – Already defined dictionary
>>> d = {'a': 1, 'b': {'c': 2}, 'd': ["hi", {'foo': "bar"}]}
>>> x = DictObject(d)
>>> x.b.c
2
>>> x.d[1].foo
'bar'
quilt_lang.absolutedir(relativedirectory)

Convert a relative directory to an absolute directory.

Parameters:relativedirectory (string) – The directory path to convert.
>>> absolutedir("src") # doctest: +SKIP
"C:/Users/richi/Documents/GitHub/quilt/src"
quilt_lang.amountdiv(number, minnum, maxnum)

Get the amount of numbers divisable by a number.

Parameters:
  • number (number) – The number to use.
  • minnum (integer) – The minimum number to check.
  • maxnum (integer) – The maximum number to check.
>>> amountdiv(20, 1, 15)
5
quilt_lang.autohard(equation)

Automatically solve a hard maths problem.

Parameters:equation (string) – The equation to solve.
>>> autohard("log 10")
2.302585092994046
quilt_lang.autosolve(equation)

Automatically solve an easy maths problem.

Parameters:equation (string) – The equation to calculate.
>>> autosolve("300 + 600")
900
quilt_lang.availchars(charactertype)

Get all the available characters for a specific type.

Parameters:charactertype (string) – The characters to get. Can be ‘letters’, ‘lowercase, ‘uppercase’, ‘digits’, ‘hexdigits’, ‘punctuation’, ‘printable’, ‘whitespace’ or ‘all’.
>>> availchars("lowercase")
'abcdefghijklmnopqrstuvwxyz'
quilt_lang.average(numbers, averagetype='mean')

Find the average of a list of numbers

Parameters:
  • numbers (list) – The list of numbers to find the average of.
  • averagetype (string) – The type of average to find.
>>> average([1, 2, 3, 4, 5], 'median')
3
quilt_lang.binboolflip(item)

Convert 0 or 1 to False or True (or vice versa). The converter works as follows:

  • 0 > False
  • False > 0
  • 1 > True
  • True > 1
Parameters:item (integer or boolean) – The item to convert.
>>> binboolflip(0)
False
>>> binboolflip(False)
0
>>> binboolflip(1)
True
>>> binboolflip(True)
1
>>> binboolflip("foo")
Traceback (most recent call last):
  ...
ValueError: Invalid item specified.
quilt_lang.case(text, casingformat='sentence')

Change the casing of some text.

Parameters:
  • text (string) – The text to change the casing of.
  • casingformat (string) – The format of casing to apply to the text. Can be ‘uppercase’, ‘lowercase’, ‘sentence’ or ‘caterpillar’.
Raises:

ValueError – Invalid text format specified.

>>> case("HELLO world", "uppercase")
'HELLO WORLD'
quilt_lang.catwalk(text)

Replace multiple spaces in a string with a single space.

Parameters:text (string) – The text to fix.
>>> catwalk("this  is    a long  sentence")
'this is a long sentence'
quilt_lang.charlimit()

Get the maximum amount of characters allowed by your system.

>>> charlimit() # doctest: +SKIP
9223372036854775807
quilt_lang.circleconvert(amount, currentformat, newformat)

Convert a circle measurement.

Parameters:
  • amount (number) – The number to convert.
  • currentformat (string) – The format of the provided value.
  • newformat (string) – The intended format of the value.
>>> circleconvert(45, "radius", "diameter")
90
quilt_lang.closeyear(year)

Find how many years away was the closest leap year to a specific year.

Parameters:year (number) – The year to check for.
quilt_lang.compare(value1, value2, comparison)

Compare 2 values

Parameters:
  • value1 (object) – The first value to compare.
  • value2 (object) – The second value to compare.
  • comparison (string) – The comparison to make. Can be “is”, “or”, “and”.
Returns:

If the value is, or, and of another value

Return type:

boolean

quilt_lang.constant(constanttype)

Get A Constant

quilt_lang.convertascii(value, command='to')

Convert an ASCII value to a symbol

Parameters:
  • value (string) – The text or the text in ascii form.
  • argument (string) – The action to perform on the value. Can be “to” or “from”.
quilt_lang.convertbase(number, base=10)

Convert a number in base 10 to another base

Parameters:
  • number (number) – The number to convert
  • base (integer) – The base to convert to.
quilt_lang.convertbinary(value, argument)

Convert text to binary form or backwards.

Parameters:
  • value (string) – The text or the binary text
  • argument (string) – The action to perform on the value. Can be “to” or “from”.
quilt_lang.converttabs(text, spaces=4)

Convert all the tabs to a specific amount of spaces

Parameters:
  • text (string) – The text to convert tabs to spaces on
  • spaces (integer) – The amount of spaces to replace tabs to.
quilt_lang.converttime(time, currentformat, newformat)

Convert a specific time format to another type.

Parameters:
  • time (integer) – The time to convert
  • currentformat (string) – The current format of the time. Can be milliseconds, seconds, minutes, hours, days, weeks, fortnights, years, decades, centuries or millenniums.
  • newformat (string) – The new format of the time. Can be milliseconds, seconds, minutes, hours, days, weeks, fortnights, years, decades, centuries or millenniums.
quilt_lang.cowsay(text='', align='centre')

Simulate an ASCII cow saying text.

Parameters:
  • text (string) – The text to print out.
  • algin – Where to align the cow. Can be ‘left’, ‘centre’ or ‘right’
quilt_lang.dayofweek(day, month, year, formatresult=True)

Get the day of the week for a specific day

Parameters:
  • day (integer) – The day to include in the search
  • month (integer) – The month to include in the search
  • year (integer) – The year to include in the search
  • formatresult (boolean) – Whether or not to format the result. A formatted date would look like: “Monday”. A non formatted date would look like: 1.
quilt_lang.decintfix(decorint=0)

Fix The Formatting Of Decimals And Integers

quilt_lang.decryptstring(enc, password)

Decrypt an encrypted string according to a specific password.

Parameters:
  • enc (string) – The encrypted text.
  • pass (string) – The password used to encrypt the text.
quilt_lang.delay(seconds)

Delay for a specific amount of seconds.

Parameters:seconds (number) – The amount of seconds to delay.
quilt_lang.dictflip(dictionary)

Flip the names and keys in a dictionary.

This means that this: {‘key1’: ‘value1’, ‘key2’: ‘value2’} will be converted into this: {‘value1’: ‘key1’, ‘value2’: ‘key2’}

Parameters:dictionary (dictionary) – The dictionary to flip.
quilt_lang.difference(num1, num2)

Find the difference between 2 numbers.

Parameters:
  • num1 (number) – The first number to use.
  • num2 (number) – The second number to use.
>>> difference(1, 4)
3
quilt_lang.dirtool(operation, directory)

Tools For Directories (If Exists, Make And Delete)

Raises:ValueError – Nor a string or a list was provided.
quilt_lang.divisable(num1, num2)

Check if a number is divisible by another number

Parameters:
  • num1 (number) – The first number to check.
  • num2 (number) – The second number to check.
>>> divisable(4, 2)
True
quilt_lang.encryptstring(text, password)

Encrypt a string according to a specific password.

Parameters:
  • text (string) – The text to encrypt.
  • pass (string) – The password to encrypt the text with.
quilt_lang.equation(operation, firstnum, secondnum)

Solve a simple maths equation manually

quilt_lang.euler(faces, edges, verticies)

Calculate the value of Euler’s formula of a shape.

Parameters:
  • faces (integer) – The faces of the shape
  • edges (integer) – The edges of the shape
  • verticies (integer) – The verticies of the shape
Returns:

The result of the euler operation

Return type:

number

quilt_lang.exitexec(arguments=0)

Exit the current execution

quilt_lang.factorial(n)

Find the factorial of a number

quilt_lang.factors(number)

Find all of the factors of a number and return it as a list.

Parameters:number (integer) – The number to find the factors for.
quilt_lang.file(operation, path)

Tools For Files (If Exists, Make And Delete)

quilt_lang.filedownload(source, destination)

Download a file and save it to a specific destination

Parameters:
  • source (string) – The url to download from
  • destination (string) – The path to save the file to
quilt_lang.flipcoords(xcoord, ycoord, axis)

Flip the coordinates over a specific axis, to a different quadrant

Parameters:
  • xcoord (integer) – The x coordinate to flip
  • ycoord (integer) – The y coordinate to flip
  • axis (string) – The axis to flip across. Could be ‘x’ or ‘y’
quilt_lang.fracsimplify(numerator, denominator)

Simplify a fraction.

Parameters:
  • numerator (integer) – The numerator of the fraction to simplify
  • denominator (integer) – The denominator of the fraction to simplify
Returns:

The simplified fraction

Return type:

list

quilt_lang.getbrowser()

Get the name of the browser currently being used

quilt_lang.getdatetime(timedateformat='complete')

Get the current date or time in a specific format.

Parameters:timedateformat (string) – The type of date to query for. Can be: day, month, year, hour, minute, second, millisecond, yearmonthday, daymonthyear, hourminutesecond, secondminutehour, complete, datetime or timedate.
quilt_lang.getletter(variable, letternumber)

Get the corresponding item in a object

Parameters:
  • variable (string) – The string to get the letter from
  • letternumber (integer) – The index of the letter to get
quilt_lang.getplatform()

Get the current system platform.

quilt_lang.gettype(value)

Get the type of an object

Parameters:value (string) – The object to check.
quilt_lang.happybirthday(person)

Sing Happy Birthday

quilt_lang.hcf(num1, num2)

Find the highest common factor of 2 numbers

Parameters:
  • num1 (number) – The first number to find the hcf for
  • num2 (number) – The second number to find the hcf for
quilt_lang.isfalse(variable)

Check if a variable is essentially “False”

Parameters:variable (variable) – The variable to check
quilt_lang.isfib(number)

Check if a number is in the Fibonacci sequence.

Parameters:number (integer) – Number to check
quilt_lang.isnum(value)

Check if a value is a type of number (decimal or integer).

Parameters:value (object) – The value to check.
quilt_lang.isonline()

Check if you are currently connected to the internet.

quilt_lang.isprime(number)

Check if a number is a prime number

Parameters:number (integer) – The number to check
quilt_lang.isrealnum(variable)

Check if the variable resembles a rational number.

quilt_lang.jointext(firststring, secondstring)

Join two strings together

Parameters:
  • firststring (string) – The first string.
  • secondstring (string) – The second string.
quilt_lang.lcm(num1, num2)

Find the lowest common multiple of 2 numbers

Parameters:
  • num1 (number) – The first number to find the lcm for
  • num2 (number) – The second number to find the lcm for
quilt_lang.leadingzero(number, minlength)

Add leading zeros to a number.

Parameters:
  • number (number) – The number to add the leading zeros to.
  • minlength (integer) – If the number is shorter than this length than add leading zeros to make the length correct.
Returns:

The number with a leading zero

Return type:

string

>>> leadingzero(1, 2)
'01'
quilt_lang.leapyear(year)

Check if a year in particular is a leap year

Parameters:year (integer) – The year to check for
quilt_lang.length(value)

Find the length of a value

Parameters:value (variable) – The value to find the length of
quilt_lang.letternum(letter)

Get The Number Corresponding To A Letter

quilt_lang.logfile(targetfile='ros.log')

Set the file for Quilt to log to targetfile: Change the file to log to.

quilt_lang.loglevel(leveltype=None, isequal=False)

Set or get the logging level of Quilt

Parameters:
  • leveltype (string or integer) – Choose the logging level. Possible choices are none (0), debug (10), info (20), warning (30), error (40) and critical (50).
  • isequal (boolean) – Check if level is equal to leveltype.
Returns:

If the level is equal to leveltype.

Return type:

boolean

>>> loglevel()
30
quilt_lang.mailto(to, cc=None, bcc=None, subject=None, body=None)

Generate and run mailto.

Parameters:
  • to (string) – The recipient email address.
  • cc (string) – The recipient to copy to.
  • bcc (string) – The recipient to blind copy to.
  • subject (string) – The subject to use.
  • body (string) – The body content to use.
quilt_lang.maxyear()

Get the maxiumum year allowed by the current OS.

quilt_lang.minyear()

Get the minimum year allowed by the current OS.

quilt_lang.modulereload(modulename)

Reload a module.

Parameters:modulename (module) – Name of module to reload.
quilt_lang.newline(lines=1)

Print 1 or more paragraph spaces in the terminal.

Parameters:lines (integer) – The amount of paragraph spaces to print.
quilt_lang.newtab(url)

Open a URL in a new tab of a web browser.

Parameters:url (string) – The url to open.
Raises:webbrowser.Error – Unable to open URL
quilt_lang.newwindow(url)

Open a URL in a new window of a web browser.

Parameters:url (string) – The url to open.
Raises:webbrowser.Error – Unable to open URL
quilt_lang.numlistbetween(num1, num2, option='list', listoption='string')

List Or Count The Numbers Between Two Numbers

quilt_lang.numprop(value, propertyexpected)

Check If A Number Is A Type

quilt_lang.onlist(listtocheck, item)

Check if something is on a list.

Parameters:
  • listtocheck (list) – The list to check.
  • item (object) – The item to check if on the list.
quilt_lang.openurl(url)

Open a URL in a web browser.

Parameters:url (string) – The url to open.
Raises:webbrowser.Error – Unable to open URL
quilt_lang.pipinstall(packages)

Install one or more pip packages.

Parameters:packages (string or list) – The package or list of packages to install.
Raises:TypeError – Nor a string or a list was provided.
quilt_lang.pipupdate()

Update all currently installed pip packages

quilt_lang.posnegtoggle(number)

Toggle a number between positive and negative. The converter works as follows:

  • 1 > -1
  • -1 > 1
  • 0 > 0
Parameters:number (number) – The number to toggle.
quilt_lang.power(number, power)

Find The Power Of A Number

quilt_lang.printmessage(text, amount=1)

Print out a console message.

Parameters:
  • text (string) – The text to print out.
  • amount (integer) – The amount of times to print it out.
quilt_lang.pyexec()

Get the executable used by Python

quilt_lang.pykeyword(operation='list', keywordtotest=None)

Check if a keyword exists in the Python keyword dictionary.

Parameters:
  • operation (string) – Whether to list or check the keywords. Possible options are ‘list’ and ‘in’.
  • keywordtotest (string) – The keyword to check.
Returns:

The list of keywords or if a keyword exists.

Return type:

list or boolean

>>> "True" in pykeyword("list")
True
>>> pykeyword("in", "True")
True
>>> pykeyword("in", "foo")
False
>>> pykeyword("foo", "foo")
Traceback (most recent call last):
  ...
ValueError: Invalid operation specified.
quilt_lang.pyname(ifmain=False)

Get the value of __name__

Parameters:ifmain (boolean) – If set to True then True will be returned if __name__ is equal to __main__
Returns:The value of __name__ or if ifmain is True, then if __name__ is equal to __main__
Return type:string or boolean
quilt_lang.pythrule(first, second)

Calculate the area of a right angled trangle based on Pythagoras’ Theorem

Parameters:
  • first (number) – The length of the first axis (x or y)
  • second (number) – The length of the second axis (x or y)
quilt_lang.pyversion(part=None)

Get the version of Python

quilt_lang.quadrant(xcoord, ycoord)

Find the quadrant a pair of coordinates are located in

Parameters:
  • xcoord (integer) – The x coordinate to find the quadrant for
  • ycoord (integer) – The y coordinate to find the quadrant for
quilt_lang.randomnum(minimum=1, maximum=2, seed=None)

Generate a random number.

Parameters:
  • minimum (integer) – The minimum number to generate.
  • maximum (integer) – The maximum number to generate.
  • seed (integer) – A seed to use when generating the random number.
Returns:

The randomized number.

Return type:

integer

Raises:
  • TypeError – Minimum number is not a number.
  • TypeError – Maximum number is not a number.
>>> randomnum(1, 100, 150)
42
quilt_lang.randomstr(valuelist)

Choose a random item from a list.

Parameters:valuelist (list) – The list to choose a random item from.
Raises:IndexError – List not specified.
quilt_lang.randstring(length=1)

Generate a random string consisting of letters, digits and punctuation

Parameters:length (integer) – The length of the generated string.
quilt_lang.replacetext(string, texttofind, texttoreplace)

Replace text with other text.

Parameters:
  • string (string) – The string with the text to replace.
  • texttofind (string) – The text to look for in the string.
  • texttoreplace (string) – The text to replace the matching text with.
quilt_lang.reverselist(listtoreverse)

Reverse a list.

Parameters:listtoreverse (list) – The list to reverse
quilt_lang.reversetext(contenttoreverse, reconvert=True)

Reverse any content

Parameters:
  • contenttoreverse (string) – The content to be reversed
  • reeval (boolean) – Wether or not to reconvert the object back into it’s initial state. Default is “True”.
quilt_lang.rounddown(number)

Round down a number

Parameters:number (number) – The number to round down
quilt_lang.sametype(variable1, variable2)

Check if 2 variables have the same type

Parameters:
  • variable1 (variable) – The first variable to check
  • variable2 (variable) – The second variable to check
>>> sametype(True, False)
True
>>> sametype(True, "foo")
False
quilt_lang.scientific(number, operation, number2=None, logbase=10)

Solve scientific operations manually

quilt_lang.shapesides(inputtocheck, inputtype='shape')

Get the sides of a shape.

inputtocheck: The amount of sides or the shape to be checked, depending on the value of inputtype.

inputtype: The type of input provided. Can be: ‘shape’, ‘sides’.

quilt_lang.shellcommand(command)

Execute a command in the host’s terminal/shell/bash command: Specify the command to be executed

quilt_lang.shellinput(initialtext='>> ', splitpart=' ')

Give the user a shell-like interface to enter commands which are returned as a multi-part list containing the command and each of the arguments.

Parameters:
  • initialtext (string) – Set the text to be displayed as the prompt.
  • splitpart (string) – The character to split when generating the list item.
Returns:

A string of the user’s input or a list of the user’s input split by the split character.

Return type:

string or list

quilt_lang.shortentext(text, minlength, placeholder='...')

Shorten some text by replacing the last part with a placeholder (such as ‘…’)

Parameters:
  • text (string) – The text to shorten
  • minlength (integer) – The minimum length before a shortening will occur
  • placeholder (string) – The text to append after removing protruding text.
quilt_lang.sigmoid(number)

Find the sigmoid of a number.

Parameters:number (number) – The number to find the sigmoid of
Returns:The result of the sigmoid
Return type:number
>>> sigmoid(1)
0.7310585786300049
quilt_lang.spacelist(listtospace, spacechar=' ')

Convert a list to a string with all of the list’s items spaced out.

Parameters:
  • listtospace (list) – The list to space out.
  • spacechar (string) – The characters to insert between each list item. Default is: ” “.
quilt_lang.splitstring(string, splitcharacter=' ', part=None)

Split a string based on a character and get the parts as a list.

Parameters:
  • string (string) – The string to split.
  • splitcharacter (string) – The character to split for the string.
  • part (integer) – Get a specific part of the list.
Returns:

The split string or a specific part of it

Return type:

list or string

>>> splitstring('hello world !')
['hello', 'world', '!']
>>> splitstring('hello world !', ' ', None)
['hello', 'world', '!']
>>> splitstring('hello world !', ' ', None)
['hello', 'world', '!']
>>> splitstring('hello world !', ' ', 0)
'hello'
quilt_lang.squareroot(number)

Find The Square Root Of A Number

quilt_lang.tempdir()

Generate and get a path to a temporary directory

quilt_lang.text(path, operation, content)

Perform changes on text files

Parameters:
  • path (string) – The path to perform the action on
  • operation (string) – The operation to use on the file
  • content (string) – The content to use with the operation
quilt_lang.textalign(text, maxlength, align='left')

Align Text When Given Full Length

quilt_lang.textbetween(variable, firstnum=None, secondnum=None, locationoftext='regular')

Get The Text Between Two Parts

quilt_lang.timeit(command, round_result=True)

Time how long a command takes to execute

command: The command to time.

round_result: Whether or not to round the number to an integer.

quilt_lang.timesince()

Get the amount of time since 00:00 on 1 January 1970, the raw date before formatting it.

quilt_lang.timezone()

Get the current timezone code.

quilt_lang.tokhex(length=10, urlsafe=False)

Return a random string in hexadecimal

quilt_lang.typematch(variable, expectedtype)

Check if a variable is a specific type

Parameters:
  • variable (variable) – The variable to check the type of
  • expectedtype (type) – The type to check against
>>> typematch(True, bool)
True
>>> typematch("foo", str)
True
>>> typematch(True, str)
False
>>> binboolflip("foo")
Traceback (most recent call last):
  ...
ValueError: Invalid item specified.
quilt_lang.unilimit()

Get The Highest Unicode Value

quilt_lang.unindent(text)

Remove indention for some text

Parameters:text (string) – The text to unindent
quilt_lang.userinput(prompttext='', times=1)

Get the input of the user via a universally secure method.

Parameters:
  • prompttext (string) – The text to display while receiving the data.
  • times (integer) – The amount of times to ask the user. If value is not 1, a list will be returned. Default is 1.
Returns:

What the user typed in.

Return type:

string

quilt_lang.waitenter(times=1)

Wait for the user to press enter.

Parameters:times (integer) – The times to ask for the user to press enter.
quilt_lang.warnconfig(action='default')

Configure the Python warnings.

Parameters:action (string) – The configuration to set. Options are: ‘default’, ‘error’, ‘ignore’, ‘always’, ‘module’ and ‘once’.
quilt_lang.wordvalue(word)

Get the value of each letter of a string’s position in the alphabet added up

Parameters:word (string) – The word to find the value of
quilt_lang.wraptext(text, maxlength)

Wrap text around the execution window according to a given size

Parameters:
  • text (string) – The text to be wraped
  • maxlength (integer) – The amount of text until a wrap will be added

Constants

quilt_lang. about
About information
quilt_lang. ready
A constant which can be checked to verify if Quilt is ready.