Skip to content

Commit

Permalink
clean code, add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Joaopeuko committed Apr 27, 2024
1 parent 4730bcf commit 98cf30f
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 46 deletions.
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Secured

- [Secured](#secured)
- [Installation](#installation)
- [Usage](#usage)
- [Example 1: Basic Usage](#example-1-basic-usage)
- [Example 2: Custom Usage](#example-2-custom-usage)
- [Features](#features)


Secure your Python data structures and secrets with Secured. This package provides a straightforward solution for obscuring sensitive data in applications. It's specifically designed for developers who need to protect API keys, database credentials, and other critical configuration details from accidental exposure. Featuring customizable security measures, our tool allows you to control how sensitive information is represented and managed securely. It's ideal for projects that demand high data confidentiality and integrity. Please note that this provides a thin layer of protection.

## Installation

To install Secured, run the following command:

```python
pip install secured
```

## Usage

Below are some examples on how to use Secured to protect your sensitive data:

### Example 1: Basic Usage

```python
from secured import Secure

# Protect a sensitive string
DATABASE_URL = "mysql://user:password@localhost/dbname"
secure_database_url = Secure(DATABASE_URL, "<Data Hidden>")

# Usage in code
print(secure_database_url) # Output: <Data Hidden>
```

### Example 2: Custom Usage

```python
from secured import Secure

# Protect an API key with a custom message
API_KEY = "12345-abcdef-67890-ghijk"
secure_api_key = Secure(API_KEY, "API Key Protected")

# Usage in code
print(secure_api_key) # Output: API Key Protected
```

## Features

- **Data Protection**: Helps prevent the accidental logging or display of sensitive information.
- **Customizable Representations**: Set how your data is displayed when being secured.
- **Ease of Use**: Integrate seamlessly into existing Python applications.
62 changes: 16 additions & 46 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,59 +1,29 @@
from setuptools import setup, find_packages
import toml

# Function to parse pyproject.toml file to extract dependencies
def parse_pyproject_dependencies():
with open("pyproject.toml", "r") as f:
content = f.read()
# Load and parse the pyproject.toml file
with open("pyproject.toml", "r") as f:
pyproject = toml.load(f)

# Extract dependencies from content
dependencies_start = content.find("[tool.poetry.dependencies]")
dependencies_end = content.find("[", dependencies_start + 1)
dependencies_section = content[dependencies_start:dependencies_end].strip()
# Extract dependencies
dependencies = pyproject['tool']['poetry']['dependencies']
dev_dependencies = pyproject['tool']['poetry']['group']['dev']['dependencies']

dependencies = {}
for line in dependencies_section.split("\n")[1:]:
if line.strip() and "=" in line:
dep, version = line.split("=")
dependencies[dep.strip()] = version.strip().replace('"', '')
# Read README.md for the long description
with open("README.md", "r") as file:
long_description = file.read()

return dependencies

# Function to parse pyproject.toml file to extract dev dependencies
def parse_pyproject_dev_dependencies():
with open("pyproject.toml", "r") as f:
content = f.read()

# Extract dev dependencies from content
dev_dependencies_start = content.find("[tool.poetry.group.dev.dependencies]")
dev_dependencies_end = content.find("[", dev_dependencies_start + 1)
dev_dependencies_section = content[dev_dependencies_start:dev_dependencies_end].strip()

dev_dependencies = {}
for line in dev_dependencies_section.split("\n")[1:]:
if line.strip() and "=" in line:
dep, version = line.split("=")
dev_dependencies[dep.strip()] = version.strip().replace('"', '')

return dev_dependencies

# Read README.md file
with open("README.md", "r") as fh:
long_description = fh.read()

# Get dependencies from pyproject.toml
install_requires = [f"{dep}=={version}" for dep, version in parse_pyproject_dependencies().items() if dep != "python"]

# Get dev dependencies from pyproject.toml
# Convert dependencies to the required format for setuptools
install_requires = [f"{dep}{version}" for dep, version in dependencies.items() if dep != "python"]
extras_require = {
"dev": [f"{dep}=={version}" for dep, version in parse_pyproject_dev_dependencies().items()]
"dev": [f"{dep}{version}" for dep, version in dev_dependencies.items()]
}

setup(
name="secured",
version="0.1.0",
version=pyproject['tool']['poetry']['version'],
author="Joao Paulo Euko",
author_email="",
description="",
description="Secure your Python data with Secured. This tool protects sensitive information like API keys and database credentials, offering customizable settings for high confidentiality and integrity. Note: Provides a thin layer of protection.",
long_description=long_description,
long_description_content_type="text/markdown",
url="",
Expand All @@ -65,5 +35,5 @@ def parse_pyproject_dev_dependencies():
],
python_requires=">=3.8",
install_requires=install_requires,
extras_require=extras_require,
extras_require=extras_require
)

0 comments on commit 98cf30f

Please sign in to comment.