Skip to content

Commit

Permalink
Fix not being able to run package from any other directory than src
Browse files Browse the repository at this point in the history
Related: #7
  • Loading branch information
fdmarcin committed Dec 28, 2020
1 parent dc7bff4 commit dfcddae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

setup(
name="benerator_cumberpy",
version="0.2.0",
version="0.2.1",
description="A Ben Cumberbatch-like name generator",
long_description=long_description,
url="https://github.com/fdmarcin/benerator-cumberpy",
download_url="https://github.com/fdmarcin/benerator-cumberpy/archive/0.2.0.tar.gz",
download_url="https://github.com/fdmarcin/benerator-cumberpy/archive/0.2.1.tar.gz",
author="Marcin Sędłak-Jakubowski",
author_email="[email protected]",
license="MIT",
Expand Down
8 changes: 6 additions & 2 deletions src/benerator_cumberpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import random
from pkg_resources import resource_filename


def benerate_name():

firstnames = resource_filename(__name__, "data/first-names.txt")
lastnames = resource_filename(__name__, "data/last-names.txt")
endname = ""

# choose first name
with open('data/first-names.txt') as f:
with open(firstnames) as f:
data = f.read().splitlines()
endname += random.choice(data).capitalize()

endname += " "

# choose second name
with open('data/last-names.txt') as f:
with open(lastnames) as f:
data = f.read().splitlines()
endname += random.choice(data).capitalize()

Expand All @@ -24,5 +27,6 @@ def hello():

print("Hello there, my name is " + benerate_name() + ".")


if __name__ == "__main__":
benerate_name()

0 comments on commit dfcddae

Please sign in to comment.