First prune of top level directory HACK-SLASH-BURN-BEGINS
authorMark Tearle <mark@tearle.com>
Sat, 8 Nov 2014 13:51:15 +0000 (21:51 +0800)
committerMark Tearle <mark@tearle.com>
Sat, 8 Nov 2014 13:51:15 +0000 (21:51 +0800)
BankAccount.py [deleted file]
DispenseServer.py [deleted file]
codesnippets/horizscroll.py [deleted file]

diff --git a/BankAccount.py b/BankAccount.py
deleted file mode 100644 (file)
index 6565b65..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-import pickle
-
-ACCOUNT_FILE = 'bank.pck'
-
-class BankAccount:
-       def __init__(self):
-               f = None
-               self.bank = {}
-               try:
-                       f = open(ACCOUNT_FILE)
-               except IOError:
-                       pass
-               if f != None:
-                       self.bank = pickle.load(f)
-                       self.sanity_check(self.bank)
-                       f.close()
-               self.save()
-
-       def sanity_check_user(self, user):
-               wanted_fields = ['balance']
-               for f in user:
-                       if f in wanted_fields:
-                               if f == 'balance':
-                                       if not isinstance(user['balance'], tuple):
-                                               return False
-                                       if len(user['balance']) != 2:
-                                               return False
-                                       if not isinstance(user[0], int) or \
-                                                       not isinstance(user[1], int):
-                                               return False
-                               del wanted_fields[f]
-                       else:
-                               return False
-               if len(wanted_fields) != 0:
-                       return False
-               return True
-                       
-       def sanity_check(self, bank):
-               for u in bank:
-                       if not self.sanity_check_user(u):
-                               return False
-               return True
-
-       def save(self):
-               f = open(ACCOUNT_FILE, 'w')
-               pickle.dump(self.bank, f)
-               f.close()
-
-       def ensure_user_exists(self, username):
-               if self.bank.has_key(username):
-                       return
-               self.bank[username] = {}
-               self.bank[username]['balance'] = (0,0)
-
-       def get_balance(self, username):
-               if self.bank.has_key(username):
-                       return self.bank[username]['balance']
-               return (0,0)
-
-       def add_amount(self, username, amount):
-               self.ensure_user_exists(username)
-               (cur_cents, cur_bytes) = self.bank[username]['balance']
-               (add_cents, add_bytes) = amount
-               self.bank[username]['balance'] = (cur_cents+add_cents,
-                       cur_bytes+add_bytes)
-               self.save()
diff --git a/DispenseServer.py b/DispenseServer.py
deleted file mode 100755 (executable)
index afbb78f..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/python
-
-from SOAPpy import *
-from BankAccount import BankAccount
-
-namespace = 'Dispense'
-bind_port = 9900
-
-server = None
-
-def hello():
-       return "hello"
-
-if __name__ == '__main__':
-       server = SOAPServer(('0.0.0.0', 9900))
-       bank = BankAccount()
-       for f in [hello]:
-               server.registerFunction(f, namespace)
-       print "Serving forever ..."
-       server.serve_forever()
diff --git a/codesnippets/horizscroll.py b/codesnippets/horizscroll.py
deleted file mode 100644 (file)
index 5dca529..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/usr/bin/env python
-
-import string
-import sys
-import time
-
-class HorizScroll:
-       def __init__(self, text):
-               self.text = text
-               pass
-
-       def expand(self, padding=None, paddingchar=" ", dir=None):
-               if len(self.text) <= 10:
-                       return [text]
-
-               if not padding:
-                       padding = len(self.text) / 2
-
-               format = "%-" + str(padding) + "." + str(padding) + "s"
-               pad = string.replace(format % " "," ",paddingchar)
-               padtext = self.text + pad
-               expansion = []
-
-               for x in range(0,len(padtext)):
-                         expansion.append(padtext[x:] + padtext[:x])
-               
-               if dir == -1:
-                       expansion.reverse()
-
-               return expansion
-
-if __name__ == '__main__':
-       h = HorizScroll("hello cruel world")
-       eh = h.expand()
-       while 1:
-               for x in eh:
-                       sys.stdout.write("\r")
-                       print "%-10.10s" % x,
-                       sys.stdout.flush()
-                       time.sleep(0.1)
-

UCC git Repository :: git.ucc.asn.au