Hello community, here is the log from the commit of package ddgr for openSUSE:Factory checked in at 2019-10-27 13:41:56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ddgr (Old) and /work/SRC/openSUSE:Factory/.ddgr.new.2990 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ddgr" Sun Oct 27 13:41:56 2019 rev:4 rq:743108 version:1.7 Changes: -------- --- /work/SRC/openSUSE:Factory/ddgr/ddgr.changes 2019-03-18 10:42:06.655217849 +0100 +++ /work/SRC/openSUSE:Factory/.ddgr.new.2990/ddgr.changes 2019-10-27 13:41:58.853336947 +0100 @@ -1,0 +2,11 @@ +Thu Oct 24 20:15:07 UTC 2019 - Sebastian Wagner <[email protected]> + +- update to version 1.7: + - Use setproctitle to set process name + - Monkeypatch textwrap for CJK wide characters + - Fix write to GNU Screen paste buffer + - Refresh current page on URL expansion toggle + - Smarter colorization and better support for native terminals on Windows + - Handle bangs in the form g! + +------------------------------------------------------------------- Old: ---- ddgr-1.6.tar.gz New: ---- ddgr-1.7.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ddgr.spec ++++++ --- /var/tmp/diff_new_pack.vXbO1e/_old 2019-10-27 13:41:59.665337926 +0100 +++ /var/tmp/diff_new_pack.vXbO1e/_new 2019-10-27 13:41:59.665337926 +0100 @@ -17,7 +17,7 @@ Name: ddgr -Version: 1.6 +Version: 1.7 Release: 0 Summary: DuckDuckGo from the terminal License: GPL-3.0-only ++++++ ddgr-1.6.tar.gz -> ddgr-1.7.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddgr-1.6/.circleci/config.yml new/ddgr-1.7/.circleci/config.yml --- old/ddgr-1.6/.circleci/config.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/ddgr-1.7/.circleci/config.yml 2019-09-03 05:15:33.000000000 +0200 @@ -0,0 +1,79 @@ +version: 2 + +test-template: &test-template + working_directory: ~/ddgr + environment: + CI_FORCE_TEST: 1 + steps: + - run: + command: | + apt update && apt install -y --no-install-recommends git make + pip install --upgrade setuptools flake8 pylint + - checkout + - run: + command: | + python3 -m flake8 ddgr + echo ddgr | xargs pylint + make test + +jobs: + py35: + docker: + - image: python:3.5-slim + <<: *test-template + + py36: + docker: + - image: python:3.6-slim + <<: *test-template + + py37: + docker: + - image: python:3.7-slim + <<: *test-template + + package-and-publish: + machine: true + working_directory: ~/ddgr + steps: + - checkout + - run: + name: "package with packagecore" + command: | + # Use latest installed python3 from pyenv + export PYENV_VERSION="$(pyenv versions | grep -Po '\b3\.\d+\.\d+' | tail -1)" + pip install packagecore + packagecore -o ./dist/ ${CIRCLE_TAG#v} + - run: + name: "publish to GitHub" + command: | + go get github.com/tcnksm/ghr + ghr -t ${GITHUB_API_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -replace ${CIRCLE_TAG} ./dist/ + +workflows: + version: 2 + + test: + jobs: &all-tests + - py35 + - py36 + - py37 + + nightly: + triggers: + - schedule: + cron: "0 0 * * 6" + filters: + branches: + only: + - master + jobs: *all-tests + + publish-github-release: + jobs: + - package-and-publish: + filters: + tags: + only: /^v.*/ + branches: + ignore: /.*/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddgr-1.6/.github/FUNDING.yml new/ddgr-1.7/.github/FUNDING.yml --- old/ddgr-1.6/.github/FUNDING.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/ddgr-1.7/.github/FUNDING.yml 2019-09-03 05:15:33.000000000 +0200 @@ -0,0 +1 @@ +custom: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RMLTQ76JSXJ4Q diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddgr-1.6/.pylintrc new/ddgr-1.7/.pylintrc --- old/ddgr-1.6/.pylintrc 2018-11-16 16:05:23.000000000 +0100 +++ new/ddgr-1.7/.pylintrc 2019-09-03 05:15:33.000000000 +0200 @@ -5,6 +5,7 @@ missing-docstring, no-self-use, protected-access, + too-few-public-methods, too-many-arguments, too-many-branches, too-many-function-args, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddgr-1.6/.travis.yml new/ddgr-1.7/.travis.yml --- old/ddgr-1.6/.travis.yml 2018-11-16 16:05:23.000000000 +0100 +++ new/ddgr-1.7/.travis.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,35 +0,0 @@ -language: python -python: - - "3.5" - - "3.6" - - "3.7" -sudo: required -services: - - docker -dist: xenial -before_install: - - "pip install --upgrade setuptools" - - "pip install --upgrade pip" - - "pip install --upgrade flake8" - - "pip install --upgrade pylint" -script: - - python3 -m flake8 ddgr - - echo ddgr | xargs pylint - - make test -before_deploy: - - sudo apt-get update -qy - - sudo apt-get install -qy python3 python3-pip - - python3 -m pip install packagecore - - packagecore -o dist/ "${TRAVIS_TAG#v}" -deploy: - provider: releases - api_key: - secure: BgInyqrgGef0IZ6ABBm8cUGOtq+aghdnYdWvEftxqioqQVM+jq8u4mhEl2MlhKG5CrWnD/KXJdBSGI/SmJ1QNKrRELEiQxWJ2V85qz8I1iDRpQ9VdpDxvQszJvNdTEqCl/7JHTPnFP05Nfr+WFQmOYffh34qxmDHyqEF93uf1VyYpJeurvsRYBCAfakQxZOTbdl4M5xNHg2XYmHzemkSwHy9sTZR/kb9xO7CdcE5GcCpJ0QUuIUZasgRbQkrq6rjCFR+8RU0DFtAc7r8x3t5a2JCKLglIm7puUg28YkDvX/PxuWTdrZKLPg+kabWkSgtdQs11mvyEkcD5n2b+aV0x3jxamJPdEBLX1WINaNdn7EUO+2WSsopAbfKWpKGnZ7S6uVEHJ5m91VzP/r4tJrU4DmvIv733kjV3trVzFofPFn5hWX/GKc/FCfGIFMpyJh/d3L/zlKsRgeUaCwYtf0TxQFwZaVOobxHaPlLQVHdLLqrfnKHqRsIJDyW7iI/OyeFxPclBSvEemxwkhWjPgwrArlYG/gY38qLcyUTHGzo362feVjMzv3MSwoC6UZTiW/9IZgtfguu743oceDQx28DcuYrJZX96FFPob+Ut4kD27qCSK6QnuzDpnTofIom5FtKrSsScfPdbk5HABmjkn/MMSW5wgFLmssXpza3XRrsRRg= - file_glob: true - file: - - dist/* - skip_cleanup: true - on: - tags: true - repo: jarun/ddgr - python: "3.6" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddgr-1.6/CHANGELOG new/ddgr-1.7/CHANGELOG --- old/ddgr-1.6/CHANGELOG 2018-11-16 16:05:23.000000000 +0100 +++ new/ddgr-1.7/CHANGELOG 2019-09-03 05:15:33.000000000 +0200 @@ -1,3 +1,16 @@ +ddgr v1.7 +2018-09-03 + +What's in? +- Use setproctitle to set process name +- Monkeypatch textwrap for CJK wide characters +- Fix write to GNU Screen paste buffer +- Refresh current page on URL expansion toggle +- Smarter colorization and better support for native terminals on Windows +- Handle bangs in the form g! + +------------------------------------------------------------------------------- + ddgr v1.6 2018-11-16 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddgr-1.6/README.md new/ddgr-1.7/README.md --- old/ddgr-1.6/README.md 2018-11-16 16:05:23.000000000 +0100 +++ new/ddgr-1.7/README.md 2019-09-03 05:15:33.000000000 +0200 @@ -4,6 +4,7 @@ <a href="https://github.com/jarun/ddgr/releases/latest"><img src="https://img.shields.io/github/release/jarun/ddgr.svg?maxAge=600" alt="Latest release" /></a> <a href="https://aur.archlinux.org/packages/ddgr"><img src="https://img.shields.io/aur/version/ddgr.svg?maxAge=600" alt="AUR" /></a> <a href="http://formulae.brew.sh/formula/ddgr"><img src="https://img.shields.io/homebrew/v/ddgr.svg?maxAge=600" alt="Homebrew" /></a> +<a href="https://pypi.python.org/pypi/ddgr"><img src="https://img.shields.io/pypi/v/ddgr.svg?maxAge=600" alt="PyPI" /></a> <a href="https://packages.debian.org/search?keywords=ddgr&searchon=names&exact=1"><img src="https://img.shields.io/badge/debian-10+-blue.svg?maxAge=2592000" alt="Debian Buster+" /></a> <a href="https://apps.fedoraproject.org/packages/ddgr"><img src="https://img.shields.io/badge/fedora-26+-blue.svg?maxAge=2592000" alt="Fedora 26+" /></a> <a href="https://software.opensuse.org/package/ddgr"><img src="https://img.shields.io/badge/opensuse%20leap-15.0+-blue.svg?maxAge=2592000" alt="openSUSE Leap 15.0+" /></a> @@ -11,15 +12,16 @@ </p> <p align="center"> +<a href="https://repology.org/metapackage/ddgr"><img src="https://repology.org/badge/tiny-repos/ddgr.svg" alt="Availability"></a> <a href="https://github.com/jarun/ddgr/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-GPLv3-yellow.svg?maxAge=2592000" alt="License" /></a> -<a href="https://travis-ci.org/jarun/ddgr"><img src="https://travis-ci.org/jarun/ddgr.svg?branch=master" alt="Build Status" /></a> +<a href="https://circleci.com/gh/jarun/workflows/ddgr"><img src="https://img.shields.io/circleci/project/github/jarun/ddgr.svg" alt="Build Status" /></a> </p> <p align="center"> <a href="https://asciinema.org/a/212198"><img src="https://asciinema.org/a/212198.png" alt="Asciicast" width="734"/></a> </p> -`ddgr` is a cmdline utility to search DuckDuckGo from the terminal. While [googler](https://github.com/jarun/googler) is highly popular among cmdline users, in many forums the need of a similar utility for privacy-aware DuckDuckGo came up. [DuckDuckGo Bangs](https://duckduckgo.com/bang) are super-cool too! So here's `ddgr` for you! +`ddgr` is a cmdline utility to search DuckDuckGo from the terminal. While [googler](https://github.com/jarun/googler) is extremely popular among cmdline users, in many forums the need of a similar utility for privacy-aware DuckDuckGo came up. [DuckDuckGo Bangs](https://duckduckgo.com/bang) are super-cool too! So here's `ddgr` for you! Unlike the web interface, you can specify the number of search results you would like to see per page. It's more convenient than skimming through 30-odd search results per page. The default interface is carefully designed to use minimum space without sacrificing readability. @@ -30,8 +32,7 @@ *Love smart and efficient utilities? Explore [my repositories](https://github.com/jarun?tab=repositories). Buy me a cup of coffee if they help you.* <p align="center"> -<a href="https://saythanks.io/to/jarun"><img src="https://img.shields.io/badge/say-thanks!-ff69b4.svg" /></a> -<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RMLTQ76JSXJ4Q"><img src="https://img.shields.io/badge/PayPal-donate-green.svg" alt="Donate via PayPal!" /></a> +<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RMLTQ76JSXJ4Q"><img src="https://img.shields.io/badge/PayPal-donate-1eb0fc.svg" alt="Donate via PayPal!" /></a> </p> ### Table of contents @@ -56,29 +57,28 @@ ### Features -- Fast and clean (no ads, stray URLs or clutter), custom color -- Designed to deliver maximum readability at minimum space -- Instant answers (which appear in the html version of DDG) -- Specify the number of search results to show per page -- Navigate result pages from omniprompt, open URLs in browser -- Search and option completion scripts for Bash, Zsh and Fish -- DuckDuckGo Bang support (along with completion) -- Open the first result directly in browser (as in I'm Feeling Ducky) -- Non-stop searches: fire new searches at omniprompt without exiting -- Keywords (e.g. `filetype:mime`, `site:somesite.com`) support +- Fast and clean; custom color +- Designed for maximum readability at minimum space +- Instant answers (supported by DDG html version) +- Custom number of results per page +- Navigation, browser integration +- Search and option completion scripts (Bash, Fish, Zsh) +- DuckDuckGo Bangs (along with completion) +- Open the first result in browser (I'm Feeling Ducky) +- REPL for continuous searches +- Keywords (e.g. `filetype:mime`, `site:somesite.com`) - Limit search by time, specify region, disable safe search -- HTTPS proxy support, Do Not Track set, optionally disable User Agent -- Support custom url handler script or cmdline utility -- Comprehensive documentation, man page with handy usage examples +- HTTPS proxy support, optionally disable User Agent +- Do Not Track set by default +- Supports custom url handler script or cmdline utility +- Thoroughly documented, man page with examples - Minimal dependencies ### Installation #### Dependencies -`ddgr` requires Python 3.4 or later. Only the latest patch release of each minor version is supported. - -`cjkwrap` is an _optional_ requirement to wrap CJK code points accurately. +`ddgr` requires Python 3.5 or later. Only the latest patch release of each minor version is supported. To copy url to clipboard at the omniprompt, `ddgr` looks for `xsel` or `xclip` or `termux-clipboard-set` (in the same order) on Linux, `pbcopy` (default installed) on OS X, `clip` (default installed) on Windows and `clipboard` (default installed) on Haiku. It also supports GNU Screen and tmux copy-paste buffers in the absence of X11. @@ -91,22 +91,22 @@ - [Fedora](https://apps.fedoraproject.org/packages/ddgr) (`dnf install ddgr`) - [FreeBSD](https://www.freshports.org/www/ddgr/) (`pkg install ddgr`) - [Haiku](https://github.com/haikuports/haikuports/tree/master/www-client/ddgr) (`pkgman install ddgr`) -- [Homebrew](http://formulae.brew.sh/formula/ddgr) (`brew install ddgr`) +- [macOS/Homebrew](http://formulae.brew.sh/formula/ddgr) (`brew install ddgr`) - [NixOS](https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/misc/ddgr) (`nix-env -i ddgr`) - [openSUSE](https://software.opensuse.org/package/ddgr) (`zypper in ddgr`) - [PyPI](https://pypi.org/project/ddgr/) (`pip3 install ddgr`) - [Raspbian Testing](https://archive.raspbian.org/raspbian/pool/main/d/ddgr/) (`apt-get install ddgr`) - [Slackware](http://slackbuilds.org/repository/14.2/network/ddgr/) (`slackpkg install ddgr`) - [Snap Store](https://snapcraft.io/ddgr/) (`snap install ddgr`) +- [Solus](https://packages.getsol.us/shannon/d/ddgr/) (`eopkg install ddgr`) - [Source Mage](http://codex.sourcemage.org/test/utils/ddgr/) (`cast ddgr`) - [Termux](https://pypi.org/project/ddgr/) (`pip3 install ddgr`) - [Ubuntu](https://packages.ubuntu.com/search?keywords=ddgr&searchon=names&exact=1) (`apt-get install ddgr`) -- [Ubuntu PPA](https://launchpad.net/~twodopeshaggy/+archive/ubuntu/jarun/) (`apt-get install ddgr`) - [Void Linux](https://github.com/void-linux/void-packages/tree/master/srcpkgs/ddgr) (`xbps-install -S ddgr`) #### Release packages -Packages for Arch Linux, CentOS, Debian, Fedora, OpenSUSE Leap and Ubuntu are available with the [latest stable release](https://github.com/jarun/ddgr/releases/latest). +Packages for Arch Linux, CentOS, Debian, Fedora, OpenSUSE Leap, Solus, and Ubuntu are available with the [latest stable release](https://github.com/jarun/ddgr/releases/latest). #### From source @@ -137,9 +137,10 @@ #### Cmdline options ``` -usage: ddgr [-h] [-n N] [-r REG] [-C] [--colors COLORS] [-j] [-t SPAN] - [-w SITE] [-x] [-p URI] [-I] [--unsafe] [--noua] [--json] [--gb] - [--np] [--url-handler UTIL] [--show-browser-logs] [-v] [-d] +usage: ddgr [-h] [-n N] [-r REG] [--colorize [{auto,always,never}]] [-C] + [--colors COLORS] [-j] [-t SPAN] [-w SITE] [-x] [-p URI] + [--unsafe] [--noua] [--json] [--gb] [--np] [--url-handler UTIL] + [--show-browser-logs] [-v] [-d] [KEYWORD [KEYWORD ...]] DuckDuckGo from the terminal. @@ -153,7 +154,12 @@ shows actual number of results fetched per page -r REG, --reg REG region-specific search e.g. 'us-en' for US (default); visit https://duckduckgo.com/params - -C, --nocolor disable color output + --colorize [{auto,always,never}] + whether to colorize output; defaults to 'auto', which + enables color when stdout is a tty device; using + --colorize without an argument is equivalent to + --colorize=always + -C, --nocolor equivalent to --colorize=never --colors COLORS set output colors (see man page for details) -j, --ducky open the first result in a web browser; implies --np -t SPAN, --time SPAN time limit search [d (1 day), w (1 wk), m (1 month)] @@ -161,7 +167,6 @@ -x, --expand Show complete url in search results -p URI, --proxy URI tunnel traffic through an HTTPS proxy; URI format: [http[s]://][user:pwd@]host[:port] - -I, --noinstant disable instant answer --unsafe disable safe search --noua disable user agent --json output in JSON format; implies --np @@ -270,11 +275,12 @@ - [SZ Lin](https://github.com/szlin) - [Alex Gontar](https://github.com/mosegontar) -Copyright © 2016-2018 [Arun Prakash Jana](mailto:[email protected]) +Copyright © 2016-2019 [Arun Prakash Jana](mailto:[email protected]) ### In the Press - [Fossbytes](https://fossbytes.com/search-duckduckgo-from-terminal-ddgr/) +- [Hacker News](https://news.ycombinator.com/item?id=19606101) - [Information Security Squad](http://itsecforu.ru/2017/11/21/%D0%BA%D0%B0%D0%BA-%D0%B8%D1%81%D0%BA%D0%B0%D1%82%D1%8C-%D0%B2-duckduckgo-%D0%B8%D0%B7-%D0%BA%D0%BE%D0%BC%D0%B0%D0%BD%D0%B4%D0%BD%D0%BE%D0%B9-%D1%81%D1%82%D1%80%D0%BE%D0%BA%D0%B8-linux/) - [LinOxide](https://linoxide.com/tools/search-duckduckgo-command-line/) - [OMG! Ubuntu!](http://www.omgubuntu.co.uk/2017/11/duck-duck-go-terminal-app) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddgr-1.6/ddgr new/ddgr-1.7/ddgr --- old/ddgr-1.6/ddgr 2018-11-16 16:05:23.000000000 +0100 +++ new/ddgr-1.7/ddgr 2019-09-03 05:15:33.000000000 +0200 @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Copyright (C) 2016-2018 Arun Prakash Jana <[email protected]> +# Copyright (C) 2016-2019 Arun Prakash Jana <[email protected]> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -25,11 +25,13 @@ import locale import logging import os +import platform import shutil import signal from subprocess import Popen, PIPE, DEVNULL import sys import textwrap +import unicodedata import urllib.error import urllib.parse import urllib.request @@ -41,10 +43,10 @@ pass try: - import cjkwrap - dwrap = cjkwrap -except ImportError: - dwrap = textwrap + import setproctitle + setproctitle.setproctitle('ddgr') +except (ImportError, Exception): + pass # Basic setup @@ -281,6 +283,48 @@ print(msg, file=sys.stderr) +# Monkeypatch textwrap for CJK wide characters. +def monkeypatch_textwrap_for_cjk(): + try: + if textwrap.wrap.patched: + return + except AttributeError: + pass + psl_textwrap_wrap = textwrap.wrap + + def textwrap_wrap(text, width=70, **kwargs): + if width <= 2: + width = 2 + # We first add a U+0000 after each East Asian Fullwidth or East + # Asian Wide character, then fill to width - 1 (so that if a NUL + # character ends up on a new line, we still have one last column + # to spare for the preceding wide character). Finally we strip + # all the NUL characters. + # + # East Asian Width: https://www.unicode.org/reports/tr11/ + return [ + line.replace('\0', '') + for line in psl_textwrap_wrap( + ''.join( + ch + '\0' if unicodedata.east_asian_width(ch) in ('F', 'W') else ch + for ch in unicodedata.normalize('NFC', text) + ), + width=width - 1, + **kwargs + ) + ] + + def textwrap_fill(text, width=70, **kwargs): + return '\n'.join(textwrap_wrap(text, width=width, **kwargs)) + textwrap.wrap = textwrap_wrap + textwrap.fill = textwrap_fill + textwrap.wrap.patched = True + textwrap.fill.patched = True + + +monkeypatch_textwrap_for_cjk() + + # Classes class DdgUrl: @@ -748,23 +792,6 @@ return r - def fetch_instant_answer(self, url): - try: - r = https_get(url.full(), - headers={ - 'Accept-Encoding': 'gzip', - 'User-Agent': self._ua, - 'DNT': '1', - }, - proxies=self._proxies, expected_code=200) - import json - answer = json.loads(r[1]) - if 'Answer' in answer and isinstance(answer['Answer'], str) and answer['Answer'].strip() != '': - return answer['Answer'] - except Exception as e: - LOGERR(e) - return None - def annotate_tag(annotated_starttag_handler): # See parser logic within the DdgParser class for documentation. @@ -1213,7 +1240,7 @@ if columns > INDENT + 1: # Try to fill to columns fillwidth = columns - INDENT - 1 - for line in dwrap.wrap(abstract.replace('\n', ''), width=fillwidth): + for line in textwrap.wrap(abstract.replace('\n', ''), width=fillwidth): print('%s%s' % (' ' * INDENT, line)) print('') else: @@ -1333,7 +1360,6 @@ proxy = opts.proxy if hasattr(opts, 'proxy') else None self._conn = DdgConnection(proxy=proxy, ua=ua) - self.instant_answer = None self.results = [] self._urltable = {} @@ -1368,9 +1394,6 @@ """ # This method also sets self._urltable. - if self._opts.instant_answer: - self.instant_answer = self._conn.fetch_instant_answer(DdgAPIUrl(self._opts.keywords)) - page = self._conn.fetch_page(self._ddg_url) if page is None: @@ -1403,6 +1426,8 @@ self._ddg_url.np_prev = parser.np_prev_button self._ddg_url.np_next = parser.np_next_button + + # Show instant answer if self.index == 0 and parser.click_result: if self.colors: print(self.colors.abstract) @@ -1413,7 +1438,7 @@ columns = 0 fillwidth = columns - INDENT - for line in dwrap.wrap(parser.click_result.strip(), width=fillwidth): + for line in textwrap.wrap(parser.click_result.strip(), width=fillwidth): print('%s%s' % (' ' * INDENT, line)) if self.colors: @@ -1438,15 +1463,6 @@ else: results = self.results - if self.index == 0 and self.instant_answer is not None: - if self.colors: - colors = self.colors - print(' ' + colors.title + 'Instant Answer' + colors.reset) - print(colors.abstract + self.instant_answer + colors.reset) - else: - print('Instant Answer') - print(self.instant_answer) - if json_output: # JSON output import json @@ -1555,7 +1571,7 @@ self._opts.keywords = arg self._ddg_url = DdgUrl(self._opts) # If there is a Bang, let DuckDuckGo do the work - if arg[0] == '!': + if arg[0] == '!' or (len(arg) > 1 and arg[1] == '!'): open_url(self._ddg_url.full()) else: self.fetch_and_display() @@ -1685,12 +1701,18 @@ print('URL copied to tmux buffer.') return - # GNU Screen + # GNU Screen paste buffer if os.getenv('STY'): - copier_params = ['screen', '-X', 'readbuf'] - with open('/tmp/screen-exchange', 'wb') as f: - f.write(content) - Popen(copier_params, stdin=DEVNULL, stdout=DEVNULL, stderr=DEVNULL).communicate() + import tempfile + copier_params = ['screen', '-X', 'readbuf', '-e', 'utf8'] + tmpfd, tmppath = tempfile.mkstemp() + try: + with os.fdopen(tmpfd, 'wb') as fp: + fp.write(content) + copier_params.append(tmppath) + Popen(copier_params, stdin=DEVNULL, stdout=DEVNULL, stderr=DEVNULL).communicate() + finally: + os.unlink(tmppath) return printerr('failed to locate suitable clipboard utility') @@ -1700,7 +1722,9 @@ def cmdloop(self): """Run REPL.""" if self.keywords: - if self.keywords[0][0] == '!': + if self.keywords[0][0] == '!' or ( + len(self.keywords[0]) > 1 and self.keywords[0][1] == '!' + ): open_url(self._ddg_url.full()) else: self.fetch_and_display() @@ -1743,7 +1767,7 @@ printerr('Index out of bound. To search for the number, use d.') elif cmd == 'x': Result.urlexpand = not Result.urlexpand - printerr('url expansion toggled.') + self.display_results() elif cmd.startswith('c ') and cmd[2:].isdigit(): idx = int(cmd[2:]) if 0 < idx <= min(self._opts.num, len(self._urltable)): @@ -1786,7 +1810,7 @@ file = sys.stderr if file is None else file file.write(textwrap.dedent(""" Version %s - Copyright © 2016-2018 Arun Prakash Jana <[email protected]> + Copyright © 2016-2019 Arun Prakash Jana <[email protected]> License: GPLv3 Webpage: https://github.com/jarun/ddgr """ % _VERSION_)) @@ -1858,6 +1882,42 @@ return '%d.%d.%d' % sys.version_info[:3] +def get_colorize(colorize): + if colorize == 'always': + return True + + if colorize == 'auto': + return sys.stdout.isatty() + + # colorize = 'never' + return False + + +def set_win_console_mode(): + # VT100 control sequences are supported on Windows 10 Anniversary Update and later. + # https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences + # https://docs.microsoft.com/en-us/windows/console/setconsolemode + if platform.release() == '10': + STD_OUTPUT_HANDLE = -11 + STD_ERROR_HANDLE = -12 + ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004 + try: + from ctypes import windll, wintypes, byref + kernel32 = windll.kernel32 + for nhandle in (STD_OUTPUT_HANDLE, STD_ERROR_HANDLE): + handle = kernel32.GetStdHandle(nhandle) + old_mode = wintypes.DWORD() + if not kernel32.GetConsoleMode(handle, byref(old_mode)): + raise RuntimeError('GetConsoleMode failed') + new_mode = old_mode.value | ENABLE_VIRTUAL_TERMINAL_PROCESSING + if not kernel32.SetConsoleMode(handle, new_mode): + raise RuntimeError('SetConsoleMode failed') + # Note: No need to restore at exit. SetConsoleMode seems to + # be limited to the calling process. + except Exception: + pass + + # Query autocompleter # This function is largely experimental and could raise any exception; @@ -1913,7 +1973,12 @@ help='show N (0<=N<=25) results per page (default 10); N=0 shows actual number of results fetched per page') addarg('-r', '--reg', dest='region', default='us-en', metavar='REG', help="region-specific search e.g. 'us-en' for US (default); visit https://duckduckgo.com/params") - addarg('-C', '--nocolor', dest='colorize', action='store_false', help='disable color output') + addarg('--colorize', nargs='?', choices=['auto', 'always', 'never'], + const='always', default='auto', + help="""whether to colorize output; defaults to 'auto', which enables + color when stdout is a tty device; using --colorize without an argument + is equivalent to --colorize=always""") + addarg('-C', '--nocolor', action='store_true', help='equivalent to --colorize=never') addarg('--colors', dest='colorstr', type=argparser.is_colorstr, default=colorstr_env if colorstr_env else 'oCdgxy', metavar='COLORS', help='set output colors (see man page for details)') addarg('-j', '--ducky', action='store_true', help='open the first result in a web browser; implies --np') @@ -1922,7 +1987,6 @@ addarg('-w', '--site', dest='sites', action='append', metavar='SITE', help='search sites using DuckDuckGo') addarg('-x', '--expand', action='store_true', help='Show complete url in search results') addarg('-p', '--proxy', metavar='URI', help='tunnel traffic through an HTTPS proxy; URI format: [http[s]://][user:pwd@]host[:port]') - addarg('-i', '--instant', dest='instant_answer', action='store_true', help=argparse.SUPPRESS) addarg('--unsafe', action='store_true', help='disable safe search') addarg('--noua', action='store_true', help='disable user agent') addarg('--json', action='store_true', help='output in JSON format; implies --np') @@ -1934,7 +1998,12 @@ addarg('-d', '--debug', action='store_true', help='enable debugging') addarg('keywords', nargs='*', metavar='KEYWORD', help='search keywords') addarg('--complete', help=argparse.SUPPRESS) - return argparser.parse_args(args, namespace) + + parsed = argparser.parse_args(args, namespace) + if parsed.nocolor: + parsed.colorize = 'never' + + return parsed def main(): @@ -1959,11 +2028,17 @@ pass # Set colors - colors = Colors(*[COLORMAP[c] for c in opts.colorstr], reset=COLORMAP['x']) if opts.colorize else None + colorize = get_colorize(opts.colorize) + + colors = Colors(*[COLORMAP[c] for c in opts.colorstr], reset=COLORMAP['x']) if colorize else None Result.colors = colors Result.urlexpand = opts.expand DdgCmd.colors = colors + # Try to enable ANSI color support in cmd or PowerShell on Windows 10 + if sys.platform == 'win32' and sys.stdout.isatty() and colorize: + set_win_console_mode() + if opts.url_handler is not None: open_url.url_handler = opts.url_handler else: @@ -1977,7 +2052,10 @@ if opts.json or opts.ducky or opts.noninteractive: # Non-interactive mode - if repl.keywords and repl.keywords[0][0] == '!': + if repl.keywords and ( + repl.keywords[0][0] == '!' or + (len(repl.keywords[0]) > 1 and repl.keywords[0][1] == '!') + ): # Handle bangs open_url(repl._ddg_url.full()) else: @@ -1991,17 +2069,17 @@ repl.display_results(prelude='', json_output=opts.json) sys.exit(0) - else: - # Interactive mode - repl.cmdloop() + + # Interactive mode + repl.cmdloop() except Exception as e: # If debugging mode is enabled, let the exception through for a traceback; # otherwise, only print the exception error message. if LOGGER.isEnabledFor(logging.DEBUG): raise - else: - LOGERR(e) - sys.exit(1) + + LOGERR(e) + sys.exit(1) if __name__ == '__main__': diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddgr-1.6/ddgr.1 new/ddgr-1.7/ddgr.1 --- old/ddgr-1.6/ddgr.1 2018-11-16 16:05:23.000000000 +0100 +++ new/ddgr-1.7/ddgr.1 2019-09-03 05:15:33.000000000 +0200 @@ -9,20 +9,21 @@ .PP .B Features .PP - * Fast and clean (no ads, stray URLs or clutter), custom color - * Designed to deliver maximum readability at minimum space - * Instant answers (which appear in the html version of DDG) - * Specify the number of search results to show per page - * Navigate result pages from omniprompt, open URLs in browser - * Search and option completion scripts for Bash, Zsh and Fish - * DuckDuckGo Bang support (along with completion) - * Open the first result directly in browser (as in I'm Feeling Ducky) - * Non-stop searches: fire new searches at omniprompt without exiting - * Keywords (e.g. \fIfiletype:mime\fR, \fIsite:somesite.com\fR) support + * Fast and clean; custom color + * Designed for maximum readability at minimum space + * Instant answers (supported by DDG html version) + * Custom number of results per page + * Navigation, browser integration + * Search and option completion scripts (Bash, Fish, Zsh) + * DuckDuckGo Bangs (along with completion) + * Open the first result in browser (I'm Feeling Ducky) + * REPL for continuous searches + * Keywords (e.g. `filetype:mime`, `site:somesite.com`) * Limit search by time, specify region, disable safe search - * HTTPS proxy support, Do Not Track set, optionally disable User Agent - * Support custom url handler script or cmdline utility - * Comprehensive documentation, man page with handy usage examples + * HTTPS proxy support, optionally disable User Agent + * Do Not Track set by default + * Supports custom url handler script or cmdline utility + * Thoroughly documented, man page with examples * Minimal dependencies .SH OPTIONS .TP @@ -56,9 +57,6 @@ .BI "-p, --proxy=" URI Tunnel traffic through an HTTP proxy. \fIURI\fR is of the form \fI[http[s]://][user:pwd@]host[:port]\fR. The proxy server must support HTTP CONNECT tunneling and must not block port 443 for the relevant DuckDuckGo hosts. If a proxy is not explicitly given, the \fIhttps_proxy\fR or \fIHTTPS_PROXY\fR environment variable (if available) is used instead. .TP -.BI "-I, --noinstant" -Disable instant answer. -.TP .BI "--unsafe" Disable safe search. .TP @@ -336,7 +334,7 @@ .SH REPORTING BUGS .I https://github.com/jarun/ddgr/issues .SH LICENSE -Copyright \(co 2016-2018 Arun Prakash Jana <[email protected]> +Copyright \(co 2016-2019 Arun Prakash Jana <[email protected]> .PP License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. .br diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddgr-1.6/packagecore.yaml new/ddgr-1.7/packagecore.yaml --- old/ddgr-1.6/packagecore.yaml 2018-11-16 16:05:23.000000000 +0100 +++ new/ddgr-1.7/packagecore.yaml 2019-09-03 05:15:33.000000000 +0200 @@ -12,8 +12,8 @@ - make deps: - python - container: "base/archlinux" - centos7.3: + container: "archlinux/base" + centos7.4: builddeps: - make deps: @@ -21,7 +21,15 @@ commands: pre: - yum install epel-release - centos7.4: + centos7.5: + builddeps: + - make + deps: + - python + commands: + pre: + - yum install epel-release + centos7.6: builddeps: - make deps: @@ -34,6 +42,11 @@ - make deps: - python3 + debian10: + builddeps: + - make + deps: + - python3 fedora26: builddeps: - make @@ -54,7 +67,7 @@ - make deps: - python3 - opensuse42.2: + fedora30: builddeps: - make deps: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddgr-1.6/setup.py new/ddgr-1.7/setup.py --- old/ddgr-1.6/setup.py 2018-11-16 16:05:23.000000000 +0100 +++ new/ddgr-1.7/setup.py 2019-09-03 05:15:33.000000000 +0200 @@ -18,7 +18,7 @@ author_email='[email protected]', description='DuckDuckGo from the terminal', long_description='See https://github.com/jarun/ddgr#readme.', - python_requires='>=3.4', + python_requires='>=3.5', platforms=['any'], py_modules=['ddgr'], entry_points={ @@ -36,7 +36,6 @@ 'Programming Language :: Python', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7',
