manuskript/manuskript/load_save/version_1.py

1132 lines
36 KiB
Python
Raw Normal View History

#!/usr/bin/env python
# --!-- coding: utf8 --!--
# Version 1 of file saving format.
# Aims at providing a plain-text way of saving a project
# (except for some elements), allowing collaborative work
# versioning and third-party editing.
2016-03-10 03:54:01 +13:00
import os
2016-03-10 23:45:40 +13:00
import re
2016-03-10 03:54:01 +13:00
import shutil
import string
import zipfile
2016-03-10 23:45:40 +13:00
from collections import OrderedDict
from PyQt5.QtCore import Qt, QModelIndex
2016-03-10 23:45:40 +13:00
from PyQt5.QtGui import QColor, QStandardItem
from PyQt5.QtWidgets import QListWidgetItem
2016-03-05 12:35:14 +13:00
from manuskript import settings
2016-03-08 21:21:44 +13:00
from manuskript.enums import Character, World, Plot, PlotStep, Outline
2017-11-14 10:55:33 +13:00
from manuskript.functions import mainWindow, iconColor, iconFromColorString
from manuskript.converters import HTML2PlainText
from lxml import etree as ET
2016-03-10 23:45:40 +13:00
from manuskript.load_save.version_0 import loadFilesFromZip
from manuskript.models.characterModel import CharacterInfo
2017-11-16 08:33:27 +13:00
from manuskript.models import outlineItem
from manuskript.ui.listDialog import ListDialog
import logging
LOGGER = logging.getLogger(__name__)
try:
import zlib # Used with zipfile for compression
compression = zipfile.ZIP_DEFLATED
except:
compression = zipfile.ZIP_STORED
2016-03-05 12:35:14 +13:00
cache = {}
2016-03-06 00:55:56 +13:00
2016-03-10 23:45:40 +13:00
characterMap = OrderedDict([
(Character.name, "Name"),
(Character.ID, "ID"),
(Character.importance, "Importance"),
(Character.pov, "POV"),
2016-03-10 23:45:40 +13:00
(Character.motivation, "Motivation"),
(Character.goal, "Goal"),
(Character.conflict, "Conflict"),
(Character.epiphany, "Epiphany"),
2016-03-10 23:45:40 +13:00
(Character.summarySentence, "Phrase Summary"),
(Character.summaryPara, "Paragraph Summary"),
(Character.summaryFull, "Full Summary"),
(Character.notes, "Notes")
2016-03-10 23:45:40 +13:00
])
2016-03-11 02:11:28 +13:00
2016-03-10 23:45:40 +13:00
2016-03-06 00:55:56 +13:00
def formatMetaData(name, value, tabLength=10):
# Multiline formatting
if len(value.split("\n")) > 1:
value = "\n".join([" " * (tabLength + 1) + l for l in value.split("\n")])[tabLength + 1:]
# Avoid empty description (don't know how much MMD loves that)
if name == "":
name = "None"
# Escapes ":" in name
name = name.replace(":", "_.._")
2016-03-06 00:55:56 +13:00
return "{name}:{spaces}{value}\n".format(
name=name,
spaces=" " * (tabLength - len(name)),
value=value
)
def slugify(name):
"""
A basic slug function, that escapes all spaces to "_" and all non letters/digits to "-".
@param name: name to slugify (str)
@return: str
"""
valid = string.ascii_letters + string.digits
newName = ""
for c in name:
if c in valid:
newName += c
elif c in string.whitespace:
newName += "_"
else:
newName += "-"
return newName
2016-03-07 04:27:03 +13:00
def saveProject(zip=None):
"""
Saves the project. If zip is False, the project is saved as a multitude of plain-text files for the most parts
and some XML or zip? for settings and stuff.
If zip is True, everything is saved as a single zipped file. Easier to carry around, but does not allow
collaborative work, versioning, or third-party editing.
@param zip: if True, saves as a single file. If False, saves as plain-text. If None, tries to determine based on
settings.
@return: True if successful, False otherwise.
"""
2021-02-22 11:45:34 +13:00
if zip == None:
zip = settings.saveToZip
LOGGER.info("Saving to: %s", "zip" if zip else "folder")
# List of files to be written
files = []
# List of files to be removed
removes = []
# List of files to be moved
moves = []
# MainWindow interaction things.
mw = mainWindow()
project = mw.currentProject
# Sanity check (see PR-583): make sure we actually have a current project.
2021-02-22 11:45:34 +13:00
if project == None:
LOGGER.error("Cannot save project because there is no current project in the UI.")
return False
2016-03-31 21:45:58 +13:00
# File format version
files.append(("MANUSKRIPT", "1"))
2016-03-07 04:27:03 +13:00
2016-03-05 12:35:14 +13:00
# General infos (book and author)
# Saved in plain text, in infos.txt
path = "infos.txt"
content = ""
for name, col in [
2016-03-10 03:54:01 +13:00
("Title", 0),
("Subtitle", 1),
("Serie", 2),
("Volume", 3),
("Genre", 4),
("License", 5),
("Author", 6),
("Email", 7),
]:
2016-03-12 02:56:16 +13:00
item = mw.mdlFlatData.item(0, col)
if item:
val = item.text().strip()
else:
val = ""
2016-03-05 12:35:14 +13:00
if val:
content += "{name}:{spaces}{value}\n".format(
name=name,
spaces=" " * (15 - len(name)),
value=val
)
files.append((path, content))
####################################################################################################################
2016-03-05 12:35:14 +13:00
# Summary
# In plain text, in summary.txt
path = "summary.txt"
content = ""
for name, col in [
2016-03-10 03:54:01 +13:00
("Situation", 0),
("Sentence", 1),
("Paragraph", 2),
("Page", 3),
("Full", 4),
]:
2016-03-12 02:56:16 +13:00
item = mw.mdlFlatData.item(1, col)
if item:
val = item.text().strip()
else:
val = ""
2016-03-05 12:35:14 +13:00
if val:
content += formatMetaData(name, val, 12)
2016-03-05 12:35:14 +13:00
files.append((path, content))
####################################################################################################################
2016-03-05 12:35:14 +13:00
# Label & Status
# In plain text
for mdl, path in [
(mw.mdlStatus, "status.txt"),
(mw.mdlLabels, "labels.txt")
]:
content = ""
# We skip the first row, which is empty and transparent
for i in range(1, mdl.rowCount()):
color = ""
2021-02-22 11:45:34 +13:00
if mdl.data(mdl.index(i, 0), Qt.DecorationRole) != None:
2016-03-05 12:35:14 +13:00
color = iconColor(mdl.data(mdl.index(i, 0), Qt.DecorationRole)).name(QColor.HexRgb)
color = color if color != "#ff000000" else "#00000000"
text = mdl.data(mdl.index(i, 0))
if text:
content += "{name}{color}\n".format(
name=text,
2016-03-10 03:54:01 +13:00
color="" if color == "" else ":" + " " * (20 - len(text)) + color
2016-03-05 12:35:14 +13:00
)
files.append((path, content))
####################################################################################################################
# Characters
2016-03-05 12:35:14 +13:00
# In a character folder
2016-03-08 21:21:44 +13:00
path = os.path.join("characters", "{name}.txt")
2016-03-06 00:55:56 +13:00
mdl = mw.mdlCharacter
# Review characters
2016-03-06 00:55:56 +13:00
for c in mdl.characters:
# Generates file's content
2016-03-06 00:55:56 +13:00
content = ""
2016-03-10 23:45:40 +13:00
for m in characterMap:
2016-03-06 00:55:56 +13:00
val = mdl.data(c.index(m.value)).strip()
if val:
2016-03-10 23:45:40 +13:00
content += formatMetaData(characterMap[m], val, 20)
# Character's color:
content += formatMetaData("Color", c.color().name(QColor.HexRgb), 20)
2016-03-06 00:55:56 +13:00
2016-03-10 23:45:40 +13:00
# Character's infos
2016-03-06 00:55:56 +13:00
for info in c.infos:
content += formatMetaData(info.description, info.value, 20)
2016-03-06 00:55:56 +13:00
# generate file's path
cpath = path.format(name="{ID}-{slugName}".format(
2016-03-06 00:55:56 +13:00
ID=c.ID(),
slugName=slugify(c.name())
))
2016-03-07 04:27:03 +13:00
# Has the character been renamed?
if c.lastPath and cpath != c.lastPath:
moves.append((c.lastPath, cpath))
# Update character's path
c.lastPath = cpath
2016-03-05 12:35:14 +13:00
files.append((cpath, content))
####################################################################################################################
2016-03-05 12:35:14 +13:00
# Texts
# In an outline folder
2016-03-08 21:21:44 +13:00
mdl = mw.mdlOutline
2016-03-10 03:48:59 +13:00
# Go through the tree
f, m, r = exportOutlineItem(mdl.rootItem)
files += f
moves += m
removes += r
2016-03-05 12:35:14 +13:00
2016-03-10 05:20:43 +13:00
# Writes revisions (if asked for)
if settings.revisions["keep"]:
files.append(("revisions.xml", mdl.saveToXML()))
####################################################################################################################
# World
2016-03-05 12:35:14 +13:00
# Either in an XML file, or in lots of plain texts?
# More probably text, since there might be writing done in third-party.
path = "world.opml"
mdl = mw.mdlWorld
root = ET.Element("opml")
root.attrib["version"] = "1.0"
body = ET.SubElement(root, "body")
addWorldItem(body, mdl)
content = ET.tostring(root, encoding="UTF-8", xml_declaration=True, pretty_print=True)
files.append((path, content))
2016-03-05 12:35:14 +13:00
####################################################################################################################
2016-03-05 12:35:14 +13:00
# Plots (mw.mdlPlots)
# Either in XML or lots of plain texts?
# More probably XML since there is not really a lot if writing to do (third-party)
2016-03-07 04:27:03 +13:00
path = "plots.xml"
mdl = mw.mdlPlots
2016-03-07 04:27:03 +13:00
root = ET.Element("root")
addPlotItem(root, mdl)
content = ET.tostring(root, encoding="UTF-8", xml_declaration=True, pretty_print=True)
files.append((path, content))
2016-03-05 12:35:14 +13:00
####################################################################################################################
2016-03-05 12:35:14 +13:00
# Settings
# Saved in readable text (json) for easier versioning. But they mustn't be shared, it seems.
2016-03-05 12:35:14 +13:00
# Maybe include them only if zipped?
# Well, for now, we keep them here...
2016-03-05 12:35:14 +13:00
files.append(("settings.txt", settings.save(protocol=0)))
# We check if the file exist and we have write access. If the file does
# not exist, we check the parent folder, because it might be a new project.
if os.path.exists(project) and not os.access(project, os.W_OK) or \
not os.path.exists(project) and not os.access(os.path.dirname(project), os.W_OK):
LOGGER.error("You don't have write access to save this project there.")
return False
####################################################################################################################
2016-03-05 12:35:14 +13:00
# Save to zip
2016-03-05 12:35:14 +13:00
if zip:
2016-03-10 05:20:43 +13:00
# project = os.path.join(
# os.path.dirname(project),
# "_" + os.path.basename(project)
# )
2016-03-05 12:35:14 +13:00
zf = zipfile.ZipFile(project, mode="w")
for filename, content in files:
zf.writestr(filename, content, compress_type=compression)
zf.close()
return True
####################################################################################################################
2016-03-05 12:35:14 +13:00
# Save to plain text
2016-03-05 12:35:14 +13:00
else:
2016-03-10 03:48:59 +13:00
global cache
filesWithPermissionErrors = list()
2016-03-10 03:48:59 +13:00
# Project path
2016-03-05 12:35:14 +13:00
dir = os.path.dirname(project)
# Folder containing file: name of the project file (without .msk extension)
2016-03-05 12:35:14 +13:00
folder = os.path.splitext(os.path.basename(project))[0]
# Debug
LOGGER.debug("Saving to folder %s", folder)
2016-03-11 02:11:28 +13:00
# If cache is empty (meaning we haven't loaded from disk), we wipe folder, just to be sure.
if not cache:
2016-03-11 02:38:46 +13:00
if os.path.exists(os.path.join(dir, folder)):
shutil.rmtree(os.path.join(dir, folder))
2016-03-11 02:11:28 +13:00
# Moving files that have been renamed
for old, new in moves:
# Get full path
oldPath = os.path.join(dir, folder, old)
newPath = os.path.join(dir, folder, new)
# Move the old file to the new place
2016-03-10 03:48:59 +13:00
try:
os.replace(oldPath, newPath)
LOGGER.debug("* Renaming/moving {} to {}".format(old, new))
2016-03-10 03:48:59 +13:00
except FileNotFoundError:
# Maybe parent folder has been renamed
pass
# Update cache
2016-03-10 03:48:59 +13:00
cache2 = {}
for f in cache:
f2 = f.replace(old, new)
if f2 != f:
LOGGER.debug(" * Updating cache: %s, %s", f, f2)
2016-03-10 03:48:59 +13:00
cache2[f2] = cache[f]
cache = cache2
# Writing files
2016-03-05 12:35:14 +13:00
for path, content in files:
filename = os.path.join(dir, folder, path)
os.makedirs(os.path.dirname(filename), exist_ok=True)
2016-03-10 23:45:40 +13:00
# Check if content is in cache, and write if necessary
2016-03-10 03:54:01 +13:00
if path not in cache or cache[path] != content:
LOGGER.debug("* Writing file {} ({})".format(path, "not in cache" if path not in cache else "different"))
# mode = "w" + ("b" if type(content) == bytes else "")
if type(content) == bytes:
try:
with open(filename, "wb") as f:
f.write(content)
except PermissionError as e:
LOGGER.error("Cannot open file " + filename + " for writing: " + e.strerror)
filesWithPermissionErrors.append(filename)
else:
try:
with open(filename, "w", encoding='utf8') as f:
f.write(content)
except PermissionError as e:
LOGGER.error("Cannot open file " + filename + " for writing: " + e.strerror)
filesWithPermissionErrors.append(filename)
2016-03-05 12:35:14 +13:00
cache[path] = content
2016-03-10 03:48:59 +13:00
# Removing phantoms
2016-03-10 03:54:01 +13:00
for path in [p for p in cache if p not in [p for p, c in files]]:
2016-03-10 03:48:59 +13:00
filename = os.path.join(dir, folder, path)
LOGGER.debug("* Removing %s", path)
2016-03-10 03:48:59 +13:00
if os.path.isdir(filename):
shutil.rmtree(filename)
else: # elif os.path.exists(filename)
os.remove(filename)
# Clear cache
cache.pop(path, 0)
# Removing empty directories
for root, dirs, files in os.walk(os.path.join(dir, folder, "outline")):
for dir in dirs:
newDir = os.path.join(root, dir)
try:
os.removedirs(newDir)
LOGGER.debug("* Removing empty directory: %s", newDir)
2016-03-10 03:48:59 +13:00
except:
# Directory not empty, we don't remove.
pass
2016-03-10 05:20:43 +13:00
# Write the project file's content
try:
with open(project, "w", encoding='utf8') as f:
f.write("1") # Format number
except PermissionError as e:
LOGGER.error("Cannot open file " + project + " for writing: " + e.strerror)
filesWithPermissionErrors.append(project)
if len(filesWithPermissionErrors) > 0:
dlg = ListDialog(mw)
dlg.setModal(True)
dlg.setWindowTitle(dlg.tr("Files not saved"))
dlg.label.setText(dlg.tr("The following files were not saved and appear to be open in another program"))
for f in filesWithPermissionErrors:
QListWidgetItem(f, dlg.listWidget)
dlg.open()
if project in filesWithPermissionErrors:
return False
return True
2016-03-10 05:20:43 +13:00
2016-03-07 04:27:03 +13:00
def addWorldItem(root, mdl, parent=QModelIndex()):
"""
Lists elements in a world model and create an OPML xml file.
@param root: an Etree element
@param mdl: a worldModel
@param parent: the parent index in the world model
@return: root, to which sub element have been added
"""
# List every row (every world item)
for x in range(mdl.rowCount(parent)):
# For each row, create an outline item.
outline = ET.SubElement(root, "outline")
for y in range(mdl.columnCount(parent)):
val = mdl.data(mdl.index(x, y, parent))
if not val:
continue
for w in World:
if y == w.value:
outline.attrib[w.name] = val
if mdl.hasChildren(mdl.index(x, y, parent)):
addWorldItem(outline, mdl, mdl.index(x, y, parent))
return root
def addPlotItem(root, mdl, parent=QModelIndex()):
"""
2016-03-07 04:27:03 +13:00
Lists elements in a plot model and create an xml file.
@param root: an Etree element
@param mdl: a plotModel
@param parent: the parent index in the plot model
@return: root, to which sub element have been added
"""
# List every row (every plot item)
for x in range(mdl.rowCount(parent)):
# For each row, create an outline item.
2016-03-07 04:27:03 +13:00
outline = ET.SubElement(root, "plot")
for y in range(mdl.columnCount(parent)):
index = mdl.index(x, y, parent)
val = mdl.data(index)
2016-03-11 02:11:28 +13:00
#
# if not val:
# continue
for w in Plot:
2016-03-11 02:11:28 +13:00
if y == w.value and val:
outline.attrib[w.name] = val
2016-03-07 04:27:03 +13:00
# List characters as attrib
2017-11-16 09:05:48 +13:00
if y == Plot.characters:
if mdl.hasChildren(index):
characters = []
for cX in range(mdl.rowCount(index)):
for cY in range(mdl.columnCount(index)):
cIndex = mdl.index(cX, cY, index)
characters.append(mdl.data(cIndex))
outline.attrib[Plot.characters.name] = ",".join(characters)
2016-03-11 02:11:28 +13:00
elif Plot.characters.name in outline.attrib:
outline.attrib.pop(Plot.characters.name)
2016-03-07 04:27:03 +13:00
# List resolution steps as sub items
2017-11-16 09:05:48 +13:00
elif y == Plot.steps:
2016-03-07 04:27:03 +13:00
if mdl.hasChildren(index):
for cX in range(mdl.rowCount(index)):
step = ET.SubElement(outline, "step")
for cY in range(mdl.columnCount(index)):
cIndex = mdl.index(cX, cY, index)
2016-04-01 03:09:37 +13:00
# If empty, returns None, which creates trouble later with lxml, so default to ""
val = mdl.data(cIndex) or ""
2016-03-07 04:27:03 +13:00
for w in PlotStep:
2016-04-01 03:09:37 +13:00
if cY == w.value and w.name:
2016-03-07 04:27:03 +13:00
step.attrib[w.name] = val
2016-03-11 02:11:28 +13:00
elif Plot.steps.name in outline.attrib:
outline.attrib.pop(Plot.steps.name)
return root
2016-03-07 04:27:03 +13:00
2016-03-08 21:21:44 +13:00
def exportOutlineItem(root):
"""
2016-03-30 21:00:09 +13:00
Takes an outline item, and returns three lists:
1. of (`filename`, `content`), representing the whole tree of files to be written, in multimarkdown.
2016-03-30 21:00:09 +13:00
2. of (`filename`, `filename`) listing files to be moved
3. of `filename`, representing files to be removed.
2016-03-08 21:21:44 +13:00
@param root: OutlineItem
2016-03-30 21:00:09 +13:00
@return: [(str, str)], [(str, str)], [str]
2016-03-08 21:21:44 +13:00
"""
files = []
moves = []
removes = []
2016-03-10 03:54:01 +13:00
k = 0
2016-03-08 21:21:44 +13:00
for child in root.children():
2016-03-10 03:54:01 +13:00
spath = os.path.join(*outlineItemPath(child))
2016-03-10 03:48:59 +13:00
2016-03-08 21:21:44 +13:00
k += 1
# Has the item been renamed?
2016-03-10 03:48:59 +13:00
lp = child._lastPath
if lp and spath != lp:
moves.append((lp, spath))
LOGGER.debug("%s has been renamed (%s%s)", child.title(), lp, spath)
LOGGER.debug(" → We mark for moving: %s", lp)
# Updates item last's path
2016-03-10 03:54:01 +13:00
child._lastPath = spath
# Generating content
2016-03-08 21:21:44 +13:00
if child.type() == "folder":
fpath = os.path.join(spath, "folder.txt")
content = outlineToMMD(child)
files.append((fpath, content))
2016-03-08 21:21:44 +13:00
2016-03-30 22:14:05 +13:00
elif child.type() == "md":
content = outlineToMMD(child)
files.append((spath, content))
2016-03-08 21:21:44 +13:00
else:
LOGGER.debug("Unknown type: %s", child.type())
2016-03-08 21:21:44 +13:00
f, m, r = exportOutlineItem(child)
files += f
moves += m
removes += r
2016-03-08 21:21:44 +13:00
return files, moves, removes
2016-03-08 21:21:44 +13:00
2016-03-10 03:54:01 +13:00
2016-03-08 21:21:44 +13:00
def outlineItemPath(item):
2016-03-10 03:48:59 +13:00
"""
Returns the outlineItem file path (like the path where it will be written on the disk). As a list of folder's
name. To be joined by os.path.join.
@param item: outlineItem
@return: list of folder's names
"""
2016-03-08 21:21:44 +13:00
# Root item
if not item.parent():
2016-03-10 03:48:59 +13:00
return ["outline"]
2016-03-08 21:21:44 +13:00
else:
2016-03-30 21:00:09 +13:00
# Count the number of siblings for padding '0'
siblings = item.parent().childCount()
# We check if multiple items have the same name
# If so, we add "-ID" to their name
siblingsNames = [s.title() for s in item.parent().children()]
if siblingsNames.count(item.title()) > 1:
title = "{}-{}".format(item.title(), item.ID())
else:
title = item.title()
2016-03-08 21:21:44 +13:00
name = "{ID}-{name}{ext}".format(
2016-03-30 21:00:09 +13:00
ID=str(item.row()).zfill(len(str(siblings))),
name=slugify(title),
ext="" if item.type() == "folder" else ".md"
2016-03-08 21:21:44 +13:00
)
return outlineItemPath(item.parent()) + [name]
2016-03-10 03:54:01 +13:00
2016-03-08 21:21:44 +13:00
def outlineToMMD(item):
content = ""
# We don't want to write some datas (computed)
exclude = [Outline.wordCount, Outline.goal, Outline.goalPercentage, Outline.revisions, Outline.text]
# We want to force some data even if they're empty
force = [Outline.compile]
for attrib in Outline:
2016-03-10 03:54:01 +13:00
if attrib in exclude:
continue
2016-03-08 21:21:44 +13:00
val = item.data(attrib.value)
if val or attrib in force:
content += formatMetaData(attrib.name, str(val), 15)
content += "\n\n"
2017-11-16 08:58:12 +13:00
content += item.data(Outline.text)
2016-03-08 21:21:44 +13:00
return content
2016-03-10 23:45:40 +13:00
########################################################################################################################
# LOAD
########################################################################################################################
2016-03-10 03:54:01 +13:00
2016-03-10 23:45:40 +13:00
def loadProject(project, zip=None):
"""
Loads a project.
@param project: the filename of the project to open.
2016-03-10 23:45:40 +13:00
@param zip: whether the project is a zipped or not.
@return: an array of errors, empty if None.
"""
2016-03-05 12:35:14 +13:00
2016-03-10 23:45:40 +13:00
mw = mainWindow()
errors = list()
filesWithPermissionErrors = list()
2016-03-10 23:45:40 +13:00
####################################################################################################################
# Read and store everything in a dict
LOGGER.debug("Loading {} ({})".format(project, "zip" if zip else "folder"))
2016-03-10 23:45:40 +13:00
if zip:
files = loadFilesFromZip(project)
# Decode files
for f in files:
if f[-4:] not in [".xml", "opml"]:
files[f] = files[f].decode("utf-8")
else:
# Project path
dir = os.path.dirname(project)
# Folder containing file: name of the project file (without .msk extension)
folder = os.path.splitext(os.path.basename(project))[0]
# The full path towards the folder containing files
path = os.path.join(dir, folder, "")
files = {}
for dirpath, dirnames, filenames in os.walk(path):
p = dirpath.replace(path, "")
Skip loading directory and file names that begin with a period See issue #281. When loading a project that has the setting **Save to one single file** disabled, Manuskript tries to read all directories and files under the project directory. Manuskript expects all files to contain valid unicode characters. However if a file containing non-unicode characters is read then Manuskript will crash. The error message displayed on the console is similar to the following: ----- begin snippet ----- Traceback (most recent call last): File "/home/gedakc/workspace/manuskript.olivierkes/bin/../manuskript/ui/welcome.py", line 134, in loadRecentFile self.mw.loadProject(act.data()) File "/home/gedakc/workspace/manuskript.olivierkes/bin/../manuskript/mainWindow.py", line 566, in loadProject self.loadDatas(project) File "/home/gedakc/workspace/manuskript.olivierkes/bin/../manuskript/mainWindow.py", line 793, in loadDatas errors = loadSave.loadProject(project) File "/home/gedakc/workspace/manuskript.olivierkes/bin/../manuskript/loadSave.py", line 66, in loadProject v1.loadProject(project, zip=isZip) File "/home/gedakc/workspace/manuskript.olivierkes/bin/../manuskript/load_save/version_1.py", line 657, in loadProject files[os.path.join(p, f)] = fo.read() File "/usr/lib/python3.5/codecs.py", line 321, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 3131: invalid start byte ----- end snippet ----- There are at least two known situations in which files with non-unicode characters can arise: A. The project is on Mac OS X and the operating system automatically creates a .DS_Store file. B. The project is under git version control and contains a .git subdirectory. This enhancement prevents the Manuskript crash on project load by ignoring all directory and file names that start with a period.
2018-01-15 07:20:48 +13:00
# Skip directories that begin with a period
if p[:1] == ".":
continue
2016-03-10 23:45:40 +13:00
for f in filenames:
Skip loading directory and file names that begin with a period See issue #281. When loading a project that has the setting **Save to one single file** disabled, Manuskript tries to read all directories and files under the project directory. Manuskript expects all files to contain valid unicode characters. However if a file containing non-unicode characters is read then Manuskript will crash. The error message displayed on the console is similar to the following: ----- begin snippet ----- Traceback (most recent call last): File "/home/gedakc/workspace/manuskript.olivierkes/bin/../manuskript/ui/welcome.py", line 134, in loadRecentFile self.mw.loadProject(act.data()) File "/home/gedakc/workspace/manuskript.olivierkes/bin/../manuskript/mainWindow.py", line 566, in loadProject self.loadDatas(project) File "/home/gedakc/workspace/manuskript.olivierkes/bin/../manuskript/mainWindow.py", line 793, in loadDatas errors = loadSave.loadProject(project) File "/home/gedakc/workspace/manuskript.olivierkes/bin/../manuskript/loadSave.py", line 66, in loadProject v1.loadProject(project, zip=isZip) File "/home/gedakc/workspace/manuskript.olivierkes/bin/../manuskript/load_save/version_1.py", line 657, in loadProject files[os.path.join(p, f)] = fo.read() File "/usr/lib/python3.5/codecs.py", line 321, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 3131: invalid start byte ----- end snippet ----- There are at least two known situations in which files with non-unicode characters can arise: A. The project is on Mac OS X and the operating system automatically creates a .DS_Store file. B. The project is under git version control and contains a .git subdirectory. This enhancement prevents the Manuskript crash on project load by ignoring all directory and file names that start with a period.
2018-01-15 07:20:48 +13:00
# Skip filenames that begin with a period
if f[:1] == ".":
continue
# mode = "r" + ("b" if f[-4:] in [".xml", "opml"] else "")
if f[-4:] in [".xml", "opml"]:
with open(os.path.join(dirpath, f), "rb") as fo:
files[os.path.join(p, f)] = fo.read()
else:
try:
filename = os.path.join(dirpath, f)
with open(filename, "r", encoding="utf8") as fo:
files[os.path.join(p, f)] = fo.read()
except PermissionError as e:
LOGGER.error("Cannot open file " + filename + ": " + e.strerror)
errors.append(fo)
filesWithPermissionErrors.append(filename)
2016-03-10 23:45:40 +13:00
2016-03-11 02:11:28 +13:00
# Saves to cache (only if we loaded from disk and not zip)
global cache
cache = files
2016-03-11 02:15:03 +13:00
# FIXME: watch directory for changes
2016-03-11 02:11:28 +13:00
2016-03-11 01:10:31 +13:00
# Sort files by keys
files = OrderedDict(sorted(files.items()))
2016-03-10 23:45:40 +13:00
####################################################################################################################
# Settings
if "settings.txt" in files:
settings.load(files["settings.txt"], fromString=True, protocol=0)
else:
errors.append("settings.txt")
# Just to be sure
settings.saveToZip = zip
settings.defaultTextType = "md"
2016-03-10 23:45:40 +13:00
####################################################################################################################
# Labels
mdl = mw.mdlLabels
mdl.appendRow(QStandardItem("")) # Empty = No labels
if "labels.txt" in files:
LOGGER.debug("Reading labels:")
2016-03-10 23:45:40 +13:00
for s in files["labels.txt"].split("\n"):
if not s:
continue
m = re.search(r"^(.*?):\s*(.*)$", s)
txt = m.group(1)
col = m.group(2)
LOGGER.debug("* Add status: {} ({})".format(txt, col))
2016-03-10 23:45:40 +13:00
icon = iconFromColorString(col)
mdl.appendRow(QStandardItem(icon, txt))
else:
errors.append("labels.txt")
####################################################################################################################
# Status
mdl = mw.mdlStatus
mdl.appendRow(QStandardItem("")) # Empty = No status
if "status.txt" in files:
LOGGER.debug("Reading status:")
2016-03-10 23:45:40 +13:00
for s in files["status.txt"].split("\n"):
if not s:
continue
LOGGER.debug("* Add status: %s", s)
2016-03-10 23:45:40 +13:00
mdl.appendRow(QStandardItem(s))
else:
errors.append("status.txt")
####################################################################################################################
# Infos
mdl = mw.mdlFlatData
if "infos.txt" in files:
md, body = parseMMDFile(files["infos.txt"], asDict=True)
row = []
for name in ["Title", "Subtitle", "Serie", "Volume", "Genre", "License", "Author", "Email"]:
row.append(QStandardItem(md.get(name, "")))
mdl.appendRow(row)
else:
errors.append("infos.txt")
####################################################################################################################
# Summary
mdl = mw.mdlFlatData
if "summary.txt" in files:
md, body = parseMMDFile(files["summary.txt"], asDict=True)
row = []
for name in ["Situation", "Sentence", "Paragraph", "Page", "Full"]:
row.append(QStandardItem(md.get(name, "")))
mdl.appendRow(row)
else:
errors.append("summary.txt")
####################################################################################################################
# Plots
mdl = mw.mdlPlots
if "plots.xml" in files:
LOGGER.debug("Reading plots:")
2016-03-10 23:45:40 +13:00
# xml = bytearray(files["plots.xml"], "utf-8")
root = ET.fromstring(files["plots.xml"])
for plot in root:
# Create row
row = getStandardItemRowFromXMLEnum(plot, Plot)
# Log
LOGGER.debug("* Add plot: %s", row[0].text())
2016-03-10 23:45:40 +13:00
# Characters
2017-11-16 09:05:48 +13:00
if row[Plot.characters].text():
IDs = row[Plot.characters].text().split(",")
2016-03-10 23:45:40 +13:00
item = QStandardItem()
for ID in IDs:
item.appendRow(QStandardItem(ID.strip()))
2017-11-16 09:05:48 +13:00
row[Plot.characters] = item
2016-03-10 23:45:40 +13:00
# Subplots
for step in plot:
2017-11-16 09:05:48 +13:00
row[Plot.steps].appendRow(
2016-03-10 23:45:40 +13:00
getStandardItemRowFromXMLEnum(step, PlotStep)
)
# Add row to the model
mdl.appendRow(row)
else:
errors.append("plots.xml")
####################################################################################################################
# World
mdl = mw.mdlWorld
if "world.opml" in files:
LOGGER.debug("Reading World:")
2016-03-10 23:45:40 +13:00
# xml = bytearray(files["plots.xml"], "utf-8")
root = ET.fromstring(files["world.opml"])
body = root.find("body")
for outline in body:
row = getOutlineItem(outline, World)
mdl.appendRow(row)
else:
errors.append("world.opml")
####################################################################################################################
# Characters
mdl = mw.mdlCharacter
LOGGER.debug("Reading Characters:")
2016-03-10 23:45:40 +13:00
for f in [f for f in files if "characters" in f]:
md, body = parseMMDFile(files[f])
c = mdl.addCharacter()
2016-03-11 02:11:28 +13:00
c.lastPath = f
2016-03-10 23:45:40 +13:00
color = False
for desc, val in md:
# Base infos
if desc in characterMap.values():
key = [key for key, value in characterMap.items() if value == desc][0]
index = c.index(key.value)
mdl.setData(index, val)
# Character color
elif desc == "Color" and not color:
c.setColor(QColor(val))
# We remember the first time we found "Color": it is the icon color.
# If "Color" comes a second time, it is a Character's info.
color = True
# Character's infos
else:
c.infos.append(CharacterInfo(c, desc, val))
LOGGER.debug("* Adds {} ({})".format(c.name(), c.ID()))
2016-03-10 23:45:40 +13:00
2016-03-11 01:10:31 +13:00
####################################################################################################################
# Texts
# We read outline form the outline folder. If revisions are saved, then there's also a revisions.xml which contains
# everything, but the outline folder takes precedence (in cases it's been edited outside of manuskript.
2016-03-11 01:10:31 +13:00
mdl = mw.mdlOutline
LOGGER.debug("Reading outline:")
2016-03-11 01:10:31 +13:00
paths = [f for f in files if "outline" in f]
outline = OrderedDict()
# We create a structure of imbricated OrderedDict to store the whole tree.
for f in paths:
split = f.split(os.path.sep)[1:]
# LOGGER.debug("* %s", split)
2016-03-11 01:10:31 +13:00
last = ""
parent = outline
2016-03-11 02:11:28 +13:00
parentLastPath = "outline"
2016-03-11 01:10:31 +13:00
for i in split:
if last:
parent = parent[last]
2016-03-11 02:11:28 +13:00
parentLastPath = os.path.join(parentLastPath, last)
2016-03-11 01:10:31 +13:00
last = i
if not i in parent:
2016-03-11 02:11:28 +13:00
# If not last item, then it is a folder
2016-03-11 01:10:31 +13:00
if i != split[-1]:
parent[i] = OrderedDict()
# If file, we store it
else:
parent[i] = files[f]
2016-03-11 02:11:28 +13:00
# We store f to add it later as lastPath
parent[i + ":lastPath"] = os.path.join(parentLastPath, i)
2016-03-11 01:10:31 +13:00
# We now just have to recursively add items.
addTextItems(mdl, outline)
# Adds revisions
if "revisions.xml" in files:
root = ET.fromstring(files["revisions.xml"])
appendRevisions(mdl, root)
# Check IDS
mdl.rootItem.checkIDs()
if len(filesWithPermissionErrors) > 0:
dlg = ListDialog(mw)
dlg.setModal(True)
dlg.setWindowTitle(dlg.tr("Files not loaded"))
dlg.label.setText(dlg.tr("The following files were not loaded and appear to be open in another program"))
for f in filesWithPermissionErrors:
QListWidgetItem(f, dlg.listWidget)
dlg.open()
2016-03-11 01:10:31 +13:00
return errors
def addTextItems(mdl, odict, parent=None):
"""
Adds a text / outline items from an OrderedDict.
@param mdl: model to add to
@param odict: OrderedDict
@return: nothing
"""
if parent is None:
2016-03-11 01:10:31 +13:00
parent = mdl.rootItem
for k in odict:
# In case k is a folder:
if (type(odict[k]) == OrderedDict) and ("folder.txt" in odict[k]):
2016-03-11 01:10:31 +13:00
# Adds folder
LOGGER.debug("{}* Adds {} to {} (folder)".format(" " * parent.level(), k, parent.title()))
2016-03-11 01:10:31 +13:00
item = outlineFromMMD(odict[k]["folder.txt"], parent=parent)
2016-03-11 02:11:28 +13:00
item._lastPath = odict[k + ":lastPath"]
2016-03-11 01:10:31 +13:00
# Read content
addTextItems(mdl, odict[k], parent=item)
if (":lastPath" in k) or (k == "folder.txt"):
continue
2016-03-11 02:11:28 +13:00
# k is not a folder
if type(odict[k]) == str:
try:
LOGGER.debug("{}* Adds {} to {} (file)".format(" " * parent.level(), k, parent.title()))
item = outlineFromMMD(odict[k], parent=parent)
item._lastPath = odict[k + ":lastPath"]
except KeyError:
Add GitHub Actions Windows CI build to commits (#1092) * Update build script, maybe? * Squashed commit of the following: commit a50aff9fb73c407a78da6013a1661c9cfbbc3d6d Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 14:40:59 2022 -0500 Add install recommends back, forgot it... commit 8034957fbcfe07b5408e926bf0cd4c8dc2a97501 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 14:18:16 2022 -0500 Try 64 bit builds? commit 4b624eff44b2c76ffad7fcf5cfb36d14797d9f6e Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 13:47:33 2022 -0500 Remove wineprefix to test. commit 1dc8cd0ab0ae10211b267cbb9d24df88e31ea47d Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 13:37:30 2022 -0500 Swap to staging. commit eb750931e018f6b608a5ffe38877b1d544f8605d Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 13:28:23 2022 -0500 printing shit to try and diagnose. commit c45c47db53d82521a61e053b91aac3fcd4909be2 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 13:06:48 2022 -0500 Try winebooting first. commit 6e618ff60b881e90e0427571abb740eabf2943bb Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 12:54:46 2022 -0500 Try running with xvfb to deal with display issues? commit cf0b938b756c078d59bde0914a5fe8f42da47a75 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 12:34:27 2022 -0500 Swapping back to stable I guess? commit 8b03199a6e5d08a862b370379642dd0df13bafff Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 12:14:09 2022 -0500 Fix broken closing bracket. commit b4d0c7ba4951b3efa86c8276707f734008292108 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:53:17 2022 -0500 Fix stupid stub call of wine --version that I put an echo on that wasn't needed... commit 9632b39c5873f1bec1cb7f7d1f370ebdb2972589 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:46:43 2022 -0500 Try WineHQ steps after fix patch. commit af21ddbec2ee0533a8cd4a1d8536a82a85f6f5cd Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:43:12 2022 -0500 Add Wine version print. commit b500eced8c2f815d3d29c0eaff2c438480e16396 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:39:04 2022 -0500 Alternate name? commit c2d9b751422de889b3ffc6943b052024318c19c6 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:35:01 2022 -0500 Swap back to devel (since it goes stable->devel->staging apparently.) commit 8cc5977d1acd8486b535a95c5900cbe33c31e280 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:30:48 2022 -0500 Try out wine staging and update python. commit 33af296b213cfc738ec88436c28fd458b5eabd1b Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:30:33 2022 -0500 Try out wine staging and pray. commit 551227bbee6526f6c4dcbde0fdd07f5e784cc220 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:25:05 2022 -0500 Undo mucked syntax. commit f67edaf009201c93fc454cb2c9dadf10ab7962bd Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:24:37 2022 -0500 Older pandoc test. commit 728707b5a2ce54af48c32594abf2ea72d17675b2 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:23:48 2022 -0500 Try older pandoc install. commit 7dee6c0039406c1ad6531fb33ce1815c33a46243 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:16:07 2022 -0500 Try to shorten build steps process. commit f2f9a5bd1c01d2351c31815903614e36ad89d577 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:14:52 2022 -0500 Remove APT cache. commit 1cdc43ae7a289b820a24d4917992ac055c336f4f Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:10:10 2022 -0500 Fix syntax error. commit 9cc172a343632e12c624e440c5b625de42487153 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:08:28 2022 -0500 Try workaround in issue. commit 6a9f2b38c18978b32a83649b813010ed35d2e7a4 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 10:53:02 2022 -0500 Regular wine whine. commit b202e08fd95a6a001ce181de43d78433a6cce16e Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:54:47 2022 -0500 List sources so I can remove deb.sury.org from stuff. commit 5bc6d770de9a73c0a6db82a00343a71f905a27c1 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:49:53 2022 -0500 Try the workaround. commit 58bee4649a1f988f6ce0c0f394c908e6ad7acd4c Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:45:59 2022 -0500 Try this selector? commit c11b9b9e943c334fea9ce9ab3d6bc600958b8659 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:41:48 2022 -0500 WIne32 prayer. commit d1afae710eff839c80e942ad7cac877dca5e6cf5 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:38:30 2022 -0500 Clear cache and pray. commit 145d38117d90ba164238f75cee2ef74734282b0c Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:34:30 2022 -0500 explicitly install libwine386. commit f152a63310a856650301ea73ae04c2e834d0cdea Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:30:31 2022 -0500 sudo sudo sudo commit df17f589c2f9c40f71ec788623cba9f369f3d5b5 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:28:04 2022 -0500 i386 wine32 prayers. commit d172b98b37b51e39209795f377eeadb9c6e5fd3c Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:22:38 2022 -0500 Swap wine calls to wine64. commit b56fe9fe498f9069239f8d8cf1dd83b81585272f Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:18:43 2022 -0500 Tiny tweak. commit a9c928e0066ca5250f6087c126d11f7b3f14c84d Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:16:28 2022 -0500 Simplify. commit ef9c94d8e2ef896eb428aa6e9d24b52cffd482c1 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:14:54 2022 -0500 Update to 22.04 and hoping. commit 5039fc25c04598c29c4ef7380f0b8207085d23a8 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:12:05 2022 -0500 Remove WineHQ again I guess. commit 32f46bbbfda89b1fb31f773ba36c98e6fef5e623 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:08:45 2022 -0500 Add multiverse/universe. commit 10f80d0a4948beb47f5380ab9b62889389898481 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:07:33 2022 -0500 Reordering and praying. commit 42be65f6573b8dece1ee3c4494ba28ae21623caf Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:05:58 2022 -0500 Purge. commit ddb83a8fe411c2083a119bb2e70bd377d839822a Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:05:20 2022 -0500 try me. commit 9214a1bb3d237c66e3a7a4b288c208147bee9469 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:02:01 2022 -0500 Or not... commit af8eff93092bb7b11c883cd7eaf0d02d28f0114f Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:59:35 2022 -0500 Trying to explicitly install amd64 install... we'll see I guess? commit 5c56958e6bcc003bd0badaf5663f3dadb385552d Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:56:08 2022 -0500 Typo fix. commit 71c784e619e35f204d410477c46b56378de747cb Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:54:00 2022 -0500 Trying to remove MSFT build repo. commit 48c8506bdb85f48e674393ad41f8ba2e2bb2cc2c Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:48:08 2022 -0500 Upgrading first. commit 3e540cca38ce6fe9fd7b518033fae643a59e55bf Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:45:04 2022 -0500 Wine Ubuntu specific instructions and hoping. commit ce4b7db69aba1ceef8bb569302530a22cb998bf4 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:42:05 2022 -0500 Try with install reccomends *this time*. commit cff2ad19fee1645bfca29045e03fcb00d71f59d7 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:40:10 2022 -0500 Try again with 386. commit 25efa15ba7d0645c70a16239d02df054465077b5 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:37:46 2022 -0500 Trying different instructions and hoping. commit 50fc7d80867fc3f25af48dba4e886de8256d9a37 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:33:55 2022 -0500 Install suggests and hope and pray. commit 928a871263b0e3ac6e0ceee770bae8c3350de651 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:31:16 2022 -0500 Forgot sudo again. commit 60ab87149345d19ecf86ef8f887ad0c824b482fa Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:29:29 2022 -0500 testing again. commit 02c4ee7954473ff004733cc7d73b34ba2cf8e312 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:24:16 2022 -0500 We ball. commit 0bdf889ca5a0a5a712964a725caabc3bc0e5a1db Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:20:59 2022 -0500 Trying out modified instructions. commit 600ab4fad16de201016487f34ef3e6db980cf7a0 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:16:57 2022 -0500 Try instructions from Winehq. commit 487be119657e307dac7370cdd8849532596fc9e7 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:12:50 2022 -0500 Try with just stock wine? commit e27ec743cbe7cb591958711f330d3d64f7559ce0 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:07:39 2022 -0500 Trying out winehq-develop step. commit 2e2a0c9b058000282f7fd45966031f7d1059124f Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:05:14 2022 -0500 Try rearranging purge and re-install stuff. commit ea26769e2c213202bc85915b33243313adf95998 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:00:07 2022 -0500 Remove erroneous procss call. Embarassing. commit 10fc0e7d568eae2b093cf34de50ad464e94e56fe Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 15:57:51 2022 -0500 Rearrange to try and cache apt from wine too. commit d11f5b686570e9971e028ec05689179b56feb199 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 15:52:40 2022 -0500 Fix *all* the calls in section to run as root.... fml. commit ae10399abb88b1ffe7aefc0d37fe8e0f041f1b33 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 15:35:42 2022 -0500 add sudo to dpkg call. commit 2507fcc838ce4cf41199b1fa8810c91d539d33be Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 15:30:25 2022 -0500 Add installer step to add i386 wine. commit 0a8a5afb376acdc69c3cd41ee69b32c9a3807ca7 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 15:25:54 2022 -0500 Try just re-running i guess. commit 8f41100f5eabd3f69186bc425c43c5eb0507768b Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 15:22:00 2022 -0500 Trying to kill latent xvfb that didn't close? commit c95bc0368ff94169e3544fd53ec72dfaa51cada8 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 15:17:15 2022 -0500 Fix package name, hopefully it runs. commit 8bf1f1febe52fbbdc06d2902290d8c1a6d474ae3 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 15:11:55 2022 -0500 Add upgrade step to hopefully help. We'll see. commit ea2322c5a8f7987c63344a91de24a7f570147ecc Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 15:09:39 2022 -0500 Install Wine from different place? We'll see. commit b2642f6d4ae5c31e1193433513fa3b48082cb37b Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 15:05:49 2022 -0500 Run in xvfb for CI/CD. commit 208fa49759825848036822131164f1fec645b928 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 15:00:09 2022 -0500 Tiny tweaks to fix Wine build issues. commit 422f589384499698bd2f91c1bc3b6ee3a43b4b9e Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:56:18 2022 -0500 Try with SHA short? commit e16a23eeb2c53a5c5f07a545128af225d8bc2536 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:54:03 2022 -0500 Swap to forced 64 bit builds (it's 2022, please...) commit cb8278f23cfc9d4627519973e49c5c0722e1a859 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:51:24 2022 -0500 Runner is not root. Continue. commit c3d27a4191b655f83aa2057593679e4e26d4b9da Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:50:44 2022 -0500 Fix silly syntax issue. commit 8b51550034a6b82a13f28fdd7730cdec49a0b32d Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:49:38 2022 -0500 Fix missing Windows Python and continue on. commit 70a20d03fadb73d1813486ad8947347aeb4d7ae9 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:44:26 2022 -0500 Add wine to apt dependencies. commit df00da451a0d7ab7c4e4d910f06fffbcb4de3e74 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:41:52 2022 -0500 Forgot to include the ENV step. commit a6e22d84edcd1c0519bf28e4001a7240e3061212 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:40:03 2022 -0500 Testing WINE builds on GH Actions. commit 2c32e4acf78db1f5a4ab55a713f42ed05538d03e Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:39:42 2022 -0500 Try running windows build script? i suppose? commit 9cb7bbd3fc6a5670713127dcb9928521e8545a7e Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:30:10 2022 -0500 Resolve syntax error #2. oops. commit db02840ae21f003d3857d79ef724c98592ca8299 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:29:39 2022 -0500 Resolve syntax error... oops. commit 8f261a7cecbd35c82d9c306ab75b7eca2cea441f Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:29:08 2022 -0500 Attempting to cache apt packages for faster builds. commit f3857d9e08e8fa18615b032c031c63c950d485ca Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:25:12 2022 -0500 Attempting to print commit hash inside build. commit f06d5adcf7cb9060986e0eb58fbd91f14e5aa538 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:22:09 2022 -0500 hash based git version test 1. commit bb19490c85c40c39f757f9f51e6c60a9188a49aa Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:18:29 2022 -0500 First test of a linux build in Github CI. commit 3808c3989ebbfe77b36f1f7b4dd8c92a444c2397 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:07:20 2022 -0500 Indentation on workflow confirm. commit 194d01a1fcd7770f57c7d8fd7a59cd1832b3197f Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:06:38 2022 -0500 Minor cleanup to make this workflow named properly. commit c27485cf30d4f36e5ccd0600834072fb579beb67 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:02:22 2022 -0500 Update to proper version? Apparently. commit 66cd7034c726d257fd1fb57154f1e5e6422519c9 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:00:11 2022 -0500 Update actions steps. commit 7c650fbb8964d4b57e3546c530c57f9d870f085c Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 13:57:38 2022 -0500 Update to python 3.9 for build script. commit b4111e316cfc851ce1c60b42c8d6ead72de872a9 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 13:56:12 2022 -0500 Try removing buggy build options. * Trim together Windows build errata. * Revert Windows build file to what it was at the start of this adventure to not break anyone else's work. * Explicitly try to remove the files per the priorly mentioned W7 issues. * Add semicolons to separate in-line powershell. * Update path of Qt5Bluetooth.dll to be removed Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> Co-authored-by: TheJackiMonster <thejackimonster@gmail.com>
2022-12-16 13:11:26 +13:00
LOGGER.error(f"Failed to add file {k}")
else:
Add GitHub Actions Windows CI build to commits (#1092) * Update build script, maybe? * Squashed commit of the following: commit a50aff9fb73c407a78da6013a1661c9cfbbc3d6d Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 14:40:59 2022 -0500 Add install recommends back, forgot it... commit 8034957fbcfe07b5408e926bf0cd4c8dc2a97501 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 14:18:16 2022 -0500 Try 64 bit builds? commit 4b624eff44b2c76ffad7fcf5cfb36d14797d9f6e Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 13:47:33 2022 -0500 Remove wineprefix to test. commit 1dc8cd0ab0ae10211b267cbb9d24df88e31ea47d Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 13:37:30 2022 -0500 Swap to staging. commit eb750931e018f6b608a5ffe38877b1d544f8605d Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 13:28:23 2022 -0500 printing shit to try and diagnose. commit c45c47db53d82521a61e053b91aac3fcd4909be2 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 13:06:48 2022 -0500 Try winebooting first. commit 6e618ff60b881e90e0427571abb740eabf2943bb Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 12:54:46 2022 -0500 Try running with xvfb to deal with display issues? commit cf0b938b756c078d59bde0914a5fe8f42da47a75 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 12:34:27 2022 -0500 Swapping back to stable I guess? commit 8b03199a6e5d08a862b370379642dd0df13bafff Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 12:14:09 2022 -0500 Fix broken closing bracket. commit b4d0c7ba4951b3efa86c8276707f734008292108 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:53:17 2022 -0500 Fix stupid stub call of wine --version that I put an echo on that wasn't needed... commit 9632b39c5873f1bec1cb7f7d1f370ebdb2972589 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:46:43 2022 -0500 Try WineHQ steps after fix patch. commit af21ddbec2ee0533a8cd4a1d8536a82a85f6f5cd Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:43:12 2022 -0500 Add Wine version print. commit b500eced8c2f815d3d29c0eaff2c438480e16396 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:39:04 2022 -0500 Alternate name? commit c2d9b751422de889b3ffc6943b052024318c19c6 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:35:01 2022 -0500 Swap back to devel (since it goes stable->devel->staging apparently.) commit 8cc5977d1acd8486b535a95c5900cbe33c31e280 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:30:48 2022 -0500 Try out wine staging and update python. commit 33af296b213cfc738ec88436c28fd458b5eabd1b Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:30:33 2022 -0500 Try out wine staging and pray. commit 551227bbee6526f6c4dcbde0fdd07f5e784cc220 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:25:05 2022 -0500 Undo mucked syntax. commit f67edaf009201c93fc454cb2c9dadf10ab7962bd Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:24:37 2022 -0500 Older pandoc test. commit 728707b5a2ce54af48c32594abf2ea72d17675b2 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:23:48 2022 -0500 Try older pandoc install. commit 7dee6c0039406c1ad6531fb33ce1815c33a46243 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:16:07 2022 -0500 Try to shorten build steps process. commit f2f9a5bd1c01d2351c31815903614e36ad89d577 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:14:52 2022 -0500 Remove APT cache. commit 1cdc43ae7a289b820a24d4917992ac055c336f4f Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:10:10 2022 -0500 Fix syntax error. commit 9cc172a343632e12c624e440c5b625de42487153 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 11:08:28 2022 -0500 Try workaround in issue. commit 6a9f2b38c18978b32a83649b813010ed35d2e7a4 Author: Kim Chase <me@hi-im.kim> Date: Tue Dec 13 10:53:02 2022 -0500 Regular wine whine. commit b202e08fd95a6a001ce181de43d78433a6cce16e Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:54:47 2022 -0500 List sources so I can remove deb.sury.org from stuff. commit 5bc6d770de9a73c0a6db82a00343a71f905a27c1 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:49:53 2022 -0500 Try the workaround. commit 58bee4649a1f988f6ce0c0f394c908e6ad7acd4c Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:45:59 2022 -0500 Try this selector? commit c11b9b9e943c334fea9ce9ab3d6bc600958b8659 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:41:48 2022 -0500 WIne32 prayer. commit d1afae710eff839c80e942ad7cac877dca5e6cf5 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:38:30 2022 -0500 Clear cache and pray. commit 145d38117d90ba164238f75cee2ef74734282b0c Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:34:30 2022 -0500 explicitly install libwine386. commit f152a63310a856650301ea73ae04c2e834d0cdea Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:30:31 2022 -0500 sudo sudo sudo commit df17f589c2f9c40f71ec788623cba9f369f3d5b5 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:28:04 2022 -0500 i386 wine32 prayers. commit d172b98b37b51e39209795f377eeadb9c6e5fd3c Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:22:38 2022 -0500 Swap wine calls to wine64. commit b56fe9fe498f9069239f8d8cf1dd83b81585272f Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:18:43 2022 -0500 Tiny tweak. commit a9c928e0066ca5250f6087c126d11f7b3f14c84d Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:16:28 2022 -0500 Simplify. commit ef9c94d8e2ef896eb428aa6e9d24b52cffd482c1 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:14:54 2022 -0500 Update to 22.04 and hoping. commit 5039fc25c04598c29c4ef7380f0b8207085d23a8 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:12:05 2022 -0500 Remove WineHQ again I guess. commit 32f46bbbfda89b1fb31f773ba36c98e6fef5e623 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:08:45 2022 -0500 Add multiverse/universe. commit 10f80d0a4948beb47f5380ab9b62889389898481 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:07:33 2022 -0500 Reordering and praying. commit 42be65f6573b8dece1ee3c4494ba28ae21623caf Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:05:58 2022 -0500 Purge. commit ddb83a8fe411c2083a119bb2e70bd377d839822a Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:05:20 2022 -0500 try me. commit 9214a1bb3d237c66e3a7a4b288c208147bee9469 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 17:02:01 2022 -0500 Or not... commit af8eff93092bb7b11c883cd7eaf0d02d28f0114f Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:59:35 2022 -0500 Trying to explicitly install amd64 install... we'll see I guess? commit 5c56958e6bcc003bd0badaf5663f3dadb385552d Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:56:08 2022 -0500 Typo fix. commit 71c784e619e35f204d410477c46b56378de747cb Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:54:00 2022 -0500 Trying to remove MSFT build repo. commit 48c8506bdb85f48e674393ad41f8ba2e2bb2cc2c Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:48:08 2022 -0500 Upgrading first. commit 3e540cca38ce6fe9fd7b518033fae643a59e55bf Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:45:04 2022 -0500 Wine Ubuntu specific instructions and hoping. commit ce4b7db69aba1ceef8bb569302530a22cb998bf4 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:42:05 2022 -0500 Try with install reccomends *this time*. commit cff2ad19fee1645bfca29045e03fcb00d71f59d7 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:40:10 2022 -0500 Try again with 386. commit 25efa15ba7d0645c70a16239d02df054465077b5 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:37:46 2022 -0500 Trying different instructions and hoping. commit 50fc7d80867fc3f25af48dba4e886de8256d9a37 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:33:55 2022 -0500 Install suggests and hope and pray. commit 928a871263b0e3ac6e0ceee770bae8c3350de651 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:31:16 2022 -0500 Forgot sudo again. commit 60ab87149345d19ecf86ef8f887ad0c824b482fa Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:29:29 2022 -0500 testing again. commit 02c4ee7954473ff004733cc7d73b34ba2cf8e312 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:24:16 2022 -0500 We ball. commit 0bdf889ca5a0a5a712964a725caabc3bc0e5a1db Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:20:59 2022 -0500 Trying out modified instructions. commit 600ab4fad16de201016487f34ef3e6db980cf7a0 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:16:57 2022 -0500 Try instructions from Winehq. commit 487be119657e307dac7370cdd8849532596fc9e7 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:12:50 2022 -0500 Try with just stock wine? commit e27ec743cbe7cb591958711f330d3d64f7559ce0 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:07:39 2022 -0500 Trying out winehq-develop step. commit 2e2a0c9b058000282f7fd45966031f7d1059124f Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:05:14 2022 -0500 Try rearranging purge and re-install stuff. commit ea26769e2c213202bc85915b33243313adf95998 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 16:00:07 2022 -0500 Remove erroneous procss call. Embarassing. commit 10fc0e7d568eae2b093cf34de50ad464e94e56fe Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 15:57:51 2022 -0500 Rearrange to try and cache apt from wine too. commit d11f5b686570e9971e028ec05689179b56feb199 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 15:52:40 2022 -0500 Fix *all* the calls in section to run as root.... fml. commit ae10399abb88b1ffe7aefc0d37fe8e0f041f1b33 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 15:35:42 2022 -0500 add sudo to dpkg call. commit 2507fcc838ce4cf41199b1fa8810c91d539d33be Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 15:30:25 2022 -0500 Add installer step to add i386 wine. commit 0a8a5afb376acdc69c3cd41ee69b32c9a3807ca7 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 15:25:54 2022 -0500 Try just re-running i guess. commit 8f41100f5eabd3f69186bc425c43c5eb0507768b Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 15:22:00 2022 -0500 Trying to kill latent xvfb that didn't close? commit c95bc0368ff94169e3544fd53ec72dfaa51cada8 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 15:17:15 2022 -0500 Fix package name, hopefully it runs. commit 8bf1f1febe52fbbdc06d2902290d8c1a6d474ae3 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 15:11:55 2022 -0500 Add upgrade step to hopefully help. We'll see. commit ea2322c5a8f7987c63344a91de24a7f570147ecc Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 15:09:39 2022 -0500 Install Wine from different place? We'll see. commit b2642f6d4ae5c31e1193433513fa3b48082cb37b Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 15:05:49 2022 -0500 Run in xvfb for CI/CD. commit 208fa49759825848036822131164f1fec645b928 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 15:00:09 2022 -0500 Tiny tweaks to fix Wine build issues. commit 422f589384499698bd2f91c1bc3b6ee3a43b4b9e Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:56:18 2022 -0500 Try with SHA short? commit e16a23eeb2c53a5c5f07a545128af225d8bc2536 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:54:03 2022 -0500 Swap to forced 64 bit builds (it's 2022, please...) commit cb8278f23cfc9d4627519973e49c5c0722e1a859 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:51:24 2022 -0500 Runner is not root. Continue. commit c3d27a4191b655f83aa2057593679e4e26d4b9da Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:50:44 2022 -0500 Fix silly syntax issue. commit 8b51550034a6b82a13f28fdd7730cdec49a0b32d Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:49:38 2022 -0500 Fix missing Windows Python and continue on. commit 70a20d03fadb73d1813486ad8947347aeb4d7ae9 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:44:26 2022 -0500 Add wine to apt dependencies. commit df00da451a0d7ab7c4e4d910f06fffbcb4de3e74 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:41:52 2022 -0500 Forgot to include the ENV step. commit a6e22d84edcd1c0519bf28e4001a7240e3061212 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:40:03 2022 -0500 Testing WINE builds on GH Actions. commit 2c32e4acf78db1f5a4ab55a713f42ed05538d03e Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:39:42 2022 -0500 Try running windows build script? i suppose? commit 9cb7bbd3fc6a5670713127dcb9928521e8545a7e Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:30:10 2022 -0500 Resolve syntax error #2. oops. commit db02840ae21f003d3857d79ef724c98592ca8299 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:29:39 2022 -0500 Resolve syntax error... oops. commit 8f261a7cecbd35c82d9c306ab75b7eca2cea441f Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:29:08 2022 -0500 Attempting to cache apt packages for faster builds. commit f3857d9e08e8fa18615b032c031c63c950d485ca Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:25:12 2022 -0500 Attempting to print commit hash inside build. commit f06d5adcf7cb9060986e0eb58fbd91f14e5aa538 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:22:09 2022 -0500 hash based git version test 1. commit bb19490c85c40c39f757f9f51e6c60a9188a49aa Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:18:29 2022 -0500 First test of a linux build in Github CI. commit 3808c3989ebbfe77b36f1f7b4dd8c92a444c2397 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:07:20 2022 -0500 Indentation on workflow confirm. commit 194d01a1fcd7770f57c7d8fd7a59cd1832b3197f Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:06:38 2022 -0500 Minor cleanup to make this workflow named properly. commit c27485cf30d4f36e5ccd0600834072fb579beb67 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:02:22 2022 -0500 Update to proper version? Apparently. commit 66cd7034c726d257fd1fb57154f1e5e6422519c9 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 14:00:11 2022 -0500 Update actions steps. commit 7c650fbb8964d4b57e3546c530c57f9d870f085c Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 13:57:38 2022 -0500 Update to python 3.9 for build script. commit b4111e316cfc851ce1c60b42c8d6ead72de872a9 Author: Kim Chase <me@hi-im.kim> Date: Mon Dec 12 13:56:12 2022 -0500 Try removing buggy build options. * Trim together Windows build errata. * Revert Windows build file to what it was at the start of this adventure to not break anyone else's work. * Explicitly try to remove the files per the priorly mentioned W7 issues. * Add semicolons to separate in-line powershell. * Update path of Qt5Bluetooth.dll to be removed Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> Co-authored-by: TheJackiMonster <thejackimonster@gmail.com>
2022-12-16 13:11:26 +13:00
LOGGER.debug(f"Strange things in file {k}")
2016-03-11 01:10:31 +13:00
def outlineFromMMD(text, parent):
"""
Creates outlineItem from multimarkdown file.
@param text: content of the file
@param parent: appends item to parent (outlineItem)
@return: outlineItem
"""
md, body = parseMMDFile(text, asDict=True)
# Assign ID on creation, to avoid generating a new ID for this object
item = outlineItem(parent=parent, ID=md.pop('ID'))
2016-03-11 01:10:31 +13:00
# Store metadata
for k in md:
if k in Outline.__members__:
2017-11-16 08:58:12 +13:00
item.setData(Outline.__members__[k], str(md[k]))
2016-03-11 01:10:31 +13:00
# Store body
2017-11-16 08:58:12 +13:00
item.setData(Outline.text, str(body))
2016-03-11 01:10:31 +13:00
2016-03-30 22:14:05 +13:00
# Set file format to "md"
# (Old version of manuskript had different file formats: text, t2t, html and md)
# If file format is html, convert to plain text:
if item.type() == "html":
2017-11-16 08:58:12 +13:00
item.setData(Outline.text, HTML2PlainText(body))
2016-03-30 22:14:05 +13:00
if item.type() in ["txt", "t2t", "html"]:
2017-11-16 08:58:12 +13:00
item.setData(Outline.type, "md")
2016-03-30 22:14:05 +13:00
2016-03-11 01:10:31 +13:00
return item
def appendRevisions(mdl, root):
"""
Parse etree item to find outlineItem's with revisions, and adds them to model `mdl`.
@param mdl: outlineModel
@param root: etree
@return: nothing
"""
for child in root:
# Recursively go through items
if child.tag == "outlineItem":
appendRevisions(mdl, child)
# Revision found.
elif child.tag == "revision":
# Get root's ID
ID = root.attrib["ID"]
if not ID:
LOGGER.debug("* Serious problem: no ID!")
LOGGER.error("Revision has no ID associated!")
2016-03-11 02:38:46 +13:00
continue
2016-03-11 01:10:31 +13:00
# Find outline item in model
item = mdl.getItemByID(ID)
2016-03-11 02:38:46 +13:00
if not item:
LOGGER.debug("* Error: no item whose ID is %s", ID)
LOGGER.error("Could not identify the item matching the revision ID.")
2016-03-11 02:38:46 +13:00
continue
2016-03-11 01:10:31 +13:00
# Store revision
LOGGER.debug("* Appends revision ({}) to {}".format(child.attrib["timestamp"], item.title()))
2016-03-11 01:10:31 +13:00
item.appendRevision(child.attrib["timestamp"], child.attrib["text"])
2016-03-10 23:45:40 +13:00
def getOutlineItem(item, enum):
2016-03-11 01:10:31 +13:00
"""
Reads outline items from an opml file. Returns a row of QStandardItem, easy to add to a QStandardItemModel.
@param item: etree item
@param enum: enum to read keys from
@return: [QStandardItem]
"""
2016-03-10 23:45:40 +13:00
row = getStandardItemRowFromXMLEnum(item, enum)
LOGGER.debug("* Add worldItem: %s", row[0].text())
2016-03-10 23:45:40 +13:00
for child in item:
sub = getOutlineItem(child, enum)
row[0].appendRow(sub)
return row
2016-03-11 01:10:31 +13:00
2016-03-10 23:45:40 +13:00
def getStandardItemRowFromXMLEnum(item, enum):
"""
Reads and etree item and creates a row of QStandardItems by cross-referencing an enum.
Returns a list of QStandardItems that can be added to a QStandardItemModel by appendRow.
@param item: the etree item
@param enum: the enum
@return: list of QStandardItems
"""
row = []
for i in range(len(enum)):
row.append(QStandardItem(""))
for name in item.attrib:
if name in enum.__members__:
row[enum[name].value] = QStandardItem(item.attrib[name])
return row
def parseMMDFile(text, asDict=False):
"""
Takes the content of a MultiMarkDown file (str) and returns:
1. A list containing metadatas: (description, value) if asDict is False.
If asDict is True, returns metadatas as an OrderedDict. Be aware that if multiple metadatas have the same description
(which is stupid, but hey), they will be lost except the last one.
2. The body of the file
@param text: the content of the file
@return: (list, str) or (OrderedDict, str)
"""
md = []
mdd = OrderedDict()
body = []
descr = ""
val = ""
inBody = False
for s in text.split("\n"):
if not inBody:
2016-03-11 02:38:46 +13:00
m = re.match(r"^([^\s].*?):\s*(.*)$", s)
2016-03-10 23:45:40 +13:00
if m:
# Commit last metadata
if descr:
if descr == "None":
descr = ""
md.append((descr, val))
mdd[descr] = val
descr = ""
val = ""
# Store new values
descr = m.group(1)
val = m.group(2)
elif s[:4] == " ":
val += "\n" + s.strip()
elif s == "":
# End of metadatas
inBody = True
# Commit last metadata
if descr:
if descr == "None":
descr = ""
md.append((descr, val))
mdd[descr] = val
else:
2016-03-11 01:10:31 +13:00
body.append(s)
2016-03-10 23:45:40 +13:00
# We remove the second empty line (since we save with two empty lines)
if body and body[0] == "":
body = body[1:]
body = "\n".join(body)
if not asDict:
return md, body
else:
return mdd, body