コード例 #1
0
ファイル: report.py プロジェクト: pignacio/vld
def print_log(log,
              format=_DEFAULT_FORMAT,
              level=0,
              width=100,
              colors=None,
              max_levels=None):
    colors = colors or _DEFAULT_COLORS
    right_part = format % _log_values(log.nutritional_value)
    left_part = '{}{}:'.format(' ' * level, log.name)
    right_size = max(0, width - len(left_part) - 2)
    format_str = '{}{:>' + str(right_size) + '}'

    try:
        color = colors[level]
    except IndexError:
        color = lambda s: s

    incomplete_marker = bright_red("!") if log.incomplete else " "
    unknown_marker = bright_red("*") if "???" in right_part else " "

    print(color(format_str.format(left_part, right_part)) + unknown_marker +
          incomplete_marker)

    if log.parts and (max_levels is None or level < max_levels):
        for part in log.parts:
            print_log(part, format, level + 1,
                      colors=colors,
                      max_levels=max_levels,
                      width=width)
        print
コード例 #2
0
ファイル: git_merge_noff.py プロジェクト: pignacio/.dotfiles
def main():
    logging.basicConfig(stream=sys.stdout, level=logging.INFO)
    options = _get_argument_parser().parse_args()

    try:
        repo = git.Repo('.', search_parent_directories=True)
    except git.exc.InvalidGitRepositoryError:
        print bright_red('This is not a valid git repository!')
        return

    try:
        branch = repo.branches[options.branch]
    except IndexError:
        print bright_red('"{}" is not a valid branch!'.format(options.branch))
        return

    active_branch = repo.active_branch

    if options.into:
        to_merge = repo.active_branch
        base = branch
    else:
        to_merge = branch
        base = repo.active_branch

    if _needs_rebase(base, to_merge):
        print bright_red('To merge "{}" into "{}" you must rebase its '
                         'contents first!'.format(to_merge, base))
        print "To do that, run:"
        print "  git checkout {} && git rebase {}".format(to_merge, base)
        return

    if options.skip_tests:
        print bright_yellow('Skipping tests')
        tests_passed = True
    else:
        to_merge.checkout()
        tests_passed = _run_tests()

    if tests_passed:
        print bright_green('Merging "{}" into "{}"'.format(to_merge, base))
        base.checkout()
        try:
            if subprocess.call(['git', 'merge', '--no-ff',
                                to_merge.name]) != 0:
                print bright_red('Something went wrong while merging. '
                                 'Restoring original branch')
                active_branch.checkout()
        except Exception:
            active_branch.checkout()
            raise
    else:
        print bright_red('Tests FAILED! Not merging.')
        active_branch.checkout()
コード例 #3
0
from .logger import Logger
from .pager import item_type_filter, ItemFilter, items_to_pages
from .props import PropertyList, MISSING_PROPERTY_IDS
from .schema import (SchemaPiece, Integer, Chars, BinarySchema, Until,
                     NullTerminatedChars)
from .utils import str_to_bits, bits_to_str, bits_to_int

logger = logging.getLogger(__name__)  # pylint: disable=invalid-name

_SHARED_STASH_HEADER = str_to_bits("\x53\x53\x53\x00\x30\x31")
_STASH_HEADER = str_to_bits("\x43\x53\x54\x4d\x30\x31")
_PAGE_HEADER = str_to_bits("\x53\x54\x00\x4a\x4d")
_ITEM_HEADER = str_to_bits("\x4a\x4d")

_GREEN_TICK = color.bright_green(u"[✓]")
_RED_CROSS = color.bright_red(u"[✗]")

_ITEM_PARSES = collections.Counter()
_FAILED_PARSES = collections.Counter()


def _check_stash(stash):
    item_schema = BinarySchema(_ITEM_SCHEMA)
    Logger.info("Checking stash. Has {} pages", stash['page_count'])
    item_count = 0
    for page_no, page in enumerate(stash['pages']):
        for item_no, item_data in enumerate(
                sorted(page['items'],
                       key=lambda i: Item(i).position())):
            item_count += 1
            item = Item(item_data)
コード例 #4
0
ファイル: logger.py プロジェクト: pignacio/d2_itemsorter
 def error(cls, format_str, *args, **kwargs):
     format_str = color.bright_red(u"[!!!] " + format_str)
     return cls._log(format_str, *args, **kwargs)