def __init__(*args): """push credentials into login fields and start thread""" args = list(args) self = args.pop(0) self._args = args self._events = [] self._urls = _urls self._running = True self._time = time() self.friends = {} self.sales = Pdict(os.path.join(os.path.dirname(__file__), "sales")) self.interval = 15 self.empty = False Thread.__init__(self) self.start()
def __init__(self, path, data={}): Pdict.__init__(self, path) Odict.__init__(self, data)
#! /usr/bin/python import sys from os.path import dirname, exists, join as pathjoin from locale import setlocale, LC_ALL, format from tools import Pdict, Odict args = sys.argv[1:] if not args: args = ("Location", "Product") setlocale(LC_ALL, "") sales = Pdict(pathjoin(dirname(__file__), "sales")) paddings = [max([max([len(sale["name"]), len(sale["item"]), len(sale["location"])]) for sale in sales.values()]), 10, 6] def cleanup(): # perform one-time clean up of sales data corrupted by # Linden Lab's change from 10 char IDs to 36 char IDs with # no defined way of comparing a sale that was recorded twice # with each type of id cleaned_file = pathjoin(dirname(__file__), "ll_id_change_cleaned") if exists(cleaned_file): return f = open(cleaned_file, "w") f.write("done") f.close() sale_str = "%(date)s%(name)s%(item)s" new_values = [sale_str % v for k, v in sales.items() if len(k) == 36] if len(new_values) == len(sales):
from os.path import dirname, join as pathjoin from os import startfile from sys import argv from tools import Pdict path = lambda f: pathjoin(dirname(__file__), f) product = "" if len(argv) < 2 else argv[1] print argv[1] csv = path("customers%s.csv" % ("" if not product else "_%s" % product.lower().replace(" ", "_"))) sales = Pdict(path("sales")) customers = set([sale["name"] for sale in sales.values() if not product or product == sale["item"]]) try: f = open(csv, "w") f.write("\n".join(customers)) f.close() except IOError, e: print "failed to create customer csv file: %s" % e else: startfile(csv)
#! /usr/bin/python import sys from os.path import dirname, exists, join as pathjoin from locale import setlocale, LC_ALL, format from tools import Pdict, Odict args = sys.argv[1:] if not args: args = ("Location", "Product") setlocale(LC_ALL, "") sales = Pdict(pathjoin(dirname(__file__), "sales")) paddings = [ max([ max([len(sale["name"]), len(sale["item"]), len(sale["location"])]) for sale in sales.values() ]), 10, 6 ] def cleanup(): # perform one-time clean up of sales data corrupted by # Linden Lab's change from 10 char IDs to 36 char IDs with # no defined way of comparing a sale that was recorded twice # with each type of id cleaned_file = pathjoin(dirname(__file__), "ll_id_change_cleaned") if exists(cleaned_file): return f = open(cleaned_file, "w") f.write("done")