diff --git a/py-packages/Makefile b/py-packages/Makefile index efe52e5..bfb1c65 100644 --- a/py-packages/Makefile +++ b/py-packages/Makefile @@ -21,9 +21,11 @@ clean: ## Clean build and .egg folder in py modules pipx: ## Install all packages with pipx 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 czf SimpleWebPage.tgz SimpleWebPage/ diff --git a/py-packages/SimpleWebPage/setup.py b/py-packages/SimpleWebPage/setup.py index 21d8844..7199ac9 100644 --- a/py-packages/SimpleWebPage/setup.py +++ b/py-packages/SimpleWebPage/setup.py @@ -1,11 +1,13 @@ 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( name="SimpleWebPage", packages=["simplewebpage"], @@ -19,7 +21,5 @@ setup( "SimpleWebPage=simplewebpage:main", ], }, - install_requires = [ - 'markdown>=3.3.4' - ] + install_requires=["markdown>=3.3.4"], ) diff --git a/py-packages/markslider/markslider/ansicodes.py b/py-packages/markslider/markslider/ansicodes.py index 7dbfebe..2bc1012 100644 --- a/py-packages/markslider/markslider/ansicodes.py +++ b/py-packages/markslider/markslider/ansicodes.py @@ -89,15 +89,15 @@ class code: custom_match = re.compile(r"(\${)([0-9;]*[ABCDEFGHJKSTfminsu]+)(})") def pos(self, y, x): - """ Go to absolute position """ + """Go to absolute position""" return "\033[" + str(y) + ";" + str(x) + "H" def column(self, x): - """ Go to absolute column """ + """Go to absolute column""" return "\033[" + str(x) + "G" 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)) self.flush() @@ -129,11 +129,11 @@ class code: sys.stdout.write("\033[" + str(n) + "E") def save(self): - """ Save cursor position """ + """Save cursor position""" sys.stdout.write("\033[s") def restore(self): - """ Restore cursor position """ + """Restore cursor position""" sys.stdout.write("\033[u") def color_string(self, s): @@ -160,7 +160,7 @@ class code: def demo(): - """ Print all control sequences """ + """Print all control sequences""" c = code() unformatted = """${S}ANSI CODES ==========${Z} diff --git a/py-packages/markslider/markslider/markslider.py b/py-packages/markslider/markslider/markslider.py index 6316506..d211749 100755 --- a/py-packages/markslider/markslider/markslider.py +++ b/py-packages/markslider/markslider/markslider.py @@ -28,6 +28,7 @@ import traceback, tty, termios, subprocess, signal sys.path.append(os.path.dirname(os.path.realpath(__file__))) import ansicodes, md_color + try: import climage except ImportError: @@ -50,13 +51,13 @@ class getch: class EndProgram(Exception): - """ Nice exit """ + """Nice exit""" pass class slide_reader: - """ Class for reading files. """ + """Class for reading files.""" def __init__(self, files, opts): self.filename = files[0] @@ -86,7 +87,7 @@ class slide_reader: self.pygments = False def read(self): - """ Read a file, set pages and data """ + """Read a file, set pages and data""" self.pages = 0 self.background = [] @@ -234,7 +235,7 @@ class slide_reader: self.file_start_page = [1 + i for i in self.file_start_page] 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 s.find("`>") > -1: command = self.re_command.match(s) @@ -278,7 +279,13 @@ class slide_reader: width = max(5, self.scrsize[1] - 10) output = climage.convert( 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") while len(output[0].strip()) == 0: @@ -375,7 +382,7 @@ def get_interactive_help_text(): def setup_options(): - """ Create command line options """ + """Create command line options""" usage = ( """ MarkSlider: a markdown based slideshow engine @@ -563,7 +570,7 @@ Keyboard shortcuts: def page_print(reader, opts, offset): - """ Print a page """ + """Print a page""" page = reader.get_current_page() scrsize = opts.size @@ -678,7 +685,7 @@ def print_time(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") maxlen = max([len(x) for x in helptext]) bc.posprint(3, 5, " +" + "-" * maxlen + "+ ") @@ -697,7 +704,7 @@ def print_help(reader, opts): def print_toc(reader, opts): - """ Create a window with TOC """ + """Create a window with TOC""" text = reader.get_toc(display_position=True) title = opts.toc if opts.toc else "Table of Contents" 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): - """ Change the display position of page """ + """Change the display position of page""" new_offset = (offset[0] + new_offset[0], offset[1] + new_offset[1]) offsety = min(reader.get_page_height() - 1, new_offset[0]) offseth = min(reader.get_page_height(), new_offset[1]) @@ -740,7 +747,7 @@ def getkeypress(): def browser(opts, files): - """ Main function for printing """ + """Main function for printing""" try: reader = slide_reader(files, opts) @@ -846,7 +853,7 @@ def get_console_size(): def colorify(s, opts): - """ Add colors to string """ + """Add colors to string""" if not opts.color: return bc.nocolor_string(s) c = bc.color_string(s) # +bc.Z @@ -854,14 +861,14 @@ def colorify(s, opts): 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 = re.sub("\$$", "", re.sub("\$\{$", "", re.sub("\$\{.$", "", s))) return s def add_highlight(s, opts): - """ Add cursor position highlight """ + """Add cursor position highlight""" if len(s.strip()) == 0: cleaned = HL else: diff --git a/py-packages/markslider/markslider/md_color.py b/py-packages/markslider/markslider/md_color.py index 9b82aeb..3b5bd6f 100755 --- a/py-packages/markslider/markslider/md_color.py +++ b/py-packages/markslider/markslider/md_color.py @@ -157,7 +157,7 @@ def colorize(data, remove_colors=False, dark_colors=False, debug=False): def md_re_compile(d): - """ Returns a re.compiled dict """ + """Returns a re.compiled dict""" n = {} for t in d: n[t] = {} diff --git a/py-packages/markslider/setup.py b/py-packages/markslider/setup.py index 41421a3..5f84861 100644 --- a/py-packages/markslider/setup.py +++ b/py-packages/markslider/setup.py @@ -16,8 +16,6 @@ setup( author="Ville Rantanen", author_email="ville.q.rantanen@gmail.com", keywords=["Markdown", "Slideshow"], - entry_points = {'console_scripts': 'markslider = markslider.markslider:main'}, - install_requires = [ - 'pygments', 'climage' - ] + entry_points={"console_scripts": "markslider = markslider.markslider:main"}, + install_requires=["pygments", "climage"], )