-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/setup param #49
Changes from 10 commits
1b2bab0
23b2204
0b86b94
1f98e54
3b7569c
041f5ca
61683f4
ae4c26c
4090262
a2b9707
92fad66
345ad48
4496359
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,9 @@ | |
"url": r'^(http|https)://[a-zA-Z0-9.-_]+\.[a-zA-Z]{2,}(/\S*)?$', | ||
} | ||
INVALID_PACKAGE_PARAMETER_NAME_ERROR = "Given parameter doesn't exist among the supported user allowed parameters." | ||
INVALID_PACKAGE_PARAMETER_VALUE_ERROR = "Invalid value for {parameter} that should be a valid {regex}" | ||
INVALID_PACKAGE_PARAMETER_VALUE_ERROR = "Invalid value for {parameter} that should be a valid {regex}" | ||
INVALID_CONFIG_FILE_NAME_ERROR = "Given file name for user-defined setup.py params is not a string." | ||
PARAM_FILE_DOES_NOT_EXIST_ERROR = "Given file doesn't exist." | ||
INVALID_INPUT_USER_PARAM = "Invalid input for user params." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure about
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I update the error message, changing |
||
UNEQUAL_PARAM_NAME_LENGTH_ERROR = "You should pass either one single file path to be used for setup.py parameters \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, add a new line at the end of this file. |
||
or per each package name, there should be a specific dedicated file path." |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
# -*- coding: utf-8 -*- | ||
"""utility module.""" | ||
from inspect import signature | ||
import os | ||
import json | ||
import shutil | ||
|
||
from inspect import signature | ||
from .reserver_errors import ReserverBaseError | ||
from .reserver_param import INVALID_CONFIG_FILE_NAME_ERROR, PARAM_FILE_DOES_NOT_EXIST_ERROR | ||
|
||
def has_named_parameter(func, param_name): | ||
""" | ||
|
@@ -32,3 +34,22 @@ def remove_dir(dirpath): | |
""" | ||
if os.path.exists(dirpath) and os.path.isdir(dirpath): | ||
shutil.rmtree(dirpath) | ||
|
||
|
||
def read_json(file_name): | ||
""" | ||
Read the json file and return the python obj of it. | ||
|
||
:param file_name: name of the .json file | ||
:type file_name: str | ||
:return: obj | ||
""" | ||
if not isinstance(file_name, str): | ||
raise ReserverBaseError(INVALID_CONFIG_FILE_NAME_ERROR) | ||
if ".json" not in file_name: | ||
file_name = file_name + ".json" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's not a good check. They may have a json file without |
||
if os.path.isfile(file_name): | ||
config_file = open(file_name) | ||
return json.load(config_file) | ||
else: | ||
raise ReserverBaseError(PARAM_FILE_DOES_NOT_EXIST_ERROR) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add extra new line to the end of this file. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"description": "[config] This name has been reserved using Reserver", | ||
"author": "[config] Development Team", | ||
"author_email": "[email protected]", | ||
"url": "https://configurl.com", | ||
"download_url": "https://configdownload_url.com", | ||
"source": "https://configgithub.com/source", | ||
"license": "[config] MIT" | ||
} | ||
Comment on lines
+1
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, add an example of this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. after this PR, I will handle CLI in which we can handle custom batch uploads |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"description": "[config2] This name has been reserved using Reserver", | ||
"author": "[config2] Development Team", | ||
"author_email": "[email protected]", | ||
"url": "https://config2url.com", | ||
"download_url": "https://config2download_url.com", | ||
"source": "https://config2github.com/source", | ||
"license": "[config2] MIT" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ def test_standard_module_conflict(): | |
def test_batch_packages_names(): | ||
# test batch of package names | ||
uploader = PyPIUploader(test_pypi_token, test_pypi=True) | ||
assert uploader.batch_upload("numpy", "scikit-learn") == 0 | ||
assert uploader.batch_upload(["numpy", "scikit-learn"]) == 0 | ||
|
||
def test_valid_package_invalid_credentials(): | ||
# test not reserved name -> wrong credentials | ||
|
@@ -36,3 +36,12 @@ def test_module_conflict(): | |
# try to reserve a name which conflicts with the module name of a previously taken package (the taken package itself has a different name, but it's module name has conflict)." | ||
uploader = PyPIUploader(pypi_token, test_pypi=False) | ||
assert uploader.upload("freeze") == False | ||
|
||
def test_batch_upload(): | ||
# try to reserve two non taken package names with per package custom setup.py parameters | ||
# uploader = PyPIUploader(test_pypi_token, True) | ||
# assert uploader.batch_upload( | ||
# [get_random_name(), get_random_name() + get_random_name()], | ||
# ["config.json", "config2.json"] | ||
# ) == 2 | ||
assert True == True | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add an extra new line at the end of this file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure about
setup.py
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I update the error message, changing
setup.py
withpackage
.