Skip to content

Commit

Permalink
Merge pull request #11884 from vkuznet/fix-issue-11619
Browse files Browse the repository at this point in the history
Continuous update of the pileup availability
  • Loading branch information
amaltaro committed Feb 26, 2024
2 parents 52ae759 + fc23c16 commit a4bc374
Show file tree
Hide file tree
Showing 8 changed files with 628 additions and 5 deletions.
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

0 comments on commit a4bc374

Please sign in to comment.