Skip to content

Commit a770e08

Browse files
committed
adding github actions workflow to upload to pypi upon release
1 parent a655921 commit a770e08

3 files changed

Lines changed: 59 additions & 11 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# This workflow will upload a Python Package using Twine when a release is created
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Upload Python Package
10+
11+
on:
12+
release:
13+
types: [published]
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
deploy:
20+
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Set up Python
26+
uses: actions/setup-python@v3
27+
with:
28+
python-version: '3.x'
29+
- name: Install dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install build
33+
- name: Build package
34+
run: python -m build
35+
- name: Publish package
36+
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
37+
with:
38+
user: __token__
39+
password: ${{ secrets.PYPI_API_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ labs
77
.venv
88
tests
99
*.7z
10+
*.env

TextSpitter/core.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Doc String
2+
Core application that contains the `FileExtractor` class object
33
"""
44

55
import mimetypes
@@ -24,6 +24,9 @@ def __init__(
2424
The extractor wrapper will initialize by assigning the filename to the
2525
object's file property; if a file-like object is provided instead of a
2626
name, then a file_ext arg will be required.
27+
28+
`file_name` is depreciated.
29+
2730
Args:
2831
file_obj: str | Path | None
2932
filename: : str | None
@@ -32,19 +35,24 @@ def __init__(
3235
if filename:
3336
self.file = FileIO(filename)
3437
self.file_ext = filename.split(".")[-1]
38+
elif isinstance(file_obj, str):
39+
file_obj = Path(file_obj)
40+
3541
elif file_obj and any((isinstance(file_obj, x) for x in (Path, IO))):
36-
if hasattr(file_obj, "name"):
37-
self.file = file_obj
38-
self.file_ext = file_obj.name.split(".")[-1]
39-
else:
40-
raise Exception(
41-
"Your file object does not contain a name attribute. Please"
42-
" add a name attribute with a file extension, and try "
43-
"again. Need the file ext. data for mime-typing."
44-
)
42+
pass
43+
44+
if hasattr(file_obj, "name"):
45+
self.file = file_obj
46+
self.file_ext = file_obj.name.split(".")[-1]
47+
else:
48+
raise Exception(
49+
"Your file object does not contain a name attribute. Please"
50+
" add a name attribute with a file extension, and try "
51+
"again. Need the file ext. data for mime-typing."
52+
)
4553

4654
@staticmethod
47-
def get_file_type(file):
55+
def get_file_type(file: str | Path):
4856
"""
4957
A static method that guesses the mime type for a given file object.
5058
The return value is taken from the sliced value from

0 commit comments

Comments
 (0)