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

AttributeError: 'str' object has no attribute 'removeprefix' #27

Closed
madzic opened this issue May 23, 2021 · 10 comments
Closed

AttributeError: 'str' object has no attribute 'removeprefix' #27

madzic opened this issue May 23, 2021 · 10 comments

Comments

@madzic
Copy link

madzic commented May 23, 2021

Hey man, love the idea, this is what I was looking for for a long time.
Encountering this issue when trying to run the module:
Traceback (most recent call last):
File "D:\Python38\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "D:\Python38\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "D:\Python38\lib\site-packages\kindle2notion_main
.py", line 31, in
main()
File "D:\Python38\lib\site-packages\click\core.py", line 1134, in call
return self.main(*args, **kwargs)
File "D:\Python38\lib\site-packages\click\core.py", line 1059, in main
rv = self.invoke(ctx)
File "D:\Python38\lib\site-packages\click\core.py", line 1401, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "D:\Python38\lib\site-packages\click\core.py", line 767, in invoke
return _callback(*args, **kwargs)
File "D:\Python38\lib\site-packages\kindle2notion_main
.py", line 25, in main
books = parse_raw_clippings_text(all_clippings)
File "D:\Python38\lib\site-packages\kindle2notion\parsing.py", line 18, in parse_raw_clippings_text
author, title = _parse_author_and_title(raw_clipping_list)
File "D:\Python38\lib\site-packages\kindle2notion\parsing.py", line 35, in _parse_author_and_title
author, title = _parse_raw_author_and_title(raw_clipping_list)
File "D:\Python38\lib\site-packages\kindle2notion\parsing.py", line 69, in _parse_raw_author_and_title
author = author.removeprefix('(').removesuffix(')')
AttributeError: 'str' object has no attribute 'removeprefix'

Any help? Thanks.

@madzic
Copy link
Author

madzic commented May 23, 2021

I found your answer to other issue and upgraded Python to 3.9.
Now I have the following issue:
Traceback (most recent call last):
File "D:\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "D:\Python39\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "D:\Python39\lib\site-packages\kindle2notion_main
.py", line 31, in
main()
File "D:\Python39\lib\site-packages\click\core.py", line 1134, in call
return self.main(*args, **kwargs)
File "D:\Python39\lib\site-packages\click\core.py", line 1059, in main
rv = self.invoke(ctx)
File "D:\Python39\lib\site-packages\click\core.py", line 1401, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "D:\Python39\lib\site-packages\click\core.py", line 767, in invoke
return _callback(*args, **kwargs)
File "D:\Python39\lib\site-packages\kindle2notion_main
.py", line 25, in main
books = parse_raw_clippings_text(all_clippings)
File "D:\Python39\lib\site-packages\kindle2notion\parsing.py", line 18, in parse_raw_clippings_text
author, title = _parse_author_and_title(raw_clipping_list)
File "D:\Python39\lib\site-packages\kindle2notion\parsing.py", line 36, in _parse_author_and_title
author, title = _deal_with_exceptions_in_author_name(author, title)
File "D:\Python39\lib\site-packages\kindle2notion\parsing.py", line 79, in _deal_with_exceptions_in_author_name
last_name, first_name = author.split(', ')
ValueError: too many values to unpack (expected 2)

Any help? Thanks.

@paperboi
Copy link
Owner

