Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'sugar/util.py')
-rw-r--r--sugar/util.py62
1 files changed, 31 insertions, 31 deletions
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()