cleaned, decorated, added headers to code source

This commit is contained in:
Bachir Soussi Chiadmi
2017-06-03 21:18:58 +02:00
parent 5a34843836
commit 06a1c3bbed
10 changed files with 101 additions and 51 deletions
+1 -2
View File
@@ -1,12 +1,11 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# @Author: Bachir Soussi Chiadmi <bach>
# @Date: 23-05-2017
# @Email: bachir@figureslibres.io
# @Last modified by: bach
# @Last modified time: 21-04-2017
# @Last modified time: 03-06-2017
# @License: GPL-V3
import sys
+13 -7
View File
@@ -1,6 +1,14 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# @Author: Bachir Soussi Chiadmi <bach>
# @Date: 23-05-2017
# @Email: bachir@figureslibres.io
# @Filename: content.py
# @Last modified by: bach
# @Last modified time: 03-06-2017
# @License: GPL-V3
import os, re
from PyQt5 import QtCore
@@ -127,7 +135,6 @@ class SummaryList(QListWidget):
# print('onItemActivated', item.data)
self.parent.parent.editor.openFile(self.currentRow())
class SummaryListWidgetItem(QListWidgetItem):
def __init__(self,parent,data):
super(SummaryListWidgetItem, self).__init__(parent)
@@ -137,7 +144,6 @@ class SummaryListWidgetItem(QListWidgetItem):
self.setText(data['title'])
self.setToolTip(data['file'])
class SummaryActions(QWidget):
def __init__(self,parent):
super(SummaryActions, self).__init__(parent)
@@ -253,11 +259,11 @@ class MarkdownEditor(QWidget):
# self.tabs.setTabText(i, re.sub(r'^\*\s', '', self.tabs.tabText(i)))
# TODO: how to combine file save and project save
# __ ___ _
# / |/ /___ _(_)___
# / /|_/ / __ `/ / __ \
# / / / / /_/ / / / / /
# /_/ /_/\__,_/_/_/ /_/
# _____ __ __
# / ___// /_____ ______/ /__
# \__ \/ __/ __ `/ ___/ //_/
# ___/ / /_/ /_/ / /__/ ,<
# /____/\__/\__,_/\___/_/|_|
class ContentStack(QWidget):
def __init__(self, core):
super(ContentStack, self).__init__()
+1 -2
View File
@@ -1,12 +1,11 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# @Author: Bachir Soussi Chiadmi <bach>
# @Date: 23-05-2017
# @Email: bachir@figureslibres.io
# @Last modified by: bach
# @Last modified time: 21-04-2017
# @Last modified time: 03-06-2017
# @License: GPL-V3
import os, re, shutil, tempfile
+34 -5
View File
@@ -1,6 +1,14 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# @Author: Bachir Soussi Chiadmi <bach>
# @Date: 23-05-2017
# @Email: bachir@figureslibres.io
# @Filename: design.py
# @Last modified by: bach
# @Last modified time: 03-06-2017
# @License: GPL-V3
import os, re
# sys,
from PyQt5 import QtCore
@@ -11,12 +19,14 @@ from PyQt5.QtWebKit import QWebSettings
from PyQt5.QtWebKitWidgets import QWebView, QWebInspector
from PyQt5.QtPrintSupport import QPrintPreviewDialog, QPrinter
# from pygments import highlight
# from pygments.lexers import *
# from pygments.formatter import Formatter
from classes import highlighter
# _ __ __ _ ___
# | | / /__ / /_| | / (_)__ _ __
# | | /| / / _ \/ __ \ | / / / _ \ | /| / /
# | |/ |/ / __/ /_/ / |/ / / __/ |/ |/ /
# |__/|__/\___/_.___/|___/_/\___/|__/|__/
class WebkitView(QWebView):
def __init__(self, parent, core):
self.parent = parent
@@ -79,6 +89,12 @@ class WebkitView(QWebView):
def evaluateJS(self, command):
self.page().mainFrame().evaluateJavaScript(command)
# ____ __
# / _/___ _________ ___ _____/ /_____ _____
# / // __ \/ ___/ __ \/ _ \/ ___/ __/ __ \/ ___/
# _/ // / / (__ ) /_/ / __/ /__/ /_/ /_/ / /
# /___/_/ /_/____/ .___/\___/\___/\__/\____/_/
# /_/
class WebkitInspector(QWebInspector):
def __init__(self, parent, webkitview):
super(WebkitInspector, self).__init__(parent)
@@ -87,6 +103,11 @@ class WebkitInspector(QWebInspector):
self.showMaximized()
# TODO: webkitinspector is disappearing when chaging tabs
# ______ ______
# /_ __/___ ____ / / __ )____ ______
# / / / __ \/ __ \/ / __ / __ `/ ___/
# / / / /_/ / /_/ / / /_/ / /_/ / /
# /_/ \____/\____/_/_____/\__,_/_/
class WebViewToolBar(QWidget):
def __init__(self, parent):
super(WebViewToolBar, self).__init__(parent)
@@ -184,7 +205,11 @@ class WebViewToolBar(QWidget):
print("onGenPDF")
self.parent.webkitview.ongenPDF()
# ______ ___ __
# / ____/___/ (_) /_____ _____
# / __/ / __ / / __/ __ \/ ___/
# / /___/ /_/ / / /_/ /_/ / /
# /_____/\__,_/_/\__/\____/_/
class CodeEditor(QPlainTextEdit):
def __init__(self, core, tabs, file, mode):
super(CodeEditor, self).__init__()
@@ -239,7 +264,6 @@ class CodeEditor(QPlainTextEdit):
self.changed = False
# TODO: how to combine file save and project save
class Editor(QWidget):
def __init__(self, parent, core):
super(Editor, self).__init__()
@@ -266,6 +290,11 @@ class Editor(QWidget):
self.scsstab.setText()
self.jstab.setText()
# _____ __ __
# / ___// /_____ ______/ /__
# \__ \/ __/ __ `/ ___/ //_/
# ___/ / /_/ /_/ / /__/ ,<
# /____/\__/\__,_/\___/_/|_|
class DesignStack(QWidget):
def __init__(self, core):
super(DesignStack, self).__init__()
+1 -2
View File
@@ -1,12 +1,11 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# @Author: Bachir Soussi Chiadmi <bach>
# @Date: 23-05-2017
# @Email: bachir@figureslibres.io
# @Last modified by: bach
# @Last modified time: 21-04-2017
# @Last modified time: 03-06-2017
# @License: GPL-V3
import os
+16 -17
View File
@@ -1,4 +1,17 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# @Author: Bachir Soussi Chiadmi <bach>
# @Date: 02-06-2017
# @Email: bachir@figureslibres.io
# @Filename: highlighter.py
# @Last modified by: bach
# @Last modified time: 03-06-2017
# @License: GPL-V3
# TODO add link to the source
import sys
import re
from PyQt5 import QtCore, QtGui
@@ -25,9 +38,11 @@ class QFormatter(Formatter):
Formatter.__init__(self)
self.data=[]
self.style = get_style_by_name(style)
self.linenos = linenos
# self.linenos = linenos
# styles = list(get_all_styles())
# print(styles)
# Create a dictionary of text styles, indexed
# by pygments token names, containing QTextCharFormat
# instances according to pygments' description
@@ -114,19 +129,3 @@ class Highlighter(QtGui.QSyntaxHighlighter):
# I may need to do something about this being called
# too quickly.
self.tstamp=time.time()
# if __name__ == "__main__":
# app = QtGui.QApplication(sys.argv)
#
# rst = QtGui.QPlainTextEdit()
# rst.setWindowTitle('reSt')
# hl=Highlighter(rst.document(),"rest")
# rst.show()
#
# python = QtGui.QPlainTextEdit()
# python.setWindowTitle('python')
# hl=Highlighter(python.document(),"python")
# python.show()
#
# sys.exit(app.exec_())
+11 -5
View File
@@ -1,12 +1,11 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# @Author: Bachir Soussi Chiadmi <bach>
# @Date: 23-05-2017
# @Email: bachir@figureslibres.io
# @Last modified by: bach
# @Last modified time: 21-04-2017
# @Last modified time: 03-06-2017
# @License: GPL-V3
import os
@@ -37,6 +36,11 @@ class MainWindow(QMainWindow):
self.show()
# __ ___ ____
# / |/ /__ ____ __ __/ __ )____ ______
# / /|_/ / _ \/ __ \/ / / / __ / __ `/ ___/
# / / / / __/ / / / /_/ / /_/ / /_/ / /
# /_/ /_/\___/_/ /_/\__,_/_____/\__,_/_/
def initMenuBar(self):
# menu bar
bar = self.menuBar()
@@ -228,13 +232,11 @@ class MainWindow(QMainWindow):
else:
self.core.quit()
def oneditmenutrigger(self, q):
print(q.text()+" is triggered")
if q.text() == "&Reload":
self.designstack.webkitview.reload()
def onviewmenutrigger(self, q):
print(q.text()+" is triggered")
if q.text() == "&Design":
@@ -244,7 +246,11 @@ class MainWindow(QMainWindow):
elif q.text() == "&Version":
self.mainstack.setCurrentIndex(2)
# __ ___ _ _____ __ __
# / |/ /___ _(_)___ / ___// /_____ ______/ /__
# / /|_/ / __ `/ / __ \\__ \/ __/ __ `/ ___/ //_/
# / / / / /_/ / / / / /__/ / /_/ /_/ / /__/ ,<
# /_/ /_/\__,_/_/_/ /_/____/\__/\__,_/\___/_/|_|
def initMainStack(self):
self.mainstack = QStackedWidget()
+8 -9
View File
@@ -1,6 +1,14 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# @Author: Bachir Soussi Chiadmi <bach>
# @Date: 23-05-2017
# @Email: bachir@figureslibres.io
# @Filename: md2html.py
# @Last modified by: bach
# @Last modified time: 03-06-2017
# @License: GPL-V3
import os
import re
from PyQt5.QtCore import QFileSystemWatcher
@@ -99,12 +107,3 @@ class Compiler():
book_html_f = os.path.join(self.core.cwd,'index.html')
with open(book_html_f, 'w') as fp:
fp.write(template_dom.prettify())
#
+9
View File
@@ -1,6 +1,15 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# @Author: Bachir Soussi Chiadmi <bach>
# @Date: 30-05-2017
# @Email: bachir@figureslibres.io
# @Filename: sasscompiler.py
# @Last modified by: bach
# @Last modified time: 03-06-2017
# @License: GPL-V3
import os
from PyQt5.QtCore import QFileSystemWatcher
import sass
+7 -2
View File
@@ -1,6 +1,13 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# @Author: Bachir Soussi Chiadmi <bach>
# @Date: 23-05-2017
# @Email: bachir@figureslibres.io
# @Filename: server.py
# @Last modified by: bach
# @Last modified time: 03-06-2017
# @License: GPL-V3
import sys, os
from socket import socket
@@ -8,9 +15,7 @@ import socketserver
import http.server
import threading
class Server():
def __init__(self, parent):
self.parent = parent