File: account.py

package info (click to toggle)
python-irodsclient 3.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,352 kB
  • sloc: python: 16,650; xml: 525; sh: 104; awk: 5; sql: 3; makefile: 3
file content (56 lines) | stat: -rw-r--r-- 1,663 bytes parent folder | download
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from irods import derived_auth_filename


class iRODSAccount:

    @property
    def derived_auth_file(self):
        return derived_auth_filename(self.env_file)

    def __init__(
        self,
        irods_host,
        irods_port,
        irods_user_name,
        irods_zone_name,
        irods_authentication_scheme="native",
        password=None,
        client_user=None,
        server_dn=None,
        client_zone=None,
        env_file="",
        **kwargs
    ):

        # Allowed overrides when cloning sessions. (Currently hostname only.)
        for k, v in kwargs.pop("_overrides", {}).items():
            if k == "irods_host":
                irods_host = v

        self.env_file = env_file
        tuplify = lambda _: _ if isinstance(_, (list, tuple)) else (_,)
        schemes = [_.lower() for _ in tuplify(irods_authentication_scheme)]

        self._original_authentication_scheme = schemes[-1]
        self.authentication_scheme = schemes[0]

        self.host = irods_host
        self.port = int(irods_port)
        self.proxy_user = self.client_user = irods_user_name
        self.proxy_zone = self.client_zone = irods_zone_name
        self.server_dn = server_dn
        self.password = password

        for key, value in kwargs.items():
            try:
                if key.startswith("irods_"):
                    setattr(self, key[6:], value)
                else:
                    setattr(self, key, value)
            except TypeError:
                setattr(self, key, value)

        if client_user:
            self.client_user = client_user
            if client_zone:
                self.client_zone = client_zone