Beispiel #1
0
def note(n, mynote=''):
    db = xz.bin2obj(bin4tasks)
    prj = db.pop()
    dic = db[n + 1]
    tid = dic['tid']
    itm = api.items.get(tid)
    #
    if os.path.exists(mynote):
        mynote = xz.txt2str(mynote)
    #
    if mynote == '':
        print(itm['notes'])
    else:
        if itm['notes'] == []:
            note = api.notes.add(tid, mynote)
            api.commit()
        else:
            nid = itm['notes'][0]['id']
            note = api.notes.get_by_id(nid)
            note.update(content=mynote)
            api.commit()
    itm = api.items.get(tid)
    print('<TITLE>', itm['item']['content'])
    print('<NOTES>')
    print(itm['notes'][0]['content'])
Beispiel #2
0
def addone(msg, see=True):
    m = re.match('^(\d+) ', msg)
    if m:
        tag = m.group(1)
        msg = msg.replace(tag + ' ', '')
        tag = setdate(tag)
        tag = str(tag)
    else:
        tag = xt.heute(False) + dt.timedelta(days=1)
    tag = str(tag)

    m = re.match('^(.+?) ', msg)
    tmp = m.group(1)
    if tmp in xz.bin2obj(bin4lists).keys():
        prj = tmp
        pid = getpid(tmp)
        tmp2 = len(tmp)
        msg = msg[tmp2 + 1:]
    else:
        prj = ''
        pid = getpid()

    api.items.add(msg, project_id=pid, due={'date': tag})
    api.commit()
    if see == True: tasks(pid)
Beispiel #3
0
def stamm2obj(xls, bin='', blatt=0, **kwargs):
    #def xls2obj(bin,xls,blatt=0): # 2019-11-04
    """
	STAMM kommst aus "STAMMDATEN"
	https://de.wikipedia.org/wiki/Stammdaten
	"""

    ### VORBEREITUNG ###
    erst = kwargs.get('erst', False)
    ldic = kwargs.get('ldic', False)
    ddic = kwargs.get('ddic', False)
    ddickey = kwargs.get('ddickey', '')
    if ddic == True:
        ldic = True


#	print( ldic ) #d
#	print( ddic ) #d
#	print( ddickey ) #d

### ERST ###
    if bin == '':
        bin = re.sub('.+/(.+)\.(.{1,6})$', '\\1_<>.><', xls)
        bin = bin.replace('<>', str(blatt))
        if ldic == True:
            bin = bin.replace('><', 'ldic')
        elif ddic == True:
            bin = bin.replace('><', 'ddic')
        else:
            bin = bin.replace('><', 'bin')
        bin = labomi + bin
        print(bin)

    if erst == True:
        os.remove(bin)

    ### HAUPT 1 - WIERDERVERWERTEN ###
    if not ein2aus(xls, bin, 'LAUFEN STAMM2OBJ()'):
        if DEBUG == True:
            print('#Wierderverwerten')  #d
        if os.path.exists(bin):
            obj = xz.bin2obj(bin)
            return obj

    ### HAUPT 2 - LADEN ###
    if DEBUG == True:
        print('#Laden')  #d
    obj = xx.xls2tbl(xls, blatt)
    if ldic == True:
        obj = xz.tbl2ldic(obj)
        if ddic == True:
            obj = xz.ldic2ddic(obj, ddickey)
    xz.obj2bin(obj, bin)

    ### AUSGABE ###
    return obj
Beispiel #4
0
def wahlbrowser(brw='chrome'):
    ### STARTEN ###
    try:
        res = xz.bin2obj(labomi + 'browser.bin')
    except FileNotFoundError:
        res = dritt.which_browser()
        res = xz.obj2bin(res, labomi + 'browser.bin')
    brw = res[brw]
    brw = wb.get(brw + ' %s')
    return brw
Beispiel #5
0
def erb(kennwort, wert=None):
    dic = 'ex/cache/xb_erb.dic'
    try:
        res = xz.bin2obj(dic)
    except FileNotFoundError:
        res = {}
    if wert == None:
        res = res.get(kennwort, None)
        return res
    else:
        res[kennwort] = wert
        xz.obj2bin(res, dic)
