added formatting
This commit is contained in:
@@ -21,9 +21,11 @@ clean: ## Clean build and .egg folder in py modules
|
|||||||
pipx: ## Install all packages with pipx
|
pipx: ## Install all packages with pipx
|
||||||
for module in *; do if [ -f $$module/setup.py ]; then pipx install $$module; fi; done
|
for module in *; do if [ -f $$module/setup.py ]; then pipx install $$module; fi; done
|
||||||
|
|
||||||
|
format: ## Reformat packages with black
|
||||||
|
black SimpleWebPage/
|
||||||
|
black TSVFilter/
|
||||||
|
black markslider/
|
||||||
|
|
||||||
packages: clean ## Create packages for every module
|
|
||||||
for module in *; do if [ -f $$module/setup.py ]; then tar czf $$module.tgz $$module; fi; done
|
|
||||||
|
|
||||||
tar-SimpleWebPage: clean ## Create package for SimpleWebPage
|
tar-SimpleWebPage: clean ## Create package for SimpleWebPage
|
||||||
tar czf SimpleWebPage.tgz SimpleWebPage/
|
tar czf SimpleWebPage.tgz SimpleWebPage/
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
|
|
||||||
def version_reader(path):
|
|
||||||
for line in open(path,"rt").read(1024).split("\n"):
|
|
||||||
if line.startswith("VERSION"):
|
|
||||||
return line.split("=")[1].strip().replace('"',"")
|
|
||||||
|
|
||||||
version = version_reader(os.path.join("simplewebpage","__init__.py"))
|
def version_reader(path):
|
||||||
|
for line in open(path, "rt").read(1024).split("\n"):
|
||||||
|
if line.startswith("VERSION"):
|
||||||
|
return line.split("=")[1].strip().replace('"', "")
|
||||||
|
|
||||||
|
|
||||||
|
version = version_reader(os.path.join("simplewebpage", "__init__.py"))
|
||||||
setup(
|
setup(
|
||||||
name="SimpleWebPage",
|
name="SimpleWebPage",
|
||||||
packages=["simplewebpage"],
|
packages=["simplewebpage"],
|
||||||
@@ -19,7 +21,5 @@ setup(
|
|||||||
"SimpleWebPage=simplewebpage:main",
|
"SimpleWebPage=simplewebpage:main",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
install_requires = [
|
install_requires=["markdown>=3.3.4"],
|
||||||
'markdown>=3.3.4'
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -89,15 +89,15 @@ class code:
|
|||||||
custom_match = re.compile(r"(\${)([0-9;]*[ABCDEFGHJKSTfminsu]+)(})")
|
custom_match = re.compile(r"(\${)([0-9;]*[ABCDEFGHJKSTfminsu]+)(})")
|
||||||
|
|
||||||
def pos(self, y, x):
|
def pos(self, y, x):
|
||||||
""" Go to absolute position """
|
"""Go to absolute position"""
|
||||||
return "\033[" + str(y) + ";" + str(x) + "H"
|
return "\033[" + str(y) + ";" + str(x) + "H"
|
||||||
|
|
||||||
def column(self, x):
|
def column(self, x):
|
||||||
""" Go to absolute column """
|
"""Go to absolute column"""
|
||||||
return "\033[" + str(x) + "G"
|
return "\033[" + str(x) + "G"
|
||||||
|
|
||||||
def posprint(self, y, x, s):
|
def posprint(self, y, x, s):
|
||||||
""" Print string at a location """
|
"""Print string at a location"""
|
||||||
sys.stdout.write(self.pos(y, x) + str(s))
|
sys.stdout.write(self.pos(y, x) + str(s))
|
||||||
self.flush()
|
self.flush()
|
||||||
|
|
||||||
@@ -129,11 +129,11 @@ class code:
|
|||||||
sys.stdout.write("\033[" + str(n) + "E")
|
sys.stdout.write("\033[" + str(n) + "E")
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
""" Save cursor position """
|
"""Save cursor position"""
|
||||||
sys.stdout.write("\033[s")
|
sys.stdout.write("\033[s")
|
||||||
|
|
||||||
def restore(self):
|
def restore(self):
|
||||||
""" Restore cursor position """
|
"""Restore cursor position"""
|
||||||
sys.stdout.write("\033[u")
|
sys.stdout.write("\033[u")
|
||||||
|
|
||||||
def color_string(self, s):
|
def color_string(self, s):
|
||||||
@@ -160,7 +160,7 @@ class code:
|
|||||||
|
|
||||||
|
|
||||||
def demo():
|
def demo():
|
||||||
""" Print all control sequences """
|
"""Print all control sequences"""
|
||||||
c = code()
|
c = code()
|
||||||
unformatted = """${S}ANSI CODES
|
unformatted = """${S}ANSI CODES
|
||||||
==========${Z}
|
==========${Z}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import traceback, tty, termios, subprocess, signal
|
|||||||
|
|
||||||
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
|
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
|
||||||
import ansicodes, md_color
|
import ansicodes, md_color
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import climage
|
import climage
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@@ -50,13 +51,13 @@ class getch:
|
|||||||
|
|
||||||
|
|
||||||
class EndProgram(Exception):
|
class EndProgram(Exception):
|
||||||
""" Nice exit """
|
"""Nice exit"""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class slide_reader:
|
class slide_reader:
|
||||||
""" Class for reading files. """
|
"""Class for reading files."""
|
||||||
|
|
||||||
def __init__(self, files, opts):
|
def __init__(self, files, opts):
|
||||||
self.filename = files[0]
|
self.filename = files[0]
|
||||||
@@ -86,7 +87,7 @@ class slide_reader:
|
|||||||
self.pygments = False
|
self.pygments = False
|
||||||
|
|
||||||
def read(self):
|
def read(self):
|
||||||
""" Read a file, set pages and data """
|
"""Read a file, set pages and data"""
|
||||||
|
|
||||||
self.pages = 0
|
self.pages = 0
|
||||||
self.background = []
|
self.background = []
|
||||||
@@ -234,7 +235,7 @@ class slide_reader:
|
|||||||
self.file_start_page = [1 + i for i in self.file_start_page]
|
self.file_start_page = [1 + i for i in self.file_start_page]
|
||||||
|
|
||||||
def generate_content(self, s):
|
def generate_content(self, s):
|
||||||
""" Check for launchable items, or converted images """
|
"""Check for launchable items, or converted images"""
|
||||||
if self.opts.execute_read:
|
if self.opts.execute_read:
|
||||||
if s.find("`>") > -1:
|
if s.find("`>") > -1:
|
||||||
command = self.re_command.match(s)
|
command = self.re_command.match(s)
|
||||||
@@ -278,7 +279,13 @@ class slide_reader:
|
|||||||
width = max(5, self.scrsize[1] - 10)
|
width = max(5, self.scrsize[1] - 10)
|
||||||
output = climage.convert(
|
output = climage.convert(
|
||||||
image.group(3),
|
image.group(3),
|
||||||
is_unicode=True, is_truecolor=True, is_256color=False, is_16color=False, is_8color=False, width=width, palette="default"
|
is_unicode=True,
|
||||||
|
is_truecolor=True,
|
||||||
|
is_256color=False,
|
||||||
|
is_16color=False,
|
||||||
|
is_8color=False,
|
||||||
|
width=width,
|
||||||
|
palette="default",
|
||||||
)
|
)
|
||||||
output = output.split("\n")
|
output = output.split("\n")
|
||||||
while len(output[0].strip()) == 0:
|
while len(output[0].strip()) == 0:
|
||||||
@@ -375,7 +382,7 @@ def get_interactive_help_text():
|
|||||||
|
|
||||||
|
|
||||||
def setup_options():
|
def setup_options():
|
||||||
""" Create command line options """
|
"""Create command line options"""
|
||||||
usage = (
|
usage = (
|
||||||
"""
|
"""
|
||||||
MarkSlider: a markdown based slideshow engine
|
MarkSlider: a markdown based slideshow engine
|
||||||
@@ -563,7 +570,7 @@ Keyboard shortcuts:
|
|||||||
|
|
||||||
|
|
||||||
def page_print(reader, opts, offset):
|
def page_print(reader, opts, offset):
|
||||||
""" Print a page """
|
"""Print a page"""
|
||||||
|
|
||||||
page = reader.get_current_page()
|
page = reader.get_current_page()
|
||||||
scrsize = opts.size
|
scrsize = opts.size
|
||||||
@@ -678,7 +685,7 @@ def print_time(opts):
|
|||||||
|
|
||||||
|
|
||||||
def print_help(reader, opts):
|
def print_help(reader, opts):
|
||||||
""" Create a window with help message """
|
"""Create a window with help message"""
|
||||||
helptext = get_interactive_help_text().split("\n")
|
helptext = get_interactive_help_text().split("\n")
|
||||||
maxlen = max([len(x) for x in helptext])
|
maxlen = max([len(x) for x in helptext])
|
||||||
bc.posprint(3, 5, " +" + "-" * maxlen + "+ ")
|
bc.posprint(3, 5, " +" + "-" * maxlen + "+ ")
|
||||||
@@ -697,7 +704,7 @@ def print_help(reader, opts):
|
|||||||
|
|
||||||
|
|
||||||
def print_toc(reader, opts):
|
def print_toc(reader, opts):
|
||||||
""" Create a window with TOC """
|
"""Create a window with TOC"""
|
||||||
text = reader.get_toc(display_position=True)
|
text = reader.get_toc(display_position=True)
|
||||||
title = opts.toc if opts.toc else "Table of Contents"
|
title = opts.toc if opts.toc else "Table of Contents"
|
||||||
maxlen = max([len(x) for x in text])
|
maxlen = max([len(x) for x in text])
|
||||||
@@ -720,7 +727,7 @@ def print_toc(reader, opts):
|
|||||||
|
|
||||||
|
|
||||||
def offset_change(opts, reader, offset, new_offset):
|
def offset_change(opts, reader, offset, new_offset):
|
||||||
""" Change the display position of page """
|
"""Change the display position of page"""
|
||||||
new_offset = (offset[0] + new_offset[0], offset[1] + new_offset[1])
|
new_offset = (offset[0] + new_offset[0], offset[1] + new_offset[1])
|
||||||
offsety = min(reader.get_page_height() - 1, new_offset[0])
|
offsety = min(reader.get_page_height() - 1, new_offset[0])
|
||||||
offseth = min(reader.get_page_height(), new_offset[1])
|
offseth = min(reader.get_page_height(), new_offset[1])
|
||||||
@@ -740,7 +747,7 @@ def getkeypress():
|
|||||||
|
|
||||||
|
|
||||||
def browser(opts, files):
|
def browser(opts, files):
|
||||||
""" Main function for printing """
|
"""Main function for printing"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
reader = slide_reader(files, opts)
|
reader = slide_reader(files, opts)
|
||||||
@@ -846,7 +853,7 @@ def get_console_size():
|
|||||||
|
|
||||||
|
|
||||||
def colorify(s, opts):
|
def colorify(s, opts):
|
||||||
""" Add colors to string """
|
"""Add colors to string"""
|
||||||
if not opts.color:
|
if not opts.color:
|
||||||
return bc.nocolor_string(s)
|
return bc.nocolor_string(s)
|
||||||
c = bc.color_string(s) # +bc.Z
|
c = bc.color_string(s) # +bc.Z
|
||||||
@@ -854,14 +861,14 @@ def colorify(s, opts):
|
|||||||
|
|
||||||
|
|
||||||
def cut_line(s, i):
|
def cut_line(s, i):
|
||||||
""" cut a color tagged string, and remove control chars """
|
"""cut a color tagged string, and remove control chars"""
|
||||||
s = s[:i]
|
s = s[:i]
|
||||||
s = re.sub("\$$", "", re.sub("\$\{$", "", re.sub("\$\{.$", "", s)))
|
s = re.sub("\$$", "", re.sub("\$\{$", "", re.sub("\$\{.$", "", s)))
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
def add_highlight(s, opts):
|
def add_highlight(s, opts):
|
||||||
""" Add cursor position highlight """
|
"""Add cursor position highlight"""
|
||||||
if len(s.strip()) == 0:
|
if len(s.strip()) == 0:
|
||||||
cleaned = HL
|
cleaned = HL
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ def colorize(data, remove_colors=False, dark_colors=False, debug=False):
|
|||||||
|
|
||||||
|
|
||||||
def md_re_compile(d):
|
def md_re_compile(d):
|
||||||
""" Returns a re.compiled dict """
|
"""Returns a re.compiled dict"""
|
||||||
n = {}
|
n = {}
|
||||||
for t in d:
|
for t in d:
|
||||||
n[t] = {}
|
n[t] = {}
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ setup(
|
|||||||
author="Ville Rantanen",
|
author="Ville Rantanen",
|
||||||
author_email="ville.q.rantanen@gmail.com",
|
author_email="ville.q.rantanen@gmail.com",
|
||||||
keywords=["Markdown", "Slideshow"],
|
keywords=["Markdown", "Slideshow"],
|
||||||
entry_points = {'console_scripts': 'markslider = markslider.markslider:main'},
|
entry_points={"console_scripts": "markslider = markslider.markslider:main"},
|
||||||
install_requires = [
|
install_requires=["pygments", "climage"],
|
||||||
'pygments', 'climage'
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user