Skip to content

IVIURRAY/yt-eve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

58 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

EVE

Eve is a cli tool to bring together all my utilities into a centralised place.

Tutorials

Follow my YouTube tutorial series to follow along making this program.

Youtube video series

How to Install

  1. git clone https://github.com/IVIURRAY/yt-eve.git
  2. cd eve
  3. pip install .
  4. eve [cmd] See API section for commands to run.

Testing

Run tests with pytest command

How to Contribute

The EVE project welcomes all contributions!

  1. Fork this repo.
  2. Make a branch to put your changes on.
  3. Add a file called /eve/commands/cmd_<you_change>.py and /eve/service/svc_<your_change>.py.
    • Plenty of examples to take from already in those directories.
    • Splitting CLI logic under /cmd_<you_change>.py and api logic under /svc_<your_change>.py.
  4. Submit a PR explaining your change and what it does, with examples!
  5. Thank you in advance πŸ‘ !!

Configuration

In order to use all supported commands, you would need to provide your personal preferences/credentials. There are two ways it can be done, see below.

  1. Override default parameters in ~/eve/config.py (Do not commit these changes) os.environ.get("ENV", "default") reads the env var "ENV" and takes "default" if this variable is not set.

config.py example

import os

# Weather API
WX_API_KEY = os.environ.get("WX_API_KEY", "e5209303a83828u2eako7c849302d2j2")
WX_LOCATION = os.environ.get("WX_LOCATION", "London")
WX_METRIC_TEMP = os.environ.get("WX_METRIC_TEMP", "celsius")
WX_METRIC_WIND = os.environ.get("WX_METRIC_WIND", "km_hour")

# Github API
GITHUB_USER = os.environ.get("GITHUB_USER", "johndoe")
GITHUB_PASS = os.environ.get("GITHUB_PASS", "superSecretPass")

# Tidy
TIDY_ROOT = os.environ.get("TIDY_ROOT", "/User/johndoe/Downloads")  # "</path/to/root>"

# Crypto
COIN_MARKET_CAP_API_KEY = os.environ.get("COIN_MARKET_CAP_API_KEY", "5i3qe43d-2de2-2eid-63b3-9403920395d2")
DEFAULT_COIN = os.environ.get("DEFAULT_COIN", "BTC")
CURRENCY = os.environ.get("CURRENCY", "GBP")

# Calendar
DEFAULT_EVENTS_NUMBER = os.environ.get("DEFAULT_EVENTS_NUMBER", "10")
PATH_TO_CRED = os.environ.get("PATH_TO_CALENDAR_API_CRED", "/Users/john/cred/credentials.json")
  1. Set env variables in your shell. For convenience, create ~/.eve_config file with the following content, examples in the comments
# Weather API
export WX_API_KEY=you_personal_open_weather_api_key # e5209303a83828u2eako7c849302d2j2
export WX_LOCATION=your_preferred_default_location # London
export WX_METRIC_TEMP=your_preferred_temperature_units # celsius ( <celsius|fahrenheit|kelvin> )
export WX_METRIC_WIND=your_preferred_wind_units # km_hour ( <miles_hour|km_hour|knots> )

#Github API
export GITHUB_USER=your_github_username # johndoe
export GITHUB_PASS=your_github_password # supersecretpassword

# Tidy
export TIDY_ROOT="</path/to/root>" # /User/johndoe/Downloads

#Crypto
export COIN_MARKET_CAP_API_KEY=your_personal_coinmarket_cap_api_key # 5i3qe43d-2de2-2eid-63b3-9403920395d2
export DEFAULT_COIN=your_preferred_default_crypto_currency_symbol # BTC
export CURRENCY=your_preferred_default_currency_to_convert_to # EUR

#Calendar
export DEFAULT_EVENTS_NUMBER=10
export PATH_TO_CALENDAR_API_CRED="/Users/john/creds/credentials.json"

export env variables in this file on the startup of the shell. Depending on what shell you use, add this line to ~/.zshrc; ~/.bash_profile, etc