Beispiel #6
0
def which_browser():

    ### MODULE ###
    import xf
    import xz

    ### BROWSER ###
    if os.name == 'posix':
        browser = '/tmp/'
    elif os.name == 'nt':
        pfad = tempfile.gettempdir()
        pfad = pfad.replace('\\', '/')
        if not pfad[-1] == '/':
            pfad += '/'
        browser = pfad + 'labomi/'

    ### VARIABLES ###
    pfad1 = 'C:/Program Files/'
    pfad2 = 'C:/Program Files (x86)/'
    ausgabe = browser + 'browser.bin'

    #

    ### HAUPT 1 ###
    if os.path.exists(ausgabe):
        res = xz.bin2obj(ausgabe)
        #		print( 111 ) #d
        if ['heute'] == datetime.date.today():
            return True

    ### HAUPT 2 ###
    res = {}
    res['heute'] = datetime.date.today()
    for pfad in [pfad1, pfad2]:
        ds = xf.alle_dateien(pfad)
        for d in ds:
            #			print( '-'*40 )
            #			print( d )
            #			print( d[-11:] )
            if d[-10:] == 'chrome.exe':
                #				print( d )
                res['chrome'] = d
                break
            elif d[-11:] == 'firefox.exe':
                #				print( d )
                res['firefox'] = d
                break

    ### AUSGABE ###
#	import pprint; pprint.pprint( res )
    xz.obj2bin(res, ausgabe)
    return res
Beispiel #7
0
def url2cmd2datei(addr, ausgabe=None):
    if ausgabe == None:
        ausgabe = re.sub('.+/', '', addr)
        ausgabe = mydwld + ausgabe
    #
    if os.path.exists(ausgabe):
        inhalt = xz.bin2obj(ausgabe)
#		print( 'Existieren!',ausgabe ) #d
    else:
        inhalt = requests.get(addr)
        #		print( ausgabe ) #d
        xz.obj2bin(inhalt, ausgabe)
    return inhalt
Beispiel #8
0
def delay(plus, *ns):
    pid = getpid()
    ns = flatten(ns)
    ns = [int(n) for n in ns]
    db = xz.bin2obj(bin4tasks)
    db.pop()
    ddic = xz.ldic2ddic(db, 'n')
    tag = setdate(plus)

    tids = [ddic[n]['tid'] for n in ns]
    for tid in tids:
        itm = api.items.get_by_id(tid)
        itm.update(due={'date': tag})
        api.commit()
Beispiel #9
0
def fin(*ns):
    pid = getpid()
    if isinstance(ns[0], list):
        ns = ns[0]
    else:
        ns = flatten(ns)
    ns = [int(n) for n in ns]
    db = xz.bin2obj(bin4tasks)
    db.pop()
    ddic = xz.ldic2ddic(db, 'n')

    #	pprint.pprint( db ) #d
    tids = [ddic[n]['tid'] for n in ns]
    for tid in tids:
        itm = api.items.get_by_id(tid)
        itm.complete()
        api.commit()
Beispiel #10
0
def today(prj=''):
    #	pid = getpid(prj)
    #	tasks(pid,False)
    db = xz.bin2obj(bin4tasks)
    db.pop()
    res = []
    tag = xt.heute(False)
    #	tag = tag + dt.timedelta(days=-5)
    #	print( tag )
    for dic in db:
        due = dic['ddate']
        if due <= tag:
            res.append(dic)
#		print( dic ) #d
    headers = 'n/tid/title/cdate/ddate'
    headers = headers.split('/')
    for dic in res:
        d = dic['cdate']
        dic['cdate'] = dt.date(d.year, d.month, d.day)
    tbl = xz.ldic2tbl(res, headers)
    xz.show(tbl)
Beispiel #11
0
from datsun import *
import xt
import xf
import xz
#import kbench
from mich.maj2 import MAJLOG1
from mich.maj2 import MAJLOG2
#
#1:battery,2:pip,3:mygen,4:myopus

### VARIABLES ###
DEBUG = True
DEBUG = False
#
if os.path.exists(MAJLOG2):
    MAJDIC = xz.bin2obj(MAJLOG2)
else:
    MAJDIC = {}

#


##############
### TIMBRE ###
##############
def timbre(name, feuille):
    temps = xf.ctime(feuille)
    temps = xt.u2p(temps)
    MAJDIC[name] = temps
    #
    tmp = xz.notice
Beispiel #12
0
def gettid(prj):
    prjs = xz.bin2obj(bin4tasks)
    return prjs[prj]
Beispiel #13
0
def getpid(prj=''):
    if prj == '':
        prj = xz.txt2str(bin4prj)
    prjs = xz.bin2obj(bin4lists)
    return prjs[prj]