Skip to content

Commit

Permalink
Creating new tool
Browse files Browse the repository at this point in the history
  • Loading branch information
John Pfuntner committed Jan 10, 2025
1 parent 70cf266 commit c9dc063
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions bin/rotate-chars
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#! /usr/bin/env python3

import sys
import signal
import logging
import argparse

parser = argparse.ArgumentParser(description='Rotate a file - lines become columns and viceversa')
parser.add_argument('-v', '--verbose', action='count', help='Enable debugging')
args = parser.parse_args()

logging.basicConfig(format='%(asctime)s %(levelname)s %(pathname)s:%(lineno)d %(msg)s')
log = logging.getLogger(sys.argv[0])
log.setLevel(logging.WARNING - (args.verbose or 0)*10)

signal.signal(signal.SIGPIPE, lambda signum, stack_frame: exit(0))

if sys.stdin.isatty():
parser.error('stdin must be directed')

lines = sys.stdin.read().splitlines()
if lines:
for col in range(max([len(line) for line in lines])):
line = ''
log.info(f'{col=}')
for row in range(len(lines)):
log.info(f'{row=} {col=}')
if col < len(lines[row]):
line += lines[row][col]
else:
line += ' '
log.info(f'{line=}')
print(line.rstrip())

0 comments on commit c9dc063

Please sign in to comment.