Skip to content

Commit

Permalink
prepare distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
clarketm committed Feb 4, 2019
1 parent 8683830 commit 8151882
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 42 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2019 Travis Clarke <[email protected]> (https://www.travismclarke.com/)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
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.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include LICENSE README.md
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# [s3finder](https://s3finder.readthedocs.io/en/latest/)

[![PyPi release](https://img.shields.io/pypi/v/s3finder.svg)](https://pypi.org/project/s3finder/)
[![Documentation Status](https://readthedocs.org/projects/s3finder/badge/?version=latest)](https://s3finder.readthedocs.io/en/latest/?badge=latest)

Amazon S3 bucket finder.

[Check out the s3finder docs](https://s3finder.readthedocs.io/en/latest/)

## Installation


## Usage


## License

MIT &copy; [**Travis Clarke**](https://blog.travismclarke.com/)
1 change: 1 addition & 0 deletions s3finder/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.0.0"
3 changes: 3 additions & 0 deletions s3finder/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from s3finder.s3finder import cli

cli()
51 changes: 9 additions & 42 deletions s3finder.py → s3finder/s3finder.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import datetime
import warnings
from asyncio import get_event_loop, gather
from collections import defaultdict, Mapping
from copy import deepcopy
from functools import reduce
from collections import defaultdict
from mergedeep import merge
from random import choice

import requests
Expand Down Expand Up @@ -65,55 +64,25 @@ def collect_results(r):

def read_config():
from pathlib import Path

config = {}

config_hierarchy = [
Path(Path.home(), 's3finder.yaml'),
Path(Path.home(), 's3finder.yml'),
Path(Path.cwd(), 's3finder.yaml'),
Path(Path.cwd(), 's3finder.yml'),
Path(Path.home(), "s3finder.yaml"),
Path(Path.home(), "s3finder.yml"),
Path(Path.cwd(), "s3finder.yaml"),
Path(Path.cwd(), "s3finder.yml"),
]

for c in config_hierarchy:
try:
c = yaml.load(open(c, "r"))
deepmerge(config, c)
merge(config, c)
except Exception as e:
pass

return config

def deepmerge(target, *sources):
"""
:param target:
:param *sources:
"""

def _deepmerge(target, source):
"""
:param target:
:param source:
"""
for key in source:
if key in target:
if isinstance(target[key], Mapping) and isinstance(
source[key], Mapping
):
# If the key for both `target` and `source` are Mapping types, then recurse.
_deepmerge(target[key], source[key])
elif target[key] == source[key]:
# If a key exists in both objects and the values are `same`, the value from the `target` object will be used.
pass
else:
# If a key exists in both objects and the values are `different`, the value from the `source` object will be used.
target[key] = deepcopy(source[key])
else:
# If the key exists only in `source`, the value from the `source` object will be used.
target[key] = deepcopy(source[key])
return target

return reduce(_deepmerge, sources, target)


def main(envs, formats, regions, seps, useragents, words):
start = datetime.datetime.now()
Expand Down Expand Up @@ -156,6 +125,4 @@ def cli():


if __name__ == "__main__":
# cli()
c = read_config()
print(c)
cli()
36 changes: 36 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import re

import setuptools, os


def open_local(paths, mode="r", encoding="utf8"):
path = os.path.join(os.path.abspath(os.path.dirname(__file__)), *paths)
return open(path, mode=mode, encoding=encoding)


with open_local(["s3finder", "__init__.py"]) as f:
version = re.search(r"__version__ = [\"'](\d+\.\d+\.\d+)[\"']", f.read()).group(1)

with open_local(["README.md"]) as f:
long_description = f.read()

install_requires = ["mergedeep>=1"]

setuptools.setup(
name="s3finder",
version=version,
author="Travis Clarke",
author_email="[email protected]",
description="Amazon S3 bucket finder.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/clarketm/s3finder",
packages=setuptools.find_packages(),
install_requires=install_requires,
entry_points={"console_scripts": ["s3finder=s3finder.s3finder:cli"]},
classifiers=(
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
),
)

0 comments on commit 8151882

Please sign in to comment.