diff --git a/config/adjectives.yml b/config/adjectives.yml deleted file mode 100644 index 768528d..0000000 --- a/config/adjectives.yml +++ /dev/null @@ -1,58 +0,0 @@ ---- -adjectives: - - arrogant - - beautiful - - best - - biggest - - circular - - competent - - confusing - - courageous - - cumbersome - - dainty - - dark - - devoted - - efficient - - expensive - - fickle - - generous - - graceful - - grumpy - - happiest - - helpful - - hopeful - - hot - - hungry - - mild - - modern - - muscular - - new - - new - - oldest - - oval - - petite - - prettiest - - proud - - rich - - rocky - - round - - round - - royal - - rude - - safe - - scary - - sleepy - - small - - smart - - smelly - - stable - - strange - - strange - - tardy - - thin - - weary - - wicked - - witty - - wooden - - youthful - - zany \ No newline at end of file diff --git a/pyfake/adjective.py b/pyfake/adjective.py index 21a6f5f..7f40ba8 100644 --- a/pyfake/adjective.py +++ b/pyfake/adjective.py @@ -1,14 +1,15 @@ from .generator import Generator +from pathlib import Path import random import yaml +with open(str(Path(__file__).parent) + '/config/adjectives.yml', 'r') as file: + CONFIG = yaml.safe_load(file) class Adjective(Generator): - with open("config/adjectives.yml", "r") as file: - CONFIG = yaml.safe_load(file) - def adjective(self): - return random.choice(self.CONFIG["adjectives"]) + print(CONFIG) + return random.choice(CONFIG) def generate(self): self.adjective = self.adjective() diff --git a/pyfake/book.py b/pyfake/book.py index 648534b..4e7431e 100644 --- a/pyfake/book.py +++ b/pyfake/book.py @@ -1,8 +1,9 @@ from .generator import Generator +from pathlib import Path import random import yaml -with open('config/books.yml', 'r') as file: +with open(str(Path(__file__).parent) + '/config/books.yml', 'r') as file: CONFIG = yaml.safe_load(file) class Book(Generator): diff --git a/pyfake/company.py b/pyfake/company.py index dd8515b..1101f7b 100644 --- a/pyfake/company.py +++ b/pyfake/company.py @@ -1,16 +1,17 @@ from .generator import Generator +from pathlib import Path import random import yaml -class Company(Generator): - with open('config/company.yml', 'r') as file: - CONFIG = yaml.safe_load(file) +with open(str(Path(__file__).parent) + '/config/company.yml', 'r') as file: + CONFIG = yaml.safe_load(file) +class Company(Generator): def company_name(self): - return random.choice(self.CONFIG['names']) + return random.choice(CONFIG['names']) def company_suffix(self): - return random.choice(self.CONFIG['suffixes']) + return random.choice(CONFIG['suffixes']) def generate(self): self.size = random.randint(1, 100) diff --git a/pyfake/config.py b/pyfake/config.py new file mode 100644 index 0000000..e69de29 diff --git a/pyfake/config/adjectives.yml b/pyfake/config/adjectives.yml new file mode 100644 index 0000000..8d7e009 --- /dev/null +++ b/pyfake/config/adjectives.yml @@ -0,0 +1,57 @@ +--- +- arrogant +- beautiful +- best +- biggest +- circular +- competent +- confusing +- courageous +- cumbersome +- dainty +- dark +- devoted +- efficient +- expensive +- fickle +- generous +- graceful +- grumpy +- happiest +- helpful +- hopeful +- hot +- hungry +- mild +- modern +- muscular +- new +- new +- oldest +- oval +- petite +- prettiest +- proud +- rich +- rocky +- round +- round +- royal +- rude +- safe +- scary +- sleepy +- small +- smart +- smelly +- stable +- strange +- strange +- tardy +- thin +- weary +- wicked +- witty +- wooden +- youthful +- zany \ No newline at end of file diff --git a/config/books.yml b/pyfake/config/books.yml similarity index 100% rename from config/books.yml rename to pyfake/config/books.yml diff --git a/config/company.yml b/pyfake/config/company.yml similarity index 100% rename from config/company.yml rename to pyfake/config/company.yml diff --git a/config/countries.yml b/pyfake/config/countries.yml similarity index 100% rename from config/countries.yml rename to pyfake/config/countries.yml diff --git a/config/people.yml b/pyfake/config/people.yml similarity index 100% rename from config/people.yml rename to pyfake/config/people.yml diff --git a/config/sports.yml b/pyfake/config/sports.yml similarity index 100% rename from config/sports.yml rename to pyfake/config/sports.yml diff --git a/pyfake/country.py b/pyfake/country.py index eaec16e..07354a0 100644 --- a/pyfake/country.py +++ b/pyfake/country.py @@ -1,13 +1,14 @@ from .generator import Generator +from pathlib import Path import yaml import random -class Country(Generator): - with open('config/countries.yml', 'r') as file: - CONFIG = yaml.safe_load(file) +with open(str(Path(__file__).parent) + '/config/countries.yml', 'r') as file: + CONFIG = yaml.safe_load(file) +class Country(Generator): def generate(self): - data = random.choice(self.CONFIG) + data = random.choice(CONFIG) self.name = data['name'] self.currency = data['currency'] diff --git a/pyfake/person.py b/pyfake/person.py index b5b4a87..4ebccb5 100644 --- a/pyfake/person.py +++ b/pyfake/person.py @@ -1,13 +1,14 @@ from .generator import Generator +from pathlib import Path import random import yaml -class Person(Generator): - with open('config/people.yml', 'r') as file: - CONFIG = yaml.safe_load(file) +with open(str(Path(__file__).parent) + '/config/people.yml', 'r') as file: + CONFIG = yaml.safe_load(file) +class Person(Generator): def generate(self): - data = random.choice(self.CONFIG) + data = random.choice(CONFIG) self.first_name = data['first_name'] self.last_name = data['last_name'] diff --git a/pyfake/sport.py b/pyfake/sport.py index 0cb4ffd..38ebfc3 100644 --- a/pyfake/sport.py +++ b/pyfake/sport.py @@ -1,13 +1,14 @@ from .generator import Generator +from pathlib import Path import yaml import random -class Sport(Generator): - with open('config/sports.yml', 'r') as file: - CONFIG = yaml.safe_load(file) +with open(str(Path(__file__).parent) + '/config/sports.yml', 'r') as file: + CONFIG = yaml.safe_load(file) +class Sport(Generator): def generate(self): - data = random.choice(self.CONFIG) + data = random.choice(CONFIG) self.name = data['name'] self.players = data['players'] diff --git a/tests/test_adjective.py b/tests/test_adjective.py index 8fb59fc..f07d51c 100644 --- a/tests/test_adjective.py +++ b/tests/test_adjective.py @@ -3,4 +3,4 @@ def test_adjective(): adj = Adjective().adjective - assert adj in Adjective().CONFIG['adjectives'] \ No newline at end of file + assert isinstance(adj, str) \ No newline at end of file