How to use the isbntools.contrib.modules.uxcolors._colors function in isbntools

To help you get started, we’ve selected a few isbntools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xlcnd / isbntools / isbntools / contrib / modules / report / _messages.py View on Github external
content = s(urlopen(request).read())

        # Parse, select and print messages
        cur = tuple([int(c) for c in __version__.split('.')])
        display = []
        lines = content.split('\n')
        for line in lines:
            if not line.strip().strip('\n'):               # pragma: no cover
                continue
            vrs, cnd, msg = line.split('|')
            ref = tuple([int(c) for c in vrs.split('.') if vrs])
            if selected(cur, cnd, ref):                    # pragma: no cover
                display.append(msg)

        if display:                                        # pragma: no cover
            print("%s%s%s" % (colors.RED, " Important messages:", colors.BOLD))
            for msg in display:
                print(" => %s" % msg)
            print((colors.RESET))
        return 0
    except:                                                # pragma: no cover
        return 1
github xlcnd / isbntools / isbntools / bin / version.py View on Github external
def main():
    """Makes an audit report."""
    print((colors.BOLD))
    print(" isbntools - app and framework for 'all things ISBN'")
    print((colors.RESET))
    print((" Copyright (C) 2014-2019  Alexandre Lima Conde, Version %s" %
           __version__))
    print("")
    print(" License LGPL v3")
    print((NOTICE))

    # make audit
    from isbntools.app import audit
    print((colors.BOLD))
    audit()
    print((colors.RESET))

    # conf file
    from isbntools.conf import conf_file
github xlcnd / isbntools / isbntools / contrib / modules / report / _version.py View on Github external
RE_VERSION = re.compile(r"__version__\s*=\s*'(.*)'")
        _newversion = re.search(RE_VERSION, content).group(1)

        has_newversion = False
        try:
            newversion = tuple(map(int, _newversion.split('.')))
            version = tuple(map(int, __version__.split('.')))
            if newversion > version:
                has_newversion = True
        except:
            newversion = None
            has_newversion = __version__ != _newversion

        if has_newversion and newversion:
            print((colors.BOLD + colors.RED))
            print((" ** A new version (%s) is available! **" % _newversion))
            print((colors.BLUE))
            print((" At command line enter: [sudo] pip install -U isbntools"))
            print("    or")
            print((" Download it from %s"
                   % "https://pypi.python.org/pypi/isbntools"))
            print((colors.RESET))
    except:
        pass
    finally:
        sys.exit()
github xlcnd / isbntools / isbntools / contrib / modules / report / _messages.py View on Github external
cur = tuple([int(c) for c in __version__.split('.')])
        display = []
        lines = content.split('\n')
        for line in lines:
            if not line.strip().strip('\n'):               # pragma: no cover
                continue
            vrs, cnd, msg = line.split('|')
            ref = tuple([int(c) for c in vrs.split('.') if vrs])
            if selected(cur, cnd, ref):                    # pragma: no cover
                display.append(msg)

        if display:                                        # pragma: no cover
            print("%s%s%s" % (colors.RED, " Important messages:", colors.BOLD))
            for msg in display:
                print(" => %s" % msg)
            print((colors.RESET))
        return 0
    except:                                                # pragma: no cover
        return 1
github xlcnd / isbntools / isbntools / contrib / modules / report / _version.py View on Github external
version = tuple(map(int, __version__.split('.')))
            if newversion > version:
                has_newversion = True
        except:
            newversion = None
            has_newversion = __version__ != _newversion

        if has_newversion and newversion:
            print((colors.BOLD + colors.RED))
            print((" ** A new version (%s) is available! **" % _newversion))
            print((colors.BLUE))
            print((" At command line enter: [sudo] pip install -U isbntools"))
            print("    or")
            print((" Download it from %s"
                   % "https://pypi.python.org/pypi/isbntools"))
            print((colors.RESET))
    except:
        pass
    finally:
        sys.exit()
github xlcnd / isbntools / isbntools / contrib / modules / report / _version.py View on Github external
_newversion = re.search(RE_VERSION, content).group(1)

        has_newversion = False
        try:
            newversion = tuple(map(int, _newversion.split('.')))
            version = tuple(map(int, __version__.split('.')))
            if newversion > version:
                has_newversion = True
        except:
            newversion = None
            has_newversion = __version__ != _newversion

        if has_newversion and newversion:
            print((colors.BOLD + colors.RED))
            print((" ** A new version (%s) is available! **" % _newversion))
            print((colors.BLUE))
            print((" At command line enter: [sudo] pip install -U isbntools"))
            print("    or")
            print((" Download it from %s"
                   % "https://pypi.python.org/pypi/isbntools"))
            print((colors.RESET))
    except:
        pass
    finally:
        sys.exit()
github xlcnd / isbntools / isbntools / bin / version.py View on Github external
print("")
        print(' Your configuration file is at:')
        print("  %s%s%s" % (colors.BOLD, conf_file, colors.RESET))
        print("")

    # lib version
    from isbntools.app import libversion
    print(" And 'isbntools' is using:")
    print("  'isbnlib' version %s%s%s with 'range db' %s%s%s" %
          (colors.BOLD, libversion, colors.RESET, colors.BOLD, RDDATE[0:8],
           colors.RESET))
    print("")

    # check for updates and pypi packages
    print(" Checking %sonline%s services ... %sWAIT%s" %
          (colors.BOLD, colors.RESET, colors.BOLD, colors.RESET))
    try:
        from isbntools.contrib.modules.report import check_pypi
        check_pypi()
    except:
        pass
github xlcnd / isbntools / isbntools / contrib / modules / report / _pypi.py View on Github external
"""Check available packages in pypi."""

import os
import sys
from subprocess import PIPE, Popen

from isbntools.contrib.modules.uxcolors import _colors as colors

PY2 = sys.version < '3'
PKGS = ('isbntools', 'isbnlib')
WINDOWS = os.name == 'nt'
EOL = '\r\n' if WINDOWS and not PY2 else '\n'
PY3 = not PY2
VIRTUAL = getattr(sys, 'base_prefix', sys.prefix) != sys.prefix \
   or hasattr(sys, 'real_prefix')
BOLD = colors.BOLD
RESET = colors.RESET


def shell(shcmd=None):
    """Run a shell command."""
    if not shcmd:  # pragma: no cover
        return
    sp = Popen(
        shcmd,
        shell=True,
        stdin=PIPE,
        stdout=PIPE,
        stderr=PIPE,
        close_fds=not WINDOWS)
    (fo, fe) = (sp.stdout, sp.stderr)
    if PY2:  # pragma: no cover
github xlcnd / isbntools / isbntools / contrib / modules / report / _pypi.py View on Github external
import os
import sys
from subprocess import PIPE, Popen

from isbntools.contrib.modules.uxcolors import _colors as colors

PY2 = sys.version < '3'
PKGS = ('isbntools', 'isbnlib')
WINDOWS = os.name == 'nt'
EOL = '\r\n' if WINDOWS and not PY2 else '\n'
PY3 = not PY2
VIRTUAL = getattr(sys, 'base_prefix', sys.prefix) != sys.prefix \
   or hasattr(sys, 'real_prefix')
BOLD = colors.BOLD
RESET = colors.RESET


def shell(shcmd=None):
    """Run a shell command."""
    if not shcmd:  # pragma: no cover
        return
    sp = Popen(
        shcmd,
        shell=True,
        stdin=PIPE,
        stdout=PIPE,
        stderr=PIPE,
        close_fds=not WINDOWS)
    (fo, fe) = (sp.stdout, sp.stderr)
    if PY2:  # pragma: no cover
        out = fo.read().strip(EOL)