I found your answer to other issue and upgraded Python to 3.9.
Now I have the following issue:
Traceback (most recent call last):
File "D:\Python39\lib\runpy.py", line 197, in _run_module_as_main
return run_code(code, main_globals, None,
File "D:\Python39\lib\runpy.py", line 87, in run_code exec(code, run_globals) File "D:\Python39\lib\site-packages\kindle2notion__main
.py", line 31, in
main()
File "D:\Python39\lib\site-packages\click\core.py", line 1134, in call
return self.main(*args, **kwargs)
File "D:\Python39\lib\site-packages\click\core.py", line 1059, in main
rv = self.invoke(ctx)
File "D:\Python39\lib\site-packages\click\core.py", line 1401, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "D:\Python39\lib\site-packages\click\core.py", line 767, in invoke
return callback(*args, **kwargs) File "D:\Python39\lib\site-packages\kindle2notion__main.py", line 25, in main
books = parse_raw_clippings_text(all_clippings)
File "D:\Python39\lib\site-packages\kindle2notion\parsing.py", line 18, in parse_raw_clippings_text
author, title = _parse_author_and_title(raw_clipping_list)
File "D:\Python39\lib\site-packages\kindle2notion\parsing.py", line 36, in _parse_author_and_title
author, title = _deal_with_exceptions_in_author_name(author, title)
File "D:\Python39\lib\site-packages\kindle2notion\parsing.py", line 79, in _deal_with_exceptions_in_author_name
last_name, first_name = author.split(', ')
ValueError: too many values to unpack (expected 2)

Any help? Thanks.

Hi, can you try posting the last book that appeared in your output before this error showed up? It may something to do with a book not having an author listed at all.

@crisdias
Copy link

I have the same problem and I have no books showing on my output. (is there a "verbose" option I should be using to get this info?)

Many books in my Clippings file don't follow a "Last, First" author structure.
e.g.: Legion Skin Deep (Brandon Sanderson)
(this is the first line of my clippings file)

Hope that helps.

@yoshihiko-k
Copy link

@paperboi
I stumbled upon the same thing.
Please update the minimum python version described in Setup.py.

setup.py

python_requires='>=3.9',

@paperboi
Copy link
Owner

@paperboi
I stumbled upon the same thing.
Please update the minimum python version described in Setup.py.

setup.py

python_requires='>=3.9',

Noted. Will address it in the next commit and release.

@paperboi
Copy link
Owner

I have the same problem and I have no books showing on my output. (is there a "verbose" option I should be using to get this info?)

Many books in my Clippings file don't follow a "Last, First" author structure.
e.g.: Legion Skin Deep (Brandon Sanderson)
(this is the first line of my clippings file)

Hope that helps.

I realized I haven't fully taken into account of the non-ASCII characters that sometimes appear when reading the clippings file in UTF-8 encoding. I assume this error came up because of it. Found a solution to this- will post a new release soon and update you here.

paperboi added a commit that referenced this issue May 25, 2021
paperboi added a commit that referenced this issue May 25, 2021
@madzic
Copy link
Author

madzic commented May 25, 2021

I found your answer to other issue and upgraded Python to 3.9.
Now I have the following issue:
Traceback (most recent call last):
File "D:\Python39\lib\runpy.py", line 197, in _run_module_as_main
return run_code(code, main_globals, None,
File "D:\Python39\lib\runpy.py", line 87, in run_code exec(code, run_globals) File "D:\Python39\lib\site-packages\kindle2notion__main
.py", line 31, in
main()
File "D:\Python39\lib\site-packages\click\core.py", line 1134, in call
return self.main(*args, **kwargs)
File "D:\Python39\lib\site-packages\click\core.py", line 1059, in main
rv = self.invoke(ctx)
File "D:\Python39\lib\site-packages\click\core.py", line 1401, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "D:\Python39\lib\site-packages\click\core.py", line 767, in invoke
return **callback(*args, kwargs) File "D:\Python39\lib\site-packages\kindle2notion__main.py", line 25, in main
books = parse_raw_clippings_text(all_clippings)
File "D:\Python39\lib\site-packages\kindle2notion\parsing.py", line 18, in parse_raw_clippings_text
author, title = _parse_author_and_title(raw_clipping_list)
File "D:\Python39\lib\site-packages\kindle2notion\parsing.py", line 36, in _parse_author_and_title
author, title = _deal_with_exceptions_in_author_name(author, title)
File "D:\Python39\lib\site-packages\kindle2notion\parsing.py", line 79, in _deal_with_exceptions_in_author_name
last_name, first_name = author.split(', ')
ValueError: too many values to unpack (expected 2)
Any help? Thanks.

Hi, can you try posting the last book that appeared in your output before this error showed up? It may something to do with a book not having an author listed at all.

Hi man, thanks for the reply.
No books appeared in Notion and the first book has the author (Cabane, Olivia Fox).
Thanks again.

@paperboi
Copy link
Owner

Hi, can you update to the new release and run the commands again? It should work now.
pip install kindle2notion==0.1.3

@madzic
Copy link
Author

madzic commented May 30, 2021

Works like a charm, thank you! Will buy you a coffee for this, thanks!

@madzic madzic closed this as completed May 30, 2021
@paperboi
Copy link
Owner

@madzic Glad to hear that! Thanks a lot!

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

No branches or pull requests

4 participants