mirror of
https://github.com/facebook/zstd.git
synced 2025-07-30 22:23:13 +03:00
Change tabsize
This commit is contained in:
@ -12,34 +12,34 @@ import sys
|
|||||||
|
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
print('usage: python3 GetZstdLibraryVersion.py <path/to/zstd.h>')
|
print('usage: python3 GetZstdLibraryVersion.py <path/to/zstd.h>')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def find_version(filepath):
|
def find_version(filepath):
|
||||||
version_file_data = None
|
version_file_data = None
|
||||||
with open(filepath) as fd:
|
with open(filepath) as fd:
|
||||||
version_file_data = fd.read()
|
version_file_data = fd.read()
|
||||||
|
|
||||||
patterns = r"""#\s*define\s+ZSTD_VERSION_MAJOR\s+([0-9]+)
|
patterns = r"""#\s*define\s+ZSTD_VERSION_MAJOR\s+([0-9]+)
|
||||||
#\s*define\s+ZSTD_VERSION_MINOR\s+([0-9]+)
|
#\s*define\s+ZSTD_VERSION_MINOR\s+([0-9]+)
|
||||||
#\s*define\s+ZSTD_VERSION_RELEASE\s+([0-9]+)
|
#\s*define\s+ZSTD_VERSION_RELEASE\s+([0-9]+)
|
||||||
"""
|
"""
|
||||||
regex = re.compile(patterns, re.MULTILINE)
|
regex = re.compile(patterns, re.MULTILINE)
|
||||||
version_match = regex.search(version_file_data)
|
version_match = regex.search(version_file_data)
|
||||||
if version_match:
|
if version_match:
|
||||||
return version_match.groups()
|
return version_match.groups()
|
||||||
raise RuntimeError("Unable to find version string.")
|
raise RuntimeError("Unable to find version string.")
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
usage()
|
usage()
|
||||||
|
|
||||||
filepath = sys.argv[1]
|
filepath = sys.argv[1]
|
||||||
version_tup = find_version(filepath)
|
version_tup = find_version(filepath)
|
||||||
print('.'.join(version_tup))
|
print('.'.join(version_tup))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Reference in New Issue
Block a user