def format(obj, fmt, lang=None): if isinstance(obj, (datetime.date, datetime.time, datetime.timedelta)): if lang is None: lang = "en" oldlocale = locale.getlocale() try: locale.setlocale(locale.LC_ALL, locale.normalize(lang)) result = builtins.format(obj, fmt) finally: locale.setlocale(locale.LC_ALL, oldlocale) return result else: return builtins.format(obj, fmt)
# pylint: disable=E1101, no-absolute-import """test checking use of the logging module """ __revision__ = '' import builtins # Muck up the names in an effort to confuse... import logging as renamed_logging import os as logging FORMAT_STR = '{0}, {1}' # Statements that should be flagged: renamed_logging.debug('{0}, {1}'.format(4, 5)) renamed_logging.log(renamed_logging.DEBUG, 'msg: {}'.format('Run!')) renamed_logging.debug(FORMAT_STR.format(4, 5)) renamed_logging.log(renamed_logging.DEBUG, FORMAT_STR.format(4, 5)) # Statements that should not be flagged: renamed_logging.debug(format(66, 'x')) renamed_logging.debug(builtins.format(66, 'x')) renamed_logging.log(renamed_logging.DEBUG, 'msg: Run!'.upper()) logging.debug('{0}, {1}'.format(4, 5)) logging.log(logging.DEBUG, 'msg: {}'.format('Run!'))
lambda *args, **kwargs: builtins.eval(*args, **kwargs), builtins.eval) eval._ = functools.update_wrapper( lambda *args, **kwargs: wrap(builtins.eval)(*args, **kwargs), builtins.eval) exec = functools.update_wrapper( lambda *args, **kwargs: builtins.exec(*args, **kwargs), builtins.exec) exec._ = functools.update_wrapper( lambda *args, **kwargs: wrap(builtins.exec)(*args, **kwargs), builtins.exec) float = functools.update_wrapper( lambda *args, **kwargs: builtins.float(*args, **kwargs), builtins.float) float._ = functools.update_wrapper( lambda *args, **kwargs: wrap(builtins.float)(*args, **kwargs), builtins.float) format = functools.update_wrapper( lambda *args, **kwargs: builtins.format(*args, **kwargs), builtins.format) format._ = functools.update_wrapper( lambda *args, **kwargs: wrap(builtins.format)(*args, **kwargs), builtins.format) frozenset = functools.update_wrapper( lambda *args, **kwargs: builtins.frozenset(*args, **kwargs), builtins.frozenset) frozenset._ = functools.update_wrapper( lambda *args, **kwargs: wrap(builtins.frozenset)(*args, **kwargs), builtins.frozenset) getattr = functools.update_wrapper( lambda *args, **kwargs: builtins.getattr(*args, **kwargs), builtins.getattr) getattr._ = functools.update_wrapper( lambda *args, **kwargs: wrap(builtins.getattr)(*args, **kwargs), builtins.getattr)
from builtins import format a = 0 b = "aa" c = "false" d = False e = not True print("a : {}".format(a)) print("b : " + b) print("c : " + format(c.index("s"))) print("d : {}".format(d)) print("e : {}".format(e))
def printSubTable(self): for row in self.subTable: separator = ' ' print(len(row), " - ", " ".join(format(x, "8.5f") for x in row))
def hex(n=64, cond=None): return gen_cond( lambda: builtins.format(random.getrandbits(n), "x"), conds(lambda id: not id.startswith(tuple("0123456789")), cond))
def format(data): #TODo: switch commata and points result = builtins.format(data, ",") return result