Beispiel #1
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 #2
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 #3
0
def timbre(name, feuille):
    temps = xf.ctime(feuille)
    temps = xt.u2p(temps)
    MAJDIC[name] = temps
    #
    tmp = xz.notice
    xz.notice = False
    xz.dic2txt(MAJDIC, MAJLOG1)
    xz.obj2bin(MAJDIC, MAJLOG2)
    xz.notice = tmp
    #
    x = 'Timbre a %s de %s' % (temps, name)
Beispiel #4
0
def tasks(prj, see=True):
    if isinstance(prj, str):
        pid = getpid(prj)
    elif isinstance(prj, int):
        pid = prj
    api.sync()
    data = api.projects.get_data(pid)
    res = []

    headers = adic({
        'n': 'n',
        'id': 'tid',
        'content': 'title',
        'date_added': 'cdate',
        'due_date': 'ddate',
    })

    for dic in data['items']:
        cdate = dic['date_added']
        ddate = dic['due']['date']
        dic['date_added'] = zt2dt(dic['date_added'])
        dic['due_date'] = xt.s2d(dic['due']['date'])
        dic['n'] = 0
        #
        info = api.items.get(id)
        try:
            dic['notes'] = info['notes'][0]
        except TypeError:
            dic['notes'] = ''
        #
        tmp = {}
        for vor, nach in headers.items():
            tmp[nach] = dic[vor]
        tmp['notes'] = dic['notes']
        res.append(tmp)

    n = 0
    res = sorted(res, key=lambda d: d['ddate'])
    for dic in res:
        n += 1
        dic['n'] = n

    ### AUSGABE ###
    res.append(prj)
    xz.obj2bin(res, bin4tasks)
    res.pop()
    if see == True:
        #
        for dic in res:
            d = dic['cdate']
            dic['cdate'] = dt.date(d.year, d.month, d.day)
        tbl = xz.ldic2tbl(res, list(headers.values()))
        xz.show(tbl)
Beispiel #5
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 #6
0
def lists():
    lis = api.state['projects']
    res = {}
    api.sync()
    for dic in lis:
        id = dic['id']
        name = dic['name']
        res[name] = id
    #
    ausgabe = bin4lists.replace('.txt', '.bin')
    xz.dic2txt(res, ausgabe)
    xz.obj2bin(res, bin4lists)
    xz.show(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 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 #9
0
def stamm3obj(xls, tsv, blatt=0):

    assert tsv[-4:] == '.tsv'

    import pandas as pd

    if ein2aus(xls, tsv):
        obj = stamm2obj(xls, tsv, blatt)
        xz.tbl2txt(obj, tsv)
        #
        obj = xz.tbl2ldic(obj)
        ausgabe = tsv.replace('.tsv', '.ldic')
        xz.obj2bin(obj, ausgabe)
        #
        obj = pd.DataFrame(obj)
        ausgabe = tsv.replace('.tsv', '.pds')
        obj.to_pickle(ausgabe)
    else:
        ausgabe = tsv.replace('.tsv', '.pds')
        obj = pd.read_pickle(ausgabe)
    return obj
Beispiel #10
0
def n2qtafel():
    #	if os.path.exists(N2QBIN): return True
    res = {}
    qq = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]
    for fy in range(1, 13):
        qq.insert(0, qq.pop())
        m = 1
        res[fy] = {}
        for i in range(12):
            q = qq[i]
            #			print( fy,m,q ) #d
            res[fy][m] = q
            m += 1
#		if fy == 2: break
#		print( fy,qq )
#
    import xz
    f = xz.notice
    xz.notice = False
    xz.obj2bin(res, N2QBIN)
    xz.notice = f
    return res
Beispiel #11
0
def replace(sache, listfile):
    sache = sache2list(sache)
    sache = "\n".join(sache)
    try:
        dic = xz.txt2dic(listfile)
    except:
        listfile = labomi + listfile
        dic = xz.obj2bin(listfile)
    tbl = xz.txt2tbl(listfile)
    for lis in tbl:
        vor = lis[0]
        nach = lis[1]
        sache = sache.replace(vor, nach)
    return sache
Beispiel #12
0
def lookup(sache, dicfile):
    sache = sache2list(sache)
    print(dicfile)  #d
    try:
        dic = xz.txt2dic(dicfile)
    except:
        dicfile = labomi + dicfile
        dic = xz.obj2bin(dicfile)
    #
    res = []
    for x in sache:
        if x in dic:
            res.append(dic[x])
        else:
            res.append(x)
    return res
Beispiel #13
0
def pd2txt(df, ausgabe):
    df.to_csv(ausgabe, sep="\t")
    ausgabe = ausgabe.replace('.tsv', '.bin')
    xz.obj2bin(df, ausgabe)