Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Clivern committed Dec 19, 2023
1 parent 7f61e05 commit da0b342
Show file tree
Hide file tree
Showing 24 changed files with 97 additions and 1,088 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ TOX ?= tox

help: Makefile
@echo
@echo " Choose a command run in Pallur:"
@echo " Choose a command run in CygX1:"
@echo
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
@echo
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

<p align="center">
<img src="https://apod.nasa.gov/apod/image/2312/CalNeb_Powell_960.jpg" width="100%" />
<p align="center">Could Queen Calafia's mythical island exist in space? Perhaps not, but by chance the outline of this molecular space cloud echoes the outline of the state of California, USA. Our Sun has its home within the Milky Way's Orion Arm, only about 1,000 light-years from the California Nebula. Also known as NGC 1499, the classic emission nebula is around 100 light-years long. On the featured image, the most prominent glow of the California Nebula is the red light characteristic of hydrogen atoms recombining with long lost electrons, stripped away (ionized) by energetic starlight. The star most likely providing the energetic starlight that ionizes much of the nebular gas is the bright, hot, bluish Xi Persei just to the right of the nebula. A regular target for astrophotographers, the California Nebula can be spotted with a wide-field telescope under a dark sky toward the constellation of Perseus, not far from the Pleiades. Explore Your Universe: Random APOD Generator</p>
</p>
22 changes: 11 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
.. image:: https://img.shields.io/pypi/v/pallur.svg
.. image:: https://img.shields.io/pypi/v/cygx1.svg
:alt: PyPI-Server
:target: https://pypi.org/project/pallur/
.. image:: https://github.com/clivern/pallur/actions/workflows/ci.yml/badge.svg
:target: https://pypi.org/project/cygx1/
.. image:: https://github.com/clivern/cygx1/actions/workflows/ci.yml/badge.svg
:alt: Build Status
:target: https://github.com/clivern/pallur/actions/workflows/ci.yml
:target: https://github.com/clivern/cygx1/actions/workflows/ci.yml

|
=======
Pallur
CygX1
=======

A Modern Command Line Tool for Apache Kafka.
The immensity of the universe is difficult to grasp.

To use pallur, follow the following steps:
To use cygx1, follow the following steps:

1. Create a python virtual environment or use system wide environment

Expand All @@ -23,15 +23,15 @@ To use pallur, follow the following steps:
$ source venv/bin/activate
2. Install pallur package with pip.
2. Install cygx1 package with pip.

.. code-block::
$ pip install pallur
$ pip install cygx1
3. Get pallur command line help
3. Get cygx1 command line help

.. code-block::
$ pallur --help
$ cygx1 --help
24 changes: 0 additions & 24 deletions kafka.yml

This file was deleted.

25 changes: 11 additions & 14 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
[metadata]
name = pallur
description = A Modern Command Line Tool for Apache Kafka.
name = cygx1
description = The immensity of the universe is difficult to grasp.
author = Clivern
author_email = [email protected]
license = MIT
license_files = LICENSE.txt
long_description = file: README.rst
long_description_content_type = text/x-rst; charset=UTF-8
url = https://github.com/Clivern/Pallur/
url = https://github.com/Clivern/cygx1/
project_urls =
Documentation = https://github.com/Clivern/Pallur/
Source = https://github.com/Clivern/Pallur/
Changelog = https://github.com/Clivern/Pallur/blob/main/CHANGELOG.rst
Tracker = https://github.com/Clivern/Pallur/issues
Download = https://pypi.org/project/Pallur/#files
Documentation = https://github.com/Clivern/cygx1/
Source = https://github.com/Clivern/cygx1/
Changelog = https://github.com/Clivern/cygx1/blob/main/CHANGELOG.rst
Tracker = https://github.com/Clivern/cygx1/issues
Download = https://pypi.org/project/cygx1/#files

platforms = any

Expand All @@ -31,10 +31,7 @@ package_dir =

install_requires =
click<=8.1.7
PyYAML<=6.0.1
prettytable<=3.8.0
cryptography<=41.0.7
confluent-kafka<=2.3.0
requests<=2.31.0
importlib-metadata<=7.0.0; python_version<"3.8"

[options.packages.find]
Expand All @@ -51,7 +48,7 @@ testing =

[options.entry_points]
console_scripts =
pallur = pallur.cli:main
cygx1 = cygx1.cli:main

[tool:pytest]
addopts =
Expand All @@ -77,4 +74,4 @@ exclude =

[pyscaffold]
version = 4.1.1
package = pallur
package = cygx1
File renamed without changes.
41 changes: 25 additions & 16 deletions src/pallur/module/config.py → src/cygx1/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,35 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import os
import yaml
import click

from cygx1 import __version__
from cygx1.command.explorer import Launch

class Config:
"""Config Class"""

FILE = ".pallur.yml"
@click.group(help="🐺 The immensity of the universe is difficult to grasp.")
@click.version_option(version=__version__, help="Show the current version")
def main():
pass

def __init__(self):
self.configs = {}
self._home = os.getenv("HOME", "")

def load(self):
"""Load Configs"""
with open("{}/{}".format(self._home, Config.FILE)) as f:
self.configs = yaml.load(f, Loader=yaml.FullLoader)
# Explorer command
@click.group(help="Explorer Commands")
def explorer():
pass

return self.configs

def get_configs(self):
"""Get Configs"""
return self.configs
# Delete host sub command
@explorer.command(help="Delete a host")
@click.argument("file")
@click.option("-p", "--platform", "platform", type=click.STRING, default="nasa", help="the platform")
def launch(file, platform):
return Launch(file, platform).run()


# Register Commands
main.add_command(explorer)


if __name__ == "__main__":
main()
File renamed without changes.
47 changes: 24 additions & 23 deletions src/pallur/command/hosts.py → src/cygx1/command/explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,37 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import os
import click

from pallur.module.logger import Logger
from pallur.module.output import Output
from pallur.module.config import Config
from pallur.module.encrypt import Encrypt
from pallur.module.database import Database
from pallur.module.file_system import FileSystem
from cygx1.module.nasa import Nasa
from cygx1.module.logger import Logger
from cygx1.module.file_system import FileSystem


class Hosts:
"""Hosts Class"""
class Launch:
"""Launch Class"""

def __init__(self):
self.output = Output()
self.database = Database()
self.config = Config()
self.encrypt = Encrypt()
def __init__(self, file, platform):
self.file = file
self.platform = platform
self.nasa = Nasa()
self.file_system = FileSystem()
self.logger = Logger().get_logger(__name__)

def init(self):
"""Init database and configs"""
self.configs = self.config.load()
self.database.connect(self.configs["database"]["path"])
self.database.migrate()
return self
def run(self):
"""Run explorer"""

def delete(self, name):
"""Delete a host"""
self.database.delete_host(name)
if self.platform == "nasa":
result = self.nasa.fetch(os.getenv('NASA_API_KEY'))

click.echo(f"Host with name {name} got deleted")
data = f"""
<p align="center">
<img src="{result['url']}" width="100%" />
<p align="center">{result['explanation']}</p>
</p>
"""

self.file_system.write_file(self.file, data)

click.echo("Explorer finished successfully!")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions src/pallur/module/__init__.py → src/cygx1/module/nasa.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,21 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import requests


class Nasa:
"""Nasa Class"""

URL = "https://api.nasa.gov/planetary/apod"

def fetch(self, api_key):
"""Fetch Nasa Data"""

response = requests.get(
Nasa.URL,
headers={'X-API-KEY': api_key}
)

return response.json()
Loading

0 comments on commit da0b342

Please sign in to comment.