Browse Source

Starting on packaging procedure.

master
Raphael Roberts 7 years ago
parent
commit
4492c72bcc
  1. 4
      .gitignore
  2. 17
      setup.py
  3. 30
      src/c_fits.c
  4. 6
      src/fits.pyx
  5. 22
      wordscape/candidate_cache.py
  6. 0
      wordscape/dictionary.py
  7. 8
      wordscape/main.py
  8. 0
      wordscape/word_remove_dialog.py

4
.gitignore

@ -1,2 +1,6 @@
__pycache__
.#*
/build/*
*.html
*.pyd
/fits.c

17
setup.py

@ -0,0 +1,17 @@
from setuptools import setup, find_packages
from Cython.Build import cythonize
with open("requirements.txt") as file:
REQUIREMENTS = file.read().rstrip().split("\n")
setup(
author="Raphael Roberts",
author_email="raphael.robets48@gmail.com",
description="Cheat for wordscape and wordscape like games",
entry_points=None,
ext_modules=cythonize("src/fits.pyx"),
install_requires=REQUIREMENTS,
name="wordscape_cheats",
packages=find_packages(),
version="1.0",
)

30
src/c_fits.c

@ -0,0 +1,30 @@
int _fits(char* bottom, int len_bottom, char* top, int len_top) {
int bottom_letters[26];
int top_letters[26];
int letter_val;
int i;
for (i = 0; i < len_bottom; i++) {
letter_val = bottom[i]-96;
if (0 <= letter_val && letter_val <= 25) {
bottom_letters[letter_val] += 1;
}
else {
return 1;
}
}
for (i = 0; i < len_top; i++) {
letter_val = top[i]-96;
if (0 <= letter_val && letter_val <= 25) {
top_letters[letter_val] += 1;
}
else {
return 1;
}
}
for (i = 0; i < 26; i++ ) {
if (bottom_letters[i] < top_letters) {
return 0;
}
}
return 1;
}

6
src/fits.pyx

@ -0,0 +1,6 @@
cdef extern from "c_fits.c":
int _fits(char* bottom, int len_bottom, char* top, int len_top)
cpdef bint fits(str bottom, str top):
return _fits(bottom.encode(), len(bottom), top.encode(), len(top)) == 0

candidate_cache.py → wordscape/candidate_cache.py

dictionary.py → wordscape/dictionary.py

main.py → wordscape/main.py

word_remove_dialog.py → wordscape/word_remove_dialog.py

Loading…
Cancel
Save