-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathlaw_wlcg.py
40 lines (27 loc) · 1.02 KB
/
law_wlcg.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# coding: utf-8
"""
WLCG remote file system and targets.
"""
__all__ = ["WLCGFileSystem", "WLCGTarget", "WLCGFileTarget", "WLCGDirectoryTarget"]
import law
from law.target.remote import RemoteFileSystem, RemoteTarget, RemoteFileTarget, RemoteDirectoryTarget
from law.logger import get_logger
logger = get_logger(__name__)
from .law_gfal import GFALFileInterface
from .grid_tools import path_to_pfn
class WLCGFileSystem(RemoteFileSystem):
def __init__(self, base, ls_cache_validity_period=60):
if type(base) is str:
base = [base]
base_pfns = [path_to_pfn(b) for b in base]
file_interface = GFALFileInterface(base_pfns)
super(WLCGFileSystem, self).__init__(file_interface)
class WLCGTarget(RemoteTarget):
def __init__(self, path, fs, **kwargs):
RemoteTarget.__init__(self, path, fs, **kwargs)
class WLCGFileTarget(WLCGTarget, RemoteFileTarget):
pass
class WLCGDirectoryTarget(WLCGTarget, RemoteDirectoryTarget):
pass
WLCGTarget.file_class = WLCGFileTarget
WLCGTarget.directory_class = WLCGDirectoryTarget