dialogtest 2 returns strings

This commit is contained in:
Wolfgang Nowak 2021-11-20 18:19:59 +01:00
parent ef728fc7f9
commit 94cde92b57

View file

@ -1,10 +1,11 @@
#!/usr/bin/python3 #!/usr/bin/python3
import sys, re, os, pg, locale, glob import sys, re, os, pg, datetime, locale, glob
from dialog import Dialog from dialog import Dialog
## Initialize a dialog.Dialog instance ## Initialize a dialog.Dialog instance
d = Dialog(dialog="dialog") d = Dialog(dialog="dialog")
clear = "\x1b[2J\x1b[H"
locale.setlocale(locale.LC_ALL, "") locale.setlocale(locale.LC_ALL, "")
sourcedir = "/home/wn/python/webgen/" sourcedir = "/home/wn/python/webgen/"
targetdir = "/home/wn/www/i21k.de/posts/" targetdir = "/home/wn/www/i21k.de/posts/"
@ -23,9 +24,19 @@ for zeile in sourcefolder:
# Open list in menu and let user choose one # Open list in menu and let user choose one
ausgewaehlt = d.menu("Biddesehr:", width=xwidth, height=0, menu_height=ywidth, title="Such dir ne Datei", choices=tabelle) ausgewaehlt = d.menu("Biddesehr:", width=xwidth, height=0, menu_height=ywidth, title="Such dir ne Datei", choices=tabelle)
if ausgewaehlt[0] == "cancel":
sys.exit("Na, dann eben nicht...")
# Clean filename from leading .md for later construction of a headline # Clean filename from leading .md for later construction of a headline
fn = re.sub("\.md$", "", tabelle[int(ausgewaehlt[1])][1]) fn = re.sub("\.md$", "", tabelle[int(ausgewaehlt[1])][1])
sourcefile = glob.glob(sourcedir + fn + ".md") sourcefile = str(glob.glob(sourcedir + fn + ".md")[0])
targetfile = glob.glob(targetdir + "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-2][0-9]:[0-6][0-9] " + fn + "*") targetfile = glob.glob(targetdir + "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-2][0-9]:[0-6][0-9] " + fn + "*")
print("Sourcefile: ", sourcefile, "\nTargetfile: ", targetfile) targetfilelength = len(targetfile)
if targetfilelength >= 1:
targetfile = targetfile[targetfilelength - 1]
if not targetfile:
targetfile = targetdir + datetime.datetime.now().strftime("%Y-%m-%d %H:00 ") + fn
print(clear, "\nSourcefile: ", sourcefile, "\nTargetfile: ", targetfile)
# return sourcefile, targetfile