예제 #1
0
 def store(self):
     now = datetime.datetime.now()
     total = 0
     for site in self.sites:
         v = getattr(self, site)
         m = v()
         num = m.replace("$", "")
         total += Decimal(num)
         site_list = dumper.load(site, silent=True, path=BASE_DIR) or []
         site_list.append({'site': site, 'datetime': now, 'total': num})
         dumper.dump(site_list, site, path=BASE_DIR)
     total_list = dumper.load('total', silent=True, path=BASE_DIR) or []
     total_list.append({'site': total, 'datetime': now, 'total': total})
     dumper.dump(total_list, "total", path=BASE_DIR)
     print "store file {}".format(now)
예제 #2
0
def main():
    parser = argparse.ArgumentParser(description='Formatter for C language')
    parser.add_argument('--train', dest='train', type=str, help='Train classifier on that folder')
    parser.add_argument('--classifier_filename', dest='classifier_filename', type=str, default='linux_classificators.data',
                        help='In which file save classifier')
    parser.add_argument('--clftab', dest='clftab', type=str,
                        choices=['solving_tree', 'kneighbors', 'svm', 'random_forest'], default='random_forest',
                        help='Type of classifier for tabs')
    parser.add_argument('--clfspace', dest='clfspace', type=str,
                        choices=['solving_tree', 'kneighbors', 'svm', 'random_forest'], default='random_forest',
                        help='Type of classifier for spaces')
    parser.add_argument('--clfnl', dest='clfnewline', type=str,
                        choices=['solving_tree', 'kneighbors', 'svm', 'random_forest'], default='random_forest',
                        help='Type of classifier for newlines')
    parser.add_argument('--load_clfs', dest='clfs', type=str, help='Load previously saved classifiers')
    parser.add_argument('file', help='File to process', nargs='?')
    args = parser.parse_args()

    clfs = None
    if args.train is not None:
        clfs = learning.generate_classifiers(args)
        dumper.dump(clfs, learning.vectorizer, args.classifier_filename)

    elif args.clfs is not None:
        data = dumper.load(args.clfs)
        clfs = data['classifiers']
        learning.vectorizer = data['vectorizer']

    if args.file is not None:
        print("Processing file...")
        data = learning.format_file(args.file, clfs['newline'], clfs['space'], clfs['tab'])
        print(data)
예제 #3
0
 def graph_site(self, site):
     x, y, data = [], [], []
     site_list = dumper.load(site, path=BASE_DIR)
     y_old = float(site_list[0]["total"])
     for i in site_list:
         t = float(i["total"]) - y_old
         y_old = float(i["total"])
         if t != 0:
             x.append(i['datetime'])
             y.append(t)
     data.append(go.Scatter(x=x, y=y, name=site))
     l = dict(layout={'title': site}, data=data)
     print(site,
           py.plot(l, filename=site, fileopt="overwrite", auto_open=False))
예제 #4
0
def main():
    nimilista = {}
    nimilista = dumper.load()
    mainwindow = tkinter.Tk()
    mainwindow.wm_title('Asiakashallintaohjelmisto')
    menubar = tkinter.Menu(mainwindow)

    #mainwindow.iconbitmap(default='transparent.ico') keksi uusi ikoni
    asiakasGUI = AsiakasGUI(nimilista,mainwindow)
    menubar.add_command(label='Lataa',command=lambda: asiakasGUI.newlistbox(1))
    menubar.add_command(label='Tallenna',command=lambda: asiakasGUI.newlistbox(2))
    mainwindow.protocol("WM_DELETE_WINDOW",asiakasGUI.eventhandler)
    mainwindow.config(menu=menubar)
    mainwindow.mainloop()
예제 #5
0
 def newlistbox(self,choice):
     if choice == 1:
         dumper.dump(self.nimilista)
         self.nimilista = {}
         a = tkinter.simpledialog.askstring('Anna etsittävän tiedoston nimi', 'Tiedoston nimi:')
         self.nimilista = dumper.specificload(a)
         if self.nimilista == {}:
             tkinter.messagebox.showinfo('File not found','Specific file not found')
             self.nimilista = dumper.load()
         self.listbox.delete(0,'end')
         for i in self.nimilista:
             self.listbox.insert('end',i)
     if choice == 2:
         a = tkinter.simpledialog.askstring('Anna tallennettavan tiedoston nimi','Tiedoston nimi: ')
         dumper.specificdump(self.nimilista,a)
예제 #6
0
 def graph_total(self):
     data = dumper.load("total", path=BASE_DIR)
     days = [x["datetime"] for x in data]
     values = ["%s" % x["total"] for x in data]
     g = [go.Scatter(x=days, y=values)]
     py.plot(dict(data=g,
                  layout={
                      "title": "Growth",
                      'xaxis': {
                          'title': "Year days"
                      },
                      'yaxis': {
                          'title': "Money"
                      }
                  }),
             filename="nekototal",
             fileopt="overwrite",
             auto_open=False)
예제 #7
0
 def graph(self):
     data = []
     for site in self.sites:
         site_list = dumper.load(site, path=BASE_DIR)
         x = [i['datetime'] for i in site_list]
         y = [i["total"] for i in site_list]
         data.append(go.Scatter(x=x, y=y, name=site))
     data.append(
         go.Scatter(y=[self.limit for i in range(0, len(x))],
                    x=x,
                    name="limit"))
     opts = dict(data=data,
                 layout={
                     'title': 'Total earns',
                     'xaxis': {
                         'title': "Timeline"
                     },
                     'yaxis': {
                         'title': "Money"
                     }
                 })
     py.plot(opts, filename="neko", fileopt="overwrite", auto_open=False)