diff --git a/.gitignore b/.gitignore index 9f2a47c..fb3cdf9 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,6 @@ tmp !public/icons/manifest.json *.yaml *.pickle +*.npy __pycache__/ config.py diff --git a/ikeagen.py b/ikeagen.py index 955bc8d..717f61f 100755 --- a/ikeagen.py +++ b/ikeagen.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -import pickle +import numpy as np import os import random from PIL import Image @@ -9,7 +9,8 @@ import utils def gen(): - table = [[[0 for i in range(221)] for j in range(221)] for k in range(221)] + n = 221 + table = np.empty(shape=(n, n, n), dtype=np.int) crawldata = utils.crawl_data() names = {result["name"] for result in crawldata} count = 0 @@ -27,17 +28,6 @@ def gen(): return table, count -def save(data): - with open('ikeaname.pickle', 'wb') as outfile: - pickle.dump(data, outfile, pickle.HIGHEST_PROTOCOL) - - -def load(): - with open('ikeaname.pickle', "rb") as inputfile: - table = pickle.load(inputfile) - return table - - def letter(a, b): mylist = [] for c in range(221): @@ -62,13 +52,11 @@ def image(table): img.save('image.png') -if os.path.isfile('ikeaname.pickle'): - table, count = load() - # image(table) - +if os.path.isfile('ikeaname.npy') and False: # Loading uses twice the memory and is therefore disabled + table, count = np.load('ikeaname.npy') else: table, count = gen() - save((table, count)) + np.save('ikeaname.npy', (table, count), ) def generate(): diff --git a/requirements.txt b/requirements.txt index 46c5b1e..0ab1747 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,17 +1,41 @@ +numpy +asn1crypto==0.24.0 +attrs==17.4.0 +Automat==0.6.0 beautifulsoup4==4.6.0 certifi==2017.11.5 +cffi==1.11.2 chardet==3.0.4 click==6.7 +constantly==15.1.0 +cryptography==2.1.4 +cssselect==1.0.3 Flask==0.12.2 future==0.16.0 +hyperlink==17.3.1 idna==2.6 +incremental==17.5.0 itsdangerous==0.24 Jinja2==2.10 +lxml==4.1.1 MarkupSafe==1.0 olefile==0.44 -Pillow==4.3.0 +parsel==1.3.1 +Pillow==5.0.0 +pyasn1==0.4.2 +pyasn1-modules==0.2.1 +pycparser==2.18 +PyDispatcher==2.0.5 +pyOpenSSL==17.5.0 python-telegram-bot==9.0.0 PyYAML==3.12 +queuelib==1.4.2 requests==2.18.4 +Scrapy==1.5.0 +service-identity==17.0.0 +six==1.11.0 +Twisted==17.9.0 urllib3==1.22 -Werkzeug==0.13 +w3lib==1.18.0 +Werkzeug==0.14.1 +zope.interface==4.4.3