Skip to content
This repository was archived by the owner on Sep 16, 2023. It is now read-only.

Commit 0097185

Browse files
committed
rename save-user and datacollection folder to secret and collect
1 parent e984670 commit 0097185

File tree

10 files changed

+48
-10
lines changed

10 files changed

+48
-10
lines changed

LICENSE.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) [year] [fullname]
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# twitchanal (Twitch Analytics)
22

3-
A command line tool for Twitch analytics.
3+
A command line tool for Twitch analytics. This is originally a group project of my class at school.
44

55
## Table of Contents
66

@@ -24,6 +24,12 @@ eGaming is one of the popular entertainments nowadays. Twitch is a live streamin
2424
pip3 install .
2525
```
2626

27+
Or for development:
28+
29+
``` shell
30+
pip3 install -e .
31+
```
32+
2733
## Commands
2834

2935
``` shell

setup.py

+5
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44
with open('requirements.txt') as f:
55
required = f.read().splitlines()
66

7+
with open("README.md", "r") as fh:
8+
long_description = fh.read()
9+
710
setup(name='twitchanal',
811
version='0.0.2',
912
author='yuukidach',
1013
author_email='[email protected]',
14+
long_description=long_description,
15+
long_description_content_type="text/markdown",
1116
install_requires = required,
1217
python_requires = '>=3.7',
1318
package_dir={'': 'src'},

src/twitchanal/cli.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import click
2-
from twitchanal.save_secret.save_secret import save_id_secret
3-
from twitchanal.datacollection.collect import collect_data
2+
from twitchanal.secret.secret import save_id_secret
3+
from twitchanal.collect.collect import collect_data
44

55

66
@click.group()
@@ -10,12 +10,14 @@ def cli():
1010

1111

1212
@click.command()
13-
def save_user():
13+
@click.option('--dir', '-d', default='./',
14+
help='Directory to store the secret.')
15+
def save_user(dir):
1416
""" Save user id and secret key in `secret.yaml`.
1517
"""
1618
id = click.prompt('Please enter the client ID', type=str)
1719
secret = click.prompt('Please enter the secret key', type=str)
18-
save_id_secret(id, secret)
20+
save_id_secret(id, secret, dir)
1921

2022

2123
@click.command()
File renamed without changes.

src/twitchanal/datacollection/collect.py src/twitchanal/collect/collect.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from twitchAPI.twitch import Twitch
77
from twitchAPI.oauth import UserAuthenticator
88
from twitchAPI.types import AuthScope
9-
from twitchanal.save_secret.save_secret import *
9+
from twitchanal.secret.secret import *
1010

1111

1212
def get_dataframe(data: dict) -> pd.DataFrame:
File renamed without changes.

src/twitchanal/save_secret/save_secret.py src/twitchanal/secret/secret.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,36 @@
44
from typing import Tuple
55

66

7-
def save_id_secret(id: str, secret: str) -> bool:
7+
def save_id_secret(id: str, secret: str, dir :str="") -> bool:
88
""" Save id and secret in yaml file.
99
1010
Args:
1111
id (str): user id
1212
secret (str): user secret key
13+
dir (str): directory to store the `secret.yaml`
1314
1415
Returns:
1516
bool: True
1617
"""
18+
path = os.path.join(dir, 'secret.yaml')
19+
os.makedirs(os.path.dirname(path), exist_ok=True)
1720
data = {'client_id': id, 'secret_key': secret}
18-
with open('secret.yaml', 'w') as f:
21+
with open(path, 'w') as f:
1922
yaml.dump(data, f)
2023
return True
2124

2225

23-
def load_id_secret() -> Tuple[str, str]:
26+
def load_id_secret(dir: str="") -> Tuple[str, str]:
2427
""" Load id and secret from yaml file.
2528
2629
Returns:
2730
(id, secret): return None if no valid data is gotten.
2831
"""
2932
id = None
3033
secret = None
34+
path = os.path.join(dir, 'secret.yaml')
3135
# check if `secret.yaml` exists
32-
if (not os.path.exists('secret.yaml')):
36+
if (not os.path.exists(path)):
3337
cprint(
3438
'Error: `secret.yaml` not found. '
3539
'Please go the the dir contains this file '
File renamed without changes.

test/test.py tests/test.py

File renamed without changes.

0 commit comments

Comments
 (0)