collection of useful python functions
Project description
ssutils
collection of useful python functions
Screenwriter
Use Screenwriter to prefix screen prints
Examples:
1 - Default prefix
from ssutils import Screenwriter
sw = Screenwriter ()
sw.echo ('my output')
Output:
2019-07-26-11:16:04 my output
2 - Date Time parts in prefix
from ssutils import Screenwriter
sw = Screenwriter ('%Y-%m-%d %H:%M:%S.%f ')
sw.echo ('my output')
Output:
2019-07-26 11:16:04 my output
3 - Error, Warning & Info standard prefixes
from ssutils import Screenwriter
sw = Screenwriter ()
sw.error ('an error message')
sw.warn ('a warming message')
sw.info ('an informational message')
Output:
2019-07-29-11:39:00 ERROR: an error message
2019-07-29-11:39:00 WARN: a warming message
2019-07-29-11:39:00 INFO: an informational message
4 - Trimming content length
By default, log strings are trimmed to 1000 chars. You can change this setting:
from ssutils import Screenwriter
sw = Screenwriter ()
sw.set_maxlen (80) #Set maximum length to 80
For format options, see http://strftime.org/
Sfdc
Use Sfdc to Query SFDC.
Examples:
1 - List Objects
from ssutils import Sfdc
sf = Sfdc('userid', 'password', 'token', False) # last Param turns off verbose
sf.connect ()
sf.load_metadata ()
for apin in sf.object_labels.keys():
print ("API Name [" + apin + "], Label [" + sf.object_labels[apin] + "]")
for apin in sf.standard_object_names:
print ("Standard Object [" + apin + "]")
for apin in sf.custom_object_names:
print ("Custom Object [" + apin + "]")
for apin in sf.custom_setting_names:
print ("Custom Setting [" + apin + "]")
2 - Describe Objects
from ssutils import Sfdc
sf = Sfdc('userid', 'password', 'token')
sf.connect ()
sf.load_metadata ()
def print_line (a, b, c, d, e):
s = '{:7}'.format(a) + '{:50}'.format(b) + '{:20}'.format(c) + '{:20}'.format(d) + e
print (s)
print_line ('Seq', 'API Name', 'Type', 'Length', 'Label')
print_line ('---', '--------', '----', '------', '-----')
fn = 1
for fld in sf.describe_object ('Contact'):
pfx = "#" + str(fn).ljust(3) + " - "
print_line (pfx, fld['name'], fld['type'], str(fld['length']), fld['label'])
fn += 1
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ssutils-0.3.0.tar.gz
(3.0 kB
view hashes)