mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 15:43:32 +01:00
Improve fname_is_c func in pratracker/includes.py
Use tuples for bname.startswith and fname.endswith in "fname_is_c" function.
This commit is contained in:
parent
8ead53330c
commit
e5b234e358
@ -40,11 +40,13 @@ def warn(msg):
|
|||||||
print(msg, file=sys.stderr)
|
print(msg, file=sys.stderr)
|
||||||
|
|
||||||
def fname_is_c(fname):
|
def fname_is_c(fname):
|
||||||
""" Return true iff 'fname' is the name of a file that we should
|
"""
|
||||||
search for possibly disallowed #include directives. """
|
Return true if 'fname' is the name of a file that we should
|
||||||
if fname.endswith(".h") or fname.endswith(".c"):
|
search for possibly disallowed #include directives.
|
||||||
|
"""
|
||||||
|
if fname.endswith((".c", ".h")):
|
||||||
bname = os.path.basename(fname)
|
bname = os.path.basename(fname)
|
||||||
return not (bname.startswith(".") or bname.startswith("#"))
|
return not bname.startswith((".", "#"))
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user