Initialised Module
This commit is contained in:
commit
106f69f703
6 changed files with 79 additions and 0 deletions
0
README.md
Normal file
0
README.md
Normal file
3
printr/__init__.py
Normal file
3
printr/__init__.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from simplePrintr import SimplePrintr
|
||||
from itterPrintr import ItterPrintr
|
||||
from ellipsisPrintr import EllipsisPrintr
|
23
printr/ellipsisPrintr.py
Normal file
23
printr/ellipsisPrintr.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
class EllipsisPrinter():
|
||||
def __init__(self, string, max=5):
|
||||
self.string = string
|
||||
self.max = max
|
||||
self.count = -1
|
||||
|
||||
def update(self, commit=False):
|
||||
self.clear()
|
||||
ellipsis = "." * self.count
|
||||
ending = '\r' if not commit else '\n'
|
||||
print(self.string + ellipsis, end=ending)
|
||||
if self.count >= self.max:
|
||||
self.zero()
|
||||
self.count += 1
|
||||
|
||||
def zero(self):
|
||||
self.count = -1
|
||||
|
||||
def commit(self):
|
||||
print()
|
||||
|
||||
def clear(self):
|
||||
print(' ' * (len(self.string) + self.max), end='\r')
|
23
printr/itterPrintr.py
Normal file
23
printr/itterPrintr.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
class ItterPrintr():
|
||||
def __init__(self, string, maxValue, start, diff=1):
|
||||
self.string = string
|
||||
self.maxValue = maxValue
|
||||
self.start = start
|
||||
self.diff = diff
|
||||
self.value = self.start
|
||||
self.buildString()
|
||||
|
||||
def buildString(self):
|
||||
return self.string.format(c=self.value, m=self.maxValue)
|
||||
|
||||
def reachedLimit(self):
|
||||
return self.maxValue <= self.value
|
||||
|
||||
def update(self, inc=True):
|
||||
ending = '\r' if not self.reachedLimit() else '\n'
|
||||
print(self.buildString(), end=ending)
|
||||
if inc:
|
||||
self.inc()
|
||||
|
||||
def inc(self):
|
||||
self.value += self.diff
|
11
printr/simplePrintr.py
Normal file
11
printr/simplePrintr.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
class SimplePrintr():
|
||||
@classmethod
|
||||
def write(string, commit=False):
|
||||
if commit:
|
||||
print(string)
|
||||
else:
|
||||
print(string, end='\r')
|
||||
|
||||
@classmethod
|
||||
def commit():
|
||||
print()
|
19
setup.py
Normal file
19
setup.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from distutils.core import setup
|
||||
|
||||
LONG_DESCRIPTION = None
|
||||
try:
|
||||
LONG_DESCRIPTION = open('README.md').read()
|
||||
except:
|
||||
pass
|
||||
|
||||
setup(
|
||||
name = 'Printr',
|
||||
packages = ['printr'],
|
||||
version = '0.0.1',
|
||||
description = 'Python module to allow a print line to be updated after printing',
|
||||
long_description = LONG_DESCRIPTION
|
||||
author = 'Jake Howard',
|
||||
url = 'https://github.com/RealOrangeOne/Printr',
|
||||
license='MIT',
|
||||
platforms=['any']
|
||||
)
|
Reference in a new issue