-
Notifications
You must be signed in to change notification settings - Fork 194
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
Add Feature: Printing Absolute Path in Context #122
Conversation
Anyway, this LGTM. @gruns any general thoughts? |
Co-authored-by: Alex Hall <[email protected]>
@HelinXu please rename the @alexmojaki zooming out, i think replacing the we could then provide a pre-built function that replicates the current behavior. something like from icecream import ic, createPrefixFn
_formatPrefix = createPrefixFn(prefix='ic |', includeContext=True, contextAbsPath=True)
ic.prefixFn = _formatPrefix conversely we could also just improve the documentation so people feel its easier to subclass thoughts? |
…via the parameter
Done. Thanks for the advice 🙌 |
awesome. thank you, @HelinXu! last step is to add appropriate tests for see https://github.com/gruns/icecream/blob/master/tests/test_icecream.py#L440-L468 for how with tests, ill merge your amazing work here! 🙌 |
Sure, I'm working on that. One more thing, there're actually two slightly different handlings when it comes to absolute path, i.e. def abspath(path):
"""Return an absolute path."""
path = os.fspath(path)
if not isabs(path):
if isinstance(path, bytes):
cwd = os.getcwdb()
else:
cwd = os.getcwd()
path = join(cwd, path)
return normpath(path)
# Return a canonical path (i.e. the absolute location of a file on the
# filesystem).
def realpath(filename):
"""Return the canonical path of the specified filename, eliminating any
symbolic links encountered in the path."""
filename = os.fspath(filename)
path, ok = _joinrealpath(filename[:0], filename, {})
return abspath(path) I'm using |
tests added :)
I've written |
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.
I've resolved the unattended TODO and have modified MYFILEPATH according to the latest commit. Sorry for the carelessness XD
merged! 🎉 thank you for your wonderful suggestion and, most importantly, your wonderful PR, @HelinXu 🙌 |
Hi, I'm curious if 2.1.3 is to be released soon, as I was kind of hoping to use this new feature :)
在2022-06-11 11:55:29,Ansgar ***@***.***写道:
merged! 🎉
thank you for your wonderful suggestion and, most importantly, your wonderful PR, @HelinXu🙌
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
ic.configureOutput(includeContext=True, absPath=True)
absPath
, False by default, can be used to control whetheric()
's output includes the absolute path of the file whereic()
is called, providedincludeContext == True
. This is useful whenic()
is called from multiple files in a project, with files potentially having same names but different paths. Moreover, for most editors such as VSCode, a clickable link to the line whereic()
is called is provided. E.g. a click on/absolute/path/to/example.py:12
brings you to the line of the debugging call. It is really handy when you have debugging outputs from multiple files and want to easily jump to the line where the debugging call is made.