Skip to content

Commit f6fc787

Browse files
authored
v6.0
2 parents 2a36a8e + 827afb5 commit f6fc787

File tree

6 files changed

+190
-87
lines changed

6 files changed

+190
-87
lines changed

.github/workflows/pypi-publish.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Upload Python Package to pypi
2+
3+
on:
4+
release
5+
6+
jobs:
7+
test-and-publish:
8+
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Set up Python
14+
uses: actions/setup-python@v2
15+
with:
16+
python-version: '3.x'
17+
- name: Install dependencies
18+
run: |
19+
python -m pip install --upgrade pip
20+
pip install setuptools wheel twine
21+
- name: Build and publish
22+
env:
23+
STACKMANAGER_VERSION: {{ github.event.release.tag_name }}
24+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
25+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
26+
run: |
27+
python setup.py sdist bdist_wheel
28+
twine upload dist/* --verbose
29+
- name: Test installation
30+
run: |
31+
pip install createstructure

.github/workflows/pypi-test.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Test Python Package
2+
3+
on:
4+
push
5+
6+
jobs:
7+
test:
8+
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Set up Python
14+
uses: actions/setup-python@v2
15+
with:
16+
python-version: '3.8'
17+
- name: Install dependencies
18+
run: |
19+
python -m pip install --upgrade pip
20+
pip install setuptools wheel twine
21+
- name: Build and publish
22+
run: |
23+
python setup.py sdist bdist_wheel

.github/workflows/test.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push
55

66
jobs:
7-
test-ubuntu-debian:
7+
test-ubuntu-debian-manual:
88
runs-on: ubuntu-latest
99
steps:
1010
- name: Installation & execution
@@ -18,7 +18,7 @@ jobs:
1818
pip3 install -r requirements/requirements.txt
1919
alias create_structure="python3 ~/create_structure/bin/create_structure.py -t=${{ secrets.REPO_TOKEN }} -o=CastellaniDavideTest"
2020
21-
test-windows:
21+
test-windows-manual:
2222
runs-on: windows-latest
2323
steps:
2424
- name: Installation
@@ -34,3 +34,18 @@ jobs:
3434
New-Item -Path $Profile -Type File -Force
3535
echo "Function CreateStructureFunction {python 'C:\Program Files/create_structure/bin/create_structure.py' -t=${{ secrets.REPO_TOKEN }} -o=CastellaniDavideTest'}" > $Profile
3636
echo "Set-Alias -Name create_structure -Value CreateStructureFunction" >> $Profile
37+
38+
pypi-test:
39+
runs-on: ${{ matrix.os }}
40+
strategy:
41+
matrix:
42+
os: [ubuntu-18.04, ubuntu-latest, windows-latest]
43+
steps:
44+
- uses: actions/checkout@v2
45+
- name: Set up Python 3.8
46+
uses: actions/setup-python@v2
47+
with:
48+
python-version: 3.8
49+
- name: Install
50+
run: |
51+
pip3.8 install createstructure
Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""This is the magic "robottino" by Castellani Davide
1+
"""This is the magic bot by Castellani Davide
22
With this programm you can easly create a repository on GitHub with a basic template, personalized for your use.
33
44
If there was any type of problem you can contact me on my help email: help@castellanidavide.it
@@ -13,33 +13,88 @@
1313
from sys import argv
1414

1515
__author__ = "help@castellanidavide.it"
16-
__version__ = "5.5 2020-12-13"
16+
__version__ = "6.0 2020-12-16"
1717

1818
class create_structure:
19-
def __init__ (self, TOKEN, SOUCES_OF_TEMPLATES, ORGANIZATION_NAME, IGNORE_FOLDERS):
19+
def __init__ (self):
2020
"""Main function
2121
"""
22-
self.TOKEN = TOKEN
23-
self.SOUCES_OF_TEMPLATES = SOUCES_OF_TEMPLATES
24-
self.ORGANIZATION_NAME = ORGANIZATION_NAME
25-
self.IGNORE_FOLDERS = IGNORE_FOLDERS
26-
27-
self.login() # Login
22+
# Initial inputs
23+
self.initial_inputs()
24+
25+
if self.CONTINUE:
26+
self.login() # Login
27+
28+
# Make questions
29+
self.asks()
2830

29-
# Make questions
30-
self.asks()
31+
# Make repo
32+
Thread(target = self.create_repo()).start()
3133

32-
# Make repo
33-
Thread(target = self.create_repo()).start()
34+
# Get template
35+
self.choose_template()
3436

35-
# Get template
36-
self.choose_template()
37+
# Get changes
38+
self.change_map()
39+
40+
# Make all
41+
Thread(target = self.scan_and_elaborate()).start()
3742

38-
# Get changes
39-
self.change_map()
43+
def initial_inputs(self):
44+
"""Initial input read
45+
"""
46+
# Default
47+
self.CONTINUE = True
48+
self.TOKEN = None
49+
self.SOUCES_OF_TEMPLATES = ['CastellaniDavide']
50+
self.ORGANIZATION_NAME = ""
51+
self.IGNORE_FOLDERS = []
52+
53+
# Check if there were all argv
54+
try:
55+
# Go to documentation if requested
56+
assert (not("-h" in argv or "--help" in argv))
57+
58+
# Read arguments
59+
for arg in argv:
60+
# find tocken
61+
if "--token=" in arg or "-t=" in arg:
62+
self.TOKEN = arg.replace("--token=", "").replace("-t=", "")
63+
# find souces
64+
if "--sources=" in arg or "-s=" in arg:
65+
self.SOUCES_OF_TEMPLATES = [i for i in arg.replace("--sources=", "").replace("-s=", "").replace("'", "").replace('"', "")[1:-1].split(",")]
66+
# find tocken
67+
if "--organization=" in arg or "-o=" in arg:
68+
self.ORGANIZATION_NAME = arg.replace("--organization=", "").replace("-o=", "")
69+
# find tocken
70+
if "--ignore=" in arg or "-i=" in arg:
71+
self.IGNORE_FOLDERS = [i for i in arg.replace("--ignore=", "").replace("-i=", "").replace("'", "").replace('"', "")[1:-1].split(",")]
4072

41-
# Make all
42-
Thread(target = self.scan_and_elaborate()).start()
73+
# Check all data
74+
assert(self.TOKEN != "TODO" and self.TOKEN != None and self.TOKEN != "***")
75+
76+
except:
77+
self.CONTINUE = False
78+
documentation = ["usage create_structure",
79+
"\t[--token= | -t=]",
80+
"\t[--sources= | -s=]",
81+
"\t[--organization= | -o=]",
82+
"\t[--ignore= | -i=]",
83+
"",
84+
"These are the create_structure arguments:",
85+
"\t--token= or -t= The GitHub tocken with repo and organization permission",
86+
"\t--sources= or -s= (optional) The array with your favourite sources, for eg. ['CastellaniDavide']",
87+
"\t--organization= or -o= (optional) The organization name, leave empty if you want to create repos in your personal account",
88+
"\t--ignore= or -i= (optional) The folders to be ignored",
89+
"",
90+
"Extra situation(s):",
91+
"\t--help or -h To see the documentation",
92+
"",
93+
"Made with ❤ by Castellani Davide (@DavideC03)",
94+
""]
95+
96+
for line in documentation:
97+
print(line)
4398

4499
def login(self):
45100
"""Made the login in GitHub
@@ -184,60 +239,5 @@ def create_file (self, path, file):
184239
""" Read the argv, and sometimes writes the documentation
185240
"""
186241

187-
# Default
188-
TOKEN = None
189-
SOUCES_OF_TEMPLATES = ['CastellaniDavide']
190-
ORGANIZATION_NAME = ""
191-
IGNORE_FOLDERS = []
192-
193-
# Check if there were all argv
194-
try:
195-
# Go to documentation if requested
196-
assert (not("-h" in argv or "--help" in argv))
197-
198-
# Read arguments
199-
for arg in argv:
200-
# find tocken
201-
if "--token=" in arg or "-t=" in arg:
202-
TOKEN = arg.replace("--token=", "").replace("-t=", "")
203-
# find souces
204-
if "--sources=" in arg or "-s=" in arg:
205-
SOUCES_OF_TEMPLATES = [i for i in arg.replace("--sources=", "").replace("-s=", "").replace("'", "").replace('"', "")[1:-1].split(",")]
206-
# find tocken
207-
if "--organization=" in arg or "-o=" in arg:
208-
ORGANIZATION_NAME = arg.replace("--organization=", "").replace("-o=", "")
209-
# find tocken
210-
if "--ignore=" in arg or "-i=" in arg:
211-
IGNORE_FOLDERS = [i for i in arg.replace("--ignore=", "").replace("-i=", "").replace("'", "").replace('"', "")[1:-1].split(",")]
212242

213-
# Check all data
214-
assert(TOKEN != None and TOKEN != "***")
215-
216-
# Start with code
217-
try:
218-
create_structure(TOKEN, SOUCES_OF_TEMPLATES, ORGANIZATION_NAME, IGNORE_FOLDERS)
219-
except:
220-
print("There is an error, try to check if the repo name is already used.")
221-
222-
except:
223-
documentation = ["usage create_structure",
224-
"\t[--token= | -t=]",
225-
"\t[--sources= | -s=]",
226-
"\t[--organization= | -o=]",
227-
"\t[--ignore= | -i=]",
228-
"",
229-
"These are the create_structure arguments:",
230-
"\t--token= or -t= The GitHub tocken with repo and organization permission",
231-
"\t--sources= or -s= (optional) The array with your favourite sources, for eg. ['CastellaniDavide']",
232-
"\t--organization= or -o= (optional) The organization name, leave empty if you want to create repos in your personal account",
233-
"\t--ignore= or -i= (optional) The folders to be ignored",
234-
"",
235-
"Extra situation(s):",
236-
"\t--help or -h To see the documentation",
237-
"",
238-
"Made with ❤ by Castellani Davide (@DavideC03)",
239-
""]
240-
241-
for line in documentation:
242-
print(line)
243243

docs/README.md

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# create_structure
2-
[![GitHub license](https://img.shields.io/badge/license-GNU-green?style=flat)](https://github.com/CastellaniDavide/cpp-create_structure/blob/master/LICENSE) ![Author](https://img.shields.io/badge/author-Castellani%20Davide-green?style=flat) ![Version](https://img.shields.io/badge/version-v5.5-blue?style=flat) ![Language Python](https://img.shields.io/badge/language-Python-yellowgreen?style=flat) ![sys.platform supported](https://img.shields.io/badge/OS%20platform%20supported-Linux,%20Windows%20&%20Mac%20OS-blue?style=flat) [![On GitHub](https://img.shields.io/badge/on%20GitHub-True-green?style=flat&logo=github)](https://github.com/CastellaniDavide/create_structure) ![Check installation](https://github.com/CastellaniDavide/create_structure/workflows/Check%20installation/badge.svg)
2+
[![GitHub license](https://img.shields.io/badge/license-GNU-green?style=flat)](https://github.com/CastellaniDavide/cpp-create_structure/blob/master/LICENSE) ![Author](https://img.shields.io/badge/author-Castellani%20Davide-green?style=flat) ![Version](https://img.shields.io/badge/version-v6.0-blue?style=flat) ![Language Python](https://img.shields.io/badge/language-Python-yellowgreen?style=flat) ![sys.platform supported](https://img.shields.io/badge/OS%20platform%20supported-Linux,%20Windows%20&%20Mac%20OS-blue?style=flat) [![On GitHub](https://img.shields.io/badge/on%20GitHub-True-green?style=flat&logo=github)](https://github.com/CastellaniDavide/create_structure) ![PyPI](https://img.shields.io/pypi/v/createstructure)
33

44
## Contents
55
- [Description](#description)
@@ -15,16 +15,20 @@ This is the magic :octocat: bot :octocat: by Castellani Davide
1515
With this programm you can easly create a repository on GitHub :octocat: with a basic template, personalized for your use.
1616

1717
### Required
18+
- required python3 (>=3.8)
19+
- pip3
1820
- Internet connection
1921
- GitHub account
2022
- [GitHub Token](https://github.com/settings/tokens) with repo and organization permission
2123

22-
### Setup/ Update
24+
### Setup
2325
#### Attention: replace <SOME_WORDS> with your values
24-
- Debian/Ubuntu: ```sudo apt install git python3 python3-pip; cd ~; git clone https://github.com/CastellaniDavide/create_structure.git; cd create_structure; git pull --force; pip3 install -r requirements/requirements.txt; alias create_structure="python3 ~/create_structure/bin/create_structure.py -t=<TOCKEN> -s=<(optional)_ARRAY_OF_TEMPLATE_SOURCES> -o=<(optional)_ORGANIZATION> -i=<(optional)_FOLDERS_TO_BE_IGNORED_FROM_TEMPLATE>"```
25-
- Windows (on PowerShell as Adminastrator): ```Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')); choco install git.install -y; choco install python3 --pre -y; cd "C:\Program Files"; git clone https://github.com/CastellaniDavide/create_structure.git; cd create_structure; git pull --force; pip3 install -r requirements/requirements.txt;New-Item -Path $Profile -Type File -Force; echo "Function CreateStructureFunction {python 'C:\Program Files/create_structure/bin/create_structure.py' -t=<TOCKEN> -s='<(optional)_ARRAY_OF_TEMPLATE_SOURCES>' -o=<(optional)_ORGANIZATION> -i='<(optional)_FOLDERS_TO_BE_IGNORED_FROM_TEMPLATE>'}" > $Profile; echo "Set-Alias -Name create_structure -Value CreateStructureFunction" >> $Profile```
26-
- open another powershell window on you PC and start to use code
27-
- Others:
26+
- All OS using pypi:
27+
- ```pip install createstructure```
28+
- Made an alias of use
29+
- Value of the alias: ```python3 -c "exec(\"from create_structure import create_structure\ncreate_structure()\")" -t=<TOCKEN> -s='<(optional)_ARRAY_OF_TEMPLATE_SOURCES>' -o=<(optional)_ORGANIZATION> -i='<(optional)_FOLDERS_TO_BE_IGNORED_FROM_TEMPLATE>```
30+
- Eg. ubuntu/debian: ```alias createstucture='python3 -c "exec(\"from create_structure import create_structure\ncreate_structure()\")" -t=<TOCKEN> -s='<(optional)_ARRAY_OF_TEMPLATE_SOURCES>' -o=<(optional)_ORGANIZATION> -i='<(optional)_FOLDERS_TO_BE_IGNORED_FROM_TEMPLATE>'```
31+
- Manual by source:
2832
- [install git](https://git-scm.com/download)
2933
- download the repo ```git clone https://github.com/CastellaniDavide/create_structure.git```
3034
- [install python3](https://www.python.org/)
@@ -34,18 +38,25 @@ With this programm you can easly create a repository on GitHub :octocat: with a
3438
- name: create_structure
3539
- attribute: python3 <ABSOLUTE_PATH_OF_REPO>/bin/create_structure.py -t=<TOCKEN> -s=<ARRAY_OF_SOURCES> -o=<(optional)_ORGANIZATION> -i=<(optional)_FOLDERS_TO_BE_IGNORED_FROM_TEMPLATE>
3640

41+
### Update
42+
- With pypi method: ```pip3 install [package_name] --upgrade```
43+
3744
### Directories structure
3845
- .github
3946
- ISSUE_TEMPLATE
40-
- bug_report.md
41-
- feature-request.md
42-
- bin
43-
- create_structure.py
47+
- *.md
48+
- workflows
49+
- *.yml
50+
- create_structure
51+
- __init __.py
4452
- doc
53+
- _config.yml
4554
- LICENSE
4655
- README.md
4756
- requirements
4857
- requirements.txt
58+
- setup.py
59+
- .gitignore
4960

5061
### Execution examples
5162
- create_structure
@@ -76,6 +87,7 @@ With this programm you can easly create a repository on GitHub :octocat: with a
7687
- Try to execute this programm and check correct use
7788

7889
### Changelog
90+
- [6.0_2020-12-16](#60_2020-12-16)
7991
- [5.5_2020-12-13](#55_2020-12-13)
8092
- [5.4_2020-12-12](#54_2020-12-12)
8193
- [5.3_2020-11-29](#53_2020-11-29)
@@ -88,7 +100,10 @@ With this programm you can easly create a repository on GitHub :octocat: with a
88100
- [2.0_2020-3-24](#20_2020-3-24)
89101
- [1.0_2020-3-24](#10_2020-3-24)
90102

91-
#### 5._2020-12-13
103+
#### 6.0_2020-12-16
104+
- Added pypi support [https://pypi.org/project/createstructure/](https://pypi.org/project/createstructure/)
105+
106+
#### 5.5_2020-12-13
92107
- Add first version of GitHub Actions
93108

94109
#### 5.4_2020-12-12

setup.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from setuptools import setup, find_packages
2+
from requests import get
3+
4+
setup(
5+
name='createstructure',
6+
version=get("https://api.github.com/repos/CastellaniDavide/create_structure/tags").json()[0]['name'].replace("v", ""), # Lastest release
7+
description=get("https://api.github.com/repos/CastellaniDavide/create_structure").json()['description'],
8+
long_description=get("https://raw.githubusercontent.com/CastellaniDavide/create_structure/master/docs/README.md").text,
9+
long_description_content_type="text/markdown",
10+
url=get("https://api.github.com/repos/CastellaniDavide/create_structure").json()['html_url'],
11+
author=get("https://api.github.com/repos/CastellaniDavide/create_structure").json()['owner']['login'],
12+
author_email=get(f"https://api.github.com/users/{get('https://api.github.com/repos/CastellaniDavide/create_structure').json()['owner']['login']}").json()['email'],
13+
license='GNU',
14+
packages=find_packages(),
15+
python_requires=">=3.7",
16+
platforms="linux_distibution",
17+
install_requires=[i for i in get("https://raw.githubusercontent.com/CastellaniDavide/create_structure/master/requirements/requirements.txt").text.split("\n") if not "#" in i and i != ''],
18+
zip_safe=True
19+
)

0 commit comments

Comments
 (0)