Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

FIX: compatibility with Python v2.x #9

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open

Conversation

nnako
Copy link

@nnako nnako commented Mar 29, 2018

modified some bits in order to make the code run on Python v2.x (checked with v2.7). Imported the standard module "io" which provides unicode character handling for Python v2 and v3 in the same way. Additionally, the call of the function "super()" had to be modified in order to fit both Python versions. Some cosmetics regarding the function comments were made to facilitate better standard folding within editors.

MOD: some cosmetics regarding folding of function comments
todotxtio.py Outdated
@@ -1,5 +1,9 @@
#!/usr/bin/python
Copy link
Owner

@EpocDotFr EpocDotFr Mar 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file isn't meant to be executable. What is the purpose of this line?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm... I always create my librarys so that in the end, they can be used as libraries AND can be executed as standalone tools (where this makes sense). So, you are right, here the line makes no sense, yet.

todotxtio.py Outdated

:param str string: The string to parse
:rtype: list
"""

# init
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry but the comments you added in this function doesn't add any useful information, given the statements are simple enough to understand. Please remove them.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right. the comments don't add any functionality. It is just a question of style and readability in general (which is in the end a question of personal taste). I can remove it.

@EpocDotFr
Copy link
Owner

EpocDotFr commented Mar 29, 2018

Hi, thank you for your interest in Todo.txt I/O!

I added some comments in your PR. Once they'll be addressed, this PR will be ready to be merged and a new version of Todo.txt I/O will be released. Also please create a contributors list in the readme (like here) then add yourself as well as what you done in a few words.

@EpocDotFr
Copy link
Owner

Also please update the docs (saying it's also compatible with Python 2) as well as the setup.py.

todotxtio.py Outdated
@@ -85,43 +114,57 @@ def from_string(string):
if todo_pre_data.group(2):
todo.completion_date = todo_pre_data.group(2)
else:
todo.creation_date = todo_pre_data.group(2)
todo.creation_date = todo_pre_data.group(4)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that's working ATM, maybe the regex is wrong. Better check the regex first. Anyway I never had issues with creation dates.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please check with the following code (just open the Python interpreter and paste the code in. I did it for both, Python v2.7 and Python v3.6):

import re
todo_data_regex = re.compile( \
    '^(?:(x) )?' + \
    '(?:(\d{4}-\d{2}-\d{2}) )?' + \
    '(?:\(([A-Z])\) )?' + \
    '(?:(\d{4}-\d{2}-\d{2}) )?' \
    )
match = todo_data_regex.match( \
    '(A) 2018-03-28 an unfinished task created at 2018-03-28 +TestProject @Home due:2018-03-29')
print( \
    'the complete prefix: ' + str(match.group(0)) + '\n' + \
    'the COMPLETED FLAG:  ' + str(match.group(1)) + '\n' + \
    'the COMPLETED DATE:  ' + str(match.group(2)) + '\n' + \
    'the PRIORITY:        ' + str(match.group(3)) + '\n' + \
    'the CREATION DATE:   ' + str(match.group(4)) \
    )

in both versions, the creation date should appear in match.group(4) . When inserting a COMPLETED TASK in the code above, the creation date appears in match.group(4) as well. As I understand RegEx there, the algorithm should not differ with a changed input string.

Kohn, Dr. Peter Nnamdi (TM-D) and others added 15 commits July 24, 2019 18:15
…e can be handled

FIX: __setattr__() function now handles persons and remarks as well
MOD: rename "author" -> "authors" and "responsible" -> "responsibles" as they are lists
…cters instilled e.g. by GitLab

     special characters following the plus sign will skip the element
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants