Print the result, ascii encode if necessary
1845
def print_result(result):
    """"""
    try:
        print result
    except UnicodeEncodeError:
        if sys.stdout.encoding:
            print result.encode(sys.stdout.encoding, 'replace')
        else:
            print result.encode('utf8')
    except:
        print "Unexpected error attempting to print result"
653480
def plaintext(self, result):
        
        from PIL import Image

        ascii_chars = ['#', 'A', '@', '%', 'S', '+', '<', '*', ':', ',', '.']

        def image_to_ascii(image):
            image_as_ascii = []
            all_pixels = list(image.getdata())
            for pixel_value in all_pixels:
                index = pixel_value / 25 # 0 - 10
                image_as_ascii.append(ascii_chars[index])
            return image_as_ascii   

        img = Image.open(result)
        width, heigth = img.size
        new_width = 80 
        new_heigth = int((heigth * new_width) / width)
        new_image = img.resize((new_width, new_heigth))
        new_image = new_image.convert("L") # convert to grayscale

        # now that we have a grayscale image with some fixed width we have to convert every pixel
        # to the appropriate ascii character from "ascii_chars"
        img_as_ascii = image_to_ascii(new_image)
        img_as_ascii = ''.join(ch for ch in img_as_ascii)
        out = []
        for c in range(0, len(img_as_ascii), new_width):
            out.append(img_as_ascii[c:c+new_width])

        return "\n".join(out)
107375
def _print_result(case, summary):
    
    for case, case_data in summary.items():
        for dof, data in case_data.items():
            print("    " + case + " " + dof)
            print("    -------------------")
            for header, val in data.items():
                print("    " + header + " : " + str(val))
            print("")
23591
def print_results_adj(results, indent=False, prt=sys.stdout):
        """"""
        # Print column headers if there are results to be printed
        if results:
            prt.write("{R}\n".format(R="\t".join(GOEnrichmentStudy.get_prtflds_default(results))))
        # Print the GOEA results
        for rec in results:
            prt.write("{R}\n".format(R=rec.__str__(indent=indent)))
350434
def _print_results(file, status):
        

        file_color = c.Fore.GREEN
        status_color = c.Fore.RED
        if status == 'Success':
            status_color = c.Fore.GREEN
        elif status == 'Skipped':
            status_color = c.Fore.YELLOW
        print(
            '{}{!s:<13}{}{!s:<35}{}{!s:<8}{}{}'.format(
                c.Fore.CYAN,
                'Downloading:',
                file_color,
                file,
                c.Fore.CYAN,
                'Status:',
                status_color,
                status,
            )
        )
683367
def print_success(msg):
    
    if IS_POSIX:
        print(u"%s[INFO] %s%s" % (ANSI_OK, msg, ANSI_END))
    else:
        print(u"[INFO] %s" % (msg))
517094
def print_results(self, results, min_ratio=None, indent=False, pval=0.05, prt=sys.stdout):
        """"""
        results_adj = self.get_adj_records(results, min_ratio, pval)
        self.print_results_adj(results_adj, indent, prt)
291358
def pretty_print(self):
        
        return u"%s\t%.3f\t%.3f\t%s" % (
            (self.identifier or u""),
            (self.begin if self.begin is not None else TimeValue("-2.000")),
            (self.end if self.end is not None else TimeValue("-1.000")),
            (self.text or u"")
        )
60420
def pretty_print(self):
        
        msg = "Source: " + str(self._source) + "\n"
        msg += "Destination: " + str(self._destination) + "\n"
        inv_types = {v: k for k, v in defines.Types.items()}
        msg += "Type: " + str(inv_types[self._type]) + "\n"
        msg += "MID: " + str(self._mid) + "\n"
        if self._code is None:
            self._code = 0

        msg += "Code: " + str(defines.Codes.LIST[self._code].name) + "\n"
        msg += "Token: " + str(self._token) + "\n"
        for opt in self._options:
            msg += str(opt)
        msg += "Payload: " + "\n"
        msg += str(self._payload) + "\n"
        return msg
602167
def _print_results(filename, data):
    
    if filename:
        with open(filename, 'wb') as f:
            f.write(data)
    else:
        print data
787178
def get_output_str(item, detect_numerics, precision, sign_value):
    """"""
    if detect_numerics:
        item = _convert_to_numeric(item)
    if isinstance(item, float):
        item = round(item, precision)
    try:
        item = '{:{sign}}'.format(item, sign=sign_value)
    except (ValueError, TypeError):
        pass
    return to_unicode(item)
90625
def asciiplot(x, y, digit=1, width=50, title=None, char="="):
    
    ax = np.array(x)
    ay = np.array(y)

    if title:
        print(dark(title), file=sys.stderr)

    az = ay * width / ay.max()
    tx = [asciiaxis(x, digit=digit) for x in ax]
    rjust = max([len(x) for x in tx]) + 1

    for x, y, z in zip(tx, ay, az):
        x = x.rjust(rjust)
        y = y or ""
        z = green(char * z)
        print("{0} |{1} {2}".format(x, z, y), file=sys.stderr)
587299
def output(self):
        
        if (self._output is None) or (len(self._output) == 0):
            result = None
        else:
            result = self._output.pop(0)
        return result
956524
def safe_print(ustring, errors='replace', **kwargs):
    
    encoding = sys.stdout.encoding or 'utf-8'
    if sys.version_info[0] == 3:
        print(ustring, **kwargs)
    else:
        bytestr = ustring.encode(encoding, errors=errors)
        print(bytestr, **kwargs)
568762
def print(self, indent=2):
        """"""
        status = {
            ResultCode.NOT_IMPLEMENTED: '{}not implemented{}'.format(
                Fore.YELLOW, Style.RESET_ALL),
            ResultCode.IGNORED: '{}failed (ignored){}'.format(
                Fore.YELLOW, Style.RESET_ALL),
            ResultCode.FAILED: '{}failed{}'.format(
                Fore.RED, Style.RESET_ALL),
            ResultCode.PASSED: '{}passed{}'.format(
                Fore.GREEN, Style.RESET_ALL),
        }.get(self.code)
        print('{bold}{group}{provider}{checker}: {none}{status}{none}'.format(
            bold=Style.BRIGHT,
            group=(self.group.name + ' – ') if self.group.name else '',
            provider=(self.provider.name + ' – ') if self.provider else '',
            checker=self.checker.name,
            none=Style.RESET_ALL,
            status=status))
        if self.messages:
            for message in self.messages.split('\n'):
                print(pretty_description(message, indent=indent))
            if self.checker.hint:
                print(pretty_description(
                    'Hint: ' + self.checker.hint, indent=indent))
500932
def print_ast(f):
    
    for linenum,indent,value in iter_lines(f):
        print("{0}{1}|{2}".format(str(linenum).rjust(3), ' ' * indent, value))
278138
def output_row(self, name):
        ""
        print("%10s        %4d     %0.3f        %0.3f        %0.3f"%(
            name, self.gold, self.precision(), self.recall(), self.fscore()))