Пример #1
0
 def setup_content(self):
     if not self.data:
         return
     self.content = []
     cut_line = '-' * (self.CW // 2 - 1) + '8<' + '-' * (self.CW // 2 - 1)
     for h in self.data:
         self.content += text.remove_superfluous_alineas(h)
         self.content.append(cut_line)
Пример #2
0
def git_diff(path):
    if not path or type(path) is not str:
        raise Exception('Path not supported: ' + str(path))

    cmd = 'git diff -- %s' % path
    data, error = run_with_error_code(cmd)
    if not data:
        cmd = 'git diff -- /dev/null %s' % path
        data, error = run_with_error_code(cmd)
        if data:
            data = data[5:]
            error = 0
    else:
        data = data[4:]
    # import cursutils
    # cursutils.debug()
    if error:
        raise Exception('Error executing "' + cmd + '" (error = ' + str(error))
    hunks = textutils.blocks(data, lambda x: x and x.startswith('@@'))
    screen_content = []
    for h in hunks:
        screen_content += textutils.remove_superfluous_alineas(h)
        screen_content.append('─' * 80)
    return screen_content