Hello community, here is the log from the commit of package urlscan for openSUSE:Factory checked in at 2020-08-07 14:21:08 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/urlscan (Old) and /work/SRC/openSUSE:Factory/.urlscan.new.3399 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "urlscan" Fri Aug 7 14:21:08 2020 rev:7 rq:824828 version:0.9.5 Changes: -------- --- /work/SRC/openSUSE:Factory/urlscan/urlscan.changes 2020-03-21 00:02:31.449136276 +0100 +++ /work/SRC/openSUSE:Factory/.urlscan.new.3399/urlscan.changes 2020-08-07 14:22:37.590321213 +0200 @@ -1,0 +2,13 @@ +Tue Jul 28 09:44:43 UTC 2020 - Martin Rey <[email protected]> + +- Update to version 0.9.5 + * Change shebang to specifically call python3 + * Add --width flag to change displayed width. Closes #92. + * Update tlds and copyright dates + * Remove workaround for fixed python webbrowser bug (#94) + * Add -R option to reverse URL/context output. Closes #90 + * Add --single option to quit after opening/copying first link. + Closes #95 + * Support wl-clipboard. Resolve #88. + +------------------------------------------------------------------- Old: ---- urlscan-0.9.4.tar.gz New: ---- urlscan-0.9.5.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ urlscan.spec ++++++ --- /var/tmp/diff_new_pack.SrsDBk/_old 2020-08-07 14:22:41.670321972 +0200 +++ /var/tmp/diff_new_pack.SrsDBk/_new 2020-08-07 14:22:41.670321972 +0200 @@ -17,7 +17,7 @@ Name: urlscan -Version: 0.9.4 +Version: 0.9.5 Release: 0 Summary: An other URL extractor/viewer License: GPL-2.0-or-later ++++++ urlscan-0.9.4.tar.gz -> urlscan-0.9.5.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlscan-0.9.4/README.rst new/urlscan-0.9.5/README.rst --- old/urlscan-0.9.4/README.rst 2019-08-30 23:40:59.000000000 +0200 +++ new/urlscan-0.9.5/README.rst 2020-07-09 19:25:47.000000000 +0200 @@ -4,12 +4,12 @@ Contributors ------------ -Daniel Burrows <[email protected]> (Original Author) - -Scott Hansen <[email protected]> (Maintainer) +Scott Hansen <[email protected]> (Author and Maintainer) Maxime Chatelle <[email protected]> (Debian Maintainer) +Daniel Burrows <[email protected]> (Original Author) + Purpose and Requirements ------------------------ @@ -54,7 +54,7 @@ - Configure colors and keybindings via ~/.config/urlscan/config.json. Generate default config file for editing by running `urlscan -g`. Cycle through - available palettes with `p`. + available palettes with `p`. Set display width with `--width`. - Copy URL to clipboard with `C` or to primary selection with `P`. Requires xsel or xclip. @@ -102,14 +102,15 @@ :: - urlscan [-g, --genconf] [-n, --no-browser] [-c, --compact] [-d, --dedupe] [-r, --run <expression>] [-p, --pipe] [-H, --nohelp] <file> + urlscan [-g, --genconf] [-n, --no-browser] [-c, --compact] [-d, --dedupe] [-r, --run <expression>] [-R, --reverse] [-s, --single] [-p, --pipe] [-w, --width] [-H, --nohelp] <file> Urlscan can extract URLs and email addresses from emails or any text file. Calling with no flags will start the curses browser. Calling with '-n' will just output a list of URLs/email addressess to stdout. The '-c' flag removes the context from around the URLs in the curses browser, and the '-d' flag removes -duplicate URLs. Files can also be piped to urlscan using normal shell pipe -mechanisms: `cat <something> | urlscan` or `urlscan < <something>` +duplicate URLs. 'R' reverses the displayed order of URLs and context. Files can +also be piped to urlscan using normal shell pipe mechanisms: `cat <something> | +urlscan` or `urlscan < <something>` Instead of opening a web browser, the selected URL can be passed as the argument to a command using `--run "<command> {}"`. Note the use of `{}` in the command @@ -126,6 +127,8 @@ The first palette in the list will be the default. Configure the palettes according to the `Urwid display attributes`_. +Display width can be set with `--width`. + Keybindings ----------- @@ -149,6 +152,7 @@ - `open_url` -- open selected URL (default: `space` or `enter`) - `palette` -- cycle through palettes (default: `p`) - `quit` -- quit (default: `q` or `Q`) +- `reverse` -- reverse display order (default: `R`) - `shorten` -- toggle shorten highlighted URL (default: `s`) - `top` -- move to first list item (default: `g`) - `up` -- cursor up (default: `k`) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlscan-0.9.4/bin/urlscan new/urlscan-0.9.5/bin/urlscan --- old/urlscan-0.9.4/bin/urlscan 2019-08-30 23:40:59.000000000 +0200 +++ new/urlscan-0.9.5/bin/urlscan 2020-07-09 19:25:47.000000000 +0200 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ A simple urlview replacement that handles things like quoted-printable properly. aka "urlview minus teh suck" @@ -47,6 +47,9 @@ arg_parse.add_argument('--compact', '-c', action='store_true', default=False, help="Don't display the context of each URL.") + arg_parse.add_argument('--reverse', '-R', dest="reverse", + action='store_true', default=False, + help="Reverse order of displayed URLS/context") arg_parse.add_argument('--no-browser', '-n', dest="nobrowser", action='store_true', default=False, help="Pipe URLs to stdout") @@ -64,6 +67,12 @@ arg_parse.add_argument('--nohelp', '-H', dest='nohelp', action='store_true', default=False, help='Hide help menu by default') + arg_parse.add_argument('--single', '-s', dest='single', + action='store_true', default=False, + help='Quit urlscan after opening/copying a single link.') + arg_parse.add_argument('--width', '-w', dest='width', + type=int, default=0, + help='Set width to display') arg_parse.add_argument('message', nargs='?', default=sys.stdin, help="Filename of the message to parse") return arg_parse.parse_args() @@ -185,15 +194,21 @@ if args.nobrowser is False: tui = urlchoose.URLChooser(urlscan.msgurls(msg), compact=args.compact, + reverse=args.reverse, nohelp=args.nohelp, dedupe=args.dedupe, run=args.run, + single=args.single, + width=args.width, pipe=args.pipe) tui.main() else: out = urlchoose.URLChooser(urlscan.msgurls(msg), dedupe=args.dedupe, + reverse=args.reverse, shorten=False) + if args.reverse is True: + out.urls.reverse() print("\n".join(out.urls)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlscan-0.9.4/setup.py new/urlscan-0.9.5/setup.py --- old/urlscan-0.9.4/setup.py 2019-08-30 23:40:59.000000000 +0200 +++ new/urlscan-0.9.5/setup.py 2020-07-09 19:25:47.000000000 +0200 @@ -1,14 +1,14 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from setuptools import setup setup(name="urlscan", - version="0.9.4", + version="0.9.5", description="View/select the URLs in an email message or file", author="Scott Hansen", author_email="[email protected]", url="https://github.com/firecat53/urlscan", - download_url="https://github.com/firecat53/urlscan/archive/0.9.4.zip", + download_url="https://github.com/firecat53/urlscan/archive/0.9.5.zip", packages=['urlscan'], scripts=['bin/urlscan'], package_data={'urlscan': ['assets/*']}, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlscan-0.9.4/urlscan/assets/tlds-alpha-by-domain.txt new/urlscan-0.9.5/urlscan/assets/tlds-alpha-by-domain.txt --- old/urlscan-0.9.4/urlscan/assets/tlds-alpha-by-domain.txt 2019-08-30 23:40:59.000000000 +0200 +++ new/urlscan-0.9.5/urlscan/assets/tlds-alpha-by-domain.txt 2020-07-09 19:25:47.000000000 +0200 @@ -1,4 +1,4 @@ -# Version 2019021501, Last Updated Fri Feb 15 07:07:01 2019 UTC +# Version 2020051401, Last Updated Fri May 15 07:07:01 2020 UTC AAA AARP ABARTH @@ -15,7 +15,6 @@ ACCOUNTANT ACCOUNTANTS ACO -ACTIVE ACTOR AD ADAC @@ -153,7 +152,6 @@ BMS BMW BN -BNL BNPPARIBAS BO BOATS @@ -212,7 +210,6 @@ CAREER CAREERS CARS -CARTIER CASA CASE CASEIH @@ -245,7 +242,6 @@ CHINTAI CHRISTMAS CHROME -CHRYSLER CHURCH CI CIPRIANI @@ -297,6 +293,7 @@ COUPON COUPONS COURSES +CPA CR CREDIT CREDITCARD @@ -358,9 +355,7 @@ DO DOCS DOCTOR -DODGE DOG -DOHA DOMAINS DOT DOWNLOAD @@ -369,7 +364,6 @@ DUBAI DUCK DUNLOP -DUNS DUPONT DURBAN DVAG @@ -405,7 +399,6 @@ EUROVISION EUS EVENTS -EVERBANK EXCHANGE EXPERT EXPOSED @@ -485,6 +478,7 @@ GAMES GAP GARDEN +GAY GB GBIZ GD @@ -577,7 +571,6 @@ HOMES HOMESENSE HONDA -HONEYWELL HORSE HOSPITAL HOST @@ -631,7 +624,6 @@ IR IRISH IS -ISELECT ISMAILI IST ISTANBUL @@ -696,12 +688,10 @@ KZ LA LACAIXA -LADBROKES LAMBORGHINI LAMER LANCASTER LANCIA -LANCOME LAND LANDROVER LANXESS @@ -722,7 +712,6 @@ LEXUS LGBT LI -LIAISON LIDL LIFE LIFEINSURANCE @@ -741,6 +730,7 @@ LIXIL LK LLC +LLP LOAN LOANS LOCKER @@ -816,7 +806,6 @@ MO MOBI MOBILE -MOBILY MODA MOE MOI @@ -824,7 +813,6 @@ MONASH MONEY MONSTER -MOPAR MORMON MORTGAGE MOSCOW @@ -832,7 +820,6 @@ MOTORCYCLES MOV MOVIE -MOVISTAR MP MQ MR @@ -851,7 +838,6 @@ MZ NA NAB -NADEX NAGOYA NAME NATIONWIDE @@ -952,7 +938,6 @@ PHOTOGRAPHY PHOTOS PHYSIO -PIAGET PICS PICTET PICTURES @@ -1154,13 +1139,11 @@ SPREADBETTING SR SRL -SRT SS ST STADA STAPLES STAR -STARHUB STATEBANK STATEFARM STC @@ -1208,7 +1191,6 @@ TECH TECHNOLOGY TEL -TELEFONICA TEMASEK TENNIS TEVA @@ -1268,7 +1250,6 @@ UA UBANK UBS -UCONNECT UG UK UNICOM @@ -1302,7 +1283,6 @@ VIRGIN VISA VISION -VISTAPRINT VIVA VIVO VLAANDEREN @@ -1321,7 +1301,6 @@ WALTER WANG WANGGOU -WARMAN WATCH WATCHES WEATHER @@ -1407,7 +1386,6 @@ XN--E1A4C XN--ECKVDTC9D XN--EFVY88H -XN--ESTV75G XN--FCT429K XN--FHBEI XN--FIQ228C5HS @@ -1452,11 +1430,11 @@ XN--MGBAH1A3HJKRD XN--MGBAI9AZGQP6J XN--MGBAYH7GPA -XN--MGBB9FBPOB XN--MGBBH1A XN--MGBBH1A71E XN--MGBC0A9AZCG XN--MGBCA7DZDO +XN--MGBCPQ6GPA1A XN--MGBERP4A5D4AR XN--MGBGU82A XN--MGBI4ECEXP @@ -1482,8 +1460,10 @@ XN--PBT977C XN--PGBS0DH XN--PSSY2U +XN--Q7CE6A XN--Q9JYB4C XN--QCKA1PMC +XN--QXA6A XN--QXAM XN--RHQV96G XN--ROVU88B diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlscan-0.9.4/urlscan/urlchoose.py new/urlscan-0.9.5/urlscan/urlchoose.py --- old/urlscan-0.9.4/urlscan/urlchoose.py 2019-08-30 23:40:59.000000000 +0200 +++ new/urlscan-0.9.5/urlscan/urlchoose.py 2020-07-09 19:25:47.000000000 +0200 @@ -1,5 +1,5 @@ # Copyright (C) 2006-2007 Daniel Burrows -# Copyright (C) 2019 Scott Hansen +# Copyright (C) 2020 Scott Hansen # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -18,7 +18,6 @@ """An urwid listview-based widget that lets you choose a URL from a list of URLs.""" -import errno import json import os from os.path import dirname, exists, expanduser @@ -26,8 +25,6 @@ import shlex from subprocess import call, Popen, PIPE, DEVNULL import sys -from threading import Thread -from time import sleep import webbrowser import urwid @@ -35,6 +32,14 @@ import urwid.raw_display +if 'WAYLAND_DISPLAY' in os.environ: + COPY_COMMANDS = ('wl-copy',) + COPY_COMMANDS_PRIMARY = ('wl-copy --primary',) +else: + COPY_COMMANDS = ("xsel -ib", "xclip -i -selection clipboard") + COPY_COMMANDS_PRIMARY = ("xsel -i", "xclip -i") + + def shorten_url(url, cols, shorten): """Shorten long URLs to fit on one line. @@ -86,8 +91,8 @@ class URLChooser: - def __init__(self, extractedurls, compact=False, nohelp=False, dedupe=False, - shorten=True, run="", pipe=False, genconf=False): + def __init__(self, extractedurls, compact=False, reverse=False, nohelp=False, dedupe=False, + shorten=True, run="", single=False, pipe=False, genconf=False, width=0): self.conf = expanduser("~/.config/urlscan/config.json") self.keys = {'/': self._search_key, '0': self._digits, @@ -113,6 +118,7 @@ 'p': self._palette, 'Q': self._quit, 'q': self._quit, + 'R': self._reverse, 'S': self._all_shorten, 's': self._shorten, 'u': self._all_escape @@ -172,11 +178,14 @@ self.shorten = shorten self.compact = compact self.run = run + self.single = single self.pipe = pipe self.search = False self.search_string = "" self.no_matches = False self.enter = False + self.term_width, _ = urwid.raw_display.Screen().get_cols_rows() + self.width = min(self.term_width, width or self.term_width) self.activate_keys = [i for i, j in urwid.Button._command_map._command.items() if j == 'activate'] self.items, self.urls = self.process_urls(extractedurls, @@ -208,9 +217,13 @@ else: self.headerwid = None self.top = urwid.Frame(listbox, self.headerwid) + self.pad = self.term_width - self.width + self.top = urwid.Padding(self.top, left=0, right=self.pad) if self.urls: - self.top.body.focus_position = \ + self.top.base_widget.body.focus_position = \ (2 if self.compact is False else 0) + if reverse is True: + self._reverse() self.tui = urwid.curses_display.Screen() self.palette_names = list(self.palettes.keys()) self.palette_idx = 0 @@ -226,6 +239,11 @@ unhandled_input=self.unhandled) self.loop.run() + @property + def size(self): + _, rows = self.tui.get_cols_rows() + return (self.width, rows) + def handle_keys(self, keys, raw): """Handle widget default keys @@ -250,7 +268,7 @@ footer = 'default' text = "" footerwid = urwid.AttrMap(urwid.Text(text), footer) - self.top.footer = footerwid + self.top.base_widget.footer = footerwid elif k in self.activate_keys: self.search_string += k self._search() @@ -282,7 +300,6 @@ """ self.key = key - self.size = self.tui.get_cols_rows() if self.search is True: if self.enter is False and self.no_matches is False: if len(key) == 1 and key.isprintable(): @@ -307,14 +324,14 @@ def _open_url(self): """<Enter> or <space>""" load_text = "Loading URL..." if self.link_open_modes[0] != self.run \ - else "Executing: {}".format(self.run) + else "Executing: {}".format(self.run) if os.environ.get('BROWSER') not in ['elinks', 'links', 'w3m', 'lynx']: - self._footer_start_thread(load_text, 5) + self._footer_display(load_text, 5) def _help_menu(self): """F1""" if self.help_menu is False: - self.focus_pos_saved = self.top.body.focus_position + self.focus_pos_saved = self.top.base_widget.body.focus_position help_men = "\n".join(["{} - {}".format(i, j.__name__.strip('_')) for i, j in self.keys.items() if j.__name__ != '_digits']) @@ -334,15 +351,17 @@ "open_url -- open selected URL\n" "palette -- cycle through palettes\n" "quit -- quit\n" + "reverse -- reverse order URLs/context\n" "shorten -- toggle shorten highlighted URL\n" + "single -- quit urlscan after opening a single link\n" "top -- move to first list item\n" "up -- cursor up\n") - self.top.body = \ - urwid.ListBox(urwid.SimpleListWalker([urwid.Columns([(30, urwid.Text(help_men)), - urwid.Text(docs)])])) + self.top.base_widget.body = \ + urwid.ListBox(urwid.SimpleListWalker([urwid.Columns([(30, urwid.Text(help_men)), + urwid.Text(docs)])])) else: - self.top.body = urwid.ListBox(self.items) - self.top.body.focus_position = self.focus_pos_saved + self.top.base_widget.body = urwid.ListBox(self.items) + self.top.base_widget.body.focus_position = self.focus_pos_saved self.help_menu = not self.help_menu def _search_key(self): @@ -359,54 +378,54 @@ # Reset the search highlighting self._search() footerwid = urwid.AttrMap(urwid.Text("Search: "), 'footer') - self.top.footer = footerwid + self.top.base_widget.footer = footerwid self.items = self.items_orig - self.top.body = urwid.ListBox(self.items) + self.top.base_widget.body = urwid.ListBox(self.items) def _digits(self): """ 0-9 """ self.number += self.key try: if self.compact is False: - self.top.body.focus_position = \ + self.top.base_widget.body.focus_position = \ self.items.index(self.items_com[max(int(self.number) - 1, 0)]) else: - self.top.body.focus_position = \ + self.top.base_widget.body.focus_position = \ self.items.index(self.items[max(int(self.number) - 1, 0)]) except IndexError: self.number = self.number[:-1] - self.top.keypress(self.size, "") # Trick urwid into redisplaying the cursor + self.top.base_widget.keypress(self.size, "") # Trick urwid into redisplaying the cursor if self.number: - self._footer_start_thread("Selection: {}".format(self.number), 1) + self._footer_display("Selection: {}".format(self.number), 1) def _clear_screen(self): """ Ctrl-l """ - self.draw_screen(self.size) + self.draw_screen() def _down(self): """ j """ - self.top.keypress(self.size, "down") + self.top.base_widget.keypress(self.size, "down") def _up(self): """ k """ - self.top.keypress(self.size, "up") + self.top.base_widget.keypress(self.size, "up") def _top(self): """ g """ # Goto top of the list - self.top.body.focus_position = 2 if self.compact is False else 0 - self.top.keypress(self.size, "") # Trick urwid into redisplaying the cursor + self.top.base_widget.body.focus_position = 2 if self.compact is False else 0 + self.top.base_widget.keypress(self.size, "") # Trick urwid into redisplaying the cursor def _bottom(self): """ G """ # Goto bottom of the list - self.top.body.focus_position = len(self.items) - 1 - self.top.keypress(self.size, "") # Trick urwid into redisplaying the cursor + self.top.base_widget.body.focus_position = len(self.items) - 1 + self.top.base_widget.keypress(self.size, "") # Trick urwid into redisplaying the cursor def _shorten(self): """ s """ # Toggle shortened URL for selected item - fpo = self.top.body.focus_position + fpo = self.top.base_widget.body.focus_position url_idx = len([i for i in self.items[:fpo + 1] if isinstance(i, urwid.Columns)]) - 1 if self.compact is False and fpo <= 1: @@ -426,6 +445,7 @@ item[1].set_label(shorten_url(next(urls), self.size[0], self.shorten)) + def _all_escape(self): """ u """ # Toggle all escaped URLs @@ -439,42 +459,60 @@ self.size[0], self.shorten)) + def _reverse(self): + """ R """ + # Reverse items + fpo = self.top.body.focus_position + if self.compact is True: + self.items.reverse() + else: + rev = [] + for item in self.items: + if isinstance(item, urwid.Divider): + rev.insert(0, item) + elif isinstance(item, urwid.Text): + rev.insert(1, item) + else: + rev.insert(2, item) + self.items = rev + self.top.body = urwid.ListBox(self.items) + self.top.body.focus_position = self._cur_focus(fpo) + def _context(self): """ c """ # Show/hide context if self.search_string: # Reset search when toggling compact mode footerwid = urwid.AttrMap(urwid.Text(""), 'default') - self.top.footer = footerwid + self.top.base_widget.footer = footerwid self.search_string = "" self.items = self.items_orig - fpo = self.top.body.focus_position + fpo = self.top.base_widget.body.focus_position self.items, self.items_com = self.items_com, self.items - self.top.body = urwid.ListBox(self.items) - self.top.body.focus_position = self._cur_focus(fpo) + self.top.base_widget.body = urwid.ListBox(self.items) + self.top.base_widget.body.focus_position = self._cur_focus(fpo) self.compact = not self.compact def _clipboard(self, pri=False): """ C """ # Copy highlighted url to clipboard - fpo = self.top.body.focus_position + fpo = self.top.base_widget.body.focus_position url_idx = len([i for i in self.items[:fpo + 1] if isinstance(i, urwid.Columns)]) - 1 if self.compact is False and fpo <= 1: return url = self.urls[url_idx] - if pri is True: - cmds = ("xsel -i", "xclip -i") - else: - cmds = ("xsel -ib", "xclip -i -selection clipboard") + cmds = COPY_COMMANDS_PRIMARY if pri else COPY_COMMANDS for cmd in cmds: try: proc = Popen(shlex.split(cmd), stdin=PIPE) proc.communicate(input=url.encode(sys.getdefaultencoding())) - self._footer_start_thread("Copied url to {} selection".format( + self._footer_display("Copied url to {} selection".format( "primary" if pri is True else "clipboard"), 5) except OSError: continue + if self.single is True: + self._quit() break def _clipboard_pri(self): @@ -507,24 +545,20 @@ else: print("~/.config/urlscan/config.json already exists") - - def _footer_start_thread(self, text, time): + def _footer_display(self, text, time): """Display given text in the footer. Clears after <time> seconds """ footerwid = urwid.AttrMap(urwid.Text(text), 'footer') - self.top.footer = footerwid - load_thread = Thread(target=self._loading_thread, args=(time,)) - load_thread.daemon = True - load_thread.start() - - def _loading_thread(self, time): - """Simple thread to wait <time> seconds after launching a URL or - displaying a URL selection number, clearing the screen and clearing the - footer loading message. + self.top.base_widget.footer = footerwid + self.loop.set_alarm_in(time, self._footer_callback) + + def _footer_callback(self, _loop, _data): + """Callback for loop set_alarm_in after launching a URL or displaying a + URL selection number, clearing the screen and clearing the footer + loading message. """ - sleep(time) self.number = "" # Clear URL selection number text = "Search: {}".format(self.search_string) if self.search_string: @@ -533,9 +567,8 @@ footer = 'default' text = "" footerwid = urwid.AttrMap(urwid.Text(text), footer) - self.top.footer = footerwid - size = self.tui.get_cols_rows() - self.draw_screen(size) + self.top.base_widget.footer = footerwid + self.draw_screen() def _cur_focus(self, fpo=0): # Return correct focus when toggling 'show context' @@ -554,7 +587,7 @@ """ text = "Search: {}".format(self.search_string) footerwid = urwid.AttrMap(urwid.Text(text), 'footer') - self.top.footer = footerwid + self.top.base_widget.footer = footerwid search_items = [] for grp in self.items_org: done = False @@ -578,24 +611,24 @@ if done is True: search_items.extend(grp) self.items = search_items - self.top.body = urwid.ListBox(self.items) + self.top.base_widget.body = urwid.ListBox(self.items) if self.items: - self.top.body.focus_position = 2 if self.compact is False else 0 + self.top.base_widget.body.focus_position = 2 if self.compact is False else 0 # Trick urwid into redisplaying the cursor - self.top.keypress(self.tui.get_cols_rows(), "") + self.top.base_widget.keypress(self.size, "") self.no_matches = False else: self.no_matches = True footerwid = urwid.AttrMap(urwid.Text(text + " No Matches"), 'footer') - self.top.footer = footerwid + self.top.base_widget.footer = footerwid - def draw_screen(self, size): + def draw_screen(self): """Render curses screen """ self.tui.clear() - canvas = self.top.render(size, focus=True) - self.tui.draw_screen(size, canvas) + canvas = self.top.base_widget.render(self.size, focus=True) + self.tui.draw_screen(self.size, canvas) def _get_search(self): return lambda: self.search, lambda: self.enter @@ -610,25 +643,13 @@ if self.nohelp is False: self.headerwid = urwid.AttrMap(urwid.Text( self.header.format(self.link_open_modes[0])), 'header') - self.top.header = self.headerwid + self.top.base_widget.header = self.headerwid def mkbrowseto(self, url): """Create the urwid callback function to open the web browser or call another function with the URL. """ - # Try-except block to work around webbrowser module bug - # https://bugs.python.org/issue31014 - try: - browser = os.environ['BROWSER'] - except KeyError: - pass - else: - del os.environ['BROWSER'] - webbrowser.register(browser, None, webbrowser.GenericBrowser(browser)) - try_idx = webbrowser._tryorder.index(browser) - webbrowser._tryorder.insert(0, webbrowser._tryorder.pop(try_idx)) - def browse(*args): # double ()() to ensure self.search evaluated at runtime, not when # browse() is _created_. [0] is self.search, [1] is self.enter @@ -648,8 +669,9 @@ else: Popen(self.run.format(url), shell=True).communicate() - size = self.tui.get_cols_rows() - self.draw_screen(size) + if self.single is True: + self._quit() + self.draw_screen() return browse def process_urls(self, extractedurls, dedupe, shorten): @@ -663,13 +685,9 @@ urls - List of all URLs """ - cols, _ = urwid.raw_display.Screen().get_cols_rows() items = [] urls = [] - first = True for group, usedfirst, usedlast in extractedurls: - if first: - first = False items.append(urwid.Divider(div_char='-', top=1, bottom=1)) if dedupe is True: # If no unique URLs exist, then skip the group completely @@ -720,7 +738,7 @@ ('urlref:number:braces', ']'), ' '])), urwid.AttrMap(urwid.Button(shorten_url(url, - cols, + self.width, shorten), self.mkbrowseto(url), user_data=url), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlscan-0.9.4/urlscan/urlscan.py new/urlscan-0.9.5/urlscan/urlscan.py --- old/urlscan-0.9.4/urlscan/urlscan.py 2019-08-30 23:40:59.000000000 +0200 +++ new/urlscan-0.9.5/urlscan/urlscan.py 2020-07-09 19:25:47.000000000 +0200 @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Copyright (C) 2006-2007 Daniel Burrows -# Copyright (C) 2019 Scott Hansen +# Copyright (C) 2020 Scott Hansen # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlscan-0.9.4/urlscan.1 new/urlscan-0.9.5/urlscan.1 --- old/urlscan-0.9.4/urlscan.1 2019-08-30 23:40:59.000000000 +0200 +++ new/urlscan-0.9.5/urlscan.1 2020-07-09 19:25:47.000000000 +0200 @@ -1,6 +1,6 @@ .\" Hey, EMACS: -*- nroff -*- -.TH URLSCAN 1 "30 August 2019" +.TH URLSCAN 1 "15 May 2020" .SH NAME urlscan \- browse the URLs in an email message from a terminal @@ -30,7 +30,7 @@ and base64. \fB2.\fR Extraction and display of the context surrounding each URL. Toggle -context view on/off with \fBc\fR. +context view on/off with \fBc\fR. Reverse displayed order of URLs with \fBR\fR. \fB3.\fR Copy current URL to primary selection with \fBP\fR or to clipboard with \fBC\fR. @@ -48,7 +48,7 @@ http://urwid.org/manual/displayattributes.html#display-attributes -for color options and allowed values. +for color options and allowed values. Set display width with `--width`. \fB7.\fR \fBu\fR will unescape the highlighted URL if necessary. @@ -94,6 +94,17 @@ characters in the URL. Example: $ urlscan --run 'xclip -i' --pipe file.txt +.TP +.B \-R, \-\-reverse +Reverse displayed order of URLs. +.TP +.B \-s, \-\-single +Exit urlscan after opening or copying a single browser link. + + $ urlscan -s file.txt +.TP +.B \-w, \-\-width +Set display width. .SH MUTT INTEGRATION @@ -151,6 +162,8 @@ .TP \fBquit\fR \-\- quit (Default: \fBq\fR or \fBQ\fR) .TP +\fBreverse\fR \-\- reverse display order (Default: \fBR\fR) +.TP \fBshorten\fR \-\- toggle shorten highlighted URL (Default: \fBs\fR) .TP \fBtop\fR \-\- move to first list item (Default: \fBg\fR)
