Skip to content
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

Continuous update of the pileup availability #11884

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/python/Utils/FileTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,45 @@

import io
import os
import glob
import stat
import subprocess
import time
import zlib

from Utils.Utilities import decodeBytesToUnicode


def findFiles(path, pat):
"""
Find files within given path and matching given pattern.
:param path: starting directory path (string)
:param pat: match pattern (string), e.g. *.py or name of the file
:return: matched file names
"""
files = []
for idir, _, _ in os.walk(path):
files.extend(glob.glob(os.path.join(idir, pat)))
return files


def tarMode(tfile, opMode):
"""
Extract proper mode of operation for given tar file. For instance,
if op='r' and tfile name is file.tar.gz we should get 'r:gz',
while if tfile name is file.tar.bz2 we should get 'r':bz2', while
if tfile name is file.tar we should get 'r', etc.
:param opMode: mode of operation (string), e.g. 'r', or 'w'
:param tfile: sandbox tar file name (string)
:return: mode of operation
"""
ext = tfile.split(".")[-1]
if ext == 'tar':
return opMode
mode = opMode + ':' + ext
return mode


def calculateChecksums(filename):
"""
_calculateChecksums_
Expand Down Expand Up @@ -108,6 +140,7 @@ def findMagicStr(filename, matchString):
if matchString in line:
yield line


def getFullPath(name, envPath="PATH"):
"""
:param name: file name
Expand Down
Loading