-
Notifications
You must be signed in to change notification settings - Fork 5
initial prototype of decorator is in progress #175
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
base: master
Are you sure you want to change the base?
Conversation
fixes #122 |
Also added the ability to get the name of attachment files without downloading any data. fixes #125 |
hmm interesting! I think it would be nice to print out only the last results, but show the rest of traces if users want to see them i.e. we can fold the rest and users can expand it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great overall! Didn't imagine this could be this simple & clean. Just left a few comments & suggestion
return False | ||
|
||
class CustomProperty(object): | ||
"Emulate PyProperty_Type() in Objects/descrobject.c" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a comment?
c=class_name, p=property_name, v=value) | ||
_set_in_log(obj, False) | ||
|
||
if not property_name.startswith("_"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this if statement right after property_name = _get_method_name(self.fget)
so we can do early-exit?
self.fset(obj, new_value) | ||
_set_in_log(obj, False) | ||
|
||
if not property_name.startswith("_"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repeating: Can we move this if statement right after property_name = _get_method_name(self.fget)
so we can do early-exit?
_get_logger().critical("HEEEEEEEEEEERE") | ||
user_property_log = obj._imap_client.user_property_log | ||
user_property_log.write(info) | ||
user_property_log.write(u"\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we are just appending logs in one string object. Can we make it more parse-able? Can we include additional information which line of user's code this property log generated from? For example,
def on_message(my_message):
if '😎' in my_message.subject and 'Luke Murray' == my_message.sender:
my_message.deadline = datetime.now()
this will be
{ 2: [{'type': 'get', 'log': 'Message.subject Testing Email 😎Yee'}, {'type': 'get', 'log': 'Message.sender [email protected]'}]
3: [{'type': 'set', 'log': 'Message.deadline None -> 2019-05-25 17:08:53.215517'}]
These are the initial semantics.
Getter Format
get {ClassName}.{PropertyName}\t{value}
Setter Format
set {ClassName}.{PropertyName}\t{oldValue} -> {newValue}
We do not log access for any properties whose name starts with underscore since these are "hidden".
We do not log anything which is touched while accessing the initial property. A simple example of when this occurs is Message.sender. Our code for Message.sender returns Message.from_. Without hiding nested logs we would log a getter for Message.sender and a getter for Message.from_. With the hiding we only log a getter for Message.sender.
Here is some code and an example of the output which looks good.
output
Now consider the following example. We have one line but we get two lines of logged output. This is because we are accessing two properties in a row. First we get the sender then we get the name. @soyapark maybe you have some insight about what we want to do here.
output
Right now these features are only implemented in the simulation code not in the regular interpret code.
The current state of the code for this feature is very poor but the semantics are interesting.