-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add dev-requirements for reserver package * import uploader object in `__init__` * add function to check given name existance as a package name * add function to generate template `setup.py` for the given name * `Uploader` object initialization * add `upload_to_pypi` function * add pypi associated params to `reserver_param.py` * add docstring for functions in `reserver_func.py` * update docstring * add `is_platform_linux` & `get_random_name` utility function * apply `autopep8.sh` * add `test.pypi` credentials to test.yml * add package name to the params * update test step's name * reserved name package upload test case * update .gitignore * update the exception's description * update test files * add requests requirement to `dev-requirements.txt` * add timeout to `get` request * add `bandit` config file * update `test.yml` * update docstring issues reported by `pydocstyle` * clean `imports` part * add return value for `upload_to_pypi` function * handle invalid PyPI API Key * split test cases add `package_exists` test case add `valid_package_invalid_credentials` test case add `valid_package_valid_credentials` test case * enhance docstrings * remove python 3.6 support for now * remove assert & dummy pass detection rules in bandit * add test case to `README.md` * add placeholder for github stars * add placeholder for PyPI counter * update `CHANGELOG.md` * `dev-requirements.txt` updated * `requirements.txt` updated * remove installation of requirements * temporarily removed `importlib-metadata<5.0` * remove unused import * remove `is_platform_linux` function * move `get_random_name` function from `utils.py` to `reserver_func.py` * update template `setup.py` * update docstrings * remove `util.py` and add inner functionalities to `reserver_func.py` * update test file import * update author email * add logo to readme * partially update discord badge * add Logo `.png` file * fullfil discord badges * fullfil `pypi` badge in `README.md` * add References + fix typo * remove `\n` from packages * add functionality to create folder with the package name with a __init__.py inside * make param name shorter * handle "-" issue in `.eggfile`(replace with "_") * handle too similiar name * remove extra print in `reserver_obj.py` * update test cases * `README.md` updated * `CHANGELOG.md` updated * logo name updated * fix `requests` requirment to trigger dependent bot * add `requests` to package main requirments * remove python 3.6 * correct typo in docstring * ensure env variables are popped out * change `>=` to `==` in basic requirments' version to trigger dependent bot * Bump twine from 4.0.0 to 4.0.2 (#6) Bumps [twine](https://github.com/pypa/twine) from 4.0.0 to 4.0.2. - [Release notes](https://github.com/pypa/twine/releases) - [Changelog](https://github.com/pypa/twine/blob/main/docs/changelog.rst) - [Commits](pypa/twine@4.0.0...4.0.2) --- updated-dependencies: - dependency-name: twine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump requests from 1.0.0 to 2.31.0 (#7) Bumps [requests](https://github.com/psf/requests) from 1.0.0 to 2.31.0. - [Release notes](https://github.com/psf/requests/releases) - [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md) - [Commits](psf/requests@v1.0.0...v2.31.0) --- updated-dependencies: - dependency-name: requests dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump wheel from 0.40.0 to 0.42.0 (#8) Bumps [wheel](https://github.com/pypa/wheel) from 0.40.0 to 0.42.0. - [Release notes](https://github.com/pypa/wheel/releases) - [Changelog](https://github.com/pypa/wheel/blob/main/docs/news.rst) - [Commits](pypa/wheel@0.40.0...0.42.0) --- updated-dependencies: - dependency-name: wheel dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump setuptools from 40.8.0 to 69.0.3 (#9) Bumps [setuptools](https://github.com/pypa/setuptools) from 40.8.0 to 69.0.3. - [Release notes](https://github.com/pypa/setuptools/releases) - [Changelog](https://github.com/pypa/setuptools/blob/main/NEWS.rst) - [Commits](pypa/setuptools@v40.8.0...v69.0.3) --- updated-dependencies: - dependency-name: setuptools dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * `Disclaimer` section added * add disclaimer to table of index * `README.md` updated --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
0ae5bb9
commit cd0429e
Showing
14 changed files
with
294 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[bandit] | ||
skips=B404,B602,B101,B105 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
requests==2.31.0 | ||
setuptools==69.0.3 | ||
wheel==0.42.0 | ||
twine==4.0.2 | ||
vulture>=1.0 | ||
bandit>=1.5.1 | ||
pydocstyle>=3.0.0 | ||
pytest>=4.3.1 | ||
pytest-cov>=2.6.1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
requests>=1.0.0 | ||
setuptools>=40.8.0 | ||
wheel>=0.40.0 | ||
twine>=4.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Reserver modules.""" | ||
from .reserver_param import RESERVER_VERSION | ||
from .reserver_obj import Uploader | ||
|
||
__version__ = RESERVER_VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,103 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Functions.""" | ||
"""Reserver functions.""" | ||
from requests import get | ||
from .reserver_param import PYPI_TEST_URL, PYPI_MAIN_URL | ||
from hashlib import sha256 | ||
from time import time | ||
from os import mkdir, rmdir | ||
|
||
|
||
def get_random_name(): | ||
""" | ||
Generate a random str based on current timestamp. | ||
:return: str | ||
""" | ||
return sha256(str(time()).encode("utf-8")).hexdigest() | ||
|
||
|
||
def does_package_exist(suggested_name, test_pypi): | ||
""" | ||
Check whether a package with the given name exists or not. | ||
:param suggested_name: given name to search in pypi(or test.pypi) | ||
:type suggested_name: str | ||
:param test_pypi: indicates to search in test.pypi or not | ||
:type test_pypi: bool | ||
:return: whether given name does exist in the pypi or not(as a boolean value) | ||
""" | ||
if not isinstance(suggested_name, str): | ||
suggested_name = str(suggested_name) | ||
if test_pypi: | ||
url = PYPI_TEST_URL + "/" + suggested_name + "/" | ||
else: | ||
url = PYPI_MAIN_URL + "/" + suggested_name + "/" | ||
response = get(url, timeout=5) | ||
return not response.status_code == 404 | ||
|
||
|
||
def generate_template_setup_py(package_name): | ||
""" | ||
Generate a template `setup.py` file for given package name. | ||
:param package_name: given name to generate template `setup.py` for it. | ||
:type package_name: str | ||
:return: None | ||
""" | ||
setup_py_content = """ | ||
import sys | ||
try: | ||
from setuptools import setup | ||
except ImportError: | ||
from distutils.core import setup | ||
# invalid email | ||
# download url | ||
# url | ||
# project urls | ||
setup( | ||
name =""" + "\"" + package_name + "\"" + """, | ||
packages=[""" + "\"" + package_name + "\"" + "," + """], | ||
version='0.0.0', | ||
description='This name has been reserved using Reserver', | ||
long_description=\"\"\" | ||
This name has been reserved using [Reserver](https://github.com/openscilab/reserver). | ||
\"\"\", | ||
long_description_content_type='text/markdown', | ||
author='Development Team', | ||
author_email='[email protected]', | ||
url='https://url.com', | ||
download_url='https://download_url.com', | ||
keywords="python3 python reserve reserver reserved", | ||
project_urls={ | ||
'Source': 'https://github.com/source', | ||
}, | ||
install_requires="", | ||
python_requires='>=3.6', | ||
classifiers=[ | ||
\'Development Status :: 1 - Planning\', | ||
\'Programming Language :: Python :: 3.6\', | ||
\'Programming Language :: Python :: 3.7\', | ||
\'Programming Language :: Python :: 3.8\', | ||
\'Programming Language :: Python :: 3.9\', | ||
\'Programming Language :: Python :: 3.10\', | ||
\'Programming Language :: Python :: 3.11\', | ||
\'Programming Language :: Python :: 3.12\', | ||
], | ||
license='MIT', | ||
) | ||
""" | ||
with open(package_name + "_setup.py", "w+") as f: | ||
f.writelines(setup_py_content) | ||
|
||
try: | ||
mkdir(package_name) | ||
except FileExistsError: | ||
rmdir(package_name) | ||
mkdir(package_name) | ||
with open(package_name + "/__init__.py", "w") as f: | ||
f.write("# -*- coding: utf-8 -*-\n") | ||
f.write("\"\"\"" + package_name + " modules." + "\"\"\"") |
Oops, something went wrong.