Skip to content

fixed some deprecated functions#2

Open
eemberda wants to merge 1 commit intorjrequina:masterfrom
eemberda:master
Open

fixed some deprecated functions#2
eemberda wants to merge 1 commit intorjrequina:masterfrom
eemberda:master

Conversation

@eemberda
Copy link
Copy Markdown

A. Fixed the following error by replacing from utilities import read_file to from .utilities import read_file:

      1 import string
----> 2 from utilities import read_file
      5 '''
      6 Get the dictionary entries
      7 '''
      8 def get_entries():

ModuleNotFoundError: No module named 'utilities'

B. When using directly or when installing through pip, the code will give the following error

FileNotFoundError: [Errno 2] No such file or directory: '<your_python_directory>data/cebposdict.txt'

This was caused by the following code under utilities.py:
nam = sys.prefix + '/' + name

To solve this, the following code was necessary:

__location__ = os.path.realpath(
    os.path.join(os.getcwd(), os.path.dirname(__file__)))

Then, the line
name = sys.prefix + '/' + name
is replaced with
name = os.path.join(__location__,name)

C. Fixed str replace

>>> print(dictionary.is_entry('buang'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<Your_Folder>/Cebuano-Dictionary/cebdict/dictionary.py", line 50, in is_entry
    term = term.replace(term, 'o', 'u')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'str' object cannot be interpreted as an integer

the replace function in python 3.12 only has 2 parameters. So,
term = term.replace(term, 'o', 'u') becomes term = term.replace('o', 'u')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant