Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix doc/scripts/sync_to_translation_status.er and update some actions #508

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

toddlerer
Copy link
Contributor

I encountered a bug that seemed to be caused by non-intuitive behavior of default arguments when using a recursive function in Python, so I fixed it by switching to a for loop.

@mtshiba

@mtshiba
Copy link
Member

mtshiba commented Apr 30, 2024

Although not directly related to this PR, I enhanced the type definitions of os.path and added a method called Str.from that does the same thing as Python's self[nth:].
So, mylib.{d.er, py} should no longer be necessary from the next release, which will be released next week.

@toddlerer
Copy link
Contributor Author

@mtshiba
Thank you for your prompt response. I tried replacing mylib.{d.er, py} with the latest commit on the main branch, and I was able to replace almost everything. However, I couldn't replace the parts using __file__, and it seems that __file__ is not available when running with erg run. (It worked when I transpiled with erg transpile and then ran the Python file.)

print! __file__
$ erg test.er    
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "test.er", line -1, in <module>
NameError: name '__file__' is not defined. Did you mean: '__name__'?

In this case, I am using it to obtain the directory of the currently executing file and set it as the current directory.

os = pyimport "os"

cwd = os.path.dirname! __file__
os.chdir! cwd

@mtshiba mtshiba mentioned this pull request May 1, 2024
@mtshiba
Copy link
Member

mtshiba commented May 3, 2024

@mtshiba Thank you for your prompt response. I tried replacing mylib.{d.er, py} with the latest commit on the main branch, and I was able to replace almost everything. However, I couldn't replace the parts using __file__, and it seems that __file__ is not available when running with erg run. (It worked when I transpiled with erg transpile and then ran the Python file.)

print! __file__
$ erg test.er    
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "test.er", line -1, in <module>
NameError: name '__file__' is not defined. Did you mean: '__name__'?

In this case, I am using it to obtain the directory of the currently executing file and set it as the current directory.

os = pyimport "os"

cwd = os.path.dirname! __file__
os.chdir! cwd

I believe this bug has been fixed in the main branch.

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.

2 participants