source ~/.eve_config

restart your shell

API

Below is a list of the currently support API commands.

Football

The football command uses openfootball under the hood.

It is intended to be used for viewing football result and table information.

Below, is a list of currently support commands.

Usage: eve football [OPTIONS] COMMAND [ARGS]...

  Football results

Options:
  --help  Show this message and exit.

Commands:
  table  View a table

table

The table command can be used to view the current standing of a given league. (Defaults to English Premier league).

Usage: eve football table [OPTIONS]

  View a table

Options:
  -l, --league TEXT  The league to view - See codes at
                     https://github.com/openfootball/football.json

  --help             Show this message and exit.

options

  • -l --league - a league code to view the table for. Defautls to en.1.
$ eve football table -l en.1
Running Premier League 2020/21 table generator
 1st:            Everton FC           13 pts  7 gd
 2nd:           Liverpool FC          10 pts  0 gd
 3rd:          Aston Villa FC         9 pts   9 gd
 4th:        Leicester City FC        9 pts   5 gd
 5th:            Arsenal FC           9 pts   2 gd
 6th:            Chelsea FC           8 pts   4 gd
 7th:       Tottenham Hotspur FC      7 pts   7 gd
 8th:         Leeds United FC         7 pts   1 gd
 9th:        Manchester City FC       7 pts   0 gd
10th:          Southampton FC         7 pts  -1 gd
11th:        Crystal Palace FC        7 pts  -2 gd
12th:       Newcastle United FC       7 pts  -2 gd
13th:        West Ham United FC       6 pts   4 gd
14th:    Wolverhampton Wanderers FC   6 pts  -3 gd
15th:       Manchester United FC      6 pts  -3 gd
16th:    Brighton & Hove Albion FC    4 pts  -2 gd
17th:       Sheffield United FC       1 pts  -5 gd
18th:            Fulham FC            1 pts  -8 gd
19th:     West Bromwich Albion FC     1 pts  -8 gd
20th:            Burnley FC           0 pts  -5 gd

Github

The github command uses PyGithub under the hood.

It is intended to be used for automating repetitive tasks around repository management.

Below, is a list of currently support commands.

Usage: eve github [OPTIONS] COMMAND [ARGS]...

  Github utilities

Options:
  --help  Show this message and exit.

Commands:
  create  Create a github repo
  delete  Delete a github repo

create

The create command allows you to create a repository on Github.

Usage: eve github create [OPTIONS] NAME

  Create a github repo

Options:
  -p, --private BOOLEAN  Is the repo private?
  -i, --gitignore TEXT   The .gitignore file to add to the repo
  --help                 Show this message and exit.

options

  • -p --private - set the repository to private or not. eve github create <name> -p <True|False>. Default to False.
  • -i --gitignore - initialise with a .gitignore file. eve github create <name> -i Python
$ eve github create test-repo -i Python

Created: test-repo at https://github.com/IVIURRAY/test-repo
Run the below command to add the repo as a remote...
git remote add origin https://github.com/IVIURRAY/test-repo.git

delete

The delete command allows you to delete a repository on Github.

Usage: eve github delete [OPTIONS] NAME

  Delete a github repo

Options:
  --help  Show this message and exit.
$ eve github delete test-repo

Are you sure you want to delete https://github.com/IVIURRAY/test-repo? [y/N]: y
Deleted: test-repo

Tidy

The tidy command is used to tidy a directory into sub-folders based on the file's extension.

A detail explaniation can be found here.

Usage: eve tidy [OPTIONS]

  Tidy a directory

Options:
  -v, --verbose    Enable verbose logging
  -p, --path TEXT  Directory path to tidy
  --help           Show this message and exit.

options

  • '-v' '--verbose' - flag to enable verbose logging
  • '-p' '--path' - the path to tidy. This can be set by default in config.py

tidy Tidy a given directory, defaults to what is set in config.py

$ eve tidy -v
============= Tidying 5 files in: /Users/SWEHaydn/Downloads =============
'some_pdf.pdf' --> '/pdf/some_pdf.pdf'
'some_txt.txt' --> '/txt/some_txt.txt'
'some_jpg.jpg' --> '/jpg/some_jpg.jpg'
'some_mp4.mp4' --> '/mp4/some_mp4.mp4'
'some_py.py'   --> '/py/some_py.py'

Weather

The weather commands use OpenWeatherMap under the hood.

It is intended to be used for querying and viewing weather information.

Below, is a list of currently supported commands.

Usage: eve weather [OPTIONS] COMMAND [ARGS]...

  Weather information

Options:
  -l, --location TEXT  Weather at this location.  [default: London]
  --help               Show this message and exit.

Commands:
  current   Current weather at a location
  forecast  Forecast for a location

options

  • -l --location - override the default location. eve weather -l <mytown> current

current

The current command gives you information for weather at a location right now.

Usage: eve weather current [OPTIONS]

  Current weather at a location

Options:
  --help  Show this message and exit.
$ eve weather current

========= London GB - BROKEN CLOUDS =========
πŸ”₯ Temp: 22.84 - 21.67/23.89 (min/max)
πŸŒͺ Wind: 12.8
πŸ’§ Rain: {}
πŸŒ• Sunrise: 05:08 - Sunset: 20:08 πŸŒ‘

forecast

The forecast command displays weather for the upcoming days.

Usage: eve weather forecast [OPTIONS]

  Forecast for a location

Options:
  --help  Show this message and exit.
$ eve weather forecast
  ================================== Paris FR =================================
  πŸ“… Date:  Mon 15 Mar    Tue 16 Mar    Wed 17 Mar    Thu 18 Mar    Fri 19 Mar
  πŸ”₯ Temp:    11.79         10.88         10.56          9.27          7.56
  πŸŒͺ Wind:    23.62          8.24         22.03         29.02         24.12
  πŸ’§ Rain: {'3h': 0.36}       No            No       {'3h': 0.4}        No

Crypto

The crypto commands use CoinMarketCapApi or Gecko under the hood.

It is intended to be used for querying current price for given crypto currency.

Below, is a list of currently supported commands.

Usage: eve crypto [OPTIONS] COMMAND [ARGS]...

  Coin price for a given coin

Options:
  -c, --coin TEXT                 Coin  [default: BTC]
  -ccy, --currency TEXT
                                  destination  [default: EUR]
  --help                          Show this message and exit.

Commands:
  price

price

The price command gives you information about the price of the coin.

$ eve crypto price
  ============= BTC (BITCOIN) PRICE ============
  πŸ’± Price:         50,413.6830 EUR
  πŸ’° Market cap:    940,417,447,517.0726 EUR
  🏦 TTL supply:    18,654,012
  πŸ“ˆ 24H change:    -1.7 %

options

  • -c --coin - override the default coin. eve crypto -c <mycoin> price
  • -ccy --currency - overrides the default destination eve cripto -ccy <mycurrency> price

example

$ eve crypto -c "ADA" -ccy "RUB" price
  ============= ADA (CARDANO) PRICE ============
  πŸ’± Price:         78.6613 RUB
  πŸ’° Market cap:    2,513,096,409,058.2915 RUB
  🏦 TTL supply:    45,000,000,000
  πŸ“ˆ 24H change:    -3.4 %

it is also possible to set another crypto currency as destination currency

$ eve crypto -c "BTC" -ccy "ADA" price
============= BTC (BITCOIN) PRICE ============
πŸ’± Price:         56,273.0083 ADA
πŸ’° Market cap:    1,049,717,372,134.1301 ADA
🏦 TTL supply:    18,654,012
πŸ“ˆ 24H change:    1.8 %

Calendar

The cal command uses Google Calendar Api

Intended to be used for getting info about upcoming events in the given calendar

$ eve cal --help
Usage: eve cal [OPTIONS] COMMAND [ARGS]...

  Google calendar interaction

Options:
  --help  Show this message and exit.

Commands:
  events  Display number of upcoming events in google calendar

