From b9f9ef0fe9e36cf6e5de59700154b16f2dae15cd Mon Sep 17 00:00:00 2001 From: Justin Gallardo Date: Mon, 04 Dec 2006 19:12:24 +0000 Subject: Changed all tabs to 4 spaces for python style --- (limited to 'sugar/util.py') diff --git a/sugar/util.py b/sugar/util.py index 108c48e..8ad840d 100644 --- a/sugar/util.py +++ b/sugar/util.py @@ -25,50 +25,50 @@ from ConfigParser import ConfigParser from ConfigParser import NoOptionError def printable_hash(in_hash): - """Convert binary hash data into printable characters.""" - printable = "" - for char in in_hash: - printable = printable + binascii.b2a_hex(char) - return printable + """Convert binary hash data into printable characters.""" + printable = "" + for char in in_hash: + printable = printable + binascii.b2a_hex(char) + return printable def _sha_data(data): - """sha1 hash some bytes.""" - sha_hash = sha.new() - sha_hash.update(data) - return sha_hash.digest() + """sha1 hash some bytes.""" + sha_hash = sha.new() + sha_hash.update(data) + return sha_hash.digest() def unique_id(data = ''): - data_string = "%s%s%s" % (time.time(), random.randint(10000, 100000), data) - return printable_hash(_sha_data(data_string)) + data_string = "%s%s%s" % (time.time(), random.randint(10000, 100000), data) + return printable_hash(_sha_data(data_string)) ACTIVITY_ID_LEN = 40 def is_hex(s): - return s.strip(string.hexdigits) == '' + return s.strip(string.hexdigits) == '' def validate_activity_id(actid): - """Validate an activity ID.""" - if not isinstance(actid, str) and not isinstance(actid, unicode): - return False - if len(actid) != ACTIVITY_ID_LEN: - return False - if not is_hex(actid): - return False - return True + """Validate an activity ID.""" + if not isinstance(actid, str) and not isinstance(actid, unicode): + return False + if len(actid) != ACTIVITY_ID_LEN: + return False + if not is_hex(actid): + return False + return True class _ServiceParser(ConfigParser): - def optionxform(self, option): - return option + def optionxform(self, option): + return option def write_service(name, bin, path): - service_cp = _ServiceParser() - section = 'D-BUS Service' - service_cp.add_section(section) - service_cp.set(section, 'Name', name) - service_cp.set(section, 'Exec', bin) + service_cp = _ServiceParser() + section = 'D-BUS Service' + service_cp.add_section(section) + service_cp.set(section, 'Name', name) + service_cp.set(section, 'Exec', bin) - dest_filename = os.path.join(path, name + '.service') - fileobject = open(dest_filename, 'w') - service_cp.write(fileobject) - fileobject.close() + dest_filename = os.path.join(path, name + '.service') + fileobject = open(dest_filename, 'w') + service_cp.write(fileobject) + fileobject.close() -- cgit v0.9.1