Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
Added files
Browse files Browse the repository at this point in the history
  • Loading branch information
nihaals committed Aug 21, 2019
1 parent d652ab8 commit 5c80b63
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 1 deletion.
28 changes: 28 additions & 0 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Upload

on: [push]

jobs:
upload:
name: Upload to PyPi
runs-on: ubuntu-latest
steps:
- name: Check if tag was pushed
uses: actions/bin/filter@master
with:
args: 'tag'
- name: Checkout
uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install dependencies
run: pip install -U pip && pip install -U twine setuptools wheel
- name: Build dist files
run: python setup.py sdist bdist_wheel
- name: Upload
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TWINE_TOKEN }}
run: twine upload dist/*
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea/
.vscode/
__pycache__/
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
# pecho
# pecho
Pecho makes it easy to write things like status bars.

## Usage
```python
from pecho import echo

echo('1%') # 1%
echo('2%') # Replaces with 2%
echo('3%', newline=True) # Replaces with 3% and appends a newline
echo('4%') # 3%\n4%
```
40 changes: 40 additions & 0 deletions pecho/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# MIT License
#
# Copyright (c) 2019 Nihaal Sangha
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import colorama

colorama.init()

__all__ = ['echo']
__version__ = '0.1.0'


def echo(*objects, sep=' ', end='', file=None, flush=True, newline=False, print_func=print):
if objects:
objects = ('\r' + str(objects[0]),) + objects[1:]

end += '\033[K'

if newline:
end += '\n'

print_func(*objects, sep=sep, end=end, file=file, flush=flush)
9 changes: 9 additions & 0 deletions pecho/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import sys
from typing import Any, TextIO, Callable, List

__all__: List[str]
__version__: str

def echo(*objects: Any, sep: str = ' ', end: str = '', file: TextIO = sys.stdout, flush: bool = False,
newline: bool = False, print_func: Callable = print):
...
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
colorama
55 changes: 55 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import re

from setuptools import find_packages, setup

with open('requirements.txt') as f:
requirements = f.read().splitlines()

with open('pecho/__init__.py') as f:
version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE).group(1)

if not version:
raise RuntimeError('Version is not set')

if version.endswith(('a', 'b', 'rc')):
# Append version identifier based on commit count
try:
import subprocess

p = subprocess.Popen(['git', 'rev-list', '--count', 'HEAD'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if out:
version += out.decode('utf-8').strip()
p = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if out:
version += '+g' + out.decode('utf-8').strip()
except Exception:
pass

with open('README.md') as f:
readme = f.read()

setup(
name="Pecho",
author="Nihaal Sangha (Orangutan)",
url="https://github.com/OrangutanGaming/pecho",
project_urls={
"Issue tracker": "https://github.com/OrangutanGaming/pecho/issues",
},
version=version,
packages=find_packages(),
license="MIT",
description="Pecho makes it easy to write things like status bars",
long_description=readme,
long_description_content_type="text/markdown",
include_package_data=True,
install_requires=requirements,
python_requires='>=3.3',
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
]
)

0 comments on commit 5c80b63

Please sign in to comment.