example

$ eve cal events
 ========= Retrospective team Avengers =========
 πŸ‘¨ Organizer:     tony.stark@gmail.com
 ⏱ Starts in:     In Progress
 ⏳ Duration:      60 min
 βœ… Status:        Confirmed
 ==================== FriYay ===================
 πŸ‘¨ Organizer:     jane.doe@gmail.com
 ⏱ Starts in:     33
 ⏳ Duration:      60 min
 βœ… Status:        Confirmed

Accessing google calendar API

In order to access api you'd need to go to the quickstart and click Enable the Google Calendar API

After that, move the downloaded file to the desired directory. Once that is done, either change config.py specifying the directory as a second parameter in os.environ.get() for PATH_TO_CRED variable or export PATH_TO_CALENDAR_API_CRED in .eve_config file.

Quote

The quote command uses the quote module which is a python wrapper for the Goodreads Quote API.

Below is a list of currently supported options:

Usage: eve quote [OPTIONS]

  Output quotes.

Options:
  -s, --search TEXT Searchstring for random quotes.
  -- help           Show this message and exit.

The default searchsting ('Tolkien') can be overridden by using the search option. For excample: eve quote -s 'Harry Potter'

Note

The note command can be used to store some small notes that are ordered by a due date and priority (if provided by the user).

On the first execution, a JSON-file is created in the users home-path to store the notes. The path can be changed in the config.py.

During creation of the file it is populated with some demo-entries. The entries are ordered by due date (first) and priority (second). If a due date is reached it is printed out with a highlighted color.

Usage: eve note [OPTIONS] COMMAND [ARGS]

  Make notes.

Options:
  -- help           Show this message and exit.

Commands:
  add     Add notes.
  delete  Delete notes.
  edit    Edit notes.
  show    Show table with notes.

Add

Usage: eve note add [OPTIONS]

  Add notes.

Options:
  -t, --note_text TEXT    Note text. [required]
  -d, --due_date TEXT     Due date (YYYY-MM-DD).
  -p, --priority INTEGER  Priority.
  -- help                 Show this message and exit.

The only required option is the note text. For example eve note add -t "This is a test."

For more detailed entries, use the other options as well. For example eve note add -t "This is a test." -d "2021-10-01" -p 5.

All notes get a (integer) key and a creation date by default. Not provided options get a None value by default.

Delete

Usage: eve note delete [OPTIONS]

  Delete notes.

Options:
  -k, --key INTEGER  Key of the note. [required]
  -- help                 Show this message and exit.

Notes are deleted by providing their (integer) key. For example eve note delete -k 3.

After deleting a note, all other notes get newly enumerated and therefore a new key value.

Edit

Usage: eve note edit [OPTIONS]

  Edit notes.

Options:
  -k, --key INTEGER       Key of the note. [required]
  -d, --due_date TEXT     Due date (YYYY-MM-DD).
  -p, --priority INTEGER  Priority.
  -t, --note_text TEXT    Note text.
  -- help                 Show this message and exit.

Notes are edited by their (integer) key. For example eve note edit -k 4 -t "Edited entry".

After editing a note the EditDate value is overwritten with the current date.

Show

Usage: eve note show [OPTIONS]

  Show table with notes.

Options:
  -- help  Show this message and exit.

Surely the simplest command with no "real" options. It just shows all notes ordered by due date and priority in a nicely formated table.

The show command is also executed automaticaly after adding, deleting or editing a note.

+-----------------------------------------------------------------------------------+
| Key | CreationDate | EditDate   | DueDate    | Priority | NoteText                |
|-----+--------------+------------+------------+----------+-------------------------|
| 3   | 2021-04-24   | 2021-04-24 | 2021-04-28 | 2        | This is sample entry 3. |
| 2   | 2021-04-24   | 2021-04-24 | 2021-04-29 | 1        | This is sample entry 2. |
| 1   | 2021-04-24   | None       | 2030-10-29 | None     | This is sample entry 1. |
+-----------------------------------------------------------------------------------+