Gold Dust
Gold Dust is a python module to import into your scripts, it includes code that can be completed in one line that would usually take multiple lines to perform.
For changes see commits
Documentation
Getting Started With Gold Dust
Using Gold Dust is easy, just download the .py file from the source folder and import it into the same folder of your script. Afterwards, in your script enter:
import golddust
To use gd or an other name instead of golddust, include in your script:
import golddust as gd
where gd is the name you want to change it to. Then you will be able to enter the name you have chosen followed by the function, for example:
gd.numbers.isprime(1)
For other infomation you can run the script directly, this will also show if your system is fully configured for Gold Dust as well as a place to test commands.
Times
times.gettime()
Shows the time
Usage:
golddust.times.gettime(splitter=":", seconds=True)
Output:
'12:40:12'
times.getdate()
Shows the date
Usage:
golddust.times.getdate(splitter="/", american=False)
Output:
'19/11/2015'
times.gettimezone()
Shows the time in different timezones
Usage:
golddust.times.gettimezone(tz="US/Pacific", splitter=":", seconds=True)
Output:
'04:40:12'
times.listtimezones()
Lists all the timezones that can be used with gettimezone() command
Usage:
golddust.times.listtimezones()
Output:
'Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers'
Output shortened
Internet
internet.get_url()
Gets webpage from url given
Usage:
golddust.internet.get_url('http://google.co.uk')
Output:
'<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en-GB"><head><meta content="/images/branding/g
oogleg/1x/googleg_standard_color_128dp.png" itemprop="image"><title>Google</title><script>(function(){window.google={kEI:\'P
ORMVsChG4Wq0gT4jIv4Aw\',kEXPI:\'3700320,4014789,4029815,4031109,4032677,4033307,4034332,403652'
Output shortened
internet.remove_html()
Returns text without html tags
Usage:
golddust.internet.remove_html(golddust.internet.get_url('http://google.co.uk'))
Output:
'Google Search Images Maps Play YouTube News Gmail Drive More »Web History | Settings | Sign in ×
A better way to browse the web Get Google Chrome UK Advanced searchLanguage toolsAdvertising Progr
ammesBusiness Solutions+GoogleAbout GoogleGoogle.com© 2015 - Privacy - Terms'
internet.public_ip()
Returns users Public IP
Usage:
golddust.internet.public_ip()
Output:
The public IP is returned
internet.local_ip()
Returns users Local IP
Usage:
golddust.internet.local_ip()
Output:
The local IP is returned
internet.location.city()
Returns City of users IP address
Usage:
golddust.internet.location.city()
Output:
City of IP address is returned
internet.location.region()
Returns Region of users IP address
Usage:
golddust.internet.location.region()
Output:
Region of IP address is returned
internet.location.country
Returns Country of users IP address
Usage:
golddust.internet.location.country()
Output:
Country of IP address is returned
internet.location.postal()
Returns Postal Address of users IP address
Usage:
golddust.internet.location.postal()
Output:
Postal code of IP address is returned
Numbers
numbers.isprime()
Returns true if number is prime
Usage:
golddust.numbers.isprime('5')
Output:
True
Saving and Loading
sl.save()
Saves string to file
Usage:
string = 'hello world'
golddust.sl.save(string, 'save.dat')
Output:
string is saved to save.dat
sl.load()
Loads string from file
Usage:
golddust.sl.load('save.dat')
Output:
'hello world'
sl.zip()
Zips a file
Usage:
golddust.sl.zip('zipfile.zip', 'save.dat', deleteafter=True)
Output:
save.dat is now zipped into zipfile.zip and save.dat is deleted
sl.unzip()
Unzips a .zip file
Usage:
golddust.sl.unzip('zipfile.zip')
Output:
zipfile.zip is now unzipped
sl.addtozip()
Adds a file to already existing zip
Usage:
golddust.sl.addtozip('zipfile.zip', 'save.dat', deleteafter=True)
Output:
save.dat is now zipped into zipfile.zip and save.dat is deleted
sl.write()
Writes text to a file
Usage:
string = 'hello world'
golddust.sl.write('text.txt', string)
Output:
string is written to text.txt
Strings
strings.tobinary()
Converts string to binary
Usage:
golddust.strings.tobinary('hello world')
Output:
'01101000 01100101 01101100 01101100 01101111 00100000 01110111 01101111 01110010 01101100 01100100 '
strings.toascii()
Converts string to ascii
Usage:
golddust.strings.toascii('01101000 01100101 01101100 01101100 01101111 00100000 01110111 01101111 01110010 01101100 01100100 ')
Output:
'hello world'
strings.nonum()
Removes numbers from string
Usage:
golddust.strings.nonum('h1e2l3l4o5w6o7r8l9d0')
Output:
'helloworld'
strings.slow_print()
Prints each letter of a string with a delay
Usage:
golddust.strings.slow_print('hello world', 0.15)
Output:
'hello world'
'hello world' printed with 0.15 delay in between each letter
Other
other.username()
Returns the username of the current user
Usage:
golddust.other.username()
Output:
'Jake'
other.pipupgrade()
Upgrades all modules installed by pip
Usage:
golddust.other.pipupgrade()
Output:
All modules installed by pip would be upgraded
other.cmd()
Runs a command in cmd
Usage:
golddust.other.cmd('echo hello world')
Output:
hello world
other.speak()
TTS, Speaks string out loud
Usage:
golddust.other.speak('hello world')
Output:
Hello World is spoken
other.password()
Equivalent to input() but doesn't show user input
Usage:
golddust.other.password('Enter password: ')
Output:
Returns users input
other.get_os()
Returns the users operating system
Usage:
golddust.other.get_os()
Output:
Below is table of what is returned for each os:
OS | Returned String |
---|---|
Windows | 'windows' |
Linux | 'linux' |
Mac OS X | 'mac os x' |